Main Page | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Related Pages

os_rpath.c

00001 /*-
00002  * See the file LICENSE for redistribution information.
00003  *
00004  * Copyright (c) 1997-2005
00005  *      Sleepycat Software.  All rights reserved.
00006  *
00007  * $Id: os_rpath.c,v 12.1 2005/06/16 20:23:26 bostic Exp $
00008  */
00009 
00010 #include "db_config.h"
00011 
00012 #ifndef NO_SYSTEM_INCLUDES
00013 #include <string.h>
00014 #endif
00015 
00016 #include "db_int.h"
00017 #ifdef HAVE_VXWORKS
00018 #include "iosLib.h"
00019 #endif
00020 
00021 /*
00022  * __db_rpath --
00023  *      Return the last path separator in the path or NULL if none found.
00024  *
00025  * PUBLIC: char *__db_rpath __P((const char *));
00026  */
00027 char *
00028 __db_rpath(path)
00029         const char *path;
00030 {
00031         const char *s, *last;
00032 #ifdef HAVE_VXWORKS
00033         DEV_HDR *dummy;
00034         char *ptail;
00035 
00036         /*
00037          * VxWorks devices can be rooted at any name.  We want to
00038          * skip over the device name and not take into account any
00039          * PATH_SEPARATOR characters that might be in that name.
00040          *
00041          * XXX [#2393]
00042          * VxWorks supports having a filename directly follow a device
00043          * name with no separator.  I.e. to access a file 'xxx' in
00044          * the top level directory of a device mounted at "mydrive"
00045          * you could say "mydrivexxx" or "mydrive/xxx" or "mydrive\xxx".
00046          * We do not support the first usage here.
00047          * XXX
00048          */
00049         if ((dummy = iosDevFind((char *)path, &ptail)) == NULL)
00050                 s = path;
00051         else
00052                 s = ptail;
00053 #else
00054         s = path;
00055 #endif
00056 
00057         last = NULL;
00058         if (PATH_SEPARATOR[1] != '\0') {
00059                 for (; s[0] != '\0'; ++s)
00060                         if (strchr(PATH_SEPARATOR, s[0]) != NULL)
00061                                 last = s;
00062         } else
00063                 for (; s[0] != '\0'; ++s)
00064                         if (s[0] == PATH_SEPARATOR[0])
00065                                 last = s;
00066         return ((char *)last);
00067 }

Generated on Sun Dec 25 12:14:42 2005 for Berkeley DB 4.4.16 by  doxygen 1.4.2