|
|
BSD 4.3reno
#ifndef lint
static char *rcsid = "$Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/calls.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $";
#endif
/*
* $Header: /var/lib/cvsd/repos/CSRG/43BSDReno/contrib/isode-beta/others/quipu/uips/pod/calls.c,v 1.1.1.1 2018/04/24 16:12:56 root Exp $
*/
/*
* $Log: calls.c,v $
* Revision 1.1.1.1 2018/04/24 16:12:56 root
* BSD 4.3reno
*
* Revision 7.2 90/07/27 08:45:32 mrose
* update
*
* Revision 7.1 90/07/09 14:41:29 mrose
* sync
*
* Revision 7.0 90/06/12 13:15:48 mrose
* *** empty log message ***
*
* Revision 1.5 90/04/26 10:21:02 emsrdsm
* *** empty log message ***
*
* Revision 1.4 90/04/25 13:46:44 emsrdsm
* i) lint'ed
*
* Revision 1.3 90/04/20 10:27:45 emsrdsm
* *** empty log message ***
*
* Revision 1.2 90/04/18 18:47:56 emsrdsm
* i) added logging
*
* Revision 1.1 90/04/10 16:43:29 emsrdsm
* Initial revision
*
*/
#include "manifest.h"
#include <malloc.h>
#include <string.h>
#include <ctype.h>
#include "quipu/util.h"
#include "quipu/common.h"
#include "quipu/entry.h"
#include "usr.dirent.h"
#include "tailor.h"
#include "sequence.h"
#include "filt.h"
#include "y.tab.h"
#include "symtab.h"
#include "defs.h"
struct attrcomp * sort_attrs();
static dn2str ();
#define RESBUF 10000
extern Filter make_filter();
extern void xprint();
typedef enum {rfc822, greybook} mailtype;
mailtype mailformat = rfc822;
extern mode listmode;
PS opt;
Attr_Sequence read_types = 0, read_types2 = 0, oclass = 0;
table_entry symtab = 0;
int typetoggled = 0;
int dn_print (), rdn_print(), as_print(), avs_comp_print();
char bound = FALSE; /* indication of wether bound */
char * TidyString();
D_seq dnseq = NULLDS, backseq = NULLDS, showseq = NULLDS;
int entry_number, back_buf_num, dn_number;
int two_passes = 0;
/* These are common operation variables */
#define STRINGLEN 1000
#define SMALLSTRING 255
#define MAXTYPES 255
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 friendly_name[STRINGLEN];
char namestr[STRINGLEN];
char cache [STRINGLEN];
char bindpass [STRINGLEN];
char srchvalue[STRINGLEN]; /* Used by search */
char svalue [STRINGLEN];
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];
typedef struct friendlyName {
D_seq names;
char fname[256];
} *fName;
unsigned int fname_num = 0;
fName name_map[MAXTYPES];
#ifndef NO_STATS
extern 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 *file;
char *file_names[MAXTYPES];
char dua_help_dir[256];
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;
}
user_tailor()
{
char *part1;
char *part2;
char *getenv ();
char *ptr = "/.quipurc";
char *config_dir = "/.duaconfig/";
char *type_dir = "filterTypes/";
char *read_File = "readTypes";
char *friendly_File = "friendlyNames";
char *options = "podOptions";
char *type_defaults = "typeDefaults";
char Dish_Home[BUFSIZ];
char read_Home[BUFSIZ];
char type_Home[BUFSIZ];
char optionsHome[BUFSIZ];
char friendly_Home[BUFSIZ];
char type_defaults_Home[BUFSIZ];
char dua_config_dir[BUFSIZ];
char stroid_buf[BUFSIZ];
char *str, *sptr;
char save;
DIR *dir;
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
(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/");
if ((opt = ps_alloc (std_open)) == NULLPS)
fatal (-1,"ps_alloc failed");
if (std_setup (opt,stdout) == NOTOK)
fatal (-1,"std_setup failed");
namestr[0] = '\0';
*passwd = '\0';
cache[0] = '\0';
(void) strcpy (Dish_Home, getenv ("HOME"));
(void) strcpy(read_Home, Dish_Home);
(void) strcpy(type_Home, Dish_Home);
(void) strcpy(friendly_Home, Dish_Home);
(void) strcpy(optionsHome, Dish_Home);
(void) strcpy(type_defaults_Home, Dish_Home);
(void) strcat(Dish_Home, ptr);
(void) strcat(read_Home, config_dir);
(void) strcat(read_Home, read_File);
(void) strcat(type_Home, config_dir);
(void) strcat(type_Home, type_dir);
(void) strcat(friendly_Home, config_dir);
(void) strcat(friendly_Home, friendly_File);
(void) strcat(optionsHome, config_dir);
(void) strcat(optionsHome, options);
(void) strcat(type_defaults_Home, config_dir);
(void) strcat(type_defaults_Home, type_defaults);
if (!(dir = opendir(type_Home))) {
(void) strcpy(type_Home, dua_config_dir);
(void) strcat(type_Home, type_dir);
if(!(dir = opendir(type_Home))) {
(void) strcpy(type_Home, "./Xd/duaconfig/");
(void) strcat(type_Home, type_dir);
if (!(dir = opendir(type_Home))) {
(void) fprintf(stderr, "Can't find directory %s!\n", type_dir);
quit(1);
}
}
}
rewinddir(dir);
filt_num = 0;
while(dir_ent = readdir(dir)) {
if (!(strncmp(dir_ent->d_name, "Type_", 5))) {
file_names[filt_num] =
(char *) malloc((unsigned int)
(strlen(dir_ent->d_name) +
strlen(type_Home) + 2));
(void) strcpy(file_names[filt_num], type_Home);
(void) strcat(file_names[filt_num], dir_ent->d_name);
filt_num++;
}
}
(void) closedir(dir);
if ((file = fopen (Dish_Home, "r")) == 0);
else {
while (fgets (Read_in_Stuff, STRINGLEN, 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 (strcmp (part1, "username") == 0)
(void) strcpy (namestr, part2);
else if (strcmp (part1, "password") == 0)
(void) strcpy (passwd, part2);
else if (strcmp(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);
}
isodexport (NULLCP);
(void) fclose(file);
}
if ((file = fopen(optionsHome, "r")) == 0) {
(void) strcpy(optionsHome, dua_config_dir);
(void) strcat(optionsHome, options);
if ((file = fopen(optionsHome, "r")) == 0) {
(void) strcpy(optionsHome, "./Xd/duaconfig/");
(void) strcat(optionsHome, options);
if ((file = fopen(optionsHome, "r")) == 0) {
(void) fprintf(stderr, "Can't find options file (%s)!\n", options);
}
}
}
if (file) {
while (fgets (Read_in_Stuff, STRINGLEN, 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 (strcmp (part1, "listmode") == 0)
if (strcmp (part2, "one") == 0)
listmode = one;
else
listmode = many;
}
}
if (!(file = fopen(read_Home, "r"))) {
(void) strcpy(read_Home, dua_config_dir);
(void) strcat(read_Home, read_File);
if (!(file = fopen(read_Home, "r"))) {
(void) strcpy(read_Home, "./Xd/duaconfig/");
(void) strcat(read_Home, read_File);
if (!(file = fopen(read_Home, "r"))) {
(void) fprintf(stderr, "Can't find read file (%s)!\n", read_Home);
quit(1);
}
}
}
while(fgets(Read_in_Stuff, STRINGLEN, 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(file);
if (!(file = fopen(friendly_Home, "r"))) {
(void) strcpy(friendly_Home, dua_config_dir);
(void) strcat(friendly_Home, friendly_File);
if (!(file = fopen(friendly_Home, "r"))) {
(void) strcpy(friendly_Home, "./Xd/duaconfig/");
(void) strcat(friendly_Home, friendly_File);
if (!(file = fopen(friendly_Home, "r"))) {
(void) fprintf(stderr, "Can't find read file (%s)!\n", friendly_Home);
quit(1);
}
}
}
name_map[fname_num] = 0;
while(fgets(Read_in_Stuff, STRINGLEN, 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 (!(file = fopen(file_names[curr_filt], "r"))) {
(void) fprintf(stderr, "Can't find file %s!\n", file_names[curr_filt]);
quit(1);
}
filtvalue[curr_filt] = (char *) malloc(STRINGLEN);
*filtvalue[curr_filt] = '\0';
(void) yyparse();
(void) fclose(file);
}
filttype[curr_filt] = NULLCP;
for (count = 0; count < filt_num; count++)
free(file_names[count]);
if (!(file = fopen(type_defaults_Home, "r"))) {
(void) strcpy(type_defaults_Home, dua_config_dir);
(void) strcat(type_defaults_Home, type_defaults);
if (!(file = fopen(type_defaults_Home, "r"))) {
(void) strcpy(type_defaults_Home, "./Xd/duaconfig/");
(void) strcat(type_defaults_Home, type_defaults);
if (!(file = fopen(type_defaults_Home, "r"))) {
(void) fprintf(stderr, "Can't open typeDefaults file\n");
quit(1);
}
}
}
default_num = 0;
while (fgets (Read_in_Stuff, STRINGLEN, 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++;
}
}
}
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];
if (*passwd != 0)
(void) strcpy(bindpass,"******");
else
bindpass[0] = '\0';
/* set dsa_address */
dsa_address = NULLCP;
/* read tailor file to get address */
if( (fp = fopen(isodefile(tailfile,0), "r")) == (FILE *) NULL) {
(void) fprintf(stderr,
"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) {
(void) fprintf(stderr, binderr.dbe_type == DBE_TYPE_SECURITY?
"Security error - Check name and pasword.\n":
"Service error - Can't connect to directory!\n");
quit(1);
} else {
user_name = bindarg.dba_dn;
(void) strcpy (buf, "TERM");
if(local_dit && *local_dit)
(void) strcpy(base_path, local_dit);
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("bound ('%s' to '%s')",namestr,dsa_address));
#endif
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("pod bound to directory"));
#endif
make_friendly(friendly_base_path, base_path);
set_default_type();
oclass = as_comp_new(AttrT_new("2.5.4.0"), NULLAV, NULLACL_INFO);
}
dn_number = 0;
back_buf_num = 0;
backseq = dnseq = NULLDS;
}
dsEnqError
rd_start()
{
struct ds_read_arg read_arg;
struct ds_read_result result;
struct DSError error;
Entry read_entry;
hold_text();
cleartext();
if (*base_path == '\0') {
xprint("The World - Big and Round\n");
restart_text();
return Okay;
}
if (get_default_service (&read_arg.rda_common) != 0) {
return nothingfound;
}
refresh();
read_arg.rda_common.ca_servicecontrol.svc_options = 1;
read_arg.rda_eis.eis_allattributes = FALSE;
read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
read_arg.rda_eis.eis_select = read_types;
read_arg.rda_object = (*friendly_base_path != 'T'? str2dn(base_path): NULLDN);
if ((read_entry =
local_find_entry (read_arg.rda_object, FALSE)) != NULLENTRY) {
cleartext();
xprint("Information on:\n");
xprint(friendly_base_path);
read_entry->e_attributes = sort_attrs(read_entry->e_attributes);
read_print (as_print, (caddr_t) read_entry->e_attributes);
restart_text();
return Okay;
}
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("read +%s",base_path));
#endif
if (ds_read (&read_arg,&error,&result) != DS_OK) {
/* deal with error */
restart_text();
return localdsaerror;
} else {
/* use data */
if (result.rdr_entry.ent_attr == NULLATTR) {
cleartext();
dn_number = 0;
restart_text();
return nothingfound;
}
if (result.rdr_common.cr_aliasdereferenced)
xprint("Alias dereferenced)\n");
result.rdr_entry.ent_attr = sort_attrs(result.rdr_entry.ent_attr);
cache_entry(&(result.rdr_entry), TRUE, TRUE);
cleartext();
xprint("Information on:\n");
xprint(friendly_base_path);
read_print(as_print, (caddr_t) result.rdr_entry.ent_attr);
}
restart_text();
return Okay;
}
set_default_type()
{
int count;
DN base_name;
if (*base_path != '\0') {
base_name = str2dn(base_path);
while (base_name->dn_parent) base_name = base_name->dn_parent;
for (count = 0; count < default_num &&
strcmp(levels[count] ,base_name->dn_rdn->rdn_at->
oa_ot.ot_stroid);
count++);
if (count < default_num) {
av_typeindx = available_types[count];
typeindx = defaults[count];
} else {
av_typeindx = available_types[0];
typeindx = defaults[0];
}
} else {
for(count = 0; count < default_num && strcmp(levels[count], "@"); count++);
if (count < default_num) {
av_typeindx = available_types[count];
typeindx = defaults[count];
} else {
av_typeindx = available_types[0];
typeindx = defaults[0];
}
}
typetoggled = 0;
}
/* These are the functions called by the list level widgets */
dsEnqError
list_start()
{
struct ds_search_arg search_arg;
struct ds_search_result result;
struct DSError error;
dsEnqError return_error;
return_error = Okay;
if (get_default_service (&search_arg.sra_common) != 0) {
return localdsaerror;
}
refresh();
search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit;
search_arg.sra_common.ca_servicecontrol.svc_options = 1;
search_arg.sra_baseobject = (*base_path != 'T'?
str2dn (base_path):
NULLDN);
search_arg.sra_eis.eis_allattributes = FALSE;
search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
search_arg.sra_eis.eis_select = read_types;
search_arg.sra_subset = SRA_ONELEVEL;
search_arg.sra_filter = filter_alloc();
search_arg.sra_filter->flt_type = FILTER_NOT;
search_arg.sra_filter->flt_next = NULLFILTER;
search_arg.sra_filter->flt_un.flt_un_filter = filter_alloc();
search_arg.sra_filter->flt_un.flt_un_filter->flt_type = FILTER_ITEM;
search_arg.sra_filter->flt_un.flt_un_filter->flt_next = NULLFILTER;
search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_type
= FILTERITEM_EQUALITY;
search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un.
fi_un_ava.ava_type = AttrT_new("2.5.4.0");
search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.fi_un.
fi_un_ava.ava_value =
str2AttrV("dsa", search_arg.sra_filter->flt_un.flt_un_filter->
flt_un.flt_un_item.fi_un.fi_un_ava.ava_type->
oa_syntax);
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("search +%s,extent %d, val objectClass != dsa",base_path,search_arg.sra_subset));
#endif
if (search_arg.sra_filter->flt_un.flt_un_filter->flt_un.flt_un_item.
fi_un.fi_un_ava.ava_value == NULLAttrV) {
return_error = localdsaerror;
} else if (ds_search (&search_arg,&error,&result) != DS_OK) {
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
switch (error.dse_type) {
case DSE_LOCALERROR:
return_error = duaerror;
break;
case DSE_REMOTEERROR:
return_error = localdsaerror;
break;
case DSE_ATTRIBUTEERROR:
return_error = attributerror;
break;
case DSE_REFERRAL:
case DSE_DSAREFERRAL:
return_error = remotedsaerror;
break;
case DSE_SECURITYERROR:
return_error = security;
break;
case DSE_NAMEERROR:
return_error = namerror;
break;
default:
return_error = localdsaerror;
break;
}
} else {
correlate_search_results (&result);
if (result.CSR_entries != NULLENTRYINFO) {
register EntryInfo *ptr;
if (result.CSR_common.cr_aliasdereferenced) {
/*quipu_print (dn_print, (caddr_t) result.CSR_object);*/
dn_free (result.CSR_object);
}
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
for (ptr = result.CSR_entries; ptr != NULLENTRYINFO;
ptr = ptr->ent_next) {
dn_number++;
dn2str ((caddr_t)ptr->ent_dn, goto_path);
add_seq (&dnseq, goto_path);
cache_entry (ptr,TRUE,TRUE);
}
if (!dn_number) return_error = nothingfound;
} else if (result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) {
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
}
if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM) {
if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) {
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
return_error = timelimit;
} else return_error = listsizelimit;
}
entryinfo_free(result.CSR_entries, 0);
}
entry_number = dn_number;
filter_free(search_arg.sra_filter);
return return_error;
}
rdn2str(ptr,cptr)
caddr_t ptr;
char * cptr;
{
PS ps;
char buffer [RESBUF];
if ((ps = ps_alloc(str_open)) == NULLPS) {
return ;
}
if (str_setup(ps, buffer, RESBUF, 1) == NOTOK) {
return ;
}
rdn_print(ps, (RDN) ptr, READOUT);
ps_free(ps);
*ps->ps_ptr = 0;
(void) strcpy(cptr, buffer);
}
/* search ... */
dsEnqError
srch_start()
{
struct ds_search_arg search_arg;
struct ds_search_result result;
struct DSError error;
dsEnqError return_error;
char *str = base_path;
if (*mvalue == '\0') {
return list_start();
}
if (get_default_service (&search_arg.sra_common) != 0) {
return nothingfound;
}
refresh();
search_arg.sra_common.ca_servicecontrol.svc_sizelimit = sizelimit;
search_arg.sra_common.ca_servicecontrol.svc_options = 1;
search_arg.sra_baseobject = (*base_path != 'T'?
str2dn (base_path):
NULLDN);
search_arg.sra_eis.eis_allattributes = FALSE;
search_arg.sra_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
search_arg.sra_eis.eis_select = read_types;
while (*str != '\0' && *str != '@') str++;
search_arg.sra_subset = ((*base_path != 'T' && *str == '@')?
SRA_WHOLESUBTREE:
SRA_ONELEVEL);
search_arg.sra_filter =
make_filter(filt_arr[typeindx]);
#ifndef NO_STATS
LLOG (log_stat,LLOG_NOTICE,("search +%s, extent %d, val %s",base_path,search_arg.sra_subset,mvalue));
#endif
if(ds_search (&search_arg,&error,&result) != DS_OK) {
/* deal with error */
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
switch (error.dse_type) {
case DSE_LOCALERROR:
return_error = duaerror;
break;
case DSE_REMOTEERROR:
return_error = localdsaerror;
break;
case DSE_ATTRIBUTEERROR:
return_error = attributerror;
break;
case DSE_REFERRAL:
case DSE_DSAREFERRAL:
return_error = remotedsaerror;
break;
case DSE_SECURITYERROR:
return_error = security;
break;
case DSE_NAMEERROR:
return_error = namerror;
break;
default:
return_error = localdsaerror;
break;
}
} else {
correlate_search_results (&result);
if (result.CSR_entries != NULLENTRYINFO) {
register EntryInfo *ptr;
if (result.CSR_common.cr_aliasdereferenced) {
quipu_print (dn_print, (caddr_t) result.CSR_object);
dn_free (result.CSR_object);
}
return_error = Okay;
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
for (ptr = result.CSR_entries;
ptr != NULLENTRYINFO; ptr = ptr->ent_next){
dn_number++;
dn2str ((caddr_t) ptr->ent_dn, goto_path);
add_seq (&dnseq, goto_path);
cache_entry (ptr,TRUE,TRUE);
}
if (!dn_number) return_error = nothingfound;
} else if(result.CSR_limitproblem != LSR_TIMELIMITEXCEEDED) {
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
return_error = nothingfound;
}
if(result.CSR_limitproblem != LSR_NOLIMITPROBLEM)
if(result.CSR_limitproblem == LSR_TIMELIMITEXCEEDED) {
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
return_error = timelimit;
} else return_error = listsizelimit;
entryinfo_free(result.CSR_entries, 0);
}
entry_number = dn_number;
filter_free(search_arg.sra_filter);
return return_error;
}
static dn2str (ptr,cptr)
caddr_t ptr;
char * cptr;
{
PS ps;
char buffer [RESBUF];
if((ps = ps_alloc(str_open)) == NULLPS) return ;
if(str_setup(ps, buffer, RESBUF, 1) == NOTOK) return ;
dn_print(ps, (DN) ptr, EDBOUT);
*ps->ps_ptr = 0;
ps_free (ps);
(void) strcpy(cptr, buffer);
}
read_print(func,ptr)
int (*func) ();
caddr_t ptr;
{
PS ps;
char buffer [RESBUF];
char save;
int i, size;
register char *str, *sptr;
if ((ps = ps_alloc (str_open)) == NULLPS) return ;
if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ;
(*func) (ps, ptr, READOUT);
*ps->ps_ptr = 0;
ps_free(ps);
str = buffer ;
sptr = str;
size = strlen(buffer);
xprint("\n");
for (i = 0; i <= size; i++, sptr++)
if (*sptr == '\n' || *sptr == '\0') {
save = *sptr ;
*sptr = '\0';
if (mailformat == greybook && indexstring(str, "rfc822") >= 0)
(void) rfc2jnt(str);
*sptr = '\n';
str = sptr+1;
*sptr = save;
}
xprint(buffer);
}
/*ARGSUSED*/
podphoto(ps, picture, format)
PS ps;
PE picture;
int format;
{
PS sps;
if ((sps = ps_alloc (str_open)) == NULLPS)
return;
if (str_setup (sps,NULLCP,LINESIZE,0) == NOTOK) {
ps_free (sps);
return;
}
two_passes = 0;
(void) pe2ps (sps,picture);
decode_t4 (sps->ps_base, "photo", 0);
decode_t4 (sps->ps_base, "photo", 0);
ps_print (ps,"(see below)");
ps_free (sps);
}
quipu_print (func,ptr)
int (*func) (); /* assumes func (PS ,dataptr,(int) format); */
caddr_t ptr;
{
/* log info to pstream */
PS ps;
char buffer [RESBUF];
register char *str, *sptr;
char save;
if ((ps = ps_alloc (str_open)) == NULLPS) return ;
if (str_setup (ps,buffer,RESBUF,1) == NOTOK) return ;
(*func) (ps,ptr,READOUT);
*ps->ps_ptr = 0;
ps_free (ps);
str = buffer;
do {
for (sptr = str; *sptr != '\0'; sptr++);
save = *sptr;
*sptr = 0;
xprint (str);
*sptr = save;
str = sptr;
} while (*sptr != '\0');
}
quipu_error (err)
struct DSError * err;
{
PS ps;
char buffer [RESBUF];
if ((ps = ps_alloc(str_open)) == NULLPS) return ;
if (str_setup (ps, buffer, RESBUF, 1) == NOTOK) return ;
ds_error(ps, err);
*ps->ps_ptr = 0;
xprint(buffer);
}
make_friendly(fstr, str)
char *fstr;
register char *str;
{
register char *end_ptr;
char *string;
char save;
int count, seqnum = 0, mapped;
*fstr = '\0';
if (*str == '\0') {
*fstr = '\0';
return;
}
while (*str != '\0') {
end_ptr = str;
while (*end_ptr != '=') end_ptr++;
while (!isalpha(*end_ptr)) end_ptr--;
end_ptr++;
save = *end_ptr;
*end_ptr = '\0';
mapped = FALSE;
for (count = 0; count < fname_num; count++) {
seqnum = 0;
while (!mapped &&
(string = get_from_seq(seqnum++, name_map[count]->names)))
if (!strcmp(string, str)) {
(void) strcat(fstr, name_map[count]->fname);
count = fname_num;
mapped = TRUE;
}
}
if (!mapped)
(void) strcat(fstr, str);
(void) strcat(fstr, " = ");
*end_ptr++ = save;
str = end_ptr;
while (!(isalpha(*str))) str++;
end_ptr = str;
while (*end_ptr != '@' && *end_ptr != '\0') end_ptr++;
save = *end_ptr;
*end_ptr = '\0';
(void) strcat(fstr, str);
*end_ptr = save;
str = end_ptr;
if (*str != '\0') {
(void) strcat(fstr, ", ");
str++;
}
}
}
make_friendly_rdn(friendly, object, base)
char *friendly;
char *object, *base;
{
register char *front;
int count;
*friendly = '\0';
front = base;
count = 0;
if (showseq != backseq) {
while (*front != '\0')
if (*front != '=') front++;
else {count++; front++;}
} else
count = 0;
front = object;
while (count && *front != '\0')
if (*front != '=') front++;
else {count--; front++;}
while (front != object && *front != '@') front++;
while (!isalpha(*front)) front++;
make_friendly(friendly, front);
}
goto_addr()
{
register char *str;
int count = 0;
set_default_type();
make_friendly(friendly_base_path, base_path);
str = get_from_seq(count+1, backseq);
while (count < back_buf_num && strcmp(str, base_path)){
count++;
str = get_from_seq(count+1, backseq);
}
if (count == back_buf_num) {
add_seq(&backseq, base_path);
back_buf_num++;
add_to_history(friendly_base_path, back_buf_num);
}
}
clear_dnseq()
{
free_seq(dnseq);
dnseq = NULLDS;
dn_number = 0;
}
int
isleaf(name)
char *name;
{
struct ds_list_arg list_arg;
struct ds_list_result list_result;
struct ds_read_arg read_arg;
struct ds_read_result read_result;
struct DSError list_error, read_error;
char entry_str[1024];
if (get_default_service (&read_arg.rda_common) != 0) return(1);
read_arg.rda_common.ca_servicecontrol.svc_options = 1;
read_arg.rda_eis.eis_allattributes = FALSE;
read_arg.rda_eis.eis_infotypes = EIS_ATTRIBUTESANDVALUES;
read_arg.rda_eis.eis_select = oclass;
read_arg.rda_object = (*name? str2dn(name): NULLDN);
if (ds_read (&read_arg,&read_error,&read_result) == DS_OK) {
if (read_result.rdr_entry.ent_attr == NULLATTR) return(0);
entry2str((caddr_t) read_result.rdr_entry.ent_attr, entry_str, 1024);
if (issubstr(entry_str, "NonLeaf")) return(0);
}
if (get_default_service (&list_arg.lsa_common) != 0) return(1);
list_arg.lsa_common.ca_servicecontrol.svc_sizelimit = 1;
list_arg.lsa_common.ca_servicecontrol.svc_options = 1;
list_arg.lsa_object = (*name? str2dn(name): NULLDN);
if (ds_list (&list_arg, &list_error, &list_result) == DS_OK) {
if (list_result.lsr_subordinates) return(0);
else return(1);
} else
return (1);
}
entry2str(ptr, cptr, size)
caddr_t ptr;
char *cptr;
int size;
{
PS ps;
if ((ps = ps_alloc (str_open)) == NULLPS) return ;
if (str_setup (ps, cptr, size, 1) == NOTOK) return ;
as_print(ps, ptr, READOUT);
*ps->ps_ptr = 0;
ps_free(ps);
}
int issubstr(str, substr)
char *str;
char *substr;
{
register char *sptr;
char c;
int substrlen = strlen(substr);
int count;
if (*substr == '\0' || *str == '\0') return(0);
sptr = str;
c = *substr;
while (1) {
while (*sptr != '\0' && *sptr != c) sptr++;
if (*sptr == '\0') return(0);
for (count = 0; count >= 0 && count < substrlen; count++) {
if (sptr[count] == '\0') return(0);
else if (substr[count] != sptr[count]) count = -2;
}
if (count == substrlen) return(1);
}
}
int indexstring(string, substring)
char *string,
*substring;
{
register char *sub, *str;
char c, s;
int indx = 0;
while (1) {
str = string + indx;;
if (*str == '\0') return(-1);
sub = substring;
if (*str == *sub) {
s = *str;
c = *sub;
while(c == s && c != '\0') {
c = *++sub;
s = *++str;
}
if (c == '\0') return((int) indx);
else if(s == '\0') return(-1);
}
indx++;
}
}
rfc2jnt(string)
char *string;
{
char reversed[STRINGLEN], front[STRINGLEN];
register char *part;
reversed[0] = '\0';
part = string + strlen(string);
if (*part != '\0') return;
while(1) {
while (*part != '.' && *part != '@') --part;
if (*part == '.') {
if (reversed[0] != '\0') (void) strcat(reversed, ".");
part++;
(void) strcat(reversed, part);
*--part = '\0';
--part;
} else {
part++;
(void) strcat(reversed, ".");
(void) strcat(reversed, part);
*part-- = '\0';
while (!isspace(*part)) --part;
++part;
(void) strcpy(front, part);
(void) strcpy(string, "mailbox - ");
(void) strcat(string, front);
(void) strcat(string, reversed);
return;
}
}
}
struct attrcomp *
sort_attrs(entry_attrs)
struct attrcomp *entry_attrs;
{
struct attrcomp *last, *next, *curr, *first, *firstn;
first = curr = entry_attrs;
firstn = last = next = 0;
while (curr)
if (!strcmp("2.5.4.3", curr->attr_type->oa_ot.ot_stroid) ||
!strcmp("2.5.4.4", curr->attr_type->oa_ot.ot_stroid) ||
!strcmp("0.9.2342.19200300.100.1.3",
curr->attr_type->oa_ot.ot_stroid) ||
!strcmp("0.9.2342.19200300.100.1.2",
curr->attr_type->oa_ot.ot_stroid) ||
!strcmp("2.5.4.20", curr->attr_type->oa_ot.ot_stroid)) {
if (first == curr) first = curr->attr_link;
if (next)
next->attr_link = curr;
else
firstn = curr;
next = curr;
if (last)
last->attr_link = curr->attr_link;
curr = curr->attr_link;
next->attr_link = 0;
} else {
last = curr;
curr = curr->attr_link;
}
if (next) {
next->attr_link = first;
return firstn;
} else
return first;
}
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.