platform/posix.c
changeset 249 fed886543e40
parent 240 052041af9001
child 251 0f4615263e32
equal deleted inserted replaced
248:db7daec832f1 249:fed886543e40
    52     const char *envr = getenv(varname);
    52     const char *envr = getenv(varname);
    53     char *retval = NULL;
    53     char *retval = NULL;
    54 
    54 
    55     if (envr != NULL)
    55     if (envr != NULL)
    56     {
    56     {
    57         retval = malloc(strlen(envr) + 1);
    57         retval = (char *) malloc(strlen(envr) + 1);
    58         if (retval != NULL)
    58         if (retval != NULL)
    59             strcpy(retval, envr);
    59             strcpy(retval, envr);
    60     } /* if */
    60     } /* if */
    61 
    61 
    62     return(retval);
    62     return(retval);
    70     char *retval = NULL;
    70     char *retval = NULL;
    71 
    71 
    72     pw = getpwuid(uid);
    72     pw = getpwuid(uid);
    73     if ((pw != NULL) && (pw->pw_name != NULL))
    73     if ((pw != NULL) && (pw->pw_name != NULL))
    74     {
    74     {
    75         retval = malloc(strlen(pw->pw_name) + 1);
    75         retval = (char *) malloc(strlen(pw->pw_name) + 1);
    76         if (retval != NULL)
    76         if (retval != NULL)
    77             strcpy(retval, pw->pw_name);
    77             strcpy(retval, pw->pw_name);
    78     } /* if */
    78     } /* if */
    79     
    79     
    80     return(retval);
    80     return(retval);
    88     char *retval = NULL;
    88     char *retval = NULL;
    89 
    89 
    90     pw = getpwuid(uid);
    90     pw = getpwuid(uid);
    91     if ((pw != NULL) && (pw->pw_dir != NULL))
    91     if ((pw != NULL) && (pw->pw_dir != NULL))
    92     {
    92     {
    93         retval = malloc(strlen(pw->pw_dir) + 1);
    93         retval = (char *) malloc(strlen(pw->pw_dir) + 1);
    94         if (retval != NULL)
    94         if (retval != NULL)
    95             strcpy(retval, pw->pw_dir);
    95             strcpy(retval, pw->pw_dir);
    96     } /* if */
    96     } /* if */
    97     
    97     
    98     return(retval);
    98     return(retval);
   186                                       const char *append)
   186                                       const char *append)
   187 {
   187 {
   188     int len = ((prepend) ? strlen(prepend) : 0) +
   188     int len = ((prepend) ? strlen(prepend) : 0) +
   189               ((append) ? strlen(append) : 0) +
   189               ((append) ? strlen(append) : 0) +
   190               strlen(dirName) + 1;
   190               strlen(dirName) + 1;
   191     char *retval = malloc(len);
   191     char *retval = (char *) malloc(len);
   192 
   192 
   193     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   193     BAIL_IF_MACRO(retval == NULL, ERR_OUT_OF_MEMORY, NULL);
   194 
   194 
   195     /* platform-independent notation is Unix-style already.  :)  */
   195     /* platform-independent notation is Unix-style already.  :)  */
   196 
   196 
   223 
   223 
   224     if (omitSymLinks)
   224     if (omitSymLinks)
   225     {
   225     {
   226         dlen = strlen(dirname);
   226         dlen = strlen(dirname);
   227         bufsize = dlen + 256;
   227         bufsize = dlen + 256;
   228         buf = malloc(bufsize);
   228         buf = (char *) malloc(bufsize);
   229         BAIL_IF_MACRO(buf == NULL, ERR_OUT_OF_MEMORY, NULL);
   229         BAIL_IF_MACRO(buf == NULL, ERR_OUT_OF_MEMORY, NULL);
   230         strcpy(buf, dirname);
   230         strcpy(buf, dirname);
   231         if (buf[dlen - 1] != '/')
   231         if (buf[dlen - 1] != '/')
   232         {
   232         {
   233             buf[dlen++] = '/';
   233             buf[dlen++] = '/';