6 |
|
|
7 |
|
#include "common.h" |
8 |
|
|
9 |
+ |
#ifdef __sun__ |
10 |
+ |
#define getpass getpassphrase |
11 |
+ |
#endif |
12 |
+ |
|
13 |
|
Shells shells[] = { |
14 |
|
{ "sh", "/bin/sh", "/bin/sh", "/bin/sh", "/usr/bin/sh" }, |
15 |
|
{ "csh", "/bin/csh", "/bin/csh", "/bin/csh", "/usr/bin/csh" }, |
161 |
|
check(setenv("SOLARIS", shells->solaris, 1), environment); |
162 |
|
} |
163 |
|
|
164 |
< |
#ifndef __FreeBSD__ |
164 |
> |
#if !defined(__FreeBSD__) && !defined(__sun__) |
165 |
|
size_t strlcpy(char *dst, const char *src, size_t size) |
166 |
|
{ |
167 |
|
dst[size - 1] = '\0'; |
188 |
|
|
189 |
|
return line; |
190 |
|
} |
191 |
+ |
#elif defined(__sun__) |
192 |
+ |
char *fgetln(FILE * restrict stream, size_t * restrict len) |
193 |
+ |
{ |
194 |
+ |
static char *line = NULL; |
195 |
+ |
|
196 |
+ |
*len = 0; |
197 |
+ |
line = line ? realloc(line, 1) : malloc(1); |
198 |
+ |
|
199 |
+ |
while (line[*len] = getc(stream), line[(*len)++] != '\n') |
200 |
+ |
if (line[*len - 1] != EOF) |
201 |
+ |
line = realloc(line, *len + 1); |
202 |
+ |
else |
203 |
+ |
return NULL; |
204 |
+ |
|
205 |
+ |
return line; |
206 |
+ |
} |
207 |
+ |
|
208 |
+ |
int setenv(const char *name, const char *value, int overwrite) |
209 |
+ |
{ |
210 |
+ |
char *string_ = getenv(name); |
211 |
+ |
|
212 |
+ |
if (overwrite || !string_) |
213 |
+ |
{ |
214 |
+ |
char *string = malloc(strlen(name) + strlen(value) + 2); |
215 |
+ |
|
216 |
+ |
sprintf(string, "%s=%s", name, value); |
217 |
+ |
|
218 |
+ |
int value_ = putenv(string); |
219 |
+ |
|
220 |
+ |
if (!string_) |
221 |
+ |
free(string_); |
222 |
+ |
|
223 |
+ |
return value_; |
224 |
+ |
} |
225 |
+ |
|
226 |
+ |
return 0; |
227 |
+ |
} |
228 |
|
#endif |