sysctl: fix coding style
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
1cde286c75
commit
8fe81caa42
282
sysctl.c
282
sysctl.c
@ -1,16 +1,13 @@
|
||||
|
||||
/*
|
||||
* Sysctl 1.01 - A utility to read and manipulate the sysctl parameters
|
||||
*
|
||||
*
|
||||
* "Copyright 1999 George Staikos
|
||||
* This file may be used subject to the terms and conditions of the
|
||||
* GNU General Public License Version 2, or any later version
|
||||
* at your option, as published by the Free Software Foundation.
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details."
|
||||
* This file may be used subject to the terms and conditions of the GNU
|
||||
* General Public License Version 2, or any later version at your option, as
|
||||
* published by the Free Software Foundation. This program is distributed in
|
||||
* the hope that it will be useful, but WITHOUT ANY WARRANTY; without even
|
||||
* the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||
* PURPOSE. See the GNU General Public License for more details."
|
||||
*
|
||||
* Changelog:
|
||||
* v1.01:
|
||||
@ -21,7 +18,6 @@
|
||||
* Changes by Albert Cahalan, 2002.
|
||||
*/
|
||||
|
||||
|
||||
#include <dirent.h>
|
||||
#include <errno.h>
|
||||
#include <getopt.h>
|
||||
@ -41,7 +37,6 @@
|
||||
#include "proc/procps.h"
|
||||
#include "proc/version.h"
|
||||
|
||||
|
||||
/* Proof that C++ causes brain damage: */
|
||||
typedef int bool;
|
||||
static bool true = 1;
|
||||
@ -50,7 +45,6 @@ static bool false = 0;
|
||||
/*
|
||||
* Globals...
|
||||
*/
|
||||
|
||||
static const char PROC_PATH[] = "/proc/sys/";
|
||||
static const char DEFAULT_PRELOAD[] = "/etc/sysctl.conf";
|
||||
static bool NameOnly;
|
||||
@ -60,37 +54,44 @@ static bool IgnoreError;
|
||||
static bool Quiet;
|
||||
static char *pattern;
|
||||
|
||||
/* Function prototypes. */
|
||||
static int pattern_match(const char *string, const char *pattern);
|
||||
static int DisplayAll(const char *restrict const path);
|
||||
|
||||
static void slashdot(char *restrict p, char old, char new){
|
||||
static void slashdot(char *restrict p, char old, char new)
|
||||
{
|
||||
int warned = 1;
|
||||
p = strpbrk(p,"/.");
|
||||
if(!p) return; /* nothing -- can't be, but oh well */
|
||||
if(*p==new) return; /* already in desired format */
|
||||
while(p){
|
||||
p = strpbrk(p, "/.");
|
||||
if (!p)
|
||||
/* nothing -- can't be, but oh well */
|
||||
return;
|
||||
if (*p == new)
|
||||
/* already in desired format */
|
||||
return;
|
||||
while (p) {
|
||||
char c = *p;
|
||||
if((*(p+1) == '/' || *(p+1) == '.') && warned) {
|
||||
if ((*(p + 1) == '/' || *(p + 1) == '.') && warned) {
|
||||
xwarnx(_("separators should not be repeated: %s"), p);
|
||||
warned = 0;
|
||||
}
|
||||
if(c==old) *p=new;
|
||||
if(c==new) *p=old;
|
||||
p = strpbrk(p+1,"/.");
|
||||
if (c == old)
|
||||
*p = new;
|
||||
if (c == new)
|
||||
*p = old;
|
||||
p = strpbrk(p + 1, "/.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Display the usage format
|
||||
*
|
||||
*/
|
||||
static void __attribute__ ((__noreturn__))
|
||||
Usage(FILE * out)
|
||||
{
|
||||
fputs(USAGE_HEADER, out);
|
||||
fprintf(out,
|
||||
_(" %s [options] [variable[=value] ...]\n"), program_invocation_short_name);
|
||||
_(" %s [options] [variable[=value] ...]\n"),
|
||||
program_invocation_short_name);
|
||||
fputs(USAGE_OPTIONS, out);
|
||||
fputs(_(" -a, --all display all variables\n"
|
||||
" -A alias of -a\n"
|
||||
@ -119,35 +120,33 @@ static void __attribute__ ((__noreturn__))
|
||||
|
||||
/*
|
||||
* Strip the leading and trailing spaces from a string
|
||||
*
|
||||
*/
|
||||
static char *StripLeadingAndTrailingSpaces(char *oneline) {
|
||||
static char *StripLeadingAndTrailingSpaces(char *oneline)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (!oneline || !*oneline)
|
||||
return oneline;
|
||||
|
||||
t = oneline;
|
||||
t += strlen(oneline)-1;
|
||||
t += strlen(oneline) - 1;
|
||||
|
||||
while ((*t==' ' || *t=='\t' || *t=='\n' || *t=='\r') && t!=oneline)
|
||||
while ((*t == ' ' || *t == '\t' || *t == '\n' || *t == '\r') && t != oneline)
|
||||
*t-- = 0;
|
||||
|
||||
t = oneline;
|
||||
|
||||
while ((*t==' ' || *t=='\t') && *t!=0)
|
||||
while ((*t == ' ' || *t == '\t') && *t != 0)
|
||||
t++;
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
static int DisplayAll(const char *restrict const path);
|
||||
|
||||
/*
|
||||
* Read a sysctl setting
|
||||
*
|
||||
*/
|
||||
static int ReadSetting(const char *restrict const name) {
|
||||
static int ReadSetting(const char *restrict const name)
|
||||
{
|
||||
int rc = 0;
|
||||
char *restrict tmpname;
|
||||
char *restrict outname;
|
||||
@ -162,17 +161,20 @@ static int ReadSetting(const char *restrict const name) {
|
||||
|
||||
/* used to display the output */
|
||||
outname = xstrdup(name);
|
||||
slashdot(outname,'/','.'); /* change / to . */
|
||||
/* change / to . */
|
||||
slashdot(outname, '/', '.');
|
||||
|
||||
/* used to open the file */
|
||||
tmpname = xmalloc(strlen(name)+strlen(PROC_PATH)+2);
|
||||
tmpname = xmalloc(strlen(name) + strlen(PROC_PATH) + 2);
|
||||
strcpy(tmpname, PROC_PATH);
|
||||
strcat(tmpname, name);
|
||||
slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
|
||||
/* change . to / */
|
||||
slashdot(tmpname + strlen(PROC_PATH), '.', '/');
|
||||
|
||||
/* used to display the output */
|
||||
outname = xstrdup(name);
|
||||
slashdot(outname,'/','.'); /* change / to . */
|
||||
/* change / to . */
|
||||
slashdot(outname, '/', '.');
|
||||
|
||||
if (stat(tmpname, &ts) < 0) {
|
||||
if (!IgnoreError) {
|
||||
@ -188,12 +190,12 @@ static int ReadSetting(const char *restrict const name) {
|
||||
size_t len;
|
||||
len = strlen(tmpname);
|
||||
tmpname[len] = '/';
|
||||
tmpname[len+1] = '\0';
|
||||
tmpname[len + 1] = '\0';
|
||||
rc = DisplayAll(tmpname);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (pattern && !pattern_match(outname, pattern)){
|
||||
if (pattern && !pattern_match(outname, pattern)) {
|
||||
free(outname);
|
||||
return 0;
|
||||
}
|
||||
@ -201,7 +203,7 @@ static int ReadSetting(const char *restrict const name) {
|
||||
fp = fopen(tmpname, "r");
|
||||
|
||||
if (!fp) {
|
||||
switch(errno) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
if (!IgnoreError) {
|
||||
xwarnx(_("\"%s\" is an unknown key"), outname);
|
||||
@ -219,36 +221,41 @@ static int ReadSetting(const char *restrict const name) {
|
||||
}
|
||||
} else {
|
||||
errno = 0;
|
||||
if(fgets(inbuf, sizeof inbuf - 1, fp)) {
|
||||
// this loop is required, see
|
||||
// /sbin/sysctl -a | egrep -6 dev.cdrom.info
|
||||
if (fgets(inbuf, sizeof inbuf - 1, fp)) {
|
||||
/* this loop is required, see
|
||||
* /sbin/sysctl -a | egrep -6 dev.cdrom.info
|
||||
*/
|
||||
do {
|
||||
if (NameOnly) {
|
||||
fprintf(stdout, "%s\n", outname);
|
||||
} else {
|
||||
/* already has the \n in it */
|
||||
if (PrintName) {
|
||||
fprintf(stdout, "%s = %s", outname, inbuf);
|
||||
fprintf(stdout, "%s = %s",
|
||||
outname, inbuf);
|
||||
} else {
|
||||
if (!PrintNewline) {
|
||||
char *nlptr = strchr(inbuf,'\n');
|
||||
if(nlptr) *nlptr='\0';
|
||||
char *nlptr =
|
||||
strchr(inbuf, '\n');
|
||||
if (nlptr)
|
||||
*nlptr = '\0';
|
||||
}
|
||||
fprintf(stdout, "%s", inbuf);
|
||||
}
|
||||
}
|
||||
} while(fgets(inbuf, sizeof inbuf - 1, fp));
|
||||
} while (fgets(inbuf, sizeof inbuf - 1, fp));
|
||||
} else {
|
||||
switch(errno) {
|
||||
switch (errno) {
|
||||
case EACCES:
|
||||
xwarnx(_("permission denied on key '%s'"), outname);
|
||||
xwarnx(_("permission denied on key '%s'"),
|
||||
outname);
|
||||
rc = -1;
|
||||
break;
|
||||
case EISDIR:{
|
||||
case EISDIR: {
|
||||
size_t len;
|
||||
len = strlen(tmpname);
|
||||
tmpname[len] = '/';
|
||||
tmpname[len+1] = '\0';
|
||||
tmpname[len + 1] = '\0';
|
||||
fclose(fp);
|
||||
rc = DisplayAll(tmpname);
|
||||
goto out;
|
||||
@ -262,19 +269,17 @@ static int ReadSetting(const char *restrict const name) {
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
out:
|
||||
out:
|
||||
free(tmpname);
|
||||
free(outname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Display all the sysctl settings
|
||||
*
|
||||
*/
|
||||
static int DisplayAll(const char *restrict const path) {
|
||||
static int DisplayAll(const char *restrict const path)
|
||||
{
|
||||
int rc = 0;
|
||||
int rc2;
|
||||
DIR *restrict dp;
|
||||
@ -287,11 +292,14 @@ static int DisplayAll(const char *restrict const path) {
|
||||
xwarnx(_("unable to open directory \"%s\""), path);
|
||||
rc = -1;
|
||||
} else {
|
||||
readdir(dp); // skip .
|
||||
readdir(dp); // skip ..
|
||||
while (( de = readdir(dp) )) {
|
||||
readdir(dp); /* skip . */
|
||||
readdir(dp); /* skip .. */
|
||||
while ((de = readdir(dp))) {
|
||||
char *restrict tmpdir;
|
||||
tmpdir = (char *restrict)xmalloc(strlen(path)+strlen(de->d_name)+2);
|
||||
tmpdir =
|
||||
(char *restrict) xmalloc(strlen(path) +
|
||||
strlen(de->d_name) +
|
||||
2);
|
||||
sprintf(tmpdir, "%s%s", path, de->d_name);
|
||||
rc2 = stat(tmpdir, &ts);
|
||||
if (rc2 != 0) {
|
||||
@ -301,7 +309,9 @@ static int DisplayAll(const char *restrict const path) {
|
||||
strcat(tmpdir, "/");
|
||||
DisplayAll(tmpdir);
|
||||
} else {
|
||||
rc |= ReadSetting(tmpdir+strlen(PROC_PATH));
|
||||
rc |=
|
||||
ReadSetting(tmpdir +
|
||||
strlen(PROC_PATH));
|
||||
}
|
||||
}
|
||||
free(tmpdir);
|
||||
@ -311,12 +321,11 @@ static int DisplayAll(const char *restrict const path) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write a sysctl setting
|
||||
*
|
||||
*/
|
||||
static int WriteSetting(const char *setting) {
|
||||
static int WriteSetting(const char *setting)
|
||||
{
|
||||
int rc = 0;
|
||||
const char *name = setting;
|
||||
const char *value;
|
||||
@ -326,18 +335,20 @@ static int WriteSetting(const char *setting) {
|
||||
FILE *fp;
|
||||
struct stat ts;
|
||||
|
||||
if (!name) { /* probably don't want to display this err */
|
||||
if (!name)
|
||||
/* probably don't want to display this err */
|
||||
return 0;
|
||||
} /* end if */
|
||||
|
||||
equals = strchr(setting, '=');
|
||||
|
||||
if (!equals) {
|
||||
xwarnx(_("\"%s\" must be of the form name=value"), setting);
|
||||
xwarnx(_("\"%s\" must be of the form name=value"),
|
||||
setting);
|
||||
return -1;
|
||||
}
|
||||
|
||||
value = equals + 1; /* point to the value in name=value */
|
||||
/* point to the value in name=value */
|
||||
value = equals + 1;
|
||||
|
||||
if (!*name || !*value || name == equals) {
|
||||
xwarnx(_("malformed setting \"%s\""), setting);
|
||||
@ -345,17 +356,19 @@ static int WriteSetting(const char *setting) {
|
||||
}
|
||||
|
||||
/* used to open the file */
|
||||
tmpname = xmalloc(equals-name+1+strlen(PROC_PATH));
|
||||
tmpname = xmalloc(equals - name + 1 + strlen(PROC_PATH));
|
||||
strcpy(tmpname, PROC_PATH);
|
||||
strncat(tmpname, name, (int)(equals-name));
|
||||
tmpname[equals-name+strlen(PROC_PATH)] = 0;
|
||||
slashdot(tmpname+strlen(PROC_PATH),'.','/'); /* change . to / */
|
||||
strncat(tmpname, name, (int) (equals - name));
|
||||
tmpname[equals - name + strlen(PROC_PATH)] = 0;
|
||||
/* change . to / */
|
||||
slashdot(tmpname + strlen(PROC_PATH), '.', '/');
|
||||
|
||||
/* used to display the output */
|
||||
outname = xmalloc(equals-name+1);
|
||||
strncpy(outname, name, (int)(equals-name));
|
||||
outname[equals-name] = 0;
|
||||
slashdot(outname,'/','.'); /* change / to . */
|
||||
outname = xmalloc(equals - name + 1);
|
||||
strncpy(outname, name, (int) (equals - name));
|
||||
outname[equals - name] = 0;
|
||||
/* change / to . */
|
||||
slashdot(outname, '/', '.');
|
||||
|
||||
if (stat(tmpname, &ts) < 0) {
|
||||
if (!IgnoreError) {
|
||||
@ -378,7 +391,7 @@ static int WriteSetting(const char *setting) {
|
||||
fp = fopen(tmpname, "w");
|
||||
|
||||
if (!fp) {
|
||||
switch(errno) {
|
||||
switch (errno) {
|
||||
case ENOENT:
|
||||
if (!IgnoreError) {
|
||||
xwarnx(_("\"%s\" is an unknown key"), outname);
|
||||
@ -400,16 +413,17 @@ static int WriteSetting(const char *setting) {
|
||||
xwarn(_("setting key \"%s\""), outname);
|
||||
fclose(fp);
|
||||
} else {
|
||||
rc=fclose(fp);
|
||||
rc = fclose(fp);
|
||||
if (rc != 0)
|
||||
xwarn(_("setting key \"%s\""), outname);
|
||||
}
|
||||
if (rc==0 && !Quiet) {
|
||||
if (rc == 0 && !Quiet) {
|
||||
if (NameOnly) {
|
||||
fprintf(stdout, "%s\n", outname);
|
||||
} else {
|
||||
if (PrintName) {
|
||||
fprintf(stdout, "%s = %s\n", outname, value);
|
||||
fprintf(stdout, "%s = %s\n",
|
||||
outname, value);
|
||||
} else {
|
||||
if (PrintNewline)
|
||||
fprintf(stdout, "%s\n", value);
|
||||
@ -419,7 +433,7 @@ static int WriteSetting(const char *setting) {
|
||||
}
|
||||
}
|
||||
}
|
||||
out:
|
||||
out:
|
||||
free(tmpname);
|
||||
free(outname);
|
||||
return rc;
|
||||
@ -430,23 +444,21 @@ static int pattern_match(const char *string, const char *pattern)
|
||||
int status;
|
||||
regex_t re;
|
||||
|
||||
if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB) != 0) {
|
||||
return (0); /* Report error. */
|
||||
}
|
||||
if (regcomp(&re, pattern, REG_EXTENDED | REG_NOSUB) != 0)
|
||||
return (0);
|
||||
status = regexec(&re, string, (size_t) 0, NULL, 0);
|
||||
regfree(&re);
|
||||
if (status != 0) {
|
||||
return (0); /* Report error. */
|
||||
}
|
||||
if (status != 0)
|
||||
return (0);
|
||||
return (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Preload the sysctl's from the conf file
|
||||
* - we parse the file and then reform it (strip out whitespace)
|
||||
*
|
||||
* Preload the sysctl's from the conf file. We parse the file and then
|
||||
* reform it (strip out whitespace).
|
||||
*/
|
||||
static int Preload(const char *restrict const filename) {
|
||||
static int Preload(const char *restrict const filename)
|
||||
{
|
||||
char oneline[256];
|
||||
char buffer[256];
|
||||
FILE *fp;
|
||||
@ -455,10 +467,8 @@ static int Preload(const char *restrict const filename) {
|
||||
int rc = 0;
|
||||
char *name, *value;
|
||||
|
||||
fp = (filename[0]=='-' && !filename[1])
|
||||
? stdin
|
||||
: fopen(filename, "r")
|
||||
;
|
||||
fp = (filename[0] == '-' && !filename[1])
|
||||
? stdin : fopen(filename, "r");
|
||||
|
||||
if (!fp) {
|
||||
xwarn(_("cannot open \"%s\""), filename);
|
||||
@ -477,26 +487,27 @@ static int Preload(const char *restrict const filename) {
|
||||
|
||||
name = strtok(t, "=");
|
||||
if (!name || !*name) {
|
||||
xwarnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
|
||||
xwarnx(_("%s(%d): invalid syntax, continuing..."),
|
||||
filename, n);
|
||||
continue;
|
||||
}
|
||||
|
||||
StripLeadingAndTrailingSpaces(name);
|
||||
|
||||
if (pattern && !pattern_match(name, pattern)){
|
||||
if (pattern && !pattern_match(name, pattern))
|
||||
continue;
|
||||
}
|
||||
|
||||
value = strtok(NULL, "\n\r");
|
||||
if (!value || !*value) {
|
||||
xwarnx(_("%s(%d): invalid syntax, continuing..."), filename, n);
|
||||
xwarnx(_("%s(%d): invalid syntax, continuing..."),
|
||||
filename, n);
|
||||
continue;
|
||||
}
|
||||
|
||||
while ((*value == ' ' || *value == '\t') && *value != 0)
|
||||
value++;
|
||||
|
||||
// should NameOnly affect this?
|
||||
/* should NameOnly affect this? */
|
||||
sprintf(buffer, "%s=%s", name, value);
|
||||
rc |= WriteSetting(buffer);
|
||||
}
|
||||
@ -506,56 +517,63 @@ static int Preload(const char *restrict const filename) {
|
||||
}
|
||||
|
||||
struct pair {
|
||||
char* name;
|
||||
char* value;
|
||||
char *name;
|
||||
char *value;
|
||||
};
|
||||
|
||||
static int sortpairs(const void* A, const void* B)
|
||||
static int sortpairs(const void *A, const void *B)
|
||||
{
|
||||
const struct pair* a = *(struct pair* const*)A;
|
||||
const struct pair* b = *(struct pair* const*)B;
|
||||
const struct pair *a = *(struct pair * const *) A;
|
||||
const struct pair *b = *(struct pair * const *) B;
|
||||
return strcmp(a->name, b->name);
|
||||
}
|
||||
|
||||
static int PreloadSystem(void) {
|
||||
static int PreloadSystem(void)
|
||||
{
|
||||
unsigned di, i;
|
||||
const char* dirs[] = {
|
||||
const char *dirs[] = {
|
||||
"/run/sysctl.d",
|
||||
"/etc/sysctl.d",
|
||||
"/usr/local/lib/sysctl.d",
|
||||
"/usr/lib/sysctl.d",
|
||||
"/lib/sysctl.d",
|
||||
};
|
||||
struct pair** cfgs = NULL;
|
||||
struct pair **cfgs = NULL;
|
||||
unsigned ncfgs = 0;
|
||||
enum { nprealloc = 16 };
|
||||
|
||||
for (di=0; di < sizeof(dirs)/sizeof(dirs[0]); ++di) {
|
||||
struct dirent* de;
|
||||
DIR* dp = opendir(dirs[di]);
|
||||
for (di = 0; di < sizeof(dirs) / sizeof(dirs[0]); ++di) {
|
||||
struct dirent *de;
|
||||
DIR *dp = opendir(dirs[di]);
|
||||
if (!dp)
|
||||
continue;
|
||||
while (( de = readdir(dp) )) {
|
||||
if (!strcmp(de->d_name, ".") || !strcmp(de->d_name, "..")) {
|
||||
|
||||
while ((de = readdir(dp))) {
|
||||
if (!strcmp(de->d_name, ".")
|
||||
|| !strcmp(de->d_name, ".."))
|
||||
continue;
|
||||
}
|
||||
if (strlen(de->d_name) < 6 || !strcmp(de->d_name+strlen(de->d_name)-6, ".conf"))
|
||||
if (strlen(de->d_name) < 6
|
||||
|| !strcmp(de->d_name + strlen(de->d_name) - 6, ".conf"))
|
||||
continue;
|
||||
/* check if config already known */
|
||||
for (i = 0; i < ncfgs; ++i) {
|
||||
if (!strcmp(cfgs[i]->name, de->d_name))
|
||||
break;
|
||||
}
|
||||
if (i < ncfgs) // already in
|
||||
if (i < ncfgs)
|
||||
/* already in */
|
||||
continue;
|
||||
|
||||
if (ncfgs % nprealloc == 0) {
|
||||
cfgs = xrealloc(cfgs, sizeof(struct pair*)*(ncfgs+nprealloc));
|
||||
}
|
||||
cfgs[ncfgs] = xmalloc(sizeof(struct pair) + strlen(de->d_name)*2+2 + strlen(dirs[di])+1);
|
||||
cfgs[ncfgs]->name = (char*)cfgs[ncfgs]+sizeof(struct pair);
|
||||
if (ncfgs % nprealloc == 0)
|
||||
cfgs = xrealloc(cfgs, sizeof(struct pair *) * (ncfgs + nprealloc));
|
||||
cfgs[ncfgs] =
|
||||
xmalloc(sizeof(struct pair) + strlen(de->d_name) * 2 + 2 +
|
||||
strlen(dirs[di]) + 1);
|
||||
cfgs[ncfgs]->name = (char *) cfgs[ncfgs] + sizeof(struct pair);
|
||||
strcpy(cfgs[ncfgs]->name, de->d_name);
|
||||
cfgs[ncfgs]->value = (char*)cfgs[ncfgs]+sizeof(struct pair) + strlen(cfgs[ncfgs]->name)+1;
|
||||
cfgs[ncfgs]->value =
|
||||
(char *) cfgs[ncfgs] + sizeof(struct pair) + strlen(cfgs[ncfgs]->name) +
|
||||
1;
|
||||
sprintf(cfgs[ncfgs]->value, "%s/%s", dirs[di], de->d_name);
|
||||
ncfgs++;
|
||||
|
||||
@ -563,7 +581,7 @@ static int PreloadSystem(void) {
|
||||
closedir(dp);
|
||||
}
|
||||
|
||||
qsort(cfgs, ncfgs, sizeof(struct cfg*), sortpairs);
|
||||
qsort(cfgs, ncfgs, sizeof(struct cfg *), sortpairs);
|
||||
|
||||
for (i = 0; i < ncfgs; ++i) {
|
||||
if (!Quiet)
|
||||
@ -576,10 +594,8 @@ static int PreloadSystem(void) {
|
||||
return Preload(DEFAULT_PRELOAD);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Main...
|
||||
*
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@ -611,7 +627,7 @@ int main(int argc, char *argv[])
|
||||
};
|
||||
|
||||
program_invocation_name = program_invocation_short_name;
|
||||
setlocale (LC_ALL, "");
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
|
||||
@ -620,9 +636,8 @@ int main(int argc, char *argv[])
|
||||
IgnoreError = false;
|
||||
Quiet = false;
|
||||
|
||||
if (argc < 2) {
|
||||
if (argc < 2)
|
||||
Usage(stderr);
|
||||
}
|
||||
|
||||
while ((c =
|
||||
getopt_long(argc, argv, "bneNwfp::qoxaAXr:Vdh", longopts,
|
||||
@ -637,8 +652,9 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 'e':
|
||||
/*
|
||||
* For FreeBSD, -e means a "%s=%s\n" format. ("%s: %s\n" default)
|
||||
* We (and NetBSD) use "%s = %s\n" always, and -e to ignore errors.
|
||||
* For FreeBSD, -e means a "%s=%s\n" format.
|
||||
* ("%s: %s\n" default). We (and NetBSD) use
|
||||
* "%s = %s\n" always, and -e to ignore errors.
|
||||
*/
|
||||
IgnoreError = true;
|
||||
break;
|
||||
@ -675,7 +691,7 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case 'V':
|
||||
printf(PROCPS_NG_VERSION);
|
||||
exit(0);
|
||||
return EXIT_SUCCESS;
|
||||
case 'd': /* BSD: print description ("vm.kvm_size: Size of KVM") */
|
||||
case 'h': /* BSD: human-readable (did FreeBSD 5 make -e default?) */
|
||||
case '?':
|
||||
@ -707,5 +723,3 @@ int main(int argc, char *argv[])
|
||||
|
||||
return ReturnCode;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user