// // This file is generated by fmtgen from "libaegis/common.def". // If you want to change the contents of this file // you need to edit libaegis/common.def // or you need to enhance fmtgen. // #include #include #include #include #include #include #include #include #include #include #include #include static const char *change_cause_s[] = { "external_bug", "external_enhancement", "external_improvement", "internal_bug", "internal_enhancement", "internal_improvement", "chain", }; static string_ty *change_cause_f[SIZEOF(change_cause_s)]; const char * change_cause_ename(change_cause_ty this_thing) { static char buffer[20]; if ((int)this_thing >= 0 && (int)this_thing < 7) return change_cause_s[this_thing]; snprintf(buffer, sizeof(buffer), "%d", (int)this_thing); return buffer; } void change_cause_write(const output::pointer &fp, const char *name, change_cause_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } if (name) { fp->fputs(name); fp->fputs(" = "); } fp->fputs(change_cause_s[this_thing]); if (name) fp->fputs(";\n"); } void change_cause_write_xml(const output::pointer &fp, const char *name, change_cause_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } assert(name); assert((size_t)this_thing < SIZEOF(change_cause_s)); fp->fputc('<'); fp->fputs(name); fp->fputc('>'); fp->fputs(change_cause_s[this_thing]); fp->fputs("fputs(name); fp->fputs(">\n"); } static bool change_cause_parse(string_ty *name, void *ptr) { slow_to_fast(change_cause_s, change_cause_f, SIZEOF(change_cause_s)); for (size_t j = 0; j < SIZEOF(change_cause_f); ++j) { if (str_equal(name, change_cause_f[j])) { *(change_cause_ty *)ptr = (change_cause_ty)j; return true; } } return false; } static string_ty * change_cause_fuzzy(string_ty *name) { return generic_enum_fuzzy(name, change_cause_f, SIZEOF(change_cause_f)); } static rpt_value::pointer change_cause_convert(void *this_thing) { if (!change_cause_f[0]) slow_to_fast(change_cause_s, change_cause_f, SIZEOF(change_cause_s)); return generic_enum_convert ( (int)*(change_cause_ty *)this_thing, change_cause_f, SIZEOF(change_cause_f) ); } static bool change_cause_is_set(void *this_thing) { return (*(change_cause_ty *)this_thing != 0); } meta_type change_cause_type = { "change_cause", 0, // alloc 0, // free change_cause_parse, 0, // list_parse 0, // struct_parse change_cause_fuzzy, change_cause_convert, change_cause_is_set, }; static const char *file_action_s[] = { "create", "modify", "remove", "insulate", "transparent", }; static string_ty *file_action_f[SIZEOF(file_action_s)]; const char * file_action_ename(file_action_ty this_thing) { static char buffer[20]; if ((int)this_thing >= 0 && (int)this_thing < 5) return file_action_s[this_thing]; snprintf(buffer, sizeof(buffer), "%d", (int)this_thing); return buffer; } void file_action_write(const output::pointer &fp, const char *name, file_action_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } if (name) { fp->fputs(name); fp->fputs(" = "); } fp->fputs(file_action_s[this_thing]); if (name) fp->fputs(";\n"); } void file_action_write_xml(const output::pointer &fp, const char *name, file_action_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } assert(name); assert((size_t)this_thing < SIZEOF(file_action_s)); fp->fputc('<'); fp->fputs(name); fp->fputc('>'); fp->fputs(file_action_s[this_thing]); fp->fputs("fputs(name); fp->fputs(">\n"); } static bool file_action_parse(string_ty *name, void *ptr) { slow_to_fast(file_action_s, file_action_f, SIZEOF(file_action_s)); for (size_t j = 0; j < SIZEOF(file_action_f); ++j) { if (str_equal(name, file_action_f[j])) { *(file_action_ty *)ptr = (file_action_ty)j; return true; } } return false; } static string_ty * file_action_fuzzy(string_ty *name) { return generic_enum_fuzzy(name, file_action_f, SIZEOF(file_action_f)); } static rpt_value::pointer file_action_convert(void *this_thing) { if (!file_action_f[0]) slow_to_fast(file_action_s, file_action_f, SIZEOF(file_action_s)); return generic_enum_convert ( (int)*(file_action_ty *)this_thing, file_action_f, SIZEOF(file_action_f) ); } static bool file_action_is_set(void *this_thing) { return (*(file_action_ty *)this_thing != 0); } meta_type file_action_type = { "file_action", 0, // alloc 0, // free file_action_parse, 0, // list_parse 0, // struct_parse file_action_fuzzy, file_action_convert, file_action_is_set, }; static const char *file_usage_s[] = { "source", "config", "build", "test", "manual_test", }; static string_ty *file_usage_f[SIZEOF(file_usage_s)]; const char * file_usage_ename(file_usage_ty this_thing) { static char buffer[20]; if ((int)this_thing >= 0 && (int)this_thing < 5) return file_usage_s[this_thing]; snprintf(buffer, sizeof(buffer), "%d", (int)this_thing); return buffer; } void file_usage_write(const output::pointer &fp, const char *name, file_usage_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } if (name) { fp->fputs(name); fp->fputs(" = "); } fp->fputs(file_usage_s[this_thing]); if (name) fp->fputs(";\n"); } void file_usage_write_xml(const output::pointer &fp, const char *name, file_usage_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } assert(name); assert((size_t)this_thing < SIZEOF(file_usage_s)); fp->fputc('<'); fp->fputs(name); fp->fputc('>'); fp->fputs(file_usage_s[this_thing]); fp->fputs("fputs(name); fp->fputs(">\n"); } static bool file_usage_parse(string_ty *name, void *ptr) { slow_to_fast(file_usage_s, file_usage_f, SIZEOF(file_usage_s)); for (size_t j = 0; j < SIZEOF(file_usage_f); ++j) { if (str_equal(name, file_usage_f[j])) { *(file_usage_ty *)ptr = (file_usage_ty)j; return true; } } return false; } static string_ty * file_usage_fuzzy(string_ty *name) { return generic_enum_fuzzy(name, file_usage_f, SIZEOF(file_usage_f)); } static rpt_value::pointer file_usage_convert(void *this_thing) { if (!file_usage_f[0]) slow_to_fast(file_usage_s, file_usage_f, SIZEOF(file_usage_s)); return generic_enum_convert ( (int)*(file_usage_ty *)this_thing, file_usage_f, SIZEOF(file_usage_f) ); } static bool file_usage_is_set(void *this_thing) { return (*(file_usage_ty *)this_thing != 0); } meta_type file_usage_type = { "file_usage", 0, // alloc 0, // free file_usage_parse, 0, // list_parse 0, // struct_parse file_usage_fuzzy, file_usage_convert, file_usage_is_set, }; void metric_write(const output::pointer &fp, const char *name, metric_ty *this_thing) { if (!this_thing) return; trace(("metric_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((metric_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((metric_ty *)this_thing)->reference_count)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } fp->fputs("{\n"); string_write(fp, "name", this_thing->name); real_write(fp, "value", this_thing->value, 0); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void metric_write_xml(const output::pointer &fp, const char *name, metric_ty *this_thing) { if (!this_thing) return; trace(("metric_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((metric_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((metric_ty *)this_thing)->reference_count)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); string_write_xml(fp, "name", this_thing->name); real_write_xml(fp, "value", this_thing->value, 0); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * metric_alloc(void) { metric_ty *this_thing; trace(("metric_alloc()\n{\n")); this_thing = (metric_ty *)mem_alloc(sizeof(metric_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->name = (string_ty *)0; this_thing->value = (double)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } metric_ty * metric_copy(metric_ty *this_thing) { trace(("metric_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } metric_ty * metric_clone(metric_ty *this_thing) { if (!this_thing) return 0; trace(("metric_clone()\n{\n")); metric_ty *result = (metric_ty *)metric_alloc(); result->name = str_copy(this_thing->name); result->value = this_thing->value; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void metric_trace_real(const char *name, const metric_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_string_real("name", value->name); trace_double_real("value", value->value); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void metric_free(void *that) { metric_ty *this_thing; this_thing = (metric_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("metric_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } str_free(this_thing->name); mem_free(this_thing); trace(("}\n")); } static type_table_ty metric_table[] = { { "name", offsetof(metric_ty, name), &string_type, metric_name_mask, 0, // redefinition not ok 0, // fast_name }, { "value", offsetof(metric_ty, value), &real_type, metric_value_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * metric_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("metric_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((metric_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, metric_table, SIZEOF(metric_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * metric_fuzzy(string_ty *name) { string_ty *result; trace(("metric_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, metric_table, SIZEOF(metric_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer metric_convert(void *this_thing) { trace(("metric_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((metric_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, metric_table, SIZEOF(metric_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type metric_type = { "metric", metric_alloc, metric_free, 0, // enum_parse 0, // list_parse metric_parse, metric_fuzzy, metric_convert, generic_struct_is_set, }; #include void metric_list_write(const output::pointer &fp, const char *name, metric_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("metric_list_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); fp->fputs("[\n"); for (j = 0; j < this_thing->length; ++j) { metric_write(fp, (const char *)0, this_thing->list[j]); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void metric_list_write_xml(const output::pointer &fp, const char *name, metric_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("metric_list_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) { metric_write_xml(fp, "metric", this_thing->list[j]); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * metric_list_alloc(void) { metric_list_ty *result; trace(("metric_list_alloc()\n{\n")); result = (metric_list_ty *)mem_alloc(sizeof(metric_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void metric_list_free(void *that) { metric_list_ty *this_thing; size_t j; this_thing = (metric_list_ty *)that; if (!this_thing) return; trace(("metric_list_free(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) metric_free(this_thing->list[j]); delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * metric_list_parse(void *that, meta_type **type_pp) { metric_list_ty *this_thing; void *addr; this_thing = (metric_list_ty *)that; trace(("metric_list_parse(this_thing = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)type_pp)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); *type_pp = &metric_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; metric_ty * *new_list = new metric_ty * [this_thing->maximum]; for (size_t j = 0; j < this_thing->length; ++j) new_list[j] = this_thing->list[j]; delete [] this_thing->list; this_thing->list = new_list; } addr = &this_thing->list[this_thing->length++]; trace(("return %08lX;\n", (long)addr)); trace(("}\n")); return addr; } static rpt_value::pointer metric_list_convert(void *that) { metric_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(metric_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("metric_list_convert(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); rpt_value_list *p = new rpt_value_list(); rpt_value::pointer result(p); for (j = 0; j < this_thing->length; ++j) { vp = metric_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } metric_list_ty * metric_list_copy(metric_list_ty *from) { size_t j; metric_list_ty *result; if (!from) return 0; trace(("metric_list_copy(from = %08lX)\n{\n", (long)from)); result = (metric_list_ty *)metric_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { metric_ty * mp; metric_ty * *mpp; meta_type *bogus; mp = from->list[j]; mpp = (metric_ty **)metric_list_parse(result, &bogus); *mpp = metric_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } metric_list_ty * metric_list_clone(metric_list_ty *from) { return metric_list_copy(from); } #ifdef DEBUG void metric_list_trace_real(const char *name, const metric_list_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("[\n"); trace_printf("// length = %ld\n", (long)value->length); trace_printf("// maximum = %ld\n", (long)value->maximum); assert(value->length <= value->maximum); assert(!value->list == !value->maximum); for (size_t j = 0; j < value->length; ++j) { metric_ty * mp = value->list[j]; metric_trace_real("", mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type metric_list_type = { "metric_list", metric_list_alloc, metric_list_free, 0, // enum_parse metric_list_parse, 0, // struct_parse 0, // fuzzy metric_list_convert, generic_struct_is_set, }; static const char *history_version_encoding_s[] = { "none", "quoted_printable", "base64", }; static string_ty *history_version_encoding_f[SIZEOF(history_version_encoding_s)]; const char * history_version_encoding_ename(history_version_encoding_ty this_thing) { static char buffer[20]; if ((int)this_thing >= 0 && (int)this_thing < 3) return history_version_encoding_s[this_thing]; snprintf(buffer, sizeof(buffer), "%d", (int)this_thing); return buffer; } void history_version_encoding_write(const output::pointer &fp, const char *name, history_version_encoding_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } if (name) { fp->fputs(name); fp->fputs(" = "); } fp->fputs(history_version_encoding_s[this_thing]); if (name) fp->fputs(";\n"); } void history_version_encoding_write_xml(const output::pointer &fp, const char *name, history_version_encoding_ty this_thing, bool show) { if (this_thing == 0) { if (!show || type_enum_option_query()) return; } assert(name); assert((size_t)this_thing < SIZEOF(history_version_encoding_s)); fp->fputc('<'); fp->fputs(name); fp->fputc('>'); fp->fputs(history_version_encoding_s[this_thing]); fp->fputs("fputs(name); fp->fputs(">\n"); } static bool history_version_encoding_parse(string_ty *name, void *ptr) { slow_to_fast(history_version_encoding_s, history_version_encoding_f, SIZEOF(history_version_encoding_s)); for (size_t j = 0; j < SIZEOF(history_version_encoding_f); ++j) { if (str_equal(name, history_version_encoding_f[j])) { *(history_version_encoding_ty *)ptr = (history_version_encoding_ty)j; return true; } } return false; } static string_ty * history_version_encoding_fuzzy(string_ty *name) { return generic_enum_fuzzy(name, history_version_encoding_f, SIZEOF(history_version_encoding_f)); } static rpt_value::pointer history_version_encoding_convert(void *this_thing) { if (!history_version_encoding_f[0]) slow_to_fast(history_version_encoding_s, history_version_encoding_f, SIZEOF(history_version_encoding_s)); return generic_enum_convert ( (int)*(history_version_encoding_ty *)this_thing, history_version_encoding_f, SIZEOF(history_version_encoding_f) ); } static bool history_version_encoding_is_set(void *this_thing) { return (*(history_version_encoding_ty *)this_thing != 0); } meta_type history_version_encoding_type = { "history_version_encoding", 0, // alloc 0, // free history_version_encoding_parse, 0, // list_parse 0, // struct_parse history_version_encoding_fuzzy, history_version_encoding_convert, history_version_encoding_is_set, }; void history_version_write(const output::pointer &fp, const char *name, history_version_ty *this_thing) { if (!this_thing) return; trace(("history_version_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((history_version_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((history_version_ty *)this_thing)->reference_count)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } fp->fputs("{\n"); string_write(fp, "revision", this_thing->revision); history_version_encoding_write(fp, "encoding", this_thing->encoding, 1); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void history_version_write_xml(const output::pointer &fp, const char *name, history_version_ty *this_thing) { if (!this_thing) return; trace(("history_version_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((history_version_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((history_version_ty *)this_thing)->reference_count)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); string_write_xml(fp, "revision", this_thing->revision); history_version_encoding_write_xml(fp, "encoding", this_thing->encoding, 0); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * history_version_alloc(void) { history_version_ty *this_thing; trace(("history_version_alloc()\n{\n")); this_thing = (history_version_ty *)mem_alloc(sizeof(history_version_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->revision = (string_ty *)0; this_thing->encoding = (history_version_encoding_ty)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } history_version_ty * history_version_copy(history_version_ty *this_thing) { trace(("history_version_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } history_version_ty * history_version_clone(history_version_ty *this_thing) { if (!this_thing) return 0; trace(("history_version_clone()\n{\n")); history_version_ty *result = (history_version_ty *)history_version_alloc(); result->revision = str_copy(this_thing->revision); result->encoding = this_thing->encoding; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void history_version_trace_real(const char *name, const history_version_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_string_real("revision", value->revision); trace_printf("encoding = %s;\n", history_version_encoding_ename(value->encoding)); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void history_version_free(void *that) { history_version_ty *this_thing; this_thing = (history_version_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("history_version_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } str_free(this_thing->revision); mem_free(this_thing); trace(("}\n")); } static type_table_ty history_version_table[] = { { "revision", offsetof(history_version_ty, revision), &string_type, history_version_revision_mask, 0, // redefinition not ok 0, // fast_name }, { "encoding", offsetof(history_version_ty, encoding), &history_version_encoding_type, history_version_encoding_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * history_version_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("history_version_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((history_version_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, history_version_table, SIZEOF(history_version_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * history_version_fuzzy(string_ty *name) { string_ty *result; trace(("history_version_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, history_version_table, SIZEOF(history_version_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer history_version_convert(void *this_thing) { trace(("history_version_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((history_version_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, history_version_table, SIZEOF(history_version_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type history_version_type = { "history_version", history_version_alloc, history_version_free, 0, // enum_parse 0, // list_parse history_version_parse, history_version_fuzzy, history_version_convert, generic_struct_is_set, }; void attributes_write(const output::pointer &fp, const char *name, attributes_ty *this_thing) { if (!this_thing) return; trace(("attributes_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(((attributes_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((attributes_ty *)this_thing)->reference_count)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } fp->fputs("{\n"); string_write(fp, "name", this_thing->name); string_write(fp, "value", this_thing->value); fp->fputs("}"); if (name) fp->fputs(";\n"); trace(("}\n")); } void attributes_write_xml(const output::pointer &fp, const char *name, attributes_ty *this_thing) { if (!this_thing) return; trace(("attributes_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); assert(((attributes_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((attributes_ty *)this_thing)->reference_count)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); string_write_xml(fp, "name", this_thing->name); string_write_xml(fp, "value", this_thing->value); fp->fputs("fputs(name); fp->fputs(">\n"); } static void * attributes_alloc(void) { attributes_ty *this_thing; trace(("attributes_alloc()\n{\n")); this_thing = (attributes_ty *)mem_alloc(sizeof(attributes_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); this_thing->name = (string_ty *)0; this_thing->value = (string_ty *)0; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } attributes_ty * attributes_copy(attributes_ty *this_thing) { trace(("attributes_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } attributes_ty * attributes_clone(attributes_ty *this_thing) { if (!this_thing) return 0; trace(("attributes_clone()\n{\n")); attributes_ty *result = (attributes_ty *)attributes_alloc(); result->name = str_copy(this_thing->name); result->value = str_copy(this_thing->value); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void attributes_trace_real(const char *name, const attributes_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_string_real("name", value->name); trace_string_real("value", value->value); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void attributes_free(void *that) { attributes_ty *this_thing; this_thing = (attributes_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("attributes_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } str_free(this_thing->name); str_free(this_thing->value); mem_free(this_thing); trace(("}\n")); } static type_table_ty attributes_table[] = { { "name", offsetof(attributes_ty, name), &string_type, attributes_name_mask, 0, // redefinition not ok 0, // fast_name }, { "value", offsetof(attributes_ty, value), &string_type, attributes_value_mask, 0, // redefinition not ok 0, // fast_name }, }; static void * attributes_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("attributes_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((attributes_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, attributes_table, SIZEOF(attributes_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * attributes_fuzzy(string_ty *name) { string_ty *result; trace(("attributes_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, attributes_table, SIZEOF(attributes_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer attributes_convert(void *this_thing) { trace(("attributes_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((attributes_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, attributes_table, SIZEOF(attributes_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type attributes_type = { "attributes", attributes_alloc, attributes_free, 0, // enum_parse 0, // list_parse attributes_parse, attributes_fuzzy, attributes_convert, generic_struct_is_set, }; void attributes_list_write(const output::pointer &fp, const char *name, attributes_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("attributes_list_write(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); if (name) { fp->fputs(name); fp->fputs(" =\n"); } assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); fp->fputs("[\n"); for (j = 0; j < this_thing->length; ++j) { attributes_write(fp, (const char *)0, this_thing->list[j]); fp->fputs(",\n"); } fp->fputs("]"); if (name) fp->fputs(";\n"); trace(("}\n")); } void attributes_list_write_xml(const output::pointer &fp, const char *name, attributes_list_ty *this_thing) { size_t j; if (!this_thing) return; trace(("attributes_list_write_xml(name = \"%s\", this_thing = %08lX)\n{\n", name, (long)this_thing)); assert(name); fp->fputc('<'); fp->fputs(name); fp->fputs(">\n"); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) { attributes_write_xml(fp, "attributes", this_thing->list[j]); } fp->fputs("fputs(name); fp->fputs(">\n"); trace(("}\n")); } static void * attributes_list_alloc(void) { attributes_list_ty *result; trace(("attributes_list_alloc()\n{\n")); result = (attributes_list_ty *)mem_alloc(sizeof(attributes_list_ty)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static void attributes_list_free(void *that) { attributes_list_ty *this_thing; size_t j; this_thing = (attributes_list_ty *)that; if (!this_thing) return; trace(("attributes_list_free(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); for (j = 0; j < this_thing->length; ++j) attributes_free(this_thing->list[j]); delete [] this_thing->list; mem_free(this_thing); trace(("}\n")); } static void * attributes_list_parse(void *that, meta_type **type_pp) { attributes_list_ty *this_thing; void *addr; this_thing = (attributes_list_ty *)that; trace(("attributes_list_parse(this_thing = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)type_pp)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); *type_pp = &attributes_type; trace_pointer(*type_pp); if (this_thing->length >= this_thing->maximum) { this_thing->maximum = this_thing->maximum * 2 + 16; attributes_ty * *new_list = new attributes_ty * [this_thing->maximum]; for (size_t j = 0; j < this_thing->length; ++j) new_list[j] = this_thing->list[j]; delete [] this_thing->list; this_thing->list = new_list; } addr = &this_thing->list[this_thing->length++]; trace(("return %08lX;\n", (long)addr)); trace(("}\n")); return addr; } static rpt_value::pointer attributes_list_convert(void *that) { attributes_list_ty *this_thing; size_t j; rpt_value::pointer vp; this_thing = *(attributes_list_ty **)that; if (!this_thing) return rpt_value::pointer(); trace(("attributes_list_convert(this_thing = %08lX)\n{\n", (long)this_thing)); assert(this_thing->length <= this_thing->maximum); assert(!this_thing->list == !this_thing->maximum); rpt_value_list *p = new rpt_value_list(); rpt_value::pointer result(p); for (j = 0; j < this_thing->length; ++j) { vp = attributes_type.convert(&this_thing->list[j]); assert(vp); p->append(vp); } trace(("}\n")); trace(("return %08lX;\n", (long)result.get())); return result; } attributes_list_ty * attributes_list_copy(attributes_list_ty *from) { size_t j; attributes_list_ty *result; if (!from) return 0; trace(("attributes_list_copy(from = %08lX)\n{\n", (long)from)); result = (attributes_list_ty *)attributes_list_alloc(); assert(from->length <= from->maximum); assert(!from->list == !from->maximum); for (j = 0; j < from->length; ++j) { attributes_ty * mp; attributes_ty * *mpp; meta_type *bogus; mp = from->list[j]; mpp = (attributes_ty **)attributes_list_parse(result, &bogus); *mpp = attributes_copy(mp); } trace(("return %8.8lX\n", (long)result)); trace(("}\n")); return result; } attributes_list_ty * attributes_list_clone(attributes_list_ty *from) { return attributes_list_copy(from); } #ifdef DEBUG void attributes_list_trace_real(const char *name, const attributes_list_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("[\n"); trace_printf("// length = %ld\n", (long)value->length); trace_printf("// maximum = %ld\n", (long)value->maximum); assert(value->length <= value->maximum); assert(!value->list == !value->maximum); for (size_t j = 0; j < value->length; ++j) { attributes_ty * mp = value->list[j]; attributes_trace_real("", mp); } trace_printf("]"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG meta_type attributes_list_type = { "attributes_list", attributes_list_alloc, attributes_list_free, 0, // enum_parse attributes_list_parse, 0, // struct_parse 0, // fuzzy attributes_list_convert, generic_struct_is_set, }; void common_write(const output::pointer &fp, common_ty *this_thing) { if (!this_thing) return; trace(("common_write(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((common_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((common_ty *)this_thing)->reference_count)); (void)fp; trace(("}\n")); } void common_write_xml(const output::pointer &fp, common_ty *this_thing) { if (!this_thing) return; trace(("common_write_xml(this_thing = %08lX)\n{\n", (long)this_thing)); assert(((common_ty *)this_thing)->reference_count > 0); trace(("rc = %ld;\n", ((common_ty *)this_thing)->reference_count)); fp->fputs("\n"); fp->fputs("\n"); } static void * common_alloc(void) { common_ty *this_thing; trace(("common_alloc()\n{\n")); this_thing = (common_ty *)mem_alloc(sizeof(common_ty)); this_thing->reference_count = 1; this_thing->mask = 0; this_thing->errpos = str_copy(lex_position()); trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } common_ty * common_copy(common_ty *this_thing) { trace(("common_copy()\n{\n")); this_thing->reference_count++; trace(("return %08lX;\n", (long)this_thing)); trace(("}\n")); return this_thing; } common_ty * common_clone(common_ty *this_thing) { if (!this_thing) return 0; trace(("common_clone()\n{\n")); common_ty *result = (common_ty *)common_alloc(); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } #ifdef DEBUG void common_trace_real(const char *name, const common_ty *value) { if (name && *name) { trace_printf("%s = ", name); } if (!value) { trace_printf("NULL"); } else { trace_printf("{\n"); trace_printf("}"); } trace_printf((name && *name) ? ";\n" : ",\n"); } #endif // DEBUG static void common_free(void *that) { common_ty *this_thing; this_thing = (common_ty *)that; if (!this_thing) return; this_thing->reference_count--; assert(this_thing->reference_count >= 0); if (this_thing->reference_count > 0) return; trace(("common_free(this_thing = %08lX)\n{\n", (long)this_thing)); if (this_thing->errpos) { str_free(this_thing->errpos); this_thing->errpos = 0; } mem_free(this_thing); trace(("}\n")); } static type_table_ty common_table[] = { { "", 0, 0, 0, 0, 0 }, }; static void * common_parse(void *this_thing, string_ty *name, meta_type **type_pp, unsigned long *mask_p, int *redef_p) { void *addr; trace(("common_parse(this_thing = %08lX, name = %08lX, type_pp = %08lX)\n{\n", (long)this_thing, (long)name, (long)type_pp)); assert(((common_ty *)this_thing)->reference_count > 0); addr = generic_struct_parse ( this_thing, name, type_pp, mask_p, redef_p, common_table, SIZEOF(common_table) ); trace(("return %08lX;\n}\n", (long)addr)); return addr; } static string_ty * common_fuzzy(string_ty *name) { string_ty *result; trace(("common_fuzzy(name = %08lX)\n{\n", (long)name)); result = generic_struct_fuzzy ( name, common_table, SIZEOF(common_table) ); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } static rpt_value::pointer common_convert(void *this_thing) { trace(("common_convert(name = %08lX)\n{\n", (long)this_thing)); assert(((common_ty *)this_thing)->reference_count > 0); rpt_value::pointer result = generic_struct_convert ( this_thing, common_table, SIZEOF(common_table) ); trace(("return %08lX;\n", (long)result.get())); trace(("}\n")); return result; } meta_type common_type = { "common", common_alloc, common_free, 0, // enum_parse 0, // list_parse common_parse, common_fuzzy, common_convert, generic_struct_is_set, }; common_ty * common_read_file(const nstring &filename) { return common_read_file(filename.get_ref()); } common_ty * common_read_file(string_ty *filename) { common_ty *result; trace(("common_read_file(filename = \"%s\")\n{\n", (filename ? filename->str_text : ""))); os_become_must_be_active(); result = (common_ty *)parse(filename, &common_type); trace(("return %08lX;\n", (long)result)); trace(("}\n")); return result; } void common_write_file(const nstring &filename, common_ty *value, bool comp) { common_write_file(filename.get_ref(), value, comp); } void common_write_file(string_ty *filename, common_ty *value, int needs_compression) { trace(("common_write_file(filename = \"%s\", value = %08lX)\n{\n", (filename ? filename->str_text : ""), (long)value)); if (filename) os_become_must_be_active(); output::pointer fp; if (needs_compression) { fp = output_file::binary_open(filename); fp = output_gzip::create(fp); } else { fp = output_file::text_open(filename); } fp = output_indent::create(fp); io_comment_emit(fp); common_write(fp, value); type_enum_option_clear(); trace(("}\n")); } void common__rpt_init(void) { trace(("common__rpt_init()\n{\n")); generic_enum__init(change_cause_s, SIZEOF(change_cause_s)); generic_enum__init(file_action_s, SIZEOF(file_action_s)); generic_enum__init(file_usage_s, SIZEOF(file_usage_s)); generic_enum__init(history_version_encoding_s, SIZEOF(history_version_encoding_s)); trace(("}\n")); }