root/opal/mca/pmix/pmix4x/pmix/src/util/basename.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


   1 /*
   2  * Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
   3  *                         University Research and Technology
   4  *                         Corporation.  All rights reserved.
   5  * Copyright (c) 2004-2005 The University of Tennessee and The University
   6  *                         of Tennessee Research Foundation.  All rights
   7  *                         reserved.
   8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
   9  *                         University of Stuttgart.  All rights reserved.
  10  * Copyright (c) 2004-2005 The Regents of the University of California.
  11  *                         All rights reserved.
  12  * Copyright (c) 2015-2017 Intel, Inc. All rights reserved.
  13  * $COPYRIGHT$
  14  *
  15  * Additional copyrights may follow
  16  *
  17  * $HEADER$
  18  */
  19 
  20 /**
  21  * @file
  22  *
  23  * Returns an OS-independant basename() of a given filename.
  24  */
  25 
  26 #ifndef PMIX_BASENAME_H
  27 #define PMIX_BASENAME_H
  28 
  29 #include <src/include/pmix_config.h>
  30 #include <pmix_common.h>
  31 
  32 BEGIN_C_DECLS
  33 
  34 /**
  35  * Return the basename of a filename.
  36  *
  37  * @param filename The filename to examine
  38  *
  39  * @returns A string containing the basename, or NULL if there is an error
  40  *
  41  * The contents of the \em filename parameter are unchanged.  This
  42  * function returns a new string containing the basename of the
  43  * filename (which must be eventually freed by the caller), or
  44  * NULL if there is an error.  Trailing "/" characters in the
  45  * filename do not count, unless it is in the only part of the
  46  * filename (e.g., "/" or "C:\").
  47  *
  48  * This function will do the Right Things on POSIX and
  49  * Windows-based operating systems.  For example:
  50  *
  51  * foo.txt returns "foo.txt"
  52  *
  53  * /foo/bar/baz returns "baz"
  54  *
  55  * /yow.c returns "yow.c"
  56  *
  57  * / returns "/"
  58  *
  59  * C:\foo\bar\baz returns "baz"
  60  *
  61  * D:foo.txt returns "foo.txt"
  62  *
  63  * E:\yow.c returns "yow.c"
  64  *
  65  * F: returns "F:"
  66  *
  67  * G:\ returns "G:"
  68  *
  69  * The caller is responsible for freeing the returned string.
  70  */
  71 PMIX_EXPORT char *pmix_basename(const char* filename) __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__;
  72 
  73 /**
  74  * Return the dirname of a filename.
  75  *
  76  * @param filename The filename to examine
  77  *
  78  * @returns A string containing the dirname, or NULL if there is an error
  79  *
  80  * The contents of the \em filename parameter are unchanged.  This
  81  * function returns a new string containing the dirname of the
  82  * filename (which must be eventually freed by the caller), or
  83  * NULL if there is an error.  Trailing "/" characters in the
  84  * filename do not count, unless it is in the only part of the
  85  * filename (e.g., "/" or "C:\").
  86  *
  87  * This function will do the Right Things on POSIX and
  88  * Windows-based operating systems.  For example:
  89  *
  90  * foo.txt returns "foo.txt"
  91  *
  92  * /foo/bar/baz returns "/foo/bar"
  93  *
  94  * /yow.c returns "/"
  95  *
  96  * / returns ""
  97  *
  98  * C:\foo\bar\baz returns "C:\foo\bar"
  99  *
 100  * D:foo.txt returns "D:"
 101  *
 102  * E:\yow.c returns "E:"
 103  *
 104  * F: returns ""
 105  *
 106  * G:\ returns ""
 107  *
 108  * The caller is responsible for freeing the returned string.
 109  */
 110 PMIX_EXPORT char *pmix_dirname(const char* filename) __pmix_attribute_malloc__ __pmix_attribute_warn_unused_result__;
 111 
 112 END_C_DECLS
 113 
 114 #endif /* PMIX_BASENAME_H */

/* [<][>][^][v][top][bottom][index][help] */