summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaja R Harinath <harinath@src.gnome.org>1998-04-12 21:07:55 +0000
committerRaja R Harinath <harinath@src.gnome.org>1998-04-12 21:07:55 +0000
commit41085eb1a0a8772f982d2fb9f2adcf75baec8d13 (patch)
tree95e748f18b65118d88ff6c3a0f9e1f81af1ae157
parenta7770e415ad2ae3028d31afd6956e360f2b10c58 (diff)
downloadgnome-common-41085eb1a0a8772f982d2fb9f2adcf75baec8d13.tar.gz
Is now $(pkglibdir)/include. `gnomesupport.h' is a generated file
* Makefile.am (supportincludedir): Is now $(pkglibdir)/include. `gnomesupport.h' is a generated file dependent on the configure process. So, this seems a good place. The rest of the headers are also here just because I'm too lazy to maintain two separate include directories to search in for `libgnomesupport' stuff ;-) (supportinclude_DATA): New var. Has `gnomesupport.h'. (BUILT_SOURCES): Generate `gnomesupport.h'. * gnomesupport-h.c: New file. Used to generate `gnomesupport.h', which contains prototypes for many of the functions in `libgnomesupport'. This method is used to ensure that prototypes appear only for those functions that are provided by `libgnomesupport'. * scandir.c (alphasort): New utility function. svn path=/trunk/; revision=190
-rw-r--r--support/ChangeLog18
-rw-r--r--support/Makefile.am14
-rw-r--r--support/gnomesupport-h.c152
-rw-r--r--support/scandir.c7
4 files changed, 190 insertions, 1 deletions
diff --git a/support/ChangeLog b/support/ChangeLog
index e6b45b9..3175003 100644
--- a/support/ChangeLog
+++ b/support/ChangeLog
@@ -1,3 +1,21 @@
+1998-04-12 Raja R Harinath <harinath@cs.umn.edu>
+
+ * Makefile.am (supportincludedir): Is now $(pkglibdir)/include.
+ `gnomesupport.h' is a generated file dependent on the configure
+ process. So, this seems a good place. The rest of the headers
+ are also here just because I'm too lazy to maintain two separate
+ include directories to search in for `libgnomesupport' stuff ;-)
+ (supportinclude_DATA): New var. Has `gnomesupport.h'.
+ (BUILT_SOURCES): Generate `gnomesupport.h'.
+
+ * gnomesupport-h.c: New file. Used to generate `gnomesupport.h',
+ which contains prototypes for many of the functions in
+ `libgnomesupport'. This method is used to ensure that prototypes
+ appear only for those functions that are provided by
+ `libgnomesupport'.
+
+ * scandir.c (alphasort): New utility function.
+
1998-04-08 Raja R Harinath <harinath@cs.umn.edu>
* scandir.c: Import from GNU libc.
diff --git a/support/Makefile.am b/support/Makefile.am
index 7876a80..7dfc945 100644
--- a/support/Makefile.am
+++ b/support/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to produce Makefile.in.
-supportincludedir = $(includedir)/libgnomesupport
+supportincludedir = $(pkglibdir)/include
if BUILD_GNOME_SUPPORT
@@ -8,6 +8,10 @@ lib_LTLIBRARIES = libgnomesupport.la
supportinclude_HEADERS = gnome-argp.h getopt.h long-options.h argp.h
+# it is in _DATA since we don't want `gnomesupport.h' to be part of
+# the distributed `.tar.gz' file
+supportinclude_DATA = gnomesupport.h
+
# These are internal headers: they are used only when compiling and
# should not be installed
noinst_HEADERS = argp-fmtstream.h argp-namefrob.h
@@ -16,6 +20,14 @@ libgnomesupport_la_SOURCES = long-options.c gnome-argp.c
libgnomesupport_la_LIBADD = @LTLIBOBJS@
libgnomesupport_la_LDFLAGS = -version-info 0:0:0
+noinst_PROGRAMS = gnomesupport-h
+
+BUILT_SOURCES = gnomesupport.h
+
+gnomesupport.h: gnomesupport-h
+ ./gnomesupport-h > gnomesupport.h-new && \
+ mv gnomesupport.h-new gnomesupport.h
+
endif
EXTRA_DIST = argp-test.c argp.texi
diff --git a/support/gnomesupport-h.c b/support/gnomesupport-h.c
new file mode 100644
index 0000000..8f8adde
--- /dev/null
+++ b/support/gnomesupport-h.c
@@ -0,0 +1,152 @@
+/* This program is used to generate `gnomesupport.h'. */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+
+/* It emits prototypes of (some of) the functions that have been built
+ into libgnomesupport, i.e. functions that are missing on the system.
+ It should explain what appears like reverse logic.
+
+ Notes:
+ - The generated file SHOULD NOT refer to <config.h>.
+ - The generated file SHOULD NOT #define or use (#ifdef/#ifndef &c.) any
+ symbols in the HAVE_* namespace.
+ - The generated file prefarably should not have any #ifdefs (except for
+ the include guard and the C++ guard, which it should have). */
+
+int main(void)
+{
+ puts("\
+/* gnomesupport.h */
+/* This is a generated file. Please modify `gnomesupport-h.c'. */
+
+#ifndef GNOMESUPPORT_H
+#define GNOMESUPPORT_H
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif /* __cplusplus */
+");
+
+#if !defined HAVE_VASPRINTF || !defined HAVE_VSNPRINTF
+ puts("\
+#include <stdarg.h>
+");
+#endif
+
+#if HAVE_DIRENT_H
+ puts("\
+#include <dirent.h>
+#define NAMLEN(dirent) strlen((dirent)->d_name)
+");
+#else
+ puts("\
+#define dirent direct
+#define NAMLEN(dirent) (dirent)->d_namlen
+");
+# if HAVE_SYS_NDIR_H
+ puts("\
+#include <sys/ndir.h>
+");
+# endif
+# if HAVE_SYS_DIR_H
+ puts("\
+#include <sys/dir.h>
+");
+# endif
+# if HAVE_NDIR_H
+ puts("\
+#include <ndir.h>
+");
+# endif
+#endif
+
+ puts("\
+#undef PARAMS
+#if defined __cplusplus || defined __GNUC__ || __STDC__
+# define PARAMS(args) args
+#else
+# define PARAMS(args) ()
+#endif
+");
+
+#ifndef HAVE_SCANDIR
+ puts("\
+/* Scan the directory DIR, calling SELECTOR on each directory entry.
+ Entries for which SELECTOR returns nonzero are individually malloc'd,
+ sorted using qsort with CMP, and collected in a malloc'd array in
+ *NAMELIST. Returns the number of entries selected, or -1 on error. */
+int scandir PARAMS((const char */*dir*/, struct dirent ***/*namelist*/,
+ int (*/*selector*/) PARAMS ((struct dirent *)),
+ int (*/*cmp*/) PARAMS ((const void *, const void *))));
+
+/* Function to compare two `struct dirent's alphabetically. */
+int alphasort PARAMS((const void */*a*/, const void */*b*/));
+");
+#endif
+
+#ifndef HAVE_STRTOK_R
+ puts("\
+/* Divide S into tokens separated by characters in DELIM. Information
+ passed between calls are stored in SAVE_PTR. */
+char * strtok_r PARAMS((char */*s*/, const char */*delim*/,
+ char **/*save_ptr*/));
+");
+#endif
+
+#ifndef HAVE_STRCASECMP
+ puts("\
+/* Compare S1 and S2, ignoring case. */
+int strcasecmp PARAMS((const char */*s1*/, const char */*s2*/));
+");
+#endif
+
+#ifndef HAVE_STRNDUP
+ puts("\
+/* Return a malloc'd copy of at most N bytes of STRING. The
+ resultant string is terminated even if no null terminator
+ appears before STRING[N]. */
+char * strndup PARAMS((const char */*s*/, size_t /*n*/));
+");
+#endif
+
+#ifndef HAVE_STRNLEN
+ puts("\
+/* Find the length of STRING, but scan at most MAXLEN characters.
+ If no '\\0' terminator is found in that many characters, return MAXLEN. */
+size_t strnlen PARAMS((const char */*string*/, size_t /*maxlen*/));
+");
+#endif
+
+#ifndef HAVE_VASPRINTF
+ puts("\
+/* Write formatted output to a string dynamically allocated with `malloc'.
+ Store the address of the string in *PTR. */
+int vasprintf PARAMS((char **/*ptr*/, const char */*format*/,
+ va_list /*args*/));
+int asprintf PARAMS((char **/*ptr*/, const char */*format*/, ...));
+");
+#endif
+
+#ifndef HAVE_VSNPRINTF
+ puts("\
+/* Maximum chars of output to write is MAXLEN. */
+int vsnprintf PARAMS((char */*str*/, size_t /*maxlen*/, char */*fmt*/,
+ va_list /*ap*/));
+int snprintf PARAMS((char */*str*/, size_t /*maxlen*/, char */*fmt*/, ...));
+");
+#endif
+
+ puts("\
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GNOMESUPPORT_H */
+");
+
+ return 0;
+}
diff --git a/support/scandir.c b/support/scandir.c
index 39cb6dd..26fe361 100644
--- a/support/scandir.c
+++ b/support/scandir.c
@@ -122,3 +122,10 @@ scandir (dir, namelist, select, cmp)
*namelist = v;
return i;
}
+
+int
+alphasort (const void *a, const void *b)
+{
+ return strcmp ((*(const struct dirent **) a)->d_name,
+ (*(const struct dirent **) b)->d_name);
+}