diff options
Diffstat (limited to 'contrib/tcl/unix')
-rw-r--r-- | contrib/tcl/unix/bp.c | 127 | ||||
-rw-r--r-- | contrib/tcl/unix/tclLoadDl2.c | 113 |
2 files changed, 0 insertions, 240 deletions
diff --git a/contrib/tcl/unix/bp.c b/contrib/tcl/unix/bp.c deleted file mode 100644 index b8c7a49b2f43e..0000000000000 --- a/contrib/tcl/unix/bp.c +++ /dev/null @@ -1,127 +0,0 @@ -/* - * bp.c -- - * - * This file contains the "bp" ("binary patch") program. It is used - * to replace configuration strings in Tcl/Tk binaries as part of - * installation. - * - * Usage: bp file search replace - * - * This program searches file bp for the first occurrence of the - * character string given by "search". If it is found, then the - * first characters of that string get replaced by the string - * given by "replace". The replacement string is NULL-terminated. - * - * Copyright (c) 1996 Sun Microsystems, Inc. - * All rights reserved. - * This file is NOT subject to the terms described in "license.terms". - * - * SCCS: @(#) bp.c 1.2 96/03/12 09:08:26 - */ - -#include <stdio.h> -#include <string.h> - -extern int errno; - -/* - * The array below saves the last few bytes read from the file, so that - * they can be compared against a particular string that we're looking - * for. - */ - -#define BUFFER_SIZE 200 -char buffer[BUFFER_SIZE]; - -int -main(argc, argv) - int argc; /* Number of command-line arguments. */ - char **argv; /* Values of command-line arguments. */ -{ - int length, matchChar, fileChar, cur, fileIndex, stringIndex; - char *s; - FILE *f; - - if (argc != 4) { - fprintf(stderr, - "Wrong # args: should be \"%s fileName string replace\"\n", - argv[0]); - exit(1); - } - f = fopen(argv[1], "r+"); - if (f == NULL) { - fprintf(stderr, - "Couldn't open \"%s\" for writing: %s\n", - argv[1], strerror(errno)); - exit(1); - } - - for (cur = 0; cur < BUFFER_SIZE; cur++) { - buffer[cur] = 0; - } - s = argv[2]; - length = strlen(s); - if (length > BUFFER_SIZE) { - fprintf(stderr, - "String \"%s\" too long; must be %d or fewer chars.\n", - s, BUFFER_SIZE); - exit(1); - } - matchChar = s[length-1]; - - while (1) { - fileChar = getc(f); - if (fileChar == EOF) { - if (ferror(f)) { - goto ioError; - } - fprintf(stderr, "Couldn't find string \"%s\"\n", argv[2]); - exit(1); - } - buffer[cur] = fileChar; - if (fileChar == matchChar) { - /* - * Last character of the string matches the current character - * from the file. Search backwards through the buffer to - * see if the preceding characters from the file match the - * characters from the string. - */ - for (fileIndex = cur-1, stringIndex = length-2; - stringIndex >= 0; fileIndex--, stringIndex--) { - if (fileIndex < 0) { - fileIndex = BUFFER_SIZE-1; - } - if (buffer[fileIndex] != s[stringIndex]) { - goto noMatch; - } - } - - /* - * Matched! Backup to the start of the string, then - * overwrite it with the replacement value. - */ - - if (fseek(f, -length, SEEK_CUR) == -1) { - goto ioError; - } - if (fwrite(argv[3], strlen(argv[3])+1, 1, f) == 0) { - goto ioError; - } - exit(0); - } - - /* - * No match; go on to next character of file. - */ - - noMatch: - cur++; - if (cur >= BUFFER_SIZE) { - cur = 0; - } - } - - ioError: - fprintf(stderr, "I/O error: %s\n", strerror(errno)); - exit(1); -} diff --git a/contrib/tcl/unix/tclLoadDl2.c b/contrib/tcl/unix/tclLoadDl2.c deleted file mode 100644 index ad18537f14407..0000000000000 --- a/contrib/tcl/unix/tclLoadDl2.c +++ /dev/null @@ -1,113 +0,0 @@ -/* - * tclLoadDl2.c -- - * - * This procedure provides a version of the TclLoadFile that - * works with the "dlopen" and "dlsym" library procedures for - * dynamic loading. It is identical to tclLoadDl.c except that - * it adds a "_" character to symbol names before looking them - * up. - * - * Copyright (c) 1995 Sun Microsystems, Inc. - * - * See the file "license.terms" for information on usage and redistribution - * of this file, and for a DISCLAIMER OF ALL WARRANTIES. - * - * SCCS: @(#) tclLoadDl2.c 1.3 96/02/15 11:58:45 - */ - -#include "tcl.h" -#include "dlfcn.h" - -/* - * In some systems, like SunOS 4.1.3, the RTLD_NOW flag isn't defined - * and this argument to dlopen must always be 1. - */ - -#ifndef RTLD_NOW -# define RTLD_NOW 1 -#endif - -/* - *---------------------------------------------------------------------- - * - * TclLoadFile -- - * - * Dynamically loads a binary code file into memory and returns - * the addresses of two procedures within that file, if they - * are defined. - * - * Results: - * A standard Tcl completion code. If an error occurs, an error - * message is left in interp->result. *proc1Ptr and *proc2Ptr - * are filled in with the addresses of the symbols given by - * *sym1 and *sym2, or NULL if those symbols can't be found. - * - * Side effects: - * New code suddenly appears in memory. - * - *---------------------------------------------------------------------- - */ - -int -TclLoadFile(interp, fileName, sym1, sym2, proc1Ptr, proc2Ptr) - Tcl_Interp *interp; /* Used for error reporting. */ - char *fileName; /* Name of the file containing the desired - * code. */ - char *sym1, *sym2; /* Names of two procedures to look up in - * the file's symbol table. */ - Tcl_PackageInitProc **proc1Ptr, **proc2Ptr; - /* Where to return the addresses corresponding - * to sym1 and sym2. */ -{ - VOID *handle; - Tcl_DString newName; - - handle = dlopen(fileName, RTLD_NOW); - if (handle == NULL) { - Tcl_AppendResult(interp, "couldn't load file \"", fileName, - "\": ", dlerror(), (char *) NULL); - return TCL_ERROR; - } - Tcl_DStringInit(&newName); - Tcl_DStringAppend(&newName, "_", 1); - Tcl_DStringAppend(&newName, sym1, -1); - *proc1Ptr = (Tcl_PackageInitProc *) dlsym(handle, - Tcl_DStringValue(&newName)); - Tcl_DStringSetLength(&newName, 0); - Tcl_DStringAppend(&newName, "_", 1); - Tcl_DStringAppend(&newName, sym2, -1); - *proc2Ptr = (Tcl_PackageInitProc *) dlsym(handle, - Tcl_DStringValue(&newName)); - Tcl_DStringFree(&newName); - return TCL_OK; -} - -/* - *---------------------------------------------------------------------- - * - * TclGuessPackageName -- - * - * If the "load" command is invoked without providing a package - * name, this procedure is invoked to try to figure it out. - * - * Results: - * Always returns 0 to indicate that we couldn't figure out a - * package name; generic code will then try to guess the package - * from the file name. A return value of 1 would have meant that - * we figured out the package name and put it in bufPtr. - * - * Side effects: - * None. - * - *---------------------------------------------------------------------- - */ - -int -TclGuessPackageName(fileName, bufPtr) - char *fileName; /* Name of file containing package (already - * translated to local form if needed). */ - Tcl_DString *bufPtr; /* Initialized empty dstring. Append - * package name to this if possible. */ -{ - return 0; -} |