changeset 4:72f0096b0e42

alternate command names
author Simon Horman <horms@verge.net.au>
date Tue, 14 May 2002 09:53:09 +0900
parents b9cfe75b8b91
children 7964a2a26d75
files pbs/Makefile.am pbs/Makefile.in pbs/pbs_option.c
diffstat 3 files changed, 78 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/pbs/Makefile.am	Mon May 13 17:11:52 2002 +0900
+++ b/pbs/Makefile.am	Tue May 14 09:53:09 2002 +0900
@@ -40,3 +40,15 @@
 
 LDADD = -ldb -lpopt \
 -lvanessa_logger -lvanessa_socket @dmalloc_lib@
+
+install-exec-hook:
+	for i in deamon list insert remove setenv purge; do \
+                (cd $(DESTDIR)$(sbindir) && rm -f perdition-pbs-$$i && \
+                        ln -sf perdition-pbs perdition-pbs-$$i); \
+        done
+
+uninstall-local:
+	for i in deamon list insert remove setenv purge; do \
+                rm -f $(DESTDIR)$(sbindir)/perditioni-pbs-$$i; \
+        done
+
--- a/pbs/Makefile.in	Mon May 13 17:11:52 2002 +0900
+++ b/pbs/Makefile.in	Tue May 14 09:53:09 2002 +0900
@@ -281,6 +281,8 @@
 installcheck-am:
 installcheck: installcheck-am
 install-exec-am: install-sbinPROGRAMS
+	@$(NORMAL_INSTALL)
+	$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
 install-exec: install-exec-am
 
 install-data-am:
@@ -289,7 +291,7 @@
 install-am: all-am
 	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
 install: install-am
-uninstall-am: uninstall-sbinPROGRAMS
+uninstall-am: uninstall-sbinPROGRAMS uninstall-local
 uninstall: uninstall-am
 all-am: Makefile $(PROGRAMS)
 all-redirect: all-am
@@ -340,12 +342,23 @@
 mostlyclean-depend distclean-depend clean-depend \
 maintainer-clean-depend info-am info dvi-am dvi check check-am \
 installcheck-am installcheck install-exec-am install-exec \
-install-data-am install-data install-am install uninstall-am uninstall \
-all-redirect all-am all installdirs mostlyclean-generic \
-distclean-generic clean-generic maintainer-clean-generic clean \
-mostlyclean distclean maintainer-clean
+install-data-am install-data install-am install uninstall-local \
+uninstall-am uninstall all-redirect all-am all installdirs \
+mostlyclean-generic distclean-generic clean-generic \
+maintainer-clean-generic clean mostlyclean distclean maintainer-clean
 
 
+install-exec-hook:
+	for i in deamon list insert remove setenv purge; do \
+                (cd $(DESTDIR)$(sbindir) && rm -f perdition-pbs-$$i && \
+                        ln -sf perdition-pbs perdition-pbs-$$i); \
+        done
+
+uninstall-local:
+	for i in deamon list insert remove setenv purge; do \
+                rm -f $(DESTDIR)$(sbindir)/perditioni-pbs-$$i; \
+        done
+
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.
 .NOEXPORT:
--- a/pbs/pbs_option.c	Mon May 13 17:11:52 2002 +0900
+++ b/pbs/pbs_option.c	Tue May 14 09:53:09 2002 +0900
@@ -51,10 +51,35 @@
 #define STR_NULL_SAFE(string) (string==NULL)?STR_NULL:string
 #define BIN_OPT_STR(opt) ((opt)?"on":"off")
 
+
+/**********************************************************************
+ * str_basename
+ * Find the filename of a fully qualified path to a file
+ * pre: filename: name of file to find basename of
+ * post: basename of filename is returned
+ * return: NULL if filename is NULL
+ *         pointer within filename pointing to basename of filename
+ *
+ * Not 8 bit clean
+ **********************************************************************/
+
+const char *str_basename(const char *filename){
+    char *result;
+
+    if(filename==NULL){
+      return(NULL);
+    }
+    
+    result=strrchr(filename, '/');
+
+    return((result==NULL)?filename:result+1);
+}
+
 pbs_options_t *pbs_options_parse(int argc, char **argv) {
 	char c;
 	pbs_options_t *opt;
 	poptContext context;
+	const char *basename;
 
 	static struct poptOption options[] =
 	{
@@ -89,12 +114,33 @@
 	opt->timeout = PBS_DEFAULT_TIMEOUT;
 	opt->prefix = PBS_DEFAULT_PREFIX;
 	opt->log_level = PBS_DEFAULT_LOG_LEVEL;
-	opt->mode = PBS_DEFAULT_MODE;
 	opt->user = PBS_DEFAULT_USERNAME;
 	opt->group = PBS_DEFAULT_GROUP;
+	opt->mode = PBS_DEFAULT_MODE;
 
   	if(argc==0 || argv==NULL) return(opt);
 
+	basename = str_basename(argv[0]);
+
+	if(strcmp("perdition-pbs-setenv", basename) == 0) {
+		opt->mode = PBS_MODE_SETENV;
+	}
+	else if(strcmp("perdition-pbs-list", basename) == 0) {
+		opt->mode = PBS_MODE_LIST;
+	}
+	else if(strcmp("perdition-pbs-insert", basename) == 0) {
+		opt->mode = PBS_MODE_INSERT;
+	}
+	else if(strcmp("perdition-pbs-remove", basename) == 0) {
+		opt->mode = PBS_MODE_REMOVE;
+	}
+	else if(strcmp("perdition-pbs-setenv", basename) == 0) {
+		opt->mode = PBS_MODE_REMOVE;
+	}
+	else if(strcmp("perdition-pbs-purge", basename) == 0) {
+		opt->mode = PBS_MODE_PURGE;
+	}
+	
   	context = poptGetContext(LOG_IDENT, argc, (const char **)argv, 
 			options, 0);
 
@@ -225,8 +271,7 @@
         "    -u, --user: USERNAME User to run as\n"
 	"                         (default \"%s\")\n"
 	"\n"
-	"Notes: Default for binary flags is off\n"
-	"       Keys are not used in \"daemon\" or \"purge\" mode.\n",
+	"Notes: Default for binary flags is off\n",
 	STR_NULL_SAFE(pbs_mode_str(PBS_DEFAULT_MODE)),
 	STR_NULL_SAFE(PBS_DEFAULT_DB_FILENAME),
 	STR_NULL_SAFE(PBS_DEFAULT_GROUP),