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

📄 calls.c

📁 ftam等标准协议服务器和客户端的源代码。
💻 C
📖 第 1 页 / 共 3 页
字号:
/* calls.c - */#ifndef lintstatic char *rcsid = "$Header: /xtel/isode/isode/others/quipu/uips/sd/RCS/calls.c,v 9.0 1992/06/16 12:45:08 isode Rel $";#endif/* * $Header: /xtel/isode/isode/others/quipu/uips/sd/RCS/calls.c,v 9.0 1992/06/16 12:45:08 isode Rel $ */#include "calls.h"#define RESBUF 10000typedef enum {rfc822, greybook} mailtype;mailtype mailformat = rfc822;int scrollize;PS opt;Attr_Sequence read_types = 0, read_types2 = 0, oclass = 0;str_seq curr_dnseq, textseq, back_seq;int current_entry, entry_number, display_entry;int back_buf_num;int rdn_print(), as_print();void quit(), int_quit();void help_back(), help_list(), help_up(), help_number(), help_srch(),      help_cncs();void setwidgets();char bound = FALSE;  /* indication of wether bound */char * TidyString();/* hack to get isode/curses compatability */#if	defined(SVR4) && !defined(SVR4_UCB)#undef WINDOW#else#define WINDOW char#endif#include "widget.h"#include "wdgtdefs.h"extern text_height;int text_state;int histlimit = 20;char testing = FALSE;#define DN_LIST 0#define TEXT 1#define BACK_LIST 3/* These are common operation variables */#define STRINGLEN 1000#define SMALLSTRING 255#define MAXTYPES  255char            goto_path[STRINGLEN];         /* Used by the 'G:goto' command*/char            base_path[STRINGLEN];         /* Used by all DS operations   */char 		friendly_base_path[STRINGLEN];char		friendly_name[STRINGLEN];char            namestr[STRINGLEN];char            cache [STRINGLEN];char            bindpass [STRINGLEN];char            srchvalue[STRINGLEN];         /* Used by search */char            mvalue [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];#ifndef NO_STATSextern LLog    *log_stat;#endif /* These are used as the data for the binding connection */char   passwd[STRINGLEN];extern char *   myname;extern int sizelimit;extern char    *local_dit;DN user_name;char * addobj = NULLCP;Filter search_filter;FILE *config_file;char *file_names[MAXTYPES];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 user_tailor(){  char           *part1;  char           *part2;  char           *getenv ();  char           *ptr = "/.duarc";  char	         *config_dir = "/.duaconfig/";  char           *isode_config_dir = "sd/duaconfig/";  char	         *type_dir = "filterTypes/";  char	         *readTypes = "readTypes";  char           *typeDefaults = "typeDefaults";  char            user_home[BUFSIZ];  char		  read_path[BUFSIZ];  char		  type_path[BUFSIZ];  char            type_defaults_path[BUFSIZ];  char	          stroid_buf[BUFSIZ];  DIR 	         *config_directory;  struct dirent  *dir_ent;    char            Read_in_Stuff[STRINGLEN];  char           *p,   		 *TidyString(),  		 *SkipSpace(),  		 *end;  int             count, n, num;  int     tempints[MAXTYPES];#ifndef NO_STATS  ll_hdinit (log_stat,"sd");#endif  if ((opt = ps_alloc (std_open)) == NULLPS)    fatal (-1,"ps_alloc failed");  if (std_setup (opt,stdout) == NOTOK)    fatal (-1,"std_setup failed");  cache[0] = '\0';  (void) strcpy (user_home, getenv ("HOME"));  (void) strcpy(read_path, user_home);  (void) strcpy(type_path, user_home);  (void) strcpy(type_defaults_path, user_home);    (void) strcat(user_home, ptr);  (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(type_defaults_path, config_dir);  (void) strcat(type_defaults_path, typeDefaults);  if (testing) {    (void) strcpy(type_path, "./sd/duaconfig/");    (void) strcat(type_path, type_dir);    if (!(config_directory = opendir(type_path))) {      (void) fprintf(stderr, "File error! Test sd should be run from source directory!\n");      int_quit(1);    }  } else {    if (!(config_directory = opendir(type_path))) {      (void) strcpy(type_path, isodefile(isode_config_dir,0));      (void) strcat(type_path, type_dir);      if(!(config_directory = opendir(type_path))) {	quit("Can't find directory filterTypes.\n", 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)			(strlen(dir_ent->d_name) + strlen(type_path) + 2));      (void) strcpy(file_names[filt_num], type_path);      (void) strcat(file_names[filt_num], dir_ent->d_name);      filt_num++;    }  }  (void) closedir(config_directory);    if ((config_file = fopen (user_home, "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] == '\0') 	(void) strcpy (namestr, part2);      else if ((lexequ(part1, "password") == 0) && passwd[0] == '\0') 	(void) strcpy (passwd, part2);      else if (lexequ(part1, "prefergreybook") == 0)	mailformat = greybook;      else if (lexequ(part1, "dsap") == 0)	(void) tai_string (part2);      else if (lexequ(part1, "isode") == 0) {	char * split;	if ((split = index(part2,' ')) != NULLCP) {	  *split++ = 0;	(void) isodesetvar(part2,split,0);	}      } else if(strcmp (part1, "service") == 0) 	new_service (part2);      else if (lexequ(part1, "history") == 0) {	(void) sscanf(part2, "%d", &histlimit);	if (histlimit < 1) histlimit = 1;      }    }    isodexport (NULLCP);    (void) fclose(config_file);  }  if (testing) {    (void) strcpy(read_path, "./sd/duaconfig/");    (void) strcat(read_path, readTypes);    if (!(config_file = fopen(read_path, "r"))) {      (void) fprintf(stderr, "File error! Test sd must be run from source directory!\n");      int_quit(1);    }  } else {    if (!(config_file = fopen(read_path, "r"))) {      (void) strcpy(read_path, isodefile(isode_config_dir,0));      (void) strcat(read_path, readTypes);      if (!(config_file = fopen(read_path, "r"))) {	quit("Can't find file readTypes.\n", 1);      }    }  }/*  load_oid_table("oidtable");*/    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      for (curr_filt = 0; curr_filt < filt_num; curr_filt++) {    if (!(config_file = fopen(file_names[curr_filt], "r"))) {      quit("Can't find filter template file\n", 1);    }    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, "./sd/duaconfig/");    (void) strcat(type_defaults_path, typeDefaults);    if (!(config_file = fopen(type_defaults_path, "r"))) {      (void) fprintf(stderr, "File error! Test sd must be run from source directory.\n");      int_quit(1);    }  } else {    if (!(config_file = fopen(type_defaults_path, "r"))) {      (void) strcpy(type_defaults_path, isodefile(isode_config_dir,0));      (void) strcat(type_defaults_path, typeDefaults);      if (!(config_file = fopen(type_defaults_path, "r"))) {	(void) strcpy(type_defaults_path, "./sd/duaconfig/");	(void) strcat(type_defaults_path, typeDefaults);	if (!(config_file = fopen(type_defaults_path, "r"))) {	  (void) fprintf(stderr, "Can't open typeDefaults file\n");        int_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!");	int_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!");          int_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!");            int_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!");        int_quit(1);      } else {        num = 0;        while (num < count && n != tempints[num]) num++;        if (num == count) {          (void) fprintf(stderr, "Parsing error in typeDefaults file!");          int_quit(1);        }      }      defaults[default_num] = n;      levels[default_num] = strdup(part1);      available_types[default_num] = (int *) malloc((unsigned) 						    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 main_help(){  cleartext();  killwidgets(mainwdgts);  setwidgets(dethelpwdgts,-1);  help_cncs();}void main_bind(){  cleartext();  if (*passwd != 0)    (void) strcpy(bindpass,"******");  else    bindpass[0] = '\0';}void cnnct_quit (){  quit("Exiting sd.\n", 0);}void cnnct_bind(){  struct ds_bind_arg bindarg;  struct ds_bind_arg bindresult;  struct ds_bind_error binderr;  extern  char * dsa_address,  	       * myname;  extern  char * tailfile;  FILE * fp;  char buf [BUFSIZ];  /* set dsa_address */  dsa_address = NULLCP;  /* read tailor file to get address */  if( (fp = fopen(isodefile(tailfile,0), "r")) == (FILE *)NULL) {    tprint ("Cannot open tailor file %s\n",isodefile(tailfile,0));    return;  }  while(fgets(buf, sizeof(buf), fp) != NULLCP)    if ( (*buf != '#') && (*buf != '\n') )      (void) tai_string(buf);    (void) fclose(fp);    if (dsa_address == NULLCP)    dsa_address = myname;    /* set password */  if (bindpass[0] != 0) {    if (strcmp (bindpass,"******") != 0)      (void) strcpy (passwd,bindpass);  } else     passwd[0] = 0;    /* now bind */  bindarg.dba_version = DBA_VERSION_V1988;  if (passwd[0] == 0) {    bindarg.dba_passwd_len = 0;    bindarg.dba_passwd [0] = '\0';  } else {    bindarg.dba_passwd_len = strlen(passwd);    (void) strcpy (bindarg.dba_passwd, passwd);  }    bindarg.dba_dn = (*namestr == 0? NULLDN: str2dn(namestr));  if (ds_bind (&bindarg,&binderr,&bindresult) != DS_OK) {    if (binderr.dbe_type == DBE_TYPE_SECURITY)      quit("Bind security error - Check name and pasword.\n", 0);    else       quit("Bind service error - Can't contact DSA!\n", 1);  } else {    setdialogstr(getwidget(mainwdgts, '\0'), friendly_base_path, STRINGLEN);    setdialogstr(getwidget(mainwdgts, 's'), mvalue, STRINGLEN);    setdialogstr(getwidget(mainwdgts, '*'), srchvalue, 6);    settogglstrs(getwidget(mainwdgts, 't'), filttype, 0);    setwidgets (mainwdgts,-1);    user_name = bindarg.dba_dn;    if(local_dit && *local_dit)      (void) strcpy(base_path, local_dit);    else       (void) strcpy(base_path, "The World");    oclass = as_comp_new(AttrT_new("objectClass"), NULLAV, NULLACL_INFO);    make_friendly(friendly_base_path, base_path);    printdialog(getwidget(mainwdgts,'\0'));    set_default_type();    (void) strcpy (buf, "TERM");#ifndef NO_STATS    LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address));#endif#ifndef NO_STATS    LLOG (log_stat,LLOG_NOTICE,("sd called from a ('%s')", getenv(buf)));#endif  }  display_entry = current_entry = 1;  entry_number = 0;  back_buf_num = 0;  textseq = back_seq = curr_dnseq = NULLDS;  text_state = TEXT;}void rd_start(){  struct ds_read_arg read_arg;  struct ds_read_result   result;  struct DSError          error;  Entry read_entry;    cleartext();  if (*friendly_base_path == 'T') {    free_seq(textseq);    if (text_state == DN_LIST) free_seq(curr_dnseq);    curr_dnseq = textseq = NULLDS;    text_state = TEXT;    entry_number  = 0;    return;  }  xprint("Reading data on ");  xprint(friendly_base_path);  xprint(".\n");  tprint("Working. Please wait.....");  if ( get_default_service (&read_arg.rda_common) != 0) {    xprint ("Default service error -> check your .quipurc\n");    return ;

⌨️ 快捷键说明

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