⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getcmd.c

📁 <B>Digital的Unix操作系统VAX 4.2源码</B>
💻 C
📖 第 1 页 / 共 3 页
字号:
	        (strncmp(parm->next_parm->parm_string,"s:",2) != 0) &&		(strncmp(parm->next_parm->parm_string,"e:",2) != 0))		{		parm = parm->next_parm;		(void)strcat(pstring,",");		(void)strcat(pstring,parm->parm_string);		}	    if ((datetime = asctotime(pstring+2)) == UE$NULL)	        return(UE$ERR_INVPAR);	    if      ((strncmp(pstring,"s:",2)) == 0)	        pars_node = es$parse(&status, DD$datetime, "ge %d",datetime);	    else if ((strncmp(pstring,"e:",2)) == 0)	        pars_node = es$parse(&status, DD$datetime, "le %d",datetime);	    else 	        return(UE$ERR_INVPAR);	    if (status != ES$SUCC)	        return(UE$ERR_INVPAR);	    BLD_NODE (pars_node,ES$AND,flag_node);	    }        while ((parm = parm->next_parm) != UE$NULL);        BLD_NODE (flag_node,ES$AND,sel_tree);	}    else	return(UE$ERR_INVPAR);    }if (sel_tree != UE$NULL)    es$select(&uctx,ES$REMEMBER,sel_tree);    /****************************************************************/return(UE$SUCC);}/*...	ENDFUNCTION valid_gen					*//****************************************************************//********** GET_DEVTYPE *****************************************//****************************************************************/SELNODE *get_devtype(label,status)char *label;long  *status;{DD$STD_ITEMS_DSD_PTR	find_std_item_dsd();DD$STD_CODES_DSD_PTR	find_std_code_dsd();char			*dsd_get_label();DD$STD_ITEMS_DSD_PTR	std_item_dsd_ptr;DD$STD_CODES_DSD_PTR	std_code_dsd_ptr;short item_cnt;short next_code;SELNODE *mult_node;SELNODE *one_node;short i, j;short len;long  stat;long  pcode;short len_label;char  *code_label_ptr;char  code_label[UE$XFF];char  item[UE$XFF];mult_node = one_node = UE$NULL;len = strlen(label);if (len < 2)    {    *status = UE$ERR_INVPAR;    return (one_node);    }for (i = 0; i < len; i++)    item[i] = toupper(label[i]);if ((std_item_dsd_ptr = find_std_item_dsd(DD$devtype)) == DD$UNKNOWN_ITEM)    {    *status = UE$ERR_DEVTBL;    return (mult_node);    }item_cnt = std_item_dsd_ptr->COUNT;for (next_code = 0; next_code < item_cnt; next_code++)    {    if ((std_code_dsd_ptr = find_std_code_dsd(std_item_dsd_ptr, next_code))		== DD$UNKNOWN_CODE)        {        *status = UE$ERR_DEVTBL;        return (mult_node);        }    code_label_ptr = dsd_get_label(std_code_dsd_ptr->LABEL_IX);    len_label = strlen(code_label_ptr);    for (i = 0, j = 0; i < len_label; i++)	{	if (code_label_ptr[i] != ' ')	    code_label[j++] = toupper(code_label_ptr[i]);	}    code_label[j] = '\0';    if ((len >= 4) && (len != j))	continue;    if (strncmp(item,code_label,len) == 0)	{	pcode = std_code_dsd_ptr->CODE;	one_node = es$parse(&stat, DD$devtype, "eq %d",pcode);	if (stat != ES$SUCC)	    {	    *status = UE$ERR_INVPAR;	    return (mult_node);	    }	BLD_NODE (one_node,ES$OR,mult_node);	}    }if (mult_node == UE$NULL)    {    *status = UE$ERR_INVPAR;    return(mult_node);    }*status = UE$SUCC;return(mult_node);}/**	.SBTTL	help - UERF help routine*++* FUNCTIONAL DESCRIPTION:		**	-  Displays the file "uerf.hlp"*	*	* FORMAL PARAMETERS:		***** IMPLICIT INPUTS:		NONE** IMPLICIT OUTPUTS:		NONE** COMPLETION STATUS:		NONE** SIDE EFFECTS:			NONE**--*//*...	FUNCTION help				*/help (){FILE *fpt;char line[UE$XFF];extern char  search_path[];char  *find_file();char  hlp_file[UE$XFF];printf(UE$HELP_HDR);strcpy(hlp_file,find_file(UE$HLP_FILE));if (strlen(hlp_file) == 0)    {    return(UE$ERR_NOHLP);    }if ((fpt = fopen(hlp_file, "r")) == NULL)    {    return(UE$ERR_H_OPEN);    }while ((fgets(line,UE$XFF,fpt)) != NULL)    {    if ((strncmp(line,"/*",2)) == NULL)	continue;    printf("%s",line);    }return(UE$SUCC);}/*...	ENDFUNCTION help				*//**	.SBTTL	get_tree - Function to find a branch on parse tree*++* FUNCTIONAL DESCRIPTION:		**	-  searches tree structure for branch with particular flag** FORMAL PARAMETERS:		value of the flag (short)** IMPLICIT INPUTS:		none** IMPLICIT OUTPUTS:		none** COMPLETION STATUS:		pointer to tree branch if successful*				UE$NULL if failure** SIDE EFFECTS:			NONE**--*//*...   FUNCTION get_tree(fl)					*/struct parse_tree *get_tree(fl)char  fl;{struct parse_tree *tree;if (in_st.root != UE$NULL)    {	    tree = in_st.root;    while (tree != UE$NULL)		/* go down the chain	*/	{	if (tree->flag[0] == fl)	    return(tree);	tree = tree->next_tree;	}    }tree = UE$NULL;return(tree);}/*...   ENDFUNCTION get_tree					*//**	.SBTTL	asctotime - Function to change ascii time to *			    unsigned long.*++* FUNCTIONAL DESCRIPTION:		**   asctotime() converts an ascii string that contains a*   date and time into the number of seconds since 31-dec-1969 midnight.*   This is stored as an unsigned longword integer.*   The ascii string must be in one of the following formats:**    complete date/time:*			dd-mmm-yyyy,hh:mm:ss*    partial input:*			dd-mmm-yyyy*			dd-mmm-yyyy,hh:mm*			dd-mmm-yyyy,hh**			dd-mmm*			dd-mmm,hh:mm*			dd-mmm,hh**			dd,hh:mm*			dd,hh**			hh:mm:ss*			hh:mm*			hh**    partial date/time will be or'd with today's date and 00:00:00 time.***   where*	    mmm :  is 3 character month abbreviation (must be lower case)**   The function returns 0 if the date/time is invalid.*   The year of the date must be between 1970 and 2099 inclusive.*** FORMAL PARAMETERS:		date and time** IMPLICIT INPUTS:		none** IMPLICIT OUTPUTS:		none** COMPLETION STATUS:		unsigned longword containing seconds*				since 31 Dec 1969.*				UE$NULL if failure** SIDE EFFECTS:			NONE**--*//*...   FUNCTION asctotime(date)		*/#define ISLEAP(y) (((((y)%4) == 0) && (((y)%100) != 0)) || (((y)%400) == 0))unsigned long asctotime(asc_date)char *asc_date;{struct tm	 *tp;struct timeval	 tv;struct timezone  tz;short i;unsigned long    t;unsigned long    parsetime();gettimeofday(&tv,&tz);tp = localtime(&(tv.tv_sec));if (parsetime(asc_date,tp) != UE$SUCC)    return(UE$NULL);i =  (tp->tm_year - 70);		/* full years since 70	*/t =  (i * 365);				/* days in those years	*/t += ((i + 2) / 4);			/* plus 1 per leap year	*/if (ISLEAP(tp->tm_year+1900))    t--;t += tp->tm_yday;			/* full days this year	*/t =  (t * 86400) +			/* secs in day	*/     (tp->tm_hour * 3600) +		/* secs in hour	*/     (tp->tm_min * 60) +		/* secs in min	*/     (tp->tm_sec) +     (tz.tz_minuteswest * 60); 		/* correct GMT	*/tp = localtime(&t);t -= (tp->tm_isdst * 3600);		/* correct DST	*/return(t);}/*...   ENDFUNCTION asctotime()			*//**	.SBTTL	parsetime - Function to convert ascii time to *			    its integer components.*++* FUNCTIONAL DESCRIPTION:		***   parsetime converts an ascii string that contains a*   date and time into its integer components. *   The ascii string must be in one of the following formats:**    complete date/time:*			dd-mmm-yyyy,hh:mm:ss*    partial input:*			dd-mmm-yyyy*			dd-mmm-yyyy,hh:mm*			dd-mmm-yyyy,hh**			dd-mmm*			dd-mmm,hh:mm*			dd-mmm,hh**			dd,hh:mm*			dd,hh**			hh:mm:ss*			hh:mm*			hh**    partial date/time will be or'd with today's date and 00:00:00 time.***   where*	    mmm :  is 3 character month abbreviation (must be lower case)**   this function will either fill in the "struct tm" structure*   or return NULL if given an invalid data/time combination*** FORMAL PARAMETERS:		ascii date and time** IMPLICIT INPUTS:		none** IMPLICIT OUTPUTS:		none** COMPLETION STATUS:		UE$SUCC*				UE$FAIL** SIDE EFFECTS:			NONE**--*//*...   FUNCTION parsetime(tstr, tp)			*/unsigned long parsetime(tstr,tp)char      *tstr;struct tm *tp;{short i;short len;short offset;static char *months[] = { " ",			  "jan", "feb", "mar", "apr",			  "may", "jun", "jul", "aug",			  "sep", "oct", "nov", "dec" };static short daysinmonth[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};tp->tm_sec  = 0;tp->tm_min  = 0;tp->tm_hour = 0;tp->tm_mon++;		/* month is stored in struc as 1 less	*/len = strlen(tstr);offset = 0;/***********  dd-mmm-yyyy,hh:mm:ss  parsing  ********************/i      = strcspn(tstr,",-");		/* split date/time	*//***************  dd-mmm-yyyy  parsing  *************************/if (i < len)    {					/* dd- or dd, present	*/    tp->tm_mday = atoi(tstr);    offset += (i + 1);    if ((tstr[offset - 1]) != ',')	{	for (i = 0; i < 3; i++)	    tstr[offset+i] = tolower(tstr[offset+i]);	for (i = 1; i <= 12; i++)	    {	    if (strncmp(tstr+offset,months[i],3) == 0)		break;	    }	if (i > 12)	    return(UE$FAIL);	tp->tm_mon = i;	i = strcspn(tstr+offset,",-");	offset += (i + 1);	if ((tstr[offset - 1]) == '-')	    {	    tp->tm_year = atoi(tstr+offset);	    if (tp->tm_year > 1900)		tp->tm_year -= 1900;	    if (tp->tm_year < 70)		return(UE$FAIL);	    i = strcspn(tstr+offset,",");	    offset += (i + 1);	    }	}    if (ISLEAP(tp->tm_year+1900))	daysinmonth[2] = 29;    else	daysinmonth[2] = 28;    tp->tm_yday = 0;    if (tp->tm_mday > daysinmonth[tp->tm_mon])	return(UE$FAIL);    for (i = 1; i < tp->tm_mon; i++)	tp->tm_yday += daysinmonth[i];    tp->tm_yday += (tp->tm_mday - 1);    if ((offset) >= len)	return(UE$SUCC);		/* no time input	*/    }/***************  hh:mm:ss  parsing  ****************************/tp->tm_hour = atoi(tstr+offset);if (tp->tm_hour >= 24)    return(UE$FAIL);i = strcspn(tstr+offset,":");if ((offset+i) >= len)    return(UE$SUCC);			/* hh   input		*/offset += (i + 1);tp->tm_min = atoi(tstr+offset);if (tp->tm_min >= 60)    return(UE$FAIL);i = strcspn(tstr+offset,":");if ((offset+i) >= len)    return(UE$SUCC);			/* hh:mm   input	*/offset += (i + 1);tp->tm_sec = atoi(tstr+offset);if (tp->tm_sec >= 60)    return(UE$FAIL);return(UE$SUCC);			/* hh:mm:ss   input	*/}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -