Beispiel #1
0
bool Memo_t::scan ( FILE* f ) {
  str_to_dat(read_tok(f), Memo__io_wen);
  str_to_dat(read_tok(f), Memo__io_wrAddr);
  str_to_dat(read_tok(f), Memo__io_wrData);
  str_to_dat(read_tok(f), Memo__io_ren);
  str_to_dat(read_tok(f), Memo__io_rdAddr);
  return(!feof(f));
}
static int read_level(VCOS_LOG_LEVEL_T *level, const char **pstr, char sep)
{
   char buf[16];
   int ret = 1;
   if (read_tok(buf,sizeof(buf),pstr,sep))
   {
      if (strcmp(buf,"error") == 0)
         *level = VCOS_LOG_ERROR;
      else if (strcmp(buf,"warn") == 0)
         *level = VCOS_LOG_WARN;
      else if (strcmp(buf,"warning") == 0)
         *level = VCOS_LOG_WARN;
      else if (strcmp(buf,"info") == 0)
         *level = VCOS_LOG_INFO;
      else if (strcmp(buf,"trace") == 0)
         *level = VCOS_LOG_TRACE;
      else
      {
         vcos_log("Invalid trace level '%s'\n", buf);
         ret = 0;
      }
   }
   else
   {
      ret = 0;
   }
   return ret;
}
Beispiel #3
0
static int read_level(VCOS_LOG_LEVEL_T *level, const char **pstr, char sep)
{
   char buf[16];
   int ret = 1;
   if (read_tok(buf,sizeof(buf),pstr,sep))
   {
      if (vcos_string_to_log_level(buf,level) != VCOS_SUCCESS)
      {
         vcos_log("Invalid trace level '%s'\n", buf);
         ret = 0;
      }
   }
   else
   {
      ret = 0;
   }
   return ret;
}
void vcos_log_register(const char *name, VCOS_LOG_CAT_T *category)
{
   const char *env;
   VCOS_LOG_CAT_T *i;
   memset(category, 0, sizeof(*category));

   category->name  = name;
   category->level = VCOS_LOG_ERROR;
   category->flags.want_prefix = 1;

   vcos_mutex_lock(&lock);

   /* is it already registered? */
   for (i = vcos_logging_categories; i ; i = i->next )
   {
      if (i == category)
         break;
   }

   if (!i)
   {
      /* not yet registered */
      category->next = vcos_logging_categories;
      vcos_logging_categories = category;
   }

   vcos_mutex_unlock(&lock);

   /* Check to see if this log level has been enabled. Look for
    * (<category:level>,)*
    *
    * VC_LOGLEVEL=ilcs:info,vchiq:warn
    */

   env = _VCOS_LOG_LEVEL();
   if (env)
   {
      do
      {
         char env_name[64];
         VCOS_LOG_LEVEL_T level;
         if (read_tok(env_name, sizeof(env_name), &env, ':') &&
             read_level(&level, &env, ','))
         {
            if (strcmp(env_name, name) == 0)
            {
               category->level = level;
               break;
            }
         }
         else
         {
            if (!warned_loglevel)
            {
                vcos_log("VC_LOGLEVEL format invalid at %s\n", env);
                warned_loglevel = 1;
            }
            return;
         }
      } while (env[0] != '\0');
   }
}
Beispiel #5
0
// suck all the global function, struct, union, enum, and typedef prototypes out of the token stream
// -- which means creating a new "defs" token stream, and splitting out a defs_idx from the idx_tbl
uint32_t proto_pass(struct proto_info *inf, uint8_t *new_eb)
{
	int32_t i;
	uint32_t j, k, m;
	uint8_t bol_flag, *p, *c, *sp;
	int8_t level, def_flg;

	bol_flag = 1;
	def_flg = level = 0;
	i = k = m = 0;
	p = sp = wrksp_top;
	if (new_eb != NULL)
		p = sp = new_eb;
	while (1)
	{
// At top level, the only thing I should ever encounter at bol are typespecs/declspecs and typedefs?
// HIHI!! I must also copydown the EMIT buffer! Use the c pointer for that! But there is a problem for the defs = -1 case that gets cancelled ...
		if (level == 0 && def_flg == 0)
		{
			inf->idx_strt = k;		// save the *next* idx index
			sp = p;					// save a ptr to the beginning of any prototype
		}
		switch (*p)
		{
	// HIHI!! how to detect the beginning of a function definition?? It's the only thing that's not a typespec or declspec or variable name?
		case TOK_STRUCT:
		case TOK_UNION:
		case TOK_ENUM:
			if (level == 0) def_flg = -1;
			break;

		case TOK_NAME_IDX:
			j = idx_tbl[k++];
			if (++m != k) idx_tbl[m - 1] = j;			// rebuild a compressed idx_tbl
			c = name_strings + j;
//			if (level == 0 && def_flg == 0)				// HIHI debugging!
//				bol_flag = 0;
			break;

		case TOK_INT_CONST:
		case TOK_FP_CONST:
		case TOK_NONAME_IDX:
			j = idx_tbl[k++];							// must keep k aligned with the token stream
			if (++m != k) idx_tbl[m - 1] = j;			// rebuild a compressed idx_tbl
			break;

		case TOK_TYPEDEF:
			if (bol_flag != 0)
			{
				if (level == 0) def_flg = 2;
		// HIHI can you do typedefs with only local scope?
			}
			// else show_error (0, "typedef syntax error", NULL, 1, inf);		// must recalculate the line number and fname first!
			break;

		case TOK_SEMIC:
			if (level == 0 && def_flg != 0) def_flg = 32;
			bol_flag = 1;
			break;

		case TOK_OCURLY:
			if (def_flg < 0) def_flg = 1;
			bol_flag = 1;
			++level;
			break;

		case TOK_CCURLY:
			if (--level == 0)
			{
				if (def_flg == 1) def_flg = 16;
			}
			bol_flag = 1;
			break;

		case TOK_ENDOFBUF:
			if (inf->infd < 0) return m;
		// HIHI!! if (def_flg != 0) then I must do a partial copy to the wrkbuf! (and reset sp = p;)
			read_tok (&p);
			break;

		default:
			if (def_flg < 0) def_flg = 0;
			bol_flag = 0;

		}		// end of switch on *p

		++p;
		if (def_flg > 2)			// found a definition?
		{
			m -= k - inf->idx_strt;
			j = p - sp;
			inf->wrkbuf = sp;		// HIHI getting rid of the wrkbuf ptr?
			if (def_flg == 32) parse_typedef(j, inf);
//			else if (def_flg == 16) parse_struct(j, inf->cur_ptr, inf->idx_strt, inf);
	// HIHI!!! then send it into a parsing routine, to break the whole thing into pieces and store it in defs
	// -- but I think I want separate parsing routines for typedefs, functions, and structs
//					parse_proto(&p, inf, 0);
			def_flg = 0;
		}

//		if ((uint32_t) (emit_ptr - wrksp) > wrk_rem - 30 * 1024) handle_emit_overflow();
		// HIHI!! do the dealie that guarantees 16K or whatever in the buffer -- at least *nxt_pass_info amount

	}		// infinite loop
}
Beispiel #6
0
void vcos_log_register(const char *name, VCOS_LOG_CAT_T *category)
{
   const char *env;
   VCOS_LOG_CAT_T *i;

   category->name  = name;
   if ( category->level == VCOS_LOG_UNINITIALIZED )
   {
      category->level = VCOS_LOG_ERROR;
   }
   category->flags.want_prefix = (category != &dflt_log_category );

   vcos_mutex_lock(&lock);

   /* is it already registered? */
   for (i = vcos_logging_categories; i ; i = i->next )
   {
      if (i == category)
      {
         i->refcount++;
         break;
      }
   }

   if (!i)
   {
      /* not yet registered */
      category->next = vcos_logging_categories;
      vcos_logging_categories = category;
      category->refcount++;

      vcos_log_platform_register(category);
   }

   vcos_mutex_unlock(&lock);

   /* Check to see if this log level has been enabled. Look for
    * (<category:level>,)*
    *
    * VC_LOGLEVEL=ilcs:info,vchiq:warn
    */

   env = _VCOS_LOG_LEVEL();
   if (env)
   {
      do
      {
         char env_name[64];
         VCOS_LOG_LEVEL_T level;
         if (read_tok(env_name, sizeof(env_name), &env, ':') &&
             read_level(&level, &env, ','))
         {
            if (strcmp(env_name, name) == 0)
            {
               category->level = level;
               break;
            }
         }
         else
         {
            if (!warned_loglevel)
            {
                vcos_log("VC_LOGLEVEL format invalid at %s\n", env);
                warned_loglevel = 1;
            }
            return;
         }
      } while (env[0] != '\0');
   }

   vcos_log_info( "Registered log category '%s' with level %s",
                  category->name,
                  vcos_log_level_to_string( category->level ));
}