#include #include #include #include #include #include #include #include #include #include #include #include static char *boolean_s[] = { "false", "true", }; static string_ty *boolean_f[SIZEOF(boolean_s)]; char * boolean_ename(this) boolean_ty this; { static char buffer[20]; if ((int)this >= 0 && (int)this < 2) return boolean_s[this]; sprintf(buffer, "%d", (int)this); return buffer; } void boolean_write(fp, name, this) output_ty *fp; const char *name; boolean_ty this; { if (name) { if (this == 0 && type_enum_option_query()) return; output_fputs(fp, name); output_fputs(fp, " = "); } output_fputs(fp, boolean_s[this]); if (name) output_fputs(fp, ";\n"); } static int boolean_parse _((string_ty *)); static int boolean_parse(name) string_ty *name; { int j; slow_to_fast(boolean_s, boolean_f, SIZEOF(boolean_s)); for (j = 0; j < SIZEOF(boolean_f); ++j) { if (str_equal(name, boolean_f[j])) return j; } return -1; } static string_ty *boolean_fuzzy _((string_ty *)); static string_ty * boolean_fuzzy(name) string_ty *name; { return generic_enum_fuzzy ( name, boolean_f, SIZEOF(boolean_f) ); } static struct rpt_value_ty *boolean_convert _((void *)); static struct rpt_value_ty * boolean_convert(this) void *this; { if (!boolean_f[0]) slow_to_fast(boolean_s, boolean_f, SIZEOF(boolean_s)); return generic_enum_convert ( this, boolean_f, SIZEOF(boolean_f) ); } type_ty boolean_type = { "boolean", 0, /* alloc */ 0, /* free */ boolean_parse, 0, /* list_parse */ 0, /* struct_parse */ boolean_fuzzy, boolean_convert, generic_enum_is_set, }; static 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)]; char * change_cause_ename(this) change_cause_ty this; { static char buffer[20]; if ((int)this >= 0 && (int)this < 7) return change_cause_s[this]; sprintf(buffer, "%d", (int)this); return buffer; } void change_cause_write(fp, name, this) output_ty *fp; const char *name; change_cause_ty this; { if (name) { if (this == 0 && type_enum_option_query()) return; output_fputs(fp, name); output_fputs(fp, " = "); } output_fputs(fp, change_cause_s[this]); if (name) output_fputs(fp, ";\n"); } static int change_cause_parse _((string_ty *)); static int change_cause_parse(name) string_ty *name; { int j; slow_to_fast(change_cause_s, change_cause_f, SIZEOF(change_cause_s)); for (j = 0; j < SIZEOF(change_cause_f); ++j) { if (str_equal(name, change_cause_f[j])) return j; } return -1; } static string_ty *change_cause_fuzzy _((string_ty *)); static string_ty * change_cause_fuzzy(name) string_ty *name; { return generic_enum_fuzzy ( name, change_cause_f, SIZEOF(change_cause_f) ); } static struct rpt_value_ty *change_cause_convert _((void *)); static struct rpt_value_ty * change_cause_convert(this) void *this; { if (!change_cause_f[0]) slow_to_fast(change_cause_s, change_cause_f, SIZEOF(change_cause_s)); return generic_enum_convert ( this, change_cause_f, SIZEOF(change_cause_f) ); } type_ty change_cause_type = { "change_cause", 0, /* alloc */ 0, /* free */ change_cause_parse, 0, /* list_parse */ 0, /* struct_parse */ change_cause_fuzzy, change_cause_convert, generic_enum_is_set, }; static char *file_action_s[] = { "create", "modify", "remove", "insulate", }; static string_ty *file_action_f[SIZEOF(file_action_s)]; char * file_action_ename(this) file_action_ty this; { static char buffer[20]; if ((int)this >= 0 && (int)this < 4) return file_action_s[this]; sprintf(buffer, "%d", (int)this); return buffer; } void file_action_write(fp, name, this) output_ty *fp; const char *name; file_action_ty this; { if (name) { if (this == 0 && type_enum_option_query()) return; output_fputs(fp, name); output_fputs(fp, " = "); } output_fputs(fp, file_action_s[this]); if (name) output_fputs(fp, ";\n"); } static int file_action_parse _((string_ty *)); static int file_action_parse(name) string_ty *name; { int j; slow_to_fast(file_action_s, file_action_f, SIZEOF(file_action_s)); for (j = 0; j < SIZEOF(file_action_f); ++j) { if (str_equal(name, file_action_f[j])) return j; } return -1; } static string_ty *file_action_fuzzy _((string_ty *)); static string_ty * file_action_fuzzy(name) string_ty *name; { return generic_enum_fuzzy ( name, file_action_f, SIZEOF(file_action_f) ); } static struct rpt_value_ty *file_action_convert _((void *)); static struct rpt_value_ty * file_action_convert(this) void *this; { if (!file_action_f[0]) slow_to_fast(file_action_s, file_action_f, SIZEOF(file_action_s)); return generic_enum_convert ( this, file_action_f, SIZEOF(file_action_f) ); } type_ty file_action_type = { "file_action", 0, /* alloc */ 0, /* free */ file_action_parse, 0, /* list_parse */ 0, /* struct_parse */ file_action_fuzzy, file_action_convert, generic_enum_is_set, }; static char *file_usage_s[] = { "source", "build", "test", "manual_test", }; static string_ty *file_usage_f[SIZEOF(file_usage_s)]; char * file_usage_ename(this) file_usage_ty this; { static char buffer[20]; if ((int)this >= 0 && (int)this < 4) return file_usage_s[this]; sprintf(buffer, "%d", (int)this); return buffer; } void file_usage_write(fp, name, this) output_ty *fp; const char *name; file_usage_ty this; { if (name) { if (this == 0 && type_enum_option_query()) return; output_fputs(fp, name); output_fputs(fp, " = "); } output_fputs(fp, file_usage_s[this]); if (name) output_fputs(fp, ";\n"); } static int file_usage_parse _((string_ty *)); static int file_usage_parse(name) string_ty *name; { int j; slow_to_fast(file_usage_s, file_usage_f, SIZEOF(file_usage_s)); for (j = 0; j < SIZEOF(file_usage_f); ++j) { if (str_equal(name, file_usage_f[j])) return j; } return -1; } static string_ty *file_usage_fuzzy _((string_ty *)); static string_ty * file_usage_fuzzy(name) string_ty *name; { return generic_enum_fuzzy ( name, file_usage_f, SIZEOF(file_usage_f) ); } static struct rpt_value_ty *file_usage_convert _((void *)); static struct rpt_value_ty * file_usage_convert(this) void *this; { if (!file_usage_f[0]) slow_to_fast(file_usage_s, file_usage_f, SIZEOF(file_usage_s)); return generic_enum_convert ( this, file_usage_f, SIZEOF(file_usage_f) ); } type_ty file_usage_type = { "file_usage", 0, /* alloc */ 0, /* free */ file_usage_parse, 0, /* list_parse */ 0, /* struct_parse */ file_usage_fuzzy, file_usage_convert, generic_enum_is_set, }; void metric_write(fp, name, this) output_ty *fp; char *name; metric this; { if (!this) return; trace(("metric_write(name = \"%s\", this = %08lX)\n{\n"/*}*/, name, (long)this)); assert(((metric)this)->reference_count > 0); trace(("rc = %d;\n", ((metric)this)->reference_count)); if (name) { output_fputs(fp, name); output_fputs(fp, " =\n"); } output_fputs(fp, "{\n"/*}*/); string_write(fp, "name", this->name); real_write(fp, "value", this->value); output_fputs(fp, /*{*/"}"); if (name) output_fputs(fp, ";\n"); trace((/*{*/"}\n")); } static void *metric_alloc _((void)); static void * metric_alloc() { metric this; trace(("metric_alloc()\n{\n"/*}*/)); this = mem_alloc(sizeof(struct metric)); this->reference_count = 1; this->mask = 0; this->name = 0; this->value = 0; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } metric metric_copy(this) metric this; { trace(("metric_copy()\n{\n"/*}*/)); this->reference_count++; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } static void metric_free _((void *)); static void metric_free(that) void *that; { metric this = that; if (!this) return; this->reference_count--; assert(this->reference_count >= 0); if (this->reference_count > 0) return; trace(("metric_free(this = %08lX)\n{\n"/*}*/, (long)this)); str_free(this->name); mem_free(this); trace((/*{*/"}\n")); } static type_table_ty metric_table[] = { { "name", offsetof(struct metric, name), &string_type, metric_name_mask, }, { "value", offsetof(struct metric, value), &real_type, metric_value_mask, }, }; static void *metric_parse _((void *, string_ty *, type_ty **, unsigned long *)); static void * metric_parse(this, name, type_pp, mask_p) void *this; string_ty *name; type_ty **type_pp; unsigned long *mask_p; { void *addr; trace(("metric_parse(this = %08lX, name = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)name, (long)type_pp)); assert(((metric)this)->reference_count > 0); assert(sizeof(metric) == sizeof(generic_struct_ty *)); addr = generic_struct_parse ( this, name, type_pp, mask_p, metric_table, SIZEOF(metric_table) ); trace((/*{*/"return %08lX;\n}\n", (long)addr)); return addr; } static string_ty *metric_fuzzy _((string_ty *)); static string_ty * metric_fuzzy(name) 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 struct rpt_value_ty *metric_convert _((void *)); static struct rpt_value_ty * metric_convert(this) void *this; { struct rpt_value_ty *result; trace(("metric_convert(name = %08lX)\n{\n"/*}*/, (long)this)); assert(((metric)this)->reference_count > 0); result = generic_struct_convert ( this, metric_table, SIZEOF(metric_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } type_ty 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(fp, name, this) output_ty *fp; char *name; metric_list this; { size_t j; if (!this) return; trace(("metric_list_write(name = \"%s\", this = %08lX)\n{\n"/*}*/, name, (long)this)); if (name) { output_fputs(fp, name); output_fputs(fp, " =\n"); } assert(this->length <= this->maximum); assert(!this->list == !this->maximum); output_fputs(fp, "[\n"/*]*/); for (j = 0; j < this->length; ++j) { metric_write(fp, (char *)0, this->list[j]); output_fputs(fp, ",\n"); } output_fputs(fp, /*[*/"]"); if (name) output_fputs(fp, ";\n"); trace((/*{*/"}\n")); } static void *metric_list_alloc _((void)); static void * metric_list_alloc() { metric_list result; trace(("metric_list_alloc()\n{\n"/*}*/)); result = mem_alloc(sizeof(struct metric_list)); 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 *)); static void metric_list_free(that) void *that; { metric_list this = that; size_t j; if (!this) return; trace(("metric_list_free(this = %08lX)\n{\n"/*}*/, (long)this)); assert(this->length <= this->maximum); assert(!this->list == !this->maximum); for (j = 0; j < this->length; ++j) metric_free(this->list[j]); if (this->list) mem_free(this->list); mem_free(this); trace((/*{*/"}\n")); } static void *metric_list_parse _((void *, type_ty **)); static void * metric_list_parse(that, type_pp) void *that; type_ty **type_pp; { metric_list this = that; void *addr; trace(("metric_list_parse(this = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)type_pp)); assert(this->length <= this->maximum); assert(!this->list == !this->maximum); *type_pp = &metric_type; trace_pointer(*type_pp); if (this->length >= this->maximum) { size_t nbytes; this->maximum = this->maximum * 2 + 16; nbytes = this->maximum * sizeof(this->list[0]); this->list = mem_change_size(this->list, nbytes); } addr = &this->list[this->length++]; trace(("return %08lX;\n", (long)addr)); trace((/*{*/"}\n")); return addr; } static rpt_value_ty *metric_list_convert _((void *)); static rpt_value_ty * metric_list_convert(that) void *that; { metric_list this; rpt_value_ty *result; size_t j; rpt_value_ty *vp; this = *(metric_list *)that; if (!this) return 0; trace(("metric_list_convert(this = %08lX)\n{\n"/*}*/, (long)this)); assert(this->length <= this->maximum); assert(!this->list == !this->maximum); result = rpt_value_list(); for (j = 0; j < this->length; ++j) { vp = metric_type.convert(&this->list[j]); assert(vp); rpt_value_list_append(result, vp); rpt_value_free(vp); } trace((/*{*/"}\n")); trace(("return %08lX;\n", (long)result)); return result; } type_ty 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 char *history_version_encoding_s[] = { "none", "quoted_printable", "base64", }; static string_ty *history_version_encoding_f[SIZEOF(history_version_encoding_s)]; char * history_version_encoding_ename(this) history_version_encoding_ty this; { static char buffer[20]; if ((int)this >= 0 && (int)this < 3) return history_version_encoding_s[this]; sprintf(buffer, "%d", (int)this); return buffer; } void history_version_encoding_write(fp, name, this) output_ty *fp; const char *name; history_version_encoding_ty this; { if (name) { if (this == 0 && type_enum_option_query()) return; output_fputs(fp, name); output_fputs(fp, " = "); } output_fputs(fp, history_version_encoding_s[this]); if (name) output_fputs(fp, ";\n"); } static int history_version_encoding_parse _((string_ty *)); static int history_version_encoding_parse(name) string_ty *name; { int j; slow_to_fast(history_version_encoding_s, history_version_encoding_f, SIZEOF(history_version_encoding_s)); for (j = 0; j < SIZEOF(history_version_encoding_f); ++j) { if (str_equal(name, history_version_encoding_f[j])) return j; } return -1; } static string_ty *history_version_encoding_fuzzy _((string_ty *)); static string_ty * history_version_encoding_fuzzy(name) string_ty *name; { return generic_enum_fuzzy ( name, history_version_encoding_f, SIZEOF(history_version_encoding_f) ); } static struct rpt_value_ty *history_version_encoding_convert _((void *)); static struct rpt_value_ty * history_version_encoding_convert(this) void *this; { 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 ( this, history_version_encoding_f, SIZEOF(history_version_encoding_f) ); } type_ty 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, generic_enum_is_set, }; void history_version_write(fp, name, this) output_ty *fp; char *name; history_version this; { if (!this) return; trace(("history_version_write(name = \"%s\", this = %08lX)\n{\n"/*}*/, name, (long)this)); assert(((history_version)this)->reference_count > 0); trace(("rc = %d;\n", ((history_version)this)->reference_count)); if (name) { output_fputs(fp, name); output_fputs(fp, " =\n"); } output_fputs(fp, "{\n"/*}*/); string_write(fp, "revision", this->revision); history_version_encoding_write(fp, "encoding", this->encoding); output_fputs(fp, /*{*/"}"); if (name) output_fputs(fp, ";\n"); trace((/*{*/"}\n")); } static void *history_version_alloc _((void)); static void * history_version_alloc() { history_version this; trace(("history_version_alloc()\n{\n"/*}*/)); this = mem_alloc(sizeof(struct history_version)); this->reference_count = 1; this->mask = 0; this->revision = 0; this->encoding = 0; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } history_version history_version_copy(this) history_version this; { trace(("history_version_copy()\n{\n"/*}*/)); this->reference_count++; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } static void history_version_free _((void *)); static void history_version_free(that) void *that; { history_version this = that; if (!this) return; this->reference_count--; assert(this->reference_count >= 0); if (this->reference_count > 0) return; trace(("history_version_free(this = %08lX)\n{\n"/*}*/, (long)this)); str_free(this->revision); mem_free(this); trace((/*{*/"}\n")); } static type_table_ty history_version_table[] = { { "revision", offsetof(struct history_version, revision), &string_type, history_version_revision_mask, }, { "encoding", offsetof(struct history_version, encoding), &history_version_encoding_type, history_version_encoding_mask, }, }; static void *history_version_parse _((void *, string_ty *, type_ty **, unsigned long *)); static void * history_version_parse(this, name, type_pp, mask_p) void *this; string_ty *name; type_ty **type_pp; unsigned long *mask_p; { void *addr; trace(("history_version_parse(this = %08lX, name = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)name, (long)type_pp)); assert(((history_version)this)->reference_count > 0); assert(sizeof(history_version) == sizeof(generic_struct_ty *)); addr = generic_struct_parse ( this, name, type_pp, mask_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 *)); static string_ty * history_version_fuzzy(name) 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 struct rpt_value_ty *history_version_convert _((void *)); static struct rpt_value_ty * history_version_convert(this) void *this; { struct rpt_value_ty *result; trace(("history_version_convert(name = %08lX)\n{\n"/*}*/, (long)this)); assert(((history_version)this)->reference_count > 0); result = generic_struct_convert ( this, history_version_table, SIZEOF(history_version_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } type_ty 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 common_write(fp, this) output_ty *fp; common this; { if (!this) return; trace(("common_write(this = %08lX)\n{\n"/*}*/, this)); assert(((common)this)->reference_count > 0); trace(("rc = %d;\n", ((common)this)->reference_count)); trace((/*{*/"}\n")); } static void *common_alloc _((void)); static void * common_alloc() { common this; trace(("common_alloc()\n{\n"/*}*/)); this = mem_alloc(sizeof(struct common)); this->reference_count = 1; this->mask = 0; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } common common_copy(this) common this; { trace(("common_copy()\n{\n"/*}*/)); this->reference_count++; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } static void common_free _((void *)); static void common_free(that) void *that; { common this = that; if (!this) return; this->reference_count--; assert(this->reference_count >= 0); if (this->reference_count > 0) return; trace(("common_free(this = %08lX)\n{\n"/*}*/, (long)this)); mem_free(this); trace((/*{*/"}\n")); } static type_table_ty common_table[] = { { "", }, }; static void *common_parse _((void *, string_ty *, type_ty **, unsigned long *)); static void * common_parse(this, name, type_pp, mask_p) void *this; string_ty *name; type_ty **type_pp; unsigned long *mask_p; { void *addr; trace(("common_parse(this = %08lX, name = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)name, (long)type_pp)); assert(((common)this)->reference_count > 0); assert(sizeof(common) == sizeof(generic_struct_ty *)); addr = generic_struct_parse ( this, name, type_pp, mask_p, common_table, SIZEOF(common_table) ); trace((/*{*/"return %08lX;\n}\n", (long)addr)); return addr; } static string_ty *common_fuzzy _((string_ty *)); static string_ty * common_fuzzy(name) 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 struct rpt_value_ty *common_convert _((void *)); static struct rpt_value_ty * common_convert(this) void *this; { struct rpt_value_ty *result; trace(("common_convert(name = %08lX)\n{\n"/*}*/, (long)this)); assert(((common)this)->reference_count > 0); result = generic_struct_convert ( this, common_table, SIZEOF(common_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } type_ty common_type = { "common", common_alloc, common_free, 0, /* enum_parse */ 0, /* list_parse */ common_parse, common_fuzzy, common_convert, generic_struct_is_set, }; common common_read_file(filename) string_ty *filename; { common result; trace(("common_read_file(filename = \"%s\")\n{\n"/*}*/, (filename ? filename->str_text : ""))); os_become_must_be_active(); result = parse(filename, &common_type); trace(("return %08lX;\n", result)); trace((/*{*/"}\n")); return result; } void common_write_file(filename, value, compress) string_ty *filename; common value; int compress; { output_ty *fp; trace(("common_write_file(filename = \"%s\", value = %08lX)\n{\n"/*}*/, (filename ? filename->str_text : ""), (long)value)); if (filename) os_become_must_be_active(); if (compress) { fp = output_file_binary_open(filename); fp = output_gzip(fp); } else { fp = output_file_text_open(filename); } fp = output_indent(fp); io_comment_emit(fp); common_write(fp, value); type_enum_option_clear(); output_delete(fp); trace((/*{*/"}\n")); } void common__rpt_init() { trace(("common__rpt_init()\n{\n"/*}*/)); generic_enum__init(boolean_s, SIZEOF(boolean_s)); 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")); }