/*=== parse_table_file ====================================================== * <Description Text> * * Assumes: ? * * Returns: (value) when X * (value) when Y * * Modifies: ? * * Calls: nothing * * Called By: ? * * History: MM/DD/YY MRH Created initial version based on function * 'func()' in motif/csr/file.c */ static PARSE_ERROR_TYPE parse_table_file(FILE *infile, FIELD **fields, char *table_name, TABLE *tables) { PARSE_TABLE_TYPE status; char *create_table = "create table"; char line[256]; char field_name[256]; FIELD_TYPE field_type; int field_length; char null_allowable; /* * First, skip to the first open paren following a 'create table' string * in the file. */ while (fgets(line, sizeof(line), infile)) if (!strncmp(line, create_table, strlen(create_table))) break; if (! strchr(line, '(')) { while (fgetc(infile) != '(') ; } while (! feof(infile)) { status = parse_field(infile, field_name, &field_type, &field_length, &null_allowable); if (status == TABLE_END) break; /* Only a single close paren */ if (status == TABLE_COMMENT) continue; /* The line is a comment */ if (status == TABLE_PARSE_ERROR) { fprintf(stderr, "Problem parsing %s.table file.\n", table_name); return PARSE_ERROR; } if (append_field(fields, table_name, field_name, field_type, field_length, null_allowable, tables) == FALSE) return PARSE_ERROR; if (status == TABLE_DONE) break; /* Had a valid field *and* a close paren */ } return OK; }
/** * rb_ext_db_key_to_string: * @key: a @RBExtDBKey * * Generates a readable string format from the key. * * Return value: (transfer full): string form of the key */ char * rb_ext_db_key_to_string (RBExtDBKey *key) { GString *s; GList *l; s = g_string_sized_new (100); g_string_append (s, key->lookup ? "[lookup]" : "[storage]"); for (l = key->fields; l != NULL; l = l->next) { append_field (s, l->data); } if (key->lookup && key->info != NULL) { g_string_append (s, " info: "); for (l = key->info; l != NULL; l = l->next) { append_field (s, l->data); } } return g_string_free (s, FALSE); }
static int add_is_active_field(char *linebuf) { int status, index; char table_name[256], field_name[256]; FIELD *field; if ((status = parse_table_field_pair(linebuf, table_name, field_name, &index)) != OK) return status; if ((field = find_field(fields, table_name, field_name, index)) == NULL) { fprintf(stderr, "(3)Unable to find field %s:%s\n", table_name, field_name); return BAD_DATA_ERROR; } return append_field(&is_active_fields, table_name, field_name, NOT_SET, FALSE, tables, index); }
/** * qerror_human(): Format QError data into human-readable string. * * Formats according to member 'desc' of the specified QError object. */ QString *qerror_human(const QError *qerror) { const char *p; QString *qstring; assert(qerror->entry != NULL); qstring = qstring_new(); for (p = qerror->entry->desc; *p != '\0';) { if (*p != '%') { qstring_append_chr(qstring, *p++); } else if (*(p + 1) == '%') { qstring_append_chr(qstring, '%'); p += 2; } else { p = append_field(qstring, qerror, p); } } return qstring; }
static QString *qerror_format_desc(QDict *error, const QErrorStringTable *entry) { QString *qstring; const char *p; assert(entry != NULL); qstring = qstring_new(); for (p = entry->desc; *p != '\0';) { if (*p != '%') { qstring_append_chr(qstring, *p++); } else if (*(p + 1) == '%') { qstring_append_chr(qstring, '%'); p += 2; } else { p = append_field(error, qstring, entry, p); } } return qstring; }