void guiSave( void ) { int i = ( guiMenu ? IupGetInt ( guiMenu, "MEDIT_I" ) : guiMenu_Org ); char path[ PATH_MAX ] = {0}; char opath[ PATH_MAX ] = {0}; if ( !appMethods.OnDefPath || !appMethods.OnDefExt ) { return; } copystri ( path, ipGetUsrDir(), PATH_MAX ); appendstr ( path, DIR_SEP ".medit" DIR_SEP "data", PATH_MAX ); copystri ( opath, path, PATH_MAX ); appMethods.OnDefPath ( opath ); appMethods.OnApply(); appMethods.OnDefPath ( path ); // Rename Directory if ( _access( opath, 0 ) == 0 && istrcmp( opath, path ).i ) { rename( opath, path ); } if ( i >= guiMenu_Hacks ) { appendstr ( opath, "*.", PATH_MAX ); appendstr ( path, "*.", PATH_MAX ); } else { appendstr ( opath, ".", PATH_MAX ); appendstr ( path, ".", PATH_MAX ); } appMethods.OnDefExt ( path ); appMethods.OnDefExt ( opath ); // Rename File if ( i < guiMenu_Hacks && _access( opath, 0 ) == 0 && istrcmp( opath, path ).i ) { rename( opath, path ); } if ( i >= guiMenu_Hacks ) { if ( IupGetFile ( path ) == -1 ) { return; } } if ( _access( path, 0 ) != 0 ) { _creat( path, _S_IREAD | _S_IWRITE ); } appMethods.OnSave ( path ); }
/* tracereturn - generate code to trace return e */ static void tracereturn(Symbol printer, Symbol f, Tree e) { appendstr(f->name); appendstr("#"); tracevalue(idtree(frameno), 0); appendstr(" returned"); if (freturn(f->type) != voidtype && e) { appendstr(" "); tracevalue(e, 0); } appendstr("\n"); tracefinis(printer); }
void guiLoad ( uchar useDlg ) { // FIXME: i = 0 when attempt to load hacks int i = ( guiMenu ? IupGetInt ( guiMenu, "MEDIT_I" ) : guiMenu_Org ); char path[ PATH_MAX ] = {0}; if ( !appMethods.OnDefPath || !appMethods.OnDefExt ) { return; } copystri ( path, ipGetUsrDir(), PATH_MAX ); appendstr ( path, DIR_SEP ".medit" DIR_SEP "data", PATH_MAX ); appMethods.OnDefPath ( path ); if ( useDlg || i >= guiMenu_Hacks ) { appendstr ( path, "*.", PATH_MAX ); } else { appendstr ( path, ".", PATH_MAX ); } appMethods.OnDefExt ( path ); if ( useDlg || i >= guiMenu_Hacks ) { if ( IupGetFile ( path ) == -1 ) { return; } } if ( _access( path, 0 ) != 0 ) { _creat( path, _S_IREAD | _S_IWRITE ); } appMethods.OnLoad ( path ); appMethods.OnReset(); }
static DECL_SYMBOL_ACTION(module_define_entry) { char *tag, *name, *base; int parts; char *cmdptr = 0L, *retstr; int ret; command_arg_get_string(SYM_ARG_1st, &tag); command_arg_get_string(SYM_ARG_2nd, &name); command_arg_get_string(SYM_ARG_3rd, &base); command_arg_get_num(SYM_ARG_4th, &parts); /* Define commands that will load this module */ cmdptr = appendstr(cmdptr, "UnloadModule"); if (parts & MOD_PART_GRAMKRACKER) { /* Do the work to find all the parts */ retstr = module_lookup_gram_kracker(cmdptr, base); if (!retstr) { xfree(cmdptr); return 0; } cmdptr = retstr; } if (parts & MOD_PART_GROM) { cmdptr = appendstr(cmdptr, "; DefineMemory \"RMG\" 0x6000 0x0000 " "\"%sg.bin\" 0x0 \"GROM for %s\"", base, name); } if (parts & MOD_PART_BANKED) { cmdptr = appendstr(cmdptr, "; DefineMemory \"RM1C\" 0x6000 0x2000 " "\"%sc.bin\" 0x0 \"Bank 1 for %s\"", base, name); cmdptr = appendstr(cmdptr, "; DefineMemory \"RM2C\" 0x6000 0x2000 " "\"%sd.bin\" 0x0 \"Bank 2 for %s\"", base, name); } else if (parts & MOD_PART_ROM) { cmdptr = appendstr(cmdptr, "; DefineMemory \"RMC\" 0x6000 0x2000 " "\"%sc.bin\" 0x0 \"ROM for %s\"", base, name); } if (parts & MOD_PART_MINIMEM) { cmdptr = appendstr(cmdptr, "; DefineMemory \"SMC\" 0x7000 0x1000 " "\"%sr.bin\" 0x0 \"Mini-Memory RAM for %s\"", base, name); } ret = module_change_entry(tag, name, base, cmdptr); xfree(cmdptr); return ret; }
static int f_write(lua_State *L) { int top, i; struct iob *ob = getiob(L, 1); erronclosed(L, ob); top = lua_gettop(L); for (i = 2; i <= top; i++) { size_t len; const char *s; s = luaL_checklstring(L, i, &len); if (!appendstr(ob, s, len)) { lua_pushliteral(L, "error appending to iostring"); lua_error(L); } } lua_pushboolean(L, 1); return 1; }
/* tracecall - generate code to trace entry to f */ static void tracecall(Symbol printer, Symbol f, void *ignore) { int i; Symbol counter = genident(STATIC, inttype, GLOBAL); defglobal(counter, BSS); (*IR->space)(counter->type->size); frameno = genident(AUTO, inttype, level); addlocal(frameno); appendstr(f->name); appendstr("#"); tracevalue(asgn(frameno, incr(INCR, idtree(counter), consttree(1, inttype))), 0); appendstr("("); for (i = 0; f->u.f.callee[i]; i++) { if (i) appendstr(","); appendstr(f->u.f.callee[i]->name); appendstr("="); tracevalue(idtree(f->u.f.callee[i]), 0); } if (variadic(f->type)) appendstr(",..."); appendstr(") called\n"); tracefinis(printer); }
static bool module_find_gram_kracker_segment(char *namebuf, OSSpec *spec, gram_kracker_header *header, bool *had_rom_segment, bool *is_banked, char **cmdptr) { if (data_find_gram_kracker(modulespath, namebuf, spec, header)) { if (header->gk_type == GK_TYPE_ROM_2 || *had_rom_segment) { // assume so... we go backwards through the types, // so we could see #2 before #1 *is_banked = true; *had_rom_segment = true; } // note the extra space, this is to patch the string later *cmdptr = appendstr(*cmdptr, "; DefineMemory \"RM%s\" 0x%04x 0x%04x " "\"%s\" %d \"GRAM Kracker segment type %d\"", header->gk_type == GK_TYPE_ROM_1 ? (*is_banked ? "C1" : "C") : header->gk_type == GK_TYPE_ROM_2 ? "C2" : "G", header->address, header->length, namebuf, header->absolute_image_file_offset, header->gk_type); return true; } else { return false; } }
/* take filename w/o comp ext. as arg, return comp->stem as a relative compressed file or NULL if none found */ struct compression *comp_file (const char *filename) { size_t len; char *compfile; struct compression *comp; compfile = xasprintf ("%s.", filename); len = strlen (compfile); for (comp = comp_list; comp->ext; comp++) { struct stat buf; compfile = appendstr (compfile, comp->ext, NULL); if (stat (compfile, &buf) == 0) { comp->stem = compfile; return comp; } *(compfile + len) = '\0'; } free (compfile); return NULL; }
LRESULT CALLBACK EditProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ char bstr[MAX_PATH]; char *p,c; int i,k,n,o,r,f; POINT pt; struct edvars *ev; r = 0; //if (domove(GetParent(hwnd),message,wParam,lParam)) return 0; switch (message) { case WM_COPYDATA: if (0x4F4E4242 == ((PCOPYDATASTRUCT)lParam)->dwData) { char buff[MAX_PATH]; int line_nr; const char *file = (const char*)((PCOPYDATASTRUCT)lParam)->lpData; getfile(buff, file, &line_nr); set_currentdir(buff); LoadFile(buff); if (line_nr) { ed_cmd(EK_GOTOLINE,line_nr-1); //ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1))); } r = TRUE; goto p0r; } return bbn_receive_data(hwnd, lParam); default: if (bb_broadcast_msg == message && message) { if (bb_register(hwnd) && bb_getstyle(hwnd)) goto reconfig1; return 0; } break; case BB_RECONFIGURE: if (bb_getstyle(hwnd)) goto reconfig1; return 0; reconfig1: bb_close_dlg(); makedlgfont(); reconfig: zy0 = title_h + FRM-1; setsize(hwnd); new_back(); InvalidateRect(hwnd, NULL, FALSE); return 0; case BB_SETSTYLESTRUCT: { StyleStruct *d = (StyleStruct *)wParam; StyleStruct *s = (StyleStruct *)lParam; memset(d, 0, sizeof *d); memcpy(d, s, sizeof *d); break; } case BB_SETSTYLE: { char *d = (char *)wParam; char *s = (char *)lParam; strcpy(d, s); break; } case WM_CREATE: zy0 = title_h + FRM-1; setsize(ewnd=hwnd); dragC = LoadCursor(hInst,MAKEINTRESOURCE(101)); dragCp = LoadCursor(hInst,MAKEINTRESOURCE(102)); pointC = hCurs = LoadCursor(NULL,IDC_ARROW); init_edit(hwnd); DragAcceptFiles(hwnd,TRUE); if (false == bb_register(hwnd) || false == bb_getstyle(hwnd)) readstyle(defstyle); goto reconfig1; case WM_DROPFILES: { POINT pt; HDROP hDrop = (HDROP)wParam; int n,f; ev=edp; f=0; GetCursorPos(&pt); if (GetAsyncKeyState(VK_CONTROL)<0) f=1; if (GetAsyncKeyState(VK_SHIFT)<0) f=2; if (f) ScreenToClient(hwnd,&pt); for (i=-1, k=0; i<k; i++) { n=DragQueryFile (hDrop, i, p=bstr, 255); if (i<0) { k=n; } else if (f==0) { LoadFile(p); } else if (f==2) { if (readstyle(p)) { CopyFile(p, defstyle, FALSE); } break; } else { if (i == 0 && -1 == getmoupos(pt.x ,pt.y)) break; ed_cmd(EK_SETVAR); ed_cmd(EK_INSERT, p); ed_cmd(KEY_RET); } } DragFinish(hDrop); SetForegroundWindow(hwnd); if (f==0) goto showf; if (f==2) goto reconfig1; goto p0; } case WM_QUERYENDSESSION: return (1 == QueryDiscard(hwnd,1)); case WM_ENDSESSION: { //void savecfg(void); savecfg(); return 0; } case WM_DESTROY: exit_edit(); DragAcceptFiles(hwnd,FALSE); bb_unregister(hwnd); PostQuitMessage(0); return 0 ; case WM_ACTIVATE: i=LOWORD(wParam); if (i==WA_ACTIVE) clickflag=0; return 0; case WM_ACTIVATEAPP: if (wParam) { clickflag=2; } return 0; case WM_LBUTTONDOWN: case WM_RBUTTONDOWN: if (alt_f) alt_f=2; case WM_MOUSEMOVE: #if 0 { static int wm; i = (short)HIWORD(lParam)/2; n = wm; wm = i; wParam = MAKELPARAM(0,(n-i)*30); goto mwhl; } #endif case WM_LBUTTONDBLCLK: case WM_LBUTTONUP: case WM_RBUTTONUP: case WM_MBUTTONUP: case WM_MBUTTONDOWN: if (drag==0 && domove (hwnd, message, wParam, lParam)) return 0; do_mouse(hwnd, wParam, lParam, message); if (message==WM_MOUSEMOVE && 0==(wParam & (MK_LBUTTON | MK_RBUTTON))) return 0; goto p0; case WM_TIMER: if (wParam==2) { resetmsg(hwnd); goto p0; } if (wParam==4) { mousewheelaccu=0; t0: KillTimer(hwnd, wParam); return 0; } GetCursorPos(&pt); ScreenToClient(hwnd,&pt); o=getmoupos(pt.x ,pt.y); if (o!=tcmd) { settimer(hwnd, o, SCROLL_INTERVAL); return 0; } if (tcmd==0) goto t0; c=ltup; ltup=0; ed_cmd(tcmd); ed_cmd(tcmd); upd=1; ltup=c; k=GetAsyncKeyState(VK_SHIFT)&0x8000; domarking(k!=0 || (0==moumrk && 0==drag)); goto p0; case WM_SIZE: if (SIZE_MINIMIZED == wParam) return 0; if (edp) upd=1; ed_cmd(EK_SIZE); new_back(); case WM_MOVE: setsize(hwnd); goto p0; /* case WM_WINDOWPOSCHANGED: ewx0 = ((LPWINDOWPOS) lParam)->x; ewy0 = ((LPWINDOWPOS) lParam)->y; ewxl = ((LPWINDOWPOS) lParam)->cx; ewyl = ((LPWINDOWPOS) lParam)->cy; cfg_f |= 1; break; //process wm_move/wm_size case WM_WINDOWPOSCHANGING: SnapWindowToEdge((WINDOWPOS*)lParam, 10, 0); setsize(hwnd); return 0; */ case WM_VSCROLL: vscroll(wParam); goto p0; case WM_HSCROLL: hscroll(wParam); goto p0; case WM_SETFOCUS: k_alt = 0>GetAsyncKeyState(VK_MENU); k_shft= 0>GetAsyncKeyState(VK_SHIFT); k_ctrl= 0>GetAsyncKeyState(VK_CONTROL); CreateCaret(hwnd,NULL,My_CaretSize,zy); caret=1; checkftime(hwnd); goto f1; case WM_KILLFOCUS: DestroyCaret(); caret=0; f1: if (edp) upd=1; goto p0; p0: r=0; p0r: set_update(hwnd); return r; case WM_ERASEBKGND: return 1; case WM_PAINT: paint_window (hwnd); return 0; case WM_COMMAND: switch (LOWORD(wParam)) { case CMD_HELP: #if 0 bbnote_help(); return 0; #else if (fileexist(set_my_path(bstr, "bbnote.txt"))) LoadFile(bstr); else if (fileexist(set_my_path(bstr, "docs/bbnote.txt"))) LoadFile(bstr); goto p0; #endif case CMD_EXIT: goto quit; case CMD_MENU_2: filemenu: if (ed0) { struct edvars *e = ed0; struct strl *s = NULL; while (e) { char temp[MAX_PATH]; sprintf(temp, "&%s", fname(e->sfilename)); appendstr(&s, temp); e = e->next; } bb_file_menu (hwnd, lParam, s); } return 0; case CMD_MENU_1: bb_menu(hwnd, lParam); return 0; case CMD_COLOR: goto reconfig; case CMD_UPD: settitle(); if (edp) upd=1; goto p0; case CMD_ZOOM: zoom: ShowWindow(hwnd, IsZoomed(hwnd) ? SW_SHOWNORMAL : SW_MAXIMIZE); return 0; case CMD_SEARCH: search: if (edp) bb_search_dialog(hwnd); return 0; case CMD_CLOSE: closefile: if (edp) { if (1 != QueryDiscard_1(hwnd, 1)) goto p0; if (ed0->next==NULL) { extern HWND mwnd; SendMessage(mwnd, WM_KEYDOWN, VK_ESCAPE, 0); //DestroyWindow(mwnd); } CloseFile(); } goto p0; case CMD_OPEN: openfile: ev=edp; DoFileOpenSave(hwnd, 0); showf: if (ev==NULL || ev->next) { edp = ev ? ev->next : ed0; settitle(); } goto p0; case CMD_RELOAD: reload: if (edp) f_reload(1); goto p0; case CMD_LIST: lParam = 2; goto filemenu; case CMD_NEW: newfile: NewFile(); goto p0; case CMD_SAVE: savefile: if (edp) DoFileOpenSave(hwnd, 2); goto p0; case CMD_SAVEAS: if (edp!=NULL) DoFileOpenSave(hwnd, 1); break; case CMD_SAVEALL: //saveall: return QueryDiscard(hwnd, 0); case CMD_UNDO: ed_cmd(KEY_C_Z); goto p0; case CMD_REDO: ed_cmd(KEY_CS_Z); goto p0; case CMD_ABOUT: oyncan_msgbox( VERSION_STRING "\n" "\nediting with style" "\n04/2003 by grischka" "\n" "\[email protected]" , NULL, 1); return 0; case CMD_OPTIONS: goto config; case CMD_INFO: resetmsg(hwnd); p=(char*)lParam; if (p[0]==1) p++; else infoflg=1,infotimer=SetTimer(hwnd,2,666,NULL); strcpy(infomsg,p); if (edp) upd=1; goto p0; case CMD_FILECHG: { struct edvars *p=edp; edp=(struct edvars*)lParam; settitle(); set_update(hwnd); f_reload(0); edp=p; settitle(); goto p0; } default: i = LOWORD(wParam); if (i>=CMD_FILE && i< CMD_FILE_M) { struct edvars *p=ed0; i-=CMD_FILE; for (;i && p!=NULL; p=p->next,i--); if (p) { //edp = p; settitle(); insfile(p); goto p0; } return 0; } break; } break; quit: if (1 == QueryDiscard(hwnd, 1)) DestroyWindow(hwnd); return 0; case WM_SYSKEYDOWN: f=3; goto k1; case WM_SYSKEYUP: f=2; goto k1; case WM_KEYUP: if (wParam==VK_CONTROL && drag==3) setdragc(2); f=0; goto k1; case WM_KEYDOWN: if (wParam==VK_CONTROL && drag==2) setdragc(3); if (wParam==VK_SCROLL) { scroll_lock^=1; goto p0; } f=1; k1: n=LOWORD(wParam); #if 0 sprintf(bstr,"key %d stat %d",n,f); if (n!=VK_MENU) MessageBox(NULL, bstr, "", MB_OK|MB_TOPMOST|MB_SETFOREGROUND); #endif n=trans_keys(n, f); //if (0==n) goto p0; if (0==n) return 0; if (n>=2110 && n<=2117) { vmark=k_alt!=0; domarking(1); ed_cmd(n-100); domarking(1); goto p0; } switch (n) { case KEY_F8: return 0; case KEY_A_RIGHT: case KEY_F6: nextfile(); goto p0; case KEY_A_LEFT: case KEY_C_F6: prevfile(); goto p0; case KEY_F10: goto zoom; case KEY_F3: case KEY_C_F: goto search; case KEY_C_F4: goto closefile; case KEY_C_O: goto openfile; //case KEY_A_F3: goto reload; case KEY_C_N: goto newfile; case KEY_C_L: lParam = 0; goto filemenu; case KEY_F4: QueryDiscard(hwnd, 0); bb_reconfig(); return 0; case KEY_S_F4: if (IDOK == oyncan_msgbox("Do you want to write all files?", "", 1+8)) QueryDiscard(hwnd, 4); return 0; case KEY_C_S: goto savefile; case KEY_A_F4: goto quit; case KEY_A_F2: config: n = tabs; bb_config_dialog(hwnd); if (n!=tabs) goto reload; return 0; case KEY_ESC: if (drag==0) goto quit; dragmove=0; do_mouse(hwnd, 0,0,WM_LBUTTONUP); goto p0; case KEY_UP: case KEY_DOWN: if (scroll_lock) n+=200; goto defkey; case KEY_LEFT: case KEY_RIGHT: if (scroll_lock) n=(n^1)+204; goto defkey; } defkey: domarking(0); ed_cmd(n); i=n; if (i!=KEY_C_A && i!=KEY_C_U && i!=KEY_C_7 && i!=KEY_C_8 && i!=KEY_C_9 && i!=KEY_C_0 && i!=KEY_TAB && i!=KEY_S_TAB ) unmark(); goto p0; case WM_MOUSEWHEEL: i = mousewheelaccu + mousewheelfac * (short)HIWORD(wParam); while (i < -300) ed_cmd(KEY_C_DOWN), i+=600; while (i > 300) ed_cmd(KEY_C_UP), i-=600; mousewheelaccu=i; unmark(); SetTimer(hwnd, 4, 200, NULL); goto p0; case WM_NCPAINT: return 0; case WM_CHAR: n = LOWORD(wParam); if (n<32||n==127) return 0; resetmsg(hwnd); ed_cmd(EK_CHAR, n); goto p0; case CMD_GOTOLINE: ed_cmd(EK_GOTOLINE,wParam-1); ed_cmd(EK_MARK,lpos,imin(lpos+1,nextline(lpos,1))); lmf=2; goto p0; case CMD_LOADFILE: r=LoadFile((char*)wParam); goto p0r; case CMD_NSEARCH: resetmsg(hwnd); if (wParam&8) { ed_cmd(EK_REPLACE,(char *)lParam); if (wParam&1) ed_cmd(EK_GOTO,fpos+strlen((char*)lParam)); goto p0; } unmark(); if (wParam!=0) { struct sea *s=(struct sea *)lParam; struct edvars *ev0; for (ev0=edp;;) { r=ed_search(s); if (r || 0==(s->sf&128)) break; s->sf &= ~4; if (s->sf & 1) { if (edp->next==NULL) break; nextfile(); s->from=0; continue; } if (s->sf & 2) { if (edp==ed0) break; prevfile(); s->from=flen; continue; }} if (r<=0) { edp=ev0; settitle(); } else { ed_cmd(KEY_HOME); ed_cmd(EK_MARK,s->a,s->e); ed_cmd(EK_GOTO,s->a); } } goto p0r; } return DefWindowProc (hwnd, message, wParam, lParam) ; }
/* print out any matches found */ static void display (MYDBM_FILE dbf, struct mandata *info, const char *page) { struct mandata *newinfo; char *string, *whatis, *string_conv; const char *page_name; char *key; int line_len, rest; newinfo = resolve_pointers (dbf, info, page); whatis = get_whatis (newinfo, page); if (newinfo == NULL) newinfo = info; dbprintf (newinfo); if (newinfo->name) page_name = newinfo->name; else page_name = page; key = xasprintf ("%s (%s)", page_name, newinfo->ext); if (hashtable_lookup_structure (display_seen, key, strlen (key))) goto out; hashtable_install (display_seen, key, strlen (key), NULL); line_len = get_line_length (); if (!long_output && strlen (page_name) > (size_t) (line_len / 2)) string = xasprintf ("%.*s...", line_len / 2 - 3, page_name); else string = xstrdup (page_name); string = appendstr (string, " (", newinfo->ext, ")", NULL); if (!STREQ (newinfo->pointer, "-") && !STREQ (newinfo->pointer, page)) string = appendstr (string, " [", newinfo->pointer, "]", NULL); if (strlen (string) < (size_t) 20) { int i; string = xrealloc (string, 21); for (i = strlen (string); i < 20; ++i) string[i] = ' '; string[i] = '\0'; } string = appendstr (string, " - ", NULL); rest = line_len - strlen (string); if (!long_output && strlen (whatis) > (size_t) rest) { whatis[rest - 3] = '\0'; string = appendstr (string, whatis, "...\n", NULL); } else string = appendstr (string, whatis, "\n", NULL); string_conv = simple_convert (conv_to_locale, string); fputs (string_conv, stdout); free (string_conv); free (string); out: free (key); free (whatis); if (newinfo != info) free_mandata_struct (newinfo); }
/* tracevalue - append format and argument to print the value of e */ static void tracevalue(Tree e, int lev) { Type ty = unqual(e->type); switch (ty->op) { case INT: if (ty == chartype || ty == signedchar) appendstr("'\\x%02x'"); else if (ty == longtype) appendstr("0x%ld"); else appendstr("0x%d"); break; case UNSIGNED: if (ty == chartype || ty == unsignedchar) appendstr("'\\x%02x'"); else if (ty == unsignedlong) appendstr("0x%lx"); else appendstr("0x%x"); break; case FLOAT: if (ty == longdouble) appendstr("%Lg"); else appendstr("%g"); break; case POINTER: if (unqual(ty->type) == chartype || unqual(ty->type) == signedchar || unqual(ty->type) == unsignedchar) { static Symbol null; if (null == NULL) null = mkstr("(null)"); tracevalue(cast(e, unsignedtype), lev + 1); appendstr(" \"%.30s\""); e = condtree(e, e, pointer(idtree(null->u.c.loc))); } else { appendstr("("); appendstr(typestring(ty, "")); appendstr(")0x%x"); } break; case STRUCT: { Field q; appendstr("("); appendstr(typestring(ty, "")); appendstr("){"); for (q = ty->u.sym->u.s.flist; q; q = q->link) { appendstr(q->name); appendstr("="); tracevalue(field(addrof(e), q->name), lev + 1); if (q->link) appendstr(","); } appendstr("}"); return; } case UNION: appendstr("("); appendstr(typestring(ty, "")); appendstr("){...}"); return; case ARRAY: if (lev && ty->type->size > 0) { int i; e = pointer(e); appendstr("{"); for (i = 0; i < ty->size/ty->type->size; i++) { Tree p = (*optree['+'])(ADD, e, consttree(i, inttype)); if (isptr(p->type) && isarray(p->type->type)) p = retype(p, p->type->type); else p = rvalue(p); if (i) appendstr(","); tracevalue(p, lev + 1); } appendstr("}"); } else appendstr(typestring(ty, "")); return; default: assert(0); } e = cast(e, promote(ty)); args = tree(mkop(ARG,e->type), e->type, e, args); }
void search( ushort used ) { int prev = 0; ME_PIPE mepI = {0}, mepO = {0}, mepP = {0}; DWORD isEof = 0; schar iSz[] = { sizeof( lint ), sizeof( long ), sizeof( int ), sizeof( short ), sizeof( char ) }, *uSz = iSz, fSz[] = { sizeof( lpn ), sizeof( dpn ), sizeof( fpn ) }; int i = 0,// c = 5, qNo = 0; char szDmp[4] = {0}, szPath[10] = {0}, szNow[10] = "q", szOld[10] = {0}; char const fEx[] = ".mef", iEx[] = ".mes", uEx[] = ".meu"; ipFdOpen( mepI.fd, "test.xps", IP_O_RW, IP_D_RW ); snprintf( szDmp, 4, "%i", qNo ); appendstr( szNow, DIR_SEP, 10 ); copystri( szOld, szNow, 10 ); appendstr( szNow, szDmp, 10 ); if ( qNo ) { snprintf( szDmp, 4, "%i", qNo - 1 ); } else { copystri( szDmp, "0", 4 ); } appendstr( szOld, szDmp, 10 ); copystri( szPath, szNow, 10 ); appendstr( szPath, ".dmp", 10 ); ipFdOpen( mepO.fd, szPath, IP_O_MKFILE | IP_O_RW, IP_D_RW ); isEof = ipFdRdBuff( mepI.fd, mepI.buff, BUFSIZ ); do { ipFdWrBuff( mepO.fd, mepO.buff, BUFSIZ ); isEof = ipFdRdBuff( mepI.fd, mepI.buff, BUFSIZ ); } while ( isEof ); ipFdShut( mepI.fd ); ipFdShut( mepO.fd ); ipFdOpen( mepI.fd, szPath, IP_O_RW, IP_D_RW ); SEARCH( f, 3 ); SEARCH( i, 5 ); SEARCH( u, 5 ); /* Close Down Pipes */ if ( prev ) { ipFdShut( prev ); ipFdShut( mepP.fd ); } ipFdShut( mepI.fd ); }
int dbdelete (MYDBM_FILE dbf, const char *name, struct mandata *info) { datum key, cont; memset (&key, 0, sizeof key); memset (&cont, 0, sizeof cont); /* get entry for info */ debug ("Attempting delete of %s(%s) entry.\n", name, info->ext); MYDBM_SET (key, name_to_key (name)); cont = MYDBM_FETCH (dbf, key); if (!MYDBM_DPTR (cont)) { /* 0 entries */ MYDBM_FREE_DPTR (key); return NO_ENTRY; } else if (*MYDBM_DPTR (cont) != '\t') { /* 1 entry */ MYDBM_DELETE (dbf, key); MYDBM_FREE_DPTR (cont); } else { /* 2+ entries */ char **names, **ext; char *multi_content = NULL; datum multi_key; int refs, i, j; /* Extract all of the extensions associated with this key */ refs = list_extensions (MYDBM_DPTR (cont) + 1, &names, &ext); for (i = 0; i < refs; ++i) if (STREQ (names[i], name) && STREQ (ext[i], info->ext)) break; if (i >= refs) { free (names); free (ext); MYDBM_FREE_DPTR (cont); MYDBM_FREE_DPTR (key); return NO_ENTRY; } multi_key = make_multi_key (names[i], ext[i]); if (!MYDBM_EXISTS (dbf, multi_key)) { error (0, 0, _( "multi key %s does not exist"), MYDBM_DPTR (multi_key)); gripe_corrupt_data (); } MYDBM_DELETE (dbf, multi_key); MYDBM_FREE_DPTR (multi_key); /* refs *may* be 1 if all manual pages with this name have been deleted. In this case, we'll have to remove the key too */ if (refs == 1) { free (names); free (ext); MYDBM_FREE_DPTR (cont); MYDBM_DELETE (dbf, key); MYDBM_FREE_DPTR (key); return 0; } /* create our new multi content */ for (j = 0; j < refs; ++j) if (i != j) multi_content = appendstr (multi_content, "\t", names[j], "\t", ext[j], NULL); MYDBM_FREE_DPTR (cont); /* if refs = 2 do something else. Doesn't really matter as the gdbm db file does not shrink any after a deletion anyway */ MYDBM_SET (cont, multi_content); if (MYDBM_REPLACE (dbf, key, cont)) gripe_replace_key (MYDBM_DPTR (key)); free (names); free (ext); } MYDBM_FREE_DPTR (key); return 0; }
char *expandmacro(char *st) { char *buffer; char *pin, *pout; int cmd; char *argstart, *argend; char temp; char *remsg; //the size of buffer will never be larger than 100+4*len(st), I hope. buffer=malloc(100+strlen(st)*4); pin=st; pout=buffer; while(*pin!=0) { if(*pin!='\\') { *pout=*pin; pin++; pout++; } else { cmd=extractcommand(basecmdlist,pin+1,&argstart,&argend); if(cmd==-1) { *pout='\\'; *(pout+1)='\\'; pout+=2; pin++; } else { temp=*argend; *argend=0; switch(cmd) { case 0: pout=appendstr(pout,"\\<a href=\\\""); pout=appendstr(pout,argstart); pout=appendstr(pout,"\\\"\\>"); pout=appendstr(pout,argstart); pout=appendstr(pout,"\\</a\\>"); break; case 1: pout=appendstr(pout,"\\<img src=\\\""); pout=appendstr(pout,argstart); pout=appendstr(pout,"\\\"\\>"); break; case 2: remsg=expandmacro(argstart); pout=appendstr(pout,"\\<b\\>"); pout=appendstr(pout,remsg); pout=appendstr(pout,"\\</b\\>"); free(remsg); break; case 3: pout=appendstr(pout,argstart); break; case 4: remsg=expandmacro(argstart); pout=appendstr(pout,"\\<center\\>"); pout=appendstr(pout,remsg); pout=appendstr(pout,"\\</center\\>"); free(remsg); break; } *argend=temp; if(*argend=='}') pin=argend+1; else pin=argend; } } } *pout=0; return buffer; }