resrc.c
来自「基于4个mips核的noc设计」· C语言 代码 · 共 2,671 行 · 第 1/5 页
C
2,671 行
else { if (level == 3) { /* This is the normal case: the three levels are TYPE/NAME/LANGUAGE. NAME will have been set at level 2, and represents the name to use. We probably just set LANGUAGE, and it will probably match what the resource itself records if anything. */ write_rc_resource (e, type, name, re->u.res, language); } else { fprintf (e, "// Resource at unexpected level %d\n", level); write_rc_resource (e, type, (struct res_id *) NULL, re->u.res, language); } } }}/* Write out a subdirectory entry. E is the file to write to. RE is the subdirectory entry. TYPE and NAME are pointers to higher level IDs, or NULL. LANGUAGE is a pointer to the current language. LEVEL is the level in the tree. */static voidwrite_rc_subdir (e, re, type, name, language, level) FILE *e; const struct res_entry *re; const struct res_id *type; const struct res_id *name; int *language; int level;{ fprintf (e, "\n"); switch (level) { case 1: fprintf (e, "// Type: "); if (re->id.named) res_id_print (e, re->id, 1); else { const char *s; switch (re->id.u.id) { case RT_CURSOR: s = "cursor"; break; case RT_BITMAP: s = "bitmap"; break; case RT_ICON: s = "icon"; break; case RT_MENU: s = "menu"; break; case RT_DIALOG: s = "dialog"; break; case RT_STRING: s = "stringtable"; break; case RT_FONTDIR: s = "fontdir"; break; case RT_FONT: s = "font"; break; case RT_ACCELERATOR: s = "accelerators"; break; case RT_RCDATA: s = "rcdata"; break; case RT_MESSAGETABLE: s = "messagetable"; break; case RT_GROUP_CURSOR: s = "group cursor"; break; case RT_GROUP_ICON: s = "group icon"; break; case RT_VERSION: s = "version"; break; case RT_DLGINCLUDE: s = "dlginclude"; break; case RT_PLUGPLAY: s = "plugplay"; break; case RT_VXD: s = "vxd"; break; case RT_ANICURSOR: s = "anicursor"; break; case RT_ANIICON: s = "aniicon"; break; default: s = NULL; break; } if (s != NULL) fprintf (e, "%s", s); else res_id_print (e, re->id, 1); } fprintf (e, "\n"); break; case 2: fprintf (e, "// Name: "); res_id_print (e, re->id, 1); fprintf (e, "\n"); break; case 3: fprintf (e, "// Language: "); res_id_print (e, re->id, 1); fprintf (e, "\n"); break; default: fprintf (e, "// Level %d: ", level); res_id_print (e, re->id, 1); fprintf (e, "\n"); } write_rc_directory (e, re->u.dir, type, name, language, level + 1);}/* Write out a single resource. E is the file to write to. TYPE is a pointer to the type of the resource. NAME is a pointer to the name of the resource; it will be NULL if there is a level mismatch. RES is the resource data. LANGUAGE is a pointer to the current language. */static voidwrite_rc_resource (e, type, name, res, language) FILE *e; const struct res_id *type; const struct res_id *name; const struct res_resource *res; int *language;{ const char *s; int rt; int menuex = 0; fprintf (e, "\n"); switch (res->type) { default: abort (); case RES_TYPE_ACCELERATOR: s = "ACCELERATOR"; rt = RT_ACCELERATOR; break; case RES_TYPE_BITMAP: s = "BITMAP"; rt = RT_BITMAP; break; case RES_TYPE_CURSOR: s = "CURSOR"; rt = RT_CURSOR; break; case RES_TYPE_GROUP_CURSOR: s = "GROUP_CURSOR"; rt = RT_GROUP_CURSOR; break; case RES_TYPE_DIALOG: if (extended_dialog (res->u.dialog)) s = "DIALOGEX"; else s = "DIALOG"; rt = RT_DIALOG; break; case RES_TYPE_FONT: s = "FONT"; rt = RT_FONT; break; case RES_TYPE_FONTDIR: s = "FONTDIR"; rt = RT_FONTDIR; break; case RES_TYPE_ICON: s = "ICON"; rt = RT_ICON; break; case RES_TYPE_GROUP_ICON: s = "GROUP_ICON"; rt = RT_GROUP_ICON; break; case RES_TYPE_MENU: if (extended_menu (res->u.menu)) { s = "MENUEX"; menuex = 1; } else { s = "MENU"; menuex = 0; } rt = RT_MENU; break; case RES_TYPE_MESSAGETABLE: s = "MESSAGETABLE"; rt = RT_MESSAGETABLE; break; case RES_TYPE_RCDATA: s = "RCDATA"; rt = RT_RCDATA; break; case RES_TYPE_STRINGTABLE: s = "STRINGTABLE"; rt = RT_STRING; break; case RES_TYPE_USERDATA: s = NULL; rt = 0; break; case RES_TYPE_VERSIONINFO: s = "VERSIONINFO"; rt = RT_VERSION; break; } if (rt != 0 && type != NULL && (type->named || type->u.id != (unsigned long) rt)) { fprintf (e, "// Unexpected resource type mismatch: "); res_id_print (e, *type, 1); fprintf (e, " != %d", rt); } if (res->coff_info.codepage != 0) fprintf (e, "// Code page: %lu\n", res->coff_info.codepage); if (res->coff_info.reserved != 0) fprintf (e, "// COFF reserved value: %lu\n", res->coff_info.reserved); if (name != NULL) res_id_print (e, *name, 0); else fprintf (e, "??Unknown-Name??"); fprintf (e, " "); if (s != NULL) fprintf (e, "%s", s); else if (type != NULL) res_id_print (e, *type, 0); else fprintf (e, "??Unknown-Type??"); if (res->res_info.memflags != 0) { if ((res->res_info.memflags & MEMFLAG_MOVEABLE) != 0) fprintf (e, " MOVEABLE"); if ((res->res_info.memflags & MEMFLAG_PURE) != 0) fprintf (e, " PURE"); if ((res->res_info.memflags & MEMFLAG_PRELOAD) != 0) fprintf (e, " PRELOAD"); if ((res->res_info.memflags & MEMFLAG_DISCARDABLE) != 0) fprintf (e, " DISCARDABLE"); } if (res->type == RES_TYPE_DIALOG) { fprintf (e, " %d, %d, %d, %d", res->u.dialog->x, res->u.dialog->y, res->u.dialog->width, res->u.dialog->height); if (res->u.dialog->ex != NULL && res->u.dialog->ex->help != 0) fprintf (e, ", %lu", res->u.dialog->ex->help); } fprintf (e, "\n"); if ((res->res_info.language != 0 && res->res_info.language != *language) || res->res_info.characteristics != 0 || res->res_info.version != 0) { int modifiers; switch (res->type) { case RES_TYPE_ACCELERATOR: case RES_TYPE_DIALOG: case RES_TYPE_MENU: case RES_TYPE_RCDATA: case RES_TYPE_STRINGTABLE: modifiers = 1; break; default: modifiers = 0; break; } if (res->res_info.language != 0 && res->res_info.language != *language) fprintf (e, "%sLANGUAGE %d, %d\n", modifiers ? "// " : "", res->res_info.language & 0xff, (res->res_info.language >> 8) & 0xff); if (res->res_info.characteristics != 0) fprintf (e, "%sCHARACTERISTICS %lu\n", modifiers ? "// " : "", res->res_info.characteristics); if (res->res_info.version != 0) fprintf (e, "%sVERSION %lu\n", modifiers ? "// " : "", res->res_info.version); } switch (res->type) { default: abort (); case RES_TYPE_ACCELERATOR: write_rc_accelerators (e, res->u.acc); break; case RES_TYPE_CURSOR: write_rc_cursor (e, res->u.cursor); break; case RES_TYPE_GROUP_CURSOR: write_rc_group_cursor (e, res->u.group_cursor); break; case RES_TYPE_DIALOG: write_rc_dialog (e, res->u.dialog); break; case RES_TYPE_FONTDIR: write_rc_fontdir (e, res->u.fontdir); break; case RES_TYPE_GROUP_ICON: write_rc_group_icon (e, res->u.group_icon); break; case RES_TYPE_MENU: write_rc_menu (e, res->u.menu, menuex); break; case RES_TYPE_RCDATA: write_rc_rcdata (e, res->u.rcdata, 0); break; case RES_TYPE_STRINGTABLE: write_rc_stringtable (e, name, res->u.stringtable); break; case RES_TYPE_USERDATA: write_rc_rcdata (e, res->u.userdata, 0); break; case RES_TYPE_VERSIONINFO: write_rc_versioninfo (e, res->u.versioninfo); break; case RES_TYPE_BITMAP: case RES_TYPE_FONT: case RES_TYPE_ICON: case RES_TYPE_MESSAGETABLE: write_rc_filedata (e, res->u.data.length, res->u.data.data); break; }}/* Write out accelerator information. */static voidwrite_rc_accelerators (e, accelerators) FILE *e; const struct accelerator *accelerators;{ const struct accelerator *acc; fprintf (e, "BEGIN\n"); for (acc = accelerators; acc != NULL; acc = acc->next) { int printable; fprintf (e, " "); if ((acc->key & 0x7f) == acc->key && isprint ((unsigned char) acc->key) && (acc->flags & ACC_VIRTKEY) == 0) { fprintf (e, "\"%c\"", acc->key); printable = 1; } else { fprintf (e, "%d", acc->key); printable = 0; } fprintf (e, ", %d", acc->id); if (! printable) { if ((acc->flags & ACC_VIRTKEY) != 0) fprintf (e, ", VIRTKEY"); else fprintf (e, ", ASCII"); } if ((acc->flags & ACC_SHIFT) != 0) fprintf (e, ", SHIFT"); if ((acc->flags & ACC_CONTROL) != 0) fprintf (e, ", CONTROL"); if ((acc->flags & ACC_ALT) != 0) fprintf (e, ", ALT"); fprintf (e, "\n"); } fprintf (e, "END\n");}/* Write out cursor information. This would normally be in a separate file, which the rc file would include. */static voidwrite_rc_cursor (e, cursor) FILE *e; const struct cursor *cursor;{ fprintf (e, "// Hotspot: x: %d; y: %d\n", cursor->xhotspot, cursor->yhotspot); write_rc_filedata (e, cursor->length, cursor->data);}/* Write out group cursor data. This would normally be built from the cursor data. */static voidwrite_rc_group_cursor (e, group_cursor) FILE *e; const struct group_cursor *group_cursor;{ const struct group_cursor *gc; for (gc = group_cursor; gc != NULL; gc = gc->next) { fprintf (e, "// width: %d; height %d; planes %d; bits %d\n", gc->width, gc->height, gc->planes, gc->bits); fprintf (e, "// data bytes: %lu; index: %d\n", gc->bytes, gc->index); }}/* Write dialog data. */static voidwrite_rc_dialog (e, dialog) FILE *e; const struct dialog *dialog;{ const struct dialog_control *control; if (dialog->style != 0) fprintf (e, "STYLE 0x%lx\n", dialog->style); if (dialog->exstyle != 0) fprintf (e, "EXSTYLE 0x%lx\n", dialog->exstyle); if ((dialog->class.named && dialog->class.u.n.length > 0) || dialog->class.u.id != 0) { fprintf (e, "CLASS "); res_id_print (e, dialog->class, 0); fprintf (e, "\n"); } if (dialog->caption != NULL) { fprintf (e, "CAPTION \""); unicode_print (e, dialog->caption, -1); fprintf (e, "\"\n"); } if ((dialog->menu.named && dialog->menu.u.n.length > 0) || dialog->menu.u.id != 0) { fprintf (e, "MENU "); res_id_print (e, dialog->menu, 0); fprintf (e, "\n"); } if (dialog->font != NULL) { fprintf (e, "FONT %d, \"", dialog->pointsize); unicode_print (e, dialog->font, -1); fprintf (e, "\""); if (dialog->ex != NULL && (dialog->ex->weight != 0 || dialog->ex->italic != 0)) fprintf (e, ", %d, %d", dialog->ex->weight, dialog->ex->italic); fprintf (e, "\n"); } fprintf (e, "BEGIN\n"); for (control = dialog->controls; control != NULL; control = control->next) write_rc_dialog_control (e, control); fprintf (e, "END\n");}/* For each predefined control keyword, this table provides the class and the style. */struct control_info{ const char *name; unsigned short class; unsigned long style;};static const struct control_info control_info[] ={ { "AUTO3STATE", CTL_BUTTON, BS_AUTO3STATE }, { "AUTOCHECKBOX", CTL_BUTTON, BS_AUTOCHECKBOX }, { "AUTORADIOBUTTON", CTL_BUTTON, BS_AUTORADIOBUTTON }, { "CHECKBOX", CTL_BUTTON, BS_CHECKBOX }, { "COMBOBOX", CTL_COMBOBOX, (unsigned long) -1 }, { "CTEXT", CTL_STATIC, SS_CENTER }, { "DEFPUSHBUTTON", CTL_BUTTON, BS_DEFPUSHBUTTON }, { "EDITTEXT", CTL_EDIT, (unsigned long) -1 }, { "GROUPBOX", CTL_BUTTON, BS_GROUPBOX }, { "ICON", CTL_STATIC, SS_ICON }, { "LISTBOX", CTL_LISTBOX, (unsigned long) -1 }, { "LTEXT", CTL_STATIC, SS_LEFT }, { "PUSHBOX", CTL_BUTTON, BS_PUSHBOX }, { "PUSHBUTTON", CTL_BUTTON, BS_PUSHBUTTON }, { "RADIOBUTTON", CTL_BUTTON, BS_RADIOBUTTON }, { "RTEXT", CTL_STATIC, SS_RIGHT }, { "SCROLLBAR", CTL_SCROLLBAR, (unsigned long) -1 }, { "STATE3", CTL_BUTTON, BS_3STATE }, /* It's important that USERBUTTON come after all the other button types, so that it won't be matched too early. */ { "USERBUTTON", CTL_BUTTON, (unsigned long) -1 }, { NULL, 0, 0 }};/* Write a dialog control. */static voidwrite_rc_dialog_control (e, control) FILE *e; const struct dialog_control *control;{
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?