diff options
Diffstat (limited to 'src/xine-utils')
-rw-r--r-- | src/xine-utils/utils.c | 76 | ||||
-rw-r--r-- | src/xine-utils/xineutils.h | 109 |
2 files changed, 12 insertions, 173 deletions
diff --git a/src/xine-utils/utils.c b/src/xine-utils/utils.c index 51ed0beb3..fff4f028d 100644 --- a/src/xine-utils/utils.c +++ b/src/xine-utils/utils.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: utils.c,v 1.33 2004/09/12 19:23:36 mroi Exp $ + * $Id: utils.c,v 1.34 2004/09/20 19:30:05 valtri Exp $ * */ #define _POSIX_PTHREAD_SEMANTICS 1 /* for 5-arg getpwuid_r on solaris */ @@ -31,7 +31,7 @@ #include <errno.h> #include <pwd.h> -#include <netdb.h> +#include <time.h> #include <unistd.h> #if HAVE_EXECINFO_H @@ -46,11 +46,7 @@ #include <langinfo.h> #endif -#if HAVE_LIBGEN_H -#include <libgen.h> -#endif - -#ifdef __CYGWIN__ +#if defined(__CYGWIN__) || defined(WIN32) #include <windows.h> #endif @@ -418,7 +414,11 @@ void xine_usec_sleep(unsigned usec) { ts.tv_nsec = (usec % 1000000) * 1000; nanosleep(&ts, NULL); #else +# if WIN32 + Sleep(usec / 1000); +# else usleep(usec); +# endif #endif } @@ -554,65 +554,3 @@ const char *xine_guess_spu_encoding(void) { return "iso-8859-1"; } - - -#ifndef HAVE_BASENAME -#define FILESYSTEM_PREFIX_LEN(filename) 0 -#define ISSLASH(C) ((C) == '/') -#endif - -/* - * get base name - * - * (adopted from sh-utils) - */ -char *xine_basename (char *name) { -#ifndef HAVE_BASENAME - char const *base = name + FILESYSTEM_PREFIX_LEN (name); - char const *p; - - for (p = base; *p; p++) - { - if (ISSLASH (*p)) - { - /* Treat multiple adjacent slashes like a single slash. */ - do p++; - while (ISSLASH (*p)); - - /* If the file name ends in slash, use the trailing slash as - the basename if no non-slashes have been found. */ - if (! *p) - { - if (ISSLASH (*base)) - base = p - 1; - break; - } - - /* *P is a non-slash preceded by a slash. */ - base = p; - } - } - - return (char *) base; -#else - return basename(name); -#endif -} - -/** - * get error descriptions in DNS lookups - */ -const char *xine_hstrerror(int err) { -#ifndef HAVE_HSTRERROR - switch (err) { - case 0: return _("No error"); - case HOST_NOT_FOUND: return _("Unknown host"); - case NO_DATA: return _("No address associated with name"); - case NO_RECOVERY: return _("Unknown server error"); - case TRY_AGAIN: return _("Host name lookup failure"); - default: return _("Unknown error"); - } -#else - return hstrerror(err); -#endif -} diff --git a/src/xine-utils/xineutils.h b/src/xine-utils/xineutils.h index 6f5fecdf8..6a4be56bf 100644 --- a/src/xine-utils/xineutils.h +++ b/src/xine-utils/xineutils.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: xineutils.h,v 1.92 2004/09/06 18:34:39 valtri Exp $ + * $Id: xineutils.h,v 1.93 2004/09/20 19:30:05 valtri Exp $ * */ #ifndef XINEUTILS_H @@ -577,27 +577,6 @@ typedef union { #endif /*ARCH_X86 */ -#ifndef HAVE_LSTAT -# define lstat(FILENAME, BUF) stat((FILENAME), (BUF)) -#endif - - -#ifdef _MSC_VER -# define snprintf _snprintf -# define vsnprintf _vsnprintf -#endif - - -#ifdef WIN32 -# ifndef strcasecmp -# define strcasecmp _stricmp -# endif -# ifndef strncasecmp -# define strncasecmp _strnicmp -# endif -#endif - - /* Optimized/fast memcpy */ /* @@ -679,78 +658,10 @@ void xine_strdupa(char *dest, char *src); } \ } while(0) -/* Shamefully copied from glibc 2.2.3 */ -#ifdef HAVE_STRPBRK -#define xine_strpbrk strpbrk -#else -static inline char *_private_strpbrk(const char *s, const char *accept) { - - while(*s != '\0') { - const char *a = accept; - while(*a != '\0') - if(*a++ == *s) - return(char *) s; - ++s; - } - - return NULL; -} -#define xine_strpbrk _private_strpbrk -#endif - -#if defined HAVE_STRSEP && !defined(_MSC_VER) -#define xine_strsep strsep -#else -static inline char *_private_strsep(char **stringp, const char *delim) { - char *begin, *end; - - begin = *stringp; - if(begin == NULL) - return NULL; - - if(delim[0] == '\0' || delim[1] == '\0') { - char ch = delim[0]; - - if(ch == '\0') - end = NULL; - else { - if(*begin == ch) - end = begin; - else if(*begin == '\0') - end = NULL; - else - end = strchr(begin + 1, ch); - } - } - else - end = xine_strpbrk(begin, delim); - - if(end) { - *end++ = '\0'; - *stringp = end; - } - else - *stringp = NULL; - - return begin; -} -#define xine_strsep _private_strsep -#endif - - -#ifdef HAVE_SETENV -#define xine_setenv setenv -#else -static inline void _private_setenv(const char *name, const char *val, int _xx) { - int len = strlen(name) + strlen(val) + 2; - char *env = (char *)malloc(len); - - sprintf(env, "%s%c%s", name, '=', val); - putenv(env); - /*free(env); The string passed to putenv must not be freed*/ -} -#define xine_setenv _private_setenv -#endif +/* compatibility macros */ +#define xine_strpbrk(S, ACCEPT) strpbrk((S), (ACCEPT)) +#define xine_strsep(STRINGP, DELIM) strsep((STRINGP), (DELIM)) +#define xine_setenv(NAME, VAL, XX) setenv((NAME), (VAL), (XX)) /* * Color Conversion Utility Functions @@ -1118,16 +1029,6 @@ char *xine_get_system_encoding(void); */ const char *xine_guess_spu_encoding(void); -/** - * get base name - */ -char *xine_basename (char *name); - -/** - * get error descriptions in DNS lookups - */ -const char *xine_hstrerror(int err); - #if defined(__CYGWIN__) || defined(WIN32) char *exec_path_append_subdir(char * string); #endif |