/* add a section with the current token as name */ static PVOID add_section_from_token( struct parser *parser ) { PINFCACHESECTION Section; if (parser->token_len > MAX_SECTION_NAME_LEN) { parser->error = INF_STATUS_SECTION_NAME_TOO_LONG; return NULL; } Section = InfpFindSection(parser->file, parser->token); if (Section == NULL) { /* need to create a new one */ Section= InfpAddSection(parser->file, parser->token); if (Section == NULL) { parser->error = INF_STATUS_NOT_ENOUGH_MEMORY; return NULL; } } parser->token_len = 0; parser->cur_section = Section; return (PVOID)Section; }
INFSTATUS InfpFindOrAddSection(PINFCACHE Cache, PCWSTR Section, PINFCONTEXT *Context) { DPRINT("InfpFindOrAddSection section %S\n", Section); *Context = MALLOC(sizeof(INFCONTEXT)); if (NULL == *Context) { DPRINT1("MALLOC() failed\n"); return INF_STATUS_NO_MEMORY; } (*Context)->Inf = Cache; (*Context)->Section = InfpFindSection(Cache, Section); (*Context)->Line = NULL; if (NULL == (*Context)->Section) { DPRINT("Section not found, creating it\n"); (*Context)->Section = InfpAddSection(Cache, Section); if (NULL == (*Context)->Section) { DPRINT("Failed to create section\n"); FREE(*Context); return INF_STATUS_NO_MEMORY; } } return INF_STATUS_SUCCESS; }