summaryrefslogtreecommitdiff
path: root/dpkg-split
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2010-07-11 15:49:27 +0200
committerGuillem Jover <guillem@debian.org>2010-07-11 15:49:27 +0200
commitd647c878fb04db22dd0cfa7a57bee8f1d3caeac8 (patch)
tree8c05eb96e34e23a0f6edb42b44711185d40c8902 /dpkg-split
parent0581dda824f26e9eec996ebf4de5f6474336bec2 (diff)
downloaddpkg-d647c878fb04db22dd0cfa7a57bee8f1d3caeac8.tar.gz
dpkg-split: Namespace global option variables to not shadow local ones
Diffstat (limited to 'dpkg-split')
-rw-r--r--dpkg-split/dpkg-split.h9
-rw-r--r--dpkg-split/join.c6
-rw-r--r--dpkg-split/main.c29
-rw-r--r--dpkg-split/queue.c26
-rw-r--r--dpkg-split/split.c4
5 files changed, 41 insertions, 33 deletions
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h
index 64b331acc..4fd0bf701 100644
--- a/dpkg-split/dpkg-split.h
+++ b/dpkg-split/dpkg-split.h
@@ -51,10 +51,13 @@ struct partqueue {
extern dofunction *action;
extern const struct cmdinfo *cipaction;
-extern long maxpartsize;
-extern const char *depotdir, *outputfile;
extern struct partqueue *queue;
-extern int npquiet, msdos;
+
+extern long opt_maxpartsize;
+extern const char *opt_depotdir;
+extern const char *opt_outputfile;
+extern int opt_npquiet;
+extern int opt_msdos;
void rerr(const char *fn) DPKG_ATTR_NORET;
void rerreof(FILE *f, const char *fn) DPKG_ATTR_NORET;
diff --git a/dpkg-split/join.c b/dpkg-split/join.c
index 7a4e950ea..ad9fb069b 100644
--- a/dpkg-split/join.c
+++ b/dpkg-split/join.c
@@ -135,13 +135,13 @@ void do_join(const char *const *argv) {
for (i=0; i<refi->maxpartn; i++) {
if (!partlist[i]) ohshit(_("part %d is missing"),i+1);
}
- if (!outputfile) {
+ if (!opt_outputfile) {
p= nfmalloc(strlen(refi->package)+1+strlen(refi->version)+sizeof(DEBEXT));
strcpy(p,refi->package);
strcat(p,"-");
strcat(p,refi->version);
strcat(p,DEBEXT);
- outputfile= p;
+ opt_outputfile = p;
}
- reassemble(partlist,outputfile);
+ reassemble(partlist, opt_outputfile);
}
diff --git a/dpkg-split/main.c b/dpkg-split/main.c
index 82a672df0..a143eb004 100644
--- a/dpkg-split/main.c
+++ b/dpkg-split/main.c
@@ -98,10 +98,13 @@ const char printforhelp[]= N_("Type dpkg-split --help for help.");
dofunction *action=NULL;
const struct cmdinfo *cipaction=NULL;
-long maxpartsize= SPLITPARTDEFMAX;
-const char *depotdir= ADMINDIR "/" PARTSDIR, *outputfile= NULL;
struct partqueue *queue= NULL;
-int npquiet= 0, msdos= 0;
+
+long opt_maxpartsize = SPLITPARTDEFMAX;
+const char *opt_depotdir = ADMINDIR "/" PARTSDIR;
+const char *opt_outputfile = NULL;
+int opt_npquiet = 0;
+int opt_msdos = 0;
void rerr(const char *fn) {
ohshite(_("error reading %.250s"), fn);
@@ -124,8 +127,8 @@ static void setpartsize(const struct cmdinfo *cip, const char *value) {
if (newpartsize <= 0 || newpartsize > (INT_MAX >> 10))
badusage(_("part size is far too large or is not positive"));
- maxpartsize= newpartsize << 10;
- if (maxpartsize <= HEADERALLOWANCE)
+ opt_maxpartsize = newpartsize << 10;
+ if (opt_maxpartsize <= HEADERALLOWANCE)
badusage(_("part size must be at least %d KiB (to allow for header)"),
(HEADERALLOWANCE >> 10) + 1);
}
@@ -151,11 +154,11 @@ static const struct cmdinfo cmdinfos[]= {
{ "discard", 'd', 0, NULL, NULL, setaction },
{ "help", 'h', 0, NULL, NULL, usage },
{ "version", 0, 0, NULL, NULL, printversion },
- { "depotdir", 0, 1, NULL, &depotdir, NULL },
+ { "depotdir", 0, 1, NULL, &opt_depotdir, NULL },
{ "partsize", 'S', 1, NULL, NULL, setpartsize },
- { "output", 'o', 1, NULL, &outputfile, NULL },
- { "npquiet", 'Q', 0, &npquiet, NULL, NULL, 1 },
- { "msdos", 0, 0, &msdos, NULL, NULL, 1 },
+ { "output", 'o', 1, NULL, &opt_outputfile, NULL },
+ { "npquiet", 'Q', 0, &opt_npquiet, NULL, NULL, 1 },
+ { "msdos", 0, 0, &opt_msdos, NULL, NULL, 1 },
{ NULL, 0 }
};
@@ -182,12 +185,12 @@ int main(int argc, const char *const *argv) {
if (!cipaction) badusage(_("need an action option"));
- l= strlen(depotdir);
- if (l && depotdir[l-1] != '/') {
+ l = strlen(opt_depotdir);
+ if (l && opt_depotdir[l - 1] != '/') {
p= nfmalloc(l+2);
- strcpy(p,depotdir);
+ strcpy(p, opt_depotdir);
strcpy(p+l,"/");
- depotdir= p;
+ opt_depotdir = p;
}
setvbuf(stdout,NULL,_IONBF,0);
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index a2ed8371e..69ac9767f 100644
--- a/dpkg-split/queue.c
+++ b/dpkg-split/queue.c
@@ -84,16 +84,17 @@ void scandepot(void) {
char *p;
assert(!queue);
- depot= opendir(depotdir);
- if (!depot) ohshite(_("unable to read depot directory `%.250s'"),depotdir);
+ depot = opendir(opt_depotdir);
+ if (!depot)
+ ohshite(_("unable to read depot directory `%.250s'"), opt_depotdir);
while ((de= readdir(depot))) {
if (de->d_name[0] == '.') continue;
pq= nfmalloc(sizeof(struct partqueue));
pq->info.fmtversion= pq->info.package= pq->info.version= NULL;
pq->info.orglength= pq->info.thispartoffset= pq->info.thispartlen= 0;
pq->info.headerlen= 0;
- p= nfmalloc(strlen(depotdir)+strlen(de->d_name)+1);
- strcpy(p,depotdir);
+ p = nfmalloc(strlen(opt_depotdir) + strlen(de->d_name) + 1);
+ strcpy(p, opt_depotdir);
strcat(p,de->d_name);
pq->info.filename= p;
if (!decompose_filename(de->d_name,pq)) {
@@ -126,7 +127,8 @@ void do_auto(const char *const *argv) {
void *buffer;
char *p, *q;
- if (!outputfile) badusage(_("--auto requires the use of the --output option"));
+ if (!opt_outputfile)
+ badusage(_("--auto requires the use of the --output option"));
if (!(partfile= *argv++) || *argv)
badusage(_("--auto requires exactly one part file argument"));
@@ -134,7 +136,7 @@ void do_auto(const char *const *argv) {
part= fopen(partfile,"r");
if (!part) ohshite(_("unable to read part file `%.250s'"),partfile);
if (!read_info(part,partfile,refi)) {
- if (!npquiet)
+ if (!opt_npquiet)
printf(_("File `%.250s' is not part of a multipart archive.\n"),partfile);
m_output(stdout, _("<standard output>"));
exit(1);
@@ -170,10 +172,10 @@ void do_auto(const char *const *argv) {
if (getc(part) != EOF) ohshit(_("part file `%.250s' has trailing garbage"),partfile);
if (ferror(part)) rerr(partfile);
fclose(part);
- p= nfmalloc(strlen(depotdir)+50);
- q= nfmalloc(strlen(depotdir)+200);
- sprintf(p,"%st.%lx",depotdir,(long)getpid());
- sprintf(q,"%s%s.%lx.%x.%x",depotdir,refi->md5sum,
+ p = nfmalloc(strlen(opt_depotdir) + 50);
+ q = nfmalloc(strlen(opt_depotdir) + 200);
+ sprintf(p, "%st.%lx", opt_depotdir, (long)getpid());
+ sprintf(q, "%s%s.%lx.%x.%x", opt_depotdir, refi->md5sum,
refi->maxpartlen,refi->thispartn,refi->maxpartn);
part= fopen(p,"w");
if (!part) ohshite(_("unable to open new depot file `%.250s'"),p);
@@ -193,11 +195,11 @@ void do_auto(const char *const *argv) {
printf("%s%d", !ap++ ? "" : i == (unsigned int)j ? _(" and ") : ", ", i + 1);
printf(").\n");
- dir_sync_path(depotdir);
+ dir_sync_path(opt_depotdir);
} else {
/* We have all the parts. */
- reassemble(partlist,outputfile);
+ reassemble(partlist, opt_outputfile);
/* OK, delete all the parts (except the new one, which we never copied). */
partlist[refi->thispartn-1]= otherthispart;
diff --git a/dpkg-split/split.c b/dpkg-split/split.c
index 762fd5cdf..fa7533609 100644
--- a/dpkg-split/split.c
+++ b/dpkg-split/split.c
@@ -263,9 +263,9 @@ do_split(const char *const *argv)
}
prefix = palloc;
}
- partsize = maxpartsize - HEADERALLOWANCE;
+ partsize = opt_maxpartsize - HEADERALLOWANCE;
- mksplit(sourcefile, prefix, partsize, maxpartsize, msdos);
+ mksplit(sourcefile, prefix, partsize, opt_maxpartsize, opt_msdos);
exit(0);
}