Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 #ifdef HAVE_CONFIG_H
00028 # include "config.h"
00029 #endif
00030
00031
00032 #include "parser.h"
00033
00034
00035 #include <string.h>
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 int
00046 digest_md5_getsubopt (char **optionp,
00047 const char *const *tokens, char **valuep)
00048 {
00049 char *endp, *vstart;
00050 int cnt;
00051 int inside_quote = 0;
00052
00053 if (**optionp == '\0')
00054 return -1;
00055
00056
00057 endp = *optionp;
00058 while (*endp != '\0' && (inside_quote || (!inside_quote && *endp != ',')))
00059 {
00060 if (*endp == '"')
00061 inside_quote = !inside_quote;
00062 endp++;
00063 }
00064
00065
00066 vstart = memchr (*optionp, '=', endp - *optionp);
00067 if (vstart == NULL)
00068 vstart = endp;
00069
00070
00071
00072 for (cnt = 0; tokens[cnt] != NULL; ++cnt)
00073 if (memcmp (*optionp, tokens[cnt], vstart - *optionp) == 0
00074 && tokens[cnt][vstart - *optionp] == '\0')
00075 {
00076
00077 *valuep = vstart != endp ? vstart + 1 : NULL;
00078
00079 while (*valuep && (**valuep == ' ' ||
00080 **valuep == '\t' ||
00081 **valuep == '\r' ||
00082 **valuep == '\n' || **valuep == '"'))
00083 (*valuep)++;
00084
00085 if (*endp != '\0')
00086 {
00087 *endp = '\0';
00088 *optionp = endp + 1;
00089 }
00090 else
00091 *optionp = endp;
00092 endp--;
00093 while (*endp == ' ' ||
00094 *endp == '\t' ||
00095 *endp == '\r' || *endp == '\n' || *endp == '"')
00096 *endp-- = '\0';
00097 while (**optionp == ' ' ||
00098 **optionp == '\t' || **optionp == '\r' || **optionp == '\n')
00099 (*optionp)++;
00100
00101 return cnt;
00102 }
00103
00104
00105 *valuep = *optionp;
00106
00107 if (*endp != '\0')
00108 *endp++ = '\0';
00109 *optionp = endp;
00110 while (**optionp == ' ' ||
00111 **optionp == '\t' || **optionp == '\r' || **optionp == '\n')
00112 (*optionp)++;
00113
00114 return -1;
00115 }