[Initng-svn] r1993 - initng/tools
svn at initng.thinktux.net
svn at initng.thinktux.net
Tue Nov 8 01:30:51 CET 2005
Author: SaTaN0r1
Date: Tue Nov 8 01:30:50 2005
New Revision: 1993
Modified:
initng/tools/install_service.c
Log:
added support for @foo:bar@ to install_service.
Modified: initng/tools/install_service.c
==============================================================================
--- initng/tools/install_service.c (original)
+++ initng/tools/install_service.c Tue Nov 8 01:30:50 2005
@@ -133,7 +133,7 @@
}
}
-static int parse_phrase(FILE * stream, const char *fullphrase, int def_path_no)
+static int parse_phrase_no_colon(FILE * stream, const char *fullphrase, int def_path_no)
{
#define FILENAME_LEN 1000
char filename[FILENAME_LEN];
@@ -154,6 +154,15 @@
else
phrase++;
+ if (phrase != fullphrase)
+ {
+ /* this means fullphrase contains an / */
+ if (is_exec(filename))
+ {
+ fputs(filename, stream);
+ return 0; /* found filename in supplied Path => no looping req'd */
+ }
+ }
tmp = path;
while (1)
{
@@ -188,6 +197,8 @@
}
i++;
}
+ if (def_path_no == -1)
+ return 1; /* this is from a coloned search: the first bastard wasn't found, try the next */
fprintf(stderr, "WARNING: No executable found for \"%s\", ",
phrase);
if (fullphrase != phrase)
@@ -222,6 +233,40 @@
}
}
+static int parse_phrase(FILE * stream, const char *fullphrase, int def_path_no)
+{
+ const char* phrases[100];
+ char* tmp;
+ int i = 0;
+
+ phrases[0] = fullphrase;
+
+ while ( (tmp = strchr(phrases[i], ':')) )
+ {
+ *tmp = '\0';
+ phrases[++i] = tmp + 1;
+ if (i == 98)
+ break;
+ /* we may do this cause fullphrase is on the stack of
+ * print line, and not needed aftwerwards.
+ * but it's an ugly hack, better would be strdup.
+ */
+ }
+ phrases[i + 1] = NULL;
+
+ if (def_path_no == 0)
+ {
+ for (i = 0; phrases[i]; i++)
+ {
+ if (parse_phrase_no_colon(stream, phrases[i], -1) == 0)
+ return 0; /* found it */
+ }
+ /*xxx*/
+ /* here = bad: all executables have not been found ! */
+ }
+ return parse_phrase_no_colon(stream, phrases[0], def_path_no);
+}
+
static int print_line(FILE * stream, const char *buf, int def_path_no)
{
const char *tmp;
More information about the Initng-svn
mailing list