Diff for /libaitio/src/aitio.c between versions 1.1.1.1.8.1 and 1.2.2.1

version 1.1.1.1.8.1, 2010/09/07 17:05:58 version 1.2.2.1, 2011/02/10 19:34:53
Line 305  char *ioRegexReplace(const char *csRegex, const char * Line 305  char *ioRegexReplace(const char *csRegex, const char *
   
         return str;          return str;
 }  }
   
   
   /*
    * ioMkDir() Function for racursive directory creation and validation
    * @csDir = Full directory path
    * @mode = Mode for directory creation if missing dir
    * return: -1 error, 0 directory path exist, >0 created missing dirs
   */
   int
   ioMkDir(const char *csDir, int mode)
   {
           char *str, *s, *pbrk, szOld[MAXPATHLEN] = { 0 };
           register int cx = -1;
   
           if (!csDir)
                   return cx;
   
           str = strdup(csDir);
           if (!str) {
                   LOGERR;
                   return cx;
           }
   
           getcwd(szOld, MAXPATHLEN);
           if (*str == '/')
                   chdir("/");
   
           for (cx = 0, s = strtok_r(str, "/", &pbrk); s; s = strtok_r(NULL, "/", &pbrk)) {
                   if (mkdir(s, mode) == -1) {
                           if (errno != EEXIST) {
                                   LOGERR;
                                   cx = -1;
                                   goto end;
                           }
                   } else
                           cx++;
   
                   if (chdir(s) == -1) {
                           LOGERR;
                           cx = -1;
                           goto end;
                   }
           }
   end:
           chdir(szOld);
           free(str);
           return cx;
   }
   
   
   /*
    * ioVarAst() Function for evaluate string like asterisk variable "{text[:[-]#[:#]]}"
    * @csString = Input string
    * @strLen = String length
    * return: NULL error, !=NULL Allocated new string evaluated from input string, must be free()
   */
   char *
   ioVarAst(const char *csString, int strLen)
   {
           char *ext, *str, *out = NULL;
           int e[2] = { 0 };
   
           if (!csString || !strLen)
                   return NULL;
   
           if (!strchr(csString, '{') || !strrchr(csString, '}'))
                   return NULL;
           else {
                   str = strdup(strchr(csString, '{') + 1);
                   *strrchr(str, '}') = 0;
           }
   
           if ((ext = strchr(str, ':'))) {
                   *ext++ = 0;
                   e[0] = strtol(ext, NULL, 0);
                   if ((ext = strchr(ext, ':')))
                           e[1] = strtol(++ext, NULL, 0);
   
                   /* make cut prefix */
                   if (e[0] >= 0)
                           ext = str + e[0];
                   else
                           ext = str + strlen(str) + e[0];
                   /* make cut suffix */
                   if (e[1] > 0)
                           *(ext + e[1]) = 0;
           } else
                   /* ok, clear show */
                   ext = str;
   
           out = strdup(ext);
           free(str);
   
           return out;
   }

Removed from v.1.1.1.1.8.1  
changed lines
  Added in v.1.2.2.1


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>