void main( int argc, char *argv[] ) { int fp; HelpHeader header; unsigned i; if( argc != 2 ) { printf( "Usage: helpdump <help file name>\n" ); return; } fp = open( argv[1], O_RDONLY | O_BINARY ); if( fp == -1 ) { printf( "Unable to open %s\n", argv[1] ); return; } read( fp, &header, sizeof( HelpHeader ) ); PrintHeader( &header ); read( fp, Buffer, header.str_size ); PrintStrings( Buffer ); read( fp, Buffer, header.datapagecnt * sizeof( uint_16 ) ); PrintItemIndex( &header ); for( i = 0; i < header.indexpagecnt + header.datapagecnt; i++ ) { read( fp, Buffer, HLP_PAGE_SIZE ); PrintPage(); } }
void Emit(char * filename) { Var * var; EmitOpen(filename); VarUse(); if (Verbose(NULL)) { PrintHeader(1, "Variables"); for(var = VarFirst(); var != NULL; var = VarNext(var)) { if (var->write >= 1 || var->read >= 1) { if (var->mode == INSTR_VAR && !VarIsReg(var) && !VarIsLabel(var)) { PrintVar(var); PrintEOL(); } } } PrintHeader(1, "Output"); } // verbose EmitLabels(); //TODO: ProcessUsedProc // if (!EmitProc(&ROOT_PROC)) goto failure; EmitProc(&ROOT_PROC); EmitProcedures(); EmitAsmIncludes(); EmitInstrOp(INSTR_CODE_END, NULL, NULL, NULL); VarEmitAlloc(); EmitInstrOp(INSTR_SRC_END, NULL, NULL, NULL); EmitClose(); }
return_val DumpASMSection( section_ptr section, unsigned_8 *contents, dis_sec_size size, unsigned pass ) { hash_data *h_data; label_list sec_label_list; label_entry l_entry; ref_list sec_ref_list; ref_entry r_entry; return_val err; hash_key h_key; h_key.u.sec_handle = section->shnd; h_data = HashTableQuery( HandleToLabelListTable, h_key ); if( h_data != NULL ) { sec_label_list = h_data->u.sec_label_list; l_entry = sec_label_list->first; } else { sec_label_list = NULL; l_entry = NULL; } r_entry = NULL; h_data = HashTableQuery( HandleToRefListTable, h_key ); if( h_data != NULL ) { sec_ref_list = h_data->u.sec_ref_list; if( sec_ref_list != NULL ) { r_entry = sec_ref_list->first; } } if( pass == 1 ) { DoPass1Relocs( contents, r_entry, 0, size ); return( RC_OKAY ); } if( size == 0 ) { if( IsMasmOutput() ) { PrintHeader( section ); dumpAsmLabel( l_entry, section, 0, 0, NULL, NULL ); PrintTail( section ); } return( RC_OKAY ); } PrintHeader( section ); err = DumpASMDataFromSection( contents, 0, size, &l_entry, &r_entry, section ); if( size > 0 ) { l_entry = dumpAsmLabel( l_entry, section, size, size, NULL, NULL ); } BufferConcatNL(); BufferPrint(); if( err == RC_OKAY ) { PrintTail( section ); } return( err ); }
return_val DumpASMSection( section_ptr sec, unsigned_8 *contents, orl_sec_size size, unsigned pass ) { hash_data *data_ptr; label_list sec_label_list; label_entry l_entry; ref_list sec_ref_list; ref_entry r_entry; return_val err; data_ptr = HashTableQuery( HandleToLabelListTable, (hash_value) sec->shnd ); if( data_ptr ) { sec_label_list = (label_list) *data_ptr; l_entry = sec_label_list->first; } else { sec_label_list = NULL; l_entry = NULL; } r_entry = NULL; data_ptr = HashTableQuery( HandleToRefListTable, (hash_value) sec->shnd ); if( data_ptr ) { sec_ref_list = (ref_list) *data_ptr; if( sec_ref_list != NULL ) { r_entry = sec_ref_list->first; } } if( pass == 1 ) { DoPass1Relocs( contents, r_entry, 0, size ); return( RC_OKAY ); } if( size == 0 ) { if( IsMasmOutput() ) { PrintHeader( sec ); dumpAsmLabel( l_entry, sec, 0, 0, NULL, NULL ); PrintTail( sec ); } return( RC_OKAY ); } PrintHeader( sec ); err = DumpASMDataFromSection( contents, 0, size, &l_entry, &r_entry, sec ); if( size > 0 ) { l_entry = dumpAsmLabel( l_entry, sec, size, size, NULL, NULL ); } BufferConcatNL(); BufferPrint(); if( err == RC_OKAY ) { PrintTail( sec ); } return( err ); }
bool MiniApache::PendingRequest(){ if (_serve_status == 1){ // Waiting for client client = _server->available(); // try to get client if (client) { // got client? ClearStr(_HTTP_request, REQUEST_BUFFER_SIZE); _serve_status = 2; } } if (_serve_status == 2){ // Reading request if (client.connected()){ while (client.available()){ // client data available to read char c = client.read(); if (_request_index < (REQUEST_BUFFER_SIZE - 1)){ // save HTTP request character _HTTP_request[_request_index] = c; _request_index++; } else { PrintHeader(400, "Bad request", "text/html", false); ReportClientServed(400); break; } if (c == '\r' || c == '\n'){ _serve_status = 3; delete [] GET_data; delete [] request_path; request_path = ExtractRequestPath(); // Get path of the HTTP request, ignore type (assume GET) GET_data = ExtractRequestData(); // Get GET data of the HTTP request if (_error_status){ // Error was detected (earlier) PrintHeader(500, "Internal Server Error", "text/html", false); client.println("<thml><hrad><title>Internal Server Error</title></head><body>500: Internal Server Error<br>Error code:"); client.println(_error_status); client.println("<br>Error message:"); client.println(GetErrorMessage()); client.println("<hr>MiniApache</body></html>"); ReportClientServed(500); } #if SERIAL_DEBUG == 1 Serial.print("Free memory: "); Serial.println(freeRam()); #endif break; // Ignore rest of the HTTP request } } } } return (_serve_status == 3); }
int MiniApache::ServeFile(char *path){ // Not used _storageFile = SD.open(path); if (_storageFile){ // Serve file PrintHeader(200, "OK", GetMIMEType(path), true); while(_storageFile.available()){ client.write(_storageFile.read()); } _storageFile.close(); return 200; } else { // Return 404 error PrintHeader(404, "Not Found", "text/html", true); client.println("File Not Found"); return 404; } }
int main() { PrintHeader("Nick Francke", 'A', 7); Rectangle myRect; Triangle myTri; int width, height, side1, side2, side3; width = ValidateInput<int>("Enter a rectangle width from 1 - 1000: ", 1, 1000); height = ValidateInput<int>("Enter a rectangle height from 1 - 1000: ", 1, 1000); std::cout << "Attributes of the rectangle: " << std::endl; myRect.setAttributes(width, height); PrintPerimeter(&myRect); PrintArea(&myRect); std::cout << std::endl; side1 = ValidateInput<int>("Enter a triangle's first side from 1 - 1000: ", 1, 1000); side2 = ValidateInput<int>("Enter a triangle's second side from 1 - 1000: ", 1, 1000); side3 = ValidateInput<int>("Enter a triangle's third side from 1 - 1000: ", 1, 1000); myTri.setAttributes(side1, side2, side3); PrintPerimeter(&myTri); PrintArea(&myTri); return 0; }
void WebResponse (const prog_char *response, long strsize) { // P(WebHeaderMsg) = SERVER_HEADER_HTML; // printP(WebHeaderMsg); PrintHeader(strsize,0); PROGMEMprint(response); }
void StdoutConsumer::Consume(const Log::Entry& entry) { PrintHeader(entry); PrintMessage(std::cout, entry, true); PrintContext(entry); PrintNewLine(std::cout, true); }
/** ** Display the usage. */ static void Usage() { PrintHeader(); printf( "\n\nUsage: %s [OPTIONS] [map.smp|map.smp.gz]\n" "\t-c file.lua\tConfiguration start file (default stratagus.lua)\n" "\t-d datapath\tPath to stratagus data (default current directory)\n" "\t-D depth\tVideo mode depth = pixel per point\n" "\t-e\t\tStart editor (instead of game)\n" "\t-E file.lua\tEditor configuration start file (default editor.lua)\n" "\t-F\t\tFull screen video mode\n" "\t-h\t\tHelp shows this page\n" "\t-I addr\t\tNetwork address to use\n" "\t-l\t\tDisable command log\n" "\t-L lag\t\tNetwork lag in # frames (default 10 = 333ms)\n" "\t-n server\tNetwork server host preset\n" "\t-N name\t\tName of the player\n" "\t-o\t\tDo not use OpenGL or OpenGL ES 1.1\n" "\t-O\t\tUse OpenGL or OpenGL ES 1.1\n" "\t-P port\t\tNetwork port to use\n" "\t-s sleep\tNumber of frames for the AI to sleep before it starts\n" "\t-S speed\tSync speed (100 = 30 frames/s)\n" "\t-U update\tNetwork update rate in # frames (default 5=6x per s)\n" "\t-v mode\t\tVideo mode resolution in format <xres>x<yres>\n" "\t-W\t\tWindowed video mode\n" "map is relative to StratagusLibPath=datapath, use ./map for relative to cwd\n", Parameters::Instance.applicationName.c_str()); }
bool CHTTPSock::PrintErrorPage(unsigned int uStatusId, const CString& sStatusMsg, const CString& sMessage) { if (SentHeader()) { DEBUG("PrintErrorPage(): Header was already sent"); return false; } CString sPage = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" "<!DOCTYPE html>\r\n" "<html xmlns=\"http://www.w3.org/1999/xhtml\" lang=\"en\" xml:lang=\"en\">\r\n" "<head>\r\n" "<meta charset=\"UTF-8\"/>\r\n" "<title>" + CString(uStatusId) + " " + sStatusMsg.Escape_n(CString::EHTML) + "</title>\r\n" "</head>\r\n" "<body>\r\n" "<h1>" + sStatusMsg.Escape_n(CString::EHTML) + "</h1>\r\n" "<p>" + sMessage.Escape_n(CString::EHTML) + "</p>\r\n" "<hr/>\r\n" "<address>" + CZNC::GetTag(false, /* bHTML = */ true) + " at " + GetLocalIP().Escape_n(CString::EHTML) + " Port " + CString(GetLocalPort()) + "</address>\r\n" "</body>\r\n" "</html>\r\n"; PrintHeader(sPage.length(), "text/html; charset=utf-8", uStatusId, sStatusMsg); Write(sPage); Close(Csock::CLT_AFTERWRITE); return true; }
size_t DumpBuffer::Print() { cout << endl; size_t size = PrintHeader(); cout << "Buffer not templated to allow formatted output" << endl; return size; }
int DrawHistogram_Vertical(int lengths[], int arraySize) { int i, f; //int maxActualLength = GetMaxNonZeroIntegerArrayElement(lengths, arraySize) + 1; PrintHeader(); //Loop down through frequencies and draw each horizontal part of vertical histogram for (f = GetMaxIntegerArrayValue(lengths, arraySize); f >= 1; f--) { for (i = 0; i < arraySize; i++) { if (lengths[i] >= f) { printf(" | "); } else { printf(" "); } } printf("\n"); } //Write out column names for (i = 1; i <= arraySize; i++) { printf("%2d ", i); } printf("\n"); return 0; }
void PrintFunction(const Proto* tf) { int i,n=tf->nkproto; PrintHeader(tf); PrintCode(tf); for (i=0; i<n; i++) PrintFunction(tf->kproto[i]); }
static void NET_QueryPrintCallback(net_addr_t *addr, net_querydata_t *data, unsigned int ping_time, void *user_data) { // If this is the first server, print the header. if (!printed_header) { PrintHeader(); printed_header = true; } formatted_printf(5, "%4i", ping_time); formatted_printf(18, "%s: ", NET_AddrToString(addr)); formatted_printf(8, "%i/%i", data->num_players, data->max_players); if (data->gamemode != indetermined) { printf("(%s) ", GameDescription(data->gamemode, data->gamemission)); } if (data->server_state) { printf("(game running) "); } NET_SafePuts(data->description); }
void PrintResults(void) { int ix; #ifdef DEBUG fprintf(ofp, "Debug dump of globals global struct:\n"); fprintf(ofp, " files_are_different = %d\n", globals.files_are_different); fprintf(ofp, " file1_size = %d\n", globals.file1_size); fprintf(ofp, " file2_size = %d\n", globals.file2_size); fprintf(ofp, " compare_size = %d\n", globals.compare_size); fprintf(ofp, " filename1 = '%s'\n", globals.filename1); fprintf(ofp, " filename2 = '%s'\n", globals.filename2); fprintf(ofp, " rng_size = %d\n", globals.rng_size); fprintf(ofp, " rng_numel = %d\n", globals.rng_numel); fprintf(ofp, "Debug dump of range array:\n"); for (ix = 0; ix < globals.rng_numel; ix++) { fprintf(ofp, " %8d %8d\n", globals.rng[ix].start, globals.rng[ix].end); } #endif if (histogram) { PrintHistogram(); } else { PrintHeader(); PrintSeparator(); for (ix = 0; ix < globals.rng_numel; ix++) { PrintRange(globals.rng[ix].start, globals.rng[ix].end); } } }
/** ** Display the usage. */ static void Usage() { PrintHeader(); printf( "\n\nUsage: %s [OPTIONS] [map.smp|map.smp.gz]\n" "\t-a\t\tEnables asserts check in engine code (for debugging)\n" "\t-c file.lua\tConfiguration start file (default stratagus.lua)\n" "\t-d datapath\tPath to stratagus data (default current directory)\n" "\t-D depth\tVideo mode depth = pixel per point\n" "\t-e\t\tStart editor (instead of game)\n" "\t-E file.lua\tEditor configuration start file (default editor.lua)\n" "\t-F\t\tFull screen video mode\n" "\t-h\t\tHelp shows this page\n" "\t-i\t\tEnables unit info dumping into log (for debugging)\n" "\t-I addr\t\tNetwork address to use\n" "\t-l\t\tDisable command log\n" "\t-N name\t\tName of the player\n" #if defined(USE_OPENGL) || defined(USE_GLES) "\t-o\t\tDo not use OpenGL or OpenGL ES 1.1\n" "\t-O\t\tUse OpenGL or OpenGL ES 1.1\n" #endif "\t-p\t\tEnables debug messages printing in console\n" "\t-P port\t\tNetwork port to use\n" "\t-s sleep\tNumber of frames for the AI to sleep before it starts\n" "\t-S speed\tSync speed (100 = 30 frames/s)\n" "\t-u userpath\tPath where stratagus saves preferences, log and savegame\n" "\t-v mode\t\tVideo mode resolution in format <xres>x<yres>\n" "\t-W\t\tWindowed video mode\n" #if defined(USE_OPENGL) || defined(USE_GLES) "\t-Z\t\tUse OpenGL to scale the screen to the viewport (retro-style). Implies -O.\n" #endif "map is relative to StratagusLibPath=datapath, use ./map for relative to cwd\n", Parameters::Instance.applicationName.c_str()); }
void ProcOptimize(Var * proc) { if (Verbose(proc)) { PrintHeader(2, proc->name); } OptimizeCombined(proc); }
static void PrintFunction(const Proto* f, int full) { int i,n=f->sizep; PrintHeader(f); PrintCode(f); if (full) PrintDebug(f); for (i=0; i<n; i++) PrintFunction(f->p[i],full); }
static void PrintFunction(const LuaProto* f, int full) { int i,n=(int)f->subprotos_.size(); PrintHeader(f); PrintCode(f); if (full) PrintDebug(f); for (i=0; i<n; i++) PrintFunction(f->subprotos_[i],full); }
int PerformKMeans(TRAININGSET *pTS, CODEBOOK *pCB, PARTITIONING *pP, int clus, int repeats, int InitMethod, int quietLevel, int useInitial) { PARTITIONING Pnew, Pinit; CODEBOOK CBnew, CBinit; llong distance[BookSize(pTS)]; llong distanceInit[BookSize(pTS)]; double totalTime, error, currError; int i, better, iter, totalIter; SetClock(&totalTime); totalIter = 0; currError = error = 0; if ((clus < 1) || (BookSize(pTS) < clus) || (repeats < 1)) { return 1; /* clustering failed */ } InitializeSolutions(pTS, pCB, pP, &CBnew, &Pnew, &CBinit, &Pinit, distanceInit, clus, useInitial); PrintHeader(quietLevel); /* perform repeats time full K-means */ for (i = 0; i < repeats; i++) { better = iter = 0; GenerateSolution(pTS, &CBnew, &Pnew, &CBinit, &Pinit, distance, distanceInit, InitMethod, useInitial); KMeansIterate(pTS, &CBnew, &Pnew, distance, quietLevel, i, &iter, &totalTime, &error, useInitial); totalIter += iter; /* got better result */ if ((i == 0) || (error < currError)) { CopyCodebook(&CBnew, pCB); CopyPartitioning(&Pnew, pP); currError = error; better = 1; } PrintRepeat(quietLevel, repeats, i, iter, error, GetClock(totalTime), better); } PrintFooterKM(quietLevel, currError, repeats, GetClock(totalTime), totalIter); FreeCodebook(&CBnew); FreePartitioning(&Pnew); FreeCodebook(&CBinit); FreePartitioning(&Pinit); return 0; } /* PerformKmeans() */
static return_val bssMasmASMSection( section_ptr section, dis_sec_size size, label_entry l_entry ) { size_t offset = OFFSET_UNDEF; dis_value value; PrintHeader( section ); value.u._32[I64HI32] = 0; for( ; l_entry != NULL; l_entry = l_entry->next ) { if( l_entry->type != LTYP_SECTION ) { if( offset != l_entry->offset ) { BufferStore( " ORG " ); value.u._32[I64LO32] = l_entry->offset; BufferHex( 8, value ); offset = l_entry->offset; BufferConcatNL(); BufferPrint(); } switch( l_entry->type ) { case LTYP_UNNAMED: BufferStore( "%c$%d", LabelChar, l_entry->label.number ); break; case LTYP_SECTION: case LTYP_NAMED: BufferStore( "%s", l_entry->label.name ); break; } BufferConcat( " LABEL\tBYTE" ); BufferConcatNL(); BufferPrint(); } } if( offset == OFFSET_UNDEF ) { if( size > 0 ) { BufferStore( " ORG 0" ); BufferConcatNL(); BufferPrint(); } offset = 0; } if( size > offset ) { BufferStore( " ORG " ); value.u._32[I64LO32] = size; BufferHex( 8, value ); BufferConcatNL(); BufferPrint(); } PrintTail( section ); BufferConcatNL(); BufferPrint(); return( RC_OKAY ); }
void CHTTPSock::PrintPage(const CString& sPage) { if (!SentHeader()) { PrintHeader(sPage.length()); } else { DEBUG("PrintPage(): Header was already sent"); } Write(sPage); Close(Csock::CLT_AFTERWRITE); }
void CDigitalStatusPrinter::DoPrinter(QPainter*p) { m_pPrinter->newPage(); printf("DigitalStatusPrinter start\n"); PrintTitle(p); PrintHeader(p); PrintTable(p); printf("DigitalStatusPrinter end\n"); }
void PrintFunction(const Proto *f, int full) { int i, n = f->sizep; PrintHeader(f); PrintCode(f); if (full) { PrintConstants(f); PrintLocals(f); PrintUpvalues(f); } for (i = 0; i < n; i++) PrintFunction(f->p[i], full); }
void Usage() { PrintHeader(); printf("Usage:\n"); printf("ptsgdump [-h][-q][-u Username][-p Password]\n"); printf("\t -h displays this usage information\n"); printf("\t -q supresses the program information - useful when running as a batch job or saving to a file\n"); printf("\t -u username to impersonate (if not provided, the currently logged in user is used)\n"); printf("\t -p password to use in conjunction with -u\n"); exit(1); }
void luaU_print(const Proto* f) { int i,n=f->sizep; PrintHeader(f); PrintCode(f); #ifdef DEBUG_PRINT PrintConstants(f); PrintLocals(f); PrintUpvalues(f); #endif for (i=0; i<n; i++) luaU_print(f->p[i]); }
size_t DumpBuffer::Print(size_t length , size_t stride ,size_t start, size_t max) { size_t size = getSize(); (void) length; (void) stride; (void) start; (void) max; cout << endl; PrintHeader(); cout << "Buffer not templated to allow formatted output" << endl; return size; }
size_t DumpWrapper<T>::Print() { T * ptr = (T*)getData(); cout << endl; size_t size = PrintHeader(); cout << "-------------------------------------------" << endl; for(size_t i=0; i<size; i++){ cout << ptr[i] << endl; } return size; }
int main(void) { realtype dx, dy, reltol, abstol, t, tout, umax; N_Vector u, up; UserData data; void *cvode_mem; int iout, flag; long int nst; u = NULL; data = NULL; cvode_mem = NULL; u = N_VNew_Serial(NEQ); up = N_VNew_Serial(NEQ); reltol = ZERO; abstol = ATOL; data = (UserData) malloc(sizeof *data); dx = data->dx = XMAX/(MX+1); dy = data->dy = YMAX/(MY+1); data->hdcoef = ONE/(dx*dx); data->hacoef = HALF/(TWO*dx); data->vdcoef = ONE/(dy*dy); SetIC(u, data); cvode_mem = CPodeCreate(CP_EXPL, CP_BDF, CP_NEWTON); flag = CPodeInit(cvode_mem, (void *)f, data, T0, u, NULL, CP_SS, reltol, &abstol); flag = CPLapackBand(cvode_mem, NEQ, MY, MY); flag = CPDlsSetJacFn(cvode_mem, (void *)Jac, data); /* In loop over output points: call CPode, print results, test for errors */ umax = N_VMaxNorm(u); PrintHeader(reltol, abstol, umax); for(iout=1, tout=T1; iout <= NOUT; iout++, tout += DTOUT) { flag = CPode(cvode_mem, tout, &t, u, up, CP_NORMAL); umax = N_VMaxNorm(u); flag = CPodeGetNumSteps(cvode_mem, &nst); PrintOutput(t, umax, nst); } PrintFinalStats(cvode_mem); N_VDestroy_Serial(u); CPodeFree(&cvode_mem); free(data); return(0); }