/* CMS REPLACEMENT HISTORY, Element DIR_SERVER.C */ /* 1I1 25-APR-2006 16:16:48 MYTH "V56 baselevel code freeze" */ /* 1H1 13-JUN-2004 15:36:14 MILLIGAN "V55 baselevel code freeze" */ /* 1G1 11-MAY-2003 23:05:20 TIBBERT "V54 baselevel code freeze" */ /* 1F1 22-JAN-2002 18:37:13 SYSTEM "V53 baselevel code freeze" */ /* 1E1 2-MAY-2001 04:44:14 MILLIGAN "V52 baselevel code freeze" */ /* 1D1 11-DEC-2000 23:04:06 MYTH "V51 baselevel code freeze" */ /* 1C1 12-MAY-2000 05:51:23 MUGGERIDGE "V51IFT baselevel code freeze" */ /* 1B1 28-OCT-1998 21:12:50 MUGGERIDGE "V50SSB baselevel code freeze" */ /* 1A1 18-JUN-1998 07:58:57 MUGGERIDGE "V50IFT baselevel code freeze" */ /* *1 9-OCT-1997 19:18:45 GEMIGNANI "Initial population of IPv6 source" */ /* CMS REPLACEMENT HISTORY, Element DIR_SERVER.C */ /* ** dir_server.c: remote OpenVMS readdir implementation */ #include #include #include /* Always needed */ #include "dir.h" /* Created by RPCGEN */ extern int SYS$PARSE(struct FAB *); extern int SYS$SEARCH(struct FAB *); extern char *malloc(); readdir_res * readdir_1(dirname) nametype *dirname; { char expanded_name[NAM$C_MAXRSS+1]; struct FAB fab; struct NAM nam; namelist nl; namelist *nlp; static readdir_res res; /* must be static! */ char resultant_name[NAM$C_MAXRSS+1]; /* ** Initialize the FAB. */ fab = cc$rms_fab; fab.fab$l_fna = *dirname; fab.fab$b_fns = strlen(*dirname); fab.fab$l_dna = "SYS$DISK:[]*.*;*"; fab.fab$b_dns = strlen(fab.fab$l_dna); /* ** Initialize the NAM. */ nam = cc$rms_nam; nam.nam$l_esa = expanded_name; nam.nam$b_ess = NAM$C_MAXRSS; nam.nam$l_rsa = resultant_name; nam.nam$b_rss = NAM$C_MAXRSS; fab.fab$l_nam = &nam; /* ** Parse the specification and see if it works. */ if (SYS$PARSE(&fab) & 1) { /* ** Free previous result */ xdr_free(xdr_readdir_res, &res); /* ** Collect directory entries. ** Memory allocated here will be freed by xdr_free ** next time readdir_1 is called */ nlp = &res.readdir_res_u.list; while (SYS$SEARCH(&fab) & 1) { resultant_name[nam.nam$b_rsl] = '\0'; nl = (namenode *) malloc(sizeof(namenode)); *nlp = nl; nl->name = (char *) malloc(nam.nam$b_name + nam.nam$b_type + nam.nam$b_ver + 1); strcpy(nl->name, nam.nam$l_name); nlp = &nl->next; } *nlp = NULL; /* ** Return the result */ res.Errno = 0; } /* SYS$PARSE() */ else res.Errno = fab.fab$l_sts; return &res; }