| 975 | } |
| 976 | |
| 977 | int tpl_set_section_from_file(tpl_t* tpl, const char* key, const char* filename) |
| 978 | { |
| 979 | int len, status; |
| 980 | tpl_node_t *node; |
| 981 | FILE *fp = fopen(filename, "rb"); |
| 982 | |
| 983 | if (fp == NULL) |
| 984 | return TPL_OPEN_ERROR; |
| 985 | |
| 986 | /* Find length of file content */ |
| 987 | (void)fseek(fp, 0, SEEK_END); |
| 988 | len = ftell(fp); |
| 989 | (void)rewind(fp); |
| 990 | |
| 991 | node = create_node(len); |
| 992 | |
| 993 | if (fread(node->val, 1, len, fp) < (unsigned)len) |
| 994 | status = TPL_READ_ERROR; |
| 995 | else |
| 996 | status = tpl_set_section_ex(tpl, key, node->val, len, node); |
| 997 | |
| 998 | (void)fclose(fp); |
| 999 | |
| 1000 | if (status != TPL_OK) |
| 1001 | destroy_node(node); |
| 1002 | |
| 1003 | return status; |
| 1004 | } |
| 1005 | |
| 1006 | |
| 1007 | int tpl_append_section(tpl_t* tpl) |
nothing calls this directly
no test coverage detected
searching dependent graphs…