/* $Header: /f/osi/others/quipu/uips/xd/RCS/calls.c,v 7.4 91/02/22 09:32:41 mrose Interim $ */
static char *rcsid
= "$Id: calls.c,v 7.4 91/02/22 09:32:41 mrose Interim $";
* Revision 7.4 91/02/22 09:32:41 mrose
* Revision 7.3 90/10/17 11:50:20 mrose
* Revision 7.2 90/07/27 08:45:53 mrose
* Revision 7.1 90/07/09 14:42:12 mrose
* Revision 7.0 90/06/12 13:10:48 mrose
* *** empty log message ***
* Revision 1.5 90/04/26 10:22:34 emsrssn
* Revision 1.4 90/04/25 17:28:04 emsrssn
* Revision 1.3 90/04/19 13:54:04 emsrssn
* keyboard accelerator now activates button highlight.
* search types available is dependent on current position
* to prevent unreasonable searches.
* the help popup changes automatically depending on the
* buttons remain a fixed size when the application is
* command line options are now handled properly
* "reads" are now sorted to show mail address at top etc.
* Revision 1.2 90/03/09 15:57:27 emsrssn
* First public distribution
* Revision 1.1 90/03/08 13:18:36 emsrssn
#include "quipu/common.h"
struct attrcomp
* sort_attrs();
Attr_Sequence read_types
= 0, read_types2
;
int dn_print (), rdn_print(), as_print();
char bound
= FALSE
; /* indication of whether bound */
D_seq dnseq
= NULLDS
, backseq
= NULLDS
, showseq
= NULLDS
;
int entry_number
, back_buf_num
, element_num
;
/* These are common operation variables */
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 bindpass
[STRINGLEN
];
char srchvalue
[STRINGLEN
]; /* Used by search */
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 *available_types
[MAXTYPES
];
extern Filter
make_filter();
extern int Switch_On_Result_Update();
extern int Switch_Off_Result_Update();
extern void Clear_Results();
/* These are used as the data for the binding connection */
char *file_names
[MAXTYPES
];
while(*ptr
== '"') ptr
++;
while(*ptr
!= '"') ptr
++;
while(*ptr
> '9' || *ptr
< '0') ptr
++;
while(*end_ptr
!= '\n') end_ptr
++;
char *config_dir
= "/.duaconfig/";
char *isode_config_dir
= "xd/duaconfig/";
char *type_dir
= "filterTypes/";
char *read_File
= "readTypes";
char *type_defaults
= "typeDefaults";
char type_defaults_Home
[BUFSIZ
];
char Read_in_Stuff
[STRINGLEN
];
(void) strcpy(dua_help_dir
, isodefile("xd/helpdir/", 0));
if ((opt
= ps_alloc (std_open
)) == NULLPS
)
fatal (-1,"ps_alloc failed");
if (std_setup (opt
,stdout
) == NOTOK
)
fatal (-1,"std_setup failed");
(void) strcpy (Dish_Home
, getenv ("HOME"));
(void) strcpy(read_Home
, Dish_Home
);
(void) strcpy(type_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
);
if (!(dir
= opendir(type_Home
))) {
(void) strcpy(type_Home
, isodefile(isode_config_dir
,0));
(void) strcat(type_Home
, type_dir
);
if(!(dir
= opendir(type_Home
))) {
(void) strcpy(type_Home
, "./");
(void) strcat(type_Home
, isode_config_dir
);
(void) strcat(type_Home
, type_dir
);
if(!(dir
= opendir(type_Home
))) {
(void) printf("Can't find directory %s!\n", type_dir
);
while(dir_ent
= readdir(dir
)) {
if (!(strncmp(dir_ent
->d_name
, "Type_", 5))) {
(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
);
if ((file
= fopen (Dish_Home
, "r")) == 0);
while (fgets (Read_in_Stuff
, STRINGLEN
, file
) != 0) {
p
= SkipSpace (Read_in_Stuff
);
if (( *p
== '#') || (*p
== '\0'))
continue; /* ignore comments and blanks */
if ((part2
= index (p
,':')) == NULLCP
)
continue; /* ignore it */
part2
= TidyString(part2
);
if (strcmp (part1
, "username") == 0)
(void) strcpy (namestr
, part2
);
else if (strcmp (part1
, "password") == 0)
(void) strcpy (passwd
, part2
);
else if (lexequ (part1
, "dsap") == 0)
(void) tai_string (part2
);
else if (lexequ (part1
, "isode") == 0) {
if ((split
= index (part2
,' ')) != NULLCP
) {
(void) isodesetvar (part2
,split
,0);
} else if (strcmp (part1
, "service") == 0)
if (!(file
= fopen(read_Home
, "r"))) {
(void) strcpy(read_Home
, isodefile(isode_config_dir
,0));
(void) strcat(read_Home
, read_File
);
if (!(file
= fopen(read_Home
, "r"))) {
(void) strcpy(read_Home
, "./");
(void) strcat(read_Home
, isode_config_dir
);
(void) strcat(read_Home
, read_File
);
if (!(file
= fopen(read_Home
, "r"))) {
(void) printf("Can't find read file (%s)!\n", read_Home
);
load_oid_table("oidtable");
while(fgets(Read_in_Stuff
, STRINGLEN
, file
) != 0) {
(void) strcpy(stroid_buf
, get_strioid(Read_in_Stuff
));
read_types
= as_comp_new(AttrT_new(stroid_buf
), NULLAV
, NULLACL_INFO
);
read_types2
= as_comp_new(AttrT_new(stroid_buf
) ,NULLAV
, NULLACL_INFO
);
read_types
= as_merge(read_types
, read_types2
);
for (curr_filt
= 0; curr_filt
< filt_num
; curr_filt
++) {
if (!(file
= fopen(file_names
[curr_filt
], "r"))) {
(void) printf("Can't find file %s!\n", (char *) file_names
[curr_filt
]);
filtvalue
[curr_filt
] = (char *) malloc(STRINGLEN
);
*filtvalue
[curr_filt
] = '\0';
filttype
[curr_filt
] = NULLCP
;
for (count
= 0; count
< filt_num
; count
++)
if (!(file
= fopen(type_defaults_Home
, "r"))) {
(void) strcpy(type_defaults_Home
, isodefile(isode_config_dir
,0));
(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");
while (fgets (Read_in_Stuff
, STRINGLEN
, file
) != 0) {
p
= SkipSpace(Read_in_Stuff
);
if (( *p
== '#') || (*p
== '\0'))
if ((part2
= index (p
,':')) == NULLCP
)
while (isspace(*end
)) end
--;
while (isspace(*part2
)) part2
++;
while (!isspace(*end
) && *end
!= ',' && *end
!= ':') end
++;
while (n
< filt_num
&& strncmp(filttype
[n
], part2
,
(int) (end
- part2
))) n
++;
(void) fprintf(stderr
, "Parsing error in typeDefaults file!");
while (!isalpha(*part2
) && *part2
!= ':' && part2
!= '\0') part2
++;
(void) fprintf(stderr
, "Parsing error in typeDefaults file!");
while (!isalpha(*part2
)) part2
++;
while (!isspace(*end
) && *end
!= ',' &&
*end
!= ':' && *end
!= '\0') end
++;
(void) fprintf(stderr
, "Parsing error in typeDefaults file!");
while (n
< filt_num
&& strcmp(filttype
[n
], p
)) n
++;
(void) fprintf(stderr
, "Parsing error in typeDefaults file!");
while (num
< count
&& n
!= tempints
[num
]) num
++;
(void) fprintf(stderr
, "Parsing error in typeDefaults file!");
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;
av_typeindx
= available_types
[0];
struct ds_bind_arg bindarg
;
struct ds_bind_arg bindresult
;
struct ds_bind_error binderr
;
extern char * dsa_address
,
(void) strcpy(bindpass
,"******");
/* read tailor file to get address */
if( (fp
= fopen(isodefile(tailfile
,0), "r")) == (FILE *)NULL
) {
(void) printf ("Cannot open tailor file %s\n",isodefile(tailfile
,0));
while(fgets(buf
, sizeof(buf
), fp
) != NULLCP
)
if ( (*buf
!= '#') && (*buf
!= '\n') )
if (dsa_address
== NULLCP
)
if (strcmp (bindpass
,"******") != 0)
(void) strcpy (passwd
,bindpass
);
bindarg
.dba_version
= DBA_VERSION_V1988
;
bindarg
.dba_passwd_len
= 0;
bindarg
.dba_passwd
[0] = '\0';
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) printf (binderr
.dbe_type
== DBE_TYPE_SECURITY
?
"Bind security error - Check name and pasword.\n":
"Bind service error - Can't contact DSA!\n");
user_name
= bindarg
.dba_dn
;
(void) strcpy (buf
, "TERM");
if(local_dit
&& *local_dit
)
(void) strcpy(base_path
, local_dit
);
LLOG (log_stat
,LLOG_NOTICE
,("bound ('%s' to '%s')",namestr
,dsa_address
));
LLOG (log_stat
,LLOG_NOTICE
,("xd bound to directory"));
make_friendly(friendly_base_path
, base_path
);
backseq
= dnseq
= NULLDS
;
struct ds_read_arg read_arg
;
struct ds_read_result result
;
if (*friendly_base_path
== 'T') {
if (get_default_service (&read_arg
.rda_common
) != 0) {
xprint ("Default service error -> check your .quipurc\n");
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_common
.ca_servicecontrol
.svc_options
= 1;
read_arg
.rda_object
= (*friendly_base_path
!= 'T'? str2dn(base_path
): NULLDN
);
local_find_entry (read_arg
.rda_object
, FALSE
)) != NULLENTRY
) {
read_entry
->e_attributes
= sort_attrs(read_entry
->e_attributes
);
read_print (as_print
, (caddr_t
) read_entry
->e_attributes
);
LLOG (log_stat
,LLOG_NOTICE
,("read +%s",base_path
));
if (ds_read (&read_arg
,&error
,&result
) != DS_OK
) {
xprint("Read error due to:\n");
if (result
.rdr_entry
.ent_attr
== NULLATTR
) {
xprint("No attributes found! Sorry.");
xprint("Result of look up ...\n");
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
);
read_print(as_print
, (caddr_t
) result
.rdr_entry
.ent_attr
);
xprint("You haven't been anywhere yet!\n");
element_num
= back_buf_num
;
register char *str
, *sptr
;
str
= get_from_seq(count
+1, backseq
);
while (count
< back_buf_num
&& strcmp(str
, base_path
)){
str
= get_from_seq(count
+1, backseq
);
if (count
== back_buf_num
) {
add_seq(&backseq
, base_path
);
for (sptr
= str
; *sptr
!= '\0'; sptr
++)
if (*sptr
== '@') str
= sptr
;
(void) strcpy(base_path
, "The World");
make_friendly(friendly_base_path
, base_path
);
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
->
if (count
< default_num
) {
av_typeindx
= available_types
[count
];
typeindx
= defaults
[count
];
av_typeindx
= available_types
[0];
for(count
= 0; count
< default_num
&& strcmp(levels
[count
], "@"); count
++);
if (count
< default_num
) {
av_typeindx
= available_types
[count
];
typeindx
= defaults
[count
];
av_typeindx
= available_types
[0];
make_friendly(friendly_base_path
, base_path
);
Set_Search_Type(filttype
[typeindx
]); /* change string in widget */
/* These are the functions called by the list level widgets */
struct ds_search_arg search_arg
;
struct ds_search_result result
;
xprint("Chugging along.....");
if (get_default_service (&search_arg
.sra_common
) != 0) {
xprint ("Default service error -> check your .quipurc\n");
search_arg
.sra_common
.ca_servicecontrol
.svc_sizelimit
= asizelimit
;
search_arg
.sra_common
.ca_servicecontrol
.svc_options
= 1;
search_arg
.sra_baseobject
= (*base_path
!= 'T'?
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
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
.
str2AttrV("dsa", search_arg
.sra_filter
->flt_un
.flt_un_filter
->
flt_un
.flt_un_item
.fi_un
.fi_un_ava
.ava_type
->
LLOG (log_stat
,LLOG_NOTICE
,("search +%s,extent %d, val objectClass != dsa",base_path
,search_arg
.sra_subset
));
if (search_arg
.sra_filter
->flt_un
.flt_un_filter
->flt_un
.flt_un_item
.
fi_un
.fi_un_ava
.ava_value
== NULLAttrV
) {
xprint("No can do. Sorry!");
} else if (ds_search (&search_arg
,&error
,&result
) != DS_OK
) {
xprint("Search error due to:\n");
correlate_search_results (&result
);
if (result
.CSR_entries
!= NULLENTRYINFO
) {
xprint ("Result of search ...\n");
if (result
.CSR_common
.cr_aliasdereferenced
) {
xprint ("(Alias dereferenced - object is ");
quipu_print (dn_print
, (caddr_t
) result
.CSR_object
);
dn_free (result
.CSR_object
);
for (ptr
= result
.CSR_entries
; ptr
!= NULLENTRYINFO
;
dn2str ((caddr_t
)ptr
->ent_dn
, goto_path
);
add_seq (&dnseq
, goto_path
);
cache_entry (ptr
,TRUE
,TRUE
);
} else if (result
.CSR_limitproblem
!= LSR_TIMELIMITEXCEEDED
) {
xprint("Nothing found. Sorry!");
if(result
.CSR_limitproblem
!= LSR_NOLIMITPROBLEM
) {
if(result
.CSR_limitproblem
== LSR_TIMELIMITEXCEEDED
) {
xprint("(Time limit exceeded)");
xprint("(Size limit exceeded)");
entryinfo_free(result
.CSR_entries
, 0);
filter_free(search_arg
.sra_filter
);
if ((ps
= ps_alloc(str_open
)) == NULLPS
) {
if (str_setup(ps
, buffer
, RESBUF
, 1) == NOTOK
) {
rdn_print(ps
, (RDN
) ptr
, READOUT
);
(void) strcpy(cptr
, buffer
);
struct ds_search_arg search_arg
;
struct ds_search_result result
;
xprint("OK. Starting search.\n");
if (get_default_service (&search_arg
.sra_common
) != 0) {
xprint ("Default service error -> check your .quipurc\n");
search_arg
.sra_common
.ca_servicecontrol
.svc_sizelimit
= asizelimit
;
search_arg
.sra_common
.ca_servicecontrol
.svc_options
= 1;
search_arg
.sra_baseobject
= (*base_path
!= 'T'?
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
== '@')?
make_filter(filt_arr
[typeindx
]);
LLOG (log_stat
,LLOG_NOTICE
,("search +%s, extent %d, val %s",base_path
,search_arg
.sra_subset
,mvalue
));
if(ds_search (&search_arg
,&error
,&result
) != DS_OK
) {
xprint(" Search error due to:\n ");
correlate_search_results (&result
);
if (result
.CSR_entries
!= NULLENTRYINFO
) {
if (result
.CSR_common
.cr_aliasdereferenced
) {
xprint (" (Alias dereferenced - object is ");
quipu_print (dn_print
, (caddr_t
) result
.CSR_object
);
dn_free (result
.CSR_object
);
for (ptr
= result
.CSR_entries
;
ptr
!= NULLENTRYINFO
; ptr
= ptr
->ent_next
){
dn2str ((caddr_t
) ptr
->ent_dn
, goto_path
);
add_seq (&dnseq
, goto_path
);
cache_entry (ptr
,TRUE
,TRUE
);
} else if(result
.CSR_limitproblem
!= LSR_TIMELIMITEXCEEDED
) {
xprint("Nothing found using current search parameters. Sorry!\n");
if(result
.CSR_limitproblem
!= LSR_NOLIMITPROBLEM
)
if(result
.CSR_limitproblem
== LSR_TIMELIMITEXCEEDED
) {
xprint("(Time limit exceeded)");
xprint("(Size limit exceeded)");
entryinfo_free(result
.CSR_entries
, 0);
filter_free(search_arg
.sra_filter
);
if((ps
= ps_alloc(str_open
)) == NULLPS
) return ;
if(str_setup(ps
, buffer
, RESBUF
, 1) == NOTOK
) return ;
dn_print(ps
, (DN
) ptr
, EDBOUT
);
(void) strcpy(cptr
, buffer
);
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
);
Switch_Off_Result_Update();
for (i
= 0; i
<= size
; i
++, sptr
++)
if (*sptr
== '\n' || *sptr
== '\0') {
Switch_On_Result_Update();
int (*func
) (); /* assumes func (PS ,dataptr,(int) format); */
/* log info to pstream */
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
);
/* print in blocks of 100 bytes-larger seems too much for curses*/
for (sptr
= str
; *sptr
!= '\0'; sptr
++);
if ((ps
= ps_alloc(str_open
)) == NULLPS
) return ;
if (str_setup (ps
, buffer
, RESBUF
, 1) == NOTOK
) return ;
for (count
= 0; count
< filt_num
; count
++) {
free_filt(filt_arr
[count
]);
get_listed_object(entrynum
)
if (entrynum
> element_num
) return;
if (sptr
= get_from_seq (entrynum
, showseq
)) {
str
= get_from_seq(count
+1, backseq
);
while (count
< back_buf_num
&& strcmp(str
, base_path
)){
str
= get_from_seq(count
+1, backseq
);
if (count
== back_buf_num
) {
add_seq(&backseq
, base_path
);
(void) strcpy(base_path
, sptr
);
make_friendly(friendly_base_path
, base_path
);
if (!strcmp(str
, "The World")) {
(void) strcpy(fstr
, str
);
while (*str
!= '=') str
++;
while (*str
== ' ') str
++;
while (*end_ptr
!= '@' && *end_ptr
!= '\0') end_ptr
++;
(void) strcpy(fstr
, str
);
(void) strcat(fstr
, str
);
(void) strcat(fstr
, ", ");
struct attrcomp
*entry_attrs
;
struct attrcomp
*last
, *next
, *curr
, *first
, *firstn
;
first
= curr
= entry_attrs
;
firstn
= last
= next
= 0;
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
;
last
->attr_link
= curr
->attr_link
;