您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ write_stdout函数代码示例

51自学网 2021-06-03 10:06:58
  C++
这篇教程C++ write_stdout函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中write_stdout函数的典型用法代码示例。如果您正苦于以下问题:C++ write_stdout函数的具体用法?C++ write_stdout怎么用?C++ write_stdout使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了write_stdout函数的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fields_fun

/* print all spaces, and only selected field numbers, on each line in turn */bool_t fields_fun(void *user, byte_t *buf, size_t buflen) {  const char_t *p, *q, *r;  fields_fun_t *fft = (fields_fun_t *)user;  if( fft ) {    p = (char_t *)buf;    q = (char_t *)(buf + buflen);      while( p < q ) {	if( xml_whitespace(*p) ) {	  fft->field_lock = FALSE;	  /* all whitespace is printed */	  r = skip_xml_whitespace(p, q);	  write_stdout((byte_t *)p, (r - p));	  if( memchr(p, '/n', r - p) ) {	    fft->fno = 0; /* reset field number if newline */	  }	  p = r;	}	if( p < q ) {	  if( !fft->field_lock ) {	    fft->fno++;	    fft->field_lock = TRUE;	  }	  /* find end of token */	  r = find_xml_whitespace(p, q);	  if( memberof_intervalmgr(fft->im, fft->fno) ) {	    write_stdout((byte_t *)p, (r - p));	  }	  p = r;	}      }    return TRUE;  }  return FALSE;}
开发者ID:rudimeier,项目名称:xml-coreutils,代码行数:36,


示例2: write_stdout

int redir_t::redirect(){	for(;;){		DWORD dw_avail = 0;		if(!::PeekNamedPipe(_h_stdout_read, nullptr, 0, 0, &dw_avail, nullptr))			break;		if(!dw_avail) return 1;		char buff[10240];		DWORD dw_read = 0;		if(!::ReadFile(_h_stdout_read, buff, min(_countof(buff)-1, dw_avail), &dw_read, nullptr))			break;		buff[dw_read] = '/0';		write_stdout(buff);	}	DWORD dw_err = ::GetLastError();	if(dw_err == ERROR_BROKEN_PIPE || dw_err == ERROR_NO_DATA) {		return 0;	}	return -1;}
开发者ID:movsb,项目名称:concon,代码行数:26,


示例3: dfault

result_t dfault(void *user, const char_t *data, size_t buflen) {  parserinfo_cut_t *pinfo = (parserinfo_cut_t *)user;  if( pinfo ) {     write_stdout((byte_t *)data, buflen);  }  return PARSER_OK;}
开发者ID:rudimeier,项目名称:xml-coreutils,代码行数:7,


示例4: add_user_db

void	add_user_db(char *username, char *passwd, char *homedirectory){  char	*crypt_passwd;  if ((!(*username)) || (!(*passwd)) || (!(*homedirectory)))    {      write_stdout("<missing one or several arguments>/n");      exit(1);    }  crypt_passwd = crypt_pass(passwd);  if (my_strcmp(crypt_passwd, "") == 0)    {      write_stdout("<invalid argument>/n");      exit(1);    }  create_user_db(username, crypt_passwd, homedirectory);}
开发者ID:Albatroce,项目名称:epita,代码行数:17,


示例5: main

int main(int argc, char *argv[]){	vir_machine_init();	bootstrap();	os_init();	char order[800];	int i;	while (1) {		echo_mip4();		mips_want_get_string(order, 799);		switch(order[0]) {			case 'e':				sys_exec(order + 2);				break;			case 'f':				format_disk();				write_stdout("successfully formats the disk!/n", F_WHITE, B_BLACK);				break;			case 'c':				sys_create(order + 2);				write_stdout("successfully create file/n", F_WHITE, B_BLACK);				break;			case 'w':  // copy the file to disk!			{				char *name = order + 2; // only one spaces !				sys_create(name);				int fid = sys_open(name);				int obj_id = open(name, O_RDONLY);				while (1) {					int buf;					if (read(obj_id, &buf, 1) == 0)						break;					char char_buf = (char)buf;					sys_write(fid, &char_buf, 1);				}				sys_close(fid);				write_stdout("successfully write file/n", F_WHITE, B_BLACK);				break;			}		}	}	return 0;}
开发者ID:qwenwang,项目名称:mip4,代码行数:44,


示例6: process_and_write_msg

process_and_write_msg(unsigned char account_len, char* account, 	    unsigned char protocol_len, char* protocol, 	    uint32_t msg_len, char* msg, uint32_t q_id) {  /* re-assemble message as single buffer */  unsigned char* buf;  unsigned char* buf_head;    if (msg == NULL || msg_len == 0) return;  uint32_t total_len = 4 + 4 + 1 + account_len + 1 + protocol_len + 4 + msg_len;  buf = malloc(total_len);  buf_head = buf;  *((uint32_t*)buf) = htonl(q_id);  buf += 4;  *((uint32_t*)buf) = htonl(total_len - 8);  buf += 4;  buf[0] = account_len;  buf++;  strncpy(buf, account, account_len);  buf += account_len;  buf[0] = protocol_len;  buf++;  strncpy(buf, protocol, protocol_len);  buf += protocol_len;  *((uint32_t*)buf) = htonl(msg_len);  buf += 4;  strncpy(buf, msg, msg_len);  uint32_t written = write_stdout(buf_head, total_len);    if (written == total_len) {        #ifdef __DEBUGGING    pthread_mutex_lock(&log_mutex);    fprintf(logfd, "%s", "Msg written to stdout/n");    fflush(logfd);    pthread_mutex_unlock(&log_mutex);    #endif      } else {    pthread_mutex_lock(&log_mutex);    fprintf(logfd, "Only wrote %u bytes to stdout, expected %u/n", written, total_len);    fprintf(logfd, "Failed on message from account %s protocol %s contents %s/n", account, protocol, msg);    fflush(logfd);    pthread_mutex_unlock(&log_mutex);    fprintf(stderr, "Only wrote %u bytes to stdout, expected %u/n", written, total_len);  }    free(buf_head);}
开发者ID:southernsun,项目名称:libotr,代码行数:55,


示例7: main

int	main(int argc, char **argv){  char	c, *user, *pwd, *homedir;  user = "/0";  pwd = "/0";  homedir = "/0";  write_stdout("/n/t**ADD A USER IN DATABANK**/n/n");  write_stdout("<enter your login>/n");  while ((read(STDIN_FILENO, &c, 1) != -1) && (c != '/n'))    user = my_strconcat(user, c);  write_stdout("<enter your password>/n");  while ((read(STDIN_FILENO, &c, 1) != -1) && (c != '/n'))    pwd = my_strconcat(pwd, c);  write_stdout("<enter your homedirectory>/n");  while ((read(STDIN_FILENO, &c, 1) != -1) && (c != '/n'))    homedir = my_strconcat(homedir, c);  add_user_db(user, pwd, homedir);  write_stdout("<you are now a member of our databank>/n");  return 0;}
开发者ID:Albatroce,项目名称:epita,代码行数:21,


示例8: print_permuted

/* Insert utf8chars at all positions in str */void print_permuted(char *str, int len){   int i;   char *utfp = utf8chars[0];   int utfc = 0;   if (len > 0) {      while (utfp) {         for (i = 0; i <= len; i++) {            /* Before part */            write_stdout(str, i);            /* The unicode 2-byte character */            write_stdout(utfp, strlen(utfp));            /* After part */            if (i < len) {               write_stdout(&str[i], len - i);            }            write_stdout("/n", 1);         }         utfc++;         utfp = utf8chars[utfc];      }   }}
开发者ID:AlbertVeli,项目名称:pwtools,代码行数:25,


示例9: _write

/* write Write a character to a file. `libc' subroutines will use this system routine for output to all files, including stdout Returns -1 on error or number of bytes sent */int _write(int file, char *ptr, int len){    switch (file)    {    case STDOUT_FILENO: /*stdout*/        return write_stdout((const unsigned char*)ptr, (unsigned int)len);        break;    case STDERR_FILENO: /* stderr */        return write_stderr((const unsigned char*)ptr, (unsigned int)len);        break;    default:        errno = EBADF;        return -1;    }    return 0;}
开发者ID:goulou,项目名称:embedded,代码行数:21,


示例10: write_query_response_s

void write_query_response_s(uint32_t id, unsigned char* msg, uint32_t msg_size) {  uint32_t buf_size = 0;  unsigned char* buf;  unsigned char* buf_head;    buf_size = 4 + 4 + msg_size;  buf = malloc(buf_size);  buf_head = buf;    pthread_mutex_lock(&log_mutex);  fprintf(logfd, "Writing query response to stdout -- id %u size %u msg size %u msg %s/n", id, buf_size, msg_size, msg);  fflush(logfd);  pthread_mutex_unlock(&log_mutex);    *((uint32_t*)buf) = htonl(id);  buf += 4;    *((uint32_t*)buf) = htonl((uint32_t)msg_size);  buf += 4;    memcpy(buf, msg, msg_size);    uint32_t written = buf_size;  written = write_stdout(buf_head, buf_size);    if (written == buf_size) {        pthread_mutex_lock(&log_mutex);    fprintf(logfd, "%s", "Msg written to stdout/n");    fflush(logfd);    pthread_mutex_unlock(&log_mutex);      } else {    pthread_mutex_lock(&log_mutex);    fprintf(logfd, "Only wrote %u bytes to stdout, expected %u/n", written, buf_size);    fflush(logfd);    pthread_mutex_unlock(&log_mutex);    fprintf(stderr, "Only wrote %u bytes to stdout, expected %u/n", written, buf_size);  }      free(buf_head);}
开发者ID:southernsun,项目名称:libotr,代码行数:42,


示例11: accept

//.........这里部分代码省略.........           error, strerror(error));    return FALSE;  }  if(rc == 0)    /* timeout */    return TRUE;  if(FD_ISSET(fileno(stdin), &fds_read)) {    /* read from stdin, commands/data to be dealt with and possibly passed on       to the socket       protocol:       4 letter command + LF [mandatory]       4-digit hexadecimal data length + LF [if the command takes data]       data                       [the data being as long as set above]       Commands:       DATA - plain pass-thru data    */    if(!read_stdin(buffer, 5))      return FALSE;    logmsg("Received %c%c%c%c (on stdin)",           buffer[0], buffer[1], buffer[2], buffer[3] );    if(!memcmp("PING", buffer, 4)) {      /* send reply on stdout, just proving we are alive */      if(!write_stdout("PONG/n", 5))        return FALSE;    }    else if(!memcmp("PORT", buffer, 4)) {      /* Question asking us what PORT number we are listening to.         Replies to PORT with "IPv[num]/[port]" */      sprintf((char *)buffer, "%s/%hu/n", ipv_inuse, port);      buffer_len = (ssize_t)strlen((char *)buffer);      snprintf(data, sizeof(data), "PORT/n%04zx/n", buffer_len);      if(!write_stdout(data, 10))        return FALSE;      if(!write_stdout(buffer, buffer_len))        return FALSE;    }    else if(!memcmp("QUIT", buffer, 4)) {      /* just die */      logmsg("quits");      return FALSE;    }    else if(!memcmp("DATA", buffer, 4)) {      /* data IN => data OUT */      if(!read_stdin(buffer, 5))        return FALSE;      buffer[5] = '/0';      buffer_len = (ssize_t)strtol((char *)buffer, NULL, 16);      if (buffer_len > (ssize_t)sizeof(buffer)) {        logmsg("ERROR: Buffer size (%zu bytes) too small for data size "               "(%zd bytes)", sizeof(buffer), buffer_len);        return FALSE;
开发者ID:AndyUI,项目名称:curl,代码行数:67,


示例12: main

//.........这里部分代码省略.........           " --ipv6/n"           " --bindonly/n"           " --port [port]/n"           " --connect [port]/n"           " --addr [address]");      return 0;    }  }#ifdef WIN32  win32_init();  atexit(win32_cleanup);  setmode(fileno(stdin), O_BINARY);  setmode(fileno(stdout), O_BINARY);  setmode(fileno(stderr), O_BINARY);#endif  install_signal_handlers();#ifdef ENABLE_IPV6  if(!use_ipv6)#endif    sock = socket(AF_INET, SOCK_STREAM, 0);#ifdef ENABLE_IPV6  else    sock = socket(AF_INET6, SOCK_STREAM, 0);#endif  if(CURL_SOCKET_BAD == sock) {    error = SOCKERRNO;    logmsg("Error creating socket: (%d) %s",           error, strerror(error));    write_stdout("FAIL/n", 5);    goto sockfilt_cleanup;  }  if(connectport) {    /* Active mode, we should connect to the given port number */    mode = ACTIVE;#ifdef ENABLE_IPV6    if(!use_ipv6) {#endif      memset(&me.sa4, 0, sizeof(me.sa4));      me.sa4.sin_family = AF_INET;      me.sa4.sin_port = htons(connectport);      me.sa4.sin_addr.s_addr = INADDR_ANY;      if (!addr)        addr = "127.0.0.1";      Curl_inet_pton(AF_INET, addr, &me.sa4.sin_addr);      rc = connect(sock, &me.sa, sizeof(me.sa4));#ifdef ENABLE_IPV6    }    else {      memset(&me.sa6, 0, sizeof(me.sa6));      me.sa6.sin6_family = AF_INET6;      me.sa6.sin6_port = htons(connectport);      if (!addr)        addr = "::1";      Curl_inet_pton(AF_INET6, addr, &me.sa6.sin6_addr);      rc = connect(sock, &me.sa, sizeof(me.sa6));    }#endif /* ENABLE_IPV6 */    if(rc) {
开发者ID:AndyUI,项目名称:curl,代码行数:67,


示例13: main

intmain (int argc, char **argv){  struct jpeg_compress_struct cinfo;  struct jpeg_error_mgr jerr;#ifdef PROGRESS_REPORT  struct cdjpeg_progress_mgr progress;#endif  int file_index;  cjpeg_source_ptr src_mgr;  FILE * input_file;  FILE * output_file;  JDIMENSION num_scanlines;  /* On Mac, fetch a command line. */#ifdef USE_CCOMMAND  argc = ccommand(&argv);#endif  progname = argv[0];  if (progname == NULL || progname[0] == 0)    progname = "cjpeg";		/* in case C library doesn't provide it */  /* Initialize the JPEG compression object with default error handling. */  cinfo.err = jpeg_std_error(&jerr);  jpeg_create_compress(&cinfo);  /* Add some application-specific error messages (from cderror.h) */  jerr.addon_message_table = cdjpeg_message_table;  jerr.first_addon_message = JMSG_FIRSTADDONCODE;  jerr.last_addon_message = JMSG_LASTADDONCODE;  /* Now safe to enable signal catcher. */#ifdef NEED_SIGNAL_CATCHER  enable_signal_catcher((j_common_ptr) &cinfo);#endif  /* Initialize JPEG parameters.   * Much of this may be overridden later.   * In particular, we don't yet know the input file's color space,   * but we need to provide some value for jpeg_set_defaults() to work.   */  cinfo.in_color_space = JCS_RGB; /* arbitrary guess */  jpeg_set_defaults(&cinfo);  /* Scan command line to find file names.   * It is convenient to use just one switch-parsing routine, but the switch   * values read here are ignored; we will rescan the switches after opening   * the input file.   */  file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);#ifdef TWO_FILE_COMMANDLINE  /* Must have either -outfile switch or explicit output file name */  if (outfilename == NULL) {    if (file_index != argc-2) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }    outfilename = argv[file_index+1];  } else {    if (file_index != argc-1) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }  }#else  /* Unix style: expect zero or one file name */  if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file/n", progname);    usage();  }#endif /* TWO_FILE_COMMANDLINE */  /* Open the input file. */  if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {    /* default input file is stdin */    input_file = read_stdin();  }  /* Open the output file. */  if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {    /* default output file is stdout */    output_file = write_stdout();  }#ifdef PROGRESS_REPORT//.........这里部分代码省略.........
开发者ID:deepakantony,项目名称:vispack,代码行数:101,


示例14: main

//.........这里部分代码省略.........        fprintf(stderr, "%s: must name one input and one output file/n",                progname);        usage();      }    }  }#else  /* Unix style: expect zero or one file name */  if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file/n", progname);    usage();  }#endif /* TWO_FILE_COMMANDLINE */  /* Open the input file. */  if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {    /* default input file is stdin */    input_file = read_stdin();  }  /* Open the output file. */  if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else if (!memdst) {    /* default output file is stdout */    output_file = write_stdout();  }#ifdef PROGRESS_REPORT  start_progress_monitor((j_common_ptr) &cinfo, &progress);#endif  /* Figure out the input file format, and set up to read it. */  src_mgr = select_file_type(&cinfo, input_file);  src_mgr->input_file = input_file;  /* Read the input file header to obtain file size & colorspace. */  (*src_mgr->start_input) (&cinfo, src_mgr);  /* Now that we know input colorspace, fix colorspace-dependent defaults */#if JPEG_RAW_READER  if (!is_jpeg)#endif    jpeg_default_colorspace(&cinfo);  /* Adjust default compression parameters by re-parsing the options */  file_index = parse_switches(&cinfo, argc, argv, 0, TRUE);  /* Specify data destination for compression */#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)  if (memdst)    jpeg_mem_dest(&cinfo, &outbuffer, &outsize);  else#endif    jpeg_stdio_dest(&cinfo, output_file);  /* Start compressor */  jpeg_start_compress(&cinfo, TRUE);
开发者ID:catufunwa,项目名称:mozjpeg,代码行数:67,


示例15: main

intmain (int argc, char **argv){    struct jpeg_decompress_struct cinfo;    struct jpeg_error_mgr jerr;#ifdef PROGRESS_REPORT    struct cdjpeg_progress_mgr progress;#endif    int file_index;    djpeg_dest_ptr dest_mgr = NULL;    FILE * input_file;    FILE * output_file;    unsigned char *inbuffer = NULL;    unsigned long insize = 0;    JDIMENSION num_scanlines;    /* On Mac, fetch a command line. */#ifdef USE_CCOMMAND    argc = ccommand(&argv);#endif    progname = argv[0];    if (progname == NULL || progname[0] == 0)        progname = "djpeg";         /* in case C library doesn't provide it */    /* Initialize the JPEG decompression object with default error handling. */    cinfo.err = jpeg_std_error(&jerr);    jpeg_create_decompress(&cinfo);    /* Add some application-specific error messages (from cderror.h) */    jerr.addon_message_table = cdjpeg_message_table;    jerr.first_addon_message = JMSG_FIRSTADDONCODE;    jerr.last_addon_message = JMSG_LASTADDONCODE;    /* Insert custom marker processor for COM and APP12.     * APP12 is used by some digital camera makers for textual info,     * so we provide the ability to display it as text.     * If you like, additional APPn marker types can be selected for display,     * but don't try to override APP0 or APP14 this way (see libjpeg.txt).     */    jpeg_set_marker_processor(&cinfo, JPEG_COM, print_text_marker);    jpeg_set_marker_processor(&cinfo, JPEG_APP0+12, print_text_marker);    /* Scan command line to find file names. */    /* It is convenient to use just one switch-parsing routine, but the switch     * values read here are ignored; we will rescan the switches after opening     * the input file.     * (Exception: tracing level set here controls verbosity for COM markers     * found during jpeg_read_header...)     */    file_index = parse_switches(&cinfo, argc, argv, 0, FALSE);#ifdef TWO_FILE_COMMANDLINE    /* Must have either -outfile switch or explicit output file name */    if (outfilename == NULL) {        if (file_index != argc-2) {            fprintf(stderr, "%s: must name one input and one output file/n",                    progname);            usage();        }        outfilename = argv[file_index+1];    } else {        if (file_index != argc-1) {            fprintf(stderr, "%s: must name one input and one output file/n",                    progname);            usage();        }    }#else    /* Unix style: expect zero or one file name */    if (file_index < argc-1) {        fprintf(stderr, "%s: only one input file/n", progname);        usage();    }#endif /* TWO_FILE_COMMANDLINE */    /* Open the input file. */    if (file_index < argc) {        if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {            fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);            exit(EXIT_FAILURE);        }    } else {        /* default input file is stdin */        input_file = read_stdin();    }    /* Open the output file. */    if (outfilename != NULL) {        if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {            fprintf(stderr, "%s: can't open %s/n", progname, outfilename);            exit(EXIT_FAILURE);        }    } else {        /* default output file is stdout */        output_file = write_stdout();    }#ifdef PROGRESS_REPORT    start_progress_monitor((j_common_ptr) &cinfo, &progress);//.........这里部分代码省略.........
开发者ID:jcyfkimi,项目名称:libjpeg-turbo,代码行数:101,


示例16: echo_mip4

static void echo_mip4(){	write_stdout("mip4 > ", F_WHITE, B_BLACK);}
开发者ID:qwenwang,项目名称:mip4,代码行数:4,


示例17: main

//.........这里部分代码省略.........  src_coef_arrays = jpeg_read_coefficients(&srcinfo);  /* Initialize destination compression parameters from source values */  jpeg_copy_critical_parameters(&srcinfo, &dstinfo);  /* Adjust destination parameters if required by transform options;   * also find out which set of coefficient arrays will hold the output.   */#if TRANSFORMS_SUPPORTED  dst_coef_arrays = jtransform_adjust_parameters(&srcinfo, &dstinfo,                                                 src_coef_arrays,                                                 &transformoption);#else  dst_coef_arrays = src_coef_arrays;#endif  /* Close input file, if we opened it.   * Note: we assume that jpeg_read_coefficients consumed all input   * until JPEG_REACHED_EOI, and that jpeg_finish_decompress will   * only consume more while (! cinfo->inputctl->eoi_reached).   * We cannot call jpeg_finish_decompress here since we still need the   * virtual arrays allocated from the source object for processing.   */  if (fp != stdin)    fclose(fp);  /* Open the output file. */  if (outfilename != NULL) {    if ((fp = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s for writing/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {    /* default output file is stdout */    fp = write_stdout();  }  /* Adjust default compression parameters by re-parsing the options */  file_index = parse_switches(&dstinfo, argc, argv, 0, TRUE);  /* Specify data destination for compression */#if JPEG_LIB_VERSION >= 80 || defined(MEM_SRCDST_SUPPORTED)  if (dstinfo.use_moz_defaults)    jpeg_mem_dest(&dstinfo, &outbuffer, &outsize);  else#endif    jpeg_stdio_dest(&dstinfo, fp);  /* Start compressor (note no image data is actually written here) */  jpeg_write_coefficients(&dstinfo, dst_coef_arrays);  /* Copy to the output file any extra markers that we want to preserve */  jcopy_markers_execute(&srcinfo, &dstinfo, copyoption);  /* Execute image transformation, if any */#if TRANSFORMS_SUPPORTED  jtransform_execute_transformation(&srcinfo, &dstinfo,                                    src_coef_arrays,                                    &transformoption);#endif  /* Finish compression and release memory */  jpeg_finish_compress(&dstinfo);    if (dstinfo.use_moz_defaults) {    size_t nbytes;        unsigned char *buffer = outbuffer;    unsigned long size = outsize;    if (insize < size) {      size = insize;      buffer = inbuffer;    }    nbytes = JFWRITE(fp, buffer, size);    if (nbytes < size && ferror(fp)) {      if (file_index < argc)        fprintf(stderr, "%s: can't write to %s/n", progname,                argv[file_index]);      else        fprintf(stderr, "%s: can't write to stdout/n", progname);    }  }      jpeg_destroy_compress(&dstinfo);  (void) jpeg_finish_decompress(&srcinfo);  jpeg_destroy_decompress(&srcinfo);  /* Close output file, if we opened it */  if (fp != stdout)    fclose(fp);#ifdef PROGRESS_REPORT  end_progress_monitor((j_common_ptr) &dstinfo);#endif  /* All done. */  exit(jsrcerr.num_warnings + jdsterr.num_warnings ?EXIT_WARNING:EXIT_SUCCESS);  return 0;                     /* suppress no-return-value warnings */}
开发者ID:dwbuiten,项目名称:mozjpeg,代码行数:101,


示例18: gather_statistics

int gather_statistics(__u8 *icmph, int icmplen,		      int cc, __u16 seq, int hops,		      int csfailed, struct timeval *tv, char *from,		      void (*pr_reply)(__u8 *icmph, int cc)){	int dupflag = 0;	long triptime = 0;	__u8 *ptr = icmph + icmplen;	++nreceived;	if (!csfailed)		acknowledge(seq);	if (timing && cc >= 8+sizeof(struct timeval)) {		struct timeval tmp_tv;		memcpy(&tmp_tv, ptr, sizeof(tmp_tv));restamp:		tvsub(tv, &tmp_tv);		triptime = tv->tv_sec * 1000000 + tv->tv_usec;		if (triptime < 0) {			fprintf(stderr, "Warning: time of day goes back (%ldus), taking countermeasures./n", triptime);			triptime = 0;			if (!(options & F_LATENCY)) {				gettimeofday(tv, NULL);				options |= F_LATENCY;				goto restamp;			}		}		if (!csfailed) {			tsum += triptime;			tsum2 += (long long)triptime * (long long)triptime;			if (triptime < tmin)				tmin = triptime;			if (triptime > tmax)				tmax = triptime;			if (!rtt)				rtt = triptime*8;			else				rtt += triptime-rtt/8;			if (options&F_ADAPTIVE)				update_interval();		}	}	if (csfailed) {		++nchecksum;		--nreceived;	} else if (rcvd_test(seq)) {		++nrepeats;		--nreceived;		dupflag = 1;	} else {		rcvd_set(seq);		dupflag = 0;	}	confirm = confirm_flag;	if (options & F_QUIET)		return 1;	if (options & F_FLOOD) {		if (!csfailed)			write_stdout("/b /b", 3);		else			write_stdout("/bC", 2);	} else {		int i;		__u8 *cp, *dp;		print_timestamp();		printf("%d bytes from %s:", cc, from);		if (pr_reply)			pr_reply(icmph, cc);		if (hops >= 0)			printf(" ttl=%d", hops);		if (cc < datalen+8) {			printf(" (truncated)/n");			return 1;		}		if (timing) {			if (triptime >= 100000)				printf(" time=%ld ms", triptime/1000);			else if (triptime >= 10000)				printf(" time=%ld.%01ld ms", triptime/1000,				       (triptime%1000)/100);			else if (triptime >= 1000)				printf(" time=%ld.%02ld ms", triptime/1000,				       (triptime%1000)/10);			else				printf(" time=%ld.%03ld ms", triptime/1000,				       triptime%1000);		}		if (dupflag)			printf(" (DUP!)");		if (csfailed)			printf(" (BAD CHECKSUM!)");//.........这里部分代码省略.........
开发者ID:DARKPOP,项目名称:external_iputils,代码行数:101,


示例19: pinger

/* * pinger -- * 	Compose and transmit an ICMP ECHO REQUEST packet.  The IP packet * will be added on by the kernel.  The ID field is our UNIX process ID, * and the sequence number is an ascending integer.  The first 8 bytes * of the data portion are used to hold a UNIX "timeval" struct in VAX * byte-order, to compute the round-trip time. */int pinger(void){	static int oom_count;	static int tokens;	int i;	/* Have we already sent enough? If we have, return an arbitrary positive value. */	if (exiting || (npackets && ntransmitted >= npackets && !deadline))		return 1000;	/* Check that packets < rate*time + preload */	if (cur_time.tv_sec == 0) {		gettimeofday(&cur_time, NULL);		tokens = interval*(preload-1);	} else {		long ntokens;		struct timeval tv;		gettimeofday(&tv, NULL);		ntokens = (tv.tv_sec - cur_time.tv_sec)*1000 +			(tv.tv_usec-cur_time.tv_usec)/1000;		if (!interval) {			/* Case of unlimited flood is special;			 * if we see no reply, they are limited to 100pps */			if (ntokens < MININTERVAL && in_flight() >= preload)				return MININTERVAL-ntokens;		}		ntokens += tokens;		if (ntokens > interval*preload)			ntokens = interval*preload;		if (ntokens < interval)			return interval - ntokens;		cur_time = tv;		tokens = ntokens - interval;	}	if (options & F_OUTSTANDING) {		if (ntransmitted > 0 && !rcvd_test(ntransmitted)) {			print_timestamp();			printf("no answer yet for icmp_seq=%lu/n", (ntransmitted % MAX_DUP_CHK));			fflush(stdout);		}	}resend:	i = send_probe();	if (i == 0) {		oom_count = 0;		advance_ntransmitted();		if (!(options & F_QUIET) && (options & F_FLOOD)) {			/* Very silly, but without this output with			 * high preload or pipe size is very confusing. */			if ((preload < screen_width && pipesize < screen_width) ||			    in_flight() < screen_width)				write_stdout(".", 1);		}		return interval - tokens;	}	/* And handle various errors... */	if (i > 0) {		/* Apparently, it is some fatal bug. */		abort();	} else if (errno == ENOBUFS || errno == ENOMEM) {		int nores_interval;		/* Device queue overflow or OOM. Packet is not sent. */		tokens = 0;		/* Slowdown. This works only in adaptive mode (option -A) */		rtt_addend += (rtt < 8*50000 ? rtt/8 : 50000);		if (options&F_ADAPTIVE)			update_interval();		nores_interval = SCHINT(interval/2);		if (nores_interval > 500)			nores_interval = 500;		oom_count++;		if (oom_count*nores_interval < lingertime)			return nores_interval;		i = 0;		/* Fall to hard error. It is to avoid complete deadlock		 * on stuck output device even when dealine was not requested.		 * Expected timings are screwed up in any case, but we will		 * exit some day. :-) */	} else if (errno == EAGAIN) {		/* Socket buffer is full. */		tokens += interval;		return MININTERVAL;	} else {		if ((i=receive_error_msg()) > 0) {			/* An ICMP error arrived. *///.........这里部分代码省略.........
开发者ID:DARKPOP,项目名称:external_iputils,代码行数:101,


示例20: memcpy

bool output_stream::push(uint8_t* p_data, int size){#if TUNER_RESOURCE_SHARING	if ((0 == (((p_data[1] & 0x1f) << 8) | p_data[2])) && (188 == size)) {		if (!have_pat) {			memcpy(pat_pkt, p_data, 188);			have_pat = true;		}		if (ringbuffer.write(pat_pkt, 188)) {			count_in += 188;			return true;		} else {			fprintf(stderr, "%s> FAILED: PAT Table (%d bytes) dropped/n", __func__, 188);		}	} else if (want_pkt(p_data)) {#else	if ((0 == (((p_data[1] & 0x1f) << 8) | p_data[2])) || (want_pkt(p_data))) {#endif	/* push data into output_stream buffer */	if (!ringbuffer.write(p_data, size))		while (size >= 188)			if (ringbuffer.write(p_data, 188)) {				p_data += 188;				size -= 188;				count_in += 188;			} else {				fprintf(stderr, "%s> FAILED: %d bytes dropped/n", __func__, size);#if 0				dPrintf("(push-false-stream) %d packets in, %d packets out, %d packets remain in rbuf", count_in / 188, count_out / 188, ringbuffer.get_size() / 188);#endif				return false;			}	else count_in += size;#if 0	dPrintf("(push-true-stream) %d packets in, %d packets out, %d packets remain in rbuf", count_in / 188, count_out / 188, ringbuffer.get_size() / 188);#endif	}	return true;}int output_stream::stream(uint8_t* p_data, int size){	int ret = -1;	if ((!p_data) || (!size))		dPrintf("no data to stream!!!");	/* stream data to target */	else switch (stream_method) {	case OUTPUT_STREAM_UDP:		if (!priv) dPrintf("no priv - should never happen!!!"); else		ret = socket_send(sock, p_data, size, 0, (struct sockaddr*) &priv->ip_addr, sizeof(priv->ip_addr));		break;	case OUTPUT_STREAM_TCP:		if (!priv) dPrintf("no priv - should never happen!!!"); else		ret = socket_send(sock, p_data, size, 0);		if (ret < 0) {			stop_without_wait();			perror("tcp streaming failed");		}		break;	case OUTPUT_STREAM_FILE:		ret = write(sock, p_data, size);		if (ret < 0) {			stop_without_wait();			perror("file streaming failed");		}		break;	case OUTPUT_STREAM_HTTP:		ret = stream_http_chunk(sock, p_data, size);		if (ret < 0) {			stop_without_wait();			perror("http streaming failed");		}		break;	case OUTPUT_STREAM_FUNC:		if (stream_cb)			ret = stream_cb(stream_cb_priv, p_data, size);		if (ret < 0) {			stop_without_wait();			perror("streaming via callback failed");		}		break;	case OUTPUT_STREAM_INTF:		if (m_iface)			ret = m_iface->stream(p_data, size);		if (ret < 0) {			stop_without_wait();			perror("streaming via interface failed");		}		break;	case OUTPUT_STREAM_STDOUT:		ret = write_stdout(p_data, size);		if (ret != size) {			stop_without_wait();			perror("dump to stdout failed");		}		break;	}	return ret;}
开发者ID:mkrufky,项目名称:libdvbtee,代码行数:100,


示例21: main

intmain (int argc, char **argv){  struct jpeg_decompress_struct srcinfo;  struct jpeg_compress_struct dstinfo;  struct jpeg_error_mgr jsrcerr, jdsterr;#ifdef PROGRESS_REPORT  struct cdjpeg_progress_mgr progress;#endif  jvirt_barray_ptr * src_coef_arrays;  jvirt_barray_ptr * dst_coef_arrays;  int file_index;  FILE * input_file;  FILE * output_file;  #ifdef USE_CCOMMAND  argc = ccommand(&argv);#endif  progname = argv[0];  if (progname == NULL || progname[0] == 0)    progname = "jpegtran";	    srcinfo.err = jpeg_std_error(&jsrcerr);  jpeg_create_decompress(&srcinfo);    dstinfo.err = jpeg_std_error(&jdsterr);  jpeg_create_compress(&dstinfo);#ifdef NEED_SIGNAL_CATCHER  enable_signal_catcher((j_common_ptr) &srcinfo);#endif  file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);  jsrcerr.trace_level = jdsterr.trace_level;  srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;#ifdef TWO_FILE_COMMANDLINE    if (outfilename == NULL) {    if (file_index != argc-2) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }    outfilename = argv[file_index+1];  } else {    if (file_index != argc-1) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }  }#else    if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file/n", progname);    usage();  }#endif     if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {        input_file = read_stdin();  }    if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {        output_file = write_stdout();  }#ifdef PROGRESS_REPORT  start_progress_monitor((j_common_ptr) &dstinfo, &progress);#endif    jpeg_stdio_src(&srcinfo, input_file);    jcopy_markers_setup(&srcinfo, copyoption);    (void) jpeg_read_header(&srcinfo, TRUE);#if TRANSFORMS_SUPPORTED//.........这里部分代码省略.........
开发者ID:qtekfun,项目名称:htcDesire820Kernel,代码行数:101,


示例22: main

intmain (int argc, char **argv){  struct jpegxr_file_struct finfo;  struct jpeg_error_mgr jerr;#ifdef PROGRESS_REPORT  struct cdjpeg_progress_mgr progress;#endif  int file_index;  djpeg_dest_ptr dest_mgr = NULL;  FILE * input_file;  FILE * output_file;  JDIMENSION num_scanlines;  /* On Mac, fetch a command line. */#ifdef USE_CCOMMAND  argc = ccommand(&argv);#endif  progname = argv[0];  if (progname == NULL || progname[0] == 0)    progname = "djpeg-xr";		/* in case C library doesn't provide it */  /* Initialize the JPEG-XR file decompression object with default error   * handling. */  finfo.err = jpeg_std_error(&jerr);  jpegxr_file_create_decompress(&finfo);  /* Add some application-specific error messages (from cderror.h) */  jerr.addon_message_table = cdjpeg_message_table;  jerr.first_addon_message = JMSG_FIRSTADDONCODE;  jerr.last_addon_message = JMSG_LASTADDONCODE;  /* Now safe to enable signal catcher. */#ifdef NEED_SIGNAL_CATCHER  enable_signal_catcher((j_common_ptr) &finfo);#endif  /* Scan command line to find file names. */  /* It is convenient to use just one switch-parsing routine, but the switch   * values read here are ignored; we will rescan the switches after opening   * the input file.   * (Exception: tracing level set here controls verbosity for COM markers   * found during jpeg_read_header...)   */  file_index = parse_switches(&finfo, argc, argv, 0, FALSE);#ifdef TWO_FILE_COMMANDLINE  /* Must have either -outfile switch or explicit output file name */  if (outfilename == NULL) {    if (file_index != argc-2) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }    outfilename = argv[file_index+1];  } else {    if (file_index != argc-1) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }  }#else  /* Unix style: expect zero or one file name */  if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file/n", progname);    usage();  }#endif /* TWO_FILE_COMMANDLINE */  /* Open the input file. */  if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {    /* default input file is stdin */    input_file = read_stdin();  }  /* Open the output file. */  if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {    /* default output file is stdout */    output_file = write_stdout();  }  #ifdef PROGRESS_REPORT  start_progress_monitor((j_common_ptr) &finfo, &progress);#endif  /* Specify data source for decompression */  jpeg_stdio_src((j_common_ptr) &finfo, input_file);  //.........这里部分代码省略.........
开发者ID:chris493,项目名称:libjpeg-xr,代码行数:101,


示例23: startup

intstartup (int argc, char **argv){  struct jpeg_decompress_struct srcinfo;  struct jpeg_compress_struct dstinfo;  struct jpeg_error_mgr jsrcerr, jdsterr;#ifdef PROGRESS_REPORT  struct cdjpeg_progress_mgr progress;#endif  jvirt_barray_ptr * coef_arrays;  int file_index;  FILE * input_file;  FILE * output_file;  /* On Mac, fetch a command line. */#ifdef USE_CCOMMAND  argc = ccommand(&argv);#endif  progname = argv[0];  if (progname == NULL || progname[0] == 0)    progname = "jpegtran";	/* in case C library doesn't provide it */  /* Initialize the JPEG decompression object with default error handling. */  srcinfo.err = jpeg_std_error(&jsrcerr);  jpeg_create_decompress(&srcinfo);  /* Initialize the JPEG compression object with default error handling. */  dstinfo.err = jpeg_std_error(&jdsterr);  jpeg_create_compress(&dstinfo);  /* Now safe to enable signal catcher.   * Note: we assume only the decompression object will have virtual arrays.   */#ifdef NEED_SIGNAL_CATCHER  enable_signal_catcher((j_common_ptr) &srcinfo);#endif  /* Scan command line to find file names.   * It is convenient to use just one switch-parsing routine, but the switch   * values read here are ignored; we will rescan the switches after opening   * the input file.   */  file_index = parse_switches(&dstinfo, argc, argv, 0, FALSE);  jsrcerr.trace_level = jdsterr.trace_level;  srcinfo.mem->max_memory_to_use = dstinfo.mem->max_memory_to_use;#ifdef TWO_FILE_COMMANDLINE  /* Must have either -outfile switch or explicit output file name */  if (outfilename == NULL) {    if (file_index != argc-2) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }    outfilename = argv[file_index+1];  } else {    if (file_index != argc-1) {      fprintf(stderr, "%s: must name one input and one output file/n",	      progname);      usage();    }  }#else  /* Unix style: expect zero or one file name */  if (file_index < argc-1) {    fprintf(stderr, "%s: only one input file/n", progname);    usage();  }#endif /* TWO_FILE_COMMANDLINE */  /* Open the input file. */  if (file_index < argc) {    if ((input_file = fopen(argv[file_index], READ_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, argv[file_index]);      exit(EXIT_FAILURE);    }  } else {    /* default input file is stdin */    input_file = read_stdin();  }  /* Open the output file. */  if (outfilename != NULL) {    if ((output_file = fopen(outfilename, WRITE_BINARY)) == NULL) {      fprintf(stderr, "%s: can't open %s/n", progname, outfilename);      exit(EXIT_FAILURE);    }  } else {    /* default output file is stdout */    output_file = write_stdout();  }#ifdef PROGRESS_REPORT  start_progress_monitor((j_common_ptr) &dstinfo, &progress);#endif  /* Specify data source for decompression */  jpeg_stdio_src(&srcinfo, input_file);//.........这里部分代码省略.........
开发者ID:phillipstanleymarbell,项目名称:sunflower-simulator,代码行数:101,



注:本文中的write_stdout函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ write_str函数代码示例
C++ write_status函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。