-/*********************************************************************
- *
- * Function : my_strsep
- *
- * Description : Convenience function. It acts like strsep, except that
- * it respects quoting of the delimiter character with the
- * quote character. (And, of course, quoting the quote char
- * with itself.) Called from `pcrs_make_job'.
- *
- * Parameters :
- * 1 : token = current token
- * 2 : text = string to tokenize
- * 3 : delimiter = single character deliminter
- * 4 : quote_char = character to cause quoting
- *
- * Returns : -1 => failure, else the length of the token found.
- * In the latter case, *text is the token's start.
- *
- *********************************************************************/
-int my_strsep(char *token, char **text, char delimiter, char quote_char)
-{
- int i, k=0, limit, quoted = FALSE;
-
- limit = strlen(*text);
- if ( 0 == limit )
- {
- return -1;
- }
-
- token[0] = '\0';
-
- for (i=0; i < limit; i++)
- {
- if (text[0][i] == delimiter && !quoted)
- {
- *text += 1;
- break;
- }
- else if (text[0][i] == quote_char && !quoted && i+1 < limit && text[0][i+1] == delimiter)
- {
- quoted = TRUE;
- continue;
- }
- token[k++] = text[0][i];
- quoted = FALSE;
- }
- token[k] = '\0';
- *text += i;
- return k;
-
-}
-
-