From: Zoran V. <vas...@us...> - 2006-01-14 18:07:53
|
Update of /cvsroot/naviserver/naviserver/nsd In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27097/nsd Modified Files: tclmisc.c Log Message: Indented. Index: tclmisc.c =================================================================== RCS file: /cvsroot/naviserver/naviserver/nsd/tclmisc.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** tclmisc.c 14 Jan 2006 17:45:41 -0000 1.16 --- tclmisc.c 14 Jan 2006 18:07:44 -0000 1.17 *************** *** 1,7 **** /* ! * The contents of this file are subject to the AOLserver Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://aolserver.com/. * * Software distributed under the License is distributed on an "AS IS" --- 1,7 ---- /* ! * The contents of this file are subject to the Mozilla Public License * Version 1.1 (the "License"); you may not use this file except in * compliance with the License. You may obtain a copy of the License at ! * http://mozilla.org/. * * Software distributed under the License is distributed on an "AS IS" *************** *** 65,70 **** Ns_TclPrintfResult(Tcl_Interp *interp, char *fmt, ...) { ! va_list ap; ! Tcl_DString ds; Tcl_DStringInit(&ds); --- 65,70 ---- Ns_TclPrintfResult(Tcl_Interp *interp, char *fmt, ...) { ! va_list ap; ! Tcl_DString ds; Tcl_DStringInit(&ds); *************** *** 93,97 **** int ! NsTclRunOnceObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { NsInterp *itPtr = arg; --- 93,98 ---- int ! NsTclRunOnceObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { NsInterp *itPtr = arg; *************** *** 119,124 **** initialized = NS_TRUE; } ! (void) Tcl_CreateHashEntry(global ? &runTable : &itPtr->servPtr->tcl.runTable, ! script, &new); Ns_MasterUnlock(); --- 120,125 ---- initialized = NS_TRUE; } ! (void) Tcl_CreateHashEntry(global ? &runTable : ! &itPtr->servPtr->tcl.runTable, script, &new); Ns_MasterUnlock(); *************** *** 239,249 **** * NsTclStripHtmlCmd -- * ! * Implements ns_striphtml. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 240,250 ---- * NsTclStripHtmlCmd -- * ! * Implements ns_striphtml. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 254,258 **** { int intag; /* flag to see if are we inside a tag */ ! int intspec; /* flag to see if we are inside a special char */ char *inString; /* copy of input string */ char *inPtr; /* moving pointer to input string */ --- 255,259 ---- { int intag; /* flag to see if are we inside a tag */ ! int intspec; /* flag to see if we are inside a special char */ char *inString; /* copy of input string */ char *inPtr; /* moving pointer to input string */ *************** *** 280,302 **** } else if (intag && (*inPtr == '>')) { ! /* inside a tag that closes */ intag = 0; } else if (intspec && (*inPtr == ';')) { ! /* inside a special character that closes */ ! intspec = 0; } else if (!intag && !intspec) { ! /* regular text */ if (*inPtr == '&') { ! /* starting a new special character */ intspec=WordEndsInSemi(inPtr); ! } if (!intspec) { ! /* incr pointer only if we're not in something htmlish */ *outPtr++ = *inPtr; ! } } ++inPtr; --- 281,303 ---- } else if (intag && (*inPtr == '>')) { ! /* inside a tag that closes */ intag = 0; } else if (intspec && (*inPtr == ';')) { ! /* inside a special character that closes */ ! intspec = 0; } else if (!intag && !intspec) { ! /* regular text */ if (*inPtr == '&') { ! /* starting a new special character */ intspec=WordEndsInSemi(inPtr); ! } if (!intspec) { ! /* incr pointer only if we're not in something htmlish */ *outPtr++ = *inPtr; ! } } ++inPtr; *************** *** 319,329 **** * NsTclCryptObjCmd -- * ! * Implements ns_crypt as ObjCommand. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 320,330 ---- * NsTclCryptObjCmd -- * ! * Implements ns_crypt as ObjCommand. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 331,335 **** int ! NsTclCryptObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { char buf[NS_ENCRYPT_BUFSIZE]; --- 332,337 ---- int ! NsTclCryptObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { char buf[NS_ENCRYPT_BUFSIZE]; *************** *** 339,343 **** return TCL_ERROR; } ! Tcl_SetResult(interp, Ns_Encrypt(Tcl_GetString(objv[1]), Tcl_GetString(objv[2]), buf), TCL_VOLATILE); return TCL_OK; --- 341,347 ---- return TCL_ERROR; } ! Tcl_SetResult(interp, ! Ns_Encrypt(Tcl_GetString(objv[1]), ! Tcl_GetString(objv[2]), buf), TCL_VOLATILE); return TCL_OK; *************** *** 350,360 **** * NsTclHrefsCmd -- * ! * Implements ns_hrefs. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 354,364 ---- * NsTclHrefsCmd -- * ! * Implements ns_hrefs. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 371,385 **** return TCL_ERROR; } ! p = argv[1]; while ((s = strchr(p, '<')) && (e = strchr(s, '>'))) { ! ++s; ! *e = '\0'; ! while (*s && isspace(UCHAR(*s))) { ! ++s; ! } ! if ((*s == 'a' || *s == 'A') && isspace(UCHAR(s[1]))) { ! ++s; ! while (*s) { if (!strncasecmp(s, "href", 4)) { s += 4; --- 375,389 ---- return TCL_ERROR; } ! p = argv[1]; while ((s = strchr(p, '<')) && (e = strchr(s, '>'))) { ! ++s; ! *e = '\0'; ! while (*s && isspace(UCHAR(*s))) { ! ++s; ! } ! if ((*s == 'a' || *s == 'A') && isspace(UCHAR(s[1]))) { ! ++s; ! while (*s) { if (!strncasecmp(s, "href", 4)) { s += 4; *************** *** 418,424 **** ++s; } ! } ! *e++ = '>'; ! p = e; } --- 422,428 ---- ++s; } ! } ! *e++ = '>'; ! p = e; } *************** *** 432,442 **** * NsTclHTUUEncodeObjCmd -- * ! * Implements ns_uuencode as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 436,446 ---- * NsTclHTUUEncodeObjCmd -- * ! * Implements ns_uuencode as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 444,452 **** int ! NsTclHTUUEncodeObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { unsigned char *string; ! char *result; ! int nbytes; if (objc != 2) { --- 448,457 ---- int ! NsTclHTUUEncodeObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, ! Tcl_Obj **objv) { unsigned char *string; ! char *result; ! int nbytes; if (objc != 2) { *************** *** 454,461 **** --- 459,468 ---- return TCL_ERROR; } + string = Tcl_GetByteArrayFromObj(objv[1], &nbytes); result = ns_malloc((size_t) 1 + (4 * MAX(nbytes,2)) / 2); Ns_HtuuEncode(string, (size_t)nbytes, result); Tcl_SetResult(interp, result, (Tcl_FreeProc *) ns_free); + return TCL_OK; } *************** *** 467,477 **** * HTUUDecodeObjcmd -- * ! * Implements ns_uudecode as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- --- 474,484 ---- * HTUUDecodeObjcmd -- * ! * Implements ns_uudecode as obj command. * * Results: ! * Tcl result. * * Side effects: ! * See docs. * *---------------------------------------------------------------------- *************** *** 479,483 **** int ! NsTclHTUUDecodeObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, Tcl_Obj **objv) { int size; --- 486,491 ---- int ! NsTclHTUUDecodeObjCmd(ClientData dummy, Tcl_Interp *interp, int objc, ! Tcl_Obj **objv) { int size; *************** *** 489,492 **** --- 497,501 ---- return TCL_ERROR; } + string = Tcl_GetStringFromObj(objv[1], &size); size += 3; *************** *** 496,499 **** --- 505,509 ---- Tcl_SetObjResult(interp, Tcl_NewByteArrayObj(decoded, size)); ns_free(decoded); + return TCL_OK; } *************** *** 505,515 **** * NsTclCrashCmd -- * ! * Crash the server to test exception handling. * * Results: ! * None. * * Side effects: ! * Server will segfault. * *---------------------------------------------------------------------- --- 515,525 ---- * NsTclCrashCmd -- * ! * Crash the server to test exception handling. * * Results: ! * None. * * Side effects: ! * Server will segfault. * *---------------------------------------------------------------------- *************** *** 519,523 **** NsTclCrashCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv) { ! char *death; death = NULL; --- 529,533 ---- NsTclCrashCmd(ClientData dummy, Tcl_Interp *interp, int argc, char **argv) { ! char *death; death = NULL; *************** *** 567,590 **** /* ! * The SHA1 routines are borrowed from libmd, which contains the following header: * ! * * sha.c - NIST Secure Hash Algorithm, FIPS PUB 180 and 180.1. ! * * The algorithm is by spook(s) unknown at the U.S. National Security Agency. ! * * ! * * Written 2 September 1992, Peter C. Gutmann. ! * * This implementation placed in the public domain. ! * * ! * * Modified 1 June 1993, Colin Plumb. ! * * Modified for the new SHS based on Peter Gutmann's work, ! * * 18 July 1994, Colin Plumb. ! * * ! * * Renamed to SHA and comments updated a bit 1 November 1995, Colin Plumb. ! * * These modifications placed in the public domain. ! * * ! * * Comments to pg...@cs... ! * * ! * * Hacked for use in libmd by Martin Hinner <mh...@pe...> * ! * This Tcl library was hacked by Jon Salz <js...@mi...>. * */ --- 577,600 ---- /* ! * The SHA1 routines are borrowed from libmd: * ! * * sha.c - NIST Secure Hash Algorithm, FIPS PUB 180 and 180.1. ! * * The algorithm is by spook(s) unknown at the U.S. National Security Agency. ! * * ! * * Written 2 September 1992, Peter C. Gutmann. ! * * This implementation placed in the public domain. ! * * ! * * Modified 1 June 1993, Colin Plumb. ! * * Modified for the new SHS based on Peter Gutmann's work, ! * * 18 July 1994, Colin Plumb. ! * * ! * * Renamed to SHA and comments updated a bit 1 November 1995, Colin Plumb. ! * * These modifications placed in the public domain. ! * * ! * * Comments to pg...@cs... ! * * ! * * Hacked for use in libmd by Martin Hinner <mh...@pe...> * ! * This Tcl library was hacked by Jon Salz <js...@mi...>. * */ *************** *** 982,986 **** int ! NsTclSHA1ObjCmd(ClientData arg, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { SHA_CTX ctx; --- 992,997 ---- int ! NsTclSHA1ObjCmd(ClientData arg, Tcl_Interp *interp, int objc, ! Tcl_Obj *CONST objv[]) { SHA_CTX ctx; *************** *** 993,997 **** if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "string"); ! return TCL_ERROR; } --- 1004,1008 ---- if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "string"); ! return TCL_ERROR; } *************** *** 1002,1012 **** for (i = 0; i < 20; ++i) { ! digestChars[i * 2] = hexChars[digest[i] >> 4]; ! digestChars[i * 2 + 1] = hexChars[digest[i] & 0xF]; } - digestChars[40] = '\0'; Tcl_AppendResult(interp, digestChars, NULL); ! return NS_OK; } --- 1013,1023 ---- for (i = 0; i < 20; ++i) { ! digestChars[i * 2] = hexChars[digest[i] >> 4]; ! digestChars[i * 2 + 1] = hexChars[digest[i] & 0xF]; } + digestChars[40] = '\0'; Tcl_AppendResult(interp, digestChars, NULL); ! return NS_OK; } |