]>
git.proxmox.com Git - grub2.git/blob - util/config.c
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2013 Free Software Foundation, Inc.
5 * GRUB is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * GRUB is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
23 #include <grub/emu/config.h>
24 #include <grub/util/misc.h>
27 grub_util_parse_config (FILE *f
, struct grub_util_config
*cfg
, int simple
)
31 while (getline (&buffer
, &sz
, f
) >= 0)
34 for (ptr
= buffer
; *ptr
&& grub_isspace (*ptr
); ptr
++);
35 if (grub_strncmp (ptr
, "GRUB_ENABLE_CRYPTODISK=",
36 sizeof ("GRUB_ENABLE_CRYPTODISK=") - 1) == 0)
38 ptr
+= sizeof ("GRUB_ENABLE_CRYPTODISK=") - 1;
39 if (*ptr
== '"' || *ptr
== '\'')
42 cfg
->is_cryptodisk_enabled
= 1;
45 if (grub_strncmp (ptr
, "GRUB_DISTRIBUTOR=",
46 sizeof ("GRUB_DISTRIBUTOR=") - 1) == 0)
49 enum { NONE
, SNGLQUOT
, DBLQUOT
} state
;
51 ptr
+= sizeof ("GRUB_DISTRIBUTOR=") - 1;
56 free (cfg
->grub_distributor
);
57 cfg
->grub_distributor
= xstrdup (ptr
);
58 for (ptr2
= cfg
->grub_distributor
59 + grub_strlen (cfg
->grub_distributor
) - 1;
60 ptr2
>= cfg
->grub_distributor
61 && (*ptr2
== '\r' || *ptr2
== '\n'); ptr2
--);
65 free (cfg
->grub_distributor
);
66 cfg
->grub_distributor
= xmalloc (strlen (ptr
) + 1);
67 optr
= cfg
->grub_distributor
;
74 if (state
== SNGLQUOT
)
101 if (state
== SNGLQUOT
)