No change, just refactoring.
---
src/main.c | 23 +++++++++++++++--------
1 file changed, 15 insertions(+), 8 deletions(-)
diff --git a/src/main.c b/src/main.c
index 46dd08c..4eca859 100644
--- a/src/main.c
+++ b/src/main.c
@@ -62,8 +62,9 @@
#define FIRST_SOCKET_ACTIVATION_FD 3 /* defined by systemd ABI */
+static int is_short_name (const char *);
static char *make_random_fifo (void);
-static void open_plugin_so (const char *filename, int is_short_name);
+static void open_plugin_so (const char *filename, int short_name);
static void start_serving (void);
static void set_up_signals (void);
static void run_command (void);
@@ -198,7 +199,7 @@ main (int argc, char *argv[])
int option_index;
int help = 0, version = 0, dump_plugin = 0;
int tls_set_on_cli = 0;
- int is_short_name;
+ int short_name;
const char *filename;
char *p;
@@ -461,13 +462,12 @@ main (int argc, char *argv[])
* help/version/plugin information.
*/
filename = argv[optind++];
- is_short_name =
- strchr (filename, '.') == NULL && strchr (filename, '/') ==
NULL;
+ short_name = is_short_name (filename);
/* Is there an executable script located in the plugindir?
* If so we simply execute it with the current command line.
*/
- if (is_short_name) {
+ if (short_name) {
size_t i;
struct stat statbuf;
CLEANUP_FREE char *script;
@@ -493,7 +493,7 @@ main (int argc, char *argv[])
}
}
- open_plugin_so (filename, is_short_name);
+ open_plugin_so (filename, short_name);
if (help) {
usage ();
@@ -570,6 +570,13 @@ main (int argc, char *argv[])
exit (EXIT_SUCCESS);
}
+/* Is it a name relative to the plugindir? */
+static int
+is_short_name (const char *filename)
+{
+ return strchr (filename, '.') == NULL && strchr (filename, '/')
== NULL;
+}
+
/* Implementation of '-U -' */
static char *
make_random_fifo (void)
@@ -603,7 +610,7 @@ make_random_fifo (void)
}
static void
-open_plugin_so (const char *name, int is_short_name)
+open_plugin_so (const char *name, int short_name)
{
char *filename = (char *) name;
int free_filename = 0;
@@ -611,7 +618,7 @@ open_plugin_so (const char *name, int is_short_name)
struct nbdkit_plugin *(*plugin_init) (void);
char *error;
- if (is_short_name) {
+ if (short_name) {
/* Short names are rewritten relative to the plugindir. */
if (asprintf (&filename,
"%s/nbdkit-%s-plugin.so", plugindir, name) == -1) {
--
2.15.1