ViewVC Help
View File | Revision Log | Show Annotations | Download File | View Changeset | Root Listing
root/repos/CCSAdmin/common.c
(Generate patch)

Comparing CCSAdmin/common.c (file contents):
Revision 583 by douglas, 2005-11-21T12:56:05-08:00 vs.
Revision 589 by douglas, 2005-11-25T05:49:24-08:00

# Line 6 | Line 6
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" },
# Line 157 | Line 161 | void setshells(Shells *shells, jmp_buf e
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';
# Line 184 | Line 188 | char *fgetln(FILE * restrict stream, siz
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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines