当前位置: 首页>>代码示例>>C++>>正文


C++ SETBIT函数代码示例

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


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

示例1: SETBIT

void IDLMRecord::IsDoOnce(bool value)
    {
    SETBIT(IDLF.value, fIsDoOnce, value);
    }
开发者ID:Dienes,项目名称:CBash,代码行数:4,代码来源:IDLMRecord.cpp

示例2: SETBIT

void WRLDRecord::IsNeedsWaterAdjustment(bool value)
    {
    SETBIT(PNAM.value, fIsNeedsWaterAdjustment, value);
    }
开发者ID:Dienes,项目名称:CBash,代码行数:4,代码来源:WRLDRecord.cpp

示例3: main

void main(void){
  __disable_interrupt();
  //Anolog mux channel select output
  DDRA = 0x3B;
  
  DDRB = 0xFF;          //initialize LCD
  SETBIT(PORTB, 0);     //deselect slave
  init_lcd_dog();
  clear_dsp();
  
  DDRD = 0x01;                  //  initialize PortD for interrupt
  PORTD = 0x02;
  
  SETBIT(DDRD, 7);    //enable buzzer output
  SETBIT(PORTD, 7);   //disable buzzer
  
  EIMSK = 0x0F;                 // enable individual interrupt
  EICRA = 0x53;
  
  __enable_interrupt();
  
  //infinite loop -- approximately 1 second for each loop
  while(1){
    if(present_state == Limit){
      __EEGET(temp_limit,channel_display);
      if(flag & (1 << 0)){
        temp_int = ((signed int)(temp_limit)*9)/5 + 32;
        unit_temp = 'F';
      }else{
        temp_int = (signed int)temp_limit;
        unit_temp = 'C';
      }
      
      clear_dsp();
      printf("Limit: %d ",temp_int);
      putchar(unit_temp);
      update_lcd_dog();
      
    }else{
      for(channel_conv = 0; channel_conv < 8; channel_conv++){
        DG528_driver(channel_conv);       //select channel
        for(i = 0; i < 10; i++){  //conv for each channel 10 times
          channel_voltage[channel_conv][i%8] = ADC161_conv();
        }
      }
      
      if(present_state == Auto){
        if(current_time == 3){
          current_time = 0;     //reset timer;
          channel_display = (channel_display + 1)%8;
        }else
          current_time ++ ;
      }else
        current_time = 0;      //always reset timer on man state
      
      if(present_state == Alert && counter == 0)
        CLEARBIT(PORTD, 7);
      else{
        SETBIT(PORTD, 7);
        if(counter > 0)
          counter --;
      }
      //summing ADC reading for a particular channel
      adc_sum = 0;
      for(i = 0; i<8; i++)
        adc_sum += (unsigned long int)channel_voltage[channel_display][i];
      
      //average the sum and look up the temperature in the table  
      temperature = tb_lookup(((unsigned int)(adc_sum >> 3)));
      
      if(flag & (1 << 0)){
        temperature = (temperature* 9)/5 + 320;
        unit_temp = 'F';
      }else
        unit_temp = 'C';
      if(temperature < 0)
         temp_tenth = (0 - temperature)%10;
      else
         temp_tenth = temperature%10;
      temperature = temperature/10;
      clear_dsp();
      printf("%s: %d.%d ", a[channel_display], temperature, temp_tenth);
      putchar(unit_temp);
      update_lcd_dog();
      __EEGET(temp_limit, channel_display);
       if(flag & (1 << 0))
          temp_int = ((signed int)(temp_limit)*9)/5 + 32;
       else
         temp_int = (signed int)temp_limit;
       
       if(((temp_int != 0) && 
          (temp_int <= temperature)) || present_state == Alert)
      {
        index = 16;
        printf("LIMIT EXCEEDED!!");
        update_lcd_dog();
        SETBIT(PORTD, 0);
        CLEARBIT(PORTD, 0);
      }
      __delay_cycles(8000000);    //delay_for_1 second
//.........这里部分代码省略.........
开发者ID:ZLAllen,项目名称:Temperature_monitor_system,代码行数:101,代码来源:main.c

示例4: bfilter_add

void bfilter_add(const bloom_filter* bFilter, const unsigned* input)
{
	SETBIT(bFilter->filter, *input % bFilter->num_buckets);
}
开发者ID:chobits,项目名称:tinybloom,代码行数:4,代码来源:tinybloom.c

示例5: dht_get

int dht_get(void) {
    int res;

    sample_count++;
    if(sample_count < DHT_INTERVAL) {
        return FALSE;
    }
    sample_count = 0;

    DPUTS(label); DPUTS("read "); DPUTS("start"); DCR;

    SETBIT(DHT_DDR, DHT_PIN);       /* set to output */
    CLEARBIT(DHT_OUTP, DHT_PIN);    /* output low */

    /* This might need to be adjusted for dht11 and 22
     * Longer delay (50ms) seems to work fine on 11, but not 22. */

    _delay_ms(20);                  /* min 18ms */
    SETBIT(DHT_OUTP, DHT_PIN);      /* and high */

    CLEARBIT(DHT_DDR, DHT_PIN);     /* set for input */

    /* set up prescalar for timer0 */
    DHT_PRESCALE_REG |= \
        (DHT_CS00 << CS00) | \
        (DHT_CS01 << CS01) | \
        (DHT_CS02 << CS02);

    if((res = dht_wait_for_value(0, DHT_FORTY)) > DHT_FORTY) {
        DPUTS(label); DPUTS("fail:"); DPUTS("0"); DCR;
        return FALSE;
    }

    if((res = dht_wait_for_value(1, DHT_HUNDRED)) > DHT_HUNDRED) {
        DPUTS(label); DPUTS("fail:"); DPUTS("1"); DCR;
        return FALSE;
    }

    if(dht_wait_for_value(0, DHT_HUNDRED) > DHT_HUNDRED) {
        DPUTS(label); DPUTS("fail:"); DPUTS("2"); DCR;
        return FALSE;
    }

    for(int i=0; i<5; i++) {
        for(int j=0; j<8; j++) {
            if(dht_wait_for_value(1, DHT_EIGHTY) > DHT_EIGHTY) {
                DPUTS(label); DPUTS("fail:"); DPUTS("3"); DCR;
                return FALSE;
            }

            if(dht_wait_for_value(0, DHT_EIGHTY) > DHT_FORTY) {
                SETBIT(dht_data[i], 7-j);
            } else {
                CLEARBIT(dht_data[i], 7-j);
            }
        }
    }

    /* should check the checksum */
    uint8_t data = dht_data[0] + dht_data[1] + \
        dht_data[2] + dht_data[3];

    if (data != dht_data[4]) {
        DPUTS(label); DPUTS("fail:"); DPUTS("4"); DCR;
        return FALSE;
    }

    DPUTS(label);
    for(int i=0; i<5; i++) {
        DPUTBYTEX(dht_data[i]); DPUTS(" ");
    }
    DCR;

    /* /\* DHT11 format *\/ */
    /* if(DHT_SENSOR_MODEL == SENSOR_MODEL_DHT11) { */
    /*     DPRINTF("Humidity:    %0d.%02d percent\n\r", dht_data[0], dht_data[1]); */
    /*     DPRINTF("Temperature: %0d.%02d degrees C\n\r", dht_data[2], dht_data[3]); */
    /* } */

    /* if(DHT_SENSOR_MODEL == SENSOR_MODEL_DHT22) { */
    /*     uint16_t h, t; */
    /*     h = dht_data[0] << 8 | dht_data[1]; */
    /*     t = dht_data[2] << 8 | dht_data[3]; */

    /*     /\* DHT22 (tenths) *\/ */
    /*     DPRINTF("Hum: %0.2f\n\r", (float)h/10.0); */
    /*     DPRINTF("Temp: %0.2f\n\r", ((float)t/10.0) * (9.0/5.0) + 32); */
    /* } */

    DPUTS(label); DPUTS("read "); DPUTS("end"); DCR;
    return TRUE;
}
开发者ID:rpedde,项目名称:nrf24-sensors,代码行数:92,代码来源:dht.c

示例6: SETBIT

void IPCTRecord::IsObjectParallax(bool value)
{
    if (!DODT.IsLoaded()) return;
    SETBIT(DODT->flags, fIsParallax, value);
}
开发者ID:Gruftikus,项目名称:CBash,代码行数:5,代码来源:IPCTRecord.cpp

示例7: SETBIT

void PGRERecord::IsPopIn(bool value)
    {
    if(!XESP.IsLoaded()) return;
    SETBIT(XESP->flags, fIsPopIn, value);
    }
开发者ID:Dienes,项目名称:CBash,代码行数:5,代码来源:PGRERecord.cpp

示例8: MBI_CommRoutine_OLD_TagMessages


//.........这里部分代码省略.........
        
        /* loop thru messages and fill up tag table */
        for (pl_itr = PL_ITERATOR(node->board->data); pl_itr; pl_itr = pl_itr->next)
        {
            assert(i < (int)node->board->data->count_current);
            
            /* skip messages that have already been synced */
            if (i < (int)node->board->synced_cursor) 
            {
                i++;
                continue;
            }
            
            /* get reference to message from iterator */
            msg = PL_NODEDATA(pl_itr);
            assert(msg != NULL);
            if (msg == NULL) return MB_ERR_INTERNAL;
            
            /* c : offset within byte buffer (window)
             * w : window offset within table row
             */
            c = w = 0;
            SETZEROS(window);
            
            /* run filter on message per MPI task */
            for (p = 0; p < MBI_CommSize; p++)
            {
                if (p != MBI_CommRank)
                {   
                    /* if message accepted by filter */
                    if (1 == (*node->board->filter)(msg, p))
                    {
                        /* set bit within our byte buffer */
                        SETBIT(window, c);
                        
                        /* update outcount */
                        node->outcount[p]++;
                        total_tagged++;

                    }
                }
                
                
                /* move index within window */
                c++;
                
                /* when window full, write to table and shift window */
                if (c == 8)
                {
                    /* write byte buffer to table */
                    rc = tt_setbyte(node->board->tt, j, w, window);
                    assert(rc == TT_SUCCESS);
                    
                    /* move window */
                    w += 1;
                    
                    /* reset byte buffer */
                    SETZEROS(window);
                    c = 0;
                }
            }
            
            /* write remaining byte buffer */
            if (w < (int)node->board->tt->row_size)
            {
                rc = tt_setbyte(node->board->tt, j, w, window);
开发者ID:somebloke,项目名称:flame-libmboard,代码行数:67,代码来源:comm_routines_OLD.c

示例9: testAudioLineIn

uint32_t testAudioLineIn(void)
{
   uint32_t rtn = ERR_NO_ERROR;
   int16_t msec, sec, sample;
   int32_t dat;

   // enable the audio clocks, verifying each bit is properly set.
   SETBIT(MCASP->XGBLCTL, XHCLKRST);
   while (!CHKBIT(MCASP->XGBLCTL, XHCLKRST)) {}
   SETBIT(MCASP->RGBLCTL, RHCLKRST);
   while (!CHKBIT(MCASP->RGBLCTL, RHCLKRST)) {}

   SETBIT(MCASP->XGBLCTL, XCLKRST);
   while (!CHKBIT(MCASP->XGBLCTL, XCLKRST)) {}
   SETBIT(MCASP->RGBLCTL, RCLKRST);
   while (!CHKBIT(MCASP->RGBLCTL, RCLKRST)) {}

   SETBIT(MCASP->XGBLCTL, XSRCLR);
   while (!CHKBIT(MCASP->XGBLCTL, XSRCLR)) {}
   SETBIT(MCASP->RGBLCTL, RSRCLR);
   while (!CHKBIT(MCASP->RGBLCTL, RSRCLR)) {}

   /* Write a 0, so that no underrun occurs after releasing the state machine */
   MCASP->XBUF11 = 0;

   SETBIT(MCASP->XGBLCTL, XSMRST);
   while (!CHKBIT(MCASP->XGBLCTL, XSMRST)) {}
   SETBIT(MCASP->RGBLCTL, RSMRST);
   while (!CHKBIT(MCASP->RGBLCTL, RSMRST)) {}

   SETBIT(MCASP->XGBLCTL, XFRST);
   while (!CHKBIT(MCASP->XGBLCTL, XFRST)) {}
   SETBIT(MCASP->RGBLCTL, RFRST);
   while (!CHKBIT(MCASP->RGBLCTL, RFRST)) {}

   // wait for transmit ready and send a dummy byte.
   while(!CHKBIT(MCASP->SRCTL11, XRDY)) {}
   MCASP->XBUF11 = 0;

   // loop audio
   for (sec = 0; sec < 15; sec++)
   {
      for (msec = 0; msec < 1000; msec++)
      {
         for (sample = 0; sample < 48; sample++)
         {
            // wait for recv ready and send a sample to the left channel.
            while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
   			MCASP->XBUF11 = dat;
            dat = MCASP->XBUF12;

            // wait for recv ready and send a sample to the right channel.
            while (!CHKBIT(MCASP->SRCTL11, XRDY)) {}
   			MCASP->XBUF11 = dat;
            dat = MCASP->XBUF12;
            //printf("you received %d\n", dat);
         }
      }
   }
   return (rtn);
}
开发者ID:lundburgerr,项目名称:workspace,代码行数:61,代码来源:test_audio.c

示例10: SETBIT

void ALCHRecord::IsFood(bool value)
    {
    SETBIT(ENIT.value.flags, fIsFood, value);
    }
开发者ID:Dienes,项目名称:CBash,代码行数:4,代码来源:ALCHRecord.cpp

示例11: _hash_getovflpage


//.........这里部分代码省略.........

		/* No free space here, try to advance to next map page */
		_hash_relbuf(rel, mapbuf);
		i++;
		j = 0;					/* scan from start of next map page */
		bit = 0;

		/* Reacquire exclusive lock on the meta page */
		_hash_chgbufaccess(rel, metabuf, HASH_NOLOCK, HASH_WRITE);
	}

	/*
	 * No free pages --- have to extend the relation to add an overflow page.
	 * First, check to see if we have to add a new bitmap page too.
	 */
	if (last_bit == (uint32) (BMPGSZ_BIT(metap) - 1))
	{
		/*
		 * We create the new bitmap page with all pages marked "in use".
		 * Actually two pages in the new bitmap's range will exist
		 * immediately: the bitmap page itself, and the following page which
		 * is the one we return to the caller.	Both of these are correctly
		 * marked "in use".  Subsequent pages do not exist yet, but it is
		 * convenient to pre-mark them as "in use" too.
		 */
		bit = metap->hashm_spares[splitnum];
		_hash_initbitmap(rel, metap, bitno_to_blkno(metap, bit), MAIN_FORKNUM);
		metap->hashm_spares[splitnum]++;
	}
	else
	{
		/*
		 * Nothing to do here; since the page will be past the last used page,
		 * we know its bitmap bit was preinitialized to "in use".
		 */
	}

	/* Calculate address of the new overflow page */
	bit = metap->hashm_spares[splitnum];
	blkno = bitno_to_blkno(metap, bit);

	/*
	 * Fetch the page with _hash_getnewbuf to ensure smgr's idea of the
	 * relation length stays in sync with oursit.  XXX It's annoying to do this
	 * with metapage write lock held; would be better to use a lock that
	 * doesn't block incoming searches.
	 */
	newbuf = _hash_getnewbuf(rel, blkno, MAIN_FORKNUM);

	metap->hashm_spares[splitnum]++;

	/*
	 * Adjust hashm_firstfree to avoid redundant searches.	But don't risk
	 * changing it if someone moved it while we were searching bitmap pages.
	 */
	if (metap->hashm_firstfree == orig_firstfree)
		metap->hashm_firstfree = bit + 1;

	/* Write updated metapage and release lock, but not pin */
	_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);

	return newbuf;

found:
	/* convert bit to bit number within page */
	bit += _hash_firstfreebit(freep[j]);

	/* mark page "in use" in the bitmap */
	SETBIT(freep, bit);
	_hash_wrtbuf(rel, mapbuf);

	/* Reacquire exclusive lock on the meta page */
	_hash_chgbufaccess(rel, metabuf, HASH_NOLOCK, HASH_WRITE);

	/* convert bit to absolute bit number */
	bit += (i << BMPG_SHIFT(metap));

	/* Calculate address of the recycled overflow page */
	blkno = bitno_to_blkno(metap, bit);

	/*
	 * Adjust hashm_firstfree to avoid redundant searches.	But don't risk
	 * changing it if someone moved it while we were searching bitmap pages.
	 */
	if (metap->hashm_firstfree == orig_firstfree)
	{
		metap->hashm_firstfree = bit + 1;

		/* Write updated metapage and release lock, but not pin */
		_hash_chgbufaccess(rel, metabuf, HASH_WRITE, HASH_NOLOCK);
	}
	else
	{
		/* We didn't change the metapage, so no need to write */
		_hash_chgbufaccess(rel, metabuf, HASH_READ, HASH_NOLOCK);
	}

	/* Fetch, init, and return the recycled page */
	return _hash_getinitbuf(rel, blkno);
}
开发者ID:hoangphuoc25,项目名称:cs3223,代码行数:101,代码来源:hashovfl.c

示例12: sqlite3BitvecBuiltinTest

/*
** This routine runs an extensive test of the Bitvec code.
**
** The input is an array of integers that acts as a program
** to test the Bitvec.  The integers are opcodes followed
** by 0, 1, or 3 operands, depending on the opcode.  Another
** opcode follows immediately after the last operand.
**
** There are 6 opcodes numbered from 0 through 5.  0 is the
** "halt" opcode and causes the test to end.
**
**    0          Halt and return the number of errors
**    1 N S X    Set N bits beginning with S and incrementing by X
**    2 N S X    Clear N bits beginning with S and incrementing by X
**    3 N        Set N randomly chosen bits
**    4 N        Clear N randomly chosen bits
**    5 N S X    Set N bits from S increment X in array only, not in bitvec
**
** The opcodes 1 through 4 perform set and clear operations are performed
** on both a Bitvec object and on a linear array of bits obtained from malloc.
** Opcode 5 works on the linear array only, not on the Bitvec.
** Opcode 5 is used to deliberately induce a fault in order to
** confirm that error detection works.
**
** At the conclusion of the test the linear array is compared
** against the Bitvec object.  If there are any differences,
** an error is returned.  If they are the same, zero is returned.
**
** If a memory allocation error occurs, return -1.
*/
int sqlite3BitvecBuiltinTest(int sz, int *aOp){
  Bitvec *pBitvec = 0;
  unsigned char *pV = 0;
  int rc = -1;
  int i, nx, pc, op;
  void *pTmpSpace;

  /* Allocate the Bitvec to be tested and a linear array of
  ** bits to act as the reference */
  pBitvec = sqlite3BitvecCreate( sz );
  pV = sqlite3MallocZero( (sz+7)/8 + 1 );
  pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
  if( pBitvec==0 || pV==0 || pTmpSpace==0  ) goto bitvec_end;

  /* NULL pBitvec tests */
  sqlite3BitvecSet(0, 1);
  sqlite3BitvecClear(0, 1, pTmpSpace);

  /* Run the program */
  pc = 0;
  while( (op = aOp[pc])!=0 ){
    switch( op ){
      case 1:
      case 2:
      case 5: {
        nx = 4;
        i = aOp[pc+2] - 1;
        aOp[pc+2] += aOp[pc+3];
        break;
      }
      case 3:
      case 4: 
      default: {
        nx = 2;
        sqlite3_randomness(sizeof(i), &i);
        break;
      }
    }
    if( (--aOp[pc+1]) > 0 ) nx = 0;
    pc += nx;
    i = (i & 0x7fffffff)%sz;
    if( (op & 1)!=0 ){
      SETBIT(pV, (i+1));
      if( op!=5 ){
        if( sqlite3BitvecSet(pBitvec, i+1) ) goto bitvec_end;
      }
    }else{
      CLEARBIT(pV, (i+1));
      sqlite3BitvecClear(pBitvec, i+1, pTmpSpace);
    }
  }

  /* Test to make sure the linear array exactly matches the
  ** Bitvec object.  Start with the assumption that they do
  ** match (rc==0).  Change rc to non-zero if a discrepancy
  ** is found.
  */
  rc = sqlite3BitvecTest(0,0) + sqlite3BitvecTest(pBitvec, sz+1)
          + sqlite3BitvecTest(pBitvec, 0)
          + (sqlite3BitvecSize(pBitvec) - sz);
  for(i=1; i<=sz; i++){
    if(  (TESTBIT(pV,i))!=sqlite3BitvecTest(pBitvec,i) ){
      rc = i;
      break;
    }
  }

  /* Free allocated structure */
bitvec_end:
  sqlite3_free(pTmpSpace);
//.........这里部分代码省略.........
开发者ID:13028122862,项目名称:firefox-ios,代码行数:101,代码来源:bitvec.c

示例13: main

	int
main (

int		argc,
char **		argv
)
{
int			i;
int			nedges;
int			nmasks;
int			fpsave;
bitmap_t *		edge_mask;
bitmap_t *		all_fsets_mask;
bitmap_t *		no_fsets_mask;
int			count;
char			tbuf [20];
char			title [128];
struct cinfo		cinfo;

	fpsave = set_floating_point_double_precision ();

	setbuf (stdout, NULL);

	decode_params (argc, argv);

	init_tables ();

	read_phase_1_data (&cinfo);

	edge_mask	= cinfo.initial_edge_mask;

	convert_cpu_time (cinfo.p1time, tbuf);
	printf (" %% Phase 1: %s seconds\n", tbuf);

	/* Prepare for plotting all terminals. */
	define_Plot_Terminals (cinfo.pts, &cinfo.scale);

	nedges = cinfo.num_edges;
	nmasks = cinfo.num_edge_masks;

	all_fsets_mask = NEWA (nmasks, bitmap_t);
	no_fsets_mask = NEWA (nmasks, bitmap_t);
	for (i = 0; i < nmasks; i++) {
		all_fsets_mask [i] = 0;
		no_fsets_mask [i] = 0;
	}
	for (i = 0; i < nedges; i++) {
		SETBIT (all_fsets_mask, i);
	}

	if (Print_Points) {
		if ((cinfo.description NE NULL) AND
		    (cinfo.description [0] NE '\0')) {
			strcpy (title, cinfo.description);
		}
		else {
			sprintf (title, "%lu points", (int32u) cinfo.num_verts);
		}
		overlay_plot_subset (title, no_fsets_mask, &cinfo, BIG_PLOT);
	}
	if (Print_Full_Sets) {
		plot_full_sets (all_fsets_mask, &cinfo, SMALL_PLOT);
	}
	if (Print_Grouped_Full_Sets) {
		plot_full_sets_grouped (all_fsets_mask, &cinfo, SMALL_PLOT);
	}

	if (Print_Overlaid_Full_Sets) {
		sprintf (title,
			 "All FSTs:  %lu points,  %s seconds",
			 (int32u) cinfo.num_verts, tbuf);
		overlay_plot_subset (title, edge_mask, &cinfo, BIG_PLOT);
	}

	restore_floating_point_precision (fpsave);

	exit (0);
}
开发者ID:JorgeKtch,项目名称:vrp,代码行数:78,代码来源:plotfst.c

示例14: add_cutset_to_list

	struct constraint *
add_cutset_to_list (

bitmap_t *		cutset,		/* IN - new cutset to add */
struct constraint *	cutlist,	/* IN - list to add to */
double *		x,		/* IN - current LP solution */
bitmap_t *		vert_mask,	/* IN - set of valid terminals */
bitmap_t *		edge_mask,	/* IN - set of valid hyperedges */
struct cinfo *		cip		/* IN - compatibility info */
)
{
int			i;
int			j;
int			nedges;
int			nmasks;
int			num_in_cut;
int			count;
int *			vp1;
int *			vp2;
struct constraint *	p;
struct constraint **	hookp;
bitmap_t *		cut_edges;
double			z;

	nedges	= cip -> num_edges;
	nmasks	= cip -> num_edge_masks;

	cut_edges = NEWA (nmasks, bitmap_t);
	memset (cut_edges, 0, nmasks * sizeof (*cut_edges));

	count = 0;
	z = 0.0;
	for (i = 0; i < cip -> num_edges; i++) {
		if (NOT BITON (edge_mask, i)) continue;
		num_in_cut = 0;
		vp1 = cip -> edge [i];
		vp2 = cip -> edge [i + 1];
		while (vp1 < vp2) {
			j = *vp1++;
			if (BITON (cutset, j)) {
				++num_in_cut;
			}
		}
		if (num_in_cut <= 0) {
			/* this hyperedge resides entirely	*/
			/* outside of the cut...  doesn't span!	*/
			continue;
		}
		if (num_in_cut >= cip -> edge_size [i]) {
			/* this hyperedge resides entirely	*/
			/* within the cut...  doesn't span!	*/
			continue;
		}
		SETBIT (cut_edges, i);
		++count;
		z += x [i];
	}

	/* Check for an all-zero cutset.  These occasionally	*/
	/* happen because of numeric issues...			*/

	if (count <= 0) {
		/* Empty cutset!  OOOPS! */
#if 1
		tracef (" %% WARNING!  empty cutset!\n");
#endif
		free ((char *) cut_edges);
		return (cutlist);
	}

	if (z >= 1.0 - FUZZ) {
#if 1
		tracef (" %% WARNING!  bogus cutset!\n");
#endif
		free ((char *) cut_edges);
		return (cutlist);
	}

	/* If this new cutset is a superset of an existing one,	*/
	/* then there is nothing to add, and nothing to delete.	*/
	for (p = cutlist; p NE NULL; p = p -> next) {
		if (is_subset (p -> mask, cut_edges, nmasks)) {
			free (cut_edges);
			return (cutlist);
		}
	}

	/* Delete all current cutsets which have this new one	*/
	/* as a subset.						*/
	hookp = &cutlist;
	while ((p = *hookp) NE NULL) {
		if (p -> type NE CT_CUTSET) {
			hookp = &(p -> next);
		}
		else if (is_subset (cut_edges, p -> mask, nmasks)) {
			*hookp = p -> next;
			free ((char *) (p -> mask));
			free ((char *) p);
		}
		else {
//.........这里部分代码省略.........
开发者ID:JorgeKtch,项目名称:vrp,代码行数:101,代码来源:cutsubs.c

示例15: splitQuotedStr

int splitQuotedStr (
                     char *str,
                     char *delims,
                     uint flgs,
                     int maxWrdCnt,
                     char *(**words)
                  ) {
  int wrdcnt = 0;
  uint flags = 0;

  char *Buffer = (char *)malloc(sizeof(char) * (strlen(str) + 1));
  char *bufPos = Buffer;
  char *ptr;
  char *p;

  //take the given flags... for now it's only FL_DLMFLD
  if (GETBIT(flgs, FL_DLMFLD))
      SETBIT(flags, FL_DLMFLD);

  if (!(*words))
     *words=(char **)malloc(sizeof(char*));

  for (ptr = str; *ptr && (GETBIT(flags, FL_MAXWRD) == 0); ptr++) {
    if ((*ptr == '\\') && (GETBIT(flags, FL_ESC)==0)) {
       SETBIT(flags, FL_ESC);
       #ifdef DEBUG
          fprintf(stderr, "Continue due to escape-char\n");
       #endif
       continue;
    }
    if (*ptr == '\"') {
        //Wenn 1. das vorhergehende Zeichen kein \ ist
        // und 2. wir nicht inmitten eines '-Wortes sind (singlequote)
       if ((GETBIT(flags, FL_ESC) == 0) &&
           (GETBIT(flags, FL_SQOT) == 0) ) {
           //...dann beginnt oder endet hier nun ein "-Wort (dblquote)
         SWPBIT(flags, FL_DQOT);
         SETBIT(flags, FL_QOTCHGD); //indikator für quote-grenze setzen
       }
    }
    if (*ptr == '\'') {
        //Wenn 1. das vorhergehende Zeichen kein \ ist
        // und 2. wir nicht inmitten eines "-Wortes sind (dblquote)
       if ((GETBIT(flags, FL_ESC) == 0) &&
           (GETBIT(flags, FL_DQOT) == 0) ) {
           //...dann beginnt oder endet hier nun ein '-Wort (singlequote)
         SWPBIT(flags, FL_SQOT);
         SETBIT(flags, FL_QOTCHGD); //indikator für wort-grenze setzen
       }
    }

    //so, nun sollte alles geklaert sein. wenn wir nicht inmitten eines
    //wortes sind, dann schauen wir mal, ob wir es mit einem
    //delimiter zu tun haben dem auch kein escape-Zeichen vorangeht:
    if (
            (GETBIT(flags, FL_SQOT) == 0)
         && (GETBIT(flags, FL_DQOT) == 0)
         && (GETBIT(flags, FL_ESC)  == 0)
       ) {
        for (p = delims; *p; p++)
           if (*ptr == *p) {
               SETBIT(flags, FL_DLM);
           }
    }

    //So, nun sind wir fast fertig: Wenn wir nicht auf einem delimiter stehen,
    //dann kopieren wir das aktuelle Zeichen in den puffer
    if (GETBIT(flags, FL_DLM) == 0)  {
      if (GETBIT(flags, FL_QOTCHGD) == 0) {
         *bufPos++ = *ptr;
         *bufPos = '\0';
      }
    } else {
        //Irgendwie müssen wir hier nun den Delimiter bearbeiten.
        if (GETBIT(flags, FL_DLMFLD) == 1) {
            //wenn delimiterfolding (FL_DLMFLD) aktiv ist, dann
            //dürfen wir keine leeren Wörter ausgeben:
            if (strlen(Buffer))
                SETBIT(flags, FL_WRDFIN);
        } else {
            //ansonsten ist uns das egal was in dem Wort steht.
            SETBIT(flags, FL_WRDFIN);
        }
        //ggf beginnen wir nun ein neues Wort und resetten den Buffer fuer
        //das naechste Wort:
        if (GETBIT(flags, FL_WRDFIN)) {
           *words = (char **)realloc(*(words), (wrdcnt + 1) * sizeof(char *));
           ((*words)[wrdcnt++]) = strdup(Buffer);
           bufPos = Buffer;
           *bufPos = '\0';
           //wenn maxWordCount definiert (>0) und erreicht ist, dann
           //setzen wir mal das Flag zum Iterationsabbruch
           if ((maxWrdCnt > 0) && (wrdcnt == maxWrdCnt)) {
              SETBIT(flags, FL_MAXWRD);
              #ifdef DEBUG
                 fprintf(stderr, "Break due to maxWrdCnt == %d\n", maxWrdCnt);
              #endif
           }
        }
    }
//.........这里部分代码省略.........
开发者ID:meissnol,项目名称:smtp-duplicator,代码行数:101,代码来源:quote.c


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