src/lib/scan.c
char *next_name(char **s)
{
   char *p, *q, *n;
   bool in_quote = false;

   if (s == NULL || *s == NULL || **s == '\0') {
      return NULL;
   }
   p = *s;
   Dmsg1(900, "Next name=%s\n", p);
   for (n = q = p; *p ; ) {
      if (*p == '\\') {                 /* slash? */
         p++;                           /* yes, skip it */
         if (*p) {
            *q++ = *p++;
         } else {
            *q++ = *p;
         }
         continue;
      }
      if (*p == '"') {                  /* start or end of quote */
         p++;
         in_quote = !in_quote;          /* change state */
         continue;
      }
      if (!in_quote && *p == ',') { /* end of field */
         p++;
         break;
      }
      *q++ = *p++;
   }
   *q = 0;
   *s = p;
   Dmsg2(900, "End arg=%s next=%s\n", n, p);
   return n;
}
/*
 * Return next name from a comma separated list.  Note, this
 *   routine is destructive because it stored 0 at the end
 *   of each argument.
 * Called with pointer to pointer to command line. This
 *   pointer is updated to point to the remainder of the
 *   command line.
 *
 * Returns pointer to next name -- don't store the result
 *   in the pointer you passed as an argument ...
 *   The next argument is terminated by a , unless within
 *   quotes. Double quote characters (unless preceded by a \) are
 *   stripped.
 *
 */
Return next name from a comma separated list.  Note, this
routine is destructive because it stored 0 at the end
of each argument.
Called with pointer to pointer to command line. This
pointer is updated to point to the remainder of the
command line.

Returns pointer to next name -- don't store the result
in the pointer you passed as an argument
The next argument is terminated by a , unless within
quotes. Double quote characters (unless preceded by a \) are
stripped.
Return next name from a comma separated list . Note this routine is destructive because it stored 0 at the end of each argument . Called with pointer to pointer to command line . This pointer is updated to point to the remainder of the command line . Returns pointer to next name -- don ' t store the result in the pointer you passed as an argument The next argument is terminated by a unless within quotes . Double quote characters ( unless preceded by a \ ) are stripped .
char *next_name(char **s)
{
   char *p, *q, *n;
   bool in_quote = false;
   if (s == NULL || *s == NULL || **s == '\0') {
      return NULL;
   }
   p = *s;
   Dmsg1(900, "Next name=%s\n", p);
   for (n = q = p; *p ; ) {
      if (*p == '\\') {                 
         p++;                           
         if (*p) {
            *q++ = *p++;
         } else {
            *q++ = *p;
         }
         continue;
      }
      if (*p == '"') {                  
         p++;
         in_quote = !in_quote;          
         continue;
      }
      if (!in_quote && *p == ',') { 
         p++;
         break;
      }
      *q++ = *p++;
   }
   *q = 0;
   *s = p;
   Dmsg2(900, "End arg=%s next=%s\n", n, p);
   return n;
}
char * next_name ( char * * s ) { char * p , * q , * n ; bool in_quote = false ; if ( s == NULL || * s == NULL || * * s == ' \0 ' ) { return NULL ; } p = * s ; Dmsg1 ( 900 , " \n " , p ) ; for ( n = q = p ; * p ; ) { if ( * p == ' \\ ' ) { p ++ ; if ( * p ) { * q ++ = * p ++ ; } else { * q ++ = * p ; } continue ; } if ( * p == ' ' ) { p ++ ; in_quote = ! in_quote ; continue ; } if ( ! in_quote && * p == ' ' ) { p ++ ; break ; } * q ++ = * p ++ ; } * q = 0 ; * s = p ; Dmsg2 ( 900 , " \n " , n , p ) ; return n ; }
Return next name from a comma separated list.
Return next name from a comma separated list .
/* slash? */ /* yes, skip it */ /* start or end of quote */ /* change state */ /* end of field */