|
|
| version 1.4, 2025/04/02 19:59:38 | version 1.5, 2025/04/09 19:52:02 |
|---|---|
| Line 25 | Line 25 |
| * along with FreeM. If not, see <https://www.gnu.org/licenses/>. | * along with FreeM. If not, see <https://www.gnu.org/licenses/>. |
| * | * |
| * $Log$ | * $Log$ |
| * Revision 1.5 2025/04/09 19:52:02 snw | |
| * Eliminate as many warnings as possible while building with -Wall | |
| * | |
| * Revision 1.4 2025/04/02 19:59:38 snw | * Revision 1.4 2025/04/02 19:59:38 snw |
| * Automatically modify env.conf from fmadm reconfigure | * Automatically modify env.conf from fmadm reconfigure |
| * | * |
| Line 68 extern char config_file[4096]; | Line 71 extern char config_file[4096]; |
| # include <sys/syslimits.h> | # include <sys/syslimits.h> |
| #endif | #endif |
| ini_keyvalue *ini_head; | /* ini_keyvalue *ini_head; */ |
| int get_conf(char *section, char *key, char *value) | int get_conf(char *section, char *key, char *value) |
| { | { |
| Line 278 int file_exists(char *filename) | Line 281 int file_exists(char *filename) |
| } | } |
| } | } |
| void write_profile_string(char *file, char *section, char *key, char *value) | |
| { | |
| ini_keyvalue *ini_head; | |
| } | |
| void parse_section_header(char *input, char *buf, size_t buflen) | void parse_section_header(char *input, char *buf, size_t buflen) |
| { | { |
| strncpy (buf, &(input[1]), buflen); | strncpy (buf, &(input[1]), buflen); |
| Line 294 int modify_profile_string(char *file, ch | Line 292 int modify_profile_string(char *file, ch |
| FILE *input_fp; | FILE *input_fp; |
| FILE *output_fp; | FILE *output_fp; |
| char output_filename[4096]; | char output_filename[4096]; |
| char input_line[255]; | char input_line[255]; |
| char output_line[255]; | |
| char current_section[255]; | char current_section[255]; |
| char *savptr; | char *savptr; |
| char *current_key; | char *current_key; |
| char *current_value; | |
| char tmpsi[255]; | char tmpsi[255]; |
| char tmps[255]; | char tmps[255]; |
| int changed = FALSE; | int changed = FALSE; |
| Line 332 int modify_profile_string(char *file, ch | Line 328 int modify_profile_string(char *file, ch |
| strcpy (tmpsi, input_line); | strcpy (tmpsi, input_line); |
| savptr = tmpsi; | savptr = tmpsi; |
| current_key = strtok_r (tmpsi, "=", &savptr); | current_key = strtok_r (tmpsi, "=", &savptr); |
| current_value = strtok_r (NULL, "=", &savptr); | |
| /* is this key the one we're changing? */ | /* is this key the one we're changing? */ |
| if (strcmp (key, current_key) == 0) { | if (strcmp (key, current_key) == 0) { |
| /* yes; modify it and write out*/ | /* yes; modify it and write out*/ |
| Line 376 int modify_profile_string(char *file, ch | Line 371 int modify_profile_string(char *file, ch |
| } | } |
| ini_keyvalue *ini_insert(ini_section *s, char *section, char *key, char *value) | |
| { | |
| ini_section *t; | |
| for (t = s; t != NULL; t = t->next) { | |
| if (strcmp (t->name, section) == 0) { | |
| /* this section already exists. update. */ | |
| return ini_kv_insert (s, key, value); | |
| } | |
| } | |
| /* section does not exist. insert. */ | |
| t = (ini_section *) malloc (sizeof (ini_section)); | |
| NULLPTRCHK(t,"ini_insert"); | |
| t->name = (char *) malloc ((strlen (section) + 1) * sizeof (char)); | |
| NULLPTRCHK(t->name,"ini_insert"); | |
| strcpy (t->name, section); | |
| t->next = s; | |
| s = t; | |
| return ini_kv_insert (s, key, value); | |
| } | |
| ini_keyvalue *ini_kv_insert(ini_section *s, char *key, char *value) | |
| { | |
| ini_keyvalue *t; | |
| for (t = s->head; t != NULL; t = t->next) { | |
| if (strcmp (t->key, key) == 0) { | |
| /* this is an update */ | |
| free (t->value); | |
| t->value = (char *) malloc ((strlen (value) + 1) * sizeof (char)); | |
| NULLPTRCHK(t->value,"ini_kv_insert"); | |
| strcpy (t->value, value); | |
| return t; | |
| } | |
| } | |
| /* this is an insert */ | |
| t = (ini_keyvalue *) malloc (sizeof (ini_keyvalue)); | |
| NULLPTRCHK(t,"ini_kv_insert"); | |
| t->key = (char *) malloc ((strlen (key) + 1) * sizeof (char)); | |
| NULLPTRCHK(t->key,"ini_kv_insert"); | |
| t->value = (char *) malloc ((strlen (value) + 1) * sizeof (char)); | |
| NULLPTRCHK(t->value,"ini_kv_insert"); | |
| strcpy (t->key, key); | |
| strcpy (t->value, value); | |
| t->next = s->head; | |
| s->head = t; | |
| return t; | |
| } | |
| void ini_section_delete(ini_section *head, char *name) | |
| { | |
| ini_section *t = head; | |
| ini_section *p = NULL; | |
| if ((t != (ini_section *) NULL) && (strcmp (t->name, name) == 0)) { | |
| head = t->next; | |
| free (t->name); | |
| free (t); | |
| return; | |
| } | |
| while ((t != NULL) && (strcmp (t->name, name) != 0)) { | |
| p = t; | |
| t = t->next; | |
| } | |
| if (t == NULL) return; | |
| free (t->name); | |
| free (t); | |
| return; | |
| } | |
| void ini_key_delete(ini_section *head, char *key) | |
| { | |
| } |