nfs-ganesha 1.4
|
00001 #include <stdio.h> 00002 #include <errno.h> 00003 #include <string.h> 00004 #include <stdlib.h> 00005 #include "Connectathon_config_parsing.h" 00006 #include "Connectathon_parser_yacc.h" 00007 00008 extern FILE *yyin; 00009 struct testparam *param; 00010 00011 extern int yyparse(); 00012 00013 /*********** For building structure from config file ***********/ 00014 void btest_init_defaults(struct btest *b) 00015 { 00016 memset(b, 0, sizeof(struct btest)); 00017 00018 b->num = -1; 00019 b->num2 = -1; 00020 00021 b->levels = -1; 00022 b->files = -1; 00023 b->dirs = -1; 00024 b->count = -1; 00025 b->size = -1; 00026 b->blocksize = -1; 00027 00028 b->bigfile = "bigfile"; 00029 00030 b->fname = "file."; 00031 b->dname = "dir."; 00032 b->nname = "newfile."; 00033 b->sname = "/this/is/a/symlink"; 00034 } 00035 00036 void testparam_init_defaults(struct testparam *t) 00037 { 00038 memset(t, 0, sizeof(struct testparam)); 00039 00040 t->dirtest = "/path/to/dir/test"; 00041 } 00042 00043 void free_btest(struct btest *b) 00044 { 00045 if(b->nextbtest != NULL) 00046 free_btest(b->nextbtest); 00047 free(b); 00048 return; 00049 } 00050 00051 void free_testparam(struct testparam *t) 00052 { 00053 free_btest(t->btest); 00054 free(t); 00055 return; 00056 } 00057 00058 /************************ For parsing **************************/ 00059 00060 char *get_test_directory(struct testparam *t) 00061 { 00062 return t->dirtest; 00063 } 00064 00065 char *get_log_file(struct testparam *t) 00066 { 00067 return t->logfile; 00068 } 00069 00070 struct btest *get_btest_args(struct testparam *param, enum test_number k) 00071 { 00072 struct btest *it = param->btest; 00073 00074 while(it) 00075 { 00076 if(it->num == k || it->num2 == k) 00077 return it; 00078 it = it->nextbtest; 00079 } 00080 00081 return NULL; 00082 } 00083 00084 struct testparam *readin_config(char *fname) 00085 { 00086 if((yyin = fopen(fname, "r")) == NULL) 00087 { 00088 fprintf(stderr, "can't open %s: %s\n", fname, strerror(errno)); 00089 return NULL; 00090 } 00091 00092 if(yyparse() != 0) 00093 { 00094 fprintf(stderr, "error parsing or activating the config file: %s\n", fname); 00095 return NULL; 00096 } 00097 00098 fclose(yyin); 00099 return param; 00100 }