/* test_path_info. WJS Aug 97 */ /* Tests path_info_routines 1.2. */ /* To use, setenv PATH_INFO string. test_path_info tries to */ /* get several fields, then replaces several fields. See code. */ /* 20 Apr 99. Fool w/putenv. Involves fooling w/getenv, too. WJS */ #include /* Try to get our own putenv in here which doesn't actually change */ /* env vars. Therefore, DON'T include stdlib */ int putenv(string) char *string; { printf("%s\n",string); return 1; } int get_level(); char *get_options(); char *get_object(); char *get_protocol(); char *get_jgofs_env_datum(); char *make_PATH_INFO_putenv_string(); char *temp_getenv(); void temp_exit(); main() { int reqlevel; char *proto,*proto1,*object,*options,*object1,*options1,*dir,*xxx,*ir,*jg; printf("\n\n-------- PATH_INFO = %s\n",temp_getenv("PATH_INFO")); /* Get level */ reqlevel = get_level(NULL); /* Get protocol, both old and new ways */ proto = get_protocol(NULL); proto1 = get_jgofs_env_datum("protocol",NULL); /* Get object, both old and new ways */ object = get_object(NULL); object1 = get_jgofs_env_datum("object",NULL); /* Get whole options string, both old and new ways */ options = get_options(NULL); options1 = get_jgofs_env_datum("options",NULL); /* Get 4 hard-coded fields from options string. If options */ /* string happens to contain */ /* dir=/wherever/jg/dir */ /* and no xxx=, ir=, or jg=, these test for valid key, invalid key, */ /* invalid key present as part of data & invalid key as part of */ /* another key */ dir = get_jgofs_env_datum("dir",NULL); xxx = get_jgofs_env_datum("xxx",NULL); jg = get_jgofs_env_datum("jg",NULL); /* usually part of dir= string */ ir = get_jgofs_env_datum("ir",NULL); /* as in dir= */ printf("\nobject = %s (object via get_datum = %s)\n",object,object1); printf("level = %d; protocol = %s (protocol via get_datum =%s)\n", reqlevel,proto,proto1); printf("options = %s\n (options via get_datum = %s)\n",options,options1); printf("\ndir (from options) = %s; xxx (from options) = %s\n",dir,xxx); printf("\n Next 2 should be null\n"); printf("ir (from options) = %s; jg (from options) = %s\n\n",ir,jg); printf("\n Default for all tests: replace protocol & level; default rest\n"); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"foof",9,NULL)); printf("\n Tests: no env var name; replace env var name\n"); printf(":%s\n",make_PATH_INFO_putenv_string("",NULL,NULL,"foof",9,NULL)); printf(":%s\n",make_PATH_INFO_putenv_string("XXX",NULL,NULL,"foof",9,NULL)); printf("\n Tests: default protocol; no protocol (error) \n"); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,NULL,9,NULL)); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"",9,NULL)); printf("\n Tests: default level; no level\n"); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"foof",-999,NULL)); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"foof",-1,NULL)); printf("\n Tests: replace options; no options\n"); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"foof",9,"myopt=5")); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,NULL,"foof",9,"")); printf("\n Tests: replace object; no object\n"); printf(":%s\n", make_PATH_INFO_putenv_string(NULL,NULL,"//wjs.whoi.edu/wjs","foof",9,NULL)); printf(":%s\n",make_PATH_INFO_putenv_string(NULL,NULL,"","foof",9,NULL)); temp_exit(0); }