about summary refs log tree commit diff
path: root/urt/cmd_name.c
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2006-08-19 03:12:28 +0000
commit1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch)
tree64c8c96cf54d8718847339a403e5e67b922e8c3f /urt/cmd_name.c
downloadnetpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz
netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'urt/cmd_name.c')
-rw-r--r--urt/cmd_name.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/urt/cmd_name.c b/urt/cmd_name.c
new file mode 100644
index 00000000..1f8f0edf
--- /dev/null
+++ b/urt/cmd_name.c
@@ -0,0 +1,54 @@
+/*
+ * This software is copyrighted as noted below.  It may be freely copied,
+ * modified, and redistributed, provided that the copyright notice is 
+ * preserved on all copies.
+ * 
+ * There is no warranty or other guarantee of fitness for this software,
+ * it is provided solely "as is".  Bug reports or fixes may be sent
+ * to the author, who may or may not act on them as he desires.
+ *
+ * You may not include this software in a program or other software product
+ * without supplying the source, or without informing the end-user that the 
+ * source is available for no extra charge.
+ *
+ * If you modify this software, you should include a notice giving the
+ * name of the person performing the modification, the date of modification,
+ * and the reason for such modification.
+ */
+/* 
+ * cmd_name.c - Extract command name from argv[0].
+ * 
+ * Author:	Spencer W. Thomas
+ * 		EECS Dept.
+ * 		University of Michigan
+ * Date:	Wed Jun 27 1990
+ * Copyright (c) 1990, University of Michigan
+ */
+
+#include "rle.h"
+static char no_name[] = "(no-name)";
+
+char *
+cmd_name( argv )
+char **argv;
+{
+    register char *cp, *a;
+
+    /* Be paranoid. */
+    if ( !argv || !(a = *argv) )
+	return no_name;
+
+    /* Find end of file name. */
+    for ( cp = a; *cp; cp++ )
+	;
+
+    /* Find last / or beginning of command name. */
+    for ( cp--; *cp != '/' && cp > a; cp-- )
+	;
+    
+    /* If it's a /, skip it. */
+    if ( *cp == '/' )
+	cp++;
+
+    return cp;
+}