#include #include #include #include #include #include #include #include #include #include #include #include void gstate_where_write(fp, name, this) output_ty *fp; char *name; gstate_where this; { if (!this) return; trace(("gstate_where_write(name = \"%s\", this = %08lX)\n{\n"/*}*/, name, (long)this)); assert(((gstate_where)this)->reference_count > 0); trace(("rc = %d;\n", ((gstate_where)this)->reference_count)); if (name) { output_fputs(fp, name); output_fputs(fp, " =\n"); } output_fputs(fp, "{\n"/*}*/); string_write(fp, "project_name", this->project_name); string_write(fp, "directory", this->directory); string_write(fp, "alias_for", this->alias_for); output_fputs(fp, /*{*/"}"); if (name) output_fputs(fp, ";\n"); trace((/*{*/"}\n")); } static void *gstate_where_alloc _((void)); static void * gstate_where_alloc() { gstate_where this; trace(("gstate_where_alloc()\n{\n"/*}*/)); this = mem_alloc(sizeof(struct gstate_where)); this->reference_count = 1; this->mask = 0; this->project_name = 0; this->directory = 0; this->alias_for = 0; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } gstate_where gstate_where_copy(this) gstate_where this; { trace(("gstate_where_copy()\n{\n"/*}*/)); this->reference_count++; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } static void gstate_where_free _((void *)); static void gstate_where_free(that) void *that; { gstate_where this = that; if (!this) return; this->reference_count--; assert(this->reference_count >= 0); if (this->reference_count > 0) return; trace(("gstate_where_free(this = %08lX)\n{\n"/*}*/, (long)this)); str_free(this->project_name); str_free(this->directory); str_free(this->alias_for); mem_free(this); trace((/*{*/"}\n")); } static type_table_ty gstate_where_table[] = { { "project_name", offsetof(struct gstate_where, project_name), &string_type, gstate_where_project_name_mask, }, { "directory", offsetof(struct gstate_where, directory), &string_type, gstate_where_directory_mask, }, { "alias_for", offsetof(struct gstate_where, alias_for), &string_type, gstate_where_alias_for_mask, }, }; static void *gstate_where_parse _((void *, string_ty *, type_ty **, unsigned long *)); static void * gstate_where_parse(this, name, type_pp, mask_p) void *this; string_ty *name; type_ty **type_pp; unsigned long *mask_p; { void *addr; trace(("gstate_where_parse(this = %08lX, name = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)name, (long)type_pp)); assert(((gstate_where)this)->reference_count > 0); assert(sizeof(gstate_where) == sizeof(generic_struct_ty *)); addr = generic_struct_parse ( this, name, type_pp, mask_p, gstate_where_table, SIZEOF(gstate_where_table) ); trace((/*{*/"return %08lX;\n}\n", (long)addr)); return addr; } static string_ty *gstate_where_fuzzy _((string_ty *)); static string_ty * gstate_where_fuzzy(name) string_ty *name; { string_ty *result; trace(("gstate_where_fuzzy(name = %08lX)\n{\n"/*}*/, (long)name)); result = generic_struct_fuzzy ( name, gstate_where_table, SIZEOF(gstate_where_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } static struct rpt_value_ty *gstate_where_convert _((void *)); static struct rpt_value_ty * gstate_where_convert(this) void *this; { struct rpt_value_ty *result; trace(("gstate_where_convert(name = %08lX)\n{\n"/*}*/, (long)this)); assert(((gstate_where)this)->reference_count > 0); result = generic_struct_convert ( this, gstate_where_table, SIZEOF(gstate_where_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } type_ty gstate_where_type = { "gstate_where", gstate_where_alloc, gstate_where_free, 0, /* enum_parse */ 0, /* list_parse */ gstate_where_parse, gstate_where_fuzzy, gstate_where_convert, generic_struct_is_set, }; #include void gstate_where_list_write(fp, name, this) output_ty *fp; char *name; gstate_where_list this; { size_t j; if (!this) return; trace(("gstate_where_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) { gstate_where_write(fp, (char *)0, this->list[j]); output_fputs(fp, ",\n"); } output_fputs(fp, /*[*/"]"); if (name) output_fputs(fp, ";\n"); trace((/*{*/"}\n")); } static void *gstate_where_list_alloc _((void)); static void * gstate_where_list_alloc() { gstate_where_list result; trace(("gstate_where_list_alloc()\n{\n"/*}*/)); result = mem_alloc(sizeof(struct gstate_where_list)); result->list = 0; result->length = 0; result->maximum = 0; trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } static void gstate_where_list_free _((void *)); static void gstate_where_list_free(that) void *that; { gstate_where_list this = that; size_t j; if (!this) return; trace(("gstate_where_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) gstate_where_free(this->list[j]); if (this->list) mem_free(this->list); mem_free(this); trace((/*{*/"}\n")); } static void *gstate_where_list_parse _((void *, type_ty **)); static void * gstate_where_list_parse(that, type_pp) void *that; type_ty **type_pp; { gstate_where_list this = that; void *addr; trace(("gstate_where_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 = &gstate_where_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 *gstate_where_list_convert _((void *)); static rpt_value_ty * gstate_where_list_convert(that) void *that; { gstate_where_list this; rpt_value_ty *result; size_t j; rpt_value_ty *vp; this = *(gstate_where_list *)that; if (!this) return 0; trace(("gstate_where_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 = gstate_where_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 gstate_where_list_type = { "gstate_where_list", gstate_where_list_alloc, gstate_where_list_free, 0, /* enum_parse */ gstate_where_list_parse, 0, /* struct_parse */ 0, /* fuzzy */ gstate_where_list_convert, generic_struct_is_set, }; void gstate_write(fp, this) output_ty *fp; gstate this; { if (!this) return; trace(("gstate_write(this = %08lX)\n{\n"/*}*/, this)); assert(((gstate)this)->reference_count > 0); trace(("rc = %d;\n", ((gstate)this)->reference_count)); gstate_where_list_write(fp, "where", this->where); trace((/*{*/"}\n")); } static void *gstate_alloc _((void)); static void * gstate_alloc() { gstate this; trace(("gstate_alloc()\n{\n"/*}*/)); this = mem_alloc(sizeof(struct gstate)); this->reference_count = 1; this->mask = 0; this->where = 0; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } gstate gstate_copy(this) gstate this; { trace(("gstate_copy()\n{\n"/*}*/)); this->reference_count++; trace(("return %08lX;\n", (long)this)); trace((/*{*/"}\n")); return this; } static void gstate_free _((void *)); static void gstate_free(that) void *that; { gstate this = that; if (!this) return; this->reference_count--; assert(this->reference_count >= 0); if (this->reference_count > 0) return; trace(("gstate_free(this = %08lX)\n{\n"/*}*/, (long)this)); gstate_where_list_free(this->where); mem_free(this); trace((/*{*/"}\n")); } static type_table_ty gstate_table[] = { { "where", offsetof(struct gstate, where), &gstate_where_list_type, gstate_where_mask, }, }; static void *gstate_parse _((void *, string_ty *, type_ty **, unsigned long *)); static void * gstate_parse(this, name, type_pp, mask_p) void *this; string_ty *name; type_ty **type_pp; unsigned long *mask_p; { void *addr; trace(("gstate_parse(this = %08lX, name = %08lX, type_pp = %08lX)\n{\n"/*}*/, (long)this, (long)name, (long)type_pp)); assert(((gstate)this)->reference_count > 0); assert(sizeof(gstate) == sizeof(generic_struct_ty *)); addr = generic_struct_parse ( this, name, type_pp, mask_p, gstate_table, SIZEOF(gstate_table) ); trace((/*{*/"return %08lX;\n}\n", (long)addr)); return addr; } static string_ty *gstate_fuzzy _((string_ty *)); static string_ty * gstate_fuzzy(name) string_ty *name; { string_ty *result; trace(("gstate_fuzzy(name = %08lX)\n{\n"/*}*/, (long)name)); result = generic_struct_fuzzy ( name, gstate_table, SIZEOF(gstate_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } static struct rpt_value_ty *gstate_convert _((void *)); static struct rpt_value_ty * gstate_convert(this) void *this; { struct rpt_value_ty *result; trace(("gstate_convert(name = %08lX)\n{\n"/*}*/, (long)this)); assert(((gstate)this)->reference_count > 0); result = generic_struct_convert ( this, gstate_table, SIZEOF(gstate_table) ); trace(("return %08lX;\n", (long)result)); trace((/*{*/"}\n")); return result; } type_ty gstate_type = { "gstate", gstate_alloc, gstate_free, 0, /* enum_parse */ 0, /* list_parse */ gstate_parse, gstate_fuzzy, gstate_convert, generic_struct_is_set, }; gstate gstate_read_file(filename) string_ty *filename; { gstate result; trace(("gstate_read_file(filename = \"%s\")\n{\n"/*}*/, (filename ? filename->str_text : ""))); os_become_must_be_active(); result = parse(filename, &gstate_type); trace(("return %08lX;\n", result)); trace((/*{*/"}\n")); return result; } void gstate_write_file(filename, value, compress) string_ty *filename; gstate value; int compress; { output_ty *fp; trace(("gstate_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); gstate_write(fp, value); type_enum_option_clear(); output_delete(fp); trace((/*{*/"}\n")); } void gstate__rpt_init() { trace(("gstate__rpt_init()\n{\n"/*}*/)); trace((/*{*/"}\n")); }