コード例 #1
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* The 4 com ports are not functionally needed.  */
/*Static */void
START(uchar Test, uchar Ref, uchar Aux1, uchar Aux2, int Echo)
{


    struct LOC_START V;
    _PROCEDURE TEMP;

    __Refpres = false;
    __Aux_A_Pres = false;
    __Aux_B_Pres = false;
    if (!PORT_ASSIGNMENTS_OK(Test, Ref, Aux1, Aux2))
        MODULE_ERR("Invalid ports specified in START.  See manual for details");
    __Manual = false;

    
    __Log_Msg = false;
    __Log_Every_Thing = false;

    /* set system variables based upon input from command line options. */    
    GET_PARAMS(&V);
    if (__Log_Msg) {
        strcpy(__Message_File_NAME, __File_Name);
        if (__Message_File != NULL)
            __Message_File = freopen(__Message_File_NAME, "w", __Message_File);
        else
            __Message_File = fopen(__Message_File_NAME, "w");
        _SETIO(__Message_File != NULL, FileNotFound);
        if (P_ioresult != 0)
            MODULE_ERR("Illegal log file name specified OR not DOS 3.x");
    }
    INIT_DEFAULTS(Echo);
}
コード例 #2
0
ファイル: dnsproxy.c プロジェクト: gitter-badger/knot
int dnsproxy_load(struct query_plan *plan, struct query_module *self)
{
	if (plan == NULL || self == NULL) {
		return KNOT_EINVAL;
	}

	struct dnsproxy *proxy = mm_alloc(self->mm, sizeof(struct dnsproxy));
	if (proxy == NULL) {
		MODULE_ERR("not enough memory");
		return KNOT_ENOMEM;
	}
	memset(proxy, 0, sizeof(struct dnsproxy));

	conf_val_t val = conf_mod_get(self->config, MOD_REMOTE, self->id);
	if (val.code != KNOT_EOK) {
		if (val.code == KNOT_EINVAL) {
			MODULE_ERR("no remote proxy address for '%s'",
			           self->id->data);
		}
		mm_free(self->mm, proxy);
		return val.code;
	}
	proxy->remote = conf_addr(&val, NULL);

	self->ctx = proxy;

	return query_plan_step(plan, QPLAN_BEGIN, dnsproxy_fwd, self->ctx);
}
コード例 #3
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* STRINSERT and strinsert both not supported yet, Do not understand
   the intent of them.                 
*/
Static void
STRINSERT(Char *S1, Char *S2, short P)
{
  MODULE_ERR("STRINSERT not supported yet");
  cleanup(0);
  return;

}
コード例 #4
0
ファイル: qalib.c プロジェクト: juddy/edcde
Static void
STRDELETE(Char *S, short P, short N)
{
   MODULE_ERR("STRDELETE not supported");
   cleanup(0);
   return;

}
コード例 #5
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* Only supporting test terminal (no reference terminal).  If support
   reference terminal, must pass in correct file descriptor. Now,
   var "Com" is not used. Only left in to keep from having to make
   changes.                                                           */
Static void
FLUSH_BUFFER_COM(short Com)
{

    if(tcflush(fd_test,TCIOFLUSH) < 0) {
       MODULE_ERR("FLUSH_BUFFER_COM: tcflush:"); 
       DONE();
    } 
}
コード例 #6
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* Do not understand the intent behind STRMOVE. NOT supported yet. */
Static void
STRMOVE(short N, Char *S1_, short P1, Char *S2, short P2)
{

    MODULE_ERR("STRMOVE not supported yet");
    cleanup(0);
    return;

}
コード例 #7
0
ファイル: qalib.c プロジェクト: juddy/edcde
Static void
WRITE_COM(FILE *f, Char *S)
{
    if(fputs(S,f) < 0) {
      MODULE_ERR("WRITE ERROR,fputs");
      perror("fputs");
     exit(1);
    }

}
コード例 #8
0
ファイル: qalib.c プロジェクト: juddy/edcde
Static void
LOGMSG(Char *S)
{
    if (__Log_Msg) {  /*$I-*/
        _SETIO(fprintf(__Message_File, "%s\n", S) >= 0, FileWriteError);
        if (P_ioresult != 0)
            MODULE_ERR("Error writing to Message File. Disk may be full");
    }
    puts(S);
}
コード例 #9
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* Not used functionally */
int
HANDSHAKE_COM(char *S)
/*  HANDSHAKE_COM(uchar Com, char *S) */
{
    if (toupper(S[0]) == 'N' || toupper(S[0]) == 'B' ||
         toupper(S[0]) == 'X' || toupper(S[0]) == 'E')
        HAND_SHAKE = toupper(S[0]);
    else
        MODULE_ERR("Bad handshaking driver type in HandShake_Com");

    return 1;

}
コード例 #10
0
ファイル: dnsproxy.c プロジェクト: jkadlec/knot-dns-zoneapi
int dnsproxy_load(struct query_plan *plan, struct query_module *self)
{
	struct dnsproxy *proxy = mm_alloc(self->mm, sizeof(struct dnsproxy));
	if (proxy == NULL) {
		MODULE_ERR("not enough memory");
		return KNOT_ENOMEM;
	}
	memset(proxy, 0, sizeof(struct dnsproxy));

	/* Determine IPv4/IPv6 */
	int family = AF_INET;
	if (strchr(self->param, ':')) {
		family = AF_INET6;
	}

	int ret = sockaddr_set(&proxy->remote.addr, family, self->param, 53);
	if (ret != KNOT_EOK) {
		MODULE_ERR("invalid proxy address: '%s'", self->param);
		mm_free(self->mm, proxy);
		return KNOT_EINVAL;
	}

	return query_plan_step(plan, QPLAN_BEGIN, dnsproxy_fwd, proxy);
}
コード例 #11
0
ファイル: rosedb.c プロジェクト: jkadlec/knot-dns-zoneapi
int rosedb_load(struct query_plan *plan, struct query_module *self)
{
	if (self == NULL || plan == NULL) {
		return KNOT_EINVAL;
	}
	
	struct cache *cache = cache_open(self->param, 0, self->mm);
	if (cache == NULL) {
		MODULE_ERR("couldn't open db '%s'", self->param);
		return KNOT_ENOMEM;
	}

	self->ctx = cache;

	return query_plan_step(plan, QPLAN_BEGIN, rosedb_query, cache);
}
コード例 #12
0
ファイル: qalib.c プロジェクト: juddy/edcde
Static char * 
READ_COM(int fd, char *terminator)
{
    char *c;
    char STR1[BUFSIZ];
   

    /* Based upon settings of strap G and H determine Handshake scheme. */
    /* Currently, on support 3 versions of the handshake scheme.        */
#if 0
    if(!inh_hndshk && inh_DC2)
       WRITETEST("\021");        /* default, DC1 handshake  */

    else if(inh_hndshk && !inh_DC2) {  /* DC1-DC2-DC1 handshake */
          ;

    }
    else if(inh_hndshk && inh_DC2)
       ;                               /* NO hand shake */
    else
       MODULE_ERR("ERROR, illegal combination of hand shake parameters."); 
#endif


    /* Determine termination character for read statements.              */
    /* Currently just work with auto line feed or not.                   */
/*
    if(autolf_mode)
      terminator="\n";
    else
      terminator="\r";
*/


    /* Read in data form /dev/tty. Input_Terminator is set globally */
    /* Read til get terminating char.                               */
    c=in(fd_test,STR1, sizeof(STR1), terminator);
    if(autolf_mode)
        STR1[(int) strlen(STR1) - 2] = '\0';   /* remove "CR and new line  */         
    else
        STR1[(int) strlen(STR1) - 1] = '\0';   /* just remove terminating char */
    return(STR1);
}
コード例 #13
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* prints to xxx.LOG file all data read and written thru READ_COM and 
   WRITE_COM.  Triggered by option -E, __Log_EveryThing.
*/
Static void
LOG_IT(char *S, short Howmany, Char Which_Way)
{
    short I, Count;
    Char Who[256];
    Char S1[3];
    boolean Ok;
    Char STR1[256];

    Count = 1;
   
    strcpy(Who,"Terminal"); 
    switch (Which_Way) {

      case 'R':
        strcat(Who, " ==> HOST");
        break;

      case 'W':
        sprintf(Who, "HOST ==> %s", strcpy(STR1, Who));
        break;

      default:
        MODULE_ERR("Bad call to Log_it.  Bad \"which_way\"");
        break;
    }
    
 
    _SETIO(fprintf(__Message_File, "%s\n", Who) >= 0, FileWriteError);
    Ok = (P_ioresult == 0);
    
    if(fprintf(__Message_File, "%s\n",vis(S)) < 0) {
      perror("fprintf __Message_File");
    } 


}
コード例 #14
0
ファイル: synth_record.c プロジェクト: dnstap/knot
int synth_record_load(struct query_plan *plan, struct query_module *self)
{
	/* Parse first token. */
	char *saveptr = NULL;
	char *token = strtok_r(self->param, " ", &saveptr);
	if (token == NULL) {
		return KNOT_EFEWDATA;
	}

	/* Create synthesis template. */
	struct synth_template *tpl = mm_alloc(self->mm, sizeof(struct synth_template));
	if (tpl == NULL) {
		return KNOT_ENOMEM;
	}

	/* Save in query module, it takes ownership from now on. */
	self->ctx = tpl;

	/* Supported types: reverse, forward */
	if (strcmp(token, "reverse") == 0) {
		tpl->type = SYNTH_REVERSE;
	} else if (strcmp(token, "forward") == 0) {
		tpl->type = SYNTH_FORWARD;
	} else {
		MODULE_ERR("invalid type '%s'.\n", token);
		return KNOT_ENOTSUP;
	}

	/* Parse format string. */
	tpl->prefix = strtok_r(NULL, " ", &saveptr);
	if (strchr(tpl->prefix, '.') != NULL) {
		MODULE_ERR("dots '.' are not allowed in the prefix.\n");
		return KNOT_EMALF;
	}

	/* Parse zone if generating reverse record. */
	if (tpl->type == SYNTH_REVERSE) {
		tpl->zone = strtok_r(NULL, " ", &saveptr);
		knot_dname_t *check_name = knot_dname_from_str(tpl->zone);
		if (check_name == NULL) {
			MODULE_ERR("invalid zone '%s'.\n", tpl->zone);
			return KNOT_EMALF;
		}
		knot_dname_free(&check_name, NULL);
	}

	/* Parse TTL. */
	tpl->ttl = strtol(strtok_r(NULL, " ", &saveptr), NULL, 10);

	/* Parse address. */
	token = strtok_r(NULL, " ", &saveptr);
	char *subnet = strchr(token, '/');
	if (subnet) {
		subnet[0] = '\0';
		tpl->subnet.prefix = strtol(subnet + 1, NULL, 10);
	}

	/* Estimate family. */
	int family = AF_INET;
	int prefix_max = IPV4_PREFIXLEN;
	if (strchr(token, ':') != NULL) {
		family = AF_INET6;
		prefix_max = IPV6_PREFIXLEN;
	}

	/* Check subnet. */
	if (tpl->subnet.prefix > prefix_max) {
		MODULE_ERR("invalid address prefix '%s'.\n", subnet);
		return KNOT_EMALF;
	}

	int ret = sockaddr_set(&tpl->subnet.ss, family, token, 0);
	if (ret != KNOT_EOK) {
		MODULE_ERR("invalid address '%s'.\n", token);
		return KNOT_EMALF;
	}

	return query_plan_step(plan, QPLAN_ANSWER, solve_synth_record, tpl);
}
コード例 #15
0
ファイル: qalib.c プロジェクト: juddy/edcde
/* Parses command line, looking at each option and doing the right thing. */
Local void
GET_PARAMS(struct LOC_START *LINK)
{
    struct LOC_GET_PARAMS V;
    Char Buffer[256], Current[256];

    
    boolean Bad_Params;
    Char STR1[256];
    Char STR2[256];

    V.LINK = LINK;

    __Group_Not_Running = true;
#if 0
    sprintf(__File_Name, "%s.LOG", GET_PROG_NAME(STR1, &V));
#endif
   
    *__Command_Line = '\0';   
    
    LINK->I = 1;
    Bad_Params = false;
    while (LINK->I < P_argc && !Bad_Params) {
        strcpy(Buffer, P_argv[LINK->I]);
        if ((char) Buffer[0] != '-' || (int) strlen(Buffer) < 2) {
            Bad_Params = true;
            break;
        }
        switch (toupper(Buffer[1])) {

          case 'T':
            if (!PUT_NUM(&__default_test_term, Buffer, &V))
                Bad_Params = true;
            break;

          case 'R':
            if (!PUT_NUM(&__default_ref_term, Buffer, &V))
                Bad_Params = true;
            break;

          case 'A':
            if (!PUT_NUM(&__default_aux_a, Buffer, &V))
                Bad_Params = true;
            break;

          case 'B':
            if (!PUT_NUM(&__default_aux_b, Buffer, &V))
                Bad_Params = true;
            break;

          case 'C':
              GET_COMMAND_LINE(&LINK->I, P_argv[LINK->I], &V);
            break;

          case 'M':
            if (strlen(Buffer) == 4) {
                if (toupper(Buffer[3]) == 'Y') {
                    __Manual = true;
                }
                else if (toupper(Buffer[3]) != 'Y')
                    Bad_Params = true;
            }
            else {
                Bad_Params = true;
            }
            break;

          case 'E':
            __Log_Every_Thing = true;
            __Log_Msg = true;
            break;

          case 'L':
            __Log_Msg = true;
            if ((int) strlen(Buffer) > 3)
                strsub(__File_Name, Buffer, 4, strlen(Buffer));
            break;

          case 'D':
         /*   __Group_Not_Running = false;  */
         /*  Option 'D' is being switched to debug mode. */
            
            __DEBUG = 1;
            break;

          default:
            Bad_Params = true;
            break;
        }
        LINK->I++;
    }
    if (Bad_Params)
        MODULE_ERR("Bad parameter line.  Please see manual for information");
    if (!PORT_ASSIGNMENTS_OK(__default_test_term, __default_ref_term,
                             __default_aux_a, __default_aux_b))
        MODULE_ERR("Bad Port assignments in command line. See manual");
    sprintf(__Command_Line, "NM%s", strcpy(STR2, __Command_Line));
    if (!__Manual)
        __Command_Line[1] = 'A';
    if (__Refpres)
        __Command_Line[0] = 'R';
}