summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2013-11-13 05:21:33 +0100
committerGuillem Jover <guillem@debian.org>2013-12-07 07:51:18 +0100
commit43f4d203d023ddda063968a11c02ad125c22cac9 (patch)
tree7b044a78432a0058a997fc7ad57ad41f634ff7db /src
parent6263f5190eceec3bc30e8c8528c6388cfb1ff15f (diff)
downloaddpkg-43f4d203d023ddda063968a11c02ad125c22cac9.tar.gz
dpkg: Move functions around to avoid static declaration
Diffstat (limited to 'src')
-rw-r--r--src/configure.c265
1 files changed, 130 insertions, 135 deletions
diff --git a/src/configure.c b/src/configure.c
index 0ce428a7a..c69970c6e 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -82,11 +82,6 @@ static int conffoptcells[2][2] = {
{ cfo_keep, cfo_prompt_keep }, /* User edited. */
};
-static enum conffopt promptconfaction(struct pkginfo *pkg, const char *cfgfile,
- const char *realold, const char *realnew,
- int useredited, int distedited,
- enum conffopt what);
-
static int
show_prompt(const char *cfgfile, const char *realold, const char *realnew,
int useredited, int distedited, enum conffopt what)
@@ -194,6 +189,136 @@ show_prompt(const char *cfgfile, const char *realold, const char *realnew,
}
/**
+ * Show a diff between two files.
+ *
+ * @param old The path to the old file.
+ * @param new The path to the new file.
+ */
+static void
+showdiff(const char *old, const char *new)
+{
+ pid_t pid;
+
+ pid = subproc_fork();
+ if (!pid) {
+ /* Child process. */
+ char cmdbuf[1024];
+
+ sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s",
+ str_quote_meta(old), str_quote_meta(new),
+ command_get_pager());
+
+ command_shell(cmdbuf, _("conffile difference visualizer"));
+ }
+
+ /* Parent process. */
+ subproc_wait(pid, _("conffile difference visualizer"));
+}
+
+/**
+ * Spawn a new shell.
+ *
+ * Create a subprocess and execute a shell to allow the user to manually
+ * solve the conffile conflict.
+ *
+ * @param confold The path to the old conffile.
+ * @param confnew The path to the new conffile.
+ */
+static void
+spawn_shell(const char *confold, const char *confnew)
+{
+ pid_t pid;
+
+ fputs(_("Type `exit' when you're done.\n"), stderr);
+
+ pid = subproc_fork();
+ if (!pid) {
+ /* Set useful variables for the user. */
+ setenv("DPKG_SHELL_REASON", "conffile-prompt", 1);
+ setenv("DPKG_CONFFILE_OLD", confold, 1);
+ setenv("DPKG_CONFFILE_NEW", confnew, 1);
+
+ command_shell(NULL, _("conffile shell"));
+ }
+
+ /* Parent process. */
+ subproc_wait(pid, _("conffile shell"));
+}
+
+/**
+ * Prompt the user for how to resolve a conffile conflict.
+ *
+ * When encountering a conffile conflict during configuration, the user will
+ * normally be presented with a textual menu of possible actions. This
+ * behavior is modified via various --force flags and perhaps on whether
+ * or not a terminal is available to do the prompting.
+ *
+ * @param pkg The package owning the conffile.
+ * @param cfgfile The path to the old conffile.
+ * @param realold The path to the old conffile, dereferenced in case of a
+ * symlink, otherwise equal to cfgfile.
+ * @param realnew The path to the new conffile, dereferenced in case of a
+ * symlink).
+ * @param useredited A flag to indicate whether the file has been edited
+ * locally. Set to nonzero to indicate that the file has been modified.
+ * @param distedited A flag to indicate whether the file has been updated
+ * between package versions. Set to nonzero to indicate that the file
+ * has been updated.
+ * @param what Hints on what action should be taken by defualt.
+ *
+ * @return The action which should be taken based on user input and/or the
+ * default actions as configured by cmdline/configuration options.
+ */
+static enum conffopt
+promptconfaction(struct pkginfo *pkg, const char *cfgfile,
+ const char *realold, const char *realnew,
+ int useredited, int distedited, enum conffopt what)
+{
+ int cc;
+
+ if (!(what & cfof_prompt))
+ return what;
+
+ statusfd_send("status: %s : %s : '%s' '%s' %i %i ",
+ cfgfile, "conffile-prompt",
+ realold, realnew, useredited, distedited);
+
+ do {
+ cc = show_prompt(cfgfile, realold, realnew,
+ useredited, distedited, what);
+
+ /* FIXME: Say something if silently not install. */
+ if (cc == 'd')
+ showdiff(realold, realnew);
+
+ if (cc == 'z')
+ spawn_shell(realold, realnew);
+ } while (!strchr("yino", cc));
+
+ log_message("conffile %s %s", cfgfile,
+ (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);
+ }
+
+ return what;
+}
+
+/**
* Configure the ghost conffile instance.
*
* When the first instance of a package set is configured, the *.dpkg-new
@@ -709,133 +834,3 @@ md5hash(struct pkginfo *pkg, char *hashbuf, const char *fn)
strcpy(hashbuf, EMPTYHASHFLAG);
}
}
-
-/**
- * Show a diff between two files.
- *
- * @param old The path to the old file.
- * @param new The path to the new file.
- */
-static void
-showdiff(const char *old, const char *new)
-{
- pid_t pid;
-
- pid = subproc_fork();
- if (!pid) {
- /* Child process. */
- char cmdbuf[1024];
-
- sprintf(cmdbuf, DIFF " -Nu %.250s %.250s | %.250s",
- str_quote_meta(old), str_quote_meta(new),
- command_get_pager());
-
- command_shell(cmdbuf, _("conffile difference visualizer"));
- }
-
- /* Parent process. */
- subproc_wait(pid, _("conffile difference visualizer"));
-}
-
-/**
- * Spawn a new shell.
- *
- * Create a subprocess and execute a shell to allow the user to manually
- * solve the conffile conflict.
- *
- * @param confold The path to the old conffile.
- * @param confnew The path to the new conffile.
- */
-static void
-spawn_shell(const char *confold, const char *confnew)
-{
- pid_t pid;
-
- fputs(_("Type `exit' when you're done.\n"), stderr);
-
- pid = subproc_fork();
- if (!pid) {
- /* Set useful variables for the user. */
- setenv("DPKG_SHELL_REASON", "conffile-prompt", 1);
- setenv("DPKG_CONFFILE_OLD", confold, 1);
- setenv("DPKG_CONFFILE_NEW", confnew, 1);
-
- command_shell(NULL, _("conffile shell"));
- }
-
- /* Parent process. */
- subproc_wait(pid, _("conffile shell"));
-}
-
-/**
- * Prompt the user for how to resolve a conffile conflict.
- *
- * When encountering a conffile conflict during configuration, the user will
- * normally be presented with a textual menu of possible actions. This
- * behavior is modified via various --force flags and perhaps on whether
- * or not a terminal is available to do the prompting.
- *
- * @param pkg The package owning the conffile.
- * @param cfgfile The path to the old conffile.
- * @param realold The path to the old conffile, dereferenced in case of a
- * symlink, otherwise equal to cfgfile.
- * @param realnew The path to the new conffile, dereferenced in case of a
- * symlink).
- * @param useredited A flag to indicate whether the file has been edited
- * locally. Set to nonzero to indicate that the file has been modified.
- * @param distedited A flag to indicate whether the file has been updated
- * between package versions. Set to nonzero to indicate that the file
- * has been updated.
- * @param what Hints on what action should be taken by defualt.
- *
- * @return The action which should be taken based on user input and/or the
- * default actions as configured by cmdline/configuration options.
- */
-static enum conffopt
-promptconfaction(struct pkginfo *pkg, const char *cfgfile,
- const char *realold, const char *realnew,
- int useredited, int distedited, enum conffopt what)
-{
- int cc;
-
- if (!(what & cfof_prompt))
- return what;
-
- statusfd_send("status: %s : %s : '%s' '%s' %i %i ",
- cfgfile, "conffile-prompt",
- realold, realnew, useredited, distedited);
-
- do {
- cc = show_prompt(cfgfile, realold, realnew,
- useredited, distedited, what);
-
- /* FIXME: Say something if silently not install. */
- if (cc == 'd')
- showdiff(realold, realnew);
-
- if (cc == 'z')
- spawn_shell(realold, realnew);
- } while (!strchr("yino", cc));
-
- log_message("conffile %s %s", cfgfile,
- (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);
- }
-
- return what;
-}