Try and get a lock on the semaphore, if not then just move on as some housekeeping...
[AROS.git] / arch / all-pc / boot / grub2-aros / util / grub-glue-efi.c
blob07fa43030fa0d33037a7292ac031a5284e4b1e6e
1 /*
2 * GRUB -- GRand Unified Bootloader
3 * Copyright (C) 2010,2012,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/>.
19 #include <config.h>
21 #include <grub/util/misc.h>
22 #include <grub/i18n.h>
23 #include <grub/term.h>
24 #include <grub/macho.h>
25 #include <grub/util/install.h>
27 #define _GNU_SOURCE 1
29 #include <stdio.h>
30 #include <stdlib.h>
31 #include <string.h>
32 #include <unistd.h>
33 #include <errno.h>
35 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
36 #pragma GCC diagnostic ignored "-Wmissing-declarations"
37 #include <argp.h>
38 #pragma GCC diagnostic error "-Wmissing-prototypes"
39 #pragma GCC diagnostic error "-Wmissing-declarations"
41 #include "progname.h"
43 struct arguments
45 char *input32;
46 char *input64;
47 char *output;
48 int verbosity;
51 static struct argp_option options[] = {
52 {"input32", '3', N_("FILE"), 0,
53 N_("set input filename for 32-bit part."), 0},
54 {"input64", '6', N_("FILE"), 0,
55 N_("set input filename for 64-bit part."), 0},
56 {"output", 'o', N_("FILE"), 0,
57 N_("set output filename. Default is STDOUT"), 0},
58 {"verbose", 'v', 0, 0, N_("print verbose messages."), 0},
59 { 0, 0, 0, 0, 0, 0 }
62 static error_t
63 argp_parser (int key, char *arg, struct argp_state *state)
65 /* Get the input argument from argp_parse, which we
66 know is a pointer to our arguments structure. */
67 struct arguments *arguments = state->input;
69 switch (key)
71 case '6':
72 arguments->input64 = xstrdup (arg);
73 break;
74 case '3':
75 arguments->input32 = xstrdup (arg);
76 break;
78 case 'o':
79 arguments->output = xstrdup (arg);
80 break;
82 case 'v':
83 arguments->verbosity++;
84 break;
86 default:
87 return ARGP_ERR_UNKNOWN;
90 return 0;
93 static struct argp argp = {
94 options, argp_parser, N_("[OPTIONS]"),
95 N_("Glue 32-bit and 64-bit binary into Apple universal one."),
96 NULL, NULL, NULL
99 int
100 main (int argc, char *argv[])
102 struct arguments arguments;
104 grub_util_host_init (&argc, &argv);
106 /* Check for options. */
107 memset (&arguments, 0, sizeof (struct arguments));
108 if (argp_parse (&argp, argc, argv, 0, 0, &arguments) != 0)
110 fprintf (stderr, "%s", _("Error in parsing command line arguments\n"));
111 exit(1);
114 if (!arguments.input32 || !arguments.input64)
116 fprintf (stderr, "%s", _("Missing input file\n"));
117 exit(1);
120 grub_util_glue_efi (arguments.input32,
121 arguments.input64,
122 arguments.output);
124 return 0;