xref: /csrg-svn/usr.bin/f77/libU77/unlink_.c (revision 47944)
1*47944Sbostic /*-
2*47944Sbostic  * Copyright (c) 1980 The Regents of the University of California.
3*47944Sbostic  * All rights reserved.
42533Sdlw  *
5*47944Sbostic  * %sccs.include.proprietary.c%
623053Skre  */
723053Skre 
8*47944Sbostic #ifndef lint
9*47944Sbostic static char sccsid[] = "@(#)unlink_.c	5.2 (Berkeley) 04/12/91";
10*47944Sbostic #endif /* not lint */
11*47944Sbostic 
1223053Skre /*
132533Sdlw  * unlink (remove) a file
142533Sdlw  *
152533Sdlw  * calling sequence:
162533Sdlw  *	integer unlink
172533Sdlw  *	ierror = unlink(filename)
182533Sdlw  * where:
192533Sdlw  *	ierror will be a returned status (0 == OK)
202533Sdlw  *	filename is the file to be unlinked
212533Sdlw  */
222533Sdlw 
232533Sdlw #include "../libI77/f_errno.h"
2412151Sdlw #include <sys/param.h>
2512151Sdlw #ifndef	MAXPATHLEN
2612151Sdlw #define MAXPATHLEN	128
2712151Sdlw #endif
282533Sdlw 
292533Sdlw long
unlink_(fname,namlen)302533Sdlw unlink_(fname, namlen)
312533Sdlw char *fname;
322533Sdlw long namlen;
332533Sdlw {
3412151Sdlw 	char buf[MAXPATHLEN];
352533Sdlw 
362533Sdlw 	if (namlen >= sizeof buf)
372533Sdlw 		return((long)(errno=F_ERARG));
382533Sdlw 	g_char(fname, namlen, buf);
392533Sdlw 	if (unlink(buf) != 0)
402533Sdlw 		return((long)errno);
412533Sdlw 	return(0L);
422533Sdlw }
43