# HG changeset patch # User Matti Hamalainen # Date 1306019442 -10800 # Node ID 0db02b8d2d11b03ef36ad0cb4958a2c52ff0b2b5 # Parent e97c764927ce45e2d2a9e68ce56f31cddf21ffec ISO C99 compatibility fixes. diff -r e97c764927ce -r 0db02b8d2d11 th_config.c --- a/th_config.c Fri May 06 03:34:52 2011 +0300 +++ b/th_config.c Sun May 22 02:10:42 2011 +0300 @@ -27,7 +27,7 @@ cfgitem_t *next = curr->next; if (curr->type == ITEM_SECTION) - th_cfg_free((cfgitem_t *) curr->data); + th_cfg_free((cfgitem_t *) curr->v.data); th_free(curr->name); th_free(curr); @@ -52,7 +52,7 @@ /* Set values */ node->type = type; - node->data = data; + node->v.data = data; node->name = th_strdup(name); /* Insert into linked list */ @@ -447,7 +447,7 @@ "Unexpected character '%c', section start '{' was expected.\n", c); parseMode = PM_ERROR; } else { - int res = th_cfg_read_sect(f, (cfgitem_t *) item->data, nesting + 1); + int res = th_cfg_read_sect(f, item->v.section, nesting + 1); c = -1; if (res > 0) validError = TRUE; @@ -473,17 +473,17 @@ switch (item->type) { case ITEM_HEX_TRIPLET: - *(int *) item->data = th_get_hex_triplet(tmpStr); + *(item->v.val_int) = th_get_hex_triplet(tmpStr); prevMode = parseMode; parseMode = PM_NORMAL; break; case ITEM_STRING: - th_pstrcpy((char **) item->data, tmpStr); + th_pstrcpy(item->v.val_str, tmpStr); prevMode = parseMode; parseMode = PM_NORMAL; break; case ITEM_STRING_LIST: - th_llist_append(item->list, th_strdup(tmpStr)); + th_llist_append(item->v.list, th_strdup(tmpStr)); prevMode = parseMode; parseMode = PM_NEXT; nextMode = PM_ARRAY; @@ -527,11 +527,11 @@ tmpStr[strPos] = 0; switch (item->type) { case ITEM_INT: - *((int *) item->data) = atoi(tmpStr); + *(item->v.val_int) = atoi(tmpStr); break; case ITEM_UINT: - *((unsigned int *) item->data) = atol(tmpStr); + *(item->v.val_uint) = atol(tmpStr); break; } @@ -586,7 +586,7 @@ th_cfg_error(f, "Invalid boolean value for '%s'.\n", item->name); parseMode = PM_ERROR; } else { - *((BOOL *) item->data) = tmpBool; + *(item->v.val_bool) = tmpBool; prevMode = parseMode; parseMode = PM_NORMAL; @@ -644,22 +644,22 @@ switch (item->type) { case ITEM_STRING: - if (*(item->val_str) == NULL) { + if (*(item->v.val_str) == NULL) { if (fprintf(f->file, "#%s = \"\"\n", item->name) < 0) return -3; } else { if (fprintf(f->file, "%s = \"%s\"\n", - item->name, *(item->val_str)) < 0) + item->name, *(item->v.val_str)) < 0) return -3; } break; case ITEM_STRING_LIST: - if (*(item->list) == NULL) { + if (*(item->v.list) == NULL) { if (fprintf(f->file, "#%s = \"\", \"\"\n", item->name) < 0) return -3; } else { - qlist_t *node = *(item->list); + qlist_t *node = *(item->v.list); size_t n = th_llist_length(node); if (fprintf(f->file, "%s = ", item->name) < 0) return -3; @@ -681,19 +681,19 @@ case ITEM_INT: if (fprintf(f->file, "%s = %i\n", - item->name, *(item->val_int)) < 0) + item->name, *(item->v.val_int)) < 0) return -4; break; case ITEM_UINT: if (fprintf(f->file, "%s = %d\n", - item->name, *(item->val_uint)) < 0) + item->name, *(item->v.val_uint)) < 0) return -5; break; case ITEM_BOOL: if (fprintf(f->file, "%s = %s\n", - item->name, *(item->val_bool) ? "yes" : "no") < 0) + item->name, *(item->v.val_bool) ? "yes" : "no") < 0) return -6; break; @@ -702,7 +702,7 @@ int res; if (fprintf(f->file, "%s = {\n", item->name) < 0) return -7; - res = th_cfg_write_sect(f, (cfgitem_t *) item->data, nesting + 1); + res = th_cfg_write_sect(f, item->v.section, nesting + 1); if (res != 0) return res; if (fprintf(f->file, "}\n\n") < 0) return -8; @@ -711,7 +711,7 @@ case ITEM_HEX_TRIPLET: if (fprintf(f->file, "%s = \"%06x\"\n", - item->name, *((int *) item->data)) < 0) + item->name, *(item->v.val_int)) < 0) return -6; break; } diff -r e97c764927ce -r 0db02b8d2d11 th_config.h --- a/th_config.h Fri May 06 03:34:52 2011 +0300 +++ b/th_config.h Sun May 22 02:10:42 2011 +0300 @@ -45,7 +45,7 @@ void *data; qlist_t **list; struct _cfgitem_t *section; - }; + } v; struct _cfgitem_t *next, *prev; } cfgitem_t;