The following commit has been merged in the master branch:
commit 7623f78d39682076ffe4ea416df947fdab91b184
Author: Guillem Jover <[email protected]>
Date: Fri Sep 25 04:40:56 2009 +0200
Clean up coding style for half compliant files
Fix spacing, indentation and alignment. Do not use backticks, on
comments use UTF-8 pretty quotes, on strings use single or double
quotes, but do not change strings marked for translation if no other
change was needed. Fix placement of braces and boolean operators. Fix
formatting of comments.
diff --git a/lib/dpkg/showpkg.c b/lib/dpkg/showpkg.c
index bfcb296..86cf8e1 100644
--- a/lib/dpkg/showpkg.c
+++ b/lib/dpkg/showpkg.c
@@ -17,6 +17,7 @@
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
#include <config.h>
#include <compat.h>
@@ -30,177 +31,191 @@
#include <dpkg/dpkg-db.h>
#include <dpkg/parsedump.h>
-
-typedef enum { invalid, string, field } itemtype_t;
+typedef enum {
+ invalid,
+ string,
+ field,
+} itemtype_t;
struct lstitem {
itemtype_t type;
size_t width;
int pad;
- char* data;
- struct lstitem* next;
+ char *data;
+ struct lstitem *next;
};
-static struct lstitem* alloclstitem(void) {
- struct lstitem* buf;
+static struct lstitem *
+alloclstitem(void)
+{
+ struct lstitem *buf;
buf = m_malloc(sizeof(struct lstitem));
- buf->type=invalid;
- buf->next=NULL;
- buf->data=NULL;
- buf->width=0;
- buf->pad=0;
+ buf->type = invalid;
+ buf->next = NULL;
+ buf->data = NULL;
+ buf->width = 0;
+ buf->pad = 0;
return buf;
}
-
-static int parsefield(struct lstitem* cur, const char* fmt, const char*
fmtend) {
+static int
+parsefield(struct lstitem *cur, const char *fmt, const char *fmtend)
+{
int len;
- const char* ws;
+ const char *ws;
- len=fmtend-fmt+1;
+ len = fmtend - fmt + 1;
ws = memchr(fmt, ';', len);
if (ws) {
- char* endptr;
+ char *endptr;
long w;
- w=strtol(ws+1,&endptr,0);
- if (endptr[0]!='}') {
- fprintf(stderr, _("invalid character `%c' in field
width\n"), *endptr);
+ w = strtol(ws + 1, &endptr, 0);
+ if (endptr[0] != '}') {
+ fprintf(stderr,
+ _("invalid character `%c' in field width\n"),
+ *endptr);
return 0;
}
- if (w<0) {
- cur->pad=1;
- cur->width=(size_t)-w;
+ if (w < 0) {
+ cur->pad = 1;
+ cur->width = (size_t)-w;
} else
- cur->width=(size_t)w;
+ cur->width = (size_t)w;
- len=ws-fmt;
+ len = ws - fmt;
}
- cur->type=field;
+ cur->type = field;
cur->data = m_malloc(len + 1);
memcpy(cur->data, fmt, len);
- cur->data[len]='\0';
+ cur->data[len] = '\0';
return 1;
}
-
-static int parsestring(struct lstitem* cur, const char* fmt, const char*
fmtend) {
+static int
+parsestring(struct lstitem *cur, const char *fmt, const char *fmtend)
+{
int len;
- char* write;
+ char *write;
- len=fmtend-fmt+1;
+ len = fmtend - fmt + 1;
- cur->type=string;
+ cur->type = string;
write = cur->data = m_malloc(len + 1);
- while (fmt<=fmtend) {
- if (*fmt=='\\') {
+ while (fmt <= fmtend) {
+ if (*fmt == '\\') {
fmt++;
switch (*fmt) {
- case 'n':
- *write='\n';
- break;
- case 't':
- *write='\t';
- break;
- case 'r':
- *write='\r';
- break;
- case '\\':
- default:
- *write=*fmt;
- break;
+ case 'n':
+ *write = '\n';
+ break;
+ case 't':
+ *write = '\t';
+ break;
+ case 'r':
+ *write = '\r';
+ break;
+ case '\\':
+ default:
+ *write = *fmt;
+ break;
}
} else
- *write=*fmt;
+ *write = *fmt;
write++;
fmt++;
}
- *write='\0';
+ *write = '\0';
return 1;
}
-
-void freeformat(struct lstitem* head) {
- struct lstitem* next;
+void
+freeformat(struct lstitem *head)
+{
+ struct lstitem *next;
while (head) {
- next=head->next;
+ next = head->next;
free(head->data);
free(head);
- head=next;
+ head = next;
}
}
+struct lstitem *
+parseformat(const char *fmt)
+{
+ struct lstitem *head;
+ struct lstitem *cur;
+ const char *fmtend;
-struct lstitem* parseformat(const char* fmt) {
- struct lstitem* head;
- struct lstitem* cur;
- const char* fmtend;
+ head = cur = NULL;
- head=cur=NULL;
-
while (*fmt) {
if (cur)
- cur=cur->next=alloclstitem();
+ cur = cur->next = alloclstitem();
else
- head=cur=alloclstitem();
+ head = cur = alloclstitem();
- if (fmt[0]=='$' && fmt[1]=='{') {
- fmtend=strchr(fmt, '}');
+ if (fmt[0] == '$' && fmt[1] == '{') {
+ fmtend = strchr(fmt, '}');
if (!fmtend) {
- fprintf(stderr, _("Closing brace missing in
format\n"));
+ fprintf(stderr,
+ _("Closing brace missing in format\n"));
freeformat(head);
return NULL;
}
- if (!parsefield(cur, fmt+2, fmtend-1)) {
+ if (!parsefield(cur, fmt + 2, fmtend - 1)) {
freeformat(head);
return NULL;
}
- fmt=fmtend+1;
+ fmt = fmtend + 1;
} else {
- fmtend=fmt;
+ fmtend = fmt;
do {
- fmtend+=1;
- fmtend=strchr(fmtend, '$');
- } while (fmtend && fmtend[1]!='{');
+ fmtend += 1;
+ fmtend = strchr(fmtend, '$');
+ } while (fmtend && fmtend[1] != '{');
if (!fmtend)
- fmtend=fmt+strlen(fmt);
+ fmtend = fmt + strlen(fmt);
- if (!parsestring(cur, fmt, fmtend-1)) {
+ if (!parsestring(cur, fmt, fmtend - 1)) {
freeformat(head);
return NULL;
}
- fmt=fmtend;
+ fmt = fmtend;
}
}
return head;
}
+#define dumpchain(head) \
+{ \
+ const struct lstitem *ptr = head; \
+\
+ while (ptr) { \
+ printf("Type: %s\n", (ptr->type == string) ? "string" :
"field"); \
+ printf("Width: %d\n", ptr->width); \
+ printf("Data: %s\n", ptr->data); \
+ printf("\n"); \
+ ptr = ptr->next; \
+ } \
+}
-#define dumpchain(head) {\
- const struct lstitem* ptr = head;\
- while (ptr) {\
- printf("Type: %s\n", (ptr->type==string) ? "string" : "field");\
- printf("Width: %d\n", ptr->width);\
- printf("Data: %s\n", ptr->data);\
- printf("\n");\
- ptr=ptr->next;\
- }\
-}\
-
-
-void show1package(const struct lstitem* head, struct pkginfo *pkg) {
+void
+show1package(const struct lstitem *head, struct pkginfo *pkg)
+{
struct varbuf vb = VARBUF_INIT, fb = VARBUF_INIT, wb = VARBUF_INIT;
/* Make sure we have package info available, even if it's all empty. */
@@ -211,57 +226,57 @@ void show1package(const struct lstitem* head, struct
pkginfo *pkg) {
int ok;
char fmt[16];
- ok=0;
+ ok = 0;
- if (head->width>0)
- snprintf(fmt,16,"%%%s%zds",
- ((head->pad) ? "-" : ""), head->width);
+ if (head->width > 0)
+ snprintf(fmt, 16, "%%%s%zds",
+ ((head->pad) ? "-" : ""), head->width);
else
strcpy(fmt, "%s");
- if (head->type==string) {
+ if (head->type == string) {
varbufprintf(&fb, fmt, head->data);
- ok=1;
- } else if (head->type==field) {
- const struct fieldinfo* fip;
+ ok = 1;
+ } else if (head->type == field) {
+ const struct fieldinfo *fip;
- for (fip=fieldinfos; fip->name; fip++)
- if (strcasecmp(head->data, fip->name)==0) {
-
fip->wcall(&wb,pkg,&pkg->installed,0,fip);
+ for (fip = fieldinfos; fip->name; fip++)
+ if (strcasecmp(head->data, fip->name) == 0) {
+ fip->wcall(&wb, pkg, &pkg->installed,
0, fip);
varbufaddc(&wb, '\0');
varbufprintf(&fb, fmt, wb.buf);
varbufreset(&wb);
- ok=1;
+ ok = 1;
break;
}
if (!fip->name && pkg->installed.valid) {
- const struct arbitraryfield* afp;
+ const struct arbitraryfield *afp;
- for (afp=pkg->installed.arbs; afp;
afp=afp->next)
- if (strcasecmp(head->data,
afp->name)==0) {
+ for (afp = pkg->installed.arbs; afp; afp =
afp->next)
+ if (strcasecmp(head->data, afp->name)
== 0) {
varbufprintf(&fb, fmt,
afp->value);
- ok=1;
+ ok = 1;
break;
}
}
}
if (ok) {
- size_t len=strlen(fb.buf);
- if ((head->width>0) && (len>head->width))
- len=head->width;
+ size_t len = strlen(fb.buf);
+ if ((head->width > 0) && (len > head->width))
+ len = head->width;
varbufaddbuf(&vb, fb.buf, len);
}
varbufreset(&fb);
- head=head->next;
+ head = head->next;
}
if (vb.buf) {
varbufaddc(&vb, '\0');
- fputs(vb.buf,stdout);
+ fputs(vb.buf, stdout);
}
varbuffree(&wb);
diff --git a/lib/dpkg/subproc.c b/lib/dpkg/subproc.c
index 6e611bd..38dd953 100644
--- a/lib/dpkg/subproc.c
+++ b/lib/dpkg/subproc.c
@@ -49,9 +49,9 @@ setup_subproc_signals(const char *name)
sigemptyset(&catchsig.sa_mask);
catchsig.sa_flags = 0;
for (i = 0; i < sizeof_array(catch_signals); i++)
- if (sigaction(catch_signals[i], &catchsig, &uncatch_signals[i]))
- ohshite(_("unable to ignore signal %s before running %.250s"),
- strsignal(catch_signals[i]), name);
+ if (sigaction(catch_signals[i], &catchsig, &uncatch_signals[i]))
+ ohshite(_("unable to ignore signal %s before running
%.250s"),
+ strsignal(catch_signals[i]), name);
push_cleanup(cu_subproc_signals, ~0, NULL, 0, 0);
onerr_abort--;
}
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index 3ca9b28..e259d7b 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -4,6 +4,7 @@
* Copyright © 1995 Bruce Perens
* This is free software under the GNU General Public License.
*/
+
#include <config.h>
#include <compat.h>
@@ -39,22 +40,22 @@ struct TarHeader {
char MinorDevice[8];
char Prefix[155]; /* Only valid on ustar. */
};
-typedef struct TarHeader TarHeader;
+typedef struct TarHeader TarHeader;
static const size_t TarChecksumOffset = offsetof(TarHeader, Checksum);
/* Octal-ASCII-to-long */
static long
-OtoL(const char * s, int size)
+OtoL(const char *s, int size)
{
- int n = 0;
+ int n = 0;
- while ( *s == ' ' ) {
+ while (*s == ' ') {
s++;
size--;
}
- while ( --size >= 0 && *s >= '0' && *s <= '7' )
+ while (--size >= 0 && *s >= '0' && *s <= '7')
n = (n * 010) + (*s++ - '0');
return n;
@@ -64,8 +65,8 @@ OtoL(const char * s, int size)
static char *
StoC(const char *s, int size)
{
- int len;
- char * str;
+ int len;
+ char *str;
len = strnlen(s, size);
str = m_malloc(len + 1);
@@ -84,7 +85,7 @@ get_prefix_name(TarHeader *h)
/* The size is not going to be bigger than that. */
s = m_malloc(257);
- prefix = StoC(h->Prefix, sizeof(h->Prefix));
+ prefix = StoC(h->Prefix, sizeof(h->Prefix));
name = StoC(h->Name, sizeof(h->Name));
strcpy(s, prefix);
@@ -100,13 +101,13 @@ get_prefix_name(TarHeader *h)
static int
DecodeTarHeader(char * block, TarInfo * d)
{
- TarHeader * h = (TarHeader *)block;
- unsigned char * s = (unsigned char *)block;
- struct passwd * passwd = NULL;
- struct group * group = NULL;
- unsigned int i;
- long sum;
- long checksum;
+ TarHeader *h = (TarHeader *)block;
+ unsigned char *s = (unsigned char *)block;
+ struct passwd *passwd = NULL;
+ struct group *group = NULL;
+ unsigned int i;
+ long sum;
+ long checksum;
if (memcmp(h->MagicNumber, TAR_MAGIC_GNU, 6) == 0)
d->format = tar_format_gnu;
@@ -115,9 +116,9 @@ DecodeTarHeader(char * block, TarInfo * d)
else
d->format = tar_format_old;
- if ( *h->UserName )
+ if (*h->UserName)
passwd = getpwnam(h->UserName);
- if ( *h->GroupName )
+ if (*h->GroupName)
group = getgrnam(h->GroupName);
/* Concatenate prefix and name to support ustar style long names. */
@@ -128,30 +129,32 @@ DecodeTarHeader(char * block, TarInfo * d)
d->LinkName = StoC(h->LinkName, sizeof(h->LinkName));
d->Mode = (mode_t)OtoL(h->Mode, sizeof(h->Mode));
d->Size = (size_t)OtoL(h->Size, sizeof(h->Size));
- d->ModTime = (time_t)OtoL(h->ModificationTime
- ,sizeof(h->ModificationTime));
- d->Device = ((OtoL(h->MajorDevice, sizeof(h->MajorDevice)) & 0xff) << 8)
- | (OtoL(h->MinorDevice, sizeof(h->MinorDevice)) & 0xff);
+ d->ModTime = (time_t)OtoL(h->ModificationTime,
+ sizeof(h->ModificationTime));
+ d->Device = ((OtoL(h->MajorDevice,
+ sizeof(h->MajorDevice)) & 0xff) << 8) |
+ (OtoL(h->MinorDevice, sizeof(h->MinorDevice)) & 0xff);
checksum = OtoL(h->Checksum, sizeof(h->Checksum));
d->UserID = (uid_t)OtoL(h->UserID, sizeof(h->UserID));
d->GroupID = (gid_t)OtoL(h->GroupID, sizeof(h->GroupID));
d->Type = (TarFileType)h->LinkFlag;
- if ( passwd )
+ if (passwd)
d->UserID = passwd->pw_uid;
- if ( group )
+ if (group)
d->GroupID = group->gr_gid;
-
- sum = ' ' * sizeof(h->Checksum);/* Treat checksum field as all blank */
- for ( i = TarChecksumOffset; i > 0; i-- )
+ /* Treat checksum field as all blank. */
+ sum = ' ' * sizeof(h->Checksum);
+ for (i = TarChecksumOffset; i > 0; i--)
sum += *s++;
- s += sizeof(h->Checksum); /* Skip the real checksum field */
- for ( i = (512 - TarChecksumOffset - sizeof(h->Checksum)); i > 0; i-- )
+ /* Skip the real checksum field. */
+ s += sizeof(h->Checksum);
+ for (i = (512 - TarChecksumOffset - sizeof(h->Checksum)); i > 0; i--)
sum += *s++;
- return ( sum == checksum );
+ return (sum == checksum);
}
typedef struct symlinkList {
@@ -160,23 +163,21 @@ typedef struct symlinkList {
} symlinkList;
int
-TarExtractor(
- void * userData
-,const TarFunctions * functions)
+TarExtractor(void *userData, const TarFunctions *functions)
{
- int status;
- char buffer[512];
- TarInfo h;
-
- char *next_long_name, *next_long_link;
- char *bp;
- char **longp;
- int long_read;
+ int status;
+ char buffer[512];
+ TarInfo h;
+
+ char *next_long_name, *next_long_link;
+ char *bp;
+ char **longp;
+ int long_read;
symlinkList *symListTop, *symListBottom, *symListPointer;
- next_long_name = NULL;
- next_long_link = NULL;
- long_read = 0;
+ next_long_name = NULL;
+ next_long_link = NULL;
+ long_read = 0;
symListBottom = symListPointer = symListTop =
m_malloc(sizeof(symlinkList));
symListTop->next = NULL;
@@ -184,50 +185,52 @@ TarExtractor(
h.LinkName = NULL;
h.UserData = userData;
- while ( (status = functions->Read(userData, buffer, 512)) == 512 ) {
- int nameLength;
+ while ((status = functions->Read(userData, buffer, 512)) == 512) {
+ int nameLength;
- if ( !DecodeTarHeader(buffer, &h) ) {
- if ( h.Name[0] == '\0' ) {
- status = 0; /* End of tape */
+ if (!DecodeTarHeader(buffer, &h)) {
+ if (h.Name[0] == '\0') {
+ /* End of tape. */
+ status = 0;
} else {
- errno = 0; /* Indicates broken tarfile */
- status = -1; /* Header checksum error */
+ /* Indicates broken tarfile:
+ * “Header checksum error”. */
+ errno = 0;
+ status = -1;
}
break;
}
- if ( h.Type != GNU_LONGLINK && h.Type != GNU_LONGNAME ) {
- if (next_long_name) {
- h.Name = next_long_name;
- }
-
- if (next_long_link) {
- h.LinkName = next_long_link;
- }
-
- next_long_link = NULL;
- next_long_name = NULL;
- }
-
- if ( h.Name[0] == '\0' ) {
- errno = 0; /* Indicates broken tarfile */
- status = -1; /* Bad header data */
+ if (h.Type != GNU_LONGLINK && h.Type != GNU_LONGNAME) {
+ if (next_long_name)
+ h.Name = next_long_name;
+
+ if (next_long_link)
+ h.LinkName = next_long_link;
+
+ next_long_link = NULL;
+ next_long_name = NULL;
+ }
+
+ if (h.Name[0] == '\0') {
+ /* Indicates broken tarfile: “Bad header data”. */
+ errno = 0;
+ status = -1;
break;
}
nameLength = strlen(h.Name);
- switch ( h.Type ) {
+ switch (h.Type) {
case NormalFile0:
case NormalFile1:
- /* Compatibility with pre-ANSI ustar */
- if ( h.Name[nameLength - 1] != '/' ) {
+ /* Compatibility with pre-ANSI ustar. */
+ if (h.Name[nameLength - 1] != '/') {
status = (*functions->ExtractFile)(&h);
break;
}
- /* Else, Fall Through */
+ /* Else, fall through. */
case Directory:
- if ( h.Name[nameLength - 1] == '/' ) {
+ if (h.Name[nameLength - 1] == '/') {
h.Name[nameLength - 1] = '\0';
}
status = (*functions->MakeDirectory)(&h);
@@ -250,58 +253,65 @@ TarExtractor(
case FIFO:
status = (*functions->MakeSpecialFile)(&h);
break;
- case GNU_LONGLINK:
- case GNU_LONGNAME:
- // set longp to the location of the long filename or link
- // we're trying to deal with
- longp = ((h.Type == GNU_LONGNAME)
- ? &next_long_name
- : &next_long_link);
-
- if (*longp)
- free(*longp);
-
- *longp = m_malloc(h.Size);
- bp = *longp;
-
- // the way the GNU long{link,name} stuff works is like this:
- // The first header is a "dummy" header that contains the size
- // of the filename. The next N headers contain the filename.
- // After the headers with the filename comes the "real" header
- // with a bogus name or link.
- for (long_read = h.Size; long_read > 0;
- long_read -= 512) {
-
- int copysize;
-
- status = functions->Read(userData, buffer, 512);
- // if we didn't get 512 bytes read, punt
- if (512 != status) {
- if ( status > 0 ) { /* Read partial header record */
- errno = 0;
- status = -1;
- }
- break;
- }
+ case GNU_LONGLINK:
+ case GNU_LONGNAME:
+ /* Set longp to the location of the long filename or
+ * link we're trying to deal with. */
+ longp = ((h.Type == GNU_LONGNAME) ?
+ &next_long_name :
+ &next_long_link);
+
+ if (*longp)
+ free(*longp);
+
+ *longp = m_malloc(h.Size);
+ bp = *longp;
+
+ /* The way the GNU long{link,name} stuff works is like
+ * this:
+ *
+ * The first header is a “dummy” header that contains
+ * the size of the filename.
+ * The next N headers contain the filename.
+ * After the headers with the filename comes the
+ * “real” header with a bogus name or link. */
+ for (long_read = h.Size;
+ long_read > 0;
+ long_read -= 512) {
+ int copysize;
+
+ status = functions->Read(userData, buffer, 512);
+ /* If we didn't get 512 bytes read, punt. */
+ if (512 != status) {
+ /* Read partial header record? */
+ if (status > 0) {
+ errno = 0;
+ status = -1;
+ }
+ break;
+ }
copysize = min(long_read, 512);
- memcpy (bp, buffer, copysize);
- bp += copysize;
-
- };
- // This decode function expects status to be 0 after
- // the case statement if we successfully decoded. I
- // guess what we just did was successful.
- status = 0;
- break;
+ memcpy (bp, buffer, copysize);
+ bp += copysize;
+ };
+
+ /* This decode function expects status to be 0 after
+ * the case statement if we successfully decoded. I
+ * guess what we just did was successful. */
+ status = 0;
+ break;
default:
- errno = 0; /* Indicates broken tarfile */
- status = -1; /* Bad header field */
+ /* Indicates broken tarfile: “Bad header field”. */
+ errno = 0;
+ status = -1;
}
- if ( status != 0 )
- break; /* Pass on status from coroutine */
+ if (status != 0)
+ /* Pass on status from coroutine. */
+ break;
}
- while(symListPointer->next) {
- if ( status == 0 )
+
+ while (symListPointer->next) {
+ if (status == 0)
status =
(*functions->MakeSymbolicLink)(&symListPointer->h);
symListBottom = symListPointer->next;
free(symListPointer->h.Name);
@@ -312,11 +322,14 @@ TarExtractor(
free(symListPointer);
free(h.Name);
free(h.LinkName);
- if ( status > 0 ) { /* Read partial header record */
- errno = 0; /* Indicates broken tarfile */
+
+ if (status > 0) {
+ /* Indicates broken tarfile: “Read partial header record”. */
+ errno = 0;
return -1;
} else {
- return status; /* Whatever I/O function returned */
+ /* Return whatever I/O function returned. */
+ return status;
}
}
diff --git a/src/configure.c b/src/configure.c
index 6342871..f691046 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -3,7 +3,7 @@
* configure.c - configure packages
*
* Copyright © 1995 Ian Jackson <[email protected]>
- * Copyright © 1999,2002 Wichert Akkerman <[email protected]>
+ * Copyright © 1999, 2002 Wichert Akkerman <[email protected]>
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -19,6 +19,7 @@
* License along with dpkg; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
#include <config.h>
#include <compat.h>
@@ -57,12 +58,13 @@ static int conffoptcells[2][2] = {
};
static void md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn);
-static void copyfileperm(const char* source, const char* target);
-static void showdiff(const char* old, const char* new);
+static void copyfileperm(const char *source, const char *target);
+static void showdiff(const char *old, const char *new);
static void suspend(void);
-static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
- const char* realnew, int useredited, int distedited,
- enum conffopt what);
+static enum conffopt promptconfaction(const char *cfgfile,
+ const char *realold, const char *realnew,
+ int useredited, int distedited,
+ enum conffopt what);
static void
deferred_configure_conffile(struct pkginfo *pkg, struct conffile *conff)
@@ -208,118 +210,126 @@ deferred_configure_conffile(struct pkginfo *pkg, struct
conffile *conff)
varbuffree(&cdr2);
}
-void deferred_configure(struct pkginfo *pkg) {
- /* The algorithm for deciding what to configure first is as follows:
- * Loop through all packages doing a `try 1' until we've been round
- * and nothing has been done, then do `try 2' and `try 3' likewise.
- * The incrementing of `dependtry' is done by process_queue().
- * Try 1:
- * Are all dependencies of this package done ? If so, do it.
- * Are any of the dependencies missing or the wrong version ?
- * If so, abort (unless --force-depends, in which case defer)
- * Will we need to configure a package we weren't given as an
- * argument ? If so, abort - except if --force-configure-any,
- * in which case we add the package to the argument list.
- * If none of the above, defer the package.
- * Try 2:
- * Find a cycle and break it (see above).
- * Do as for try 1.
- * Try 3 (only if --force-depends-version).
- * Same as for try 2, but don't mind version number in dependencies.
- * Try 4 (only if --force-depends).
- * Do anyway.
- */
+/*
+ * The algorithm for deciding what to configure first is as follows:
+ * Loop through all packages doing a ‘try 1’ until we've been round
+ * and nothing has been done, then do ‘try 2’ and ‘try 3’ likewise.
+ * The incrementing of ‘dependtry’ is done by process_queue().
+ *
+ * Try 1:
+ * Are all dependencies of this package done? If so, do it.
+ * Are any of the dependencies missing or the wrong version?
+ * If so, abort (unless --force-depends, in which case defer).
+ * Will we need to configure a package we weren't given as an
+ * argument? If so, abort ─ except if --force-configure-any,
+ * in which case we add the package to the argument list.
+ * If none of the above, defer the package.
+ *
+ * Try 2:
+ * Find a cycle and break it (see above).
+ * Do as for try 1.
+ *
+ * Try 3 (only if --force-depends-version):
+ * Same as for try 2, but don't mind version number in dependencies.
+ *
+ * Try 4 (only if --force-depends):
+ * Do anyway.
+ */
+void
+deferred_configure(struct pkginfo *pkg)
+{
struct varbuf aemsgs = VARBUF_INIT;
struct conffile *conff;
int ok;
if (pkg->status == stat_notinstalled)
- ohshit(_("no package named `%s' is installed, cannot
configure"),pkg->name);
+ ohshit(_("no package named `%s' is installed, cannot
configure"),
+ pkg->name);
if (pkg->status == stat_installed)
- ohshit(_("package %.250s is already installed and configured"),
pkg->name);
+ ohshit(_("package %.250s is already installed and configured"),
+ pkg->name);
if (pkg->status != stat_unpacked && pkg->status != stat_halfconfigured)
ohshit(_("package %.250s is not ready for configuration\n"
- " cannot configure (current status
`%.250s')"),
- pkg->name, statusinfos[pkg->status].name);
+ " cannot configure (current status `%.250s')"),
+ pkg->name, statusinfos[pkg->status].name);
if (dependtry > 1)
if (findbreakcycle(pkg))
- sincenothing= 0;
+ sincenothing = 0;
ok = dependencies_ok(pkg, NULL, &aemsgs);
if (ok == 1) {
varbuffree(&aemsgs);
- pkg->clientdata->istobe= itb_installnew;
+ pkg->clientdata->istobe = itb_installnew;
add_to_queue(pkg);
return;
}
trigproc_reset_cycle();
- /* At this point removal from the queue is confirmed. This
- * represents irreversible progress wrt trigger cycles. Only
+
+ /* At this point removal from the queue is confirmed. This
+ * represents irreversible progress wrt trigger cycles. Only
* packages in stat_unpacked are automatically added to the
* configuration queue, and during configuration and trigger
- * processing new packages can't enter into unpacked.
- */
+ * processing new packages can't enter into unpacked. */
ok = breakses_ok(pkg, &aemsgs) ? ok : 0;
if (ok == 0) {
- sincenothing= 0;
- varbufaddc(&aemsgs,0);
+ sincenothing = 0;
+ varbufaddc(&aemsgs, 0);
fprintf(stderr,
- _("dpkg: dependency problems prevent
configuration of %s:\n%s"),
- pkg->name, aemsgs.buf);
+ _("dpkg: dependency problems prevent configuration of
%s:\n%s"),
+ pkg->name, aemsgs.buf);
varbuffree(&aemsgs);
ohshit(_("dependency problems - leaving unconfigured"));
} else if (aemsgs.used) {
- varbufaddc(&aemsgs,0);
+ varbufaddc(&aemsgs, 0);
fprintf(stderr,
- _("dpkg: %s: dependency problems, but
configuring anyway as you requested:\n%s"),
- pkg->name, aemsgs.buf);
+ _("dpkg: %s: dependency problems, but configuring
anyway as you requested:\n%s"),
+ pkg->name, aemsgs.buf);
}
varbuffree(&aemsgs);
- sincenothing= 0;
+ sincenothing = 0;
if (pkg->eflag & eflag_reinstreq)
forcibleerr(fc_removereinstreq,
- _("Package is in a very bad inconsistent state
- you should\n"
- " reinstall it before attempting
configuration."));
+ _("Package is in a very bad inconsistent state -
you should\n"
+ " reinstall it before attempting
configuration."));
- printf(_("Setting up %s (%s) ...\n"),pkg->name,
+ printf(_("Setting up %s (%s) ...\n"), pkg->name,
versiondescribe(&pkg->installed.version, vdew_nonambig));
log_action("configure", pkg);
trig_activate_packageprocessing(pkg);
if (f_noact) {
- pkg->status= stat_installed;
- pkg->clientdata->istobe= itb_normal;
+ pkg->status = stat_installed;
+ pkg->clientdata->istobe = itb_normal;
return;
}
if (pkg->status == stat_unpacked) {
- debug(dbg_general,"deferred_configure updating conffiles");
- /* This will not do at all the right thing with overridden
conffiles
- * or conffiles that are the `target' of an override; all the
references
- * here would be to the `contested' filename, and in any case
there'd
- * only be one hash for both `versions' of the conffile.
+ debug(dbg_general, "deferred_configure updating conffiles");
+ /* This will not do at all the right thing with overridden
+ * conffiles or conffiles that are the ‘target’ of an override;
+ * all the references here would be to the ‘contested’
+ * filename, and in any case there'd only be one hash for both
+ * ‘versions’ of the conffile.
*
- * Overriding conffiles is a silly thing to do anyway :-).
- */
+ * Overriding conffiles is a silly thing to do anyway :-). */
modstatdb_note(pkg);
- /* On entry, the `new' version of each conffile has been
- * unpacked as *.dpkg-new, and the `installed' version is
- * as-yet untouched in `*'. The hash of the `old distributed'
- * version is in the conffiles data for the package.
- * If `*.dpkg-new' no longer exists we assume that we've already
- * processed this one.
- */
+ /* On entry, the ‘new’ version of each conffile has been
+ * unpacked as ‘*.dpkg-new’, and the ‘installed’ version is
+ * as-yet untouched in ‘*’. The hash of the ‘old distributed’
+ * version is in the conffiles data for the package. If
+ * ‘*.dpkg-new’ no longer exists we assume that we've
+ * already processed this one. */
for (conff = pkg->installed.conffiles; conff; conff =
conff->next)
deferred_configure_conffile(pkg, conff);
- pkg->status= stat_halfconfigured;
+ pkg->status = stat_halfconfigured;
}
assert(pkg->status == stat_halfconfigured);
@@ -336,71 +346,81 @@ void deferred_configure(struct pkginfo *pkg) {
post_postinst_tasks(pkg, stat_installed);
}
-
-
-/* Dereference a file by following all possibly used symlinks.
+/*
+ * Dereference a file by following all possibly used symlinks.
* Returns 0 if everything went ok, -1 otherwise.
*/
-int conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in) {
+int
+conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in)
+{
static char *linkreadbuf = NULL;
- static int linkreadbufsize = 0;
- struct stat stab;
- int r, need;
- int loopprotect;
+ static int linkreadbufsize = 0;
+ struct stat stab;
+ int r, need;
+ int loopprotect;
varbufreset(result);
- varbufaddstr(result,instdir);
- if (*in != '/') varbufaddc(result,'/');
- varbufaddstr(result,in);
- varbufaddc(result,0);
+ varbufaddstr(result, instdir);
+ if (*in != '/')
+ varbufaddc(result, '/');
+ varbufaddstr(result, in);
+ varbufaddc(result, 0);
- loopprotect= 0;
+ loopprotect = 0;
for (;;) {
- debug(dbg_conffdetail,"conffderef in=`%s' current
working=`%s'", in, result->buf);
- if (lstat(result->buf,&stab)) {
+ debug(dbg_conffdetail, "conffderef in='%s' current
working='%s'",
+ in, result->buf);
+ if (lstat(result->buf, &stab)) {
if (errno != ENOENT)
warning(_("%s: unable to stat config file
'%s'\n"
" (= '%s'): %s"),
pkg->name, in, result->buf,
strerror(errno));
- debug(dbg_conffdetail,"conffderef nonexistent");
+ debug(dbg_conffdetail, "conffderef nonexistent");
return 0;
} else if (S_ISREG(stab.st_mode)) {
- debug(dbg_conff,"conffderef in=`%s' result=`%s'", in,
result->buf);
+ debug(dbg_conff, "conffderef in='%s' result='%s'",
+ in, result->buf);
return 0;
} else if (S_ISLNK(stab.st_mode)) {
- debug(dbg_conffdetail,"conffderef symlink
loopprotect=%d",loopprotect);
+ debug(dbg_conffdetail, "conffderef symlink
loopprotect=%d",
+ loopprotect);
if (loopprotect++ >= 25) {
warning(_("%s: config file '%s' is a circular
link\n"
" (= '%s')"), pkg->name, in,
result->buf);
return -1;
}
- need= 255;
+ need = 255;
for (;;) {
if (need > linkreadbufsize) {
- linkreadbuf=
m_realloc(linkreadbuf,need);
- linkreadbufsize= need;
- debug(dbg_conffdetail,"conffderef
readlink realloc(%d)=%p",need,linkreadbuf);
+ linkreadbuf = m_realloc(linkreadbuf,
need);
+ linkreadbufsize = need;
+ debug(dbg_conffdetail,
+ "conffderef readlink
realloc(%d)=%p",
+ need, linkreadbuf);
}
- r=
readlink(result->buf,linkreadbuf,linkreadbufsize-1);
+ r = readlink(result->buf, linkreadbuf,
linkreadbufsize - 1);
if (r < 0) {
warning(_("%s: unable to readlink
conffile '%s'\n"
" (= '%s'): %s"),
pkg->name, in, result->buf,
strerror(errno));
return -1;
}
- debug(dbg_conffdetail,"conffderef readlink gave
%d, `%.*s'",
- r, max(r, 0), linkreadbuf);
- if (r < linkreadbufsize-1) break;
- need= r<<2;
+ debug(dbg_conffdetail,
+ "conffderef readlink gave %d, '%.*s'",
+ r, max(r, 0), linkreadbuf);
+ if (r < linkreadbufsize - 1)
+ break;
+ need = r << 2;
}
linkreadbuf[r] = '\0';
if (linkreadbuf[0] == '/') {
varbufreset(result);
- varbufaddstr(result,instdir);
- debug(dbg_conffdetail,"conffderef readlink
absolute");
+ varbufaddstr(result, instdir);
+ debug(dbg_conffdetail,
+ "conffderef readlink absolute");
} else {
- for (r=result->used-2; r>0 && result->buf[r] !=
'/'; r--)
+ for (r = result->used - 2; r > 0 &&
result->buf[r] != '/'; r--)
;
if (r < 0) {
warning(_("%s: conffile '%.250s'
resolves to degenerate filename\n"
@@ -408,13 +428,15 @@ int conffderef(struct pkginfo *pkg, struct varbuf
*result, const char *in) {
pkg->name, in, result->buf,
linkreadbuf);
return -1;
}
- if (result->buf[r] == '/') r++;
- result->used= r;
- debug(dbg_conffdetail,"conffderef readlink
relative to `%.*s'",
- (int)result->used, result->buf);
+ if (result->buf[r] == '/')
+ r++;
+ result->used = r;
+ debug(dbg_conffdetail,
+ "conffderef readlink relative to '%.*s'",
+ (int)result->used, result->buf);
}
- varbufaddstr(result,linkreadbuf);
- varbufaddc(result,0);
+ varbufaddstr(result, linkreadbuf);
+ varbufaddc(result, 0);
} else {
warning(_("%s: conffile '%.250s' is not a plain file or
symlink (= '%s')"),
pkg->name, in, result->buf);
@@ -422,7 +444,7 @@ int conffderef(struct pkginfo *pkg, struct varbuf *result,
const char *in) {
}
}
}
-
+
/*
* Generate a MD5 hash for fn and store it in hashbuf, which needs to be
* at least MD5HASHLEN + 1 characters long.
@@ -432,14 +454,14 @@ md5hash(struct pkginfo *pkg, char *hashbuf, const char
*fn)
{
static int fd;
- fd=open(fn,O_RDONLY);
+ fd = open(fn, O_RDONLY);
- if (fd>=0) {
+ if (fd >= 0) {
push_cleanup(cu_closefd, ehflag_bombout, NULL, 0, 1, &fd);
fd_md5(fd, hashbuf, -1, _("md5hash"));
- pop_cleanup(ehflag_normaltidy); /* fd= open(cdr.buf) */
+ pop_cleanup(ehflag_normaltidy); /* fd = open(cdr.buf) */
close(fd);
- } else if (errno==ENOENT) {
+ } else if (errno == ENOENT) {
strcpy(hashbuf, NONEXISTENTFLAG);
} else {
warning(_("%s: unable to open conffile %s for hash: %s"),
@@ -448,152 +470,162 @@ md5hash(struct pkginfo *pkg, char *hashbuf, const char
*fn)
}
}
-/* Copy file ownership and permissions from one file to another
+/*
+ * Copy file ownership and permissions from one file to another.
*/
-static void copyfileperm(const char* source, const char* target) {
- struct stat stab;
+static void
+copyfileperm(const char *source, const char *target)
+{
+ struct stat stab;
- if (stat(source, &stab)==-1) {
- if (errno==ENOENT)
+ if (stat(source, &stab) == -1) {
+ if (errno == ENOENT)
return;
- ohshite(_("unable to stat current installed conffile
`%.250s'"), source);
+ ohshite(_("unable to stat current installed conffile `%.250s'"),
+ source);
}
- if (chown(target, stab.st_uid, stab.st_gid)==-1)
- ohshite(_("unable to change ownership of new dist conffile
`%.250s'"), target);
+ if (chown(target, stab.st_uid, stab.st_gid) == -1)
+ ohshite(_("unable to change ownership of new dist conffile
`%.250s'"),
+ target);
- if (chmod(target, (stab.st_mode & 07777))==-1)
- ohshite(_("unable to set mode of new dist conffile `%.250s'"),
target);
+ if (chmod(target, (stab.st_mode & 07777)) == -1)
+ ohshite(_("unable to set mode of new dist conffile `%.250s'"),
+ target);
}
+/*
+ * Show a diff between two files.
+ */
+static void
+showdiff(const char *old, const char *new)
+{
+ int pid;
+ int r;
+ int status;
+ pid = m_fork();
+ if (!pid) {
+ /* Child process. */
+ const char *p; /* pager */
+ const char *s; /* shell */
+ char cmdbuf[1024]; /* command to run */
-
-/* Show a diff between two files
- */
-static void showdiff(const char* old, const char* new) {
- int pid;
- int r;
- int status;
-
- if (!(pid=m_fork())) {
- /* Child process */
- const char* p; /* pager */
- const char* s; /* shell */
- char cmdbuf[1024]; /* command to run */
-
- p=getenv(PAGERENV);
+ p = getenv(PAGERENV);
if (!p || !*p)
- p=DEFAULTPAGER;
+ p = DEFAULTPAGER;
sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s", old, new,
p);
- s=getenv(SHELLENV);
+ s = getenv(SHELLENV);
if (!s || !*s)
- s=DEFAULTSHELL;
+ s = DEFAULTSHELL;
- execlp(s,s,"-c", cmdbuf, NULL);
+ execlp(s, s, "-c", cmdbuf, NULL);
ohshite(_("failed to run %s (%.250s)"), DIFF, cmdbuf);
}
- /* Parent process */
- while (((r=waitpid(pid,&status,0))==-1) && (errno==EINTR))
+ /* Parent process. */
+ while (((r = waitpid(pid, &status, 0)) == -1) && (errno == EINTR))
;
- if (r!=pid) {
+ if (r != pid) {
onerr_abort++;
ohshite(_("wait for shell failed"));
}
}
-
-/* Suspend dpkg temporarily
+/*
+ * Suspend dpkg temporarily.
*/
-static void suspend(void) {
- const char* s;
- int pid;
+static void
+suspend(void)
+{
+ const char *s;
+ int pid;
- s= getenv(NOJOBCTRLSTOPENV);
+ s = getenv(NOJOBCTRLSTOPENV);
if (s && *s) {
- /* Do not job control to suspend but fork and start a new shell
- * instead.
- */
+ /* Do not job control to suspend but fork and start a new
+ * shell instead. */
- int status; /* waitpid status */
- int r; /* waitpid result */
+ int status; /* waitpid status */
+ int r; /* waitpid result */
fputs(_("Type `exit' when you're done.\n"), stderr);
- if (!(pid= m_fork())) {
+ pid = m_fork();
+ if (!pid) {
/* Child process */
- s= getenv(SHELLENV);
+ s = getenv(SHELLENV);
if (!s || !*s)
- s=DEFAULTSHELL;
+ s = DEFAULTSHELL;
execlp(s, s, "-i", NULL);
- ohshite(_("failed to exec shell (%.250s)"),s);
+ ohshite(_("failed to exec shell (%.250s)"), s);
}
- /* Parent process */
- while (((r=waitpid(pid,&status,0))==-1) && (errno==EINTR))
+ /* Parent process. */
+ while (((r = waitpid(pid, &status, 0)) == -1) && (errno ==
EINTR))
;
- if (r!=pid) {
+ if (r != pid) {
onerr_abort++;
ohshite(_("wait for shell failed"));
}
} else {
fputs(_("Don't forget to foreground (`fg') this "
- "process when you're done !\n"),
stderr);
- kill(-getpgid(0),SIGTSTP);
+ "process when you're done !\n"), stderr);
+ kill(-getpgid(0), SIGTSTP);
}
}
-
-/* Select what to do with a configuration file.
+/*
+ * Select what to do with a configuration file.
*/
-static enum conffopt promptconfaction(const char* cfgfile, const char* realold,
- const char* realnew, int useredited, int distedited,
- enum conffopt what) {
+static enum conffopt
+promptconfaction(const char *cfgfile, const char *realold, const char *realnew,
+ int useredited, int distedited, enum conffopt what)
+{
const char *s;
int c, cc;
- if (!(what&cfof_prompt))
+ if (!(what & cfof_prompt))
return what;
statusfd_send("status: %s : %s : '%s' '%s' %i %i ",
- cfgfile, "conffile-prompt",
- realold, realnew, useredited, distedited);
+ cfgfile, "conffile-prompt",
+ realold, realnew, useredited, distedited);
do {
- /* Flush the terminal's input in case the user
- * involuntarily typed some characters.
- */
+ /* Flush the terminal's input in case the user involuntarily
+ * typed some characters. */
tcflush(STDIN_FILENO, TCIFLUSH);
fprintf(stderr, _("\nConfiguration file `%s'"), cfgfile);
if (strcmp(cfgfile, realold))
- fprintf(stderr,_(" (actually `%s')"), realold);
+ fprintf(stderr, _(" (actually `%s')"), realold);
if (what & cfof_isnew) {
fprintf(stderr,
- _("\n"
- " ==> File on system created by
you or by a script.\n"
- " ==> File also in package
provided by package maintainer.\n"));
+ _("\n"
+ " ==> File on system created by you or by a
script.\n"
+ " ==> File also in package provided by
package maintainer.\n"));
} else {
fprintf(stderr, !useredited ?
- _("\n Not modified since
installation.\n") :
- !(what & cfof_userrmd) ?
- _("\n ==> Modified (by you or by a
script) since installation.\n") :
- _("\n ==> Deleted (by you or by a
script) since installation.\n"));
+ _("\n Not modified since installation.\n") :
+ !(what & cfof_userrmd) ?
+ _("\n ==> Modified (by you or by a script)
since installation.\n") :
+ _("\n ==> Deleted (by you or by a script) since
installation.\n"));
fprintf(stderr, distedited ?
- _(" ==> Package distributor has shipped
an updated version.\n") :
- _(" Version in package is the same
as at last installation.\n"));
+ _(" ==> Package distributor has shipped an
updated version.\n") :
+ _(" Version in package is the same as at
last installation.\n"));
}
- /* No --force-confdef but a forcible situtation */
- /* TODO: check if this condition can not be simplified to just
!fc_conff_def */
- if (!(fc_conff_def && (what&(cfof_install|cfof_keep)))) {
+ /* No --force-confdef but a forcible situtation. */
+ /* TODO: check if this condition can not be simplified to
+ * just !fc_conff_def */
+ if (!(fc_conff_def && (what & (cfof_install | cfof_keep)))) {
if (fc_conff_new) {
fprintf(stderr, _(" ==> Using new file as you
requested.\n"));
cc = 'y';
@@ -605,84 +637,90 @@ static enum conffopt promptconfaction(const char*
cfgfile, const char* realold,
}
}
-
- /* Force the default action (if there is one */
+ /* Force the default action (if there is one. */
if (fc_conff_def) {
- if (what&cfof_keep) {
+ if (what & cfof_keep) {
fprintf(stderr, _(" ==> Keeping old config file
as default.\n"));
cc = 'n';
break;
- } else if (what&cfof_install) {
+ } else if (what & cfof_install) {
fprintf(stderr, _(" ==> Using new config file
as default.\n"));
cc = 'y';
break;
}
}
-
fprintf(stderr,
- _(" What would you like to do about it ?
Your options are:\n"
- " Y or I : install the package
maintainer's version\n"
- " N or O : keep your
currently-installed version\n"
- " D : show the differences
between the versions\n"
- " Z : background this process
to examine the situation\n"));
+ _(" What would you like to do about it ? Your
options are:\n"
+ " Y or I : install the package maintainer's
version\n"
+ " N or O : keep your currently-installed
version\n"
+ " D : show the differences between the
versions\n"
+ " Z : background this process to examine the
situation\n"));
if (what & cfof_keep)
fprintf(stderr, _(" The default action is to keep your
current version.\n"));
else if (what & cfof_install)
fprintf(stderr, _(" The default action is to install
the new version.\n"));
- s= strrchr(cfgfile,'/');
- if (!s || !*++s) s= cfgfile;
+ s = strrchr(cfgfile, '/');
+ if (!s || !*++s)
+ s = cfgfile;
fprintf(stderr, "*** %s (Y/I/N/O/D/Z) %s ? ",
- s,
- (what & cfof_keep) ? _("[default=N]") :
- (what & cfof_install) ? _("[default=Y]") :
_("[no default]"));
+ s,
+ (what & cfof_keep) ? _("[default=N]") :
+ (what & cfof_install) ? _("[default=Y]") :
+ _("[no default]"));
if (ferror(stderr))
ohshite(_("error writing to stderr, discovered before
conffile prompt"));
- cc= 0;
- while ((c= getchar()) != EOF && c != '\n')
- if (!isspace(c) && !cc) cc= tolower(c);
+ cc = 0;
+ while ((c = getchar()) != EOF && c != '\n')
+ if (!isspace(c) && !cc)
+ cc = tolower(c);
if (c == EOF) {
- if (ferror(stdin)) ohshite(_("read error on stdin at
conffile prompt"));
+ if (ferror(stdin))
+ ohshite(_("read error on stdin at conffile
prompt"));
ohshit(_("EOF on stdin at conffile prompt"));
}
if (!cc) {
- if (what & cfof_keep) { cc= 'n'; break; }
- else if (what & cfof_install) { cc= 'y'; break; }
+ if (what & cfof_keep) {
+ cc = 'n';
+ break;
+ } else if (what & cfof_install) {
+ cc = 'y';
+ break;
+ }
}
- /* FIXME: say something if silently not install */
+ /* FIXME: Say something if silently not install. */
if (cc == 'd')
showdiff(realold, realnew);
if (cc == 'z')
suspend();
-
- } while (!strchr("yino",cc));
+ } while (!strchr("yino", cc));
log_message("conffile %s %s", cfgfile,
- (cc == 'i' || cc == 'y') ? "install" : "keep");
+ (cc == 'i' || cc == 'y') ? "install" : "keep");
what &= cfof_userrmd;
switch (cc) {
- case 'i':
- case 'y':
- what |= cfof_install|cfof_backup;
- break;
-
- case 'n':
- case 'o':
- what |= cfof_keep|cfof_backup;
- break;
-
- default:
- internerr("unknown response '%d'", cc);
+ case 'i':
+ case 'y':
+ what |= cfof_install | cfof_backup;
+ break;
+
+ case 'n':
+ case 'o':
+ what |= cfof_keep | cfof_backup;
+ break;
+
+ default:
+ internerr("unknown response '%d'", cc);
}
return what;
diff --git a/utils/start-stop-daemon.c b/utils/start-stop-daemon.c
index e282f03..2214819 100644
--- a/utils/start-stop-daemon.c
+++ b/utils/start-stop-daemon.c
@@ -195,7 +195,7 @@ struct schedule_item {
sched_goto,
sched_forever /* Only seen within parse_schedule and callees */
} type;
- int value; /* Seconds, signal no., or index into array */
+ int value; /* Seconds, signal no., or index into array. */
};
static struct res_schedule *proc_sched = NULL;
@@ -312,10 +312,10 @@ daemonize(void)
pid = fork();
if (pid < 0)
fatal("Unable to do first fork.\n");
- else if (pid) /* Parent */
+ else if (pid) /* Parent. */
_exit(0);
- /* Create a new session */
+ /* Create a new session. */
#ifdef HAVE_SETSID
setsid();
#else
@@ -325,7 +325,7 @@ daemonize(void)
pid = fork();
if (pid < 0)
fatal("Unable to do second fork.\n");
- else if (pid) /* Parent */
+ else if (pid) /* Parent. */
_exit(0);
if (quietmode < 0)
@@ -427,7 +427,7 @@ badusage(const char *msg)
{
if (msg)
fprintf(stderr, "%s: %s\n", progname, msg);
- fprintf(stderr, "Try `%s --help' for more information.\n", progname);
+ fprintf(stderr, "Try '%s --help' for more information.\n", progname);
exit(3);
}
@@ -637,7 +637,7 @@ parse_schedule_item(const char *string, struct
schedule_item *item)
item->type = sched_signal;
} else {
badusage("invalid schedule item (must be [-]<signal-name>, "
- "-<signal-number>, <timeout> or `forever'");
+ "-<signal-number>, <timeout> or 'forever'");
}
}
@@ -684,7 +684,7 @@ parse_schedule(const char *schedule_str)
parse_schedule_item(item_buf, &schedule[count]);
if (schedule[count].type == sched_forever) {
if (repeatat >= 0)
- badusage("invalid schedule: `forever'"
+ badusage("invalid schedule: 'forever'"
" appears more than once");
repeatat = count;
continue;
@@ -825,14 +825,15 @@ parse_options(int argc, char * const *argv)
changedir = optarg;
break;
default:
- badusage(NULL); /* message printed by getopt */
+ /* Message printed by getopt. */
+ badusage(NULL);
}
}
if (signal_str != NULL) {
if (parse_signal(signal_str, &signal_nr) != 0)
badusage("signal value must be numeric or name"
- " of signal (KILL, INT, ...)");
+ " of signal (KILL, INT, ...)");
}
if (schedule_str != NULL) {
@@ -950,8 +951,8 @@ pid_is_exec(pid_t pid, const struct stat *esb)
if (pstat_getproc(&pst, sizeof(pst), (size_t)0, (int)pid) < 0)
return 0;
- return ((dev_t)pst.pst_text.psf_fsid.psfs_id == esb->st_dev
- && (ino_t)pst.pst_text.psf_fileid == esb->st_ino);
+ return ((dev_t)pst.pst_text.psf_fsid.psfs_id == esb->st_dev &&
+ (ino_t)pst.pst_text.psf_fileid == esb->st_ino);
}
#elif defined(HAVE_KVM_H)
static int
@@ -1011,7 +1012,7 @@ static int
pid_is_user(pid_t pid, uid_t uid)
{
kvm_t *kd;
- int nentries; /* Value not used */
+ int nentries; /* Value not used. */
uid_t proc_uid;
struct kinfo_proc *kp;
char errbuf[_POSIX2_LINE_MAX];
@@ -1049,7 +1050,7 @@ pid_is_cmd(pid_t pid, const char *name)
fclose(f);
return 0;
}
- /* this hopefully handles command names containing ')' */
+ /* This hopefully handles command names containing ')'. */
while ((c = getc(f)) != EOF && c == *name)
name++;
fclose(f);
@@ -1096,7 +1097,7 @@ pid_is_cmd(pid_t pid, const char *name)
errx(1, "%s", kvm_geterr(kd));
start_argv_0_p = *pid_argv_p;
- /* Find and compare string */
+ /* Find and compare string. */
/* Find end of argv[0] then copy and cut of str there. */
end_argv_0_p = strchr(*pid_argv_p, ' ');
@@ -1148,7 +1149,7 @@ check(pid_t pid)
if (execname && !pid_is_exec(pid, execname))
return;
#elif defined(OSHurd) || defined(OSFreeBSD) || defined(OSNetBSD)
- /* Let's try this to see if it works */
+ /* Let's try this to see if it works. */
if (execname && !pid_is_cmd(pid, execname))
return;
#endif
@@ -1239,7 +1240,7 @@ do_procinit(void)
static void
do_procinit(void)
{
- /* Nothing to do */
+ /* Nothing to do. */
}
#endif
@@ -1255,7 +1256,8 @@ do_findprocs(void)
}
static void
-do_stop(int signal_nr, int quietmode, int *n_killed, int *n_notkilled, int
retry_nr)
+do_stop(int signal_nr, int quietmode, int *n_killed, int *n_notkilled,
+ int retry_nr)
{
struct pid_list *p;
@@ -1322,9 +1324,9 @@ run_stop_schedule(void)
else if (execname)
set_what_stop(execname);
else if (pidfile)
- sprintf(what_stop, "process in pidfile `%.200s'", pidfile);
+ sprintf(what_stop, "process in pidfile '%.200s'", pidfile);
else if (userspec)
- sprintf(what_stop, "process(es) owned by `%.200s'", userspec);
+ sprintf(what_stop, "process(es) owned by '%.200s'", userspec);
else
fatal("internal error, please report");
@@ -1341,7 +1343,7 @@ run_stop_schedule(void)
}
for (position = 0; position < schedule_length; ) {
- value= schedule[position].value;
+ value = schedule[position].value;
n_notkilled = 0;
switch (schedule[position].type) {
@@ -1372,7 +1374,7 @@ run_stop_schedule(void)
* poll. However, if that would put us past the end of the timeout
* period we wait only as long as the timeout period, but in any case
* we always wait at least MIN_POLL_INTERVAL (20ms). The multiple
- * (`ratio') starts out as 2, and increases by 1 for each poll to a
+ * (‘ratio’) starts out as 2, and increases by 1 for each poll to a
* maximum of 10; so we use up to between 30% and 10% of the
* machine's resources (assuming a few reasonable things about system
* performance).
@@ -1480,7 +1482,7 @@ main(int argc, char **argv)
pw = getpwnam(userspec);
if (!pw)
- fatal("user `%s' not found\n", userspec);
+ fatal("user '%s' not found\n", userspec);
user_id = pw->pw_uid;
}
@@ -1488,7 +1490,7 @@ main(int argc, char **argv)
if (changegroup && sscanf(changegroup, "%d", &runas_gid) != 1) {
struct group *gr = getgrnam(changegroup);
if (!gr)
- fatal("group `%s' not found\n", changegroup);
+ fatal("group '%s' not found\n", changegroup);
runas_gid = gr->gr_gid;
}
if (changeuser) {
@@ -1499,11 +1501,11 @@ main(int argc, char **argv)
else
pw = getpwnam(changeuser);
if (!pw)
- fatal("user `%s' not found\n", changeuser);
+ fatal("user '%s' not found\n", changeuser);
runas_uid = pw->pw_uid;
if (changegroup == NULL) {
- /* Pass the default group of this user */
- changegroup = ""; /* Just empty */
+ /* Pass the default group of this user. */
+ changegroup = ""; /* Just empty. */
runas_gid = pw->pw_gid;
}
if (access(pw->pw_dir, F_OK) == 0)
@@ -1550,13 +1552,14 @@ main(int argc, char **argv)
if (quietmode < 0)
printf("Starting %s...\n", startas);
*--argv = startas;
- if (background) { /* ok, we need to detach this process */
+ if (background) {
+ /* Ok, we need to detach this process. */
daemonize();
#ifdef HAVE_TIOCNOTTY
- tty_fd=open("/dev/tty", O_RDWR);
+ tty_fd = open("/dev/tty", O_RDWR);
#endif
- devnull_fd=open("/dev/null", O_RDWR);
+ devnull_fd = open("/dev/null", O_RDWR);
}
if (nicelevel) {
errno = 0;
@@ -1571,11 +1574,11 @@ main(int argc, char **argv)
if (umask_value >= 0)
umask(umask_value);
if (mpidfile && pidfile != NULL) {
- /* User wants _us_ to make the pidfile :) */
+ /* User wants _us_ to make the pidfile. :) */
FILE *pidf = fopen(pidfile, "w");
pid_t pidt = getpid();
if (pidf == NULL)
- fatal("Unable to open pidfile `%s' for writing: %s",
+ fatal("Unable to open pidfile '%s' for writing: %s",
pidfile, strerror(errno));
fprintf(pidf, "%d\n", pidt);
fclose(pidf);
@@ -1611,20 +1614,20 @@ main(int argc, char **argv)
}
if (background) {
- /* Continue background setup */
+ /* Continue background setup. */
int i;
#ifdef HAVE_TIOCNOTTY
- /* Change tty */
+ /* Change tty. */
ioctl(tty_fd, TIOCNOTTY, 0);
close(tty_fd);
#endif
if (umask_value < 0)
- umask(022); /* Set a default for dumb programs */
+ umask(022); /* Set a default for dumb programs. */
dup2(devnull_fd, 0); /* stdin */
dup2(devnull_fd, 1); /* stdout */
dup2(devnull_fd, 2); /* stderr */
- /* Now close all extra fds */
+ /* Now close all extra fds. */
for (i = get_open_fd_max() - 1; i >= 3; --i)
close(i);
}
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]