Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Updated to include source for compiled Rivet parser (untested) |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
ac5f782e14389c1a6d3030f38da8cc54 |
User & Date: | rkeene 2011-07-08 13:12:10.000 |
Context
2011-07-08
| ||
13:42 | Updated to try hardre to compile librivetparser check-in: 24c1357b4e user: rkeene tags: trunk | |
13:12 | Updated to include source for compiled Rivet parser (untested) check-in: ac5f782e14 user: rkeene tags: trunk | |
2011-07-01
| ||
11:53 | Updated to read configuration file correctly Updated to normalize paths relative to starkit/starpack check-in: 3ed8ae2b4b user: rkeene tags: trunk | |
Changes
Added .fossil-settings/ignore-glob.
> > | 1 2 | lib/*-* lib/*-*/* |
Changes to bin/rivet2starkit.
︙ | ︙ | |||
68 69 70 71 72 73 74 75 76 77 78 79 80 81 | cp "${OURDIR}/../rivet-starkit/main.tcl" "${TMPVFSDIR}" # Install requiste packages mkdir "${TMPVFSDIR}/lib" >/dev/null 2>/dev/null rm -rf "${TMPVFSDIR}/rivet-tcl" cp -rp "${OURDIR}/../packages"/tclrivet "${TMPVFSDIR}/lib/" cp -rp "${OURDIR}/../rivet-tcl" "${TMPVFSDIR}/" # Add "Deny from all" .htaccess files where needed echo "Deny from all" > "${TMPVFSDIR}/lib/.htaccess" echo "Deny from all" > "${TMPVFSDIR}/rivet-tcl/.htaccess" # Wrap VFS dir into kit echo "${TCLPACK}" "${SDXKIT}" wrap "${TMPRIVETDIR}/rivet.kit" -nocompress | > | 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 | cp "${OURDIR}/../rivet-starkit/main.tcl" "${TMPVFSDIR}" # Install requiste packages mkdir "${TMPVFSDIR}/lib" >/dev/null 2>/dev/null rm -rf "${TMPVFSDIR}/rivet-tcl" cp -rp "${OURDIR}/../packages"/tclrivet "${TMPVFSDIR}/lib/" cp -rp "${OURDIR}/../rivet-tcl" "${TMPVFSDIR}/" cp -rp "${OURDIR}/../lib"/*-* "${TMPVFSDIR}/lib/" >/dev/null 2>/dev/null # Add "Deny from all" .htaccess files where needed echo "Deny from all" > "${TMPVFSDIR}/lib/.htaccess" echo "Deny from all" > "${TMPVFSDIR}/rivet-tcl/.htaccess" # Wrap VFS dir into kit echo "${TCLPACK}" "${SDXKIT}" wrap "${TMPRIVETDIR}/rivet.kit" -nocompress |
︙ | ︙ |
Changes to build/makearch.info.
︙ | ︙ | |||
25 26 27 28 29 30 31 | # These files follow the same convention as DOCS, but don't have the header # tacked onto them. UPDATE_VARS="rivet-starkit/main.tcl" # This script is executed immediately after copying the files # to a temp directory to attempt to compile | | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | # These files follow the same convention as DOCS, but don't have the header # tacked onto them. UPDATE_VARS="rivet-starkit/main.tcl" # This script is executed immediately after copying the files # to a temp directory to attempt to compile BEFORE="build/pre.sh" # This script is executed immediately prior to creation of the # tarball AFTER="" # Files matching these (space-seperated) patterns are deleted TMPS="*.out HEADER build" |
Added build/pre.sh.
> > > | 1 2 3 | #! /bin/bash rm -rf src/*-* |
Added lib/src/Makefile.
> > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 | all: ./build ./install clean: ./build clean distclean: clean ./build distclean .PHONY: all clean distclean |
Added lib/src/build.
> > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #! /bin/bash source "$(find "${TCLCONFIGPATH}" /usr/lib /usr/local/lib -name 'tclConfig.sh' 2>/dev/null | head -1)" OUTFILE="librivetparser${TCL_SHLIB_SUFFIX}" if [ "$1" = "clean" -o "$1" = "distclean" ]; then rm -f "${OUTFILE}" exit 0 fi if [ -z "${CC}" ]; then CC="${TCL_CC}" fi CFLAGS="-DUSE_TCL_STUBS=1 ${TCL_CFLAGS_OPTIMIZE} ${TCL_EXTRA_CFLAGS} ${TCL_INCLUDE_SPEC} ${TCL_SHLIB_CFLAGS}" LDFLAGS="$(eval echo "${TCL_LDFLAGS_OPTIMIZE} ${TCL_STUB_LIB_SPEC}")" eval echo "${TCL_SHLIB_LD}" -o "\"${OUTFILE}\"" parserPkgInit.c rivetParser.c eval "${TCL_SHLIB_LD}" -o "\"${OUTFILE}\"" parserPkgInit.c rivetParser.c || exit $? exit 0 |
Added lib/src/install.
> > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #! /bin/bash source "$(find "${TCLCONFIGPATH}" /usr/lib /usr/local/lib -name 'tclConfig.sh' 2>/dev/null | head -1)" TCLSH="${TCLSH:-tclsh}" LIBFILE="librivetparser${TCL_SHLIB_SUFFIX}" if [ -z "${INSTALL_PLATFORM}" ]; then INSTALL_PLATFORM="$(echo 'package require platform; puts [::platform::generic]' | "${TCLSH}")" fi INSTALLDIR="../${INSTALL_PLATFORM}" mkdir -p "${INSTALLDIR}" || exit 1 echo cp "\"${LIBFILE}\"" "\"${INSTALLDIR}/\"" || exit 1 cp "${LIBFILE}" "${INSTALLDIR}/" || exit 1 exit 0 |
Added lib/src/parserPkgInit.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | /* * parserPkgInit.c - This code provides a wrapper around * rivetParser.c, in order to expose it to Tcl scripts not running in * Rivet. */ /* Copyright 2003-2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* $Id: parserPkgInit.c 265452 2004-12-03 02:17:12Z karl $ */ /* Rivet config */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <tcl.h> #include "rivetParser.h" /* *----------------------------------------------------------------------------- * * Parse_Rivet -- * * Provides glue between Rivet_GetRivetFile and tcl command * rivet::parserivet. * *----------------------------------------------------------------------------- */ static int Parse_Rivet( ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *outbuf; outbuf = Tcl_NewObj(); Tcl_IncrRefCount(outbuf); if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "filename"); return TCL_ERROR; } if (Rivet_GetRivetFile(Tcl_GetString(objv[1]), 1, outbuf, interp) == TCL_ERROR) { return TCL_ERROR; } Tcl_SetObjResult(interp, outbuf); Tcl_DecrRefCount(outbuf); return TCL_OK; } /* *----------------------------------------------------------------------------- * * Parse_RivetData -- * * Takes a Rivet script as an argument, and returns the parsed * tcl script version. * * Results: * A normal Tcl result. * * Side Effects: * None. * *----------------------------------------------------------------------------- */ static int Parse_RivetData(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) { Tcl_Obj *outbuf; outbuf = Tcl_NewObj(); if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, "data"); return TCL_ERROR; } Tcl_IncrRefCount(outbuf); Tcl_AppendToObj(outbuf, "puts -nonewline \"", -1); if (Rivet_Parser(outbuf, objv[1]) == 0) { Tcl_AppendToObj(outbuf, "\"\n", 2); } Tcl_SetObjResult(interp, outbuf); Tcl_DecrRefCount(outbuf); return TCL_OK; } /* Package init for standalone parser package. */ EXTERN int Rivetparser_Init( Tcl_Interp *interp ) { Tcl_CreateObjCommand(interp, "rivet::parserivet", Parse_Rivet, NULL, (Tcl_CmdDeleteProc *)NULL); Tcl_CreateObjCommand(interp, "rivet::parserivetdata", Parse_RivetData, NULL, (Tcl_CmdDeleteProc *)NULL); return Tcl_PkgProvide( interp, "rivetparser", "0.2" ); } EXTERN int Rivetparser_SafeInit( Tcl_Interp *interp ) { /* rivet::parserivet is DEFINITELY unsafe -- it takes a filename, * and code in safe interpreters could possibly manipulate it * to read files */ /* but after inspect we find that rivet::parserivetdata appears * to be safe -- it reads a string and returns a new string derived * from the string it read, using Tcl C calls to construct the * target string, which should by design prevent buffer overflow * attacks, etc. */ Tcl_CreateObjCommand(interp, "rivet::parserivetdata", Parse_RivetData, NULL, (Tcl_CmdDeleteProc *)NULL); return Tcl_PkgProvide( interp, "rivetparser", "0.2" ); } |
Added lib/src/rivetParser.c.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 | /* * Rivet parser. * * Contains functions for loading up Tcl scripts either in flat Tcl * files, or in Rivet .rvt files. * */ /* Copyright 2002-2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* $Id: rivetParser.c 369059 2006-01-14 17:15:42Z davidw $ */ /* Rivet config */ #ifdef HAVE_CONFIG_H #include <config.h> #endif #include <string.h> #include <tcl.h> #include "rivetParser.h" int Rivet_Parser(Tcl_Obj *outbuf, Tcl_Obj *inbuf); /* *----------------------------------------------------------------------------- * * Rivet_GetTclFile -- * * Takes a filename, an outbuf to fill in with a Tcl script, and a * TclWebRequest. Fills in outbuf with a Tcl script. * *----------------------------------------------------------------------------- */ int Rivet_GetTclFile(char *filename, Tcl_Obj *outbuf, Tcl_Interp *interp) { int result = 0; /* Taken, in part, from tclIOUtil.c out of the Tcl distribution, * and modified. */ Tcl_Channel chan = Tcl_OpenFileChannel(interp, filename, "r", 0644); if (chan == (Tcl_Channel) NULL) { Tcl_ResetResult(interp); Tcl_AppendResult(interp, "couldn't read file \"", filename, "\": ", Tcl_PosixError(interp), (char *) NULL); return TCL_ERROR; } result = Tcl_ReadChars(chan, outbuf, -1, 1); if (result < 0) { Tcl_Close(interp, chan); Tcl_AppendResult(interp, "couldn't read file \"", filename, "\": ", Tcl_PosixError(interp), (char *) NULL); return TCL_ERROR; } if (Tcl_Close(interp, chan) != TCL_OK) return TCL_ERROR; return TCL_OK; } /* *----------------------------------------------------------------------------- * * Rivet_GetRivetFile -- * * Takes a filename, a flag to indicate whether we are operating at * the top level (not from within the "parse" command), a buffer to * fill in, and a TclWebRequest. Fills in outbuf with a parsed Rivet * .rvt file, creating a Tcl script ready for execution. * *----------------------------------------------------------------------------- */ int Rivet_GetRivetFile(char *filename, int toplevel, Tcl_Obj *outbuf, Tcl_Interp *interp) { int sz = 0; Tcl_Obj *inbuf; Tcl_Channel rivetfile; rivetfile = Tcl_OpenFileChannel(interp, filename, "r", 0664); if (rivetfile == NULL) { /* Don't need to adderrorinfo - Tcl_OpenFileChannel takes care of that for us. */ return TCL_ERROR; } if (toplevel) { Tcl_AppendToObj(outbuf, "namespace eval request {\n", -1); } else { Tcl_SetStringObj(outbuf, "", -1); } Tcl_AppendToObj(outbuf, "puts -nonewline \"", -1); inbuf = Tcl_NewObj(); Tcl_IncrRefCount(inbuf); sz = Tcl_ReadChars(rivetfile, inbuf, -1, 0); Tcl_Close(interp, rivetfile); if (sz == -1) { Tcl_AddErrorInfo(interp, Tcl_PosixError(interp)); Tcl_DecrRefCount(inbuf); return TCL_ERROR; } /* If we are not inside a <? ?> section, add the closing ". */ if (Rivet_Parser(outbuf, inbuf) == 0) { Tcl_AppendToObj(outbuf, "\"\n", 2); } if (toplevel) { Tcl_AppendToObj(outbuf, "\n}", -1); } Tcl_AppendToObj(outbuf, "\n", -1); Tcl_DecrRefCount(inbuf); /* END PARSER */ return TCL_OK; } /* *----------------------------------------------------------------------------- * * Rivet_Parser -- * * Parses data (from .rvt file) in inbuf and creates resulting script * in outbuf. * * Results: * * Returns 'inside' - whether we were still inside a block of Tcl code * or not, when the parser hit the end of the data. * *----------------------------------------------------------------------------- */ int Rivet_Parser(Tcl_Obj *outbuf, Tcl_Obj *inbuf) { char *next; char *cur; const char *strstart = START_TAG; const char *strend = END_TAG; int endseqlen = strlen(END_TAG); int startseqlen = strlen(START_TAG); int inside = 0, p = 0; int inLen = 0; next = Tcl_GetStringFromObj(inbuf, &inLen); if (inLen == 0) return 0; while (*next != 0) { cur = next; next = (char *)Tcl_UtfNext(cur); if (!inside) { /* Outside the delimiting tags. */ if (*cur == strstart[p]) { if ((++p) == startseqlen) { /* We have matched the whole ending sequence. */ Tcl_AppendToObj(outbuf, "\"\n", 2); inside = 1; p = 0; continue; } } else { if (p > 0) { Tcl_AppendToObj(outbuf, (char *)strstart, p); p = 0; } /* or else just put the char in outbuf */ switch (*cur) { case '{': Tcl_AppendToObj(outbuf, "\\{", 2); break; case '}': Tcl_AppendToObj(outbuf, "\\}", 2); break; case '$': Tcl_AppendToObj(outbuf, "\\$", 2); break; case '[': Tcl_AppendToObj(outbuf, "\\[", 2); break; case ']': Tcl_AppendToObj(outbuf, "\\]", 2); break; case '"': Tcl_AppendToObj(outbuf, "\\\"", 2); break; case '\\': Tcl_AppendToObj(outbuf, "\\\\", 2); break; default: Tcl_AppendToObj(outbuf, cur, next - cur); break; } continue; } } else { /* Inside the delimiting tags. */ if (*cur == strend[p]) { if ((++p) == endseqlen) { Tcl_AppendToObj(outbuf, "\nputs -nonewline \"", -1); inside = 0; p = 0; } } else { /* Plop stuff into outbuf, which we will then eval. */ if (p > 0) { Tcl_AppendToObj(outbuf, (char *)strend, p); p = 0; } Tcl_AppendToObj(outbuf, cur, next - cur); } } } //fprintf (stderr, "content:\n%s\n", Tcl_GetString(outbuf)); //fflush (stderr); return inside; } |
Added lib/src/rivetParser.h.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | /* Copyright 2002-2004 The Apache Software Foundation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ #ifndef RIVETPARSER_H #define RIVETPARSER_H 1 #define START_TAG "<?" #define END_TAG "?>" /* This bit is for windows. */ #ifdef BUILD_rivet #undef TCL_STORAGE_CLASS #define TCL_STORAGE_CLASS DLLEXPORT #endif /* BUILD_rivet */ EXTERN int Rivet_GetRivetFile(char *filename, int toplevel, Tcl_Obj *outbuf, Tcl_Interp *interp); EXTERN int Rivet_GetTclFile(char *filename, Tcl_Obj *outbuf, Tcl_Interp *interp); EXTERN int Rivet_Parser(Tcl_Obj *outbuf, Tcl_Obj *inbuf); #endif /* RIVETPARSER_H */ |
Changes to packages/tclrivet/tclrivet.tcl.
︙ | ︙ | |||
14 15 16 17 18 19 20 21 22 | # See the License for the specific language governing permissions and # limitations under the License. # $Id: tclrivet.tcl,v 1.2 2004/02/24 10:24:34 davidw Exp $ package provide tclrivet 0.1 if {[catch { | > > | | 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | # See the License for the specific language governing permissions and # limitations under the License. # $Id: tclrivet.tcl,v 1.2 2004/02/24 10:24:34 davidw Exp $ package provide tclrivet 0.1 if {[catch { package require platform load [file join [file dirname [info script]] .. .. lib [::platform::generic] librivetparser[info sharedlibextension]] set ::librivetparser_loaded 1 } tclRivetLoadError]} { if {![info exists ::tclrivetparser_loaded]} { set ::tclrivetparser_loaded 1 source [file join [file dirname [info script]] tclrivetparser.tcl] } } |
︙ | ︙ |