Revision d246b3cf libcacard/vcard_emul_nss.c

b/libcacard/vcard_emul_nss.c
1105 1105
static VCardEmulOptions options;
1106 1106
#define READER_STEP 4
1107 1107

  
1108
/* Expects "args" to be at the beginning of a token (ie right after the ','
1109
 * ending the previous token), and puts the next token start in "token",
1110
 * and its length in "token_length". "token" will not be nul-terminated.
1111
 * After calling the macro, "args" will be advanced to the beginning of
1112
 * the next token.
1113
 * This macro may call continue or break.
1114
 */
1115
#define NEXT_TOKEN(token) \
1116
            (token) = args; \
1117
            args = strpbrk(args, ",)"); \
1118
            if (*args == 0) { \
1119
                break; \
1120
            } \
1121
            if (*args == ')') { \
1122
                args++; \
1123
                continue; \
1124
            } \
1125
            (token##_length) = args - (token); \
1126
            args = strip(args+1);
1127

  
1108 1128
VCardEmulOptions *
1109 1129
vcard_emul_options(const char *args)
1110 1130
{
......
1140 1160
            }
1141 1161
            args = strip(args+1);
1142 1162

  
1143
            name = args;
1144
            args = strpbrk(args, ",)");
1145
            if (*args == 0) {
1146
                break;
1147
            }
1148
            if (*args == ')') {
1149
                args++;
1150
                continue;
1151
            }
1152
            name_length = args - name;
1153
            args = strip(args+1);
1154

  
1155
            vname = args;
1156
            args = strpbrk(args, ",)");
1157
            if (*args == 0) {
1158
                break;
1159
            }
1160
            if (*args == ')') {
1161
                args++;
1162
                continue;
1163
            }
1164
            vname_length = args - vname;
1165
            args = strip(args+1);
1166

  
1167
            type_params = args;
1168
            args = strpbrk(args, ",)");
1169
            if (*args == 0) {
1170
                break;
1171
            }
1172
            if (*args == ')') {
1173
                args++;
1174
                continue;
1175
            }
1176
            type_params_length = args - type_params;
1177
            args = strip(args+1);
1178

  
1163
            NEXT_TOKEN(name)
1164
            NEXT_TOKEN(vname)
1165
            NEXT_TOKEN(type_params)
1179 1166
            type_params_length = MIN(type_params_length, sizeof(type_str)-1);
1180 1167
            strncpy(type_str, type_params, type_params_length);
1181 1168
            type_str[type_params_length] = 0;
1182 1169
            type = vcard_emul_type_from_string(type_str);
1183 1170

  
1184
            type_params = args;
1185
            args = strpbrk(args, ",)");
1186
            if (*args == 0) {
1187
                break;
1188
            }
1189
            if (*args == ')') {
1190
                args++;
1191
                continue;
1192
            }
1193
            type_params_length = args - type_params;
1194
            args = strip(args+1);
1171
            NEXT_TOKEN(type_params)
1195 1172

  
1196 1173
            if (*args == 0) {
1197 1174
                break;

Also available in: Unified diff