📄 cvaltype.c
字号:
/* CXL - Copyright (c) 1987-1989 by Mike Smedley - All Rights Reserved */
/* CVALTYPE.C - determines if a character is a valid for a given CXL type */
#include <ctype.h>
#include <string.h>
#include "cxldef.h"
#include "cxlstr.h"
static char bad_filechars[]="*?;,=+<>|/[]\"";
int cvaltype(int ch,int ctype)
{
register int valid=NO;
switch(ctype) {
case '9': /* is char type = float? */
if( ch=='.' || ch=='+' || ch=='-' ) {
valid=YES;
break;
}
case '#': /* is char type = numeric? */
if( ch>='0' && ch<='9' ) valid=YES;
break;
case '%': /* is char=numeric or space? */
if( (ch>='0' && ch<='9') || ch==' ' ) valid=YES;
break;
case 'A': /* is char type = alpha? */
case 'L': /* is type = tolower alpha? */
case 'M': /* is type = tomixed alpha? */
case 'U': /* is type = toupper alpha? */
if( isalpha(ch) || ch==' ' ) valid=YES;
break;
case 'D':
if( isdigit(ch) || ch=='-' || ch=='/' ) valid=YES;
break;
case 'F': /* legal file name character */
if(strchr(bad_filechars,ch)==NULL) valid=YES;
break;
case 'W': /* file name character w/wildcard */
if(strchr(bad_filechars+2,ch)==NULL) valid=YES;
break;
case 'H': /* is char type = hexadecimal? */
if( isdigit(ch) || (ch>='A'&&ch<='F') || (ch>='a'&&ch<='f') )
valid=YES;
break;
case 'T': /* is char type = phone num? */
if( isdigit(ch) || ch=='(' || ch==')' || ch=='-' || ch==' ' )
valid=YES;
break;
case 'P': /* is char type = password? */
case 'X': /* is char type = alphanum? */
if( isalnum(ch) || ch==' ' ) valid=YES;
break;
case 'Y': /* is char type = Yes/No? */
if( ch=='Y' || ch=='N' || ch=='y' || ch=='n' ) valid=YES;
break;
case '*': /* is char type = printable? */
if(isprint(ch)) valid=YES;
break;
case '?': /* is char type = anything? */
valid=YES;
break;
default: /* invalid char type */
return(-1);
}
return(valid);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -