Return the specified INFO field from the INFO command output "info". * A new buffer is allocated for the result, that needs to be free'd. * If the field is not found NULL is returned. */
| 6810 | * A new buffer is allocated for the result, that needs to be free'd. |
| 6811 | * If the field is not found NULL is returned. */ |
| 6812 | static char *getInfoField(char *info, char *field) { |
| 6813 | char *p = strstr(info,field); |
| 6814 | char *n1, *n2; |
| 6815 | char *result; |
| 6816 | |
| 6817 | if (!p) return NULL; |
| 6818 | p += strlen(field)+1; |
| 6819 | n1 = strchr(p,'\r'); |
| 6820 | n2 = strchr(p,','); |
| 6821 | if (n2 && n2 < n1) n1 = n2; |
| 6822 | result = zmalloc(sizeof(char)*(n1-p)+1, MALLOC_LOCAL); |
| 6823 | memcpy(result,p,(n1-p)); |
| 6824 | result[n1-p] = '\0'; |
| 6825 | return result; |
| 6826 | } |
| 6827 | |
| 6828 | /* Like the above function but automatically convert the result into |
| 6829 | * a long. On error (missing field) LONG_MIN is returned. */ |
no test coverage detected