Magellan Linux

Contents of /trunk/mkinitrd-magellan/busybox/coreutils/printenv.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 532 - (show annotations) (download)
Sat Sep 1 22:45:15 2007 UTC (16 years, 8 months ago) by niro
File MIME type: text/plain
File size: 867 byte(s)
-import if magellan mkinitrd; it is a fork of redhats mkinitrd-5.0.8 with all magellan patches and features; deprecates magellan-src/mkinitrd

1 /* vi: set sw=4 ts=4: */
2 /*
3 * printenv implementation for busybox
4 *
5 * Copyright (C) 2005 by Erik Andersen <andersen@codepoet.org>
6 * Copyright (C) 2005 by Mike Frysinger <vapier@gentoo.org>
7 *
8 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
9 */
10
11 #include <stdio.h>
12 #include <string.h>
13 #include <stdlib.h>
14 #include "busybox.h"
15
16 int printenv_main(int argc, char **argv)
17 {
18 extern char **environ;
19 int e = 0;
20
21 /* no variables specified, show whole env */
22 if (argc == 1)
23 while (environ[e])
24 puts(environ[e++]);
25
26 /* search for specified variables and print them out if found */
27 else {
28 int i;
29 size_t l;
30 char *arg, *env;
31
32 for (i=1; (arg = argv[i]); ++i)
33 for (; (env = environ[e]); ++e) {
34 l = strlen(arg);
35 if (!strncmp(env, arg, l) && env[l] == '=')
36 puts(env + l + 1);
37 }
38 }
39
40 fflush_stdout_and_exit(0);
41 }