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 584 by douglas, 2005-11-22T18:14:57-08:00

# Line 157 | Line 157 | void setshells(Shells *shells, jmp_buf e
157          check(setenv("SOLARIS", shells->solaris, 1), environment);
158   }
159  
160 < #ifndef __FreeBSD__
160 > #if !defined(__FreeBSD__) && !defined(__sun__)
161   size_t strlcpy(char *dst, const char *src, size_t size)
162   {
163          dst[size - 1] = '\0';
# Line 184 | Line 184 | char *fgetln(FILE * restrict stream, siz
184  
185          return line;
186   }
187 + #elif defined(__sun__)
188 + char *fgetln(FILE * restrict stream, size_t * restrict len)
189 + {
190 +        static char *line = NULL;
191 +
192 +        *len = 0;
193 +        line = line ? realloc(line, 1) : malloc(1);
194 +
195 +        while (line[*len] = getc(stream), line[(*len)++] != '\n')
196 +                if (line[*len - 1] != EOF)
197 +                        line = realloc(line, *len + 1);
198 +                else
199 +                        return NULL;
200 +
201 +        return line;
202 + }
203 +
204 + int setenv(const char *name, const char *value, int overwrite)
205 + {
206 +        char *string = getenv(name);
207 +
208 +        if (overwrite || !string)
209 +        {
210 +                string = string ? realloc(string, strlen(name) + strlen(value) + 2) : malloc(strlen(name) + strlen(value) + 2);
211 +
212 +                sprintf(string, "%s=%s", name, value);
213 +
214 +                return putenv(string);
215 +        }
216 +        else
217 +                return 0;
218 + }
219   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines