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

📄 calls.c

📁 ftam等标准协议服务器和客户端的源代码。
💻 C
📖 第 1 页 / 共 2 页
字号:
#ifndef lintstatic char *rcsid = "$Header: /xtel/isode/isode/others/quipu/uips/pod/RCS/calls.c,v 9.0 1992/06/16 12:44:54 isode Rel $";#endif/* * $Header: /xtel/isode/isode/others/quipu/uips/pod/RCS/calls.c,v 9.0 1992/06/16 12:44:54 isode Rel $ * * * $Log: calls.c,v $ * Revision 9.0  1992/06/16  12:44:54  isode * Release 8.0 * */#include "quipu/util.h"#include "quipu/common.h"#include "quipu/entry.h"#include "quipu/name.h"#include "quipu/list.h"#include "usr.dirent.h"#include "tailor.h"#include "sequence.h"#include "filt.h"#include "defs.h"#include "util.h"#include <X11/Intrinsic.h>extern mailtype mailformat;extern Attr_Sequence read_types, read_types2, oclass;extern bool photo_on;int typetoggled = 0;int rdn_print(), as_print();char *TidyString();Attr_Sequence get_sorted_attrs();void kill_message(), message();void requestPassword();void parse_duarc();void set_default_type(), make_friendly();void quit();void put_dn_and_password();str_seq dnseq = NULLDS, backseq = NULLDS, showseq = NULLDS;str_seq alias_seq = NULLDS, aliased_dn_seq = NULLDS, password_seq = NULLDS;int entry_number, back_buf_num, dn_number, histlimit = 50;bool read_all_flag = TRUE;bool testing = FALSE;static void make_friendly_aux();char            goto_path[STRINGLEN];         /* Used by the 'G:goto' command*/char            base_path[STRINGLEN];         /* Used by all DS operations   */char 		friendly_base_path[STRINGLEN];char            namestr[STRINGLEN];char            bindpass [STRINGLEN];char            mvalue [STRINGLEN];char   		passwd[STRINGLEN];unsigned int curr_filt = 0;unsigned int filt_num = 0;unsigned int typeindx = 0;filt_struct *filt_arr[MAXTYPES];char	*filtvalue[MAXTYPES];char    *filttype[MAXTYPES];int default_num;int *av_typeindx;int *available_types[MAXTYPES];char *levels[MAXTYPES];int defaults[MAXTYPES];typedef struct friendlyName {  str_seq names;  char fname[256];} *fName;unsigned int fname_num = 0;fName name_map[MAXTYPES];#ifndef NO_STATSextern LLog    *log_stat;#endifextern int sizelimit;extern char *local_dit;DN user_name;char * addobj = NULLCP;Filter search_filter;FILE *config_file;char *file_names[MAXTYPES];char dua_help_dir[SMALLSTRING];char *get_strioid(ptr)     register char *ptr;{  register char *end_ptr;  while(*ptr == '"') ptr++;  while(*ptr != '"') ptr++;  while(*ptr > '9' || *ptr < '0') ptr++;  end_ptr = ptr;  while(*end_ptr != '\n') end_ptr++;  *end_ptr = '\0';  return ptr;}void put_dn_and_password(dn, password, name)     char *dn, *password, *name;{  str_seq alias_list = alias_seq;  int seq_num;  for (seq_num = 1; alias_list != NULLDS;        seq_num++, alias_list = alias_list->next)    if (!lexequ(name, alias_list->dname)) break;      if (alias_list == NULLDS) {    (void) strcpy(dn, name);    *password = '\0';  } else {    (void) strcpy(dn, get_from_seq(seq_num, aliased_dn_seq));    if (get_from_seq(seq_num, password_seq) != NULLCP)      (void) strcpy(password, get_from_seq(seq_num, password_seq));    else      *password = '\0';  }}void user_tailor(){  char *part1, *part2;  char *getenv(), *TidyString(), *SkipSpace();  char *config_dir = "/.duaconfig",       *type_dir = "/filterTypes",       *readTypes = "/readTypes",       *friendlyNames = "/friendlyNames",       *options = "/.duarc",       *typeDefaults = "/typeDefaults";  char user_path[BUFSIZ], read_path[BUFSIZ],        type_path[BUFSIZ], options_path[BUFSIZ],        friendly_path[BUFSIZ], type_defaults_path[BUFSIZ],       dua_config_dir[BUFSIZ];  char stroid_buf[BUFSIZ];  char Read_in_Stuff[STRINGLEN];  extern  char * dsa_address,  	       * myname;  extern  char * tailfile;  register char *str, *sptr, *p, *end;  char save;  DIR *config_directory;  struct dirent  *dir_ent;  int count, n, num;  int tempints[MAXTYPES];#ifndef NO_STATS  ll_hdinit (log_stat,"pod");#endif   /* read dsaptailor file to get address */    dsa_address = NULLCP;   if((config_file = fopen(isodefile(tailfile,0), "r")) == (FILE *) NULL) {     kill_message();     message((Widget) NULL, 	    "Cannot open `dsaptailor' file. Attempting to continue.");   } else {     while(fgets(Read_in_Stuff, sizeof(Read_in_Stuff), config_file) != NULLCP)       if ((*Read_in_Stuff != '#') && (*Read_in_Stuff != '\n') ) 	(void) tai_string (Read_in_Stuff);          (void) fclose(config_file);   }     (void) strcpy(dua_config_dir, isodefile("xd", 0));  (void) strcpy(dua_help_dir, dua_config_dir);  (void) strcat(dua_config_dir, "/duaconfig/");  (void) strcat(dua_help_dir, "/podHelpdir/");  (void) strcpy (user_path, getenv("HOME"));  (void) strcpy(read_path, user_path);  (void) strcpy(type_path, user_path);  (void) strcpy(friendly_path, user_path);  (void) strcpy(type_defaults_path, user_path);  (void) strcat(read_path, config_dir);  (void) strcat(read_path, readTypes);  (void) strcat(type_path, config_dir);  (void) strcat(type_path, type_dir);  (void) strcat(friendly_path, config_dir);  (void) strcat(friendly_path, friendlyNames);  (void) strcat(type_defaults_path, config_dir);  (void) strcat(type_defaults_path, typeDefaults);	  if (testing) {    (void) strcpy(type_path, "./Xd/duaconfig/");    (void) strcat(type_path, type_dir);    if (!(config_directory = opendir(type_path))) {      (void) fprintf(stderr, 		"File error! Test pod should be run from source directory!\n");      quit(1);    }  } else {    if (!(config_directory = opendir(type_path))) {      (void) strcpy(type_path, dua_config_dir);      (void) strcat(type_path, type_dir);      if(!(config_directory = opendir(type_path))) {	(void) fprintf(stderr, "Can't find directory %s!\n", type_dir);	quit(1);      }    }  }  rewinddir(config_directory);  filt_num = 0;  while(dir_ent = readdir(config_directory)) {    if (!(strncmp(dir_ent->d_name, "Type_", 5))) {      file_names[filt_num] = 	(char *) malloc((unsigned int) 			(strlen(dir_ent->d_name) + 			strlen(type_path) + 2));      (void) strcpy(file_names[filt_num], type_path);      (void) strcat(file_names[filt_num], "/");      (void) strcat(file_names[filt_num], dir_ent->d_name);      filt_num++;    }  }  (void) closedir(config_directory);  if (testing) {    (void) strcpy(options_path, "./Xd/duaconfig/duarc");    parse_duarc(options_path);  } else {    (void) strcpy(options_path, dua_config_dir);    (void) strcpy(options_path, "duarc");    parse_duarc(options_path);  }   (void) strcpy(options_path, user_path);  (void) strcat(options_path, options);  parse_duarc(options_path);   if (testing) {    (void) strcpy(read_path, "./Xd/duaconfig/");    (void) strcat(read_path, readTypes);    if (!(config_file = fopen(read_path, "r"))) {      (void) fprintf(stderr, "File error! Test pod must be run from source directory!\n");      quit(1);    }  } else {    if (!(config_file = fopen(read_path, "r"))) {      (void) strcpy(read_path, dua_config_dir);      (void) strcat(read_path, readTypes);      if (!(config_file = fopen(read_path, "r"))) {	(void) fprintf(stderr, "Can't find read file (%s)!\n", read_path);	quit(1);      }    }  }    while(fgets(Read_in_Stuff, STRINGLEN, config_file) != 0) {    (void) strcpy(stroid_buf, get_strioid(Read_in_Stuff));    if (*stroid_buf) {      if (!read_types)	read_types = as_comp_new(AttrT_new(stroid_buf), NULLAV, NULLACL_INFO);      else {	read_types2 = as_comp_new(AttrT_new(stroid_buf), NULLAV, NULLACL_INFO);	read_types = as_merge(read_types, read_types2);      }    }  }  (void) fclose(config_file);#ifdef USE_PP  /* If they want PP - they want OR names don't they ! */      if (!read_types)	read_types = as_comp_new(AttrT_new("2.6.5.2.6"), 				 NULLAV, NULLACL_INFO);      else {	read_types2 = as_comp_new(AttrT_new("2.6.5.2.6"), 				  NULLAV, NULLACL_INFO);	read_types = as_merge(read_types, read_types2);      }#endif    if (testing) {    (void) strcpy(friendly_path, "./Xd/duaconfig/");    (void) strcat(friendly_path, friendlyNames);    if (!(config_file = fopen(friendly_path, "r"))) {      (void) fprintf(stderr, "File error! Test pod must be run from source directory!\n");      quit(1);    }  } else {    if (!(config_file = fopen(friendly_path, "r"))) {      (void) strcpy(friendly_path, dua_config_dir);      (void) strcat(friendly_path, friendlyNames);      if (!(config_file = fopen(friendly_path, "r"))) {	(void) fprintf(stderr, "Can't find read file (%s)!\n", friendly_path);	quit(1);      }    }  }  name_map[fname_num] = 0;  while(fgets(Read_in_Stuff, STRINGLEN, config_file) != 0) {    if (*Read_in_Stuff != '#') {      sptr = str = Read_in_Stuff;      while (*sptr != ':' && !isspace(*sptr) && sptr != '\0') {	while (!isalnum(*sptr)) sptr++;	str = sptr;	while (*str != ' ' && *str != ',' && *str != ':') str++;	save = *str;	*str = '\0';	if (!name_map[fname_num]) {	  name_map[fname_num] = (fName) malloc(sizeof(struct friendlyName));	  name_map[fname_num]->names = 0;	}	add_seq(&name_map[fname_num]->names, sptr);	*str = save;	sptr = str;	while (*sptr != ',' && *sptr != ':') sptr++;      }      while (!isalpha(*sptr) && *sptr != '\0') sptr++;      str = sptr;      while (*str != '\0' && *str != '\n') str++;      *str = '\0';      if (name_map[fname_num]) {	(void) strcpy(name_map[fname_num]->fname, sptr);	fname_num++;	name_map[fname_num] = 0;      }    }  }  for (curr_filt = 0; curr_filt < filt_num; curr_filt++) {    if (!(config_file = fopen(file_names[curr_filt], "r"))) {      (void) fprintf(stderr, "Can't find file %s!\n", file_names[curr_filt]);      quit(1);    }    filt_arr[curr_filt] = (filt_struct  *) NULL;    filtvalue[curr_filt] = (char *) malloc(STRINGLEN);    *filtvalue[curr_filt] = '\0';        (void) yyparse();    (void) fclose(config_file);  }  filttype[curr_filt] = NULLCP;  for (count = 0; count < filt_num; count++)    free(file_names[count]);  if (testing) {    (void) strcpy(type_defaults_path, "./Xd/duaconfig/");    (void) strcat(type_defaults_path, typeDefaults);    if (!(config_file = fopen(type_defaults_path, "r"))) {      (void) fprintf(stderr, "File error! Test pod must be run from source directory.\n");      quit(1);    }  } else {    if (!(config_file = fopen(type_defaults_path, "r"))) {      (void) strcpy(type_defaults_path, dua_config_dir);      (void) strcat(type_defaults_path, typeDefaults);      if (!(config_file = fopen(type_defaults_path, "r"))) {	(void) fprintf(stderr, "File error! Can't find typeDefaults file.\n");	quit(1);      }    }  }  default_num = 0;  while (fgets (Read_in_Stuff, STRINGLEN, config_file) != 0) {    p = SkipSpace(Read_in_Stuff);    if (( *p == '#') || (*p == '\0'))      continue;        part1 = p;    if ((part2 = index (p,':')) == NULLCP)      continue;        end = part2 - 1;    while (isspace(*end)) end--;    *++end = '\0';    *part2++ = '\0';    while (isspace(*part2)) part2++;    end = part2;    while (!isspace(*end) && *end != ',' && *end != ':') end++;    count = 0;    while (*part2 != ':') {      n = 0;      while (n < filt_num && strncmp(filttype[n], 				     part2, (int) (end - part2))) n++;            if (n == filt_num) {	(void) fprintf(stderr, "Parsing error in typeDefaults file!");	quit(1);      } else {	tempints[count] = n;	count++;	part2 = end;	while (!isalpha(*part2) && *part2 != ':' && part2 != '\0') part2++;	if (*part2 == '\0') {	  (void) fprintf(stderr, "Parsing error in typeDefaults file!");	  quit(1);	} 	if (*part2 != ':') {	  while (!isalpha(*part2)) part2++;	  end = part2;	  while (!isspace(*end) && *end != ',' && 		 *end != ':' && *end != '\0') end++;	  if (*end == '\0') {	    (void) fprintf(stderr, "Parsing error in typeDefaults file!");	    quit(1);	  }	} else end = part2;      }    }    if (*end == ':') {      while(isspace(*++end));      p = end;      while(!isspace(*++end));      *end = '\0';      n = 0;      while (n < filt_num && strcmp(filttype[n], p)) n++;            if (n == filt_num) {	(void) fprintf(stderr, "Parsing error in typeDefaults file!");	quit(1);      } else {	num = 0;	while (num < count && n != tempints[num]) num++;	if (num == count) {	  (void) fprintf(stderr, "Parsing error in typeDefaults file!");	  quit(1);	}      }      defaults[default_num] = n;      levels[default_num] = malloc((unsigned int) (strlen(part1) + 1));      (void) strcpy(levels[default_num], part1);      available_types[default_num] = 	(int *) malloc((unsigned int) (sizeof(int) * (count+1)));      for (n = 0; n < count; n++)	available_types[default_num][n] = tempints[n];            available_types[default_num][n] = -1;      default_num++;    }  }  (void) fclose(config_file);}void parse_duarc(options_path)     char *options_path;{  char *SkipSpace(), *TidyString();  char *p, *part1, *part2, *part3;  char Read_in_Stuff[BUFSIZ];  extern char *myname;  if ((config_file = fopen (options_path, "r")) == 0);  else {    while (fgets (Read_in_Stuff, STRINGLEN, config_file) != 0) {      p = SkipSpace (Read_in_Stuff);      if (( *p == '#') || (*p == '\0'))	continue;  /* ignore comments and blanks */            part1 = p;      if ((part2 = index (p,':')) == NULLCP) 	continue; /* ignore it */            *part2++ = '\0';      part2 = TidyString(part2);            if ((lexequ(part1, "username") == 0) && *namestr == '\0')	(void) strcpy (namestr, part2);      else if ((lexequ(part1, "password") == 0) && *passwd == '\0') 	(void) strcpy (passwd, part2);      else if (lexequ(part1, "prefergreybook") == 0) {	if (*part2 != '\0' && lexequ(part2, "TRUE") != 0)	  mailformat = rfc822;	else 	  mailformat = greybook;

⌨️ 快捷键说明

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