2016-10-11 22:31:45 +00:00
|
|
|
/*-
|
2021-04-09 22:35:08 +00:00
|
|
|
* Copyright (c) 2016-2021 Netflix, Inc.
|
2016-10-11 22:31:45 +00:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2016-10-13 06:56:23 +00:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
|
2016-10-11 22:31:45 +00:00
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
2016-10-13 06:56:23 +00:00
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
2016-10-11 22:31:45 +00:00
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <efivar.h>
|
2017-03-09 00:31:36 +00:00
|
|
|
#include <efivar-dp.h>
|
2016-10-11 22:31:45 +00:00
|
|
|
#include <err.h>
|
|
|
|
#include <errno.h>
|
2018-10-26 22:13:40 +00:00
|
|
|
#include <fcntl.h>
|
2016-10-11 22:31:45 +00:00
|
|
|
#include <getopt.h>
|
2021-04-09 22:35:08 +00:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdbool.h>
|
2016-10-11 22:31:45 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <unistd.h>
|
2017-09-07 07:30:19 +00:00
|
|
|
#include "efiutil.h"
|
2017-08-31 17:53:50 +00:00
|
|
|
#include "efichar.h"
|
2016-10-11 22:31:45 +00:00
|
|
|
|
|
|
|
/* options descriptor */
|
|
|
|
static struct option longopts[] = {
|
|
|
|
{ "append", no_argument, NULL, 'a' },
|
|
|
|
{ "ascii", no_argument, NULL, 'A' },
|
|
|
|
{ "attributes", required_argument, NULL, 't' },
|
|
|
|
{ "binary", no_argument, NULL, 'b' },
|
|
|
|
{ "delete", no_argument, NULL, 'D' },
|
2017-03-03 20:23:14 +00:00
|
|
|
{ "device", no_argument, NULL, 'd' },
|
|
|
|
{ "device-path", no_argument, NULL, 'd' },
|
2016-10-11 22:31:45 +00:00
|
|
|
{ "fromfile", required_argument, NULL, 'f' },
|
2017-03-03 20:23:10 +00:00
|
|
|
{ "guid", no_argument, NULL, 'g' },
|
2016-10-11 22:31:45 +00:00
|
|
|
{ "hex", no_argument, NULL, 'H' },
|
|
|
|
{ "list-guids", no_argument, NULL, 'L' },
|
|
|
|
{ "list", no_argument, NULL, 'l' },
|
2017-09-07 07:30:19 +00:00
|
|
|
{ "load-option", no_argument, NULL, 'O' },
|
2016-10-11 22:31:45 +00:00
|
|
|
{ "name", required_argument, NULL, 'n' },
|
|
|
|
{ "no-name", no_argument, NULL, 'N' },
|
|
|
|
{ "print", no_argument, NULL, 'p' },
|
2020-09-25 18:20:45 +00:00
|
|
|
// { "print-decimal", no_argument, NULL, 'd' }, /* unimplemnted clash with linux version */
|
2021-04-09 22:35:08 +00:00
|
|
|
{ "quiet", no_argument, NULL, 'q' },
|
2016-10-11 22:31:45 +00:00
|
|
|
{ "raw-guid", no_argument, NULL, 'R' },
|
2017-08-31 17:53:50 +00:00
|
|
|
{ "utf8", no_argument, NULL, 'u' },
|
2016-10-11 22:31:45 +00:00
|
|
|
{ "write", no_argument, NULL, 'w' },
|
|
|
|
{ NULL, 0, NULL, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2021-04-09 22:35:50 +00:00
|
|
|
static bool aflag, Aflag, bflag, dflag, Dflag, gflag, Hflag, Nflag,
|
|
|
|
lflag, Lflag, Rflag, wflag, pflag, uflag, load_opt_flag, quiet;
|
2016-10-11 22:31:45 +00:00
|
|
|
static char *varname;
|
2018-10-26 22:13:40 +00:00
|
|
|
static char *fromfile;
|
2016-10-16 05:53:18 +00:00
|
|
|
static u_long attrib = EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS;
|
2016-10-11 22:31:45 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
|
2021-04-09 22:35:08 +00:00
|
|
|
errx(1, "efivar [-abdDHlLNpqRtuw] [-n name] [-f file] [--append] [--ascii]\n"
|
2016-10-11 22:31:45 +00:00
|
|
|
"\t[--attributes] [--binary] [--delete] [--fromfile file] [--hex]\n"
|
2017-09-07 07:30:19 +00:00
|
|
|
"\t[--list-guids] [--list] [--load-option] [--name name] [--no-name]\n"
|
|
|
|
"\t[--print] [--print-decimal] [--raw-guid] [--utf8] [--write]\n"
|
2021-04-09 22:35:08 +00:00
|
|
|
"\t[--quiet]\n"
|
2017-09-07 07:30:19 +00:00
|
|
|
"\tname[=value]");
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
2021-04-09 22:35:08 +00:00
|
|
|
static void
|
|
|
|
rep_err(int eval, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
if (quiet)
|
|
|
|
exit(eval);
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
verr(eval, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
rep_errx(int eval, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list ap;
|
|
|
|
|
|
|
|
if (quiet)
|
|
|
|
exit(eval);
|
|
|
|
|
|
|
|
va_start(ap, fmt);
|
|
|
|
verrx(eval, fmt, ap);
|
|
|
|
va_end(ap);
|
|
|
|
}
|
|
|
|
|
2016-10-11 22:31:45 +00:00
|
|
|
static void
|
|
|
|
breakdown_name(char *name, efi_guid_t *guid, char **vname)
|
|
|
|
{
|
2021-04-09 22:35:17 +00:00
|
|
|
char *cp, *ocp;
|
|
|
|
|
|
|
|
ocp = NULL;
|
|
|
|
while (true) {
|
|
|
|
cp = strrchr(name, '-');
|
|
|
|
if (cp == NULL) {
|
|
|
|
if (ocp != NULL)
|
|
|
|
*ocp = '-';
|
|
|
|
rep_errx(1, "Invalid guid in: %s", name);
|
|
|
|
}
|
|
|
|
if (ocp != NULL)
|
|
|
|
*ocp = '-';
|
|
|
|
*vname = cp + 1;
|
|
|
|
*cp = '\0';
|
|
|
|
ocp = cp;
|
|
|
|
if (efi_name_to_guid(name, guid) >= 0)
|
|
|
|
break;
|
|
|
|
}
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t *
|
|
|
|
get_value(char *val, size_t *datalen)
|
|
|
|
{
|
|
|
|
static char buffer[16*1024];
|
|
|
|
|
|
|
|
if (val != NULL) {
|
|
|
|
*datalen = strlen(val);
|
|
|
|
return ((uint8_t *)val);
|
|
|
|
}
|
|
|
|
/* Read from stdin */
|
|
|
|
*datalen = sizeof(buffer);
|
|
|
|
*datalen = read(0, buffer, *datalen);
|
|
|
|
return ((uint8_t *)buffer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
append_variable(char *name, char *val)
|
|
|
|
{
|
|
|
|
char *vname;
|
|
|
|
efi_guid_t guid;
|
|
|
|
size_t datalen;
|
|
|
|
uint8_t *data;
|
|
|
|
|
|
|
|
breakdown_name(name, &guid, &vname);
|
|
|
|
data = get_value(val, &datalen);
|
|
|
|
if (efi_append_variable(guid, vname, data, datalen, attrib) < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "efi_append_variable");
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
delete_variable(char *name)
|
|
|
|
{
|
|
|
|
char *vname;
|
|
|
|
efi_guid_t guid;
|
|
|
|
|
|
|
|
breakdown_name(name, &guid, &vname);
|
|
|
|
if (efi_del_variable(guid, vname) < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "efi_del_variable");
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
write_variable(char *name, char *val)
|
|
|
|
{
|
|
|
|
char *vname;
|
|
|
|
efi_guid_t guid;
|
|
|
|
size_t datalen;
|
|
|
|
uint8_t *data;
|
|
|
|
|
|
|
|
breakdown_name(name, &guid, &vname);
|
|
|
|
data = get_value(val, &datalen);
|
2017-11-10 23:30:23 +00:00
|
|
|
if (efi_set_variable(guid, vname, data, datalen, attrib) < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "efi_set_variable");
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 20:23:14 +00:00
|
|
|
static void
|
|
|
|
devpath_dump(uint8_t *data, size_t datalen)
|
|
|
|
{
|
2017-03-09 00:31:36 +00:00
|
|
|
char buffer[1024];
|
2017-03-03 20:23:14 +00:00
|
|
|
|
2017-03-09 00:31:36 +00:00
|
|
|
efidp_format_device_path(buffer, sizeof(buffer),
|
|
|
|
(const_efidp)data, datalen);
|
|
|
|
if (!Nflag)
|
|
|
|
printf(": ");
|
|
|
|
printf("%s\n", buffer);
|
2017-03-03 20:23:14 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 20:23:10 +00:00
|
|
|
static void
|
|
|
|
pretty_guid(efi_guid_t *guid, char **gname)
|
|
|
|
{
|
|
|
|
char *pretty = NULL;
|
|
|
|
|
|
|
|
if (gflag)
|
|
|
|
efi_guid_to_name(guid, &pretty);
|
|
|
|
|
|
|
|
if (pretty == NULL)
|
|
|
|
efi_guid_to_str(guid, gname);
|
|
|
|
else
|
|
|
|
*gname = pretty;
|
|
|
|
}
|
|
|
|
|
2016-10-11 22:31:45 +00:00
|
|
|
static void
|
|
|
|
print_var(efi_guid_t *guid, char *name)
|
|
|
|
{
|
|
|
|
uint32_t att;
|
|
|
|
uint8_t *data;
|
|
|
|
size_t datalen;
|
2018-10-26 22:13:40 +00:00
|
|
|
char *gname = NULL;
|
2016-10-11 22:31:45 +00:00
|
|
|
int rv;
|
|
|
|
|
2018-10-26 22:13:40 +00:00
|
|
|
if (guid)
|
|
|
|
pretty_guid(guid, &gname);
|
|
|
|
if (pflag || fromfile) {
|
|
|
|
if (fromfile) {
|
|
|
|
int fd;
|
|
|
|
|
|
|
|
fd = open(fromfile, O_RDONLY);
|
|
|
|
if (fd < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "open %s", fromfile);
|
2018-10-26 22:13:40 +00:00
|
|
|
data = malloc(64 * 1024);
|
|
|
|
if (data == NULL)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "malloc");
|
2018-10-26 22:13:40 +00:00
|
|
|
datalen = read(fd, data, 64 * 1024);
|
2022-02-23 18:15:34 +00:00
|
|
|
if ((ssize_t)datalen < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "read");
|
2022-02-23 18:15:34 +00:00
|
|
|
if (datalen == 0)
|
|
|
|
rep_errx(1, "empty file");
|
2018-10-26 22:13:40 +00:00
|
|
|
close(fd);
|
|
|
|
} else {
|
|
|
|
rv = efi_get_variable(*guid, name, &data, &datalen, &att);
|
|
|
|
if (rv < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "fetching %s-%s", gname, name);
|
2018-10-26 22:13:40 +00:00
|
|
|
}
|
2016-10-11 22:31:45 +00:00
|
|
|
|
2017-02-25 00:09:26 +00:00
|
|
|
|
|
|
|
if (!Nflag)
|
2017-09-07 07:30:19 +00:00
|
|
|
printf("%s-%s\n", gname, name);
|
|
|
|
if (load_opt_flag)
|
|
|
|
efi_print_load_option(data, datalen, Aflag, bflag, uflag);
|
|
|
|
else if (Aflag)
|
2017-02-25 00:09:26 +00:00
|
|
|
asciidump(data, datalen);
|
2017-08-31 17:53:50 +00:00
|
|
|
else if (uflag)
|
|
|
|
utf8dump(data, datalen);
|
2017-02-25 00:09:26 +00:00
|
|
|
else if (bflag)
|
|
|
|
bindump(data, datalen);
|
2017-03-03 20:23:14 +00:00
|
|
|
else if (dflag)
|
|
|
|
devpath_dump(data, datalen);
|
2017-02-25 00:09:26 +00:00
|
|
|
else
|
|
|
|
hexdump(data, datalen);
|
2017-03-03 20:23:01 +00:00
|
|
|
} else {
|
|
|
|
printf("%s-%s", gname, name);
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
free(gname);
|
|
|
|
if (!Nflag)
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_variable(char *name)
|
|
|
|
{
|
|
|
|
char *vname;
|
|
|
|
efi_guid_t guid;
|
|
|
|
|
|
|
|
breakdown_name(name, &guid, &vname);
|
|
|
|
print_var(&guid, vname);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
print_variables(void)
|
|
|
|
{
|
|
|
|
int rv;
|
|
|
|
char *name = NULL;
|
|
|
|
efi_guid_t *guid = NULL;
|
|
|
|
|
|
|
|
while ((rv = efi_get_next_variable_name(&guid, &name)) > 0)
|
|
|
|
print_var(guid, name);
|
|
|
|
|
|
|
|
if (rv < 0)
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_err(1, "Error listing names");
|
2016-10-11 22:31:45 +00:00
|
|
|
}
|
|
|
|
|
2017-03-03 20:23:05 +00:00
|
|
|
static void
|
|
|
|
print_known_guid(void)
|
|
|
|
{
|
|
|
|
struct uuid_table *tbl;
|
|
|
|
int i, n;
|
|
|
|
|
|
|
|
n = efi_known_guid(&tbl);
|
|
|
|
for (i = 0; i < n; i++)
|
|
|
|
printf("%s %s\n", tbl[i].uuid_str, tbl[i].name);
|
|
|
|
}
|
|
|
|
|
2016-10-11 22:31:45 +00:00
|
|
|
static void
|
|
|
|
parse_args(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ch, i;
|
|
|
|
|
2021-04-09 22:35:08 +00:00
|
|
|
while ((ch = getopt_long(argc, argv, "aAbdDf:gHlLNn:OpqRt:uw",
|
2016-10-11 22:31:45 +00:00
|
|
|
longopts, NULL)) != -1) {
|
|
|
|
switch (ch) {
|
|
|
|
case 'a':
|
2021-04-09 22:35:50 +00:00
|
|
|
aflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'A':
|
2021-04-09 22:35:50 +00:00
|
|
|
Aflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'b':
|
2021-04-09 22:35:50 +00:00
|
|
|
bflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'd':
|
2021-04-09 22:35:50 +00:00
|
|
|
dflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'D':
|
2021-04-09 22:35:50 +00:00
|
|
|
Dflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
2017-03-03 20:23:10 +00:00
|
|
|
case 'g':
|
2021-04-09 22:35:50 +00:00
|
|
|
gflag = true;
|
2017-03-03 20:23:10 +00:00
|
|
|
break;
|
2016-10-11 22:31:45 +00:00
|
|
|
case 'H':
|
2021-04-09 22:35:50 +00:00
|
|
|
Hflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'l':
|
2021-04-09 22:35:50 +00:00
|
|
|
lflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'L':
|
2021-04-09 22:35:50 +00:00
|
|
|
Lflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'n':
|
|
|
|
varname = optarg;
|
|
|
|
break;
|
|
|
|
case 'N':
|
2021-04-09 22:35:50 +00:00
|
|
|
Nflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
2017-09-07 07:30:19 +00:00
|
|
|
case 'O':
|
2021-04-09 22:35:50 +00:00
|
|
|
load_opt_flag = true;
|
2017-09-07 07:30:19 +00:00
|
|
|
break;
|
2016-10-11 22:31:45 +00:00
|
|
|
case 'p':
|
2021-04-09 22:35:50 +00:00
|
|
|
pflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
2021-04-09 22:35:08 +00:00
|
|
|
case 'q':
|
|
|
|
quiet = true;
|
|
|
|
break;
|
2016-10-11 22:31:45 +00:00
|
|
|
case 'R':
|
2021-04-09 22:35:50 +00:00
|
|
|
Rflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
2016-10-15 06:16:35 +00:00
|
|
|
case 't':
|
|
|
|
attrib = strtoul(optarg, NULL, 16);
|
|
|
|
break;
|
2017-08-31 17:53:50 +00:00
|
|
|
case 'u':
|
2021-04-09 22:35:50 +00:00
|
|
|
uflag = true;
|
2017-08-31 17:53:50 +00:00
|
|
|
break;
|
2016-10-11 22:31:45 +00:00
|
|
|
case 'w':
|
2021-04-09 22:35:50 +00:00
|
|
|
wflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
case 'f':
|
2018-10-26 22:13:40 +00:00
|
|
|
free(fromfile);
|
|
|
|
fromfile = strdup(optarg);
|
|
|
|
break;
|
2016-10-11 22:31:45 +00:00
|
|
|
case 0:
|
2021-04-09 22:35:08 +00:00
|
|
|
rep_errx(1, "unknown or unimplemented option\n");
|
2016-10-11 22:31:45 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
if (argc == 1)
|
|
|
|
varname = argv[0];
|
|
|
|
|
2021-04-09 22:35:50 +00:00
|
|
|
if ((int)aflag + (int)Dflag + (int)wflag > 1) {
|
2016-10-11 22:31:45 +00:00
|
|
|
warnx("Can only use one of -a (--append), "
|
|
|
|
"-D (--delete) and -w (--write)");
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
2021-04-09 22:35:50 +00:00
|
|
|
if ((int)aflag + (int)Dflag + (int)wflag > 0 && varname == NULL) {
|
2016-10-11 22:31:45 +00:00
|
|
|
warnx("Must specify a variable for -a (--append), "
|
|
|
|
"-D (--delete) or -w (--write)");
|
|
|
|
usage();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (aflag)
|
|
|
|
append_variable(varname, NULL);
|
|
|
|
else if (Dflag)
|
|
|
|
delete_variable(varname);
|
|
|
|
else if (wflag)
|
|
|
|
write_variable(varname, NULL);
|
2017-03-03 20:23:05 +00:00
|
|
|
else if (Lflag)
|
|
|
|
print_known_guid();
|
2018-10-26 22:13:40 +00:00
|
|
|
else if (fromfile) {
|
2021-04-09 22:35:50 +00:00
|
|
|
Nflag = true;
|
2018-10-26 22:13:40 +00:00
|
|
|
print_var(NULL, NULL);
|
|
|
|
} else if (varname) {
|
2021-04-09 22:35:50 +00:00
|
|
|
pflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
print_variable(varname);
|
|
|
|
} else if (argc > 0) {
|
2021-04-09 22:35:50 +00:00
|
|
|
pflag = true;
|
2016-10-11 22:31:45 +00:00
|
|
|
for (i = 0; i < argc; i++)
|
|
|
|
print_variable(argv[i]);
|
|
|
|
} else
|
|
|
|
print_variables();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
parse_args(argc, argv);
|
|
|
|
}
|