Esempio n. 1
0
/*
 * Convenience wrapper on logwrite() which printf-formats the
 * string.
 */
static void logprintf(struct LogContext *ctx, const char *fmt, ...)
{
    va_list ap;
    char *data;

    va_start(ap, fmt);
    data = dupvprintf(fmt, ap);
    va_end(ap);

    logwrite(ctx, data, strlen(data));
    sfree(data);
}
Esempio n. 2
0
void prg_exit(int exit_code) {

	if (daemon_mode) logwrite("miniupdate terminated.\n");

	//if (pid_file != NULL) free(pid_file);
	if (log_file != NULL) free(log_file);
	if (log_fd != NULL) {
		fclose(log_fd);
	}
	unlink(pid_file);
	exit(exit_code);
}
Esempio n. 3
0
static int cf_dvbs_trans_pol(struct lc_centry *ce, struct lc_value *val) {
	if (strcasecmp(val->string, "h") == 0) {
		adapter->fe.dvbs.t_pol=POL_H;
	} else if(strcasecmp(val->string, "v") == 0) {
		adapter->fe.dvbs.t_pol=POL_V;
	} else {
		logwrite(LOG_ERROR, "Illegal polarization \"%s\" in line %d\n", val->string, ce->vline);
		return 0;
	}

	return 1;
}
Esempio n. 4
0
File: fe.c Progetto: tcuje/getstream
static int fe_api5_checkcap(struct adapter_s *adapter) {
    struct dtv_property p[1];
    struct dtv_properties cmds;

    p[0].cmd = DTV_DELIVERY_SYSTEM;

    cmds.props = p;
    cmds.num = 1;

    if (ioctl(adapter->fe.fd, FE_GET_PROPERTY, &cmds)) {
        logwrite(LOG_DEBUG, "fe: ioctl(FE_GET_PROPERTY) failed - no DVBS2 aka API 5 support?");
        return 0;
    }

    switch (p[0].u.data) {
    case(SYS_DVBS):
        if (adapter->type == AT_DVBS)
            break;
        logwrite(LOG_ERROR, "fe: Adapter %d is an DVB-S card - config is not for DVB-S", adapter->no);
        exit(-1);
    case(SYS_DVBS2):
        if (adapter->type == AT_DVBS || adapter->type == AT_DVBS2)
            break;
        logwrite(LOG_ERROR, "fe: Adapter %d is an DVB-S2 card - config is not DVB-S or S2", adapter->no);
        exit(-1);
    case(SYS_DVBT):
        if (adapter->type == AT_DVBT)
            break;
        logwrite(LOG_ERROR, "fe: Adapter %d is an DVB-T card - config is not for DVB-T", adapter->no);
        exit(-1);
    case(SYS_DVBC_ANNEX_B):
    case(SYS_DVBC_ANNEX_AC):
        if (adapter->type == AT_DVBC)
            break;
        logwrite(LOG_ERROR, "fe: Adapter %d is an DVB-C card - config is not for DVB-C", adapter->no);
        exit(-1);
    }

    return 1;
}
Esempio n. 5
0
static void logfopen_callback(void *handle, int mode)
{
    struct LogContext *ctx = (struct LogContext *)handle;
    char buf[256], *event;
    struct tm tm;
    const char *fmode;

    if (mode == 0) {
        ctx->state = L_ERROR;	       /* disable logging */
    } else {
        fmode = (mode == 1 ? "ab" : "wb");
        ctx->lgfp = f_open(&ctx->currlogfilename, fmode, FALSE);
        if (ctx->lgfp)
            ctx->state = L_OPEN;
        else
            ctx->state = L_ERROR;
    }

    if (ctx->state == L_OPEN) {
        /* Write header line into log file. */
        tm = ltime();
        strftime(buf, 24, "%Y.%m.%d %H:%M:%S", &tm);
        logprintf(ctx, "=~=~=~=~=~=~=~=~=~=~=~= PuTTY log %s"
                  " =~=~=~=~=~=~=~=~=~=~=~=\r\n", buf);
    }

    event = dupprintf("%s session log (%s mode) to file: %s",
                      ctx->state == L_ERROR ?
                      (mode == 0 ? "Disabled writing" : "Error writing") :
                      (mode == 1 ? "Appending" : "Writing new"),
                      (ctx->cfg.logtype == LGTYP_ASCII ? "ASCII" :
                       ctx->cfg.logtype == LGTYP_DEBUG ? "raw" :
                       ctx->cfg.logtype == LGTYP_PACKETS ? "SSH packets" :
                       ctx->cfg.logtype == LGTYP_SSHRAW ? "SSH raw data" :
                       "unknown"),
                      filename_to_str(&ctx->currlogfilename));
    logevent(ctx->frontend, event);
    sfree(event);

    /*
     * Having either succeeded or failed in opening the log file,
     * we should write any queued data out.
     */
    assert(ctx->state != L_OPENING);   /* make _sure_ it won't be requeued */
    while (bufchain_size(&ctx->queue)) {
        void *data;
        int len;
        bufchain_prefix(&ctx->queue, &data, &len);
        logwrite(ctx, data, len);
        bufchain_consume(&ctx->queue, len);
    }
}
Esempio n. 6
0
void StrokeGroup::MoveSG(double vec[])
{
    try{
  for(int i=0;i<nstrokes;i++)
   strklist[i].MoveStrk(vec);
    }
    catch(exception& e)
    {
        string str="StrokeGroup:Exception in MoveSG: ";
        str.append(e.what());
    logwrite(str);
    }
}
Esempio n. 7
0
PVOID MemAlloc(ULONG cb)
  {
  PVOID pv = NULL;
  if ( !cb ) return NULL;
  // if the RAM semaphore is locked gives CPU time to the other threads
  // so they can finish their job and release the semaphore
  heapLock();
  pv = _umalloc(hp, cb);
  heapUnlock();
  logwrite("malloc        - address : %08x size : %8u\n", (ULONG)pv, cb);
  TRACE2("malloc        - address : %08x size : %8u", (ULONG)pv, cb);
  return pv;
  }
Esempio n. 8
0
void ts_packet_decode(uint8_t *ts) {
	logwrite(LOG_DEBUG, "ts_packet_decode\n");
	dump_hex(LOG_DEBUG, "pdecode:", ts, TS_PACKET_SIZE);
	logwrite(LOG_DEBUG, "\tsync: %02x\n", ts[0]);
	logwrite(LOG_DEBUG, "\ttransport_error_indicator: %d\n", ts[1]&0x80 ? 1 : 0);
	logwrite(LOG_DEBUG, "\tpayload_unit_start_indicator: %d\n", ts[1]&0x40 ? 1 : 0);
	logwrite(LOG_DEBUG, "\ttransport_priority: %d\n", ts[1]&0x20 ? 1 : 0);
	logwrite(LOG_DEBUG, "\tpid: %d\n", (ts[1]<<8|ts[2])&0x1fff);
	logwrite(LOG_DEBUG, "\ttransport_scrambling_control: %d\n", (ts[3]>>6) & 0x3);
	logwrite(LOG_DEBUG, "\tadaption_field_control: %d\n", (ts[3]>>4) & 0x3);
	logwrite(LOG_DEBUG, "\tcontinuity_counter: %d\n", ts[3]&0xf);
}
Esempio n. 9
0
static void output_remove_receiver(struct http_receiver_s *hr) {
	struct output_s		*o=hr->output;
	struct http_connection	*hc=hr->hc;

	o->http_receiver=g_list_remove(o->http_receiver, hr);
	o->receiver--;

	logwrite(LOG_INFO, "stream_http: dropping connection to %s for %s",
				inet_ntoa(hc->sin.sin_addr),
				hc->url);

	http_drop_connection(hc);
	free(hr);
}
Esempio n. 10
0
static int rmailfunc(char *addrlist)
{
  char *p, *p1;
  int  r, noaddr=1;

  conf=0;
  cnews=0;
  debug(4, "rmailfunc(\"%s\")", addrlist);
  p=addrlist;
  while (isspace(*p)) p++;
  for (; *p; lseek(fileno(stdin), 0, SEEK_SET))
  {
    for (p1=p; *p1 && !isspace(*p1); p1++);
    if (p1-p>=sizeof(addr))
    { logwrite('?', "Too long address\n");
      return 1;
    }
    strncpy(addr, p, (int)(p1-p));
    addr[(int)(p1-p)]='\0';
    ibufsrc=BUFSIZE;
    msgsize=-1;
    if (!myfgets(gotstr, sizeof(gotstr)))
    { logwrite('?', "Incorrect message\n");
      return 1;
    }
    if (isbeg(gotstr)!=0)
    { logwrite('?', "Incorrect message start\n");
      return 1;
    }
    r=msg_unmime(-1);
    if (r) return r;
    noaddr=0;
    for (p=p1; isspace(*p); p++);
  }
  debug(4, "rmailfunc ok");
  return noaddr;
}
Esempio n. 11
0
void dump_hex(int level, const char *prefix, uint8_t *buf, int size) {
	int		i;
	unsigned char	ch;
	char		sascii[17];
	char		linebuffer[16*4+1];

	/* Speedup */
	if (level > loglevel)
		return;

	sascii[16]=0x0;

	for(i=0;i<size;i++) {
		ch=buf[i];
		if (i%16 == 0) {
			sprintf(linebuffer, "%04x ", i);
		}
		sprintf(&linebuffer[(i%16)*3], "%02x ", ch);
		if (ch >= ' ' && ch <= '}')
			sascii[i%16]=ch;
		else
			sascii[i%16]='.';

		if (i%16 == 15)
			logwrite(level, "%s %s  %s", prefix, linebuffer, sascii);
	}

	/* i++ after loop */
	if (i%16 != 0) {
		for(;i%16 != 0;i++) {
			sprintf(&linebuffer[(i%16)*3], "   ");
			sascii[i%16]=' ';
		}

		logwrite(level, "%s %s  %s", prefix, linebuffer, sascii);
	}
}
Esempio n. 12
0
void StrokeGroup::InterpStrokesForSVM()
{
    try{
        for(int i=0;i<nstrokes;i++)
        {
                strklist[i].InterpStrkForSVM();
        }
    }
    catch(exception& e)
    {
        string str="StrokeGroup:Exception in InterpStrokesForSVM: ";
        str.append(e.what());
     logwrite(str);
    }
}
Esempio n. 13
0
void MainWindow::DisplayFirmwareInfo(void)
{
    uint8_t buff[16];
    QString digistr;
    QChar fw_major, fw_minor;

    qDebug() << "Reading Firmware info...";

    if((fmtxCmdStatus = fmtxIoAppCommand(GET_REV, buff, 0)) !=FMTX_MODE_OK) goto display_firmware_err;

    digistr = QString::number(buff[1]).rightJustified(2, '0', false);
    ui->lineEdit_hw_id_txpart->setText(QString("SI47").append(digistr));

    fw_major = QChar(buff[2]);
    fw_minor = QChar(buff[3]);
    ui->lineEdit_hw_id_txfwrev->setText(QString(fw_major) + "." + QString(fw_minor));

    ui->lineEdit_hw_id_txpatchid->setText(QString::number(buff[4]) + "." + QString::number(buff[5]));

    fw_major = QChar(buff[6]);
    fw_minor = QChar(buff[7]);
    ui->lineEdit_hw_id_txcomprev->setText(QString(fw_major) + "." + QString(fw_minor));

    ui->lineEdit_hw_id_txchiprev->setText(QString(QChar(buff[8])));


    qDebug() << "Chip identified: SI47" << digistr << "-" << QString(QChar(buff[8])) << QString(QChar(buff[2])) << QString(QChar(buff[3])) << "-GM(R)";

    logwrite(LOG_INFO, "CHIP: si47%d, fw=%c.%c, patch_id=0x%02x.0x%02x, "
                       "chip_fw=%c.%c, chip_rev=%c",
             buff[1],
             buff[2],buff[3],
             buff[4],buff[5],
             buff[6],buff[7],
             buff[8]);
    if ((buff[1] == 11)||(buff[1] == 13)){
        if (buff[2] < 2){
            qDebug() << "Chip supports RDS, but firmware: " << QString(QChar(buff[8])) << "." << QString(QChar(buff[2])) << "is NOT, please change your chip to more modern one...";
        } else {
            qDebug() << "Chip supports RDS";
        }
    }

    qDebug() << "Firmware info readed";
    return;
display_firmware_err:
    qDebug() << "Error while reading firmware info";
}
Esempio n. 14
0
StrokeGroup::StrokeGroup()
{
    try
    {
        label="none";
        nstrokes = 0;
        origin[0]=0;
        origin[1]=0;
    }
    catch(exception& e)
    {
        string str="StrokeGroup:Exception in constructor: ";
        str.append(e.what());
        logwrite(str);
    }
}
Esempio n. 15
0
static int cf_sap_scope(struct lc_centry *ce, struct lc_value *val) {

	if (strcasecmp(val->string, "global") == 0) {
		sap->scope=SAP_SCOPE_GLOBAL;
	} else if(strcasecmp(val->string, "org") == 0) {
		sap->scope=SAP_SCOPE_ORG;
	} else if(strcasecmp(val->string, "local") == 0) {
		sap->scope=SAP_SCOPE_LOCAL;
	} else if(strcasecmp(val->string, "link") == 0) {
		sap->scope=SAP_SCOPE_LINK;
	} else {
		logwrite(LOG_ERROR, "Illegal SAP scope \"%s\" in line %d\n", val->string, ce->vline);
		return 0;
	}

	return 1;
}
Esempio n. 16
0
// Masks the constant value in the signature tree of a trigger node, if the trigger node was the first
// node to be installed in a constant node under the index structure, and there is some constant value
// that was not copied completely in the constant node; rather its reference was stored.
static void save_const_node_info (syntree *signature_tree)
{
	switch (signature_tree->type)
	{
	case FUNCTION_CALL_TYPE:
		// Currently it is being used only by free text predicate index.
		ASSERT (tm_stricmp(get_chars (signature_tree->left_tree->datum), "contains") == 0);
		// We set the free text predicate syntree in the signature tree to be NULL, so that it is not
		// deleted with the triggger's syntax tree. This free text predicate syntree is required by 
		// the constant node in the index.
		signature_tree->right_tree->right_tree->left_tree = NULL;
		break;
	default:
		logwrite ("Internal Error: bad indexable predicate found.");
		TMAN_HALT;
	}
}
Esempio n. 17
0
void StrokeGroup::AddStrk2SG(Stroke strk)
{
    try
    {
        if(nstrokes==0)
        {
            strklist.clear();
        }
        strklist.push_back(strk);
        nstrokes++;
    }
    catch(exception& e)
    {
        string str="StrokeGroup:Exception in constructor: ";
        str.append(e.what());
        logwrite(str);
    }
}
Esempio n. 18
0
StrokeGroup::StrokeGroup(double argorigin[])
{
    try
	{
  label="none";
  nstrokes = 0;
  origin[0]=argorigin[0];
  origin[1]=argorigin[1];
  Stroke emptystrk;
  emptystrk.RandStrk(0);
  strklist.push_back(emptystrk);
    }
    catch(exception& e)
    {
        string str="StrokeGroup:Exception in constructor1: ";
        str.append(e.what());
        logwrite(str);
    }
}
Esempio n. 19
0
/*
 * Apply section filter to opened demux interface.
 *
 */
int demux_set_sct_filter(int fd, int pid,
		struct dmx_filter *df, int flags, int timeout) {

	struct dmx_sct_filter_params	sctFilterParams;

	memset(&sctFilterParams, 0, sizeof(struct dmx_sct_filter_params));

	sctFilterParams.pid=pid;
	sctFilterParams.timeout=timeout;
	sctFilterParams.flags=flags;

	memcpy(&sctFilterParams.filter, df, sizeof(struct dmx_filter));

	if (ioctl(fd, DMX_SET_FILTER, &sctFilterParams) < 0) {
		logwrite(LOG_ERROR, "demux: ioctl DMX_SET_PES_FILTER failed for pid %u",pid);
		exit(-1);
	}

	return 0;
}
Esempio n. 20
0
static double match_score_ft_basic_pred (ft_doc_index *doc_idx, ft_basic_pred *ft_pred)
{
	int basic_pred_type;
	ASSERT (ft_pred);
	basic_pred_type = ft_pred->basic_pred_type;
	switch (basic_pred_type)
	{
	case FT_OR_TYPE:
		return (match_score_or_basic_pred (doc_idx, ft_pred));
	case FT_AND_TYPE:
		return (match_score_and_basic_pred (doc_idx, ft_pred));
	case FT_ACCRUE_TYPE:
		return (match_score_accrue_basic_pred (doc_idx, ft_pred));
	default:
		logwrite ("Internal Error: wrong type '%d' appeared in match_score_ft_basic_pred", basic_pred_type);
		TMAN_HALT;
	}

	return 0.0;	// Never reached.
}
Esempio n. 21
0
static double match_score (ft_doc_index *doc_idx, void *ft_node)
{
	int *type;
	type = ft_node;
	ASSERT (type);
	switch (*type)
	{
	case FT_AND_TYPE:
		return (match_score_ft_and (doc_idx, (syntree *)ft_node));
	case FT_OR_TYPE:
		return (match_score_ft_or (doc_idx, (syntree *)ft_node));
	case FT_BASIC_PRED_TYPE:
		return (match_score_ft_basic_pred (doc_idx, (ft_basic_pred *)ft_node));
	default:
		logwrite ("Internal Error: wrong type '%d' appeared in match_score", type);
		TMAN_HALT;
	}

	return 0.0;	// Never reached.
}
Esempio n. 22
0
// Deletes the constant node from the index.
// Calls specific index structure routines to delete the constant node. It is the index implementor's responsibility
// to dispose the constant node properly.
static void delete_const_node_from_pred_index (constant_node *const_node_to_delete, predicate_index *pred_index, int index)
{
	int *pred_type;

	ASSERT (const_node_to_delete);
	ASSERT (pred_index);
	pred_type = (int *)pred_index->index; // Get the predicate index type.

	switch (*pred_type)
	{
	case SKIP_LIST_TYPE:
		delete_const_node_from_sig_skiplist ((slnode *)const_node_to_delete, pred_index->index);
		break;
	case FT_PREDICATE_INDEX_TYPE:
		delete_const_node_from_ft_pred_index ((ft_pred_constant *)const_node_to_delete, pred_index->index, index);
		break;
	default:
		logwrite ("Internal Error: bad index type encountered while deleting the constant node from predicate index.");
		TMAN_HALT;
	}
}
Esempio n. 23
0
RCG_node *get_node_from_RCG(char *name, RCG *graph)
{
	ListElement *cursor;
	RCG_node *node;
	
	ASSERT (name);
	ASSERT (graph);

	for (node = (RCG_node *)List_getFirst(graph->nodes, &cursor);
		 node;
		 node = (RCG_node *)List_getNext(&cursor))
		
	{
		if (strcmp(node->tuple_variable_name, name) == 0)
			return node;
	}
	
	logwrite ("Internal error: tuple variable %s not found in rule condition graph (RCG).", name);
	TMAN_HALT;
	return NULL;
}
Esempio n. 24
0
double StrokeGroup::LocaliseSGCoordSysInChar()
{
  Matrix<double> sgbnds;
  double offset[2];
  try{
  sgbnds = SGBounds();
  //to shift all strokes in SG such that the left bound is at origin.
  origin[0]= sgbnds(1);
  //offset[0]=origin[0]*(-1);
  offset[0]=origin[0]=0;

  origin[1]=offset[1]=0;
  MoveSG(offset);
  }
  catch(exception& e)
  {
      string str="StrokeGroup:Exception in LocaliseSGCoordSysInChar: ";
      str.append(e.what());
    logwrite(str);
  }
  return(origin[0]);
}
Esempio n. 25
0
Matrix<double> StrokeGroup::SGBounds()
{
  Matrix<double> sgbnds(1,4),strkbnds(1,4),tmpbnds;
  double xl,xr,yb,yt;
  int i,bndsmode;
  try{
  if(nstrokes==0){
    sgbnds.MakeNull();
    return sgbnds;
  }
  bndsmode = 1; //y-coord increases bottom up
  for(i=0;i<nstrokes;i++){
    tmpbnds = strklist[i].StrkBounds(bndsmode);
   if(i==0)
     strkbnds=tmpbnds;
   strkbnds.Append(tmpbnds,1);
  }

  xl = strkbnds.Min(1,2);
  xr = strkbnds.Max(2,2);
  yb = strkbnds.Min(3,2);
  yt = strkbnds.Max(4,2);

 sgbnds.Set(1,1,xl);
 sgbnds.Set(1,2,xr);
 sgbnds.Set(1,3,yb);
 sgbnds.Set(1,4,yt);
  }
  catch(exception& e)
  {
      string str="StrokeGroup:Exception in SGBounds: ";
      str.append(e.what());
     logwrite(str);
  }
  return(sgbnds);
}
Esempio n. 26
0
static int output_cb_http(struct http_connection *hc, int cbtype, void *arg) {

	switch(cbtype) {
		case(HCB_QUERY): {
			struct http_receiver_s	*hr;
			struct output_s		*o=arg;	/* HCB_QUERY returns http_url args */

			hr=calloc(1, sizeof(struct http_receiver_s));
			hr->hc=hc;
			hr->output=o;

			/* Put into stream output list */
			o->http_receiver=g_list_append(o->http_receiver, hr);
			o->receiver++;

			/* Store http_receiver into http_connection structure */
			hc->arg=hr;

			/* Return head */
			http_header_start(hc, "200 OK", "application/octet-stream");
			http_header_nocache(hc);
			http_header_clength(hc, -1);
			http_header_end(hc);

			logwrite(LOG_INFO, "stream_http: connection from %s for %s",
						inet_ntoa(hc->sin.sin_addr),
						hc->url);
			break;
		}
		case(HCB_ERROR): {
			output_remove_receiver(hc->arg);
			break;
		}
	}
	return 1;
}
Esempio n. 27
0
void print_RCG(RCG *graph)
{
	ListElement *node_cursor, *tree_cursor;
	RCG_node *node;
	syntree *tree;

	ASSERT(graph);
	
	for (node = List_getFirst(graph->nodes, &node_cursor);
		 node;
		 node = List_getNext(&node_cursor))
	{
		logwrite("Node is %s\n", node->tuple_variable_name);
        logwrite("data source is %s\n", node->datasrc_name);
		logwrite("The selection predicates in the node are ");
		
		for (tree = List_getFirst(node->selection_predicates_list, &tree_cursor);
		tree;
		tree = List_getNext(&tree_cursor))
		{
			print_tree(tree, 0);
			logwrite ("");
		}
		logwrite ("The decorated selction  predicate for the node is");
		print_tree(node->decorated_selection_predicate, 0);

		logwrite ("The join predicates in the node are");
		for (tree = List_getFirst(node->join_predicates_list, &tree_cursor);
		tree;
		tree = List_getNext(&tree_cursor))
		{
            print_tree(tree, 0);
			logwrite ("");
		}
	}
	
}
Esempio n. 28
0
void print_tree (void *arg, int level)
{
    int *type;

    type = (int *) arg;

    if (!type)
        return;
    /*
     * indent (level);
     * logwrite ("print_tree: Type code %d @ %p", *type, arg);
     */
     

    switch (*type)
    {
        case STATEMENT_LIST_TYPE:
            statement_list_print_tree (arg, level);
            break;
        case CREATE_TRIGGER_TYPE:
            create_trigger_print_tree (arg, level);
            break;
        case CREATE_TRIGGERSET_TYPE:
            create_triggerset_print_tree (arg, level);
            break;      
        case DROP_TRIGGER_TYPE:
            drop_trigger_print_tree (arg, level);
            break;
        case DROP_TRIGGERSET_TYPE:
            drop_triggerset_print_tree (arg, level);
            break;
        case ENABLE_TRIGGER_TYPE:
            enable_trigger_print_tree (arg, level);
            break;
        case DISABLE_TRIGGER_TYPE:
            disable_trigger_print_tree (arg, level);
            break;
        case ENABLE_ALL_TRIGGERSETS_TYPE:
            enable_all_triggersets_print_tree (arg, level);
            break;
        case DISABLE_ALL_TRIGGERSETS_TYPE:
            disable_all_triggersets_print_tree (arg, level);
            break;
        case ENABLE_TRIGGERSET_TYPE:
            enable_triggerset_print_tree (arg, level);
            break;
        case DISABLE_TRIGGERSET_TYPE:
            disable_triggerset_print_tree (arg, level);
            break;
        case ECHO_TYPE:
            echo_print_tree (arg, level);
            break;
        case DATASRC_SPEC_TYPE:
            datasrc_spec_print_tree (arg, level);
            break;
        case CREATE_DATASRC_TYPE:
            create_datasrc_print_tree (arg, level);
            break;
        case DROP_DATASRC_TYPE:
            drop_datasrc_print_tree (arg, level);
            break;
        case ENABLE_DATASRC_TYPE:
            enable_datasrc_print_tree (arg, level);
            break;
        case DISABLE_DATASRC_TYPE:
            disable_datasrc_print_tree (arg, level);
            break;
        case DOT_TYPE:
            dot_print_tree (arg, level);
            break;
        case ACTION_CLAUSE_TYPE:
            action_clause_print_tree (arg, level);
            break;
        case INT_LIT_TYPE:
            int_lit_print_tree (arg, level);
            break;
        case DBL_LIT_TYPE:
            dbl_lit_print_tree (arg, level);
            break;
        case STR_LIT_TYPE:
            str_lit_print_tree (arg, level);
            break;
        case BOOL_LIT_TYPE:
            bool_lit_print_tree (arg, level);
            break;
		case DECIMAL_LIT_TYPE:
			decimal_lit_print_tree(arg, level);
			break;
		case DATETIME_LIT_TYPE:
			datetime_lit_print_tree(arg, level);
			break;
		case DATE_LIT_TYPE:
			date_lit_print_tree(arg, level);
			break;
		case INTERVAL_LIT_TYPE:
			interval_lit_print_tree(arg, level);
			break;
        case ID_TYPE:
            id_print_tree (arg, level);
            break;
        case AND_TYPE:
            and_print_tree (arg, level);
            break;
        case OR_TYPE:
            or_print_tree (arg, level);
            break;
        case NOT_TYPE:
            not_print_tree (arg, level);
            break;
        case LESS_TYPE:
            less_print_tree (arg, level);
            break;
        case GREATER_TYPE:
            greater_print_tree (arg, level);
            break;
        case EQUAL_TYPE:
            equal_print_tree (arg, level);
            break;
        case NOT_EQUAL_TYPE:
            not_equal_print_tree (arg, level);
            break;
        case LESS_EQUAL_TYPE:
            less_equal_print_tree (arg, level);
            break;
        case GREATER_EQUAL_TYPE:
            greater_equal_print_tree (arg, level);
            break;
        case ADD_TYPE:
            add_print_tree (arg, level);
            break;
        case SUBTRACT_TYPE:
            subtract_print_tree (arg, level);
            break;
        case MULTIPLY_TYPE:
            multiply_print_tree (arg, level);
            break;
        case DIVIDE_TYPE:
            divide_print_tree (arg, level);
            break;
        case UNARY_MINUS_TYPE:
            unary_minus_print_tree (arg, level);
            break;
        case LIKE_TYPE:
            like_print_tree (arg, level);
            break;
        case EXPR_LIST_TYPE:
            expr_list_print_tree (arg, level);
            break;
        case FUNCTION_CALL_TYPE:
            function_call_print_tree (arg, level);
            break;
        case INT_TO_DOUBLE_TYPE:
            int_to_double_print_tree (arg, level);
            break;
		case DBL_TO_SMALLFLT_TYPE:
			double_to_smallfloat_print_tree (arg, level);
			break;
		case DATE_TO_DATETIME_TYPE:
			date_to_datetime_print_tree(arg, level);
			break;
		case DOUBLE_TO_DECIMAL_TYPE:
			double_to_decimal_print_tree(arg, level);
			break;
		case INT_TO_DECIMAL_TYPE:
			int_to_decimal_print_tree(arg, level);
			break;
        case FROM_CLAUSE_TYPE:
            from_clause_print_tree (arg, level);
            break;
        case DATASRC_LIST_TYPE:
            datasrc_list_print_tree (arg, level);
            break;
        case IN_TYPE:
            in_print_tree (arg, level);
            break;
        case WHEN_CLAUSE_TYPE:
            when_clause_print_tree (arg, level);
            break;
        case AFTER_CLAUSE_TYPE:
            after_clause_print_tree (arg, level);
            break;
        case COMM_BLOCK_TYPE:
            comm_block_print_tree (arg, level);
            break;
        case UPDATE_TYPE:
            update_print_tree (arg, level);
            break;
        case INSERT_TYPE:
            insert_print_tree (arg, level);
            break;
		case INSERT_UPDATE_TYPE:
			insert_update_print_tree (arg, level);
			break;
        case DELETE_TYPE:
            delete_print_tree (arg, level);
            break;
        case FORM_PARAM_LIST_TYPE:
            form_param_list_print_tree (arg, level);
            break;
		case PARAM_SPEC_TYPE:
			param_spec_print_tree (arg, level);
			break;
		case TYPE_TYPE:
			type_print_tree (arg, level);
			break;
		case TYPEEXT_TYPE:
			typeext_print_tree (arg, level);
			break;
		case TYPE_NAME_TYPE:
			type_name_print_tree (arg, level);
			break;
        case EXECSQL_TYPE:
            execsql_print_tree (arg, level);
            break;
        case DATASRC_NAME_TYPE:
            datasrc_name_print_tree (arg, level);
            break;
        case SKIP_TYPE:
            skip_print_tree (arg, level);
            break;
		case SUBMIT_TYPE:
			submit_print_tree (arg, level);
			break;
        case SOURCE_TYPE:
            source_print_tree (arg, level);
            break;
		case SEND_NOTICE_TYPE:
            send_notice_print_tree (arg, level);
            break;
		case NOTICE_MESSAGE_TYPE:
            notice_message_print_tree (arg, level);
            break;
        case SEND_MAIL_TYPE:
            send_mail_print_tree (arg, level);
            break;
		case EMAIL_ADDR_TYPE:
			email_addr_print_tree(arg, level);
			break;
		case EMAIL_CONTENT_TYPE:
			email_content_print_tree(arg, level);
			break;
		case FT_PREDICATE_TYPE:
			ft_predicate_print_tree (arg, level);
			break;
		case FT_OR_TYPE:
			ft_or_print_tree (arg, level);
			break;
		case FT_ACCRUE_TYPE:
			ft_accrue_print_tree (arg, level);
			break;
		case FT_AND_TYPE:
			ft_and_print_tree (arg, level);
			break;
		case FT_NOT_TYPE:
			ft_not_print_tree (arg, level);
			break;
		case FT_WORD_TYPE:
			ft_word_print_tree (arg, level);
			break;
		case FT_PHRASE_TYPE:
			ft_phrase_print_tree (arg, level);
			break;
		case FT_BASIC_PRED_TYPE:
			ft_basic_pred_print_tree (arg, level);
			break;
		case FT_PHRASE_INFO_TYPE:
			ft_phrase_info_print_tree (arg, level);
			break;
		case VARARRAY_TYPE:
			va_print_tree (arg, level);
			break;
		case FT_DOC_INDEX_TYPE:
			ft_doc_index_print_tree (arg);
			break;
		case FT_DOC_TRIE_LEAF_TYPE:
			ft_doc_trie_leaf_print_tree ((ft_doc_trie_leaf *)arg, level);
			break;
		case FT_DOC_TRIE_BRANCH_TYPE:
			ft_doc_trie_branch_print_tree ((ft_doc_trie_branch *)arg, level);
			break;
		case FT_PRED_TRIE_NODE_TYPE:
			ft_pred_trie_node_print_tree ((ft_pred_trie_node *)arg, level);
			break;
		case FT_PRED_TRIE_BRANCH_TYPE:
			ft_pred_trie_branch_print_tree ((ft_pred_trie_branch *)arg, level);
			break;
		case FT_PRED_TRIE_LEAF_TYPE:
			ft_pred_trie_leaf_print_tree ((ft_pred_trie_leaf *)arg, level);
			break;
        default:
            logwrite ("Internal error: called print_tree with unknown type code %d.", *type);
			TMAN_HALT;
            break;            
    }
}
Esempio n. 29
0
int getifaddr(const char *ifname, char *ipaddr) {

	/* init vars */
	int numreqs = 30, sd, n, tick, found=0;
	struct ifconf ifc;
	struct ifreq *ifr;
	struct in_addr *ia;
	char *tmpip;

	/* cheap way to empty the result */
	*ipaddr = '\0';

	sd=socket(AF_INET, SOCK_STREAM, 0);
	ifc.ifc_buf = NULL;
	ifc.ifc_len = sizeof(struct ifreq) * numreqs;

	if ((ifc.ifc_buf = realloc(ifc.ifc_buf, ifc.ifc_len)) == NULL) {
		logwrite("getifaddr: Fatal error in memory allocation");
		close(sd);
		prg_exit(EXIT_FAILURE);
		return(-1);
	}

	if (ioctl(sd, SIOCGIFCONF, &ifc) < 0) {
		free(ifc.ifc_buf);
		close(sd);
		logwrite("getifaddr: error in ioctl call");
		return(-1);
	}

	ifr = ifc.ifc_req;
	for (n = 0; n < ifc.ifc_len; n += sizeof(struct ifreq)) {

		ia= (struct in_addr *) ((ifr->ifr_ifru.ifru_addr.sa_data)+2);

		if ((tick = strcmp(ifr->ifr_ifrn.ifrn_name, ifname)) == 0) {
			tmpip = inet_ntoa(*ia);
			if (log_verbose) {
				sprintf(msg, "getifaddr: IP of %s:%s", ifname, tmpip);
				logwrite(msg);
			}
			if (sscanf(tmpip, "%u.%u.%u.%u", &int_tmp,&int_tmp,&int_tmp,&int_tmp) == 4) {
				strncpy(ipaddr, tmpip, IPADDR_LEN);
				found = 1;
			} else {
				if (log_verbose) logwrite("getifaddr: error in IP format");
			}
			break;
		}

		ifr++;
	}

	free(ifc.ifc_buf);
	close(sd);

	if (found) {
		return(0);
	} else {
		return(-1);
	}

}
Esempio n. 30
0
void open_db_connection (TM_CONN_HNDL *conn_hndl)
{
	TM_CONNECTION		*conn;
	SQLRETURN			retcode;

	*conn_hndl = tman_malloc(sizeof(TM_CONNECTION));

	conn = (TM_CONNECTION *) *conn_hndl;

	/*Allocate environment handle */
	retcode = SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &(conn->henv));

	if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
	{
		/* Set the ODBC version environment attribute */
		retcode = SQLSetEnvAttr(conn->henv, SQL_ATTR_ODBC_VERSION, (void*)SQL_OV_ODBC3, 0);

		if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
		{
			/* Allocate connection handle */
			retcode = SQLAllocHandle(SQL_HANDLE_DBC, conn->henv, &(conn->hdbc));

			if (retcode == SQL_SUCCESS || retcode == SQL_SUCCESS_WITH_INFO)
			{
				/* Set login timeout to 5 seconds. */
#pragma warning (disable : 4022)
				SQLSetConnectAttr(conn->hdbc, SQL_LOGIN_TIMEOUT, 5, 0);
#pragma warning (default : 4022)

				/* Connect to data source */
				retcode = SQLConnect(conn->hdbc, (SQLCHAR*) odbc_dsn, SQL_NTS,
					(SQLCHAR*) username, SQL_NTS,
					(SQLCHAR*) password, SQL_NTS);

				if ((retcode != SQL_SUCCESS) && (retcode != SQL_SUCCESS_WITH_INFO))
				{
					checkerr(conn->henv, SQL_HANDLE_ENV);
					logwrite("Error: could not open a connection to the ODBC data source.");
					logwrite("Please verify that the Configuration Wizard has been run, the DBMS is running,");
					logwrite("and that the username and password are valid.");
					SQLFreeHandle(SQL_HANDLE_DBC, conn->hdbc);
					SQLFreeHandle(SQL_HANDLE_ENV, conn->henv);
					tman_free(conn_hndl);
					return;
				}
			}
			else
			{
				checkerr(conn->henv, SQL_HANDLE_ENV);
				logwrite("Error: could not connect to ODBC data source. Please check the username, password and permissions.");
				logwrite("Ensure that the DBMS is running.");
				SQLFreeHandle(SQL_HANDLE_DBC, conn->hdbc);
				SQLFreeHandle(SQL_HANDLE_ENV, conn->henv);
				tman_free(conn_hndl);
				return;
			}
		}
	}
	else
	{
		checkerr(conn->henv, SQL_HANDLE_ENV);
		logwrite("Error: could not connect to ODBC data source. Please check the username, password and permissions.");
		logwrite("Ensure that the DBMS is running.");
		SQLFreeHandle(SQL_HANDLE_ENV, conn->henv);
		tman_free(conn_hndl);
	}
}