int main(int argc, char *argv[]) { GUIElement *menuBar, *menu; gui_init_debug(); gui_init(); gui_set_cmd_hander(do_command); gui_set_evt_hander(handle_event); menuBar = gui_new_menubar(); menu = gui_new_menu("File", file_menu_items, NUM_FILE_MENU_ITEMS); gui_add_menu_to_menubar(menuBar, menu); menu = gui_new_menu("Edit", edit_menu_items, NUM_EDIT_MENU_ITEMS); gui_add_menu_to_menubar(menuBar, menu); gMenuBar = menuBar; gui_add_rect_to_region(&gBottomElement->r); gui_start_redraw(); gui_redraw_all(); gui_fninish_redraw(); gui_main_loop(); gui_dispose_all_elements(); gui_end_debug(); color(15, 4, 4); totext(); return 0; }
int main(int argc, char *argv[]) { static struct prk prk; char filename[sizeof prk.name + sizeof ".PRK"]; if (argc > 2) { fprintf(stderr, "usage: prktext [park.PRK]\n"); return EXIT_FAILURE; } if (argc == 2) { if (prkin(&prk, argv[1])) { fprintf(stderr, "%s: can't read PRK file\n", argv[1]); return EXIT_FAILURE; } if (totext(&prk)) { fprintf(stderr, "<stdout>: can't write to file\n"); return EXIT_FAILURE; } } else { if (fromtext(&prk)) { fprintf(stderr, "<stdin>: can't read from file\n"); return EXIT_FAILURE; } sprintf(filename, "%s.PRK", prk.name); if (prkout(&prk, filename)) { fprintf(stderr, "%s: can't write to file\n", filename); return EXIT_FAILURE; } } return 0; }
int sniff_arp_fromwire(const byte *packet, size_t length) { const struct ether_arp *header = (struct ether_arp *)packet; uint16_t arphrd = ntohs(header->arp_hrd); uint16_t arppro = ntohs(header->arp_pro); uint16_t arpop = ntohs(header->arp_op); LOG_PRINTF(ARP, "-- ARP (%lu bytes)\n", length); LOG_PRINTF_INDENT(ARP, 2, "hrd: %u [%s]\n", arphrd, totext(ARP_ARRAY_HRD, arphrd)); // format of hardware address LOG_PRINTF_INDENT(ARP, 2, "pro: 0x%04x [%s]\n", arppro, totext(ARP_ARRAY_PRO, arppro)); // format of protocol address LOG_PRINTF_INDENT(ARP, 2, "hln: %u\n", header->arp_hln); // length of hardware address LOG_PRINTF_INDENT(ARP, 2, "pln: %u\n", header->arp_pln); // length of protocol address LOG_PRINTF_INDENT(ARP, 2, "op : %u [%s]\n", arpop, totext(ARP_ARRAY_OP, arpop)); LOG_PRINTF_INDENT(ARP, 2, "sha: %s\n", ether_ntoa((struct ether_addr *)&header->arp_sha)); // sender hardware address LOG_PRINTF_INDENT(ARP, 2, "spa: %s\n", inet_ntoa(*(struct in_addr *)&header->arp_spa)); // sender protocol address LOG_PRINTF_INDENT(ARP, 2, "tha: %s\n", ether_ntoa((struct ether_addr *)&header->arp_tha)); // target hardware address LOG_PRINTF_INDENT(ARP, 2, "tpa: %s\n", inet_ntoa(*(struct in_addr *)&header->arp_tpa)); // target protocol address return 0; }
void reset_all() { iniplt(); /* herstel kleuren */ color(15,4,4); totext(); }
static char* fswalk1(Fid *fid, char *name, Qid *qid) { char *q; int i, isdotdot, n, t; uvlong path; Aux *a; Whist *wh; String *s; isdotdot = strcmp(name, "..")==0; n = strtoul(name, &q, 10); path = fid->qid.path; a = fid->aux; switch(qidtype(path)){ case 0: return "wikifs: bad path in server (bug)"; case Droot: if(isdotdot){ *qid = fid->qid; return nil; } if(strcmp(name, "new")==0){ *qid = (Qid){mkqid(Fnew, 0, 0, 0), 0, 0}; return nil; } if(strcmp(name, "map")==0){ *qid = (Qid){mkqid(Fmap, 0, 0, 0), 0, 0}; return nil; } if((*q!='\0' || (wh=getcurrent(n))==nil) && (wh=getcurrentbyname(name))==nil) return "file does not exist"; *qid = (Qid){mkqid(D1st, wh->n, 0, 0), wh->doc->time, QTDIR}; a->w = wh; return nil; case D1st: if(isdotdot){ *qid = (Qid){mkqid(Droot, 0, 0, 0), 0, QTDIR}; return nil; } /* handle history directories */ if(*q == '\0'){ if((wh = gethistory(qidnum(path))) == nil) return "file does not exist"; for(i=0; i<wh->ndoc; i++) if(wh->doc[i].time == n) break; if(i==wh->ndoc){ closewhist(wh); return "file does not exist"; } closewhist(a->w); a->w = wh; a->n = i; *qid = (Qid){mkqid(D2nd, qidnum(path), i, 0), wh->doc[i].time, QTDIR}; return nil; } /* handle files other than index */ for(i=0; i<nelem(filelist); i++){ if(strcmp(name, filelist[i])==0){ if(needhist[i]){ if((wh = gethistory(qidnum(path))) == nil) return "file does not exist"; closewhist(a->w); a->w = wh; } *qid = (Qid){mkqid(F1st, qidnum(path), 0, i), a->w->doc->time, 0}; goto Gotfile; } } return "file does not exist"; case D2nd: if(isdotdot){ /* * Can't use a->w[a->ndoc-1] because that * might be a failed write rather than the real one. */ *qid = (Qid){mkqid(D1st, qidnum(path), 0, 0), 0, QTDIR}; if((wh = getcurrent(qidnum(path))) == nil) return "file does not exist"; closewhist(a->w); a->w = wh; a->n = 0; return nil; } for(i=0; i<=Qraw; i++){ if(strcmp(name, filelist[i])==0){ *qid = (Qid){mkqid(F2nd, qidnum(path), qidvers(path), i), a->w->doc->time, 0}; goto Gotfile; } } return "file does not exist"; default: return "bad programming"; } /* not reached */ Gotfile: t = qidtype(qid->path); switch(qidfile(qid->path)){ case Qindexhtml: s = tohtml(a->w, a->w->doc+a->n, t==F1st? Tpage : Toldpage); break; case Qindextxt: s = totext(a->w, a->w->doc+a->n, t==F1st? Tpage : Toldpage); break; case Qraw: s = s_copy(a->w->title); s = s_append(s, "\n"); s = doctext(s, &a->w->doc[a->n]); break; case Qhistoryhtml: s = tohtml(a->w, a->w->doc+a->n, Thistory); break; case Qhistorytxt: s = totext(a->w, a->w->doc+a->n, Thistory); break; case Qdiffhtml: s = tohtml(a->w, a->w->doc+a->n, Tdiff); break; case Qedithtml: s = tohtml(a->w, a->w->doc+a->n, Tedit); break; case Qwerrorhtml: s = tohtml(a->w, a->w->doc+a->n, Twerror); break; case Qwerrortxt: s = totext(a->w, a->w->doc+a->n, Twerror); break; case Qhttplogin: s = httplogin(); break; default: return "internal error"; } a->s = s; return nil; }