/* add a field containing the current token to the current line */ static struct field* add_field_from_token( struct parser *parser, int is_key) { PVOID field; if (!parser->line) /* need to start a new line */ { if (parser->cur_section == NULL) /* got a line before the first section */ { parser->error = STATUS_WRONG_INF_STYLE; return NULL; } parser->line = InfpCacheAddLine(parser->cur_section); if (parser->line == NULL) goto error; } else { // assert(!is_key); } if (is_key) { field = InfpAddKeyToLine(parser->line, parser->token); } else { field = InfpAddFieldToLine(parser->line, parser->token); } if (field != NULL) { parser->token_len = 0; return field; } error: parser->error = FALSE; return NULL; }
INFSTATUS InfpAddLineWithKey(PINFCONTEXT Context, PCWSTR Key) { if (NULL == Context) { DPRINT1("Invalid parameter\n"); return INF_STATUS_INVALID_PARAMETER; } Context->Line = InfpAddLine(Context->Section); if (NULL == Context->Line) { DPRINT("Failed to create line\n"); return INF_STATUS_NO_MEMORY; } if (NULL != Key && NULL == InfpAddKeyToLine(Context->Line, Key)) { DPRINT("Failed to add key\n"); return INF_STATUS_NO_MEMORY; } return INF_STATUS_SUCCESS; }