/* vfprint - formatted output to f or string bp */ void vfprint(FILE *f, char *bp, const char *fmt, va_list ap) { for (; *fmt; fmt++) if (*fmt == '%') switch (*++fmt) { case 'd': bp = outd(va_arg(ap, int), f, bp); break; case 'D': bp = outd(va_arg(ap, long), f, bp); break; case 'U': bp = outu(va_arg(ap, unsigned long), 10, f, bp); break; case 'u': bp = outu(va_arg(ap, unsigned), 10, f, bp); break; case 'o': bp = outu(va_arg(ap, unsigned), 8, f, bp); break; case 'X': bp = outu(va_arg(ap, unsigned long), 16, f, bp); break; case 'x': bp = outu(va_arg(ap, unsigned), 16, f, bp); break; case 'f': case 'e': case 'g': { static char format[] = "%f"; char buf[128]; format[1] = *fmt; sprintf(buf, format, va_arg(ap, double)); bp = outs(buf, f, bp); } ; break; case 's': bp = outs(va_arg(ap, char *), f, bp); break; case 'p': { void *p = va_arg(ap, void *); if (p) bp = outs("0x", f, bp); bp = outu((unsigned long)p, 16, f, bp); break; } case 'c': if (f) fputc(va_arg(ap, int), f); else *bp++ = va_arg(ap, int); break; case 'S': { char *s = va_arg(ap, char *); int n = va_arg(ap, int); if (s) for ( ; n-- > 0; s++) if (f) (void)putc(*s, f); else *bp++ = *s; } break; case 'k': { int t = va_arg(ap, int); static char *tokens[] = { #define xx(a,b,c,d,e,f,g) g, #define yy(a,b,c,d,e,f,g) g, #include "token.h" }; assert(tokens[t&0177]); bp = outs(tokens[t&0177], f, bp); } break; case 't': { Type ty = va_arg(ap, Type); assert(f); outtype(ty ? ty : voidtype, f); } break; case 'w': { Coordinate *p = va_arg(ap, Coordinate *); if (p->file && *p->file) { bp = outs(p->file, f, bp); bp = outs(":", f, bp); } bp = outd(p->y, f, bp); } break; case 'I': { int n = va_arg(ap, int); while (--n >= 0) if (f) (void)putc(' ', f); else *bp++ = ' '; } break; default: if (f) (void)putc(*fmt, f); else *bp++ = *fmt; break; } else if (f)
unsigned int svstatus_print(char *m) { int pid; int normallyup =0; struct stat s; if (stat("down", &s) == -1) { if (errno != error_noent) { outs2(WARN); outs2("unable to stat "); outs2(*service); outs2("/down: "); outs2(error_str(errno)); flush2("\n"); return(0); } normallyup =1; } pid =(unsigned char) svstatus[15]; pid <<=8; pid +=(unsigned char)svstatus[14]; pid <<=8; pid +=(unsigned char)svstatus[13]; pid <<=8; pid +=(unsigned char)svstatus[12]; tai_unpack(svstatus, &tstatus); switch (svstatus[19]) { case 0: outs(DOWN); break; case 1: outs(RUN); break; case 2: outs(FINISH); break; } outs(m); outs(": "); if (svstatus[19]) { outs("(pid "); sulong[fmt_ulong(sulong, pid)] =0; outs(sulong); outs(") "); } buffer_put(buffer_1, sulong, fmt_ulong(sulong, tnow.sec.x < tstatus.x ? 0 : tnow.sec.x -tstatus.x)); outs("s"); if (pid && !normallyup) outs(", normally down"); if (!pid && normallyup) outs(", normally up"); if (pid && svstatus[16]) outs(", paused"); if (!pid && (svstatus[17] == 'u')) outs(", want up"); if (pid && (svstatus[17] == 'd')) outs(", want down"); if (pid && svstatus[18]) outs(", got TERM"); return(pid ? 1 : 2); }
//search in HTML document void SearchString(void) { struct HTMLrecord HTMLatom,foundatom; unsigned currentHTMLatom=p->firstonscr,foundHTMLatom,nextHTMLatom; struct HTMLframe *frame=&(p->htmlframe[p->activeframe]); long minY=0l; char *str,*tmp,*foundstr,*ptr,found=0; struct HTMLrecord *atomptr; str=farmalloc(IE_MAXLEN+2); tmp=farmalloc(IE_MAXLEN+2); foundstr=farmalloc(IE_MAXLEN+2); if(!str || !tmp || !foundstr) memerr(); getTXTprompt(str,IE_MAXLEN); if(p->HTMLatomcounter>1000) { sprintf(tmp,MSG_SRCH1,str); outs(tmp); } strlwr(str); while(currentHTMLatom!=IE_NULL) { // kbhit(); atomptr=(struct HTMLrecord *)ie_getswap(currentHTMLatom); if(!atomptr) MALLOCERR(); nextHTMLatom=atomptr->next; if(atomptr->type==TEXT && atomptr->frameID==p->activeframe && atomptr->y>=frame->posY) { memcpy(&HTMLatom,atomptr,sizeof(struct HTMLrecord)); ptr=ie_getswap(atomptr->ptr); if(!ptr) MALLOCERR(); strcpy(tmp,ptr); //tmp[IE_MAXLEN]='\0'; strlwr(tmp); if(strstr(tmp,str) && HTMLatom.y>frame->posY && lastfound!=currentHTMLatom && (lastfoundY<HTMLatom.y || lastfoundY==HTMLatom.y && lastfoundX<HTMLatom.x) && (!found || HTMLatom.y<minY)) { minY=HTMLatom.y; memcpy(&foundatom,&HTMLatom,sizeof(struct HTMLrecord)); makestr(foundstr,ptr,IE_MAXLEN); foundHTMLatom=currentHTMLatom; found=1; if(foundHTMLatom==p->firstHTMLatom) break; } } currentHTMLatom=nextHTMLatom; }//loop if(found) { if(foundatom.yy>frame->posY+frame->scroll.ysize) { frame->posY=foundatom.y-FUZZYPIX; if(frame->posY+frame->scroll.ysize>frame->scroll.total_y) frame->posY=frame->scroll.total_y-frame->scroll.ysize; if(frame->posY<0) frame->posY=0; } if(foundatom.xx>frame->posX+frame->scroll.xsize || foundatom.x<frame->posX) { frame->posX=foundatom.x; if(frame->posX+frame->scroll.xsize>frame->scroll.total_x) frame->posX=frame->scroll.total_x-frame->scroll.xsize; } //!!glennmcc: Sep 21, 2007 -- place pointer at new postion #ifdef CAV ImouseSet((int)foundatom.x,(int)foundatom.y); #endif //!!glennmcc: end if(arachne.framescount) { p->activeframe=0; redrawHTML(REDRAW_NO_MESSAGE,REDRAW_CREATE_VIRTUAL); } else redrawHTML(REDRAW_NO_MESSAGE,REDRAW_VIRTUAL); highlightatom(&foundatom); lastfound=foundHTMLatom; lastfoundY=foundatom.y; lastfoundX=foundatom.x; outs(foundstr); ie_appendclip(foundstr); GLOBAL.clipdel=0; } else { redrawHTML(REDRAW_NO_MESSAGE,REDRAW_VIRTUAL); outs(MSG_SRCH2); } farfree(foundstr); farfree(tmp); farfree(str); }
/* * Load the BOOT-file from TFTP server */ int tftp_boot_load (void) { int rc = 0; /* Allocate socket and buffers */ sock = (sock_type*) malloc (sizeof(sock->udp)); inbuf = (struct tftphdr*) malloc (TFTP_HEADSIZE+SEGSIZE); outbuf = (struct tftphdr*) malloc (TFTP_HEADSIZE+SEGSIZE); if (!sock || !inbuf || !outbuf) { outsnl (_LANG("No memory for TFTP boot.")); return (0); } if (!tftp_boot_remote_file) { outsnl (_LANG("No remote TFTP boot filename defined.")); return (0); } if (tftp_server_name[0] && !tftp_server) tftp_server = resolve (tftp_server_name); if (!tftp_server) { outsnl (_LANG("Cannot resolve TFTP-server ")); return (0); } if (debug_on) outs (_LANG("Doing TFTP boot load...")); /* Open connection and request file */ if (!tftp_open (tftp_server, tftp_boot_remote_file)) { tftp_close(); return (0); } while (1) { const char *buf; int size = tftp_get_block (&buf); if (size < 0) /* error in transfer */ { rc = 0; break; } if (size > 0 && (*tftp_writer)(buf,size) < 0) { rc = -1; /* writer failed, errno set */ break; } if (size < blocksize) /* got last block */ { rc = 1; break; } } tftp_close(); return (rc); }
int main( int argc, char *argv[] ) { /* int i; */ int status = 0; char *temp; if (argc < 4 ) { outs("SERTN host port program options\n\r"); exit(1); } sock_init(); if (!( host = resolve( argv[1] ))) { outs( "Bad Host\n\r" ); exit(1); } if ( (temp = getenv( TCPTERM )) != NULL ) { /* deal with strncpy limitation */ movmem( temp, termtype, sizeof( termtype )); termtype[ sizeof(termtype) -1 ] = 0; outs("TERMINAL EMULATION :"); outs( termtype ); outs("\n\r"); } else strcpy(termtype, "UNKNOWN"); s = &socketdata; if ( host == my_ip_addr ) { outs("Incomming sessions not supported...\n\r"); sock_wait_established( s, 0, NULL, &status ); exit( -3 ); } if (! tcp_open( s, 0, host, atoi( argv[2]), NULL )) { #ifndef OLD sock_recv_init( s, bigbuf, sizeof( bigbuf ), 0); #endif OLD outs( "Unable to open\n\r"); exit(1); } sock_wait_established( s, sock_delay, NULL, &status ); sock_mode( s, TCP_MODE_NAGLE ); sock_status = 1; /* allow interrupts */ /* move vectors */ moved_vectors = 1; old8 = getvect( 0x08 ); old14 = getvect( 0x014 ); /* setvect( 0x08, (void interrupt (*)())serial_t ); */ setvect( 0x08, tcpport_tick ); setvect( 0x014,ourhandler); /* was serial_2 */ recvtimeout = set_ttimeout( 1 ); outs("Running..."); outs( argv[3] ); outs( "\n\r"); system( argv[ argc-1 ] ); outs("Done, now closing session\n\r"); setvect( 0x014, old14 ); setvect( 0x08, old8 ); moved_vectors = 0; if ( s ) { sock_close( s ); sock_wait_closed( s, sock_delay, NULL, &status ); } sock_err: switch (status) { case 1 : outs("Done.\n\r"); break; case -1: outs("Remote host reset connection."); break; } if (moved_vectors) { setvect( 0x014, old14 ); setvect( 0x08, old8 ); } exit( (status)? 2 : 0); return (0); /* not reached */ }
//search in active TEXTAREA... void SearchInTextarea(char cont) { int i=0; struct HTMLrecord *aptr=(struct HTMLrecord *)ie_getswap(focusedatom); if(aptr) { char searchstring[IE_MAXLEN+1],str[IE_MAXLEN+80],*ptr; int l1,l2,x; memcpy(&activeatom,aptr,sizeof(struct HTMLrecord)); activeatomptr=&activeatom; activeadr=focusedatom; getTXTprompt(searchstring,IE_MAXLEN); sprintf(str,MSG_SRCH1,searchstring); outs(str); l1=strlen(searchstring); if(l1==0) goto redraw_and_exit; editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr); if(editorptr) { memcpy(&tmpeditor,editorptr,sizeof(struct ib_editor)); if(cont) i=tmpeditor.y; while(i<tmpeditor.lines) { ptr=ie_getline(&tmpeditor,i); if(cont) { x=tmpeditor.x+l1; ptr+=x; cont=0; } else x=0; l2=strlen(ptr); while(l2>=l1) { if(!strncmpi(searchstring,ptr,l1)) { tmpeditor.y=i; tmpeditor.x=x; editorptr=(struct ib_editor *)ie_getswap(activeatomptr->ptr); if(editorptr) { memcpy(editorptr,&tmpeditor,sizeof(struct ib_editor)); swapmod=1; } activeatomtick(ZOOM_SYNCHRO,TEXTAREA_NOREFRESH); //found goto redraw_and_exit; } ptr++; l2--; x++; }//loop i++; }//loop } else MALLOCERR(); outs(MSG_SRCH2); //not found redraw_and_exit: redrawHTML(REDRAW_NO_MESSAGE,REDRAW_VIRTUAL); activeatomptr=&activeatom; activeadr=focusedatom; activeatomcursor(1); }//end if pointer exists - else "nonfatal error" }
void elf::log(const Twine &Msg) { std::lock_guard<std::mutex> Lock(Mu); if (Config->Verbose) outs() << Argv0 << ": " << Msg << "\n"; }
void printOptionInfo(const Option &O, size_t GlobalWidth) const { outs() << " -" << O.ArgStr; Option::printHelpStr(O.HelpStr, GlobalWidth, getOptionWidth(O)); }
void XMLScannerTest::run() { //create a dummy map with a fakie f*****g modulewhateverinfo.... std::vector<std::pair<std::string, std::string> > outs(1); std::vector<std::pair<std::string, std::string> > ins(0); std::pair<std::string, std::string> outpair("typ_string", "String"); outs[0] = outpair; //Xpm dummy(dummyXpm, strlen(dummyXpm)+1); ModuleInfo* mi = new ModuleInfo("mod_stringModule", "String", ins, outs, true); std::vector<std::pair<std::string, std::string> > outs2(0); std::vector<std::pair<std::string, std::string> > ins2(1); std::pair<std::string, std::string> inpair("typ_framebuffer", "Bild"); ins2[0] = inpair; ModuleInfo* mi2 = new ModuleInfo("mod_glOutputModule", "GLoutput" , ins, outs, false); std::vector<std::pair<std::string, std::string> > outs3(1); std::vector<std::pair<std::string, std::string> > ins3(3); std::pair<std::string, std::string> inpair2("typ_number","Zahl"); ins3[0] = inpair2; ins3[1] = inpair2; ins3[2] = inpair; outs3[0] = inpair; ModuleInfo* mi3 = new ModuleInfo("mod_tunnelModule", "Tunnel" , ins, outs, false); std::map<int, ModuleInfo*> mi_map; mi_map[0] = mi; mi_map[1] = mi2; mi_map[2] = mi3; //create storage room for the listener std::map<std::string, int> infos; std::map<std::string, std::pair<int,int> > nodes; std::map<int, std::string> nodeIDs; std::map<std::string, std::pair<int,int> > controls; std::map<int, std::string> controlIDs; std::map<std::pair<int,int>, std::pair<int,int> > conns; std::map<std::pair<int,int>, std::pair<int,int> > ctrlconns; //create an xmlListener with that dummyinfo XMLTokenListener horcher(mi_map, infos, nodes, nodeIDs, controls, controlIDs, conns, ctrlconns); XMLFileScanner gucker(horcher); std::ifstream ifs("testCorrect.graph"); if(ifs==0) std::cout<<"File not found \n"; std::string testTextCorrect; char tmp; while(ifs.get(tmp)) { testTextCorrect += tmp; } gucker.scan(testTextCorrect); //eine datei ohne <model> //std::cout<<"Processing incorrect file 1...\n"; std::ifstream ifs1("testInCorrect1.graph"); if(ifs1==0) std::cout<<"File not found \n"; std::string testTextInCorrect1; while(ifs.get(tmp)) { testTextInCorrect1 += tmp; } try { gucker.scan(testTextInCorrect1); } catch(std::runtime_error err) { //if(err.what() != "This is no Ge-Phex Graph file...go f**k your dog!!!") // throw std::runtime_error(err.what()); //std::cout<<err.what()<<std::endl; } //eine datei ohne </model>, ja, ich weiss, kreativ... //std::cout<<"Processing incorrect file 2...\n"; std::ifstream ifs2("testInCorrect2.graph"); if(ifs2==0) std::cout<<"File not found \n"; std::string testTextInCorrect2; while(ifs2.get(tmp)) { testTextInCorrect2 += tmp; } try { gucker.scan(testTextInCorrect2); } catch(std::runtime_error err) { //if(err.what() != "File has a wrong finishing tag...wrong format") // throw std::runtime_error(err.what()); //std::cout<<err.what()<<std::endl; } //eine datei mit fehlender node section //std::cout<<"Processing incorrect file 3...\n"; std::ifstream ifs3("testInCorrect3.graph"); if(ifs3==0) std::cout<<"File not found \n"; std::string testTextInCorrect3; while(ifs3.get(tmp)) { testTextInCorrect3 += tmp; } try { gucker.scan(testTextInCorrect3); } catch(std::runtime_error err) { //if(err.what() != "File has wrong format...section nodes") // throw std::runtime_error(err.what()); //std::cout<<err.what()<<std::endl; } }
template <class ELFT> void printProgramHeaders(const ELFFile<ELFT> *o) { outs() << "Program Header:\n"; auto ProgramHeaderOrError = o->program_headers(); if (!ProgramHeaderOrError) report_fatal_error(toString(ProgramHeaderOrError.takeError())); for (const typename ELFT::Phdr &Phdr : *ProgramHeaderOrError) { switch (Phdr.p_type) { case ELF::PT_DYNAMIC: outs() << " DYNAMIC "; break; case ELF::PT_GNU_EH_FRAME: outs() << "EH_FRAME "; break; case ELF::PT_GNU_RELRO: outs() << " RELRO "; break; case ELF::PT_GNU_STACK: outs() << " STACK "; break; case ELF::PT_INTERP: outs() << " INTERP "; break; case ELF::PT_LOAD: outs() << " LOAD "; break; case ELF::PT_NOTE: outs() << " NOTE "; break; case ELF::PT_OPENBSD_BOOTDATA: outs() << " OPENBSD_BOOTDATA "; break; case ELF::PT_OPENBSD_RANDOMIZE: outs() << " OPENBSD_RANDOMIZE "; break; case ELF::PT_OPENBSD_WXNEEDED: outs() << " OPENBSD_WXNEEDED "; break; case ELF::PT_PHDR: outs() << " PHDR "; break; case ELF::PT_TLS: outs() << " TLS "; break; default: outs() << " UNKNOWN "; } const char *Fmt = ELFT::Is64Bits ? "0x%016" PRIx64 " " : "0x%08" PRIx64 " "; outs() << "off " << format(Fmt, (uint64_t)Phdr.p_offset) << "vaddr " << format(Fmt, (uint64_t)Phdr.p_vaddr) << "paddr " << format(Fmt, (uint64_t)Phdr.p_paddr) << format("align 2**%u\n", countTrailingZeros<uint64_t>(Phdr.p_align)) << " filesz " << format(Fmt, (uint64_t)Phdr.p_filesz) << "memsz " << format(Fmt, (uint64_t)Phdr.p_memsz) << "flags " << ((Phdr.p_flags & ELF::PF_R) ? "r" : "-") << ((Phdr.p_flags & ELF::PF_W) ? "w" : "-") << ((Phdr.p_flags & ELF::PF_X) ? "x" : "-") << "\n"; } outs() << "\n"; }
static unsigned __loadds __saveregs __cdecl __far debug_handler( unsigned int hNext, TSF32 FarPtr client ) { int eip_mod = 0; char in_debuggee; __asm cld; /* CLD to be safe */ in_debuggee = debugging; #ifdef TIMER if( client->int_id == INT_TIMER ) { if( --timer_mod == 0 ) { timer_mod = timer_mult; chain_interrupt( hNext, client ); } else { outp( INT_CTRL, EOI ); } hNext = 0; if( in_debuggee && find_user_code( client ) != client ) { in_debuggee = 0; } } #endif if( in_debuggee == 0 ) { /* Handler should get out of the way */ if( ( client->int_id == hotkey_int ) && !being_debugged ) { /* If we detect the hotkey while the debugger is in control, and there is no other debugger to hotkey into, just beep. */ #if DEBUGHOTKEY outi( debugging ); outs( " think we're in the debugger\r\n" ); #endif beep(); /* Can't hotkey, already in control */ hNext = 0; } else if( client->int_id == EXC_PAGE_FAULT ) { /* If a page fault in debugger, assume triggered by peek32/poke32 and just cover it up, setting the page_fault flag. */ page_fault = 1; client->eip += 3; hNext = 0; /* Fault has been handled */ } else if( ( client->int_id == EXC_SINGLE_STEP ) && !being_debugged ) { /* If a debug exception occurs while the debugger is active, it's because something (such as DOS/4G with NULLP) is debugging the debugger. Because the debugger must juggle the real mode interrupt vectors, we want to cover up run-of-the-mill exceptions caused by NULLP. However, if there is a parent debugger present to handle the exception, we don't want to cover it up. */ hNext = 0; } return( hNext ); /* Execute next in chain */ } #if OUTDATEDWINDOWSCRAP analyze: #endif outs( "got int " ); outi( client->int_id ); outs( "\r\n" ); switch( client->int_id ) { case EXC_SINGLE_STEP: /* Single step */ #if OUTDATEDWINDOWSCRAP /* NEEDWORK */ /* If the trace bit is not turned on, assume illegal OP code */ if( _d16info.swmode == 0 && (client->eflags & 0x100) == 0 ) { /* Running under Windows 3.00 and took illegal opcode */ client->int_id = 6; /* Attribute this problem properly */ eip_mod = -1; /* And back up an instruction */ goto analyze; } #endif check_hotkey( eip_mod, client ); break; case EXC_GP_FAULT: /* GP Fault */ if( fixcrash( client ) ) return( 0 ); break; case EXC_PAGE_FAULT: /* Page fault */ /* If we get a page fault while the user program is running, we want to flag it immediately. If VM is present, it will already have covered up any of its own page faults; the debug handler will only be called on a legitimate fault. */ break; case EXC_BREAKPOINT: /* Breakpoint */ eip_mod = -1; check_hotkey( eip_mod, client ); break; case EXC_DIVIDE_BY_ZERO: /* Divide by zero */ case INT_NMI: /* NMI */ case EXC_UNDEF_OPCODE: /* Illegal opcode */ case EXC_INVALID_TASK_STATE: /* Invalid task state segment */ case EXC_STACK_FAULT: /* stack fault */ break; #ifdef TIMER case INT_TIMER: /* timer */ break; #endif case INT_DOS: /* Catch INT 21h/AH = 4Ch (terminate program) */ if( ((unsigned short)client->eax & 0xFF00) == 0x4c00 ) { eip_mod = -2; break; } /* Catch INT 21h/AH = FFh DX = 11FFh (DOS/16M debugger presence test) */ if( ((unsigned short)client->eax & 0xFF00) == 0xFF00 && (unsigned short)client->edx == 0x11FF ) { client->eflags &= ~1; /* Clear carry flag */ return( 0 ); } return( hNext ); case INT_PRT_SCRN_KEY: case INT_RM_PASSUP: /* Possible hotkey interrupts */ case INT_CTRL_C_KEY: if( client->int_id == hotkey_int ) { set_hotkey_break( client ); return( 0 ); } break; // return( hNext ); default: return( hNext ); } dbgregs = *client; dbgregs.eip += eip_mod; /* Point to "correct" instruction */ tsf32_exec( &debug_handler_tsf, &debugger_tsf ); *client = dbgregs; return( 0 ); }
void EspMessageInfo::write_esp_ng_ipp() { const char *parent=getParentName(); const char *baseclass=parent; if (!baseclass) { switch(espm_type_) { case espm_struct: baseclass="CEspNgStruct"; break; case espm_request: baseclass="CEspNgRequest"; break; default: baseclass="CEspNgResponse"; break; } } outf("class CNg%s : public %s,\n", name_, baseclass); outf(" implements IEsp%s\n", name_); outs("{\n"); outs("protected:\n"); int pcount=0; ParamInfo *pi=NULL; for (pi=getParams();pi!=NULL;pi=pi->next) pcount++; outs(1, "int m_pcount;\n"); outf(1, "IEspNgParameter *m_params[%d];\n", pcount); outs("public:\n\n"); outs(1,"StringBuffer m_serviceName;\n"); outs(1,"StringBuffer m_methodName;\n"); outs(1,"StringBuffer m_msgName;\n"); outs(1,"IMPLEMENT_IINTERFACE;\n\n"); outs(1, "void init_params()\n"); outs(1, "{\n"); outf(2, "m_pcount=%d;\n", pcount); int pidx=0; for (pi=getParams();pi!=NULL;pi=pi->next) { pi->write_esp_ng_declaration(pidx++); } outs(1, "}\n\n"); outs(1, "virtual IEspNgParameterIterator * getParameterIterator()\n"); outs(1, "{\n"); outs(2, "return new EspNgParameterIterator(m_params, m_pcount);\n"); outs(1, "}\n"); //default constructor outf(1, "CNg%s(const char *serviceName){\n", name_); outs(2, "m_serviceName.append(serviceName);\n"); outs(2, "init_params();\n"); outs(1, "}\n"); //default destructor -- bhegerle outf(1, "~CNg%s() {\n", name_); outs(2, "for(int i=0; i < m_pcount; i++)\n"); outs(3, "m_params[i]->Release();\n"); outs(1, "}\n"); if (espm_type_==espm_response) { outs(1,"virtual void setRedirectUrl(const char *url){CEspNgResponse::setRedirectUrl(url);}\n"); outs(1,"virtual const IMultiException & getExceptions(){return CEspNgResponse::getExceptions();}\n"); outs(1,"virtual void noteException(IException & e){CEspNgResponse::noteException(e);}\n"); } outs("\n"); write_esp_methods_ng(espaxm_both); outf(1, "virtual void copy(IConst%s &from){/*not implemented*/}\n", name_); outf(1, "virtual const char * queryName(){return \"%s\";}\n", name_); outs("};\n\n"); }
void EspServInfo::write_esp_binding_ng_ipp(EspMessageInfo *msgs) { EspMethodInfo *mthi=NULL; outs("\n\n"); outf("template <class base_binding> class CNg%sServiceBinding : public base_binding\n", name_); outs("{\npublic:\n"); outf(1,"CNg%sServiceBinding(IPropertyTree* cfg, const char *bindname=NULL, const char *procname=NULL) : base_binding(cfg, bindname, procname){}\n", name_); outs(1,"IEspNgRequest* createRequest(const char *method)\n"); outs(1,"{\n"); int count=0; for (mthi=methods;mthi;mthi=mthi->next) { outf(2,"%sif (!stricmp(method, \"%s\"))\n", (count++==0)? "" : "else ", mthi->getName()); outs(2,"{\n"); outf(3,"return new CNg%s(\"%s\");\n", mthi->getReq(), name_); outs(2,"}\n"); } outs(2,"return NULL;\n"); outs(1,"}\n\n"); outs(1,"virtual IEspNgResponse* createResponse(const char *method)\n"); outs(1,"{\n"); count=0; for (mthi=methods;mthi;mthi=mthi->next) { outf(2,"%sif (!stricmp(method, \"%s\"))\n", (count++==0)? "" : "else ", mthi->getName()); outs(2,"{\n"); outf(3,"return new CNg%s(\"%s\");\n", mthi->getResp(), name_); outs(2,"}\n"); } outs(2,"return NULL;\n"); outs(1,"}\n\n"); //method ==> processRequest outs(1,"virtual int processRequest(IEspContext &context, const char *method_name, IEspNgRequest* req, IEspNgResponse* resp)\n"); outs(1,"{\n"); outf(2, "Owned<IEsp%s> iserv = (IEsp%s*)base_binding::getService();\n", name_, name_); count=0; for (mthi=methods;mthi;mthi=mthi->next) { outf(2,"%sif (!stricmp(method_name, \"%s\")/*||!stricmp(req->queryName(), \"%s\")*/)\n", (count++==0)? "" : "else ", mthi->getName(), mthi->getReq()); outs(2,"{\n"); outf(3,"return iserv->on%s(context, *dynamic_cast<IEsp%s*>(req), *dynamic_cast<IEsp%s*>(resp));\n", mthi->getName(), mthi->getReq(), mthi->getResp()); outs(2,"}\n"); } outs(2,"return 0;\n"); outs(1,"}\n\n"); //method ==> getServiceName outf(1,"StringBuffer & getServiceName(StringBuffer &resp){resp.clear().append(\"%s\");}\n", name_); outs("};\n\n"); }
int main(int argc, char **argv) { unsigned int i, done; char *x; progname =*argv; for (i =str_len(*argv); i; --i) if ((*argv)[i -1] == '/') break; *argv +=i; optprogname =progname =*argv; service =argv; services =1; lsb =(str_diff(progname, "sv")); if ((x =env_get("SVDIR"))) varservice =x; if ((x =env_get("SVWAIT"))) scan_ulong(x, &wait); while ((i =getopt(argc, (const char* const*)argv, "w:vV")) != opteof) { switch(i) { case 'w': scan_ulong(optarg, &wait); case 'v': verbose =1; break; case 'V': strerr_warn1(VERSION, 0); case '?': usage(); } } argv +=optind; argc -=optind; if (!(action =*argv++)) usage(); --argc; if (!lsb) { service =argv; services =argc; } if (!*service) usage(); taia_now(&tnow); tstart =tnow; if ((curdir =open_read(".")) == -1) fatal("unable to open current directory"); act =&control; acts ="s"; if (verbose) cbk =✓ switch (*action) { case 'x': case 'e': acts ="x"; break; case 'X': case 'E': acts ="x"; kll =1; cbk =✓ break; case 'D': acts ="d"; kll =1; cbk =✓ break; case 'T': acts ="tc"; kll =1; cbk =✓ break; case 'c': if (!str_diff(action, "check")) { act =0; acts ="C"; cbk =✓ break; } case 'u': case 'd': case 'o': case 't': case 'p': case 'h': case 'a': case 'i': case 'k': case 'q': case '1': case '2': action[1] =0; acts =action; break; case 's': if (!str_diff(action, "shutdown")) { acts ="x"; cbk =✓ break; } if (!str_diff(action, "start")) { acts ="u"; cbk =✓ break; } if (!str_diff(action, "stop")) { acts ="d"; cbk =✓ break; } if (lsb && str_diff(action, "status")) usage(); act =&status; cbk =0; break; case 'r': if (!str_diff(action, "restart")) { acts ="tcu"; cbk =✓ break; } usage(); case 'f': if (!str_diff(action, "force-reload")) { acts ="tc"; kll =1; cbk =✓ break; } if (!str_diff(action, "force-restart")) { acts ="tcu"; kll =1; cbk =✓ break; } if (!str_diff(action, "force-shutdown")) { acts ="x"; kll =1; cbk =✓ break; } if (!str_diff(action, "force-stop")) { acts ="d"; kll =1; cbk =✓ break; } default: usage(); } servicex =service; for (i =0; i < services; ++i) { if ((**service != '/') && (**service != '.') && **service && ((*service)[str_len(*service) -1] != '/')) { if ((chdir(varservice) == -1) || (chdir(*service) == -1)) { fail("unable to change to service directory"); *service =0; } } else if (chdir(*service) == -1) { fail("unable to change to service directory"); *service =0; } if (*service) if (act && (act(acts) == -1)) *service =0; if (fchdir(curdir) == -1) fatal("unable to change to original directory"); service++; } if (*cbk) for (;;) { taia_sub(&tdiff, &tnow, &tstart); service =servicex; done =1; for (i =0; i < services; ++i, ++service) { if (!*service) continue; if ((**service != '/') && (**service != '.')) { if ((chdir(varservice) == -1) || (chdir(*service) == -1)) { fail("unable to change to service directory"); *service =0; } } else if (chdir(*service) == -1) { fail("unable to change to service directory"); *service =0; } if (*service) { if (cbk(acts) != 0) *service =0; else done =0; } if (*service && taia_approx(&tdiff) > wait) { kll ? outs(KILL) : outs(TIMEOUT); if (svstatus_get() > 0) { svstatus_print(*service); ++rc; } flush("\n"); if (kll) control("k"); *service =0; } if (fchdir(curdir) == -1) fatal("unable to change to original directory"); } if (done) break; usleep(420000); taia_now(&tnow); } return(rc > 99 ? 99 : rc); }
static int pad_draw() { int i, cc, fdr, color; FILE *fpw; Pad pad; char *str, buf[3][71]; /* itoc.註解: 不想用高彩度,太花 */ static char pcolors[6] = {31, 32, 33, 34, 35, 36}; /* itoc.010309: 留言板提供不同的顏色 */ color = vans("心情顏色 1) \033[41m \033[m 2) \033[42m \033[m 3) \033[43m \033[m " "4) \033[44m \033[m 5) \033[45m \033[m 6) \033[46m \033[m [Q] "); if (color < '1' || color > '6') return XEASY; else color -= '1'; do { buf[0][0] = buf[1][0] = buf[2][0] = '\0'; move(MENU_XPOS, 0); clrtobot(); outs("\n請留言 (至多三行),按[Enter]結束"); for (i = 0; (i < 3) && vget(16 + i, 0, ":", buf[i], 71, DOECHO); i++); cc = vans("(S)存檔觀賞 (E)重新來過 (Q)算了?[S] "); if (cc == 'q' || i == 0) return 0; } while (cc == 'e'); time(&pad.tpad); /* itoc.020812.註解: 改版面的時候要注意 struct Pad.msg[] 是否夠大 */ str = pad.msg; sprintf(str, "╭┤\033[1;46m %s - %s \033[m├", cuser.userid, cuser.username); for (cc = strlen(str); cc < 60; cc += 2) strcpy(str + cc, "─"); if (cc == 60) str[cc++] = ' '; sprintf(str + cc, "\033[1;44m %s \033[m╮\n" "│ \033[1;%dm%-70s\033[m │\n" "│ \033[1;%dm%-70s\033[m │\n" "╰ \033[1;%dm%-70s\033[m ╯\n", Btime(&pad.tpad), pcolors[color], buf[0], pcolors[color], buf[1], pcolors[color], buf[2]); f_cat(FN_RUN_NOTE_ALL, str); if (!(fpw = fopen(FN_RUN_NOTE_TMP, "w"))) return 0; fwrite(&pad, sizeof(pad), 1, fpw); if ((fdr = open(FN_RUN_NOTE_PAD, O_RDONLY)) >= 0) { Pad *pp; i = 0; cc = pad.tpad - NOTE_DUE * 60 * 60; mgets(-1); while (pp = mread(fdr, sizeof(Pad))) { fwrite(pp, sizeof(Pad), 1, fpw); if ((++i > NOTE_MAX) || (pp->tpad < cc)) break; } close(fdr); } fclose(fpw); rename(FN_RUN_NOTE_TMP, FN_RUN_NOTE_PAD); pad_view(); return 0; }
void flush(const char *s) { outs(s); buffer_flush(buffer_1); }
// Returns true on error. static bool format(StringRef FileName) { ErrorOr<std::unique_ptr<MemoryBuffer>> CodeOrErr = MemoryBuffer::getFileOrSTDIN(FileName); if (std::error_code EC = CodeOrErr.getError()) { errs() << EC.message() << "\n"; return true; } std::unique_ptr<llvm::MemoryBuffer> Code = std::move(CodeOrErr.get()); if (Code->getBufferSize() == 0) return false; // Empty files are formatted correctly. std::vector<tooling::Range> Ranges; if (fillRanges(Code.get(), Ranges)) return true; StringRef AssumedFileName = (FileName == "-") ? AssumeFileName : FileName; FormatStyle FormatStyle = getStyle(Style, AssumedFileName, FallbackStyle, Code->getBuffer()); if (SortIncludes.getNumOccurrences() != 0) FormatStyle.SortIncludes = SortIncludes; unsigned CursorPosition = Cursor; Replacements Replaces = sortIncludes(FormatStyle, Code->getBuffer(), Ranges, AssumedFileName, &CursorPosition); auto ChangedCode = tooling::applyAllReplacements(Code->getBuffer(), Replaces); if (!ChangedCode) { llvm::errs() << llvm::toString(ChangedCode.takeError()) << "\n"; return true; } // Get new affected ranges after sorting `#includes`. Ranges = tooling::calculateRangesAfterReplacements(Replaces, Ranges); bool IncompleteFormat = false; Replacements FormatChanges = reformat(FormatStyle, *ChangedCode, Ranges, AssumedFileName, &IncompleteFormat); Replaces = Replaces.merge(FormatChanges); if (OutputXML) { outs() << "<?xml version='1.0'?>\n<replacements " "xml:space='preserve' incomplete_format='" << (IncompleteFormat ? "true" : "false") << "'>\n"; if (Cursor.getNumOccurrences() != 0) outs() << "<cursor>" << FormatChanges.getShiftedCodePosition(CursorPosition) << "</cursor>\n"; outputReplacementsXML(Replaces); outs() << "</replacements>\n"; } else { IntrusiveRefCntPtr<vfs::InMemoryFileSystem> InMemoryFileSystem( new vfs::InMemoryFileSystem); FileManager Files(FileSystemOptions(), InMemoryFileSystem); DiagnosticsEngine Diagnostics( IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), new DiagnosticOptions); SourceManager Sources(Diagnostics, Files); FileID ID = createInMemoryFile(AssumedFileName, Code.get(), Sources, Files, InMemoryFileSystem.get()); Rewriter Rewrite(Sources, LangOptions()); tooling::applyAllReplacements(Replaces, Rewrite); if (Inplace) { if (FileName == "-") errs() << "error: cannot use -i when reading from stdin.\n"; else if (Rewrite.overwriteChangedFiles()) return true; } else { if (Cursor.getNumOccurrences() != 0) outs() << "{ \"Cursor\": " << FormatChanges.getShiftedCodePosition(CursorPosition) << ", \"IncompleteFormat\": " << (IncompleteFormat ? "true" : "false") << " }\n"; Rewrite.getEditBuffer(ID).write(outs()); } } return false; }
void printOptionDiff(const Option &O, OffsetOption V, OptVal Default, size_t GlobalWidth) const { printOptionName(O, GlobalWidth); outs() << "[=offset]"; }
unsigned sytek_int( unsigned ax /*, unsigned dx */ ) { unsigned char ah; unsigned char ch; /* int sent; */ unsigned int status; if ( !s ) { return( 0x1000 ); /* timeout */ } if (chk_timeout( recvtimeout )) { do_reception(); recvtimeout = set_ttimeout( 2 ); /* 10 ms */ } /* disable(); receive_clock = RECEIVE_TICKS; enable(); } */ ah = ax >> 8; if( ah == 1 ) { /* send char in AL */ ch = ax & 0x0FF; /* if (ch == '\r') ch = '\n'; */ if( ((tran_in + 1) % TRANSMIT_BUF_SIZE) == tran_out ) { outs( "?tr_buf_full?" ); status = 0x08000 | ch; } else { if ((ch == '\r') && echo ) stuff_char( '\n' ); else stuff_char( ch ); status = 0x06000 | ch; /* local echoing if requested */ if ( echo ) { receive_buffer[ rec_in ] = ch; rec_in = (rec_in + 1) % RECEIVE_BUF_SIZE; if (ch == '\r') { receive_buffer[ rec_in ] = '\n'; rec_in = (rec_in + 1) % RECEIVE_BUF_SIZE; } } } } else if( ah == 2 ) { /* receive char into AL */ do { ch = 0; if( rec_in == rec_out ) status = 0x08000; else { status = ch = (ttinc( 0 ) & 0xff); if ( ch == IAC ) { /* process this stuff */ ch = ttinc( 0 ); if ( ch == IAC ) ch = 0; /* let it pass through */ else tn_doop(ch); } } } while ( ch == IAC ); /* status = 0x0800; timeout */ } else if( ah == 3 ) { /* get status */ if( rec_in == rec_out ) status = 0x06010; else { status = 0x06110; } } else if( ah == 0 ) { /* init port */ status = 0x06010; } else { status = ax; outs( "?command_err?" ); } /* here we do the io */ if( transmit_clock <= 0 ) { do_transmission(); disable(); transmit_clock = TRANSMIT_TICKS; enable(); } return( status ); }