| 351 | } |
| 352 | |
| 353 | struct proc_properties * get_properties(const char * uuid, processor_context * ctx) { |
| 354 | struct proc_properties * props = get_processor_properties(uuid); |
| 355 | if (props) { |
| 356 | return props; |
| 357 | } |
| 358 | |
| 359 | char file_path[4096]; |
| 360 | char delimiter[3]; |
| 361 | |
| 362 | if (get_property(ctx, "file_path", file_path, sizeof(file_path)) != 0) { |
| 363 | return props; |
| 364 | } |
| 365 | |
| 366 | if (get_property(ctx, "delimiter", delimiter, sizeof(delimiter)) != 0) { |
| 367 | printf("No delimiter found\n"); |
| 368 | return props; |
| 369 | } |
| 370 | |
| 371 | if (strlen(delimiter) == 0) { |
| 372 | printf("Delimiter not specified or it is empty\n"); |
| 373 | return props; |
| 374 | } |
| 375 | |
| 376 | props = (struct proc_properties *)malloc(sizeof(struct proc_properties)); |
| 377 | memset(props, 0, sizeof(struct proc_properties)); |
| 378 | |
| 379 | char delim = delimiter[0]; |
| 380 | |
| 381 | if (delim == '\\') { |
| 382 | if (strlen(delimiter) > 1) { |
| 383 | switch (delimiter[1]) { |
| 384 | case 'r': |
| 385 | delim = '\r'; |
| 386 | break; |
| 387 | case 't': |
| 388 | delim = '\t'; |
| 389 | break; |
| 390 | case 'n': |
| 391 | delim = '\n'; |
| 392 | break; |
| 393 | case '\\': |
| 394 | delim = '\\'; |
| 395 | break; |
| 396 | default: |
| 397 | break; |
| 398 | } |
| 399 | } |
| 400 | } |
| 401 | |
| 402 | int len = strlen(file_path); |
| 403 | props->file_path = (char *)malloc((len + 1) * sizeof(char)); |
| 404 | strncpy(props->file_path, file_path, len); |
| 405 | props->file_path[len] = '\0'; |
| 406 | props->delimiter = delim; |
| 407 | |
| 408 | add_processor_properties(uuid, props); |
| 409 | return props; |
| 410 | } |
no test coverage detected