MCPcopy Create free account
hub / github.com/NetHack/NetHack / same_dir

Function same_dir

sys/vms/vmsfiles.c:193–222  ·  view source on GitHub ↗

Determine whether two strings contain the same directory name. Used for deciding whether installed privileges should be disabled when HACKDIR is defined in the environment (or specified via -d on the command line). This version doesn't handle Unix-style file specs. */

Source from the content-addressed store, hash-verified

191 the command line). This version doesn't handle Unix-style file specs.
192 */
193boolean
194same_dir(const char *d1, const char *d2)
195{
196 if (!d1 || !*d1 || !d2 || !*d2)
197 return FALSE;
198 else if (!strcmp(d1, d2)) /* strcmpi() would be better, but that leads */
199 return TRUE; /* to linking problems for the utilities */
200 else {
201 struct FAB f1, f2;
202 struct NAM n1, n2;
203
204 f1 = f2 = cc$rms_fab; /* initialize file access block */
205 n1 = n2 = cc$rms_nam; /* initialize name block */
206 f1.fab$b_acmodes = PSL$C_EXEC << FAB$V_LNM_MODE;
207 f1.fab$b_fns = strlen(f1.fab$l_fna = (char *) d1);
208 f2.fab$b_fns = strlen(f2.fab$l_fna = (char *) d2);
209 f1.fab$l_nam = (genericptr_t) &n1; /* link nam to fab */
210 f2.fab$l_nam = (genericptr_t) &n2;
211 /* want true device name */
212 n1.nam$b_nop = n2.nam$b_nop = NAM$M_NOCONCEAL;
213
214 return (vms_success(sys$parse(&f1)) && vms_success(sys$parse(&f2))
215 && n1.nam$t_dvi[0] == n2.nam$t_dvi[0]
216 && !strncmp(&n1.nam$t_dvi[1], &n2.nam$t_dvi[1],
217 n1.nam$t_dvi[0])
218 && !memcmp((genericptr_t) n1.nam$w_did,
219 (genericptr_t) n2.nam$w_did,
220 sizeof n1.nam$w_did)); /*{ short nam$w_did[3]; }*/
221 }
222}
223
224/*
225 * c__translate -- substitute for VAXCRTL routine C$$TRANSLATE.

Callers 1

chdirxFunction · 0.85

Calls 1

memcmpFunction · 0.85

Tested by

no test coverage detected