/* * abspath.h - 1.0 * Copyright (C) 2000 Earnie Boyd and assigns * GNU General Public License (GPL) Version 2 or later. * This code may also be used with the GNU LGPL Version 2.0 or later to create * a shared object library or a dynamically loadable library and that library * is also goverened by the GNU Lesser General Public License (LGPL). * * These macros were created in the hopes that portability between DOS/WIN32 * filesystems and UNIX filesystems may be coded more easily. * * Example 1: * char **pp; * for (pp = path; *pp; pp++) * if (ISABSPATH(*&pp[0]) * { * ... * } * * Example 2: * char * * somefunction(char *dir) * { * ... * if (ISABSPATH(dir)) * { * ... * } * ... * } * * Send bug reports to: * */ #ifndef __WIN32__ # define ISDIRDELIM(s) ((s) == '/') #else # define ISDIRDELIM(s) (((s) == '/' || (s) == '\\')) #endif #define ISDIRCURNT(p) (((p)[0] == '.' && (ISDIRDELIM((p)[1]) || !(p)[1]))) #define ISDIRPARNT(p) (((p)[0] == '.' && (p)[1] == '.' && \ (ISDIRDELIM((p)[2]) || !(p)[2]))) #ifndef __WIN32__ # define ISABSPATH(p) (ISDIRDELIM((p)[0]) || ISDIRCURNT((p)) || ISDIRPARNT((p))) #else # define ISABSPATH(p) (ISDIRDELIM((p)[0]) || \ (isalpha((p)[0]) && (p)[1] == ':' && \ (ISDIRDELIM((p)[2]))) || \ (ISDIRCURNT((p)) || ISDIRPARNT((p)))) #endif