Esempio n. 1
0
void
regmac_base_ssid(struct SQDB *sqdb, const unsigned char *bssid, struct SQDB_String *ssid)
{
	struct SQDB_AccessPoint *entry;

    /* Ignore empty SSIDs */
    if (ssid->length == 0)
        return;
    if (ssid->length == 1 && ssid->value[0] == '\0')
        return;

	pixie_enter_critical_section(sqdb->cs);

	entry = sqdb_create_bssid(sqdb, bssid);

	if (!sqdb_string_is_equal(&entry->ssid, ssid)) {
		if (entry->ssid.length > 0) {
			SQUIRREL_EVENT("[%02X:%02X:%02X:%02X:%02X:%02X]  SSID=\"%.*s\" (was \"%.*s\")\n", 
				PRINTMAC(bssid),
				PRINTSTR(ssid),
				PRINTSTR(&entry->ssid));
		}
		sqdb_string_copy(&entry->ssid, ssid);
		/*FIXME: we should support seeing multiple SSIDs on a BSSID */
	}
	pixie_leave_critical_section(sqdb->cs);
}
Esempio n. 2
0
void tryStdVectorResize()
{
	PRINTSTR("try std::vector::resize() whether it allocate memory");
	std::vector<int> vInt;
	vInt.resize(3);
	PRINT(vInt);
	vInt[2]=10;
	PRINT(vInt);

	PRINTSTR("try std::vector< <> >::resize() whether it allocate memory");
	std::vector< std::vector< int > > vvIdx;
	vvIdx.resize(3);
	vvIdx[2].push_back(1);
	PRINT(vvIdx);
}
Esempio n. 3
0
void tryStdList(){
	PRINTSTR("try std::list");
	typedef unsigned int uint;
	std::list<uint> lTmp;
	for (unsigned int i=0; i<10; i++){
		lTmp.push_back(i);
	}
	PRINT(lTmp);
	std::list<uint>::iterator itErase;
	bool bErase = false;
	for (std::list<uint>::iterator itNum = lTmp.begin(); itNum != lTmp.end(); itNum++ ){
		if( bErase ){
			lTmp.erase(itErase);
			bErase = false;
		}//remove after itNum increased
		if ((*itNum%2)==1)	{
			itErase= itNum;
			bErase = true;
		}//store 
	}
	if( bErase ){
		lTmp.erase(itErase);
		bErase = false;
	}//remove after itNum increased
	PRINT(lTmp);
}
Esempio n. 4
0
void tryStdVectorEnum()
{
	PRINTSTR("try std::vector< enum >");
	std::vector<tp_flag > vMergeFlags(2,NO_MERGE);
	vMergeFlags[1] = MERGE_WITH_BOTH;
	PRINT(vMergeFlags);
}
Esempio n. 5
0
void tryCppSizeof()
{
	PRINTSTR("try sizeof() operator");
	PRINT(sizeof(long double));
	PRINT(sizeof(double));
	PRINT(sizeof(short));
}
Esempio n. 6
0
int make_colname_list( char *buf)
{
  int col;

  strcpy( buf, "(");
  for( col = 0; col < MAX_TBL_COLS; ++col)
    {
      switch(col)
	{
	case 0:  strcat( buf, "id");         break;
	case 1:  strcat( buf, "quantity");   break;
	case 2:  strcat( buf, "category");   break;
	case 3:  strcat( buf, "langcode");   break;
	case 4:  strcat( buf, "shortdesc");  break;
	case 5:  strcat( buf, "wdesc");	     break;
	case 6:  strcat( buf, "opcode");     break;
	case 7:  strcat( buf, "inceptdate"); break;
	case 8:  strcat( buf, "termdate");   break;
	case 9:  strcat( buf, "weight");     break;
	case 10: strcat( buf, "volume");     break;
	case 11: strcat( buf, "bitflags");   break;
	case 12: strcat( buf, "license");    break;
	default: abort();
	}
      if( col + 1 < MAX_TBL_COLS)
	strcat( buf, ",");
    }
  strcat( buf, ")");
  PRINTSTR(buf);
  return 0;
}
Esempio n. 7
0
/*
 * The following routine was originally written to pin down a bug.  It is
 * no longer needed for that problem, but may be useful to keep around for
 * other debugging.
 */
void
ctl_dumpcji(FILE *dbg_stream, const char *heading, struct cjobinfo *cjinf)
{
#define PRINTSTR(xHdr,xStr) \
	astr = xStr; \
	ctl_dbgline++; \
	fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, xHdr); \
	if (astr == NULL) \
		fprintf(dbg_stream, "NULL\n"); \
	else \
		fprintf(dbg_stream, "%p -> %s\n", astr, astr)

    struct cjprivate *cpriv;
    char *astr;

    if (cjinf == NULL) {
        fprintf(dbg_stream,
                "ctl_dumpcji: ptr to cjobinfo for '%s' is NULL\n",
                heading);
        return;
    }
    cpriv = cjinf->cji_priv;

    fprintf(dbg_stream, "ctl_dumpcji: Dump '%s' of cjobinfo at %p->%p\n",
            heading, (void *)cjinf, cpriv->cji_buff);

    PRINTSTR("accthost.H", cpriv->pub.cji_accthost);
    PRINTSTR("acctuser.P", cpriv->pub.cji_acctuser);
    PRINTSTR("class.C", cpriv->pub.cji_class);
    PRINTSTR("cf-qname", cpriv->pub.cji_curqueue);
    PRINTSTR("cf-fname", cpriv->pub.cji_fname);
    PRINTSTR("jobname.J", cpriv->pub.cji_jobname);
    PRINTSTR("mailto.M", cpriv->pub.cji_mailto);
    PRINTSTR("headruser.L", cpriv->pub.cji_headruser);

    ctl_dbgline++;
    fprintf(dbg_stream, "%4d] %12s = ", ctl_dbgline, "*cjprivate");
    if (cpriv->pub.cji_priv == NULL)
        fprintf(dbg_stream, "NULL !!\n");
    else
        fprintf(dbg_stream, "%p\n", (void *)cpriv->pub.cji_priv);

    fprintf(dbg_stream, "|- - - - --> Dump '%s' complete\n", heading);

    /* flush output for the benefit of anyone doing a 'tail -f' */
    fflush(dbg_stream);

#undef PRINTSTR
}
Esempio n. 8
0
int main ( int argc, char** argv ) {
    try {
        glutInit ( &argc, argv );
        glutInitDisplayMode ( GLUT_DOUBLE | GLUT_RGB );
        glutInitWindowSize (1000,750 );//1280, 480 ); //480
        glutCreateWindow ( "CameraPose" );
		GLenum eError = glewInit();
		if (GLEW_OK != eError){
			PRINTSTR("glewInit() error.");
			PRINT( glewGetErrorString(eError) );
		}
        glutKeyboardFunc ( normalKeys );
		glutSpecialFunc ( specialKeys );
        glutMouseFunc   ( mouseClick );
        glutMotionFunc  ( mouseMotion );
        glutReshapeFunc ( reshape );
        glutDisplayFunc ( display );

		btl::gl_util::CGLUtil::initCuda();
		btl::gl_util::CGLUtil::setCudaDeviceForGLInteroperation();

		init();
		
		glutMainLoop();
		_pGL->destroyVBOsPBOs();
	}
	catch ( btl::utility::CError& e )	{
		if ( std::string const* mi = boost::get_error_info< btl::utility::CErrorInfo > ( e ) )	{
			std::cerr << "Error Info: " << *mi << std::endl;
		}
	}
	catch ( std::runtime_error& e )	{
		PRINTSTR( e.what() );
	}

    return 0;
}
Esempio n. 9
0
void tryStdLimits(){
	PRINTSTR("try std::limits");
	float fQNaN = std::numeric_limits<float>::quiet_NaN();
	PRINT(fQNaN);
	float fSNaN = std::numeric_limits<float>::signaling_NaN();
	PRINT(fSNaN);
	float fInf  = std::numeric_limits<float>::infinity();
	PRINT(fInf);
	PRINT(fSNaN<10.f);
	PRINT(fSNaN>10.f);
	PRINT(fInf>10.f);
	PRINT(fInf<10.f);
	PRINT(-fInf<10.f);
	PRINT(fQNaN - 1);
}
Esempio n. 10
0
int main(void)
{
    PRINTSTR("\n" POS_STARTUPSTRING "\n\n");

    /* start multitasking and execute first task (task1) */
#if (POSCFG_TASKSTACKTYPE == 0)
    posInit(task1, NULL, 1, allocstack(0x0600), allocstack(0x0200));
#elif (POSCFG_TASKSTACKTYPE == 1)
    posInit(task1, NULL, 1, 0x0600, 0x0200);
#elif (POSCFG_TASKSTACKTYPE == 2)
    posInit(task1, NULL, 1);
#endif

    /* we will never get here */
    return 0;
}
Esempio n. 11
0
void tryCppTypeDef()
{
	PRINTSTR("try cpp keyword typedef");
	{
		typedef int tp_int;
		tp_int n;
		n = 1;
		PRINT( n );
		{
			tp_int m;
			m = 2;
			PRINT( m );
		}
	}
	//tp_int o; compile error
}
Esempio n. 12
0
static void task_printer(void *arg)
{
    char *buf;

    (void) arg;

    for (;;)
    {
        /* get message */
        buf = posMessageGet();

        /* print content to screen */
        PRINTSTR(buf);

        /* free message buffer */
        posMessageFree(buf);
    }
}
Esempio n. 13
0
int populate_table( Arb_connection *conn)
{
  Widget widget;
  char colname_list[300];
  char control_string[200];
  char sql[500];
  int  i;
  int  rc;

  memset( &widget, 0, sizeof( widget));
  make_Widget_column_list_string( colname_list);
  make_Widget_control_string( control_string);
  
  sprintf( sql, "insert into " TABLENAME " ( %s ) VALUES ( %s )",
	   colname_list, control_string);
  PRINTSTR( sql);

  for( i = 0; i < NUM_INSERTS; ++i)
    {
      makedata_Widget( i, &widget);
      rc = arb_dbfcmd( conn, sql,
		        widget.id,
		        widget.quantity,
		        widget.category,
		        widget.langcode,
		        widget.shortdesc,
		        widget.wdesc,
		        widget.opcode,
		       &widget.inceptdate,
		       &widget.termdate,
		       &widget.weight,
		       &widget.volume,
		        widget.bitflags,
		        widget.license);
      if( rc != SUCCESS)
	abort();
      
      rc = arb_exec_string( conn, "", SQL_EXECUTE_NOW);
      if( rc != SUCCESS)
	abort();

    } /* for i */
} /* populate_table */
	int CGLUtil::getLevel(int nCols_ ){
		switch ( nCols_ )
		{
		case 1280:
			return 0;
		case 640:
			return 0;
		case 320:
			return 1;
		case 160:
			return 2;
		case 80:
			return 3;
		case 40:
			return 4;
		case 20:
			return 5;
		default:
			PRINTSTR("Failure - input resolution is not 640x480 or 320x240 or 160x120 or 80x60 or 40x30. ");
			return -1;
		}
		return -1;
	}
Esempio n. 15
0
int create_procedure( Arb_connection *conn)
{
  char selectlist[256];
  char procsql[1024];
  int rc;

  make_Widget_select_list_string( selectlist);
  sprintf( procsql,
	   "CREATE OR REPLACE PROCEDURE select_widget_proc "
	   "( select_widget_proc_cv IN OUT cv_types.customer_tp)"
	   "IS "
	   "BEGIN "
	   "OPEN select_widget_proc_cv FOR "
	   "SELECT %s "
	   "FROM   %s ; "
	   "END;",
	   selectlist, TABLENAME);
  PRINTSTR( procsql);

  rc = arb_exec_string( conn, procsql, SQL_EXECUTE_NOW);
  if( rc != SUCCESS)
    abort();
  return 0;
}
Esempio n. 16
0
int populate_table( Arb_connection *conn, Input_param_list *inlist, Widget *warr)
{
  char colname_list[300];
  char control_string[200];
  char sql[500];
  int  i;
  int  rc;

  memset( colname_list, 0, sizeof(colname_list));
  memset( control_string, 0, sizeof(control_string));

  make_colname_list( colname_list);
#if 0
  arb_reset_placeholder();
#endif
  sprintf( sql, "insert into " TABLENAME " %s VALUES ",
	   colname_list);

  rc = arb_dbfcmd( conn, sql);
  if( rc != SUCCESS)
    abort();

  make_placeholders( conn, control_string, sql);
  PRINTSTR( sql);

  rc = arb_exec_string_array( conn, "", inlist, sizeof(warr[0]), WIDGET_ARRSZ);
  if( rc != SUCCESS)
    abort();
      
#if 0
  rc = arb_exec_string( conn, "", SQL_EXECUTE_NOW);
  if( rc != SUCCESS)
    abort();
#endif
  return 0;
} /* populate_table */
	void CGLUtil::errorDetectorGL() const
	{
		GLenum eError = glGetError();
		if (eError != GL_NO_ERROR)
		{
			switch(eError){
			case GL_INVALID_ENUM:
				PRINTSTR("GL_INVALID_ENUM");break;
			case GL_INVALID_VALUE:
				PRINTSTR("GL_INVALID_VALUE");break;
			case GL_INVALID_OPERATION:
				PRINTSTR("GL_INVALID_OPERATION");break;
			case GL_STACK_OVERFLOW:
				PRINTSTR("GL_STACK_OVERFLOW");break;
			case GL_STACK_UNDERFLOW:
				PRINTSTR("GL_STACK_UNDERFLOW");break;
			case GL_OUT_OF_MEMORY:
				PRINTSTR("GL_OUT_OF_MEMORY");break;
			}
		}
	}
itpType *interpret(nodeType *p)
{
	int nodeSize;
	int len, n;
	itpType *pret, *pret1, *pret2, *pret3, *pret4;

	DBG("come in function\n");
	if (p == NULL)
		return NULL;

	DBG_NODE(p);
	pret = malloc(sizeof(itpType));
	if (pret == NULL) {
		yyerror("interpret, malloc pret failed\n");
		return NULL;
	}

	pret->type = typeLong;
	pret->ival = 1;		/* default to return true */

	switch(p->type) {
	case typeLongCon:
		pret->ival = p->longCon.var;
		pret->type = typeLong;
		DBG_INTERPRET(pret);
		return pret;
		break;
	case typeStrCon:
		len = strlen(p->strCon.ptr);
		pret->pstr = malloc(len + 1);
		if (pret->pstr == NULL) {
			yyerror("interpret, typeStrCon malloc failed\n");
			free_itpType(pret);
			return NULL;
		}
		strncpy(pret->pstr, p->strCon.ptr, len);
		pret->pstr[len] = '\0';
		pret->type = typeStr;
		DBG_INTERPRET(pret);
		return pret;
		break;
	case typeVar:
		nodeSize = sizeof(symType);
		memcpy(pret, &symtab[p->var.index], nodeSize);
		if (pret->type == typeStr) {
			len = strlen(pret->pstr);
			pret->pstr = malloc(len + 1);
			if (pret->pstr == NULL) {
				yyerror("interpret, typeVar malloc failed\n");
				free_itpType(pret);
				return NULL;
			}
			strncpy(pret->pstr, symtab[p->var.index].pstr, len);
			pret->pstr[len] = '\0';
		}
		DBG_INTERPRET(pret);
		return pret;
		break;
	case typeOpr:
		switch(p->opr.name) {
		case WHILE:
			pret1 = interpret(p->opr.op[0]);
			if (pret1 == NULL) {
				free_itpType(pret);
				return NULL;
			}
			while ((pret1->type == typeLong && pret1->ival) ||
				(pret1->type == typeStr && pret1->pstr)) {
				pret2 = interpret(p->opr.op[1]);
				free_itpType(pret1);
				free_itpType(pret2);
				pret1 = interpret(p->opr.op[0]);
				if (pret1 == NULL) {
					free_itpType(pret);
					return NULL;
				}
			}
			free_itpType(pret1);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case IF:
			pret1 = interpret(p->opr.op[0]);
			if (pret1 == NULL)
				return NULL;
			if ((pret1->type == typeLong && pret1->ival) ||
				(pret1->type == typeStr && pret1->pstr)) {
				pret2 = interpret(p->opr.op[1]);
				free_itpType(pret1);
				free_itpType(pret2);
			} else if (p->opr.number > 2) {
				pret2 = interpret(p->opr.op[2]);
				free_itpType(pret1);
				free_itpType(pret2);
			}
			DBG_INTERPRET(pret);
			return pret;
		case PRINT:
			pret1 = interpret(p->opr.op[0]);
			if (pret1 == NULL)
				return NULL;
			if (pret1->type == typeLong)
				PRINTLONG(pret1);
			else if (pret1->type == typeStr)
				PRINTSTR(pret1);
			free_itpType(pret1);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case ';':
			pret1 = interpret(p->opr.op[0]);
			pret2 = interpret(p->opr.op[1]);
			if (pret1)
				free_itpType(pret1);
			if (pret2)
				free_itpType(pret2);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case '=':
			pret2 = interpret(p->opr.op[1]);
			if (pret2 == NULL)
				return NULL;
			if (pret2->type == typeLong)
				symtab[p->opr.op[0]->var.index].ival = pret2->ival;
			else if (pret2->type == typeStr) {
				if (symtab[p->opr.op[0]->var.index].type == typeStr)
					free(symtab[p->opr.op[0]->var.index].pstr);
				symtab[p->opr.op[0]->var.index].pstr = pret2->pstr;
			}
			symtab[p->opr.op[0]->var.index].type = pret2->type;
			free(pret2); /* do not free pret2->pstr, as it is used by the variable */
			DBG_INTERPRET(pret);
			return pret;
			break;
		case UMINUS:
			pret1 = interpret(p->opr.op[0]);
			if (pret1 == NULL)
				return NULL;
			if (pret1->type == typeLong) {
				pret->type = typeLong;
				pret->ival = -pret1->ival;
			} else {
				free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			free_itpType(pret1);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case PP:
			if (symtab[p->opr.op[0]->var.index].type == typeLong) {
				symtab[p->opr.op[0]->var.index].ival += 1;
				pret->type = typeLong;
				pret->ival = symtab[p->opr.op[0]->var.index].ival;
			} else {
				free_itpType(pret);
				return NULL;
			}
			DBG_INTERPRET(pret);
			return pret;
			break;
		case SS:
			if (symtab[p->opr.op[0]->var.index].type == typeLong) {
				symtab[p->opr.op[0]->var.index].ival -= 1;
				pret->type = typeLong;
				pret->ival = symtab[p->opr.op[0]->var.index].ival;
			} else {
				free_itpType(pret);
				return NULL;
			}
			DBG_INTERPRET(pret);
			return pret;
			break;
		case '+':
			pret1 = interpret(p->opr.op[0]);
			pret2 = interpret(p->opr.op[1]);
			if (pret1 == NULL || pret2 == NULL) {
				if (pret1 == NULL)
					free_itpType(pret2);
				if (pret2 == NULL)
					free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			if (pret1->type == typeLong && pret2->type == typeLong) {
				pret->type = typeLong;
				pret->ival = pret1->ival + pret2->ival;
				free_itpType(pret1);
				free_itpType(pret2);
				DBG_INTERPRET(pret);
				return pret;
			} else if (pret1->type == typeStr && pret2->type == typeStr) {
				int m = strlen(pret1->pstr);
				int n = strlen(pret2->pstr);
				char *s = malloc(m+n+1);
				if (s == NULL) {
					free_itpType(pret1);
					free_itpType(pret2);
					free_itpType(pret);
					return NULL;
				}
				strncpy(s, pret1->pstr, m);
				s[m] = '\0';
				strncat(s, pret2->pstr, n);
				s[m+n] = '\0';
				free_itpType(pret1);
				free_itpType(pret2);
				pret->type = typeStr;
				pret->pstr = s;
				DBG_INTERPRET(pret);
				return pret;
			} else {
				yyerror("add type not match\n");
				free_itpType(pret1);
				free_itpType(pret2);
				free_itpType(pret);
				return NULL;
			}
			break;
		case '-':
		case '*':
		case '/':
		case '<':
		case '>':
		case '%':
		case AND:
		case OR:
		case GE:
		case LE:
			pret1 = interpret(p->opr.op[0]);
			pret2 = interpret(p->opr.op[1]);
			if (pret1 == NULL || pret2 == NULL) {
				if (pret1 == NULL)
					free_itpType(pret2);
				if (pret2 == NULL)
					free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			if (pret1->type == typeLong && pret2->type == typeLong) {
				pret->type = typeLong;
				if (p->opr.name == '-')
					pret->ival = pret1->ival - pret2->ival;
				else if (p->opr.name == '*')
					pret->ival = pret1->ival * pret2->ival;
				else if (p->opr.name == '/')
					pret->ival = pret1->ival / pret2->ival;
				else if (p->opr.name == '<')
					pret->ival = pret1->ival < pret2->ival;
				else if (p->opr.name == '>')
					pret->ival = pret1->ival > pret2->ival;
				else if (p->opr.name == '%')
					pret->ival = pret1->ival % pret2->ival;
				else if (p->opr.name == AND)
					pret->ival = pret1->ival && pret2->ival;
				else if (p->opr.name == OR)
					pret->ival = pret1->ival || pret2->ival;
				else if (p->opr.name == GE)
					pret->ival = pret1->ival >= pret2->ival;
				else if (p->opr.name == LE)
					pret->ival = pret1->ival <= pret2->ival;
				free_itpType(pret1);
				free_itpType(pret2);
				DBG_INTERPRET(pret);
				return pret;
			} else {
				yyerror("type not match\n");
				free_itpType(pret1);
				free_itpType(pret2);
				free_itpType(pret);
				return NULL;
			}
			break;
		case EQ:
		case NE:
			pret1 = interpret(p->opr.op[0]);
			pret2 = interpret(p->opr.op[1]);
			if (pret1 == NULL || pret2 == NULL) {
				if (pret1 == NULL)
					free_itpType(pret2);
				if (pret2 == NULL)
					free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			if (pret1->type == typeLong && pret2->type == typeLong) {
				pret->type = typeLong;
				if (p->opr.name == EQ)
					pret->ival = pret1->ival == pret2->ival;
				else if (pret->type == NE)
					pret->ival = pret1->ival != pret2->ival;
				free_itpType(pret1);
				free_itpType(pret2);
				DBG_INTERPRET(pret);
				return pret;
			} else if (pret1->type == typeStr && pret2->type == typeStr) {
				pret->type == typeLong;
				if (p->opr.name == EQ)
					pret->ival = !strcmp(pret1->pstr, pret2->pstr);
				else if (p->opr.name == NE) {
					pret->ival = !!strcmp(pret1->pstr, pret2->pstr);
				}
				free_itpType(pret1);
				free_itpType(pret2);
				DBG_INTERPRET(pret);
				return pret;
			} else {
				yyerror("add type not match\n");
				free_itpType(pret1);
				free_itpType(pret2);
				free_itpType(pret);
				return NULL;
			}
			break;
		case CALL:
			pret1 = interpret(p->opr.op[0]);
			if (pret1 == NULL) {
				free_itpType(pret);
				return NULL;
			}
			if (pret1->type != typeStr) {
				free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			pret->type = typeStr;
			pret->pstr = call_func(pret1->pstr);
			free_itpType(pret1);
			if (pret->pstr == NULL) {
				free_itpType(pret);
				return NULL;
			}
			DBG_INTERPRET(pret);
			return pret;
			break;
		case GET:
			pret1 = interpret(p->opr.op[0]);
			pret2 = interpret(p->opr.op[1]);
			pret3 = interpret(p->opr.op[2]);
			pret4 = interpret(p->opr.op[3]);
			if (pret1->type == typeStr && pret2->type == typeLong &&
				pret3->type == typeLong && pret4->type == typeLong) {
				pret->type = typeStr;
				pret->pstr = get_func(pret1->pstr, pret2->ival, pret3->ival, pret4->ival);
				if (pret->pstr == NULL) {
					free_itpType(pret);
					pret = NULL;
				}
			}
			free_itpType(pret1);
			free_itpType(pret2);
			free_itpType(pret3);
			free_itpType(pret4);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case LINES:
			pret1 = interpret(p->opr.op[0]);
			pret->type = typeLong;
			if (pret1->type == typeStr)
				pret->ival = lines_func(pret1->pstr);
			else
				pret->ival = 0;
			free_itpType(pret1);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case LEN:
			pret1 = interpret(p->opr.op[0]);
			pret->type = typeLong;
			if (pret1->type == typeStr)
				pret->ival = strlen(pret1->pstr);
			else
				pret->ival = 0;
			free_itpType(pret1);
			DBG_INTERPRET(pret);
			return pret;
			break;
		case STR2LONG:
			pret1 = interpret(p->opr.op[0]);
			pret->type = typeLong;
			if (pret1->type != typeStr) {
				yyerror("str2long need a string as param\n");
				free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			}
			pret->ival = str2long(pret1->pstr);
			free_itpType(pret1);
			return pret;
			break;
		case LONG2DECSTR:
		case LONG2HEXSTR:
			pret1 = interpret(p->opr.op[0]);
			if (pret1->type != typeLong) {
				yyerror("long2decstr need a number as param\n");
				free_itpType(pret1);
				free_itpType(pret);
				return NULL;
			} else {
				char *s;
				int len;
				s = malloc(MAX_CONVERT_STRLEN);
				if (s == NULL) {
					yyerror("malloc for long2decstr failed\n");
					free_itpType(pret1);
					free_itpType(pret);
					return NULL;
				}
				if (p->opr.name == LONG2DECSTR)
					len = snprintf(s, MAX_CONVERT_STRLEN, "%lld", pret1->ival);
				else
					len = snprintf(s, MAX_CONVERT_STRLEN, "0x%llx", pret1->ival);
				s[len] = '\0';
				pret->type = typeStr;
				pret->pstr = s;
				return pret;
			}
			break;
		default:
			yyerror("bad operator!\n");
		}
	default:
		yyerror("bad node type!\n");
	}
	pret->ival = 0;
	return pret;
}
Esempio n. 19
0
long
w_ifstat(Ether* ether, void* a, long n, ulong offset)
{
	Ctlr *ctlr = (Ctlr*) ether->ctlr;
	char *k, *p;
	int i, l, txid;

	ether->oerrs = ctlr->ntxerr;
	ether->crcs = ctlr->nrxfcserr;
	ether->frames = 0;
	ether->buffs = ctlr->nrxdropnobuf;
	ether->overflows = 0;

	//
	// Offset must be zero or there's a possibility the
	// new data won't match the previous read.
	//
	if(n == 0 || offset != 0)
		return 0;

	p = smalloc(READSTR);
	l = 0;

	PRINTSTAT("Signal: %d\n", ctlr->signal-149);
	PRINTSTAT("Noise: %d\n", ctlr->noise-149);
	PRINTSTAT("SNR: %ud\n", ctlr->signal-ctlr->noise);
	PRINTSTAT("Interrupts: %lud\n", ctlr->nints);
	PRINTSTAT("Double Interrupts: %lud\n", ctlr->ndoubleint);
	PRINTSTAT("TxPackets: %lud\n", ctlr->ntx);
	PRINTSTAT("RxPackets: %lud\n", ctlr->nrx);
	PRINTSTAT("TxErrors: %lud\n", ctlr->ntxerr);
	PRINTSTAT("RxErrors: %lud\n", ctlr->nrxerr);
	PRINTSTAT("TxRequests: %lud\n", ctlr->ntxrq);
	PRINTSTAT("AllocEvs: %lud\n", ctlr->nalloc);
	PRINTSTAT("InfoEvs: %lud\n", ctlr->ninfo);
	PRINTSTAT("InfoDrop: %lud\n", ctlr->nidrop);
	PRINTSTAT("WatchDogs: %lud\n", ctlr->nwatchdogs);
	PRINTSTAT("Ticks: %ud\n", ctlr->ticks);
	PRINTSTAT("TickIntr: %ud\n", ctlr->tickintr);
	k = ((ctlr->state & Attached) ? "attached" : "not attached");
	PRINTSTAT("Card %s", k);
	k = ((ctlr->state & Power) ? "on" : "off");
	PRINTSTAT(", power %s", k);
	k = ((ctlr->txbusy)? ", txbusy" : "");
	PRINTSTAT("%s\n", k);

	if(ctlr->hascrypt){
		PRINTSTR("Keys: ");
		for (i = 0; i < WNKeys; i++){
			if(ctlr->keys.keys[i].len == 0)
				PRINTSTR("none ");
			else if(SEEKEYS == 0)
				PRINTSTR("set ");
			else
				PRINTSTAT("%s ", ctlr->keys.keys[i].dat);
		}
		PRINTSTR("\n");
	}

	// real card stats
	ilock(ctlr);
	PRINTSTR("\nCard stats: \n");
	PRINTSTAT("Status: %ux\n", csr_ins(ctlr, WR_Sts));
	PRINTSTAT("Event status: %ux\n", csr_ins(ctlr, WR_EvSts));
	i = ltv_ins(ctlr, WTyp_Ptype);
	PRINTSTAT("Port type: %d\n", i);
	PRINTSTAT("Transmit rate: %d\n", ltv_ins(ctlr, WTyp_TxRate));
	PRINTSTAT("Current Transmit rate: %d\n",
		ltv_ins(ctlr, WTyp_CurTxRate));
	PRINTSTAT("Channel: %d\n", ltv_ins(ctlr, WTyp_Chan));
	PRINTSTAT("AP density: %d\n", ltv_ins(ctlr, WTyp_ApDens));
	PRINTSTAT("Promiscuous mode: %d\n", ltv_ins(ctlr, WTyp_Prom));
	if(i == WPTypeAdHoc)
		PRINTSTAT("SSID name: %s\n", ltv_inname(ctlr, WTyp_NetName));
	else {
		Wltv ltv;
		PRINTSTAT("Current name: %s\n", ltv_inname(ctlr, WTyp_CurName));
		ltv.type = WTyp_BaseID;
		ltv.len = 4;
		if(w_inltv(ctlr, &ltv))
			print("#l%d: unable to read base station mac addr\n", ether->ctlrno);
		l += snprint(p+l, READSTR-l, "Base station: %2.2x%2.2x%2.2x%2.2x%2.2x%2.2x\n",
			ltv.addr[0], ltv.addr[1], ltv.addr[2], ltv.addr[3], ltv.addr[4], ltv.addr[5]);
	}
	PRINTSTAT("Net name: %s\n", ltv_inname(ctlr, WTyp_WantName));
	PRINTSTAT("Node name: %s\n", ltv_inname(ctlr, WTyp_NodeName));
	if(ltv_ins(ctlr, WTyp_HasCrypt) == 0)
		PRINTSTR("WEP: not supported\n");
	else {
		if(ltv_ins(ctlr, WTyp_Crypt) == 0)
			PRINTSTR("WEP: disabled\n");
		else{
			PRINTSTR("WEP: enabled\n");
			k = ((ctlr->xclear)? "excluded": "included");
			PRINTSTAT("Clear packets: %s\n", k);
			txid = ltv_ins(ctlr, WTyp_TxKey);
			PRINTSTAT("Transmit key id: %d\n", txid);
		}
	}
	iunlock(ctlr);

	PRINTSTAT("ntxuframes: %lud\n", ctlr->ntxuframes);
	PRINTSTAT("ntxmframes: %lud\n", ctlr->ntxmframes);
	PRINTSTAT("ntxfrags: %lud\n", ctlr->ntxfrags);
	PRINTSTAT("ntxubytes: %lud\n", ctlr->ntxubytes);
	PRINTSTAT("ntxmbytes: %lud\n", ctlr->ntxmbytes);
	PRINTSTAT("ntxdeferred: %lud\n", ctlr->ntxdeferred);
	PRINTSTAT("ntxsretries: %lud\n", ctlr->ntxsretries);
	PRINTSTAT("ntxmultiretries: %lud\n", ctlr->ntxmultiretries);
	PRINTSTAT("ntxretrylimit: %lud\n", ctlr->ntxretrylimit);
	PRINTSTAT("ntxdiscards: %lud\n", ctlr->ntxdiscards);
	PRINTSTAT("nrxuframes: %lud\n", ctlr->nrxuframes);
	PRINTSTAT("nrxmframes: %lud\n", ctlr->nrxmframes);
	PRINTSTAT("nrxfrags: %lud\n", ctlr->nrxfrags);
	PRINTSTAT("nrxubytes: %lud\n", ctlr->nrxubytes);
	PRINTSTAT("nrxmbytes: %lud\n", ctlr->nrxmbytes);
	PRINTSTAT("nrxfcserr: %lud\n", ctlr->nrxfcserr);
	PRINTSTAT("nrxdropnobuf: %lud\n", ctlr->nrxdropnobuf);
	PRINTSTAT("nrxdropnosa: %lud\n", ctlr->nrxdropnosa);
	PRINTSTAT("nrxcantdecrypt: %lud\n", ctlr->nrxcantdecrypt);
	PRINTSTAT("nrxmsgfrag: %lud\n", ctlr->nrxmsgfrag);
	PRINTSTAT("nrxmsgbadfrag: %lud\n", ctlr->nrxmsgbadfrag);
	USED(l);
	n = readstr(offset, a, n, p);
	free(p);
	return n;
}
Esempio n. 20
0
int make_placeholders( Arb_connection *conn, char *cntrlstring, char *sql)
{ /* make_placeholders
   *
   * Informs the datalayer of the inputs in the sql. Builds the control
   * string: "( %d, %d, %d, %d, '%s', ....)"
   * And puts onto the end of sql value: "insert into ... values"
   */
  int col;

  /* build the cntrlstring, and the conn's internal sql */
  strcpy( cntrlstring, "(");
  arb_dbcmd( conn, "(");
  for( col = 0; col < MAX_TBL_COLS; ++col)
    {
      switch(col)
	{
	case 0:
	  strcat( cntrlstring, "%d");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 1:
	  strcat( cntrlstring, "%d");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 2:
	  strcat( cntrlstring, "%d");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 3:
	  strcat( cntrlstring, "%d");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 4:
	  strcat( cntrlstring, "'%s'");
	  arb_dbfcmd(conn, "%s", arb_get_next_placeholder());
	  break;
	case 5:
	  strcat( cntrlstring, "'%s'");
	  arb_dbfcmd(conn, "%s", arb_get_next_placeholder());
	  break;
	case 6:
	  strcat( cntrlstring, "%x");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 7:
	  strcat( cntrlstring, "%t");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 8:
	  strcat( cntrlstring, "%t");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 9:
	  strcat( cntrlstring, "%n");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 10:
	  strcat( cntrlstring, "%n");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 11:
	  strcat( cntrlstring, "%d");
	  arb_dbfcmd(conn, "%s"  , arb_get_next_placeholder());
	  break;
	case 12:
	  strcat( cntrlstring, "'%s'");
	  arb_dbfcmd(conn, "%s", arb_get_next_placeholder());
	  break;
	default:
	  abort();
	}
      if( col + 1 < MAX_TBL_COLS)
	{
	  arb_dbcmd( conn, ",");
	  strcat( cntrlstring, ",");
	}
    }
  strcat( cntrlstring, ")");
  arb_dbcmd(conn, ")");
  /* build cntrlstring and conn's internal sql */

  strcat( sql, cntrlstring);
  PRINTSTR(cntrlstring);
  PRINTSTR(sql);
  return 0;
}
Esempio n. 21
0
void uip_log(char msg[]){
    PRINTSTR("uIP log message: ");
    PRINTSTRLN(msg);
}
Esempio n. 22
0
int populate_table( Arb_connection *conn)
{
  char colname_list[300];
  char control_string[200];
  char sql[500];
  int  i;
  int  rc;

  /*
   * The individual array data sources for inserting.
   */

  ARB_INT32   id        [WIDGET_ARRSZ];         
  ARB_INT32   quantity  [WIDGET_ARRSZ];   
  ARB_INT8    category  [WIDGET_ARRSZ];   
  ARB_INT16   langcode  [WIDGET_ARRSZ];   
  ARB_STRING  shortdesc [WIDGET_ARRSZ][WIDGET_SHORTDESC_LEN];
  ARB_STRING  wdesc     [WIDGET_ARRSZ][WIDGET_WDESC_LEN]; 
  ARB_HEX     opcode    [WIDGET_ARRSZ][WIDGET_OPCODE_LEN+1];
  Arb_date    inceptdate[WIDGET_ARRSZ]; 
  Arb_date    termdate  [WIDGET_ARRSZ];   
  Arb_numeric weight    [WIDGET_ARRSZ];     
  Arb_numeric volume    [WIDGET_ARRSZ];     
  ARB_BIT     bitflags  [WIDGET_ARRSZ];   
  ARB_STRING  license   [WIDGET_ARRSZ][WIDGET_LICENSE_LEN];
	                
  short       indi      [WIDGET_TABLE_NUM_COLS][WIDGET_ARRSZ];

  Input_param_list *inlist;

  memset( colname_list, 0, sizeof(colname_list));
  memset( control_string, 0, sizeof(control_string));

  memset( id        ,0,sizeof(id        ));
  memset( quantity  ,0,sizeof(quantity  ));
  memset( category  ,0,sizeof(category  ));
  memset( langcode  ,0,sizeof(langcode  ));
  memset( shortdesc ,0,sizeof(shortdesc ));
  memset( wdesc     ,0,sizeof(wdesc     ));
  memset( opcode    ,0,sizeof(opcode    ));
  memset( inceptdate,0,sizeof(inceptdate));
  memset( termdate  ,0,sizeof(termdate  ));
  memset( weight    ,0,sizeof(weight    ));
  memset( volume    ,0,sizeof(volume    ));
  memset( bitflags  ,0,sizeof(bitflags  ));
  memset( license   ,0,sizeof(license   ));	  
  memset( indi      ,0,sizeof(indi      ));

  for( i = 0; i < WIDGET_ARRSZ; ++i)
    {
      makedata_id(         i,   &id[i]);
      makedata_quantity(   i,   &quantity[i]);
      makedata_category(   i,   &category[i]);
      makedata_langcode(   i,   &langcode[i]);
      makedata_shortdesc(  i,    shortdesc[i]);
      makedata_wdesc(      i,    wdesc[i]);
      makedata_opcode(     i,    opcode[i]);
      makedata_inceptdate( i,   &inceptdate[i]);
      makedata_termdate(   i,   &termdate[i]);
      makedata_weight(     i,   &weight[i]);
      makedata_volume(     i,   &volume[i]);
      makedata_bitflags(   i,   &bitflags[i]);
      makedata_license(    i,    license[i]);
    }

  /* to assoc. arrays with arb datalayer */
  init_InputList( &inlist,
		  indi,
		  id        ,
		  quantity  ,
		  category  ,
		  langcode  ,
		  shortdesc ,
		  wdesc     ,
		  opcode    ,
		  inceptdate,
		  termdate  ,
		  weight    ,
		  volume    ,
		  bitflags  ,
		  license   );



  make_colname_list( colname_list);
#if 0
  arb_reset_placeholder();
#endif
  sprintf( sql, "insert into " TABLENAME " %s VALUES ",
	   colname_list);

  rc = arb_dbfcmd( conn, sql);
  if( rc != SUCCESS)
    abort();

  make_placeholders( conn, control_string, sql);
  PRINTSTR( sql);

  rc = arb_exec_string_array( conn, "", inlist,0/*structsz*/, WIDGET_ARRSZ);
  if( rc != SUCCESS)
    abort();
      
  return 0;
} /* populate_table */
Esempio n. 23
0
void tryStdVectorConstructor()
{
	PRINTSTR("try std::vector< <> >::vector()");
	std::vector< int > vInt(5,1);
	PRINT( vInt );
}