Commit c35dcdd00512fef7c644adaab6e984e91d3d3dc0
1 parent
1a9aa427
Exists in
master
and in
5 other branches
Implementando chamadas HLLAPI
Showing
3 changed files
with
48 additions
and
6 deletions
Show diff stats
src/plugins/hllapi/calls.c
... | ... | @@ -461,3 +461,17 @@ |
461 | 461 | #warning Implementar |
462 | 462 | return -1; |
463 | 463 | } |
464 | + | |
465 | + char * hllapi_get_string(int offset, size_t len) | |
466 | + { | |
467 | + if(!(get_text_at_offset && hSession)) | |
468 | + return NULL; | |
469 | + | |
470 | + return get_text_at_offset(hSession,offset-1,len); | |
471 | + } | |
472 | + | |
473 | + void hllapi_free(void *p) | |
474 | + { | |
475 | + if(release_memory) | |
476 | + release_memory(p); | |
477 | + } | ... | ... |
src/plugins/hllapi/client.h
src/plugins/hllapi/hllapi.c
... | ... | @@ -316,15 +316,34 @@ static int search_ps(char *buffer, unsigned short *length, unsigned short *ps) |
316 | 316 | * 24 The search string was not found. |
317 | 317 | * |
318 | 318 | */ |
319 | - size_t szBuffer = strlen(buffer); | |
319 | + size_t szBuffer = strlen(buffer); | |
320 | + char * text; | |
321 | + int rc = -1; | |
320 | 322 | |
321 | - if(*length < szBuffer) | |
323 | + if(*length < szBuffer) | |
322 | 324 | szBuffer = *length; |
325 | + | |
326 | + | |
327 | + text = hllapi_get_string(*ps,szBuffer); | |
328 | + if(!text) | |
329 | + return HLLAPI_STATUS_SYSTEM_ERROR; | |
330 | + | |
331 | + if(strncmp(text,buffer,szBuffer)) | |
332 | + { | |
333 | + // String not found | |
334 | + *ps = 0; | |
335 | + rc = 24; | |
336 | + } | |
337 | + else | |
338 | + { | |
339 | + // String found | |
340 | + *ps = 1; | |
341 | + rc = 0; | |
342 | + } | |
343 | + | |
344 | + hllapi_free(text); | |
323 | 345 | |
324 | - | |
325 | - #warning Implementar | |
326 | - | |
327 | - return HLLAPI_STATUS_SYSTEM_ERROR; | |
346 | + return rc; | |
328 | 347 | } |
329 | 348 | |
330 | 349 | static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) |
... | ... | @@ -338,6 +357,11 @@ static int copy_ps(char *buffer, unsigned short *length, unsigned short *rc) |
338 | 357 | * |
339 | 358 | * |
340 | 359 | */ |
360 | + size_t szBuffer = strlen(buffer); | |
361 | + | |
362 | + if(*length < szBuffer) | |
363 | + szBuffer = *length; | |
364 | + | |
341 | 365 | |
342 | 366 | #warning Implementar |
343 | 367 | ... | ... |