Back to index

tetex-bin  3.0
Defines | Functions
access.c File Reference
#include <curses.priv.h>
#include <tic.h>
#include <nc_alloc.h>

Go to the source code of this file.

Defines

#define LOWERCASE(c)   ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))

Functions

 _nc_rootname (char *path)
 _nc_pathlast (const char *path)
 _nc_basename (char *path)
 _nc_access (const char *path, int mode)
 _nc_env_access (void)

Define Documentation

#define LOWERCASE (   c)    ((isalpha(UChar(c)) && isupper(UChar(c))) ? tolower(UChar(c)) : (c))

Definition at line 39 of file access.c.


Function Documentation

_nc_access ( const char *  path,
int  mode 
)

Definition at line 92 of file access.c.

{
    if (access(path, mode) < 0) {
       if ((mode & W_OK) != 0
           && errno == ENOENT
           && strlen(path) < PATH_MAX) {
           char head[PATH_MAX];
           char *leaf = _nc_basename(strcpy(head, path));

           if (leaf == 0)
              leaf = head;
           *leaf = '\0';
           if (head == leaf)
              (void) strcpy(head, ".");

           return access(head, R_OK | W_OK | X_OK);
       }
       return -1;
    }
    return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_basename ( char *  path)

Definition at line 86 of file access.c.

{
    return path + _nc_pathlast(path);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 120 of file access.c.

{
#if HAVE_ISSETUGID
    if (issetugid())
       return FALSE;
#elif HAVE_GETEUID && HAVE_GETEGID
    if (getuid() != geteuid()
       || getgid() != getegid())
       return FALSE;
#endif
    return getuid() != 0 && geteuid() != 0;      /* ...finally, disallow root */
}
_nc_pathlast ( const char *  path)

Definition at line 71 of file access.c.

{
    const char *test = strrchr(path, '/');
#ifdef __EMX__
    if (test == 0)
       test = strrchr(path, '\\');
#endif
    if (test == 0)
       test = path;
    else
       test++;
    return (test - path);
}

Here is the call graph for this function:

Here is the caller graph for this function:

_nc_rootname ( char *  path)

Definition at line 42 of file access.c.

{
    char *result = _nc_basename(path);
#if !defined(MIXEDCASE_FILENAMES) || defined(PROG_EXT)
    static char *temp;
    char *s;

    temp = strdup(result);
    result = temp;
#if !defined(MIXEDCASE_FILENAMES)
    int n;
    for (s = result; *s != '\0'; ++s) {
       *s = LOWERCASE(*s);
    }
#endif
#if defined(PROG_EXT)
    if ((s = strrchr(result, '.')) != 0) {
       if (!strcmp(s, PROG_EXT))
           *s = '\0';
    }
#endif
#endif
    return result;
}

Here is the call graph for this function: