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