Function to compute a simple case of base name.
authorPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 27 Oct 2002 18:05:03 +0000 (18:05 +0000)
committerPeter Verthez <Peter.Verthez@advalvas.be>
Sun, 27 Oct 2002 18:05:03 +0000 (18:05 +0000)
t/src/portability.c
t/src/portability.h

index e44f7c36702637571440445f83235157490038c2..d7245959b4431d699848b21ff0058b04fee74a00 100644 (file)
@@ -21,6 +21,7 @@
 /* $Id$ */
 /* $Name$ */
 
+#include <string.h>
 #include "config.h"
 
 char* null_str = "(null)";
@@ -72,3 +73,13 @@ void* int_to_void_ptr(int i)
   t = i;
   return (void*)t;
 }
+
+char* simple_base_name(char* filename)
+{
+  char* runner = NULL;
+  if (filename) {
+    runner = filename + strlen(filename) - 1;
+    while (runner != filename && *(runner-1) != '/') runner--;
+  }
+  return runner;
+}
index 0aa2bb9e4e9fd996888a991e9efe9b631ac5e793..89099a0711a21e6032af3f1968afbea608a6fdd6 100644 (file)
@@ -28,5 +28,6 @@ long int void_ptr_to_int(void* ptr);
 void*    int_to_void_ptr(int t);
 char*    str_val(char* input);
 char*    ptr_val(void* ptr);
+char*    simple_base_name(char* filename);
 
 #endif /* __PORTABILITY_H */