xref: /csrg-svn/usr.bin/f77/libU77/chdir_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
42405Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623005Skre  */
723005Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)chdir_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223005Skre /*
132405Sdlw  * change default directory
142405Sdlw  *
152405Sdlw  * calling sequence:
162405Sdlw  *	integer chdir
172405Sdlw  *	ierror = chdir(dirname)
182405Sdlw  * where:
192405Sdlw  *	ierror will receive a returned status (0 == OK)
202405Sdlw  *	dirname is the directory name
212405Sdlw  */
222405Sdlw 
232405Sdlw #include "../libI77/f_errno.h"
2412141Sdlw #include <sys/param.h>
2512141Sdlw #ifndef	MAXPATHLEN
2612141Sdlw #define MAXPATHLEN	128
2712141Sdlw #endif
282405Sdlw 
chdir_(dname,dnamlen)292405Sdlw long chdir_(dname, dnamlen)
302405Sdlw char *dname;
312405Sdlw long dnamlen;
322405Sdlw {
3312141Sdlw 	char buf[MAXPATHLEN];
342405Sdlw 
352534Sdlw 	if (dnamlen >= sizeof buf)
362534Sdlw 		return((long)(errno=F_ERARG));
372405Sdlw 	g_char(dname, dnamlen, buf);
382405Sdlw 	if (chdir(buf) != 0)
392405Sdlw 		return((long)errno);
402405Sdlw 	return(0L);
412405Sdlw }
42