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

📄 validate.c

📁 Solaris操作系统下的过滤驱动程序, C源码程序.
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (c) 1997-2003 Erez Zadok * Copyright (c) 2001-2003 Stony Brook University * Copyright (c) 1997-2000 Columbia University * * For specific licensing information, see the COPYING file distributed with * this package, or get one from ftp://ftp.filesystems.org/pub/fist/COPYING. * * This Copyright notice must be kept intact and distributed with all * fistgen sources INCLUDING sources generated by fistgen. *//* * validate.c: Validate fist syntax. * Fistgen sources. */#ifdef HAVE_CONFIG_H# include <config.h>#endif /* HAVE_CONFIG_H *//****************************************************************************//* * List of valid fist rule definition components: callset, optype, and part. */char *valid_rule_callsets[] = {  "op",  "ops",  "readops",  "writeops",  NULL				/* must be last entry */};char *valid_rule_optypes[] = {  "all",  "data",  "name",  /* the rest of the ops mirror the NFS v.2 protocol */  "create",  "getattr",  "lstat",  "stat",  "link",  "lookup",  "mkdir",  "read",  "readdir",  "readlink",  "rename",  "rmdir",  "setattr",  "statfs",  "symlink",  "unlink",  "write",  /* now some more ops that correspond to certain system calls */  "ioctl",  NULL				/* must be last entry */};char *valid_rule_parts[] = {  "precall",  "call",  "postcall",  NULL				/* must be last entry */};/****************************************************************************//* * Validate accessmode, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_accessmode(const char *str){  if (STREQ(str, "readonly")) {    fist_globals.fg_accessmode = FF_ACCESSMODE_READONLY;    return TRUE;  }  if (STREQ(str, "writeonly")) {    fist_globals.fg_accessmode = FF_ACCESSMODE_WRITEONLY;    return TRUE;  }  if (STREQ(str, "readwrite")) {    fist_globals.fg_accessmode = FF_ACCESSMODE_READWRITE;    return TRUE;  }  return FALSE;}/* * Validate debug flag, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_debug(const char *str){  if (STREQ(str, "on")) {    fist_globals.fg_debug = 1;    return TRUE;  }  if (STREQ(str, "off")) {    fist_globals.fg_debug = 0;    return TRUE;  }  return FALSE;}/* * Validate dynamic_inode_numbers flag, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_dynamic_inode_numbers(const char *str){  if (STREQ(str, "on")) {    fist_globals.fg_dynamic_inode_numbers = 1;    return TRUE;  }  if (STREQ(str, "off")) {    fist_globals.fg_dynamic_inode_numbers = 0;    return TRUE;  }  return FALSE;}/* * Validate filter names, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_filter(const char *str){  if (STREQ(str, "data")) {    fist_globals.fg_filter |= FF_FILTER_DATA;    return TRUE;  }  if (STREQ(str, "name")) {    fist_globals.fg_filter |= FF_FILTER_NAME;    return TRUE;  }  if (STREQ(str, "sca")) {    fist_globals.fg_filter |= FF_FILTER_SCA; /* size changing algorithm */    return TRUE;  }  return FALSE;}/* * Validate mntstyle flag, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_mntstyle(const char *str){  if (STREQ(str, "regular")) {    fist_globals.fg_mntstyle = FF_MNTSTYLE_REGULAR;    return TRUE;  }  if (STREQ(str, "overlay")) {    fist_globals.fg_mntstyle = FF_MNTSTYLE_OVERLAY;    return TRUE;  }  if (STREQ(str, "attach")) {    fist_globals.fg_mntstyle = FF_MNTSTYLE_ATTACH;    return TRUE;  }  return FALSE;}/* * Validate fanout, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_fanout(int fo){  if (fo < 1 || fo > MAX_FAN_OUT)    return FALSE;  fist_globals.fg_fanout = fo;  return TRUE;}/* * Validate encoding-type, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_encoding_type(const char *str){  if (STREQ(str, "none")) {    fist_globals.fg_encoding_type = FF_ENCODING_TYPE_NONE;    return TRUE;  }  if (STREQ(str, "stream")) {    fist_globals.fg_encoding_type = FF_ENCODING_TYPE_STREAM;    return TRUE;  }  if (STREQ(str, "block")) {    fist_globals.fg_encoding_type = FF_ENCODING_TYPE_BLOCK;    return TRUE;  }  return FALSE;}/* * Validate encoding-blocksize, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_encoding_blocksize(int ebs){  if (ebs < 1 || ebs > MAX_ENCODING_BLOCKSIZE)    return FALSE;  fist_globals.fg_encoding_blocksize = ebs;  return TRUE;}/* * Validate errorcodes, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_errorcode(const char *str, char *errmsg){  int cur = fist_globals.fg_num_errorcodes;  int i;  /* check if exceeded maximum number of error codes */  if (cur >= MAX_ERRORCODES) {    sprintf(errmsg, "too many error codes (max=%d)", MAX_ERRORCODES);    return FALSE;  }  /* check if error code is already defined */  if (cur > 0)    for (i=0; i<cur; i++) {      if (STREQ(str, fist_globals.fg_errorcodes[i])) {	strcpy(errmsg, "duplicate error code");	return FALSE;      }    }  /* all is well */  fist_globals.fg_errorcodes[cur] = strdup(str);  fist_globals.fg_num_errorcodes++; /* increment */  //  fprintf(out_fp_h, "#define %s (LAST_OS_ERRNO+%d)\n", str, cur+1);  return TRUE;}/* * Validate module sources, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_msources(const char *str, char *errmsg){  int cur = fist_globals.fg_num_msources;  int i;  /* check if exceeded maximum number of error codes */  if (cur >= MAX_SOURCES) {    sprintf(errmsg, "too many additional module sources (max=%d)", MAX_SOURCES);    return FALSE;  }  /* check if error code is already defined */  if (cur > 0)    for (i=0; i<cur; i++) {      if (STREQ(str, fist_globals.fg_msources[i])) {	sprintf(errmsg, "duplicate module source file: %s", str);	return FALSE;      }    }  /* check if really a .c file */  if (!STREQ(&str[strlen(str)-2], ".c")) {    sprintf(errmsg, "not a C source file: %s", str);    return FALSE;  }  /* all is well */  fist_globals.fg_msources[cur] = strdup(str);  fist_globals.fg_num_msources++; /* increment */  return TRUE;}/* * Validate module headers, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_mheaders(const char *str, char *errmsg){  int cur = fist_globals.fg_num_mheaders;  int i;  /* check if exceeded maximum number of error codes */  if (cur >= MAX_SOURCES) {    sprintf(errmsg, "too many additional module headers (max=%d)", MAX_SOURCES);    return FALSE;  }  /* check if error code is already defined */  if (cur > 0)    for (i=0; i<cur; i++) {      if (STREQ(str, fist_globals.fg_mheaders[i])) {	sprintf(errmsg, "duplicate module source file: %s", str);	return FALSE;      }    }  /* check if really a .c file */  if (!STREQ(&str[strlen(str)-2], ".h")) {    sprintf(errmsg, "not a C header file: %s", str);    return FALSE;  }  /* all is well */  fist_globals.fg_mheaders[cur] = strdup(str);  fist_globals.fg_num_mheaders++; /* increment */  return TRUE;}/* * Validate user-level sources, and perform necessary actions. * Return TRUE/FALSE. */intfist_validate_decl_usources(const char *str, char *errmsg){  int cur = fist_globals.fg_num_usources;  int i, len;  char *cp;  /* check if exceeded maximum number of error codes */  if (cur >= MAX_SOURCES) {    sprintf(errmsg, "too many additional user-level sources (max=%d)", MAX_SOURCES);    return FALSE;  }  /* check if error code is already defined */  if (cur > 0)    for (i=0; i<cur; i++) {      if (STREQ(str, fist_globals.fg_usources[i])) {	sprintf(errmsg, "duplicate user-level source file: %s", str);	return FALSE;      }    }  /* valid sources end with .h or .c */  len = strlen(str);  if (len < 3) {    sprintf(errmsg, "invalid length foe C source/header file name: %s", str);

⌨️ 快捷键说明

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