예제 #1
0
long IRrecv::decodePanasonic(decode_results *results) {
    unsigned long long data = 0;
	int offset = 1;  // Dont skip first space    
    if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_MARK)) {
        return ERR;
    }
    offset++;		
    if (!MATCH_MARK(results->rawbuf[offset], PANASONIC_HDR_SPACE)) {
        return ERR;
    }
    offset++;    
    // decode address
    for (int i = 0; i < PANASONIC_BITS; i++) {
        if (!MATCH(results->rawbuf[offset++], PANASONIC_BIT_MARK)) {
            return ERR;
        }
        if (MATCH(results->rawbuf[offset],PANASONIC_ONE_SPACE)) {
            data = (data << 1) | 1;
        } else if (MATCH(results->rawbuf[offset],PANASONIC_ZERO_SPACE)) {
            data <<= 1;
        } else {
            return ERR;
        }
        offset++;
    }
    results->value = (unsigned long)data;
    results->panasonicAddress = (unsigned int)(data >> 32);
    results->decode_type = PANASONIC;
    results->bits = PANASONIC_BITS;
    return DECODED;
}
/* does the event match the tag, followed by a null, space, or slash? */
#define MATCH(event, tag) \
  (!strncmp(event, tag, sizeof(tag)-1) && \
   (!event[sizeof(tag)-1] || strchr(" /", event[sizeof(tag)-1])))


static const char event_cookie[] = "event_cookie"; /* demo placeholder */
static void* handle_event(void* cookie, const char* event, void* arg) {
#define NS_DEMO "demo:"
  if (cookie != event_cookie)
    printf("*** bad event cookie %p != %p\n", cookie, event_cookie);

  if (xml) {
    /* We could almost do a printf(event, arg),
       but for the sake of a better demo,
       we dress the result up as valid XML.
    */
    const char* fmt = strchr(event, ' ');
    int evlen = (fmt ? fmt - event : strlen(event));
    if (!fmt) {
      if (event[0] != '/') {
        printf("<"NS_DEMO"%.*s>", evlen, event);
      } else {
        printf("</"NS_DEMO"%.*s>", evlen-1, event+1);
      }
    } else {
      if (event[0] != '/') {
        printf("<"NS_DEMO"%.*s", evlen, event);
        printf(fmt, arg);
        printf(">");
      } else {
        printf("<"NS_DEMO"%.*s_done", evlen-1, event+1);
        printf(fmt, arg);
        printf("/></"NS_DEMO"%.*s>", evlen-1, event+1);
      }
    }
  }

  if (MATCH(event, "insn")) {
    const char* name = lookup(arg);
    if (name)  printf("%s:\n", name);

    /* basic action for <insn>: */
    printf(" %p\t", arg);

  } else if (MATCH(event, "/insn")) {
    /* basic action for </insn>:
       (none, plugin puts the newline for us
    */

  } else if (MATCH(event, "mach")) {
    printf("Decoding for CPU '%s'\n", (char*) arg);

  } else if (MATCH(event, "addr")) {
    /* basic action for <addr/>: */
    const char* name = lookup(arg);
    if (name) {
      printf("&%s (%p)", name, arg);
      /* return non-null to notify hsdis not to print the addr */
      return arg;
    }
  }

  /* null return is always safe; can mean "I ignored it" */
  return NULL;
}
예제 #3
0
static int divinglog_fill_sample(struct sample *sample, const char *name, int len, char *buf)
{
	return	MATCH(".p.time", sampletime, &sample->time) ||
		MATCH(".p.depth", depth, &sample->depth) ||
		MATCH(".p.temp", fahrenheit, &sample->temperature) ||
		MATCH(".p.press1", psi, &sample->cylinderpressure) ||
		0;
}
예제 #4
0
파일: jobs.c 프로젝트: Colliotv/42.sh
static FLAG match_these(char *word)
{
  if (MATCH(";", word))
    return (NONE);
  if (MATCH("&", word))
    return (JOBS);
  return (0);
}
예제 #5
0
static int uddf_fill_sample(struct sample *sample, const char *name, int len, char *buf)
{
	return	MATCH(".divetime", sampletime, &sample->time) ||
		MATCH(".depth", depth, &sample->depth) ||
		MATCH(".temperature", temperature, &sample->temperature) ||
		MATCH(".tankpressure", pressure, &sample->cylinderpressure) ||
		0;
}
예제 #6
0
void
SCOMP(SCOMP_TYPE v1,		/* "old" vector to compare  */
      int n1,			/* ...corresponding length  */
      SCOMP_TYPE v2,		/* "new" vector to compare  */
      int n2,			/* ...corresponding length  */
      int size,			/* size of vector-entry             */
      int (*match) (SCOMP_MATCH_ARGS(p1, p2)),
      void (*report) (SCOMP_REPORT_ARGS(p1, p2)))
{
    int x, y, z;
    int j1, j2;
    char *V1 = (char *) v1;
    char *V2 = (char *) v2;
    int diag, bottom, corner, ok;

    j1 = j2 = 0;

    while ((j1 < n1) && (j2 < n2)) {
	if (MATCH(j1, j2)) {
	    j1++, j2++;
	} else {
	    corner = (n1 - j1) + (n2 - j2);
	    ok = 0;
	    for (diag = 1; !ok && (diag < corner); diag++) {

		bottom = j1 + diag;
		if (bottom >= n1)
		    bottom = n1 - 1;

		for (y = bottom; y >= j1; y--) {
		    x = (j1 + diag) - y + j2;
		    if (x >= n2)
			break;
		    for (z = 0; z < SYNC; z++) {
			if ((y + z >= n1)
			    || (x + z >= n2)
			    || MATCH(y + z, x + z))
			    ok++;
		    }
		    if (ok == SYNC) {
			(*report) (v1, j1, y - 1, v2, j2, x - 1);
			j1 = y;
			j2 = x;
			break;
		    } else
			ok = 0;
		}
	    }
	    if (!ok)		/* remainder of file is diff */
		break;
	}
    }

    if (j1 < n1)		/* deletions on end ? */
	(*report) (v1, j1, n1 - 1, v2, n2, n2 - 1);
    if (j2 < n2)		/* insertions on end ? */
	(*report) (v1, n1, n1 - 1, v2, j2, n2 - 1);
}
예제 #7
0
static int uemis_fill_sample(struct sample *sample, const char *name, int len, char *buf)
{
	return	MATCH(".reading.dive_time", sampletime, &sample->time) ||
		MATCH(".reading.water_pressure", water_pressure, &sample->depth) ||
		MATCH(".reading.active_tank", get_index, &sample->cylinderindex) ||
		MATCH(".reading.tank_pressure", centibar, &sample->cylinderpressure) ||
		MATCH(".reading.dive_temperature", decicelsius, &sample->temperature) ||
		0;
}
예제 #8
0
const ImageIOParameter *
ImageSpec::find_attribute (string_view name, ImageIOParameter &tmpparam,
                           TypeDesc searchtype, bool casesensitive) const
{
    ImageIOParameterList::const_iterator iter =
        extra_attribs.find (name, searchtype, casesensitive);
    if (iter != extra_attribs.end())
        return &(*iter);
    // Check named items in the ImageSpec structs, not in extra_attrubs
#define MATCH(n,t) (((!casesensitive && Strutil::iequals(name,n)) || \
                     ( casesensitive && name == n)) && \
                    (searchtype == TypeDesc::UNKNOWN || searchtype == t))
#define GETINT(n) if (MATCH(#n,TypeDesc::TypeInt)) { \
                      tmpparam.init (#n, TypeDesc::TypeInt, 1, &this->n); \
                      return &tmpparam; \
                  }
    GETINT(nchannels);
    GETINT(width);
    GETINT(height);
    GETINT(depth);
    GETINT(x);
    GETINT(y);
    GETINT(z);
    GETINT(full_width);
    GETINT(full_height);
    GETINT(full_depth);
    GETINT(full_x);
    GETINT(full_y);
    GETINT(full_z);
    GETINT(tile_width);
    GETINT(tile_height);
    GETINT(tile_depth);
    GETINT(alpha_channel);
    GETINT(z_channel);
    // some special cases
    if (MATCH("geom", TypeDesc::TypeString)) {
        ustring s = (depth <= 1 && full_depth <= 1)
                    ? ustring::format ("%dx%d%+d%+d", width, height, x, y)
                    : ustring::format ("%dx%dx%d%+d%+d%+d", width, height, depth, x, y, z);
        tmpparam.init ("geom", TypeDesc::TypeString, 1, &s);
        return &tmpparam;
    }
    if (MATCH("full_geom", TypeDesc::TypeString)) {
        ustring s = (depth <= 1 && full_depth <= 1)
                    ? ustring::format ("%dx%d%+d%+d",
                                       full_width, full_height, full_x, full_y)
                    : ustring::format ("%dx%dx%d%+d%+d%+d",
                                       full_width, full_height, full_depth,
                                       full_x, full_y, full_z);
        tmpparam.init ("full_geom", TypeDesc::TypeString, 1, &s);
        return &tmpparam;
    }
#undef GETINT
#undef MATCH
    return NULL;
}
예제 #9
0
파일: settings.c 프로젝트: baloo79/uTox
static void parse_notifications_section(UTOX_SAVE *config, const char* key, const char* value) {
    if (MATCH(NAMEOF(config->audible_notifications_enabled), key)) {
        config->audible_notifications_enabled = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->status_notifications), key)) {
        config->status_notifications = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->no_typing_notifications), key)) {
        config->no_typing_notifications = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->group_notifications), key)) {
        config->group_notifications = atoi(value);
    }
}
예제 #10
0
파일: settings.c 프로젝트: baloo79/uTox
static void parse_general_section(UTOX_SAVE *config, const char* key, const char* value) {
    if (MATCH(NAMEOF(config->save_version), key)) {
        config->save_version = atoi(value);
    } else if (MATCH(NAMEOF(config->utox_last_version), key)) {
        config->utox_last_version = atoi(value);
    } else if (MATCH(NAMEOF(config->send_version), key)) {
        config->send_version = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->update_to_develop), key)) {
        config->update_to_develop = STR_TO_BOOL(value);
    }
}
예제 #11
0
END_TEST

START_TEST(test_capa_add)
{
    char *ex1 = "IMAP4rev1 AUTH=LOGIN AUTH=CRAM-MD5 ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE STARTTLS UIDPLUS WITHIN LOGINDISABLED CONDSTORE LITERAL+ ENABLE QRESYNC";
    char *ex2 = "IMAP4rev1 AUTH=LOGIN AUTH=CRAM-MD5 ACL RIGHTS=texk NAMESPACE CHILDREN SORT QUOTA THREAD=ORDEREDSUBJECT UNSELECT IDLE STARTTLS UIDPLUS WITHIN LOGINDISABLED CONDSTORE LITERAL+ ENABLE QRESYNC ID";
    Capa_remove(A, "ID");
    fail_unless(! Capa_match(A, "ID"), "remove failed\n[%s] !=\n[%s]\n", ex1, Capa_as_string(A));
    fail_unless(MATCH(Capa_as_string(A), ex1), "remove failed\n[%s] !=\n[%s]\n", ex1, Capa_as_string(A));
    Capa_add(A, "ID");
    fail_unless(Capa_match(A, "ID"), "add failed\n[%s] !=\n[%s]\n", ex2, Capa_as_string(A));
    fail_unless(MATCH(Capa_as_string(A), ex2), "add failed\n[%s] !=\n[%s]\n", ex2, Capa_as_string(A));
}
예제 #12
0
파일: settings.c 프로젝트: baloo79/uTox
static void parse_av_section(UTOX_SAVE *config, const char* key, const char* value) {
    if (MATCH(NAMEOF(config->push_to_talk), key)) {
        config->push_to_talk = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->audio_filtering_enabled), key)) {
        config->audio_filtering_enabled = STR_TO_BOOL(value);
    } else if (MATCH(NAMEOF(config->audio_device_in), key)) {
        config->audio_device_in = atoi(value);
    } else if (MATCH(NAMEOF(config->audio_device_out), key)) {
        config->audio_device_out = atoi(value);
    } else if (MATCH(NAMEOF(config->video_fps), key)) {
        config->video_fps = atoi(value);
    }
}
예제 #13
0
token_type
peek_token (void)
{
  token_type result;
  int ch = peek_input ();

  if (ch == CHAR_EOF)
    {
      result = TOKEN_EOF;
    }
  else if (ch == CHAR_MACRO)
    {
      result = TOKEN_MACDEF;
    }
  else if (MATCH (ch, bcomm.string, false))
    {
      result = TOKEN_STRING;
    }
  else if ((default_word_regexp && (isalpha (ch) || ch == '_'))
#ifdef ENABLE_CHANGEWORD
           || (! default_word_regexp && word_regexp.fastmap[ch])
#endif /* ENABLE_CHANGEWORD */
           )
    {
      result = TOKEN_WORD;
    }
  else if (MATCH (ch, lquote.string, false))
    {
      result = TOKEN_STRING;
    }
  else
    switch (ch)
      {
      case '(':
        result = TOKEN_OPEN;
        break;
      case ',':
        result = TOKEN_COMMA;
        break;
      case ')':
        result = TOKEN_CLOSE;
        break;
      default:
        result = TOKEN_SIMPLE;
      }

#ifdef DEBUG_INPUT
  xfprintf (stderr, "peek_token -> %s\n", token_type_string (result));
#endif /* DEBUG_INPUT */
  return result;
}
예제 #14
0
bool	operator==(const AudioStreamBasicDescription& x, const AudioStreamBasicDescription& y)
{
	//	the semantics for equality are:
	//		1) Values must match exactly
	//		2) wildcard's are ignored in the comparison
	
#define MATCH(name) ((x.name) == 0 || (y.name) == 0 || (x.name) == (y.name))
	
	return 
			//	check the sample rate
		MATCH(mSampleRate)
		
			//	check the format ids
		&& MATCH(mFormatID)
		
			//	check the format flags
		&& (x.mFormatID == 0 || y.mFormatID == 0 || MATCH(mFormatFlags)) 
			
			//	check the bytes per packet
		&& MATCH(mBytesPerPacket) 
		
			//	check the frames per packet
		&& MATCH(mFramesPerPacket) 
		
			//	check the bytes per frame
		&& MATCH(mBytesPerFrame) 
		
			//	check the channels per frame
		&& MATCH(mChannelsPerFrame) 
		
			//	check the channels per frame
		&& MATCH(mBitsPerChannel) ;
}
예제 #15
0
static int divinglog_dive_match(struct dive *dive, const char *name, int len, char *buf)
{
	return	MATCH(".divedate", divedate, &dive->when) ||
		MATCH(".entrytime", divetime, &dive->when) ||
		MATCH(".depth", depth, &dive->maxdepth) ||
		MATCH(".tanksize", cylindersize, &dive->cylinder[0].type.size) ||
		MATCH(".presw", pressure, &dive->cylinder[0].type.workingpressure) ||
		MATCH(".comments", utf8_string, &dive->notes) ||
		MATCH(".buddy.names", utf8_string, &dive->buddy) ||
		MATCH(".country.name", utf8_string, &country) ||
		MATCH(".city.name", utf8_string, &city) ||
		MATCH(".place.name", divinglog_place, &dive->location) ||
		0;
}
예제 #16
0
/*
 * Crazy suunto xml. Look at how those o2/he things match up.
 */
static int suunto_dive_match(struct dive *dive, const char *name, int len, char *buf)
{
	return	MATCH(".o2pct", percent, &dive->cylinder[0].gasmix.o2) ||
		MATCH(".hepct_0", percent, &dive->cylinder[0].gasmix.he) ||
		MATCH(".o2pct_2", percent, &dive->cylinder[1].gasmix.o2) ||
		MATCH(".hepct_1", percent, &dive->cylinder[1].gasmix.he) ||
		MATCH(".o2pct_3", percent, &dive->cylinder[2].gasmix.o2) ||
		MATCH(".hepct_2", percent, &dive->cylinder[2].gasmix.he) ||
		MATCH(".o2pct_4", percent, &dive->cylinder[3].gasmix.o2) ||
		MATCH(".hepct_3", percent, &dive->cylinder[3].gasmix.he) ||
		MATCH(".cylindersize", cylindersize, &dive->cylinder[0].type.size) ||
		MATCH(".cylinderworkpressure", pressure, &dive->cylinder[0].type.workingpressure) ||
		0;
}
예제 #17
0
bool IRdecodeNEC::decode(void) {
  IRLIB_ATTEMPT_MESSAGE(F("NEC"));
  // Check for repeat
  if (rawlen == 4 && MATCH(rawbuf[2], NEC_RPT_SPACE) &&
    MATCH(rawbuf[3],564)) {
    bits = 0;
    value = REPEAT;
    decode_type = NEC;
    return true;
  }
  if(!decodeGeneric(68, 564*16, 564*8, 0, 564, 564*3, 564)) return false;
  decode_type = NEC;
  return true;
}
예제 #18
0
int main(void) {

  extern int program_buffer;
  memset(&program_buffer, 0x00, 0x001d00);

  init();

  puts("kzload (kozos boot loader) started.\n");

  while(1){

    static long program_size = -1;

    #define CommandSize 16
    static char command_buff[CommandSize];
    memset(command_buff, 0x00, CommandSize);

    puts("kzload> ");
    gets(command_buff);

    #define MATCH(command) (strcmp(command_buff,command) == 0)

    if(MATCH("load")){ // XMODEMでファイルをダウンロード
      memset(&program_buffer, 0x00, 0x001d00);
      program_size = receive_program((unsigned char*)&program_buffer);
    }
    else if(MATCH("dump")){
      puts("size: "); putxval(program_size, 12);
      puts("\n");
      dump_h((unsigned char*)&program_buffer, program_size);
    }
    else if(MATCH("run")) {
      const char *ep = elf_load((unsigned char*)&program_buffer);
      const void (*entry_point)(void) = (void(*)(void))ep;

      if( entry_point == NULL ){
        puts("no entry_point.\n");
      } else {
        puts("start at 0x"); putxval(entry_point, 6); puts("\n");
        entry_point();
      }
    }
    else {
      puts("unknown command.\n");
    }

  } // end of while(1)

  return 0;
}
예제 #19
0
파일: settings.c 프로젝트: baloo79/uTox
static CONFIG_SECTION get_section(const char* section) {
    if (MATCH(config_sections[GENERAL_SECTION], section)) {
        return GENERAL_SECTION;
    } else if (MATCH(config_sections[INTERFACE_SECTION], section)) {
        return INTERFACE_SECTION;
    } else if (MATCH(config_sections[AV_SECTION], section)) {
        return AV_SECTION;
    } else if (MATCH(config_sections[NOTIFICATIONS_SECTION], section)) {
        return NOTIFICATIONS_SECTION;
    } else if (MATCH(config_sections[ADVANCED_SECTION], section)) {
        return ADVANCED_SECTION;
    } else {
        return UNKNOWN_SECTION;
    }
}
예제 #20
0
파일: UtlRegex.cpp 프로젝트: mranga/sipxecs
   void testInput1()
      {
         RegEx* TheRegEx = 0;

         EXPRESSION( "the quick brown fox", 0 );
         SHOULD_MATCH( 1, "the quick brown fox" );
         MATCH( 0, "the quick brown fox" );
         SHOULD_NOT_MATCH("The quick brown FOX");
         SHOULD_MATCH( 1, "What do you know about the quick brown fox?" );
         MATCH( 0, "the quick brown fox" );
         SHOULD_NOT_MATCH("What do you know about THE QUICK BROWN FOX?");

         delete TheRegEx;

      }
예제 #21
0
파일: UtlRegex.cpp 프로젝트: mranga/sipxecs
   void testCopy2()
      {
         static const RegEx ConstRegEx("^[a-z]+([0-9]+)$");
         RegEx TheCopiedRegEx(ConstRegEx);
         RegEx* TheRegEx = &TheCopiedRegEx;
         
         SHOULD_MATCH(2,"foo35");
         MATCH(0,"foo35");
         MATCH(1,"35");

         SHOULD_NOT_MATCH( "abc" );
         SHOULD_NOT_MATCH( "Foo35" );
         SHOULD_NOT_MATCH( "12Foo35" );
         SHOULD_NOT_MATCH( "foo35 " );
      }
예제 #22
0
/* does the event match the tag, followed by a null, space, or slash? */
#define MATCH(event, tag) \
  (!strncmp(event, tag, sizeof(tag)-1) && \
   (!event[sizeof(tag)-1] || strchr(" /", event[sizeof(tag)-1])))


static const char event_cookie[] = "event_cookie"; /* demo placeholder */
static void* simple_handle_event(void* cookie, const char* event, void* arg) {
  if (MATCH(event, "/insn")) {
    // follow each complete insn by a nice newline
    printf("\n");
  }
  return NULL;
}
예제 #23
0
파일: cmd_part.c 프로젝트: Colliotv/42.sh
static BOOL	parents(t_get *word, t_get **words,
			t_cmd *link, char **bad_sintax)
{
  BOOL		no_word;
  t_get	*organize;

  if (lvl_parents(words, bad_sintax) == FALSE)
    return (FALSE);
  if ((organize = word->next))
    word->next->prev = NULL;
  rm_words(word);
  if ((word = (*words)->prev) == NULL)
    return (check_sintax(bad_sintax, 1, ERROR_NEAR_PARENTS));
  if (MATCH(word->word, "("))
    return (check_sintax(bad_sintax, 1, ERROR_NEAR_PARENTS));
  word->next = NULL;
  word = (*words)->next;
  rm_words(*words);
  if ((link->parents = orga(organize, bad_sintax, &no_word, TRUE)) == NULL)
    return (check_sintax(bad_sintax, no_word, ERROR_NEAR_PARENTS));
  while (word)
    if (!add_redir(word, &word, bad_sintax, link))
      return (FALSE);
  return (TRUE);
}
예제 #24
0
파일: UtlRegex.cpp 프로젝트: mranga/sipxecs
   void testCopy1()
      {
         static const RegEx ConstRegEx("^[a-z]+([0-9]+)$");
         RegEx* TheRegEx = new RegEx(ConstRegEx);

         SHOULD_MATCH(2,"foo35");
         MATCH(0,"foo35");
         MATCH(1,"35");

         SHOULD_NOT_MATCH( "abc" );
         SHOULD_NOT_MATCH( "Foo35" );
         SHOULD_NOT_MATCH( "12Foo35" );
         SHOULD_NOT_MATCH( "foo35 " );

         delete TheRegEx;
      }
예제 #25
0
파일: csparser.c 프로젝트: Zhang626/cs
csA_simplelist p_simplelist_(void)
{
	csA_simplelist foo = NULL;
	csA_simpleexpr bar = NULL;
	csG_pos pos;
loop:
	switch (token.kind) {
	case csL_NOT:case csL_MINUS:case csL_LPAREN:
	case csL_LBRACK:case csL_NUM:case csL_CHAR:
	case csL_TRUE:case csL_FALSE:case csL_STRING:
	case csL_ID:
		if (!foo) foo = csA_mksimplelist();
		pos = token.pos;
		bar = p_simpleexpr_();
		if(bar) csA_simplelistadd(foo,bar);
		else VERIFY(0);
		bar->pos = pos;
		switch (token.kind) {
		case csL_OR:
			MATCH(csL_OR,"missing |",sync);
			break;
		default:
			return foo;
		}
		goto loop;
	default:
		goto sync;	
	}
sync:
	VERIFY(0);
}
예제 #26
0
파일: csparser.c 프로젝트: Zhang626/cs
static csA_sumexprlist p_sumexprlist_(void)
{
	csA_sumexprlist foo = NULL;
	csA_sumexpr bar = NULL;
loop:
	switch (token.kind) {
	case csL_MINUS:case csL_LPAREN:case csL_LBRACK:
	case csL_NUM:case csL_CHAR:case csL_STRING:
	case csL_TRUE:case csL_FALSE:case csL_ID:
		if (!foo) foo = csA_mksumexprlist();
		bar = p_sumexpr_();
		VERIFY(bar);
		csA_sumexprlistadd(foo,bar);
		switch (token.kind) {
		case csL_PLUS:	
			csA_setsumexprop(bar,csA_plus);
			break;
		case csL_MINUS:
			csA_setsumexprop(bar,csA_minus);
			break;
		default:
			return foo;
		}
		MATCH(token.kind,"missing sumop",sync);
		goto loop;
	default:
		goto sync;
	}
sync:
	VERIFY(0);
}
예제 #27
0
파일: csparser.c 프로젝트: Zhang626/cs
static csA_exprlist p_exprlist_(void)
{
	csA_exprlist foo = NULL;
	csA_expr bar = NULL;
loop:
	switch(token.kind) {
	case csL_NOT:case csL_MINUS:case csL_LPAREN:
	case csL_LBRACK:case csL_NUM:case csL_CHAR:
	case csL_TRUE:case csL_FALSE:case csL_STRING:
	case csL_ID:case csL_DOLLAR:
		if (!foo) foo = csA_mkexprlist();
		bar = p_expr_();
		if (bar) csA_exprlistadd(foo,bar);
		if (token.kind == csL_COMMA) {
			MATCH(csL_COMMA,"missing ,",sync);
			goto loop;
		}
		break;
	case csL_SEMICOLON://FOLLOW
	case csL_RPAREN:
	case csL_RBRACK:
		break;
	default:
		VERIFY(0);
	}
	return foo;
sync:
	VERIFY(0);
}
예제 #28
0
파일: csparser.c 프로젝트: Zhang626/cs
static csA_paramlist p_paramlist_(void)
{
	csA_paramlist foo = NULL;
	csA_param bar = NULL;
loop:
	switch (token.kind) {
	case csL_ID:
		bar = p_param_();
		if (bar) {
			if (!foo) foo = csA_mkparamlist();
			csA_paramlistadd(foo,bar);
			if (token.kind == csL_COMMA) {
				MATCH(csL_COMMA,"missing ,",sync);
				if (token.kind != csL_ID)
					goto sync;
				goto loop;
			}
		} else {
			VERIFY(0);
		}
		break;
	case csL_RPAREN:
		break;
	default:
		VERIFY(0);
	}
	return foo;
sync:
	VERIFY(0);
}
예제 #29
0
파일: xt_policy.c 프로젝트: Arakmar/G3MOD
static bool
match_xfrm_state(const struct xfrm_state *x, const struct xt_policy_elem *e,
		 unsigned short family)
{
#define MATCH_ADDR(x,y,z)	(!e->match.x ||			       \
				 (xt_addr_cmp(&e->x, &e->y, (const union nf_inet_addr *)(z), family) \
				  ^ e->invert.x))
#define MATCH(x,y)		(!e->match.x || ((e->x == (y)) ^ e->invert.x))

	return MATCH_ADDR(saddr, smask, &x->props.saddr) &&
	       MATCH_ADDR(daddr, dmask, &x->id.daddr) &&
	       MATCH(proto, x->id.proto) &&
	       MATCH(mode, x->props.mode) &&
	       MATCH(spi, x->id.spi) &&
	       MATCH(reqid, x->props.reqid);
}
예제 #30
0
// jvalue is known to be union of jobject and friends. And yet from C's
// perspective, it's aggregate object which may require passing via stack
// instead of registers. Work that around by passing jobject and typecasting
// it.
STATIC mp_obj_t jvalue2py(const char *jtypesig, jobject arg) {
    if (arg == NULL || MATCH(jtypesig, "void")) {
        return mp_const_none;
    } else if (MATCH(jtypesig, "boolean")) {
        return mp_obj_new_bool((bool)arg);
    } else if (MATCH(jtypesig, "int")) {
        return mp_obj_new_int((mp_int_t)arg);
    } else if (is_object_type(jtypesig)) {
        // Non-primitive, object type
        return new_jobject(arg);
    }

    printf("Unknown return type: %s\n", jtypesig);

    return MP_OBJ_NULL;
}