Add copyright
[unix-history] / usr / src / usr.bin / f77 / libU77 / link_.c
CommitLineData
b79a1bb9 1/*
161423a6
RE
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.
b79a1bb9 5 *
161423a6
RE
6 * @(#)link_.c 5.1 %G%
7 */
8
9/*
b79a1bb9
DW
10 * make a link to an existing file
11 *
12 * calling sequence:
13 * ierror = link(name1, name2)
14 * where:
15 * name1 is the pathname of an existing file
16 * name2 is a pathname to be linked to file name1
17 * ierror will be 0 if successful; a system error code otherwise.
18 */
19
20#include "../libI77/f_errno.h"
05ec41e3
DW
21#include <sys/param.h>
22#ifndef MAXPATHLEN
23#define MAXPATHLEN 128
24#endif
b79a1bb9
DW
25
26long link_(name1, name2, n1len, n2len)
27char *name1, *name2;
28long n1len, n2len;
29{
05ec41e3
DW
30 char buf1[MAXPATHLEN];
31 char buf2[MAXPATHLEN];
b79a1bb9
DW
32
33 if (n1len >= sizeof buf1 || n2len >= sizeof buf2)
34 return((long)(errno=F_ERARG));
35 g_char(name1, n1len, buf1);
36 g_char(name2, n2len, buf2);
05ec41e3 37 if (buf1[0] == '\0' || buf2[0] == '\0')
b79a1bb9
DW
38 return((long)(errno=F_ERARG));
39 if (link(buf1, buf2) != 0)
40 return((long)errno);
41 return(0L);
42}