From 5b24f41029acf84631ae8a812349856a217ac1f1 Mon Sep 17 00:00:00 2001 From: Kim Woelders Date: Wed, 19 Apr 2006 19:13:46 +0000 Subject: [PATCH] Split up and shuffle around some more. SVN revision: 22236 --- src/E.h | 138 +++--------------------------------------------- src/Makefile.am | 4 ++ src/alert.c | 27 ++++++---- src/alert.h | 33 ++++++++++++ src/config.c | 1 + src/events.c | 1 + src/ewins.h | 3 ++ src/handlers.c | 1 + src/icccm.c | 1 + src/ipc.c | 1 + src/lang.c | 11 ++++ src/lang.h | 49 +++++++++++++++++ src/main.c | 1 + src/mod-misc.c | 16 ++++++ src/session.c | 20 ++----- src/session.h | 48 +++++++++++++++++ src/theme.c | 1 + src/util.h | 104 ++++++++++++++++++++++++++++++++++++ 18 files changed, 305 insertions(+), 155 deletions(-) create mode 100644 src/alert.h create mode 100644 src/lang.h create mode 100644 src/session.h create mode 100644 src/util.h diff --git a/src/E.h b/src/E.h index 10aa2ecd..27062c29 100644 --- a/src/E.h +++ b/src/E.h @@ -27,18 +27,11 @@ #define _GNU_SOURCE #include "config.h" -#define USE_EXT_INIT_WIN 1 +#include "alert.h" +#include "lang.h" +#include "util.h" -#if HAVE_STRDUP -#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */ -#endif -#if HAVE_STRNDUP -#define USE_LIBC_STRNDUP 1 /* Use libc strndup if present */ -#endif -#if HAVE_SETENV -#define USE_LIBC_SETENV 1 /* Use libc setenv if present */ -#endif -#define USE_LIBC_MALLOC 1 /* Use unwrapped libc malloc/realloc/free */ +#define USE_EXT_INIT_WIN 1 #include #include @@ -91,14 +84,6 @@ #include #include -#if HAVE___ATTRIBUTE__ -#define __UNUSED__ __attribute__((unused)) -#define __PRINTF__ __attribute__((__format__(__printf__, 1, 2))) -#else -#define __UNUSED__ -#define __PRINTF__ -#endif - #ifndef HAVE_GETCWD #error "ERROR: Enlightenment needs a system with getcwd() in it's libs." #error "You may have to upgrade your Operating system, Distribution, base" @@ -114,44 +99,6 @@ #define FILEPATH_LEN_MAX 4096 -#ifdef HAVE_SNPRINTF -#define Evsnprintf vsnprintf -#define Esnprintf snprintf -#else /* HAVE_SNPRINTF */ -int Evsnprintf(char *str, size_t count, const char *fmt, - va_list args); - -#ifdef HAVE_STDARG_H -int Esnprintf(char *str, size_t count, const char *fmt, ...); - -#else -int Esnprintf(va_alist); -#endif -#endif /* HAVE_SNPRINTF */ - -/* This is a start to providing internationalization by means */ -/* of gettext */ - -#ifdef HAVE_LOCALE_H -#include -#endif - -#ifdef ENABLE_NLS -# include -# define _(String) gettext(String) -# ifdef gettext_noop -# define N_(String) gettext_noop(String) -# else -# define N_(String) (String) -# endif -#else -# define _(String) (String) -# define N_(String) (String) -# define bindtextdomain(pkg,locale) -# define textdomain(pkg) -# define bind_textdomain_codeset(pkg,enc) -#endif - #ifndef MAX #define MAX(a,b) ((a)>(b)?(a):(b)) #endif @@ -583,12 +530,6 @@ int execApplication(const char *params); void Espawn(int argc, char **argv); void EspawnCmd(const char *cmd); -/* alert.c */ -void Alert(const char *fmt, ...); -void AlertX(const char *title, const char *ignore, - const char *restart, const char *quit, - const char *fmt, ...); - /* arrange.c */ #define ARRANGE_VERBATIM 0 #define ARRANGE_BY_SIZE 1 @@ -806,13 +747,6 @@ int HandleIPC(const char *params, Client * c); int EFunc(EWin * ewin, const char *params); void EFuncDefer(EWin * ewin, const char *params); -/* lang.c */ -void LangInit(void); -char *EstrLoc2Int(const char *str, int len); -char *EstrUtf82Int(const char *str, int len); -const char *EstrInt2Enc(const char *str, int want_utf8); -void EstrInt2EncFree(const char *str, int want_utf8); - /* main.c */ void EExit(int exitcode); const char *EDirRoot(void); @@ -823,48 +757,14 @@ void EDirMake(const char *base, const char *name); const char *EGetSavePrefix(void); const char *EGetSavePrefixCommon(void); -/* memory.c */ -#define Ecalloc calloc -#define Emalloc malloc -#define Efree free -#define Erealloc realloc - -#define _EFREE(p) do { if (p) { Efree(p); p = NULL; } } while (0) -#define _EFDUP(p, s) do { if (p) Efree(p); p = Estrdup(s); } while (0) - -char *Estrtrim(char *s); - -#if USE_LIBC_STRDUP -#define Estrdup(s) ((s) ? strdup(s) : NULL) -#else -char *Estrdup(const char *s); -#endif -#if USE_LIBC_STRNDUP -#define Estrndup(s,n) ((s) ? strndup(s,n) : NULL) -#else -char *Estrndup(const char *s, int n); -#endif -#if USE_LIBC_SETENV -#define Esetenv setenv -#else -int Esetenv(const char *name, const char *value, int overwrite); -#endif -char *Estrdupcat2(char *ss, const char *s1, const char *s2); - -char **StrlistDup(char **lst, int num); -void StrlistFree(char **lst, int num); -char *StrlistJoin(char **lst, int num); -char *StrlistEncodeEscaped(char *buf, int len, char **lst, - int num); -char **StrlistDecodeEscaped(const char *str, int *pnum); -char **StrlistFromString(const char *str, int delim, int *num); - /* misc.c */ void Quicksort(void **a, int l, int r, int (*CompareFunc) (void *d1, void *d2)); void ETimedLoopInit(int k1, int k2, int speed); int ETimedLoopNext(void); -void __PRINTF__ Eprintf(const char *fmt, ...); + +/* mod-misc.c */ +void autosave(void); /* moveresize.c */ int ActionMoveStart(EWin * ewin, int grab, char constrained, @@ -901,30 +801,6 @@ int GetPointerScreenGeometry(int *px, int *py, int GetPointerScreenAvailableArea(int *px, int *py, int *pw, int *ph); -/* session.c */ -#define EEXIT_EXIT 0 -#define EEXIT_ERROR 1 -#define EEXIT_LOGOUT 2 -#define EEXIT_RESTART 3 -#define EEXIT_THEME 4 -#define EEXIT_EXEC 5 - -#define ESESSION_INIT 0 -#define ESESSION_START 1 -#define ESESSION_STOP 2 - -void SessionInit(void); -void SessionSave(int shutdown); -void SessionExit(int mode, const char *params); -void SessionHelper(int when); -void ProcessICEMSGS(void); -int GetSMfd(void); -void SessionGetInfo(EWin * ewin, Atom atom_change); -void SetSMID(const char *smid); -void MatchEwinToSM(EWin * ewin); -void autosave(void); -void SettingsSession(void); - /* settings.c */ void SettingsMoveResize(void); void SettingsPlacement(void); diff --git a/src/Makefile.am b/src/Makefile.am index 61f1e0d2..ab3a04f0 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -19,6 +19,7 @@ e16_SOURCES = \ aclass.h \ actions.c \ alert.c \ + alert.h \ arrange.c \ backgrounds.c \ backgrounds.h \ @@ -80,6 +81,7 @@ e16_SOURCES = \ icons.h \ ipc.c \ lang.c \ + lang.h \ main.c \ memory.c \ menus.c \ @@ -95,6 +97,7 @@ e16_SOURCES = \ regex.c \ screen.c \ session.c \ + session.h \ settings.c \ setup.c \ size.c \ @@ -112,6 +115,7 @@ e16_SOURCES = \ timers.h \ tooltips.c \ tooltips.h \ + util.h \ ttfont.c \ warp.c \ windowmatch.c \ diff --git a/src/alert.c b/src/alert.c index 90135b3f..cd97c90e 100644 --- a/src/alert.c +++ b/src/alert.c @@ -21,7 +21,19 @@ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include "E.h" +#include +#include +#include +#include +#include +#include +#include "alert.h" +#include "lang.h" +#include "session.h" +#include "util.h" + +/* Should be elsewhere */ +void SoundPlay(const char *name); #define ExTextExtents XmbTextExtents #define ExDrawString XmbDrawString @@ -173,6 +185,8 @@ ShowAlert(const char *title, XFontStruct **font_struct_list_return; char **font_name_list_return; + SoundPlay("SOUND_ALERT"); + if (!text) return; @@ -509,17 +523,14 @@ ShowAlert(const char *title, switch (button) { + default: case 1: break; case 2: - if (getpid() == Mode.wm.pid) - SessionExit(EEXIT_RESTART, NULL); + SessionExit(EEXIT_RESTART, NULL); break; case 3: - if (getpid() == Mode.wm.pid) - SessionExit(EEXIT_EXIT, NULL); - break; - default: + SessionExit(EEXIT_EXIT, NULL); break; } @@ -543,7 +554,6 @@ AlertX(const char *title, const char *ignore, Evsnprintf(text, sizeof(text), fmt, args); va_end(args); - SoundPlay("SOUND_ALERT"); ShowAlert(title, ignore, restart, quit, text); } @@ -557,7 +567,6 @@ Alert(const char *fmt, ...) Evsnprintf(text, sizeof(text), fmt, args); va_end(args); - SoundPlay("SOUND_ALERT"); ShowAlert(_("Enlightenment Message Dialog"), _("Ignore this"), _("Restart Enlightenment"), _("Quit Enlightenment"), text); } diff --git a/src/alert.h b/src/alert.h new file mode 100644 index 00000000..84a6e726 --- /dev/null +++ b/src/alert.h @@ -0,0 +1,33 @@ +/* + * Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2006 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _ALERT_H_ +#define _ALERT_H_ + +/* alert.c */ +void Alert(const char *fmt, ...); +void AlertX(const char *title, const char *ignore, + const char *restart, const char *quit, + const char *fmt, ...); + +#endif /* _ALERT_H_ */ diff --git a/src/config.c b/src/config.c index 3757b904..391fbd3d 100644 --- a/src/config.c +++ b/src/config.c @@ -29,6 +29,7 @@ #include "conf.h" #include "iclass.h" #include "menus.h" +#include "session.h" #include "tclass.h" #include "tooltips.h" diff --git a/src/events.c b/src/events.c index d946a333..31ddd1d0 100644 --- a/src/events.c +++ b/src/events.c @@ -24,6 +24,7 @@ #include "E.h" #include "aclass.h" #include "emodule.h" +#include "session.h" #include "timers.h" #include "xwin.h" #include diff --git a/src/ewins.h b/src/ewins.h index c54949e6..25d579bf 100644 --- a/src/ewins.h +++ b/src/ewins.h @@ -392,6 +392,9 @@ EWin *EwinFindByString(const char *win, int type); EWin **EwinListTransients(const EWin * ewin, int *num, int group); EWin **EwinListTransientFor(const EWin * ewin, int *num); +/* session.c */ +void SessionGetInfo(EWin * ewin, Atom atom_change); + /* size.c */ void MaxSize(EWin * ewin, const char *resize_type); void MaxWidth(EWin * ewin, const char *resize_type); diff --git a/src/handlers.c b/src/handlers.c index 31e846a3..58fc05ce 100644 --- a/src/handlers.c +++ b/src/handlers.c @@ -22,6 +22,7 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "session.h" #include "xwin.h" #include #include diff --git a/src/icccm.c b/src/icccm.c index 9029ddf9..6eabfbc5 100644 --- a/src/icccm.c +++ b/src/icccm.c @@ -26,6 +26,7 @@ #include "e16-ecore_hints.h" #include "ewins.h" #include "hints.h" +#include "session.h" #include "xwin.h" #if USE_XSYNC #include diff --git a/src/ipc.c b/src/ipc.c index 953cd078..c80fc349 100644 --- a/src/ipc.c +++ b/src/ipc.c @@ -30,6 +30,7 @@ #include "ewins.h" #include "ewin-ops.h" #include "hints.h" /* FIXME - Should not be here */ +#include "session.h" #include "snaps.h" #include "timers.h" #include "xwin.h" diff --git a/src/lang.c b/src/lang.c index 36226e88..1c2f351c 100644 --- a/src/lang.c +++ b/src/lang.c @@ -22,11 +22,22 @@ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include "E.h" +#include "lang.h" + +#ifdef HAVE_LOCALE_H +#include +#endif #if HAVE_LANGINFO_CODESET #include #endif +#ifndef ENABLE_NLS +#define bindtextdomain(pkg,locale) +#define textdomain(pkg) +#define bind_textdomain_codeset(pkg,enc) +#endif + #if HAVE_ICONV #include diff --git a/src/lang.h b/src/lang.h new file mode 100644 index 00000000..c2da7731 --- /dev/null +++ b/src/lang.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2006 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _LANG_H_ +#define _LANG_H_ + +#include "config.h" + +#ifdef ENABLE_NLS +# include +# define _(String) gettext(String) +# ifdef gettext_noop +# define N_(String) gettext_noop(String) +# else +# define N_(String) (String) +# endif +#else +# define _(String) (String) +# define N_(String) (String) +#endif + +/* lang.c */ +void LangInit(void); +char *EstrLoc2Int(const char *str, int len); +char *EstrUtf82Int(const char *str, int len); +const char *EstrInt2Enc(const char *str, int want_utf8); +void EstrInt2EncFree(const char *str, int want_utf8); + +#endif /* _LANG_H_ */ diff --git a/src/main.c b/src/main.c index 44490800..9138eaa3 100644 --- a/src/main.c +++ b/src/main.c @@ -26,6 +26,7 @@ #include "dialog.h" #include "emodule.h" #include "hints.h" +#include "session.h" #include "snaps.h" #include "timestamp.h" #include "xwin.h" diff --git a/src/mod-misc.c b/src/mod-misc.c index 0f05f194..dc005c99 100644 --- a/src/mod-misc.c +++ b/src/mod-misc.c @@ -22,6 +22,7 @@ */ #include "E.h" #include "emodule.h" +#include "session.h" #include "snaps.h" /*********************************************************************** @@ -233,3 +234,18 @@ EModule ModMisc = { , {N_CFG_ITEMS, MiscCfgItems} }; + +void +autosave(void) +{ + if (!Mode.wm.save_ok) + return; + + if (EventDebug(EDBUG_TYPE_SESSION)) + Eprintf("autosave\n"); + + Real_SaveSnapInfo(0, NULL); + + /* Save the configuration parameters */ + ConfigurationSave(); +} diff --git a/src/session.c b/src/session.c index ac490fdd..03491bec 100644 --- a/src/session.c +++ b/src/session.c @@ -26,6 +26,7 @@ #include "e16-ecore_hints.h" #include "emodule.h" #include "ewins.h" +#include "session.h" #include "snaps.h" #include "xwin.h" #include @@ -55,21 +56,6 @@ static int sm_fd = -1; /* True if we are saving state for a doExit("restart") */ static int restarting = False; -void -autosave(void) -{ - if (!Mode.wm.save_ok) - return; - - if (EventDebug(EDBUG_TYPE_SESSION)) - Eprintf("autosave\n"); - - Real_SaveSnapInfo(0, NULL); - - /* Save the configuration parameters */ - ConfigurationSave(); -} - #ifdef HAVE_X11_SM_SMLIB_H #include @@ -680,6 +666,10 @@ SessionLogoutConfirm(void) void SessionExit(int mode, const char *param) { + /* We do not want to be exited by children. */ + if (getpid() != Mode.wm.pid) + return; + if (mode == EEXIT_LOGOUT) { if (Conf.session.enable_logout_dialog) diff --git a/src/session.h b/src/session.h new file mode 100644 index 00000000..d7288e4b --- /dev/null +++ b/src/session.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2006 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _SESSION_H_ +#define _SESSION_H_ + +/* session.c */ +#define EEXIT_EXIT 0 +#define EEXIT_ERROR 1 +#define EEXIT_LOGOUT 2 +#define EEXIT_RESTART 3 +#define EEXIT_THEME 4 +#define EEXIT_EXEC 5 + +#define ESESSION_INIT 0 +#define ESESSION_START 1 +#define ESESSION_STOP 2 + +void SessionInit(void); +void SessionSave(int shutdown); +void SessionExit(int mode, const char *params); +void SessionHelper(int when); +void ProcessICEMSGS(void); +int GetSMfd(void); +void SetSMID(const char *smid); +void SettingsSession(void); + +#endif /* _SESSION_H_ */ diff --git a/src/theme.c b/src/theme.c index dc96d043..3ecaa8e9 100644 --- a/src/theme.c +++ b/src/theme.c @@ -23,6 +23,7 @@ */ #include "E.h" #include "emodule.h" +#include "session.h" #define ENABLE_THEME_SANITY_CHECKING 0 diff --git a/src/util.h b/src/util.h new file mode 100644 index 00000000..f4e2dd83 --- /dev/null +++ b/src/util.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2000-2006 Carsten Haitzler, Geoff Harrison and various contributors + * Copyright (C) 2004-2006 Kim Woelders + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies of the Software, its documentation and marketing & publicity + * materials, and acknowledgment shall be given in the documentation, materials + * and software packages that this Software was used. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +#ifndef _UTIL_H_ +#define _UTIL_H_ + +#include "config.h" + +#if HAVE___ATTRIBUTE__ +#define __UNUSED__ __attribute__((unused)) +#define __PRINTF__ __attribute__((__format__(__printf__, 1, 2))) +#else +#define __UNUSED__ +#define __PRINTF__ +#endif + +#if HAVE_STRDUP +#define USE_LIBC_STRDUP 1 /* Use libc strdup if present */ +#endif +#if HAVE_STRNDUP +#define USE_LIBC_STRNDUP 1 /* Use libc strndup if present */ +#endif +#if HAVE_SETENV +#define USE_LIBC_SETENV 1 /* Use libc setenv if present */ +#endif + +/* memory.c */ +#define Ecalloc calloc +#define Emalloc malloc +#define Efree free +#define Erealloc realloc + +#define _EFREE(p) do { if (p) { Efree(p); p = NULL; } } while (0) +#define _EFDUP(p, s) do { if (p) Efree(p); p = Estrdup(s); } while (0) + +char *Estrtrim(char *s); + +#if USE_LIBC_STRDUP +#define Estrdup(s) ((s) ? strdup(s) : NULL) +#else +char *Estrdup(const char *s); +#endif + +#if USE_LIBC_STRNDUP +#define Estrndup(s,n) ((s) ? strndup(s,n) : NULL) +#else +char *Estrndup(const char *s, int n); +#endif + +char *Estrdupcat2(char *ss, const char *s1, const char *s2); + +#if USE_LIBC_SETENV +#define Esetenv setenv +#else +int Esetenv(const char *name, const char *value, int overwrite); +#endif + +char **StrlistDup(char **lst, int num); +void StrlistFree(char **lst, int num); +char *StrlistJoin(char **lst, int num); +char *StrlistEncodeEscaped(char *buf, int len, char **lst, + int num); +char **StrlistDecodeEscaped(const char *str, int *pnum); +char **StrlistFromString(const char *str, int delim, int *num); + +/* misc.c */ +void __PRINTF__ Eprintf(const char *fmt, ...); + +#ifdef HAVE_SNPRINTF +#define Evsnprintf vsnprintf +#define Esnprintf snprintf +#else /* HAVE_SNPRINTF */ +int Evsnprintf(char *str, size_t count, const char *fmt, + va_list args); + +#ifdef HAVE_STDARG_H +int Esnprintf(char *str, size_t count, const char *fmt, ...); + +#else +int Esnprintf(va_alist); +#endif +#endif /* HAVE_SNPRINTF */ + +#endif /* _UTIL_H_ */