xref: /original-bsd/usr.bin/f77/libU77/chdir_.c (revision 2301fdfb)
1 /*
2  * Copyright (c) 1980 Regents of the University of California.
3  * All rights reserved.  The Berkeley software License Agreement
4  * specifies the terms and conditions for redistribution.
5  *
6  *	@(#)chdir_.c	5.1	06/07/85
7  */
8 
9 /*
10  * change default directory
11  *
12  * calling sequence:
13  *	integer chdir
14  *	ierror = chdir(dirname)
15  * where:
16  *	ierror will receive a returned status (0 == OK)
17  *	dirname is the directory name
18  */
19 
20 #include "../libI77/f_errno.h"
21 #include <sys/param.h>
22 #ifndef	MAXPATHLEN
23 #define MAXPATHLEN	128
24 #endif
25 
26 long chdir_(dname, dnamlen)
27 char *dname;
28 long dnamlen;
29 {
30 	char buf[MAXPATHLEN];
31 
32 	if (dnamlen >= sizeof buf)
33 		return((long)(errno=F_ERARG));
34 	g_char(dname, dnamlen, buf);
35 	if (chdir(buf) != 0)
36 		return((long)errno);
37 	return(0L);
38 }
39