265 |
return count; |
return count; |
266 |
} |
} |
267 |
|
|
268 |
|
static int isquote(char q) |
269 |
|
{ |
270 |
|
if (q == '\'' || q == '\"') |
271 |
|
return 1; |
272 |
|
return 0; |
273 |
|
} |
274 |
|
|
275 |
char *grub2ExtractTitle(struct singleLine * line) { |
char *grub2ExtractTitle(struct singleLine * line) { |
276 |
char * current; |
char * current; |
277 |
char * current_indent; |
char * current_indent; |
288 |
current_len = strlen(current); |
current_len = strlen(current); |
289 |
|
|
290 |
/* if second word is quoted, strip the quotes and return single word */ |
/* if second word is quoted, strip the quotes and return single word */ |
291 |
if ((*current == '\'') && (*(current + current_len - 1) == '\'')) { |
if (isquote(*current) && isquote(current[current_len - 1])) { |
292 |
char *tmp; |
char *tmp; |
293 |
|
|
294 |
tmp = strdup(current); |
tmp = strdup(current); |
295 |
*(tmp + current_len - 1) = '\0'; |
*(tmp + current_len - 1) = '\0'; |
296 |
return ++tmp; |
return ++tmp; |
297 |
} |
} |
298 |
|
|
299 |
/* if no quotes, return second word verbatim */ |
/* if no quotes, return second word verbatim */ |
300 |
if (*current != '\'') { |
if (!isquote(*current)) |
301 |
return current; |
return current; |
|
} |
|
302 |
|
|
303 |
/* second element start with a quote, so we have to find the element |
/* second element start with a quote, so we have to find the element |
304 |
* whose last character is also quote (assuming it's the closing one) */ |
* whose last character is also quote (assuming it's the closing one) */ |
305 |
if (*current == '\'') { |
int resultMaxSize; |
306 |
int resultMaxSize; |
char * result; |
307 |
char * result; |
|
308 |
|
resultMaxSize = sizeOfSingleLine(line); |
309 |
resultMaxSize = sizeOfSingleLine(line); |
result = malloc(resultMaxSize); |
310 |
result = malloc(resultMaxSize); |
snprintf(result, resultMaxSize, "%s", ++current); |
311 |
snprintf(result, resultMaxSize, "%s", ++current); |
|
312 |
|
i++; |
313 |
i++; |
for (; i < line->numElements; ++i) { |
|
for (; i < line->numElements; ++i) { |
|
314 |
current = line->elements[i].item; |
current = line->elements[i].item; |
315 |
current_len = strlen(current); |
current_len = strlen(current); |
316 |
current_indent = line->elements[i].indent; |
current_indent = line->elements[i].indent; |
317 |
current_indent_len = strlen(current_indent); |
current_indent_len = strlen(current_indent); |
318 |
|
|
319 |
strncat(result, current_indent, current_indent_len); |
strncat(result, current_indent, current_indent_len); |
320 |
if (*(current + current_len - 1) != '\'') { |
if (!isquote(current[current_len-1])) { |
321 |
strncat(result, current, current_len); |
strncat(result, current, current_len); |
322 |
} else { |
} else { |
323 |
strncat(result, current, current_len - 1); |
strncat(result, current, current_len - 1); |
324 |
break; |
break; |
325 |
} |
} |
|
} |
|
|
return result; |
|
326 |
} |
} |
327 |
|
return result; |
|
return NULL; |
|
328 |
} |
} |
329 |
|
|
330 |
struct configFileInfo grub2ConfigType = { |
struct configFileInfo grub2ConfigType = { |
1928 |
printf("%s%s", line->elements[i].item, line->elements[i].indent); |
printf("%s%s", line->elements[i].item, line->elements[i].indent); |
1929 |
printf("\n"); |
printf("\n"); |
1930 |
} |
} |
1931 |
|
|
1932 |
|
line = getLineByType(LT_TITLE, entry->lines); |
1933 |
|
if (line) { |
1934 |
|
printf("title=%s\n", line->elements[1].item); |
1935 |
|
} else { |
1936 |
|
char * title; |
1937 |
|
line = getLineByType(LT_MENUENTRY, entry->lines); |
1938 |
|
title = grub2ExtractTitle(line); |
1939 |
|
if (title) |
1940 |
|
printf("title=%s\n", title); |
1941 |
|
} |
1942 |
} |
} |
1943 |
|
|
1944 |
int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { |
int parseSysconfigGrub(int * lbaPtr, char ** bootPtr) { |
2193 |
free(line); |
free(line); |
2194 |
} |
} |
2195 |
|
|
|
static int isquote(char q) |
|
|
{ |
|
|
if (q == '\'' || q == '\"') |
|
|
return 1; |
|
|
return 0; |
|
|
} |
|
|
|
|
2196 |
static void requote(struct singleLine *tmplLine, struct configFileInfo * cfi) |
static void requote(struct singleLine *tmplLine, struct configFileInfo * cfi) |
2197 |
{ |
{ |
2198 |
struct singleLine newLine = { |
struct singleLine newLine = { |