summaryrefslogtreecommitdiff
path: root/ext/DynaLoader/dlutils.c
diff options
context:
space:
mode:
authorLarry Wall <lwall@netlabs.com>1994-10-17 23:00:00 +0000
committerLarry Wall <lwall@netlabs.com>1994-10-17 23:00:00 +0000
commita0d0e21ea6ea90a22318550944fe6cb09ae10cda (patch)
treefaca1018149b736b1142f487e44d1ff2de5cc1fa /ext/DynaLoader/dlutils.c
parent85e6fe838fb25b257a1b363debf8691c0992ef71 (diff)
downloadperl-5.000.tar.gz
perl 5.000perl-5.000
[editor's note: this commit combines approximate 4 months of furious releases of Andy Dougherty and Larry Wall - see pod/perlhist.pod for details. Andy notes that; Alas neither my "Irwin AccuTrack" nor my DC 600A quarter-inch cartridge backup tapes from that era seem to be readable anymore. I guess 13 years exceeds the shelf life for that backup technology :-(. ]
Diffstat (limited to 'ext/DynaLoader/dlutils.c')
-rw-r--r--ext/DynaLoader/dlutils.c85
1 files changed, 85 insertions, 0 deletions
diff --git a/ext/DynaLoader/dlutils.c b/ext/DynaLoader/dlutils.c
new file mode 100644
index 0000000000..0ce082182c
--- /dev/null
+++ b/ext/DynaLoader/dlutils.c
@@ -0,0 +1,85 @@
+/* dlutils.c - handy functions and definitions for dl_*.xs files
+ *
+ * Currently this file is simply #included into dl_*.xs/.c files.
+ * It should really be split into a dlutils.h and dlutils.c
+ *
+ */
+
+
+/* pointer to allocated memory for last error message */
+static char *LastError = (char*)NULL;
+
+
+
+#ifdef DEBUGGING
+/* currently not connected to $DynaLoader::dl_error but should be */
+static int dl_debug = 0;
+#define DLDEBUG(level,code) if(dl_debug>=level){ code; }
+#else
+#define DLDEBUG(level,code)
+#endif
+
+
+static void
+dl_generic_private_init() /* called by dl_*.xs dl_private_init() */
+{
+#ifdef DEBUGGING
+ char *perl_dl_debug = getenv("PERL_DL_DEBUG");
+ if (perl_dl_debug)
+ dl_debug = atoi(perl_dl_debug);
+#endif
+}
+
+
+/* SaveError() takes printf style args and saves the result in LastError */
+#ifdef STANDARD_C
+static void
+SaveError(char* pat, ...)
+#else
+/*VARARGS0*/
+static void
+SaveError(pat, va_alist)
+ char *pat;
+ va_dcl
+#endif
+{
+ va_list args;
+ char *message;
+ int len;
+
+ /* This code is based on croak/warn but I'm not sure where mess() */
+ /* gets its buffer space from! */
+
+#ifdef I_STDARG
+ va_start(args, pat);
+#else
+ va_start(args);
+#endif
+ message = mess(pat, &args);
+ va_end(args);
+
+ len = strlen(message) + 1 ; /* include terminating null char */
+
+ /* Allocate some memory for the error message */
+ if (LastError)
+ LastError = (char*)saferealloc(LastError, len) ;
+ else
+ LastError = safemalloc(len) ;
+
+ /* Copy message into LastError (including terminating null char) */
+ strncpy(LastError, message, len) ;
+ DLDEBUG(2,fprintf(stderr,"DynaLoader: stored error msg '%s'\n",LastError));
+}
+
+
+/* prepend underscore to s. write into buf. return buf. */
+char *
+dl_add_underscore(s, buf)
+char *s;
+char *buf;
+{
+ *buf = '_';
+ (void)strcpy(buf + 1, s);
+ return buf;
+}
+