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