Diff for /libaitio/src/Attic/tools.c between versions 1.15 and 1.17

version 1.15, 2012/07/03 08:51:05 version 1.17, 2012/08/01 00:37:08
Line 303  io_FreeNullTerm(char *** __restrict arr) Line 303  io_FreeNullTerm(char *** __restrict arr)
 }  }
   
 /*  /*
    * io_argsNum() Parse and calculate number of arguments
    *
    * @csArgs = Input arguments line
    * @csDelim = Delimiter(s) for separate
    * return: 0 error format; -1 error:: can`t read; >0 ok, number of items
    */
   inline int
   io_argsNum(const char *csArgs, const char *csDelim)
   {
           register int res;
           char *pos;
   
           assert(csArgs);
           assert(csDelim);
           if (!csArgs || !csDelim)
                   return -1;
   
           for (res = 1, pos = (char*) csArgs; (pos = strpbrk(pos, csDelim)); res++, pos++);
           return res;
   }
   
   /*
    * io_MakeAV() Parse and make attribute/value pair
    *
    * @csArgs = Input argument line
    * @csDelim = Delimiter for separate
    * @psAttr = Output Attribute
    * @attrLen = Size of attribute array
    * @psValue = Output Value, if ==NULL this element not present value or not wanted for return
    * @valLen = Size of value array
    * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
   */
   int
   io_MakeAV(const char * __restrict csArgs, const char *csDelim, 
                   char * __restrict psAttr, int attrLen, char * __restrict psValue, int valLen)
   {
           register int ret = 0;
           char *pos, *psBuf;
   
           if (!csArgs || !csDelim || !psAttr || !attrLen)
                   return -1;
           if (psValue && !valLen)
                   return -1;
           else
                   memset(psValue, 0, valLen);
           psBuf = io_strdup(csArgs);
           if (!psBuf) {
                   LOGERR;
                   return -1;
           }
   
           pos = strpbrk(psBuf, csDelim);
           if (pos)
                   *pos++ = 0;
           ret++;
           strlcpy(psAttr, psBuf, attrLen);
   
           if (pos && *pos) {
                   ret++;
                   if (psValue)
                           strlcpy(psValue, pos, valLen);
           }
   
           io_free(psBuf);
           return ret;
   }
   
   /*
    * io_MakeAV2() Parse and make attribute/value pair over input string
    *
    * @csArgs = Input argument line, will be modified!
    * @csDelim = Delimiter for separate
    * @psAttr = Output Attribute
    * @psValue = Output Value, if ==NULL this element not present value or not wanted for return
    * return: 0 error format; -1 error:: can`t read; >0 ok, number of readed items
   */
   int
   io_MakeAV2(char * __restrict psArgs, const char *csDelim, 
                   char ** __restrict psAttr, char ** __restrict psValue)
   {
           register int ret = 0;
           char *pos;
   
           if (!psArgs || !csDelim)
                   return -1;
   
           pos = strpbrk(psArgs, csDelim);
           if (pos) {
                   *pos++ = 0;
                   ret++;
                   if (psAttr)
                           *psAttr = psArgs;
           } else
                   return 0;
   
           if (psValue) {
                   if (pos && *pos) {
                           ret++;
                           *psValue = pos;
                   } else
                           *psValue = NULL;
           }
   
           return ret;
   }
   
   /*
  * io_Path2File() - Parse and make path/filename pair   * io_Path2File() - Parse and make path/filename pair
  *   *
  * @csArgs = Input argument line   * @csArgs = Input argument line
Line 486  io_gethostbyname(const char *psHost, u_short port, io_ Line 593  io_gethostbyname(const char *psHost, u_short port, io_
   
         if (!psHost || !addr)          if (!psHost || !addr)
                 return NULL;                  return NULL;
         else  
                 memset(addr, 0, sizeof(io_sockaddr_t));  
   
         if (*psHost != '/') {          if (*psHost != '/') {
                 /* resolver */                  /* resolver */
Line 498  io_gethostbyname(const char *psHost, u_short port, io_ Line 603  io_gethostbyname(const char *psHost, u_short port, io_
                 if (!host) {                  if (!host) {
                         io_SetErr(EINVAL, "Resolver #%d - %s", h_errno, hstrerror(h_errno));                          io_SetErr(EINVAL, "Resolver #%d - %s", h_errno, hstrerror(h_errno));
                         return NULL;                          return NULL;
                } else                } else {
                         memset(addr, 0, sizeof(io_sockaddr_t));
                         addr->sa.sa_family = host->h_addrtype;                          addr->sa.sa_family = host->h_addrtype;
        } else                }
         } else {
                 memset(addr, 0, sizeof(io_sockaddr_t));
                 addr->sa.sa_family = AF_LOCAL;                  addr->sa.sa_family = AF_LOCAL;
           }
                   
   
         switch (addr->sa.sa_family) {          switch (addr->sa.sa_family) {
                 case AF_INET:                  case AF_INET:

Removed from v.1.15  
changed lines
  Added in v.1.17


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