• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ check_status函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: transfer_window_files

void
transfer_window_files (gftp_window_data * fromwdata, gftp_window_data * towdata)
{
  gftp_file * tempfle, * newfle;
  GList * templist, * filelist;
  gftp_transfer * transfer;
  int num, ret, disconnect;

  if (!check_status (_("Transfer Files"), fromwdata, 1, 0, 1,
       towdata->request->put_file != NULL && fromwdata->request->get_file != NULL))
    return;

  if (!GFTP_IS_CONNECTED (fromwdata->request) || 
      !GFTP_IS_CONNECTED (towdata->request))
    {
      ftp_log (gftp_logging_error, NULL,
               _("Retrieve Files: Not connected to a remote site\n"));
      return;
    }

  if (check_reconnect (fromwdata) < 0 || check_reconnect (towdata) < 0)
    return;

  transfer = g_malloc0 (sizeof (*transfer));
  transfer->fromreq = gftp_copy_request (fromwdata->request);
  transfer->toreq = gftp_copy_request (towdata->request);
  transfer->fromwdata = fromwdata;
  transfer->towdata = towdata;

  num = 0;
  templist = gftp_gtk_get_list_selection (fromwdata);
  filelist = fromwdata->files;
  while (templist != NULL)
    {
      templist = get_next_selection (templist, &filelist, &num);
      tempfle = filelist->data;
      if (strcmp (tempfle->file, "..") != 0)
        {
          newfle = copy_fdata (tempfle);
          transfer->files = g_list_append (transfer->files, newfle);
        }
    }

  if (transfer->files != NULL)
    {
      gftp_swap_socks (transfer->fromreq, fromwdata->request);
      gftp_swap_socks (transfer->toreq, towdata->request);

      ret = gftp_gtk_get_subdirs (transfer);
      if (ret < 0)
        disconnect = 1;
      else
        disconnect = 0;

      if (!GFTP_IS_CONNECTED (transfer->fromreq))
        {
          gftpui_disconnect (fromwdata);
          disconnect = 1;
        } 

      if (!GFTP_IS_CONNECTED (transfer->toreq))
        {
          gftpui_disconnect (towdata);
          disconnect = 1;
        } 

      if (disconnect)
        {
          free_tdata (transfer);
          return;
        }

      gftp_swap_socks (fromwdata->request, transfer->fromreq);
      gftp_swap_socks (towdata->request, transfer->toreq);
    }

  if (transfer->files != NULL)
    {
      gftpui_common_add_file_transfer (transfer->fromreq, transfer->toreq, 
                                       transfer->fromwdata, transfer->towdata, 
                                       transfer->files);
      g_free (transfer);
    }
  else
    free_tdata (transfer);
}
开发者ID:GNOME,项目名称:gftp,代码行数:86,代码来源:transfer.c


示例2: process_outgoing_tun

void
process_outgoing_tun (struct context *c)
{
  struct gc_arena gc = gc_new ();

  /*
   * Set up for write() call to TUN/TAP
   * device.
   */
  if (c->c2.to_tun.len <= 0)
    return;

  perf_push (PERF_PROC_OUT_TUN);

  /*
   * The --mssfix option requires
   * us to examine the IP header (IPv4 or IPv6).
   */
  process_ip_header (c, PIP_MSSFIX|PIPV4_EXTRACT_DHCP_ROUTER|PIPV4_CLIENT_NAT|PIPV4_OUTGOING, &c->c2.to_tun);

  if (c->c2.to_tun.len <= MAX_RW_SIZE_TUN (&c->c2.frame))
    {
      /*
       * Write to TUN/TAP device.
       */
      int size;

#ifdef LOG_RW
      if (c->c2.log_rw)
	fprintf (stderr, "w");
#endif
      dmsg (D_TUN_RW, "TUN WRITE [%d]", BLEN (&c->c2.to_tun));

#ifdef PACKET_TRUNCATION_CHECK
      ipv4_packet_size_verify (BPTR (&c->c2.to_tun),
			       BLEN (&c->c2.to_tun),
			       TUNNEL_TYPE (c->c1.tuntap),
			       "WRITE_TUN",
			       &c->c2.n_trunc_tun_write);
#endif

#ifdef TUN_PASS_BUFFER
      size = write_tun_buffered (c->c1.tuntap, &c->c2.to_tun);
#else
      size = write_tun (c->c1.tuntap, BPTR (&c->c2.to_tun), BLEN (&c->c2.to_tun));
#endif

      if (size > 0)
	c->c2.tun_write_bytes += size;
      check_status (size, "write to TUN/TAP", NULL, c->c1.tuntap);

      /* check written packet size */
      if (size > 0)
	{
	  /* Did we write a different size packet than we intended? */
	  if (size != BLEN (&c->c2.to_tun))
	    msg (D_LINK_ERRORS,
		 "TUN/TAP packet was destructively fragmented on write to %s (tried=%d,actual=%d)",
		 c->c1.tuntap->actual_name,
		 BLEN (&c->c2.to_tun),
		 size);

	  /* indicate activity regarding --inactive parameter */
	  register_activity (c, size);
	}
    }
  else
    {
      /*
       * This should never happen, probably indicates some kind
       * of MTU mismatch.
       */
      msg (D_LINK_ERRORS, "tun packet too large on write (tried=%d,max=%d)",
	   c->c2.to_tun.len,
	   MAX_RW_SIZE_TUN (&c->c2.frame));
    }

  buf_reset (&c->c2.to_tun);

  perf_pop ();
  gc_free (&gc);
}
开发者ID:devxguru,项目名称:AndroVPN,代码行数:82,代码来源:forward.c


示例3: read_incoming_link

void
read_incoming_link (struct context *c)
{
  /*
   * Set up for recvfrom call to read datagram
   * sent to our TCP/UDP port.
   */
  int status;

  /*ASSERT (!c->c2.to_tun.len);*/

  perf_push (PERF_READ_IN_LINK);

  c->c2.buf = c->c2.buffers->read_link_buf;
  ASSERT (buf_init (&c->c2.buf, FRAME_HEADROOM_ADJ (&c->c2.frame, FRAME_HEADROOM_MARKER_READ_LINK)));

  status = link_socket_read (c->c2.link_socket,
			     &c->c2.buf,
			     MAX_RW_SIZE_LINK (&c->c2.frame),
			     &c->c2.from);

  if (socket_connection_reset (c->c2.link_socket, status))
    {
#if PORT_SHARE
      if (port_share && socket_foreign_protocol_detected (c->c2.link_socket))
	{
	  const struct buffer *fbuf = socket_foreign_protocol_head (c->c2.link_socket);
	  const int sd = socket_foreign_protocol_sd (c->c2.link_socket);
	  port_share_redirect (port_share, fbuf, sd);
	  register_signal (c, SIGTERM, "port-share-redirect");
	}
      else
#endif
      {
	/* received a disconnect from a connection-oriented protocol */
	if (c->options.inetd)
	  {
	    register_signal (c, SIGTERM, "connection-reset-inetd");
	    msg (D_STREAM_ERRORS, "Connection reset, inetd/xinetd exit [%d]", status);
	  }
	else
	  {
#ifdef ENABLE_OCC
	    if (event_timeout_defined(&c->c2.explicit_exit_notification_interval))
	      {
		msg (D_STREAM_ERRORS, "Connection reset during exit notification period, ignoring [%d]", status);
		openvpn_sleep(1);
	      }
	    else
#endif
	      {
		register_signal (c, SIGUSR1, "connection-reset"); /* SOFT-SIGUSR1 -- TCP connection reset */
		msg (D_STREAM_ERRORS, "Connection reset, restarting [%d]", status);
	      }
	  }
      }
      perf_pop ();
      return;
    }

  /* check recvfrom status */
  check_status (status, "read", c->c2.link_socket, NULL);

  /* Remove socks header if applicable */
  socks_postprocess_incoming_link (c);

  perf_pop ();
}
开发者ID:devxguru,项目名称:AndroVPN,代码行数:68,代码来源:forward.c


示例4: build

bool redis_string::mset(const std::vector<string>& keys,
	const std::vector<string>& values)
{
	build("MSET", NULL, keys, values);
	return check_status();
}
开发者ID:neland,项目名称:acl,代码行数:6,代码来源:redis_string.cpp


示例5: length

/*
 * Counts occurrences of four-node functional motifs in a binary graph.
 */
VECTOR_T* BCT_NAMESPACE::motif4funct_bin(const MATRIX_T* W, MATRIX_T** F) {
	if (safe_mode) check_status(W, SQUARE | BINARY, "motif4funct_bin");
	
	// load motif34lib M4 ID4 N4
	VECTOR_T* ID4;
	VECTOR_T* N4;
	MATRIX_T* M4 = motif4generate(&ID4, &N4);
	
	// n=length(W);
	int n = length(W);
	
	// f=zeros(199,1);
	VECTOR_T* f = zeros_vector(199);
	
	// F=zeros(199,n);
	if (F != NULL) {
		*F = zeros(199, n);
	}
	
	// A=1*(W~=0);
	MATRIX_T* A = compare_elements(W, fp_not_equal, 0.0);
	
	// As=A|A.';
	MATRIX_T* A_transpose = MATRIX_ID(alloc)(A->size2, A->size1);
	MATRIX_ID(transpose_memcpy)(A_transpose, A);
	MATRIX_T* As = logical_or(A, A_transpose);
	MATRIX_ID(free)(A_transpose);
	
	// for u=1:n-3
	for (int u = 0; u < n - 3; u++) {
		
		// V1=[false(1,u) As(u,u+1:n)];
		VECTOR_T* V1 = VECTOR_ID(alloc)(n);
		MATRIX_ID(get_row)(V1, As, u);
		for (int i = 0; i <= u; i++) {
			VECTOR_ID(set)(V1, i, 0.0);
		}
		
		// for v1=find(V1)
		VECTOR_T* find_V1 = find(V1);
		if (find_V1 != NULL) {
			for (int i_find_V1 = 0; i_find_V1 < (int)find_V1->size; i_find_V1++) {
				int v1 = (int)VECTOR_ID(get)(find_V1, i_find_V1);
				
				// V2=[false(1,u) As(v1,u+1:n)];
				VECTOR_T* V2 = VECTOR_ID(alloc)(n);
				MATRIX_ID(get_row)(V2, As, v1);
				for (int i = 0; i <= u; i++) {
					VECTOR_ID(set)(V2, i, 0.0);
				}
				
				// V2(V1)=0;
				logical_index_assign(V2, V1, 0.0);
				
				// V2=V2|([false(1,v1) As(u,v1+1:n)]);
				VECTOR_T* V2_1 = V2;
				VECTOR_T* V2_2 = VECTOR_ID(alloc)(n);
				MATRIX_ID(get_row)(V2_2, As, u);
				for (int i = 0; i <= v1; i++) {
					VECTOR_ID(set)(V2_2, i, 0.0);
				}
				V2 = logical_or(V2_1, V2_2);
				VECTOR_ID(free)(V2_1);
				VECTOR_ID(free)(V2_2);
				
				// for v2=find(V2)
				VECTOR_T* find_V2 = find(V2);
				if (find_V2 != NULL) {
					for (int i_find_V2 = 0; i_find_V2 < (int)find_V2->size; i_find_V2++) {
						int v2 = (int)VECTOR_ID(get)(find_V2, i_find_V2);
						
						// vz=max(v1,v2);
						int vz = (v1 > v2) ? v1 : v2;
						
						// V3=([false(1,u) As(v2,u+1:n)]);
						VECTOR_T* V3 = VECTOR_ID(alloc)(n);
						MATRIX_ID(get_row)(V3, As, v2);
						for (int i = 0; i <= u; i++) {
							VECTOR_ID(set)(V3, i, 0.0);
						}
						
						// V3(V2)=0;
						logical_index_assign(V3, V2, 0.0);
						
						// V3=V3|([false(1,v2) As(v1,v2+1:n)]);
						VECTOR_T* V3_1 = V3;
						VECTOR_T* V3_2 = VECTOR_ID(alloc)(n);
						MATRIX_ID(get_row)(V3_2, As, v1);
						for (int i = 0; i <= v2; i++) {
							VECTOR_ID(set)(V3_2, i, 0.0);
						}
						V3 = logical_or(V3_1, V3_2);
						VECTOR_ID(free)(V3_1);
						VECTOR_ID(free)(V3_2);
						
						// V3(V1)=0;
						logical_index_assign(V3, V1, 0.0);
//.........这里部分代码省略.........
开发者ID:igormis,项目名称:bct-cpp,代码行数:101,代码来源:motif4funct_bin.cpp


示例6: tune_it

int tune_it(int fd_frontend, unsigned int freq, unsigned int srate, char pol, int tone, fe_spectral_inversion_t specInv, unsigned char diseqc,fe_modulation_t modulation,fe_code_rate_t HP_CodeRate,fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth, fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier) {
  int res, hi_lo, dfd;
  unsigned int base;
  struct dvb_frontend_parameters feparams;
  struct dvb_frontend_info fe_info;

  if ( (res = ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)){
     perror("FE_GET_INFO: ");
     return -1;
  }
  
  fprintf(stderr,"Using DVB card \"%s\", freq=%d\n",fe_info.name, freq);

  if (freq < 1000000) freq*=1000UL;
  switch(fe_info.type) {
    case FE_OFDM:
      feparams.frequency=freq;
      feparams.inversion=INVERSION_OFF;
      feparams.u.ofdm.bandwidth=bandwidth;
      feparams.u.ofdm.code_rate_HP=HP_CodeRate;
      feparams.u.ofdm.code_rate_LP=LP_CodeRate;
      feparams.u.ofdm.constellation=modulation;
      feparams.u.ofdm.transmission_mode=TransmissionMode;
      feparams.u.ofdm.guard_interval=guardInterval;
      feparams.u.ofdm.hierarchy_information=hier;
      fprintf(stderr,"tuning DVB-T (%s) to %d Hz, Bandwidth: %d\n",DVB_T_LOCATION,freq, 
	bandwidth==BANDWIDTH_8_MHZ ? 8 : (bandwidth==BANDWIDTH_7_MHZ ? 7 : 6));
      break;
    case FE_QPSK:
    	pol = toupper(pol);
	if (freq > 2200000) {
        if (freq < SLOF) {
          feparams.frequency=(freq-LOF1);
	  hi_lo = 0;
	  base = LOF1;
        } else {
          feparams.frequency=(freq-LOF2);
	  hi_lo = 1;
	  base = LOF2;
      } 
      } else {
          feparams.frequency=freq;
	  base = 0;
      }

      fprintf(stderr,"tuning DVB-S to Freq: %u, Pol:%c Srate=%d, 22kHz tone=%s, LNB: %d\n",feparams.frequency,pol,srate,tone == SEC_TONE_ON ? "on" : "off", diseqc);
      feparams.inversion=specInv;
      feparams.u.qpsk.symbol_rate=srate;
      feparams.u.qpsk.fec_inner=FEC_AUTO;
      dfd = fd_frontend;

   if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
	fprintf(stderr, "DISEQC SETTING SUCCEDED\n");
   else  {
	fprintf(stderr, "DISEQC SETTING FAILED\n");
          return -1;
        }
      break;
    case FE_QAM:
      fprintf(stderr,"tuning DVB-C to %d, srate=%d\n",freq,srate);
      feparams.frequency=freq;
      feparams.inversion=INVERSION_OFF;
      feparams.u.qam.symbol_rate = srate;
      feparams.u.qam.fec_inner = FEC_AUTO;
      feparams.u.qam.modulation = modulation;
      break;
#ifdef DVB_ATSC
    case FE_ATSC:
      fprintf(stderr, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
      feparams.frequency=freq;
      feparams.u.vsb.modulation = modulation;
      break;
#endif
    default:
      fprintf(stderr,"Unknown FE type. Aborting\n");
      exit(-1);
  }
  usleep(100000);

  return(check_status(fd_frontend,fe_info.type,&feparams,base));
}
开发者ID:BGCX262,项目名称:zsoft-svn-to-git,代码行数:81,代码来源:tune.c


示例7: Vect_cidx_get_num_fields

/*!
  \brief Get number of layers in category index
  
  \param Map pointer to Map_info structure
  
  \return number of layers
 */
int Vect_cidx_get_num_fields(const struct Map_info *Map)
{
    check_status(Map);

    return Map->plus.n_cidx;
}
开发者ID:caomw,项目名称:grass,代码行数:13,代码来源:cindex.c


示例8: read_dsk

int read_dsk(spi_t *spi)
{
    int result = start_floppy(spi);
    if(result < 0) {
        return result;
    }

    int num_tracks = config.end_track - config.begin_track + 1;
    int side;
    switch(config.sides) {
        case SIDES_TOP:
            side = 1;
            break;
        case SIDES_BOTTOM:
            side = 0;
            break;
        case SIDES_ALL:
            side = 0; 
            num_tracks *= 2;
            break;
    }

    int i;
    int t = config.begin_track;
    int error = 0;
    for(i=0;i<num_tracks;i++) {
        // determine file name
        const char *output_file = config.args[0];
        char name[256];
        snprintf(name,255,"%s_%02d_%d",output_file,t,side);

        printf("reading track %02d.%d to '%s'\r", t, side, name);
        fflush(stdout);
        
        // receive SPI raw blocks with track samples
        if(config.verbose>0) {
            printf("\n  [waiting for raw blocks... wait_blocks=%d max_blocks=%d]\n", config.wait_blocks, config.max_blocks);
        }
        uint8_t *raw_blocks;
        uint32_t num_blocks;
        error = spi_bulk_read_raw_blocks(spi, config.wait_blocks, config.max_blocks, &raw_blocks, &num_blocks);

        // reading from SPI failed!
        if(error < 0) {
            printf("READ ERROR: %s (got %d blocks)\n", spi_bulk_proto_error_string(error), num_blocks);
            if(raw_blocks != NULL) {

            	/* write error dump */
            	FILE *fh = fopen("error.dump","w");
                if(fh != NULL) {
                     if(config.verbose) {
                         printf("  [writing 'error.dump']\n");
                     }
                     fwrite(raw_blocks, num_blocks * SPI_BLOCK_SIZE,1,fh);
                     fclose(fh);
                 }

            	free(raw_blocks);
            }
            error = -1;
            break;
        }
        
        // decode blocks
        uint8_t *data;
        uint32_t max_frame_size;
        int size = spi_bulk_decode_raw_blocks(raw_blocks, config.max_blocks, &data, &max_frame_size);
        if(size <= 0) {
            printf("DECODE ERROR: %s\n", spi_bulk_proto_error_string(size));
            error = -2;
            break;
        }
        if(config.verbose) {
            printf("  [decoded %d/%x bytes, max frame size: %d]\n", size, size, max_frame_size);
        }
        free(raw_blocks);

        // get status
        if(check_status(spi, size)<0) {
        	printf("SAMPLER FAILED!\n");
        	error = -3;
        	break;
        }

        // write raw track data
        FILE *fh = fopen(name,"w");
        if(fh != NULL) {
            if(config.verbose) {
                printf("  [writing track to file '%s']\n", name);
            }
            fwrite(data,size,1,fh);
            fclose(fh);
        } else {
            printf("ERROR writing to '%s'\n", name);
            error = -3;
            break;
        }
        free(data);
        
        // ready?
//.........这里部分代码省略.........
开发者ID:cnvogelg,项目名称:DiskFreezerX,代码行数:101,代码来源:read.c


示例9: read_trk

int read_trk(spi_t *spi)
{
    int result;

    result = start_floppy(spi);
    if(result < 0) {
        return result;
    }

    printf("reading track %d side %c\n", config.begin_track, config.sides);
    
    if(config.verbose>0) {
        printf("  [waiting for raw blocks... wait_blocks=%d max_blocks=%d]\n", config.wait_blocks, config.max_blocks);
    }
    uint8_t *raw_blocks;
    uint32_t num_blocks;
    result = spi_bulk_read_raw_blocks(spi, config.wait_blocks, config.max_blocks, &raw_blocks, &num_blocks);

    result = stop_floppy(spi);
    if(result < 0) {
        return result;
    }

    if(num_blocks <= 0) {
        printf("READ ERROR: %s\n", spi_bulk_proto_error_string(num_blocks));
        return num_blocks;
    }

    printf("track data: received %d blocks, %d bytes\n", num_blocks, num_blocks * 4096);
    
    // write raw (debug) data
    if(config.num_args>1) {
        const char *raw_output = config.args[1];
        FILE *fh = fopen(raw_output,"w");
        if(fh != NULL) {
            printf("writing to raw data to '%s'\n", raw_output);
            fwrite(raw_blocks,num_blocks * 4096,1,fh);
            fclose(fh);
        } else {
            printf("ERROR writing to '%s'\n", raw_output);
        }
    }

    // decode blocks
    uint8_t *data;
    uint32_t max_frame_size;
    int size = spi_bulk_decode_raw_blocks(raw_blocks, config.max_blocks, &data, &max_frame_size);
    if(size <= 0) {
        printf("DECODE ERROR: %s\n", spi_bulk_proto_error_string(size));
        return -2;
    }
    if(config.verbose) {
        printf("  [decoded %d/%x bytes, max frame size: %d]\n", size, size, max_frame_size);
    }
    free(raw_blocks);

    // check status
    if(check_status(spi, size)<0) {
    	printf("SAMPLER FAILED\n");
    	return -3;
    }

    // write data
    const char *output_file = config.args[0];
    FILE *fh = fopen(output_file,"w");
    if(fh != NULL) {
        if(config.verbose) {
            printf("writing to track to '%s'\n", output_file);
        }
        fwrite(data,size,1,fh);
        fclose(fh);
    } else {
        printf("ERROR writing to '%s'\n", output_file);
    }
    
    free(data);
    return 0;
}
开发者ID:cnvogelg,项目名称:DiskFreezerX,代码行数:78,代码来源:read.c


示例10: mp750_fill_buffer

static int
mp750_fill_buffer (pixma_t * s, pixma_imagebuf_t * ib)
{
  mp750_t *mp = (mp750_t *) s->subdriver;
  int error;
  uint8_t info;
  unsigned block_size, bytes_received, n;
  int shift[3], base_shift;
  int c;

  c = ((is_ccd_grayscale (s)) ? 3 : s->param->channels) * s->param->depth / 8; /* single-byte or double-byte data */

  if (mp->state == state_warmup)
    {
      int tmo = 60;

      query_status (s);
      check_status (s);
 /*SIM*/ while (!is_calibrated (s) && --tmo >= 0)
        {
          if (s->cancel)
            return PIXMA_ECANCELED;
          if (handle_interrupt (s, 1000) > 0)
            {
              block_size = 0;
              error = request_image_block (s, &block_size, &info);
               /*SIM*/ if (error < 0)
          return error;
            }
        }
      if (tmo < 0)
        {
          PDBG (pixma_dbg (1, "WARNING: Timed out waiting for calibration\n"));
          return PIXMA_ETIMEDOUT;
        }
      pixma_sleep (100000);
      query_status (s);
      if (is_warming_up (s) || !is_calibrated (s))
        {
          PDBG (pixma_dbg (1, "WARNING: Wrong status: wup=%d cal=%d\n",
               is_warming_up (s), is_calibrated (s)));
          return PIXMA_EPROTO;
        }
      block_size = 0;
      request_image_block (s, &block_size, &info);
       /*SIM*/ mp->state = state_scanning;
      mp->last_block = 0;
    }

  /* TODO: Move to other place, values are constant. */
  base_shift = calc_component_shifting (s) * mp->line_size;
  if (s->param->source == PIXMA_SOURCE_ADF)
    {
      shift[0] = 0;
      shift[1] = -base_shift;
      shift[2] = -2 * base_shift;
    }
  else
    {
      shift[0] = -2 * base_shift;
      shift[1] = -base_shift;
      shift[2] = 0;
    }

  do
    {
      if (mp->last_block_size > 0)
        {
          block_size = mp->imgbuf_len - mp->last_block_size;
          memcpy (mp->img, mp->img + mp->last_block_size, block_size);
        }

      do
        {
          if (s->cancel)
            return PIXMA_ECANCELED;
          if (mp->last_block)
            {
              /* end of image */
              info = mp->last_block;
              if (info != 0x38)
                {
                  query_status (s);
                   /*SIM*/ while ((info & 0x28) != 0x28)
                    {
                      pixma_sleep (10000);
                      error = request_image_block2 (s, &info);
                      if (s->cancel)
                        return PIXMA_ECANCELED;	/* FIXME: Is it safe to cancel here? */
                      if (error < 0)
                        return error;
                    }
                }
              mp->needs_abort = (info != 0x38);
              mp->last_block = info;
              mp->state = state_finished;
              return 0;
            }

          check_status (s);
//.........这里部分代码省略.........
开发者ID:Distrotech,项目名称:sane-backends,代码行数:101,代码来源:pixma_mp750.c


示例11: main

int main() {

    MPI_Init( NULL, NULL );
    FTI_Init( "config.fti", MPI_COMM_WORLD );
    MPI_Comm_rank( FTI_COMM_WORLD, &rank );
    MPI_Comm_size( FTI_COMM_WORLD, &size );

    // total number of staged files
    num_files = ((unsigned long)size)*FILES_PER_ITER*NUM_ITER;

    // request ID array
    int *reqID = (int*) malloc( FILES_PER_ITER*NUM_ITER * sizeof(int) );

    // set stage and remote directory
    char ldir[F_BUFF];
    char rdir[] = REMOTE_DIR;
    if ( FTI_GetStageDir( ldir, F_BUFF ) != FTI_SCES ) {
        EXIT_FAIL( "Failed to get the local directory." );
    }
    
    // create remote directory
    errno = 0;
    if ( mkdir( rdir, (mode_t) 0700 ) != 0 ) {
        if ( errno != EEXIST ) {
            char msg[F_BUFF];
            snprintf( msg, F_BUFF ,"unable to create remote directory ('%s').", rdir ); 
            EXIT_FAIL( msg );
        }
    }

    // allocate filename arrays
    char *lfile[FILES_PER_ITER];
    char *rfile[FILES_PER_ITER];
    char *filename[FILES_PER_ITER];
    unsigned long i;
    for(i=0; i<FILES_PER_ITER; ++i) {
        lfile[i] = (char*) malloc( F_BUFF );
        rfile[i] = (char*) malloc( F_BUFF );
        filename[i] = (char*) malloc( F_BUFF );
    }

    // perform staging
    unsigned long request_counter = 0;
    for(i=0; i<NUM_ITER; ++i) {
        unsigned long j = 0;
        for(; j<FILES_PER_ITER; ++j) {
            snprintf( filename[j], F_BUFF, F_FORM, rank, i, j );
            snprintf( lfile[j], F_BUFF, "%s/%s", ldir, filename[j] );
            snprintf( rfile[j], F_BUFF, "%s/%s", rdir, filename[j] );
            createFile( lfile[j] );
            if ( (reqID[i*FILES_PER_ITER+j] = FTI_SendFile( lfile[j], rfile[j] )) == FTI_NSCS ) {
                char msg[F_BUFF];
                snprintf( msg, F_BUFF, "Failed to stage %s.", filename[j] );
                EXIT_FAIL( msg );
            }
            request_counter++;
        }
        if ( i%CLEAN_FREQ == 0 ) {
            check_status( request_counter, reqID, true ); 
        }

    }
    
    while( check_status( request_counter, reqID, true ) ) { sleep(2); }
    
    FTI_Finalize();

    // remove files
    for(i=0; i<NUM_ITER; ++i) {
        unsigned long j = 0;
        for(; j<FILES_PER_ITER; ++j) {
            snprintf( filename[j], F_BUFF, F_FORM, rank, i, j );
            snprintf( rfile[j], F_BUFF, "%s/%s", rdir, filename[j] );
            errno = 0;
            if ( remove( rfile[j] ) != 0 ) {
                if ( errno != ENOENT ) {
                    char msg[F_BUFF];
                    snprintf( msg, F_BUFF, "Failed to remove %s ('%s').", filename[j], strerror(errno) );
                    EXIT_FAIL( msg );
                }
            }
        }
    }
    
    MPI_Finalize();

    return EXIT_SUCCESS;

}
开发者ID:leobago,项目名称:fti,代码行数:89,代码来源:massive.c


示例12: calibrate_cs

static int
calibrate_cs (pixma_t * s)
{
   /*SIM*/ check_status (s);
  return calibrate (s);
}
开发者ID:Distrotech,项目名称:sane-backends,代码行数:6,代码来源:pixma_mp750.c


示例13: activate_cs

static int
activate_cs (pixma_t * s, uint8_t x)
{
   /*SIM*/ check_status (s);
  return activate (s, x);
}
开发者ID:Distrotech,项目名称:sane-backends,代码行数:6,代码来源:pixma_mp750.c


示例14: get_neighbors

/*ARGSUSED1*/
static int
get_neighbors(dev_info_t *di, int flag)
{
	register int nid, snid, cnid;
	dev_info_t *parent;
	char buf[OBP_MAXPROPNAME];

	if (di == NULL)
		return (DDI_WALK_CONTINUE);

	nid = ddi_get_nodeid(di);

	snid = cnid = 0;
	switch (flag) {
		case DDI_WALK_PRUNESIB:
			cnid = (int)prom_childnode((pnode_t)nid);
			break;
		case DDI_WALK_PRUNECHILD:
			snid = (int)prom_nextnode((pnode_t)nid);
			break;
		case 0:
			snid = (int)prom_nextnode((pnode_t)nid);
			cnid = (int)prom_childnode((pnode_t)nid);
			break;
		default:
			return (DDI_WALK_TERMINATE);
	}


	if (snid && (snid != -1) && ((parent = ddi_get_parent(di)) != NULL)) {
		/*
		 * add the first sibling that passes check_status()
		 */
		for (; snid && (snid != -1);
		    snid = (int)prom_nextnode((pnode_t)snid)) {
			if (getlongprop_buf(snid, OBP_NAME, buf,
			    sizeof (buf)) > 0) {
				if (check_status(snid, buf, parent) ==
				    DDI_SUCCESS) {
					(void) ddi_add_child(parent, buf,
					    snid, -1);
					break;
				}
			}
		}
	}

	if (cnid && (cnid != -1)) {
		/*
		 * add the first child that passes check_status()
		 */
		if (getlongprop_buf(cnid, OBP_NAME, buf, sizeof (buf)) > 0) {
			if (check_status(cnid, buf, di) == DDI_SUCCESS) {
				(void) ddi_add_child(di, buf, cnid, -1);
			} else {
				for (cnid = (int)prom_nextnode((pnode_t)cnid);
				    cnid && (cnid != -1);
				    cnid = (int)prom_nextnode((pnode_t)cnid)) {
					if (getlongprop_buf(cnid, OBP_NAME,
					    buf, sizeof (buf)) > 0) {
						if (check_status(cnid, buf, di)
						    == DDI_SUCCESS) {
							(void) ddi_add_child(
							    di, buf, cnid, -1);
							break;
						}
					}
				}
			}
		}
	}

	return (DDI_WALK_CONTINUE);
}
开发者ID:libkeiser,项目名称:illumos-nexenta,代码行数:75,代码来源:autoconf.c


示例15: tune_it


//.........这里部分代码省略.........
	fe_transmit_mode_t TransmissionMode, fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth,
	fe_code_rate_t LP_CodeRate, fe_hierarchy_t hier, int timeout)
{
  int hi_lo = 0, dfd;
  struct dvb_frontend_parameters feparams;
  struct dvb_frontend_info fe_info;

  mp_msg(MSGT_DEMUX, MSGL_V,  "TUNE_IT, fd_frontend %d, fd_sec %d\nfreq %lu, srate %lu, pol %c, tone %i, specInv, diseqc %u, fe_modulation_t modulation,fe_code_rate_t HP_CodeRate, fe_transmit_mode_t TransmissionMode,fe_guard_interval_t guardInterval, fe_bandwidth_t bandwidth\n",
    fd_frontend, fd_sec, (long unsigned int)freq, (long unsigned int)srate, pol, tone, diseqc);


  memset(&feparams, 0, sizeof(feparams));
  if ( ioctl(fd_frontend,FE_GET_INFO, &fe_info) < 0)
  {
        mp_msg(MSGT_DEMUX, MSGL_FATAL, "FE_GET_INFO FAILED\n");
        return -1;
  }

  mp_msg(MSGT_DEMUX, MSGL_V, "Using DVB card \"%s\"\n", fe_info.name);

  switch(fe_info.type)
  {
    case FE_OFDM:
      if (freq < 1000000) freq*=1000UL;
      feparams.frequency=freq;
      feparams.inversion=specInv;
      feparams.u.ofdm.bandwidth=bandwidth;
      feparams.u.ofdm.code_rate_HP=HP_CodeRate;
      feparams.u.ofdm.code_rate_LP=LP_CodeRate;
      feparams.u.ofdm.constellation=modulation;
      feparams.u.ofdm.transmission_mode=TransmissionMode;
      feparams.u.ofdm.guard_interval=guardInterval;
      feparams.u.ofdm.hierarchy_information=hier;
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-T to %d Hz, bandwidth: %d\n",freq, bandwidth);
      break;
    case FE_QPSK:
      if (freq > 2200000)
      {
        // this must be an absolute frequency
        if (freq < SLOF)
        {
          freq = feparams.frequency=(freq-LOF1);
          hi_lo = 0;
        }
        else
        {
          freq = feparams.frequency=(freq-LOF2);
          hi_lo = 1;
        }
      }
      else
      {
        // this is an L-Band frequency
       feparams.frequency=freq;
      }

      feparams.inversion=specInv;
      feparams.u.qpsk.symbol_rate=srate;
      feparams.u.qpsk.fec_inner=HP_CodeRate;
      dfd = fd_frontend;

      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-S to Freq: %u, Pol: %c Srate: %d, 22kHz: %s, LNB:  %d\n",freq,pol,srate,hi_lo ? "on" : "off", diseqc);

      if(do_diseqc(dfd, diseqc, (pol == 'V' ? 1 : 0), hi_lo) == 0)
          mp_msg(MSGT_DEMUX, MSGL_V, "DISEQC SETTING SUCCEDED\n");
      else
      {
          mp_msg(MSGT_DEMUX, MSGL_ERR, "DISEQC SETTING FAILED\n");
          return -1;
      }
      break;
    case FE_QAM:
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning DVB-C to %d, srate=%d\n",freq,srate);
      feparams.frequency=freq;
      feparams.inversion=specInv;
      feparams.u.qam.symbol_rate = srate;
      feparams.u.qam.fec_inner = HP_CodeRate;
      feparams.u.qam.modulation = modulation;
      break;
#ifdef DVB_ATSC
    case FE_ATSC:
      mp_msg(MSGT_DEMUX, MSGL_V, "tuning ATSC to %d, modulation=%d\n",freq,modulation);
      feparams.frequency=freq;
      feparams.u.vsb.modulation = modulation;
      break;
#endif
    default:
      mp_msg(MSGT_DEMUX, MSGL_V, "Unknown FE type. Aborting\n");
      return 0;
  }
  usleep(100000);

  if(ioctl(fd_frontend,FE_SET_FRONTEND,&feparams) < 0)
  {
    mp_msg(MSGT_DEMUX, MSGL_ERR, "ERROR tuning channel\n");
    return -1;
  }

  return check_status(fd_frontend, timeout);
}
开发者ID:agiz,项目名称:mpv,代码行数:101,代码来源:dvb_tune.c


示例16: reentry_tls_init

static void reentry_tls_init() {
    // value for reentry_flag_key will default to NULL (false)
    check_status(pthread_key_create(&reentry_flag_key, NULL));
}
开发者ID:apurtell,项目名称:jdk8u-hotspot,代码行数:4,代码来源:jsig.c


示例17: length

/*
 * Counts occurrences of three-node structural motifs in a binary graph.
 */
VECTOR_T* BCT_NAMESPACE::motif3struct_bin(const MATRIX_T* A, MATRIX_T** F) {
    if (safe_mode) check_status(A, SQUARE | BINARY, "motif3struct_bin");

    // load motif34lib M3n ID3
    VECTOR_T* ID3;
    MATRIX_T* M3 = motif3generate(&ID3);

    // n=length(A);
    int n = length(A);

    // F=zeros(13,n);
    if (F != NULL) {
        *F = zeros(13, n);
    }

    // f=zeros(13,1);
    VECTOR_T* f = zeros_vector(13);

    // As=A|A.';
    MATRIX_T* A_transpose = MATRIX_ID(alloc)(A->size2, A->size1);
    MATRIX_ID(transpose_memcpy)(A_transpose, A);
    MATRIX_T* As = logical_or(A, A_transpose);
    MATRIX_ID(free)(A_transpose);

    // for u=1:n-2
    for (int u = 0; u < n - 2; u++) {

        // V1=[false(1,u) As(u,u+1:n)];
        VECTOR_T* V1 = VECTOR_ID(alloc)(n);
        MATRIX_ID(get_row)(V1, As, u);
        for (int i = 0; i <= u; i++) {
            VECTOR_ID(set)(V1, i, 0.0);
        }

        // for v1=find(V1)
        VECTOR_T* find_V1 = find(V1);
        if (find_V1 != NULL) {
            for (int i_find_V1 = 0; i_find_V1 < (int)find_V1->size; i_find_V1++) {
                int v1 = (int)VECTOR_ID(get)(find_V1, i_find_V1);

                // V2=[false(1,u) As(v1,u+1:n)];
                VECTOR_T* V2 = VECTOR_ID(alloc)(n);
                MATRIX_ID(get_row)(V2, As, v1);
                for (int i = 0; i <= u; i++) {
                    VECTOR_ID(set)(V2, i, 0.0);
                }

                // V2(V1)=0;
                logical_index_assign(V2, V1, 0.0);

                // V2=([false(1,v1) As(u,v1+1:n)])|V2;
                VECTOR_T* V2_1 = VECTOR_ID(alloc)(n);
                MATRIX_ID(get_row)(V2_1, As, u);
                for (int i = 0; i <= v1; i++) {
                    VECTOR_ID(set)(V2_1, i, 0.0);
                }
                VECTOR_T* V2_2 = V2;
                V2 = logical_or(V2_1, V2_2);
                VECTOR_ID(free)(V2_1);
                VECTOR_ID(free)(V2_2);

                // for v2=find(V2)
                VECTOR_T* find_V2 = find(V2);
                if (find_V2 != NULL) {
                    for (int i_find_V2 = 0; i_find_V2 < (int)find_V2->size; i_find_V2++) {
                        int v2 = (int)VECTOR_ID(get)(find_V2, i_find_V2);

                        // s=uint32(sum(10.^(5:-1:0).*[A(v1,u) A(v2,u) A(u,v1) A(v2,v1) A(u,v2) A(v1,v2)]));
                        int A_rows[] = { v1, v2, u, v2, u, v1 };
                        int A_cols[] = { u, u, v1, v1, v2, v2 };
                        VECTOR_T* s = VECTOR_ID(alloc)(6);
                        for (int i = 0; i < 6; i++) {
                            VECTOR_ID(set)(s, i, MATRIX_ID(get)(A, A_rows[i], A_cols[i]));
                        }

                        // ind=ID3(s==M3n);
                        int i_M3 = 0;
                        for ( ; i_M3 < (int)M3->size1; i_M3++) {
                            VECTOR_ID(view) M3_row_i_M3 = MATRIX_ID(row)(M3, i_M3);
                            if (compare_vectors(s, &M3_row_i_M3.vector) == 0) {
                                break;
                            }
                        }
                        VECTOR_ID(free)(s);
                        if (i_M3 < (int)M3->size1) {
                            int ind = (int)VECTOR_ID(get)(ID3, i_M3) - 1;

                            // if nargout==2; F(ind,[u v1 v2])=F(ind,[u v1 v2])+1; end
                            if (F != NULL) {
                                int F_cols[] = { u, v1, v2 };
                                for (int i = 0; i < 3; i++) {
                                    MATRIX_ID(set)(*F, ind, F_cols[i], MATRIX_ID(get)(*F, ind, F_cols[i]) + 1.0);
                                }
                            }

                            // f(ind)=f(ind)+1;
                            VECTOR_ID(set)(f, ind, VECTOR_ID(get)(f, ind) + 1.0);
//.........这里部分代码省略.........
开发者ID:kbxu,项目名称:bct-cpp,代码行数:101,代码来源:motif3struct_bin.cpp


示例18: hash_slot

bool redis_hash::hmset(const char* key, const std::map<string, const char*>& attrs)
{
	hash_slot(key);
	build("HMSET", key, attrs);
	return check_status();
}
开发者ID:gnuhub,项目名称:redis-1,代码行数:6,代码来源:redis_hash.cpp


示例19: main

int
main(int argc, char *argv[]) {
  cipher_t *c = NULL;
  err_status_t status;
  unsigned char test_key[20] = {
    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
    0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
    0x10, 0x11, 0x12, 0x13
  };
  int q;
  unsigned do_timing_test = 0;
  unsigned do_validation = 0;
  unsigned do_array_timing_test = 0;

  /* process input arguments */
  while (1) {
    q = getopt(argc, argv, "tva");
    if (q == -1) 
      break;
    switch (q) {
    case 't':
      do_timing_test = 1;
      break;
    case 'v':
      do_validation = 1;
      break;
    case 'a':
      do_array_timing_test = 1;
      break;
    default:
      usage(argv[0]);
    }    
  }
   
  printf("cipher test driver\n"
	 "David A. McGrew\n"
	 "Cisco Systems, Inc.\n");

  if (!do_validation && !do_timing_test && !do_array_timing_test)
    usage(argv[0]);

   /* arry timing (cache thrash) test */
  if (do_array_timing_test) {
    int max_num_cipher = 1 << 16;   /* number of ciphers in cipher_array */
    int num_cipher;
    
    for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8)
      cipher_driver_test_array_throughput(&null_cipher, 0, num_cipher); 

    for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8)
      cipher_driver_test_array_throughput(&aes_icm, 30, num_cipher); 

    for (num_cipher=1; num_cipher < max_num_cipher; num_cipher *=8)
      cipher_driver_test_array_throughput(&aes_cbc, 16, num_cipher); 
 
  }

  if (do_validation) {
    cipher_driver_self_test(&null_cipher);
    cipher_driver_self_test(&aes_icm);
    cipher_driver_self_test(&aes_cbc);
  }

  /* do timing and/or buffer_test on null_cipher */
  status = cipher_type_alloc(&null_cipher, &c, 0); 
  check_status(status);

  status = cipher_init(c, NULL, direction_encrypt);
  check_status(status);

  if (do_timing_test) 
    cipher_driver_test_throughput(c);
  if (do_validation) {
    status = cipher_driver_test_buffering(c);
    check_status(status);
  }
  status = cipher_dealloc(c);
  check_status(status);
  

  /* run the throughput test on the aes_icm cipher */
    status = cipher_type_alloc(&aes_icm, &c, 30);  
    if (status) {
      fprintf(stderr, "error: can't allocate cipher\n");
      exit(status);
    }

    status = cipher_init(c, test_key, direction_encrypt);
    check_status(status);

    if (do_timing_test)
      cipher_driver_test_throughput(c);
    
    if (do_validation) {
      status = cipher_driver_test_buffering(c);
      check_status(status);
    }
    
    status = cipher_dealloc(c);
    check_status(status);
//.........这里部分代码省略.........
开发者ID:imace,项目名称:mbgapp,代码行数:101,代码来源:cipher_driver.c


示例20: mmdb_ml_lookup_path

该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ check_stdin函数代码示例发布时间:2022-05-30
下一篇:
C++ check_state函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap