Beispiel #1
0
/*************************************************
  Function:		unsigned char INTERFACE_ConfigIp(unsigned char *pucBuf, MsgTabIndex uiIndex)
  Description:	config IP address
  Param:   		unsigned char ucMin:		max length that can be input
		  		unsigned char ucMax:		min length that can be input
		  		unsigned char ucType:		input type, same as the parameter
		  									in INPUT_UTIL_Process
		  		unsigned char *pucBuf:		pointer of buffer which save the
											inputed data
		  		unsigned char *pucMask:		appoint data that can be input
		  		MsgTabIndex uiIndex:		message index want to display
  											as a title
  Return:		0				SUCCESS
				ERR_CANCLE		cancel
				ERR_TIME_OUT	time out
  remake:
  history:
  	<author>  	<time>			<version >   		<desc>
	yyf			2007.07.06		1.0					build this module  
*************************************************/
unsigned char INTERFACE_ConfigIp(unsigned long *pulIpAddress, MsgTabIndex uiIndex)
{
	unsigned char ucResult = SUCCESS;
	unsigned char aucDisp[MAX_DISPLAY_CHAR + 1];

	INTERFACE_CleanTimeOutCount();

	while(ucResult == SUCCESS)
	{
		MSG_DisplayMsg(1, 0, 0, uiIndex);
		MSG_DisplayMsg(0, 1, 0, ACTUAL_VALUE);
		COMMON_UTIL_FormIpAddress(aucDisp, *pulIpAddress);
		DISPLAY_UTIL_Line('0', DISPLAY_LEFT, 2, aucDisp);
		MSG_DisplayMsg(0, 3, 0, INPUT_NEW_VALUE);
		MSG_DisplayMsg(0, 6, 0, CANCEL_TO_MAIN_MENU);
		MSG_DisplayMsg(0, 7, 0, ENTER_TO_CONTINUE);
		memset(aucDisp, 0, sizeof(aucDisp));
		long_tab(aucDisp, 4, pulIpAddress);
		ucResult = INPUT_UTIL_IPV4Addr(0, '0', 4, aucDisp);
		if(ucResult == SUCCESS)
		{
			*pulIpAddress = tab_long(aucDisp, 4);
			break;
		}
		if(ucResult == ERR_CANCEL)
		{
			ucResult = INTERFACE_CancelConfirm();
		}
		else if(ucResult == ERR_TIME_OUT)
		{
			ucResult = INTERFACE_TimeOutConfirm();
		}
	}
	return ucResult;
}
Beispiel #2
0
int
odftread()
{
    if (Already_read)
	return(0);
    Already_read = TRUE;
    if (!Vflag) {
	/*
	 * table is hard-coded for "FACE" FMLI 
	 */
	register int i;

	for (i = 0; i < MAXODFT && FMLI_detab[i].objtype[0] != '\0';i++)
	    Detab[i] = FMLI_detab[i];
	Detab[i].objtype[0] = '\0';
    }
    else {
	register int i, moffset;
	char *p, *q, buf[PATHSIZ];
	char *b;
	char	*tmpstr;
	FILE *fp;
	int offset = 0, magic;
	long magic_offset[MAXMAGIC+1];
	char magic_bytes[MAXMAGIC];
	char	*get_skip();
	char	*tab_parse();
	long	tab_long();

	p = expand("$OASYS/info/OH/externals/detect.tab");
	fp = fopen(p, "r");
	free(p);
	if (fp == NULL)
	    fatal(MISSING, "detect.tab");
	tmpstr = NULL;
	while (get_skip(buf, PATHSIZ, fp) != NULL) {
	    /* flush optional line number */
	    for (b = buf; *b == '\t' || isdigit(*b); b++)
		;
	    b = tab_parse(&tmpstr, b);
	    strncpy(Detab[offset].objtype, tmpstr, OTYPESIZ);
	    if (b) {
		char	*unbackslash();

		b = tab_parse(&Detab[offset].defodi, b);
		p = unbackslash(Detab[offset].defodi);
		if (p[0] == '"')
		    memshift(p, p + 1, strlen(p));
		p += strlen(p) - 1;
		if (p[0] == '"')
		    p[0] = '\0';
	    }
	    Detab[offset].defmask = tab_long(&b, 16);
	    if (b && *b)
		Detab[offset].func_type = tab_long(&b, 16);
	    else {
#ifdef _DEBUG
		_debug(stderr, "BAD ODFT '%s'\n", Detab[offset].objtype);
#endif
		error(MUNGED, "heuristics table");
		continue;
	    }
	    switch (Detab[offset].func_type) {
	    case F_INT:
		Detab[offset].intern_func = tab_long(&b, 0);
		break;
	    case F_SHELL:
	    case F_EXEC:
		b = tab_parse(&tmpstr, b);
		Detab[offset].extern_func = tmpstr;
		tmpstr = NULL;
		break;
	    case F_PARTS:
	    case F_DPARTS:
		break;
	    case F_MAGIC:
		p = b;
		magic = 0;
		while (*p && magic < MAXMAGIC) {
		    moffset = strtol(p, &q, 0);
		    if (p == q)	/* strtol failed */
			break;
		    p = q;
		    while (*q && isspace(*q))
			q++;
		    if (*q == '"') {
			q++;
			while (*q && *q != '"' && magic < MAXMAGIC-1) {
			    magic_bytes[magic] = *q;
			    magic_offset[magic] = moffset++;
			    magic++;
			    q++;
			}
			if (*q)
			    q++;
		    } else {
			magic_offset[magic] = moffset;
			magic_bytes[magic] = (char) strtol(p,&q,0);
			if (p == q) {
			    p = '\0';
			    break;
			} else
			    p = q;
			magic++;
		    }
		}
		if (magic == 0) {
#ifdef _DEBUG
		    _debug(stderr, "BAD ODFT '%s' MAGIC: %s\n", Detab[offset].objtype, q);
#endif
		    error(MUNGED, "heuristics magic number");
		    continue;
		}
		magic_offset[magic] = -1L;

		/* for efficiency, the most common magic number
		 * case, 0, 1, -1, is coded up.
		 */

		if (magic == 2 && magic_offset[0] == 0L &&
		    magic_offset[1] == 1L) {
		    Detab[offset].magic_offset = &(Normal_mag_offset[0]);
		}
		else {
		    Detab[offset].magic_offset = (long *)calloc(magic+1, sizeof(long));
		    for (i = 0; i < magic+1; i++)
			Detab[offset].magic_offset[i] = magic_offset[i];
		}
		Detab[offset].magic_bytes = calloc(magic, sizeof(char));
		for (i = 0; i < magic; i++)
		    Detab[offset].magic_bytes[i] = magic_bytes[i];
		break;
	    default:
#ifdef _DEBUG
		_debug(stderr, "ODFT '%s' BAD FUNCTION: %d\n", Detab[offset].objtype, Detab[offset].func_type);
#endif
		error(MUNGED, "heuristics table function");
		continue;
	    }
	    offset++;
	}
	fclose(fp);
	Detab[offset].objtype[0] = '\0';
	if (tmpstr)
	    free(tmpstr);
    }
    return(0);
}