Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Merge from trunk |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | ashish-ipv6 |
| Files: | files | file ages | folders |
| SHA1: |
26b7b16a7c923f157c8bf7e24ae9e800 |
| User & Date: | ashish 2014-11-11 12:15:47.984 |
Context
|
2014-11-11
| ||
| 12:15 | Merge from trunk ... (Closed-Leaf check-in: 26b7b16a7c user: ashish tags: ashish-ipv6) | |
|
2014-11-10
| ||
| 02:41 | Update the makefile.wiki documentation page to talk about the mkbuiltin.exe program used for generating the builtin_data.h header file. ... (check-in: 8a8177071f user: drh tags: trunk) | |
|
2014-07-20
| ||
| 13:20 | Merge from trunk ... (check-in: c4fca467f7 user: ashish tags: ashish-ipv6) | |
Changes
Added Dockerfile.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
###
# Dockerfile for Fossil
###
FROM fedora:21
### Now install some additional parts we will need for the build
# RUN yum update -y && yum clean all
RUN yum install -y gcc make zlib-devel openssl-devel tcl-devel && yum clean all
RUN groupadd -r fossil -g 433 && useradd -u 431 -r -g fossil -d /opt/fossil -s /sbin/nologin -c "Fossil user" fossil
### If you want to build "release", change the next line accordingly.
ENV FOSSIL_INSTALL_VERSION trunk
RUN curl "http://www.fossil-scm.org/index.html/tarball/fossil-src.tar.gz?name=fossil-src&uuid=${FOSSIL_INSTALL_VERSION}" | tar zx
RUN cd fossil-src && ./configure --lineedit=0 --json --with-tcl --with-tcl-stubs --with-tcl-private-stubs && make;
RUN cp fossil-src/fossil /usr/bin
RUN rm -rf fossil-src
RUN chmod a+rx /usr/bin/fossil
RUN mkdir -p /opt/fossil
RUN chown fossil:fossil /opt/fossil
### Build is done, remove modules no longer needed
RUN yum remove -y gcc make zlib-devel openssl-devel tcl-devel && yum clean all
USER fossil
ENV HOME /opt/fossil
RUN fossil new --docker -A admin /opt/fossil/repository.fossil
RUN fossil user password -R /opt/fossil/repository.fossil admin admin
RUN fossil cache init -R /opt/fossil/repository.fossil
EXPOSE 8080
CMD ["/usr/bin/fossil", "server", "/opt/fossil/repository.fossil"]
|
Changes to Makefile.classic.
| ︙ | ︙ | |||
23 24 25 26 27 28 29 | BCC = gcc #### The suffix to add to final executable file. When cross-compiling # to windows, make this ".exe". Otherwise leave it blank. # E = | | > > > > | > | | | | > > > > > | 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 | BCC = gcc #### The suffix to add to final executable file. When cross-compiling # to windows, make this ".exe". Otherwise leave it blank. # E = #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # #TCC = gcc -O6 #TCC = gcc -g -O0 -Wall -fprofile-arcs -ftest-coverage TCC = gcc -g -Os -Wall # To use the included miniz library # FOSSIL_ENABLE_MINIZ = 1 # TCC += -DFOSSIL_ENABLE_MINIZ # To add support for HTTPS TCC += -DFOSSIL_ENABLE_SSL #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library unless the miniz # library in the source tree is being used. There are no other # required dependencies. We sometimes add the -static option # here so that we can build a static executable that will run in # a chroot jail. # ZLIB_LIB.0 = -lz ZLIB_LIB.1 = ZLIB_LIB. = $(ZLIB_LIB.0) # If using zlib: LIB = $(ZLIB_LIB.$(FOSSIL_ENABLE_MINIZ)) $(LDFLAGS) # If using HTTPS: LIB += -lcrypto -lssl #### Tcl shell for use in running the fossil testsuite. If you do not # care about testing the end result, this can be blank. # |
| ︙ | ︙ |
Changes to Makefile.in.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 | # TCLSH = tclsh LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@ TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H INSTALLDIR = $(DESTDIR)@prefix@/bin USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@ include $(SRCDIR)/main.mk distclean: clean rm -f autoconfig.h config.log Makefile | > | 38 39 40 41 42 43 44 45 46 47 48 49 50 | # TCLSH = tclsh LIB = @LDFLAGS@ @EXTRA_LDFLAGS@ @LIBS@ TCC += @EXTRA_CFLAGS@ @CPPFLAGS@ @CFLAGS@ -DHAVE_AUTOCONFIG_H -D_HAVE_SQLITE_CONFIG_H INSTALLDIR = $(DESTDIR)@prefix@/bin USE_SYSTEM_SQLITE = @USE_SYSTEM_SQLITE@ FOSSIL_ENABLE_MINIZ = @FOSSIL_ENABLE_MINIZ@ include $(SRCDIR)/main.mk distclean: clean rm -f autoconfig.h config.log Makefile |
Changes to auto.def.
1 2 3 4 5 6 |
# System autoconfiguration. Try: ./configure --help
use cc cc-lib
options {
with-openssl:path|auto|none
| | > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# System autoconfiguration. Try: ./configure --help
use cc cc-lib
options {
with-openssl:path|auto|none
=> {Look for OpenSSL in the given path, or auto or none}
with-miniz=0 => {Use miniz from the source tree}
with-zlib:path => {Look for zlib in the given path}
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
with-tcl-private-stubs=0
=> {Enable Tcl integration via private stubs mechanism}
internal-sqlite=1 => {Don't use the internal SQLite, use the system one}
static=0 => {Link a static executable}
|
| ︙ | ︙ | |||
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# is required in the CFLAGS because json*.c
# have #ifdef guards around the whole file without
# reading config.h first.
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
define FOSSIL_ENABLE_JSON
msg-result "JSON support enabled"
}
if {[opt-bool with-th1-hooks]} {
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS
define FOSSIL_ENABLE_TH1_HOOKS
msg-result "TH1 hooks support enabled"
}
| > > > > > > | 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# is required in the CFLAGS because json*.c
# have #ifdef guards around the whole file without
# reading config.h first.
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
define FOSSIL_ENABLE_JSON
msg-result "JSON support enabled"
}
if {[opt-bool with-th1-docs]} {
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS
define FOSSIL_ENABLE_TH1_DOCS
msg-result "TH1 embedded documentation support enabled"
}
if {[opt-bool with-th1-hooks]} {
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_HOOKS
define FOSSIL_ENABLE_TH1_HOOKS
msg-result "TH1 hooks support enabled"
}
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
define-append LIBS $libs
}
define-append EXTRA_CFLAGS $cflags
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
define FOSSIL_ENABLE_TCL
}
| | | 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
define-append LIBS $libs
}
define-append EXTRA_CFLAGS $cflags
define-append EXTRA_LDFLAGS $tclconfig(TCL_LD_FLAGS)
define FOSSIL_ENABLE_TCL
}
# Helper for OpenSSL checking
proc check-for-openssl {msg {cflags {}}} {
msg-checking "Checking for $msg..."
set rc 0
msg-quiet cc-with [list -cflags $cflags -libs {-lssl -lcrypto}] {
if {[cc-check-includes openssl/ssl.h] && [cc-check-functions SSL_new]} {
incr rc
}
|
| ︙ | ︙ | |||
247 248 249 250 251 252 253 |
}
}
} else {
user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
}
}
| > > > > | | | | | | | | | | > > > > | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 |
}
}
} else {
user-error "OpenSSL not found. Consider --with-openssl=none to disable HTTPS support"
}
}
if {[opt-bool with-miniz]} {
define FOSSIL_ENABLE_MINIZ 1
msg-result "Using miniz for compression"
} else {
# Check for zlib, using the given location if specified
set zlibpath [opt-val with-zlib]
if {$zlibpath ne ""} {
cc-with [list -cflags "-I$zlibpath -L$zlibpath"]
define-append EXTRA_CFLAGS -I$zlibpath
define-append EXTRA_LDFLAGS -L$zlibpath
msg-result "Using zlib from $zlibpath"
}
if {![cc-check-includes zlib.h] || ![cc-check-function-in-lib inflateEnd z]} {
user-error "zlib not found please install it or specify the location with --with-zlib"
}
}
if {[opt-bool lineedit]} {
# Need readline-compatible line editing
cc-with {-includes stdio.h} {
if {[cc-check-includes readline/readline.h] && [cc-check-function-in-lib readline readline]} {
define-append EXTRA_CFLAGS -DHAVE_READLINE
msg-result "Using readline for line editing"
} elseif {[cc-check-includes editline/readline.h] && [cc-check-function-in-lib readline edit]} {
define-feature editline
define-append EXTRA_CFLAGS -DHAVE_EDITLINE
msg-result "Using editline for line editing"
}
}
}
# Network functions require libraries on some systems
cc-check-function-in-lib gethostbyname nsl
if {![cc-check-function-in-lib socket {socket network}]} {
# Last resort, may be Windows
if {[string match *mingw* [get-define host]]} {
define-append LIBS -lwsock32
}
}
cc-check-function-in-lib iconv iconv
cc-check-functions utime
cc-check-functions usleep
cc-check-functions strchrnul
# Check for getloadavg(), and if it doesn't exist, define FOSSIL_OMIT_LOAD_AVERAGE
if {![cc-check-functions getloadavg]} {
define FOSSIL_OMIT_LOAD_AVERAGE 1
msg-result "Load average support unavailable"
}
|
| ︙ | ︙ |
Changes to autosetup/jimsh0.c.
|
| | | 1 2 3 4 5 6 7 8 | /* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */ #define _GNU_SOURCE #define JIM_TCL_COMPAT #define JIM_REFERENCES #define JIM_ANSIC #define JIM_REGEXP #define HAVE_NO_AUTOCONF #define _JIMAUTOCONF_H |
| ︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 | #define HAVE_UNISTD_H #endif #define JIM_VERSION 75 #ifndef JIM_WIN32COMPAT_H #define JIM_WIN32COMPAT_H #if defined(_WIN32) || defined(WIN32) #define HAVE_DLOPEN void *dlopen(const char *path, int mode); int dlclose(void *handle); | > > > > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
#define HAVE_UNISTD_H
#endif
#define JIM_VERSION 75
#ifndef JIM_WIN32COMPAT_H
#define JIM_WIN32COMPAT_H
#ifdef __cplusplus
extern "C" {
#endif
#if defined(_WIN32) || defined(WIN32)
#define HAVE_DLOPEN
void *dlopen(const char *path, int mode);
int dlclose(void *handle);
|
| ︙ | ︙ | |||
104 105 106 107 108 109 110 | struct dirent result; char *name; } DIR; DIR *opendir(const char *name); int closedir(DIR *dir); struct dirent *readdir(DIR *dir); | > > > > > | > > > > > > > > > > > > > > | 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 |
struct dirent result;
char *name;
} DIR;
DIR *opendir(const char *name);
int closedir(DIR *dir);
struct dirent *readdir(DIR *dir);
#elif defined(__MINGW32__)
#define strtod __strtod
#endif
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef UTF8_UTIL_H
#define UTF8_UTIL_H
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_UTF8_LEN 4
int utf8_fromunicode(char *p, unsigned uc);
#ifndef JIM_UTF8
#include <ctype.h>
#define utf8_strlen(S, B) ((B) < 0 ? strlen(S) : (B))
#define utf8_tounicode(S, CP) (*(CP) = (unsigned char)*(S), 1)
#define utf8_getchars(CP, C) (*(CP) = (C), 1)
#define utf8_upper(C) toupper(C)
#define utf8_title(C) toupper(C)
#define utf8_lower(C) tolower(C)
#define utf8_index(C, I) (I)
#define utf8_charlen(C) 1
#define utf8_prev_len(S, L) 1
#else
#endif
#ifdef __cplusplus
}
#endif
#endif
#ifndef __JIM__H
#define __JIM__H
#ifdef __cplusplus
|
| ︙ | ︙ | |||
197 198 199 200 201 202 203 | #define JIM_EXIT 6 #define JIM_EVAL 7 #define JIM_MAX_CALLFRAME_DEPTH 1000 #define JIM_MAX_EVAL_DEPTH 2000 | | | | | | | | < < < < < < < < < | < | 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 |
#define JIM_EXIT 6
#define JIM_EVAL 7
#define JIM_MAX_CALLFRAME_DEPTH 1000
#define JIM_MAX_EVAL_DEPTH 2000
#define JIM_PRIV_FLAG_SHIFT 20
#define JIM_NONE 0
#define JIM_ERRMSG 1
#define JIM_ENUM_ABBREV 2
#define JIM_UNSHARED 4
#define JIM_MUSTEXIST 8
#define JIM_SUBST_NOVAR 1
#define JIM_SUBST_NOCMD 2
#define JIM_SUBST_NOESC 4
#define JIM_SUBST_FLAG 128
#define JIM_CASESENS 0
#define JIM_NOCASE 1
#define JIM_PATH_LEN 1024
#define JIM_NOTUSED(V) ((void) V)
#define JIM_LIBPATH "auto_path"
#define JIM_INTERACTIVE "tcl_interactive"
typedef struct Jim_Stack {
int len;
|
| ︙ | ︙ | |||
264 265 266 267 268 269 270 271 272 273 274 |
void (*keyDestructor)(void *privdata, void *key);
void (*valDestructor)(void *privdata, void *obj);
} Jim_HashTableType;
typedef struct Jim_HashTable {
Jim_HashEntry **table;
const Jim_HashTableType *type;
unsigned int size;
unsigned int sizemask;
unsigned int used;
unsigned int collisions;
| > | < > | | | | | | | | 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
void (*keyDestructor)(void *privdata, void *key);
void (*valDestructor)(void *privdata, void *obj);
} Jim_HashTableType;
typedef struct Jim_HashTable {
Jim_HashEntry **table;
const Jim_HashTableType *type;
void *privdata;
unsigned int size;
unsigned int sizemask;
unsigned int used;
unsigned int collisions;
unsigned int uniq;
} Jim_HashTable;
typedef struct Jim_HashTableIterator {
Jim_HashTable *ht;
Jim_HashEntry *entry, *nextEntry;
int index;
} Jim_HashTableIterator;
#define JIM_HT_INITIAL_SIZE 16
#define Jim_FreeEntryVal(ht, entry) \
if ((ht)->type->valDestructor) \
(ht)->type->valDestructor((ht)->privdata, (entry)->u.val)
#define Jim_SetHashVal(ht, entry, _val_) do { \
if ((ht)->type->valDup) \
(entry)->u.val = (ht)->type->valDup((ht)->privdata, (_val_)); \
else \
(entry)->u.val = (_val_); \
} while(0)
#define Jim_FreeEntryKey(ht, entry) \
if ((ht)->type->keyDestructor) \
(ht)->type->keyDestructor((ht)->privdata, (entry)->key)
#define Jim_SetHashKey(ht, entry, _key_) do { \
if ((ht)->type->keyDup) \
(entry)->key = (ht)->type->keyDup((ht)->privdata, (_key_)); \
else \
(entry)->key = (void *)(_key_); \
} while(0)
#define Jim_CompareHashKeys(ht, key1, key2) \
(((ht)->type->keyCompare) ? \
(ht)->type->keyCompare((ht)->privdata, (key1), (key2)) : \
(key1) == (key2))
#define Jim_HashKey(ht, key) ((ht)->type->hashFunction(key) + (ht)->uniq)
#define Jim_GetHashEntryKey(he) ((he)->key)
#define Jim_GetHashEntryVal(he) ((he)->u.val)
#define Jim_GetHashTableCollisions(ht) ((ht)->collisions)
#define Jim_GetHashTableSize(ht) ((ht)->size)
#define Jim_GetHashTableUsed(ht) ((ht)->used)
typedef struct Jim_Obj {
char *bytes;
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 |
struct {
void *ptr1;
void *ptr2;
} twoPtrValue;
struct {
| < > < > | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
struct {
void *ptr1;
void *ptr2;
} twoPtrValue;
struct {
struct Jim_Var *varPtr;
unsigned long callFrameId;
int global;
} varValue;
struct {
struct Jim_Obj *nsObj;
struct Jim_Cmd *cmdPtr;
unsigned long procEpoch;
} cmdValue;
struct {
struct Jim_Obj **ele;
int len;
int maxLen;
} listValue;
|
| ︙ | ︙ | |||
377 378 379 380 381 382 383 |
struct {
struct Jim_Obj *varNameObjPtr;
struct Jim_Obj *indexObjPtr;
} dictSubstValue;
struct {
| < > | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
struct {
struct Jim_Obj *varNameObjPtr;
struct Jim_Obj *indexObjPtr;
} dictSubstValue;
struct {
void *compre;
unsigned flags;
} regexpValue;
struct {
int line;
int argc;
} scriptLineValue;
} internalRep;
struct Jim_Obj *prevObjPtr;
|
| ︙ | ︙ | |||
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 |
Jim_Obj *procArgsObjPtr;
Jim_Obj *procBodyObjPtr;
struct Jim_CallFrame *next;
Jim_Obj *nsObj;
Jim_Obj *fileNameObj;
int line;
Jim_Stack *localCommands;
} Jim_CallFrame;
typedef struct Jim_Var {
Jim_Obj *objPtr;
struct Jim_CallFrame *linkFramePtr;
} Jim_Var;
| > > > | | | | | 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
Jim_Obj *procArgsObjPtr;
Jim_Obj *procBodyObjPtr;
struct Jim_CallFrame *next;
Jim_Obj *nsObj;
Jim_Obj *fileNameObj;
int line;
Jim_Stack *localCommands;
int tailcall;
struct Jim_Obj *tailcallObj;
struct Jim_Cmd *tailcallCmd;
} Jim_CallFrame;
typedef struct Jim_Var {
Jim_Obj *objPtr;
struct Jim_CallFrame *linkFramePtr;
} Jim_Var;
typedef int Jim_CmdProc(struct Jim_Interp *interp, int argc,
Jim_Obj *const *argv);
typedef void Jim_DelCmdProc(struct Jim_Interp *interp, void *privData);
typedef struct Jim_Cmd {
int inUse;
int isproc;
struct Jim_Cmd *prevCmd;
union {
struct {
Jim_CmdProc *cmdProc;
Jim_DelCmdProc *delProc;
void *privData;
} native;
struct {
Jim_Obj *argListObjPtr;
Jim_Obj *bodyObjPtr;
Jim_HashTable *staticVars;
|
| ︙ | ︙ | |||
587 588 589 590 591 592 593 |
typedef struct Jim_Reference {
Jim_Obj *objPtr;
Jim_Obj *finalizerCmdNamePtr;
char tag[JIM_REFERENCE_TAGLEN+1];
} Jim_Reference;
| < < < < > | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 |
typedef struct Jim_Reference {
Jim_Obj *objPtr;
Jim_Obj *finalizerCmdNamePtr;
char tag[JIM_REFERENCE_TAGLEN+1];
} Jim_Reference;
#define Jim_NewEmptyStringObj(i) Jim_NewStringObj(i, "", 0)
#define Jim_FreeHashTableIterator(iter) Jim_Free(iter)
#define JIM_EXPORT
JIM_EXPORT void *Jim_Alloc (int size);
JIM_EXPORT void *Jim_Realloc(void *ptr, int size);
JIM_EXPORT void Jim_Free (void *ptr);
JIM_EXPORT char * Jim_StrDup (const char *s);
JIM_EXPORT char *Jim_StrDupLen(const char *s, int l);
JIM_EXPORT char **Jim_GetEnviron(void);
JIM_EXPORT void Jim_SetEnviron(char **env);
JIM_EXPORT int Jim_MakeTempFile(Jim_Interp *interp, const char *template);
JIM_EXPORT int Jim_Eval(Jim_Interp *interp, const char *script);
JIM_EXPORT int Jim_EvalSource(Jim_Interp *interp, const char *filename, int lineno, const char *script);
|
| ︙ | ︙ | |||
737 738 739 740 741 742 743 |
JIM_EXPORT int Jim_SetGlobalVariableStr (Jim_Interp *interp,
const char *name, Jim_Obj *objPtr);
JIM_EXPORT int Jim_SetVariableStrWithStr (Jim_Interp *interp,
const char *name, const char *val);
JIM_EXPORT int Jim_SetVariableLink (Jim_Interp *interp,
Jim_Obj *nameObjPtr, Jim_Obj *targetNameObjPtr,
Jim_CallFrame *targetCallFrame);
| | | < | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 |
JIM_EXPORT int Jim_SetGlobalVariableStr (Jim_Interp *interp,
const char *name, Jim_Obj *objPtr);
JIM_EXPORT int Jim_SetVariableStrWithStr (Jim_Interp *interp,
const char *name, const char *val);
JIM_EXPORT int Jim_SetVariableLink (Jim_Interp *interp,
Jim_Obj *nameObjPtr, Jim_Obj *targetNameObjPtr,
Jim_CallFrame *targetCallFrame);
JIM_EXPORT Jim_Obj * Jim_MakeGlobalNamespaceName(Jim_Interp *interp,
Jim_Obj *nameObjPtr);
JIM_EXPORT Jim_Obj * Jim_GetVariable (Jim_Interp *interp,
Jim_Obj *nameObjPtr, int flags);
JIM_EXPORT Jim_Obj * Jim_GetGlobalVariable (Jim_Interp *interp,
Jim_Obj *nameObjPtr, int flags);
JIM_EXPORT Jim_Obj * Jim_GetVariableStr (Jim_Interp *interp,
const char *name, int flags);
JIM_EXPORT Jim_Obj * Jim_GetGlobalVariableStr (Jim_Interp *interp,
|
| ︙ | ︙ | |||
802 803 804 805 806 807 808 809 810 811 812 813 814 815 |
JIM_EXPORT int Jim_DictPairs(Jim_Interp *interp,
Jim_Obj *dictPtr, Jim_Obj ***objPtrPtr, int *len);
JIM_EXPORT int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr);
JIM_EXPORT int Jim_DictKeys(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj);
JIM_EXPORT int Jim_DictValues(Jim_Interp *interp, Jim_Obj *dictObjPtr, Jim_Obj *patternObjPtr);
JIM_EXPORT int Jim_DictSize(Jim_Interp *interp, Jim_Obj *objPtr);
JIM_EXPORT int Jim_GetReturnCode (Jim_Interp *interp, Jim_Obj *objPtr,
int *intPtr);
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
| > | 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 |
JIM_EXPORT int Jim_DictPairs(Jim_Interp *interp,
Jim_Obj *dictPtr, Jim_Obj ***objPtrPtr, int *len);
JIM_EXPORT int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr);
JIM_EXPORT int Jim_DictKeys(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *patternObj);
JIM_EXPORT int Jim_DictValues(Jim_Interp *interp, Jim_Obj *dictObjPtr, Jim_Obj *patternObjPtr);
JIM_EXPORT int Jim_DictSize(Jim_Interp *interp, Jim_Obj *objPtr);
JIM_EXPORT int Jim_DictInfo(Jim_Interp *interp, Jim_Obj *objPtr);
JIM_EXPORT int Jim_GetReturnCode (Jim_Interp *interp, Jim_Obj *objPtr,
int *intPtr);
JIM_EXPORT int Jim_EvalExpression (Jim_Interp *interp,
|
| ︙ | ︙ | |||
867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 | JIM_EXPORT void Jim_HistoryAdd(const char *line); JIM_EXPORT void Jim_HistoryShow(void); JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); JIM_EXPORT int Jim_IsBigEndian(void); #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); JIM_EXPORT FILE *Jim_AioFilehandle(Jim_Interp *interp, Jim_Obj *command); | > < | 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 | JIM_EXPORT void Jim_HistoryAdd(const char *line); JIM_EXPORT void Jim_HistoryShow(void); JIM_EXPORT int Jim_InitStaticExtensions(Jim_Interp *interp); JIM_EXPORT int Jim_StringToWide(const char *str, jim_wide *widePtr, int base); JIM_EXPORT int Jim_IsBigEndian(void); #define Jim_CheckSignal(i) ((i)->signal_level && (i)->sigmask) JIM_EXPORT int Jim_LoadLibrary(Jim_Interp *interp, const char *pathName); JIM_EXPORT void Jim_FreeLoadHandles(Jim_Interp *interp); JIM_EXPORT FILE *Jim_AioFilehandle(Jim_Interp *interp, Jim_Obj *command); JIM_EXPORT int Jim_IsDict(Jim_Obj *objPtr); JIM_EXPORT int Jim_IsList(Jim_Obj *objPtr); #ifdef __cplusplus } |
| ︙ | ︙ | |||
901 902 903 904 905 906 907 | #define JIM_MODFLAG_HIDDEN 0x0001 #define JIM_MODFLAG_FULLARGV 0x0002 | | | < < < < | < | | < | 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 |
#define JIM_MODFLAG_HIDDEN 0x0001
#define JIM_MODFLAG_FULLARGV 0x0002
typedef int jim_subcmd_function(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
typedef struct {
const char *cmd;
const char *args;
jim_subcmd_function *function;
short minargs;
short maxargs;
unsigned short flags;
} jim_subcmd_type;
const jim_subcmd_type *
Jim_ParseSubCmd(Jim_Interp *interp, const jim_subcmd_type *command_table, int argc, Jim_Obj *const *argv);
int Jim_SubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
int Jim_CallSubCmd(Jim_Interp *interp, const jim_subcmd_type *ct, int argc, Jim_Obj *const *argv);
#ifdef __cplusplus
}
#endif
#endif
#ifndef JIMREGEXP_H
#define JIMREGEXP_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
typedef struct {
int rm_so;
int rm_eo;
} regmatch_t;
|
| ︙ | ︙ | |||
1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 |
};
int regcomp(regex_t *preg, const char *regex, int cflags);
int regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size);
void regfree(regex_t *preg);
#endif
#endif
int Jim_bootstrapInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "bootstrap", "1.0", JIM_ERRMSG))
return JIM_ERR;
| > > | 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 |
};
int regcomp(regex_t *preg, const char *regex, int cflags);
int regexec(regex_t *preg, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags);
size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size);
void regfree(regex_t *preg);
#ifdef __cplusplus
}
#endif
#endif
int Jim_bootstrapInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "bootstrap", "1.0", JIM_ERRMSG))
return JIM_ERR;
|
| ︙ | ︙ | |||
1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 |
"\n"
"\n"
"\n"
"package require readdir\n"
"\n"
"\n"
"proc glob.globdir {dir pattern} {\n"
" set result {}\n"
" set files [readdir $dir]\n"
" lappend files . ..\n"
"\n"
" foreach name $files {\n"
" if {[string match $pattern $name]} {\n"
"\n"
| > > > > > | 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 |
"\n"
"\n"
"\n"
"package require readdir\n"
"\n"
"\n"
"proc glob.globdir {dir pattern} {\n"
" if {[file exists $dir/$pattern]} {\n"
"\n"
" return $pattern\n"
" }\n"
"\n"
" set result {}\n"
" set files [readdir $dir]\n"
" lappend files . ..\n"
"\n"
" foreach name $files {\n"
" if {[string match $pattern $name]} {\n"
"\n"
|
| ︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 |
}
int Jim_stdlibInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "stdlib", "1.0", JIM_ERRMSG))
return JIM_ERR;
return Jim_EvalSource(interp, "stdlib.tcl", 1,
"\n"
"proc lambda {arglist args} {\n"
" tailcall proc [ref {} function lambda.finalizer] $arglist {*}$args\n"
"}\n"
"\n"
"proc lambda.finalizer {name val} {\n"
" rename $name {}\n"
| > > | 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 |
}
int Jim_stdlibInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "stdlib", "1.0", JIM_ERRMSG))
return JIM_ERR;
return Jim_EvalSource(interp, "stdlib.tcl", 1,
"\n"
"\n"
"\n"
"proc lambda {arglist args} {\n"
" tailcall proc [ref {} function lambda.finalizer] $arglist {*}$args\n"
"}\n"
"\n"
"proc lambda.finalizer {name val} {\n"
" rename $name {}\n"
|
| ︙ | ︙ | |||
1288 1289 1290 1291 1292 1293 1294 |
"proc function {value} {\n"
" return $value\n"
"}\n"
"\n"
"\n"
"\n"
"\n"
| | > | < | < | < < | < | | | > > > | > > > | 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 |
"proc function {value} {\n"
" return $value\n"
"}\n"
"\n"
"\n"
"\n"
"\n"
"proc stacktrace {{skip 0}} {\n"
" set trace {}\n"
" incr skip\n"
" foreach level [range $skip [info level]] {\n"
" lappend trace {*}[info frame -$level]\n"
" }\n"
" return $trace\n"
"}\n"
"\n"
"\n"
"proc stackdump {stacktrace} {\n"
" set lines {}\n"
" foreach {l f p} [lreverse $stacktrace] {\n"
" set line {}\n"
" if {$p ne \"\"} {\n"
" append line \"in procedure '$p' \"\n"
" if {$f ne \"\"} {\n"
" append line \"called \"\n"
" }\n"
" }\n"
" if {$f ne \"\"} {\n"
" append line \"at file \\\"$f\\\", line $l\"\n"
" }\n"
" if {$line ne \"\"} {\n"
" lappend lines $line\n"
" }\n"
" }\n"
" join $lines \\n\n"
"}\n"
"\n"
"\n"
"\n"
"proc errorInfo {msg {stacktrace \"\"}} {\n"
" if {$stacktrace eq \"\"} {\n"
"\n"
" set stacktrace [info stacktrace]\n"
"\n"
" lappend stacktrace {*}[stacktrace 1]\n"
" }\n"
" lassign $stacktrace p f l\n"
" if {$f ne \"\"} {\n"
" set result \"Runtime Error: $f:$l: \"\n"
" }\n"
" append result \"$msg\\n\"\n"
" append result [stackdump $stacktrace]\n"
|
| ︙ | ︙ | |||
1354 1355 1356 1357 1358 1359 1360 | " }\n" " }\n" " }\n" " return \"\"\n" "}\n" "\n" "\n" | | < | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 |
" }\n"
" }\n"
" }\n"
" return \"\"\n"
"}\n"
"\n"
"\n"
"proc {dict with} {&dictVar {args key} script} {\n"
" set keys {}\n"
" foreach {n v} [dict get $dictVar {*}$key] {\n"
" upvar $n var_$n\n"
" set var_$n $v\n"
" lappend keys $n\n"
" }\n"
" catch {uplevel 1 $script} msg opts\n"
" if {[info exists dictVar] && ([llength $key] == 0 || [dict exists $dictVar {*}$key])} {\n"
" foreach n $keys {\n"
" if {[info exists var_$n]} {\n"
" dict set dictVar {*}$key $n [set var_$n]\n"
" } else {\n"
" dict unset dictVar {*}$key $n\n"
" }\n"
" }\n"
" }\n"
" return {*}$opts $msg\n"
"}\n"
"\n"
"\n"
"proc {dict update} {&varName args script} {\n"
" set keys {}\n"
" foreach {n v} $args {\n"
" upvar $v var_$v\n"
" if {[dict exists $varName $n]} {\n"
" set var_$v [dict get $varName $n]\n"
" }\n"
" }\n"
" catch {uplevel 1 $script} msg opts\n"
" if {[info exists varName]} {\n"
" foreach {n v} $args {\n"
" if {[info exists var_$v]} {\n"
" dict set varName $n [set var_$v]\n"
" } else {\n"
" dict unset varName $n\n"
" }\n"
" }\n"
" }\n"
" return {*}$opts $msg\n"
"}\n"
"\n"
"\n"
"\n"
"proc {dict merge} {dict args} {\n"
" foreach d $args {\n"
"\n"
" dict size $d\n"
" foreach {k v} $d {\n"
" dict set dict $k $v\n"
" }\n"
" }\n"
" return $dict\n"
"}\n"
"\n"
"proc {dict replace} {dictionary {args {key value}}} {\n"
" if {[llength ${key value}] % 2} {\n"
" tailcall {dict replace}\n"
" }\n"
" tailcall dict merge $dictionary ${key value}\n"
"}\n"
"\n"
"\n"
"proc {dict lappend} {varName key {args value}} {\n"
" upvar $varName dict\n"
" if {[exists dict] && [dict exists $dict $key]} {\n"
" set list [dict get $dict $key]\n"
" }\n"
" lappend list {*}$value\n"
" dict set dict $key $list\n"
"}\n"
"\n"
"\n"
"proc {dict append} {varName key {args value}} {\n"
" upvar $varName dict\n"
" if {[exists dict] && [dict exists $dict $key]} {\n"
" set str [dict get $dict $key]\n"
" }\n"
" append str {*}$value\n"
" dict set dict $key $str\n"
"}\n"
"\n"
"\n"
"proc {dict incr} {varName key {increment 1}} {\n"
" upvar $varName dict\n"
" if {[exists dict] && [dict exists $dict $key]} {\n"
" set value [dict get $dict $key]\n"
" }\n"
" incr value $increment\n"
" dict set dict $key $value\n"
"}\n"
"\n"
"\n"
"proc {dict remove} {dictionary {args key}} {\n"
" foreach k $key {\n"
" dict unset dictionary $k\n"
" }\n"
" return $dictionary\n"
"}\n"
"\n"
"\n"
"proc {dict values} {dictionary {pattern *}} {\n"
" dict keys [lreverse $dictionary] $pattern\n"
"}\n"
"\n"
"\n"
"proc {dict for} {vars dictionary script} {\n"
" if {[llength $vars] != 2} {\n"
" return -code error \"must have exactly two variable names\"\n"
" }\n"
" dict size $dictionary\n"
" tailcall foreach $vars $dictionary $script\n"
"}\n"
);
}
int Jim_tclcompatInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "tclcompat", "1.0", JIM_ERRMSG))
return JIM_ERR;
return Jim_EvalSource(interp, "tclcompat.tcl", 1,
"\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"\n"
"set env [env]\n"
"\n"
"\n"
"if {[info commands stdout] ne \"\"} {\n"
"\n"
" foreach p {gets flush close eof seek tell} {\n"
" proc $p {chan args} {p} {\n"
" tailcall $chan $p {*}$args\n"
" }\n"
|
| ︙ | ︙ | |||
1453 1454 1455 1456 1457 1458 1459 | " return -code error \"fconfigure: unknown option $n\"\n" " }\n" " }\n" " }\n" " }\n" "}\n" "\n" | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 |
" return -code error \"fconfigure: unknown option $n\"\n"
" }\n"
" }\n"
" }\n"
" }\n"
"}\n"
"\n"
"\n"
"proc fileevent {args} {\n"
" tailcall {*}$args\n"
"}\n"
"\n"
"\n"
"\n"
|
| ︙ | ︙ | |||
1527 1528 1529 1530 1531 1532 1533 |
" try {\n"
" if {$force ni {{} -force}} {\n"
" error \"bad option \\\"$force\\\": should be -force\"\n"
" }\n"
"\n"
" set in [open $source]\n"
"\n"
| | | | > > > > > > > > > > > > | 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 |
" try {\n"
" if {$force ni {{} -force}} {\n"
" error \"bad option \\\"$force\\\": should be -force\"\n"
" }\n"
"\n"
" set in [open $source]\n"
"\n"
" if {[file exists $target]} {\n"
" if {$force eq \"\"} {\n"
" error \"error copying \\\"$source\\\" to \\\"$target\\\": file already exists\"\n"
" }\n"
"\n"
" if {$source eq $target} {\n"
" return\n"
" }\n"
"\n"
"\n"
" file stat $source ss\n"
" file stat $target ts\n"
" if {$ss(dev) == $ts(dev) && $ss(ino) == $ts(ino) && $ss(ino)} {\n"
" return\n"
" }\n"
" }\n"
" set out [open $target w]\n"
" $in copyto $out\n"
" $out close\n"
" } on error {msg opts} {\n"
" incr opts(-level)\n"
" return {*}$opts $msg\n"
|
| ︙ | ︙ | |||
1578 1579 1580 1581 1582 1583 1584 | " $r close\n" " $w close\n" " error $error\n" " }\n" "}\n" "\n" "\n" | | | | | | | 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 |
" $r close\n"
" $w close\n"
" error $error\n"
" }\n"
"}\n"
"\n"
"\n"
"local proc pid {{channelId {}}} {\n"
" if {$channelId eq \"\"} {\n"
" tailcall upcall pid\n"
" }\n"
" if {[catch {$channelId tell}]} {\n"
" return -code error \"can not find channel named \\\"$channelId\\\"\"\n"
" }\n"
" if {[catch {$channelId pid} pids]} {\n"
" return \"\"\n"
" }\n"
" return $pids\n"
"}\n"
"\n"
"\n"
"\n"
|
| ︙ | ︙ | |||
1678 1679 1680 1681 1682 1683 1684 | " }\n" " file delete $path\n" "}\n" ); } | < > > > > < | 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 | " }\n" " file delete $path\n" "}\n" ); } #include <stdio.h> #include <string.h> #include <errno.h> #include <fcntl.h> #ifdef HAVE_UNISTD_H #include <unistd.h> #include <sys/stat.h> #endif #if defined(HAVE_SYS_SOCKET_H) && defined(HAVE_SELECT) && defined(HAVE_NETINET_IN_H) && defined(HAVE_NETDB_H) && defined(HAVE_ARPA_INET_H) #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <netdb.h> #ifdef HAVE_SYS_UN_H #include <sys/un.h> #endif #else #define JIM_ANSIC #endif |
| ︙ | ︙ | |||
1726 1727 1728 1729 1730 1731 1732 |
typedef struct AioFile
{
FILE *fp;
Jim_Obj *filename;
int type;
| | < < < | 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 |
typedef struct AioFile
{
FILE *fp;
Jim_Obj *filename;
int type;
int openFlags;
int fd;
Jim_Obj *rEvent;
Jim_Obj *wEvent;
Jim_Obj *eEvent;
int addr_family;
} AioFile;
static int JimAioSubCmdProc(Jim_Interp *interp, int argc, Jim_Obj *const *argv);
|
| ︙ | ︙ | |||
1758 1759 1760 1761 1762 1763 1764 |
static void JimAioDelProc(Jim_Interp *interp, void *privData)
{
AioFile *af = privData;
JIM_NOTUSED(interp);
| < < < < > > > > > | 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 |
static void JimAioDelProc(Jim_Interp *interp, void *privData)
{
AioFile *af = privData;
JIM_NOTUSED(interp);
Jim_DecrRefCount(interp, af->filename);
#ifdef jim_ext_eventloop
Jim_DeleteFileHandler(interp, af->fp, JIM_EVENT_READABLE | JIM_EVENT_WRITABLE | JIM_EVENT_EXCEPTION);
#endif
if (!(af->openFlags & AIO_KEEPOPEN)) {
fclose(af->fp);
}
Jim_Free(af);
}
static int JimCheckStreamError(Jim_Interp *interp, AioFile *af)
{
if (!ferror(af->fp)) {
return JIM_OK;
|
| ︙ | ︙ | |||
2018 2019 2020 2021 2022 2023 2024 |
Jim_SetResultInt(interp, feof(af->fp));
return JIM_OK;
}
static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| > > > > > > | > > > > | > > > > > > > > > | 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 |
Jim_SetResultInt(interp, feof(af->fp));
return JIM_OK;
}
static int aio_cmd_close(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc == 3) {
#if !defined(JIM_ANSIC) && defined(HAVE_SHUTDOWN)
static const char * const options[] = { "r", "w", NULL };
enum { OPT_R, OPT_W, };
int option;
AioFile *af = Jim_CmdPrivData(interp);
if (Jim_GetEnum(interp, argv[2], options, &option, NULL, JIM_ERRMSG) != JIM_OK) {
return JIM_ERR;
}
if (shutdown(af->fd, option == OPT_R ? SHUT_RD : SHUT_WR) == 0) {
return JIM_OK;
}
JimAioSetError(interp, NULL);
#else
Jim_SetResultString(interp, "async close not supported", -1);
#endif
return JIM_ERR;
}
return Jim_DeleteCommand(interp, Jim_String(argv[0]));
}
static int aio_cmd_seek(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
int orig = SEEK_SET;
jim_wide offset;
|
| ︙ | ︙ | |||
2070 2071 2072 2073 2074 2075 2076 |
}
#ifdef O_NDELAY
static int aio_cmd_ndelay(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
| | | < | 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 |
}
#ifdef O_NDELAY
static int aio_cmd_ndelay(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
int fmode = fcntl(af->fd, F_GETFL);
if (argc) {
long nb;
if (Jim_GetLong(interp, argv[0], &nb) != JIM_OK) {
return JIM_ERR;
}
if (nb) {
fmode |= O_NDELAY;
}
else {
fmode &= ~O_NDELAY;
}
(void)fcntl(af->fd, F_SETFL, fmode);
}
Jim_SetResultInt(interp, (fmode & O_NONBLOCK) ? 1 : 0);
return JIM_OK;
}
#endif
static int aio_cmd_buffering(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
|
| ︙ | ︙ | |||
2193 2194 2195 2196 2197 2198 2199 |
return aio_eventinfo(interp, af, JIM_EVENT_WRITABLE, &af->wEvent, argc, argv);
}
static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
| | | 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 |
return aio_eventinfo(interp, af, JIM_EVENT_WRITABLE, &af->wEvent, argc, argv);
}
static int aio_cmd_onexception(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
AioFile *af = Jim_CmdPrivData(interp);
return aio_eventinfo(interp, af, JIM_EVENT_EXCEPTION, &af->eEvent, argc, argv);
}
#endif
static const jim_subcmd_type aio_command_table[] = {
{ "read",
"?-nonewline? ?len?",
aio_cmd_read,
|
| ︙ | ︙ | |||
2248 2249 2250 2251 2252 2253 2254 |
NULL,
aio_cmd_eof,
0,
0,
},
{ "close",
| < > < > | 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 |
NULL,
aio_cmd_eof,
0,
0,
},
{ "close",
"?r(ead)|w(rite)?",
aio_cmd_close,
0,
1,
JIM_MODFLAG_FULLARGV,
},
{ "seek",
"offset ?start|current|end",
aio_cmd_seek,
1,
|
| ︙ | ︙ | |||
2327 2328 2329 2330 2331 2332 2333 |
return Jim_CallSubCmd(interp, Jim_ParseSubCmd(interp, aio_command_table, argc, argv), argc, argv);
}
static int JimAioOpenCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
const char *mode;
| < < | > > > | | | | | | > | | > > | < < < < | | > | < | | | | | | | > | | | < < < > | > | > > > > > > > > > > > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 |
return Jim_CallSubCmd(interp, Jim_ParseSubCmd(interp, aio_command_table, argc, argv), argc, argv);
}
static int JimAioOpenCommand(Jim_Interp *interp, int argc,
Jim_Obj *const *argv)
{
const char *mode;
if (argc != 2 && argc != 3) {
Jim_WrongNumArgs(interp, 1, argv, "filename ?mode?");
return JIM_ERR;
}
mode = (argc == 3) ? Jim_String(argv[2]) : "r";
#ifdef jim_ext_tclcompat
{
const char *filename = Jim_String(argv[1]);
if (*filename == '|') {
Jim_Obj *evalObj[3];
evalObj[0] = Jim_NewStringObj(interp, "::popen", -1);
evalObj[1] = Jim_NewStringObj(interp, filename + 1, -1);
evalObj[2] = Jim_NewStringObj(interp, mode, -1);
return Jim_EvalObjVector(interp, 3, evalObj);
}
}
#endif
return JimMakeChannel(interp, NULL, -1, argv[1], "aio.handle%ld", 0, mode);
}
static int JimMakeChannel(Jim_Interp *interp, FILE *fh, int fd, Jim_Obj *filename,
const char *hdlfmt, int family, const char *mode)
{
AioFile *af;
char buf[AIO_CMD_LEN];
int openFlags = 0;
if (fh) {
filename = Jim_NewStringObj(interp, hdlfmt, -1);
openFlags = AIO_KEEPOPEN;
}
Jim_IncrRefCount(filename);
if (fh == NULL) {
#if !defined(JIM_ANSIC)
if (fd >= 0) {
fh = fdopen(fd, mode);
}
else
#endif
fh = fopen(Jim_String(filename), mode);
if (fh == NULL) {
JimAioSetError(interp, filename);
#if !defined(JIM_ANSIC)
if (fd >= 0) {
close(fd);
}
#endif
Jim_DecrRefCount(interp, filename);
return JIM_ERR;
}
}
af = Jim_Alloc(sizeof(*af));
memset(af, 0, sizeof(*af));
af->fp = fh;
af->fd = fileno(fh);
af->filename = filename;
#ifdef FD_CLOEXEC
if ((openFlags & AIO_KEEPOPEN) == 0) {
(void)fcntl(af->fd, F_SETFD, FD_CLOEXEC);
}
#endif
af->openFlags = openFlags;
af->addr_family = family;
snprintf(buf, sizeof(buf), hdlfmt, Jim_GetId(interp));
Jim_CreateCommand(interp, buf, JimAioSubCmdProc, af, JimAioDelProc);
Jim_SetResult(interp, Jim_MakeGlobalNamespaceName(interp, Jim_NewStringObj(interp, buf, -1)));
return JIM_OK;
}
static int JimMakeChannelPair(Jim_Interp *interp, int p[2], Jim_Obj *filename,
const char *hdlfmt, int family, const char *mode[2])
{
if (JimMakeChannel(interp, NULL, p[0], filename, hdlfmt, family, mode[0]) == JIM_OK) {
Jim_Obj *objPtr = Jim_NewListObj(interp, NULL, 0);
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
if (JimMakeChannel(interp, NULL, p[1], filename, hdlfmt, family, mode[1]) == JIM_OK) {
Jim_ListAppendElement(interp, objPtr, Jim_GetResult(interp));
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
}
close(p[0]);
close(p[1]);
JimAioSetError(interp, NULL);
return JIM_ERR;
}
int Jim_MakeTempFile(Jim_Interp *interp, const char *template)
{
#ifdef HAVE_MKSTEMP
int fd;
mode_t mask;
Jim_Obj *filenameObj;
if (template == NULL) {
const char *tmpdir = getenv("TMPDIR");
if (tmpdir == NULL || *tmpdir == '\0' || access(tmpdir, W_OK) != 0) {
tmpdir = "/tmp/";
}
filenameObj = Jim_NewStringObj(interp, tmpdir, -1);
if (tmpdir[0] && tmpdir[strlen(tmpdir) - 1] != '/') {
Jim_AppendString(interp, filenameObj, "/", 1);
}
Jim_AppendString(interp, filenameObj, "tcl.tmp.XXXXXX", -1);
}
else {
filenameObj = Jim_NewStringObj(interp, template, -1);
}
mask = umask(S_IXUSR | S_IRWXG | S_IRWXO);
fd = mkstemp(filenameObj->bytes);
umask(mask);
if (fd < 0) {
Jim_SetResultString(interp, "Failed to create tempfile", -1);
Jim_FreeNewObj(interp, filenameObj);
return -1;
}
Jim_SetResult(interp, filenameObj);
return fd;
#else
Jim_SetResultString(interp, "tempfile not supported", -1);
return -1;
#endif
}
FILE *Jim_AioFilehandle(Jim_Interp *interp, Jim_Obj *command)
{
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, command, JIM_ERRMSG);
if (cmdPtr && !cmdPtr->isproc && cmdPtr->u.native.cmdProc == JimAioSubCmdProc) {
return ((AioFile *) cmdPtr->u.native.privData)->fp;
}
Jim_SetResultFormatted(interp, "Not a filehandle: \"%#s\"", command);
return NULL;
}
|
| ︙ | ︙ | |||
2441 2442 2443 2444 2445 2446 2447 |
JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
return JIM_OK;
}
| < | 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 |
JimMakeChannel(interp, stdin, -1, NULL, "stdin", 0, "r");
JimMakeChannel(interp, stdout, -1, NULL, "stdout", 0, "w");
JimMakeChannel(interp, stderr, -1, NULL, "stderr", 0, "w");
return JIM_OK;
}
#include <errno.h>
#include <stdio.h>
#include <string.h>
#ifdef HAVE_DIRENT_H
|
| ︙ | ︙ | |||
2477 2478 2479 2480 2481 2482 2483 |
if (dirPtr == NULL) {
if (nocomplain) {
return JIM_OK;
}
Jim_SetResultString(interp, strerror(errno), -1);
return JIM_ERR;
}
| < | | | | | | | | | | | < | | > > | > > > > > | 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 |
if (dirPtr == NULL) {
if (nocomplain) {
return JIM_OK;
}
Jim_SetResultString(interp, strerror(errno), -1);
return JIM_ERR;
}
else {
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
while ((entryPtr = readdir(dirPtr)) != NULL) {
if (entryPtr->d_name[0] == '.') {
if (entryPtr->d_name[1] == '\0') {
continue;
}
if ((entryPtr->d_name[1] == '.') && (entryPtr->d_name[2] == '\0'))
continue;
}
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, entryPtr->d_name, -1));
}
closedir(dirPtr);
Jim_SetResult(interp, listObj);
return JIM_OK;
}
}
int Jim_readdirInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "readdir", "1.0", JIM_ERRMSG))
return JIM_ERR;
Jim_CreateCommand(interp, "readdir", Jim_ReaddirCmd, NULL, NULL);
return JIM_OK;
}
#include <stdlib.h>
#include <string.h>
#if defined(JIM_REGEXP)
#else
#include <regex.h>
#endif
static void FreeRegexpInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
{
regfree(objPtr->internalRep.regexpValue.compre);
Jim_Free(objPtr->internalRep.regexpValue.compre);
}
|
| ︙ | ︙ | |||
3056 3057 3058 3059 3060 3061 3062 |
else if (S_ISSOCK(mode)) {
return "socket";
}
#endif
return "unknown";
}
| | < < | < | < < < < < < < < < < < < < < < < < < < < | > > > > > > > > > > > > > > > > > > > > > | > | | | > | | | | | > | | > > | < | | > | | 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 |
else if (S_ISSOCK(mode)) {
return "socket";
}
#endif
return "unknown";
}
static void AppendStatElement(Jim_Interp *interp, Jim_Obj *listObj, const char *key, jim_wide value)
{
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, key, -1));
Jim_ListAppendElement(interp, listObj, Jim_NewIntObj(interp, value));
}
static int StoreStatData(Jim_Interp *interp, Jim_Obj *varName, const struct stat *sb)
{
Jim_Obj *listObj = Jim_NewListObj(interp, NULL, 0);
AppendStatElement(interp, listObj, "dev", sb->st_dev);
AppendStatElement(interp, listObj, "ino", sb->st_ino);
AppendStatElement(interp, listObj, "mode", sb->st_mode);
AppendStatElement(interp, listObj, "nlink", sb->st_nlink);
AppendStatElement(interp, listObj, "uid", sb->st_uid);
AppendStatElement(interp, listObj, "gid", sb->st_gid);
AppendStatElement(interp, listObj, "size", sb->st_size);
AppendStatElement(interp, listObj, "atime", sb->st_atime);
AppendStatElement(interp, listObj, "mtime", sb->st_mtime);
AppendStatElement(interp, listObj, "ctime", sb->st_ctime);
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, "type", -1));
Jim_ListAppendElement(interp, listObj, Jim_NewStringObj(interp, JimGetFileType((int)sb->st_mode), -1));
if (varName) {
Jim_Obj *objPtr = Jim_GetVariable(interp, varName, JIM_NONE);
if (objPtr) {
if (Jim_DictSize(interp, objPtr) < 0) {
Jim_SetResultFormatted(interp, "can't set \"%#s(dev)\": variable isn't array", varName);
Jim_FreeNewObj(interp, listObj);
return JIM_ERR;
}
if (Jim_IsShared(objPtr))
objPtr = Jim_DuplicateObj(interp, objPtr);
Jim_ListAppendList(interp, objPtr, listObj);
Jim_DictSize(interp, objPtr);
Jim_InvalidateStringRep(objPtr);
Jim_FreeNewObj(interp, listObj);
listObj = objPtr;
}
Jim_SetVariable(interp, varName, listObj);
}
Jim_SetResult(interp, listObj);
return JIM_OK;
}
static int file_cmd_dirname(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
const char *path = Jim_String(argv[0]);
|
| ︙ | ︙ | |||
3262 3263 3264 3265 3266 3267 3268 |
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));
return JIM_OK;
}
static int file_access(Jim_Interp *interp, Jim_Obj *filename, int mode)
{
| < < < | > | 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 |
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, newname, last - newname));
return JIM_OK;
}
static int file_access(Jim_Interp *interp, Jim_Obj *filename, int mode)
{
Jim_SetResultBool(interp, access(Jim_String(filename), mode) != -1);
return JIM_OK;
}
static int file_cmd_readable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
return file_access(interp, argv[0], R_OK);
}
static int file_cmd_writable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
return file_access(interp, argv[0], W_OK);
}
static int file_cmd_executable(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
#ifdef X_OK
return file_access(interp, argv[0], X_OK);
#else
Jim_SetResultBool(interp, 1);
return JIM_OK;
#endif
}
static int file_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
|
| ︙ | ︙ | |||
3389 3390 3391 3392 3393 3394 3395 |
return JIM_ERR;
}
argv++;
}
return JIM_OK;
}
| < < < < | < < | < < < < < < | 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 |
return JIM_ERR;
}
argv++;
}
return JIM_OK;
}
static int file_cmd_tempfile(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int fd = Jim_MakeTempFile(interp, (argc >= 1) ? Jim_String(argv[0]) : NULL);
if (fd < 0) {
return JIM_ERR;
}
close(fd);
return JIM_OK;
}
static int file_cmd_rename(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
const char *source;
const char *dest;
int force = 0;
|
| ︙ | ︙ | |||
3457 3458 3459 3460 3461 3462 3463 |
if (stat(path, sb) == -1) {
Jim_SetResultFormatted(interp, "could not read \"%#s\": %s", filename, strerror(errno));
return JIM_ERR;
}
return JIM_OK;
}
| | < < < > > > | 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 |
if (stat(path, sb) == -1) {
Jim_SetResultFormatted(interp, "could not read \"%#s\": %s", filename, strerror(errno));
return JIM_ERR;
}
return JIM_OK;
}
#ifdef HAVE_LSTAT
static int file_lstat(Jim_Interp *interp, Jim_Obj *filename, struct stat *sb)
{
const char *path = Jim_String(filename);
if (lstat(path, sb) == -1) {
Jim_SetResultFormatted(interp, "could not read \"%#s\": %s", filename, strerror(errno));
return JIM_ERR;
}
return JIM_OK;
}
#else
#define file_lstat file_stat
#endif
static int file_cmd_atime(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct stat sb;
if (file_stat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
|
| ︙ | ︙ | |||
3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 |
if (file_lstat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
}
Jim_SetResultString(interp, JimGetFileType((int)sb.st_mode), -1);
return JIM_OK;
}
static int file_cmd_lstat(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct stat sb;
if (file_lstat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
}
| > | > > > | | 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 |
if (file_lstat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
}
Jim_SetResultString(interp, JimGetFileType((int)sb.st_mode), -1);
return JIM_OK;
}
#ifdef HAVE_LSTAT
static int file_cmd_lstat(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct stat sb;
if (file_lstat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
}
return StoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb);
}
#else
#define file_cmd_lstat file_cmd_stat
#endif
static int file_cmd_stat(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
struct stat sb;
if (file_stat(interp, argv[0], &sb) != JIM_OK) {
return JIM_ERR;
}
return StoreStatData(interp, argc == 2 ? argv[1] : NULL, &sb);
}
static const jim_subcmd_type file_command_table[] = {
{ "atime",
"name",
file_cmd_atime,
1,
|
| ︙ | ︙ | |||
3725 3726 3727 3728 3729 3730 3731 |
{ "mkdir",
"dir ...",
file_cmd_mkdir,
1,
-1,
},
| < < | 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 |
{ "mkdir",
"dir ...",
file_cmd_mkdir,
1,
-1,
},
{ "tempfile",
"?template?",
file_cmd_tempfile,
0,
1,
},
{ "rename",
"?-force? source dest",
file_cmd_rename,
2,
3,
},
|
| ︙ | ︙ | |||
3758 3759 3760 3761 3762 3763 3764 |
"name",
file_cmd_size,
1,
1,
},
{ "stat",
| | < > | < > | 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 |
"name",
file_cmd_size,
1,
1,
},
{ "stat",
"name ?var?",
file_cmd_stat,
1,
2,
},
{ "lstat",
"name ?var?",
file_cmd_lstat,
1,
2,
},
{ "type",
"name",
file_cmd_type,
1,
|
| ︙ | ︙ | |||
3827 3828 3829 3830 3831 3832 3833 |
return JIM_ERR;
}
return JIM_OK;
}
static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| < | | > | | 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 |
return JIM_ERR;
}
return JIM_OK;
}
static int Jim_PwdCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
char *cwd = Jim_Alloc(MAXPATHLEN);
if (getcwd(cwd, MAXPATHLEN) == NULL) {
Jim_SetResultString(interp, "Failed to get pwd", -1);
Jim_Free(cwd);
return JIM_ERR;
}
#if defined(__MINGW32__) || defined(_MSC_VER)
{
char *p = cwd;
while ((p = strchr(p, '\\')) != NULL) {
*p++ = '/';
}
}
#endif
Jim_SetResultString(interp, cwd, -1);
Jim_Free(cwd);
return JIM_OK;
}
int Jim_fileInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "file", "1.0", JIM_ERRMSG))
return JIM_ERR;
|
| ︙ | ︙ | |||
3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 |
return JIM_OK;
}
int Jim_execInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "exec", "1.0", JIM_ERRMSG))
return JIM_ERR;
Jim_CreateCommand(interp, "exec", Jim_ExecCmd, NULL, NULL);
return JIM_OK;
}
#else
#include <errno.h>
| > | 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 |
return JIM_OK;
}
int Jim_execInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "exec", "1.0", JIM_ERRMSG))
return JIM_ERR;
Jim_CreateCommand(interp, "exec", Jim_ExecCmd, NULL, NULL);
return JIM_OK;
}
#else
#include <errno.h>
|
| ︙ | ︙ | |||
3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 |
static pidtype JimStartWinProcess(Jim_Interp *interp, char **argv, char *env,
fdtype inputId, fdtype outputId, fdtype errorId);
static int JimErrno(void);
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
typedef int fdtype;
typedef int pidtype;
#define JimPipe pipe
#define JimErrno() errno
#define JIM_BAD_FD -1
#define JIM_BAD_PID -1
| > | 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 |
static pidtype JimStartWinProcess(Jim_Interp *interp, char **argv, char *env,
fdtype inputId, fdtype outputId, fdtype errorId);
static int JimErrno(void);
#else
#include <unistd.h>
#include <fcntl.h>
#include <sys/wait.h>
#include <sys/stat.h>
typedef int fdtype;
typedef int pidtype;
#define JimPipe pipe
#define JimErrno() errno
#define JIM_BAD_FD -1
#define JIM_BAD_PID -1
|
| ︙ | ︙ | |||
4032 4033 4034 4035 4036 4037 4038 |
}
}
Jim_RemoveTrailingNewline(strObj);
fclose(fh);
return JIM_OK;
}
| < < < < < < < < < < < > | 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 |
}
}
Jim_RemoveTrailingNewline(strObj);
fclose(fh);
return JIM_OK;
}
static char **JimBuildEnv(Jim_Interp *interp)
{
int i;
int size;
int num;
int n;
char **envptr;
char *envdata;
Jim_Obj *objPtr = Jim_GetGlobalVariableStr(interp, "env", JIM_NONE);
if (!objPtr) {
return Jim_GetEnviron();
}
num = Jim_ListLength(interp, objPtr);
if (num % 2) {
num--;
}
size = Jim_Length(objPtr) + 2;
envptr = Jim_Alloc(sizeof(*envptr) * (num / 2 + 1) + size);
envdata = (char *)&envptr[num / 2 + 1];
|
| ︙ | ︙ | |||
4088 4089 4090 4091 4092 4093 4094 |
envdata++;
n++;
}
envptr[n] = NULL;
*envdata = 0;
return envptr;
| < < < < < | 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 |
envdata++;
n++;
}
envptr[n] = NULL;
*envdata = 0;
return envptr;
}
static void JimFreeEnv(char **env, char **original_environ)
{
if (env != original_environ) {
Jim_Free(env);
}
}
static int JimCheckWaitStatus(Jim_Interp *interp, pidtype pid, int waitStatus)
{
Jim_Obj *errorCode = Jim_NewListObj(interp, NULL, 0);
int rc = JIM_ERR;
|
| ︙ | ︙ | |||
4152 4153 4154 4155 4156 4157 4158 |
Jim_SetGlobalVariableStr(interp, "errorCode", errorCode);
return rc;
}
struct WaitInfo
{
| | | | | | 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 |
Jim_SetGlobalVariableStr(interp, "errorCode", errorCode);
return rc;
}
struct WaitInfo
{
pidtype pid;
int status;
int flags;
};
struct WaitInfoTable {
struct WaitInfo *info;
int size;
int used;
};
#define WI_DETACHED 2
#define WAIT_TABLE_GROW_BY 4
|
| ︙ | ︙ | |||
4187 4188 4189 4190 4191 4192 4193 |
table->size = table->used = 0;
return table;
}
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| | < | < | 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 |
table->size = table->used = 0;
return table;
}
static int Jim_ExecCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
fdtype outputId;
fdtype errorId;
pidtype *pidPtr;
int numPids, result;
if (argc > 1 && Jim_CompareStringImmediate(interp, argv[argc - 1], "&")) {
Jim_Obj *listObj;
int i;
|
| ︙ | ︙ | |||
4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 |
return result;
}
static void JimReapDetachedPids(struct WaitInfoTable *table)
{
struct WaitInfo *waitPtr;
int count;
if (!table) {
return;
}
| > > > | | < < | > > > > > | 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 |
return result;
}
static void JimReapDetachedPids(struct WaitInfoTable *table)
{
struct WaitInfo *waitPtr;
int count;
int dest;
if (!table) {
return;
}
waitPtr = table->info;
dest = 0;
for (count = table->used; count > 0; waitPtr++, count--) {
if (waitPtr->flags & WI_DETACHED) {
int status;
pidtype pid = JimWaitPid(waitPtr->pid, &status, WNOHANG);
if (pid == waitPtr->pid) {
table->used--;
continue;
}
}
if (waitPtr != &table->info[dest]) {
table->info[dest] = *waitPtr;
}
dest++;
}
}
static pidtype JimWaitForProcess(struct WaitInfoTable *table, pidtype pid, int *statusPtr)
{
int i;
|
| ︙ | ︙ | |||
4282 4283 4284 4285 4286 4287 4288 |
return pid;
}
}
return JIM_BAD_PID;
}
| < | 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 |
return pid;
}
}
return JIM_BAD_PID;
}
static void JimDetachPids(Jim_Interp *interp, int numPids, const pidtype *pidPtr)
{
int j;
struct WaitInfoTable *table = Jim_CmdPrivData(interp);
for (j = 0; j < numPids; j++) {
|
| ︙ | ︙ | |||
4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 |
Jim_SetResultErrno(interp, "couldn't create pipe");
goto error;
}
outputId = pipeIds[1];
}
#ifdef __MINGW32__
pid = JimStartWinProcess(interp, &arg_array[firstArg], save_environ ? save_environ[0] : NULL, inputId, outputId, errorId);
if (pid == JIM_BAD_PID) {
Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
goto error;
}
#else
| > > > > > < < < < < < < < < > > > | | 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 |
Jim_SetResultErrno(interp, "couldn't create pipe");
goto error;
}
outputId = pipeIds[1];
}
if (pipe_dup_err) {
errorId = outputId;
}
#ifdef __MINGW32__
pid = JimStartWinProcess(interp, &arg_array[firstArg], save_environ ? save_environ[0] : NULL, inputId, outputId, errorId);
if (pid == JIM_BAD_PID) {
Jim_SetResultFormatted(interp, "couldn't exec \"%s\"", arg_array[firstArg]);
goto error;
}
#else
pid = vfork();
if (pid < 0) {
Jim_SetResultErrno(interp, "couldn't fork child process");
goto error;
}
if (pid == 0) {
if (inputId != -1) dup2(inputId, 0);
if (outputId != -1) dup2(outputId, 1);
if (errorId != -1) dup2(errorId, 2);
for (i = 3; (i <= outputId) || (i <= inputId) || (i <= errorId); i++) {
close(i);
}
(void)signal(SIGPIPE, SIG_DFL);
execvpe(arg_array[firstArg], &arg_array[firstArg], Jim_GetEnviron());
fprintf(stderr, "couldn't exec \"%s\"\n", arg_array[firstArg]);
_exit(127);
}
#endif
if (table->used == table->size) {
|
| ︙ | ︙ | |||
4749 4750 4751 4752 4753 4754 4755 |
if (errorId != JIM_BAD_FD) {
JimRewindFd(errorId);
if (JimAppendStreamToString(interp, errorId, Jim_GetResult(interp)) != JIM_OK) {
result = JIM_ERR;
}
}
| | > > > > > | 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 |
if (errorId != JIM_BAD_FD) {
JimRewindFd(errorId);
if (JimAppendStreamToString(interp, errorId, Jim_GetResult(interp)) != JIM_OK) {
result = JIM_ERR;
}
}
Jim_RemoveTrailingNewline(Jim_GetResult(interp));
return result;
}
int Jim_execInit(Jim_Interp *interp)
{
if (Jim_PackageProvide(interp, "exec", "1.0", JIM_ERRMSG))
return JIM_ERR;
#ifdef SIGPIPE
(void)signal(SIGPIPE, SIG_IGN);
#endif
Jim_CreateCommand(interp, "exec", Jim_ExecCmd, JimAllocWaitInfoTable(), JimFreeWaitInfoTable);
return JIM_OK;
}
#if defined(__MINGW32__)
|
| ︙ | ︙ | |||
5086 5087 5088 5089 5090 5091 5092 |
static pidtype
JimStartWinProcess(Jim_Interp *interp, char **argv, char *env, fdtype inputId, fdtype outputId, fdtype errorId)
{
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
HANDLE hProcess, h;
char execPath[MAX_PATH];
| < < | | 5226 5227 5228 5229 5230 5231 5232 5233 5234 5235 5236 5237 5238 5239 5240 5241 5242 5243 5244 5245 5246 5247 5248 5249 5250 5251 5252 5253 5254 5255 |
static pidtype
JimStartWinProcess(Jim_Interp *interp, char **argv, char *env, fdtype inputId, fdtype outputId, fdtype errorId)
{
STARTUPINFO startInfo;
PROCESS_INFORMATION procInfo;
HANDLE hProcess, h;
char execPath[MAX_PATH];
pidtype pid = JIM_BAD_PID;
Jim_Obj *cmdLineObj;
if (JimWinFindExecutable(argv[0], execPath) < 0) {
return JIM_BAD_PID;
}
argv[0] = execPath;
hProcess = GetCurrentProcess();
cmdLineObj = JimWinBuildCommandLine(interp, argv);
ZeroMemory(&startInfo, sizeof(startInfo));
startInfo.cb = sizeof(startInfo);
startInfo.dwFlags = STARTF_USESTDHANDLES;
startInfo.hStdInput = INVALID_HANDLE_VALUE;
startInfo.hStdOutput= INVALID_HANDLE_VALUE;
startInfo.hStdError = INVALID_HANDLE_VALUE;
if (inputId == JIM_BAD_FD) {
if (CreatePipe(&startInfo.hStdInput, &h, JimStdSecAttrs(), 0) != FALSE) {
CloseHandle(h);
}
|
| ︙ | ︙ | |||
5180 5181 5182 5183 5184 5185 5186 |
static int JimRewindFd(int fd)
{
return lseek(fd, 0L, SEEK_SET);
}
static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
{
| | < | | 5318 5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 |
static int JimRewindFd(int fd)
{
return lseek(fd, 0L, SEEK_SET);
}
static int JimCreateTemp(Jim_Interp *interp, const char *contents, int len)
{
int fd = Jim_MakeTempFile(interp, NULL);
if (fd == JIM_BAD_FD) {
Jim_SetResultErrno(interp, "couldn't create temp file");
return -1;
}
unlink(Jim_String(Jim_GetResult(interp)));
if (contents) {
if (write(fd, contents, len) != len) {
Jim_SetResultErrno(interp, "couldn't write temp file");
close(fd);
return -1;
}
lseek(fd, 0L, SEEK_SET);
|
| ︙ | ︙ | |||
5215 5216 5217 5218 5219 5220 5221 |
JimFreeEnv(Jim_GetEnviron(), env);
Jim_SetEnviron(env);
}
#endif
#endif
| < | 5352 5353 5354 5355 5356 5357 5358 5359 5360 5361 5362 5363 5364 5365 |
JimFreeEnv(Jim_GetEnviron(), env);
Jim_SetEnviron(env);
}
#endif
#endif
#ifndef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
|
| ︙ | ︙ | |||
5237 5238 5239 5240 5241 5242 5243 |
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
char buf[100];
time_t t;
long seconds;
| | | > > > | 5373 5374 5375 5376 5377 5378 5379 5380 5381 5382 5383 5384 5385 5386 5387 5388 5389 5390 5391 5392 5393 5394 5395 5396 5397 5398 5399 5400 5401 5402 5403 5404 5405 |
static int clock_cmd_format(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
char buf[100];
time_t t;
long seconds;
const char *format = "%a %b %d %H:%M:%S %Z %Y";
if (argc == 2 || (argc == 3 && !Jim_CompareStringImmediate(interp, argv[1], "-format"))) {
return -1;
}
if (argc == 3) {
format = Jim_String(argv[2]);
}
if (Jim_GetLong(interp, argv[0], &seconds) != JIM_OK) {
return JIM_ERR;
}
t = seconds;
if (strftime(buf, sizeof(buf), format, localtime(&t)) == 0) {
Jim_SetResultString(interp, "format string too long", -1);
return JIM_ERR;
}
Jim_SetResultString(interp, buf, -1);
return JIM_OK;
}
#ifdef HAVE_STRPTIME
|
| ︙ | ︙ | |||
5372 5373 5374 5375 5376 5377 5378 |
if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG))
return JIM_ERR;
Jim_CreateCommand(interp, "clock", Jim_SubCmdProc, (void *)clock_command_table, NULL);
return JIM_OK;
}
| < > < | < < | < | < < | < > | | | | | | > | | 5511 5512 5513 5514 5515 5516 5517 5518 5519 5520 5521 5522 5523 5524 5525 5526 5527 5528 5529 5530 5531 5532 5533 5534 5535 5536 5537 5538 5539 5540 5541 5542 5543 5544 5545 5546 5547 5548 5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 |
if (Jim_PackageProvide(interp, "clock", "1.0", JIM_ERRMSG))
return JIM_ERR;
Jim_CreateCommand(interp, "clock", Jim_SubCmdProc, (void *)clock_command_table, NULL);
return JIM_OK;
}
#include <limits.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
static int array_cmd_exists(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_SetResultInt(interp, Jim_GetVariable(interp, argv[0], 0) != 0);
return JIM_OK;
}
static int array_cmd_get(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
Jim_Obj *patternObj;
if (!objPtr) {
return JIM_OK;
}
patternObj = (argc == 1) ? NULL : argv[1];
if (patternObj == NULL || Jim_CompareStringImmediate(interp, patternObj, "*")) {
if (Jim_IsList(objPtr) && Jim_ListLength(interp, objPtr) % 2 == 0) {
Jim_SetResult(interp, objPtr);
return JIM_OK;
}
}
return Jim_DictValues(interp, objPtr, patternObj);
}
static int array_cmd_names(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (!objPtr) {
|
| ︙ | ︙ | |||
5441 5442 5443 5444 5445 5446 5447 5448 5449 5450 5451 5452 5453 5454 |
if (argc == 1 || Jim_CompareStringImmediate(interp, argv[1], "*")) {
Jim_UnsetVariable(interp, argv[0], JIM_NONE);
return JIM_OK;
}
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (Jim_DictPairs(interp, objPtr, &dictValuesObj, &len) != JIM_OK) {
return JIM_ERR;
}
resultObj = Jim_NewDictObj(interp, NULL, 0);
| > > > > > | 5575 5576 5577 5578 5579 5580 5581 5582 5583 5584 5585 5586 5587 5588 5589 5590 5591 5592 5593 |
if (argc == 1 || Jim_CompareStringImmediate(interp, argv[1], "*")) {
Jim_UnsetVariable(interp, argv[0], JIM_NONE);
return JIM_OK;
}
objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (objPtr == NULL) {
return JIM_OK;
}
if (Jim_DictPairs(interp, objPtr, &dictValuesObj, &len) != JIM_OK) {
return JIM_ERR;
}
resultObj = Jim_NewDictObj(interp, NULL, 0);
|
| ︙ | ︙ | |||
5478 5479 5480 5481 5482 5483 5484 5485 5486 5487 5488 5489 5490 5491 5492 5493 5494 5495 5496 5497 5498 5499 5500 5501 5502 5503 5504 5505 5506 5507 5508 5509 |
}
}
Jim_SetResultInt(interp, len);
return JIM_OK;
}
static int array_cmd_set(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
int len;
Jim_Obj *listObj = argv[1];
Jim_Obj *dictObj;
len = Jim_ListLength(interp, listObj);
if (len % 2) {
Jim_SetResultString(interp, "list must have an even number of elements", -1);
return JIM_ERR;
}
dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
if (!dictObj) {
return Jim_SetVariable(interp, argv[0], listObj);
}
if (Jim_IsShared(dictObj)) {
dictObj = Jim_DuplicateObj(interp, dictObj);
}
for (i = 0; i < len; i += 2) {
| > > > > > > > > > > > > > | 5617 5618 5619 5620 5621 5622 5623 5624 5625 5626 5627 5628 5629 5630 5631 5632 5633 5634 5635 5636 5637 5638 5639 5640 5641 5642 5643 5644 5645 5646 5647 5648 5649 5650 5651 5652 5653 5654 5655 5656 5657 5658 5659 5660 5661 |
}
}
Jim_SetResultInt(interp, len);
return JIM_OK;
}
static int array_cmd_stat(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr = Jim_GetVariable(interp, argv[0], JIM_NONE);
if (objPtr) {
return Jim_DictInfo(interp, objPtr);
}
Jim_SetResultFormatted(interp, "\"%#s\" isn't an array", argv[0], NULL);
return JIM_ERR;
}
static int array_cmd_set(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
int i;
int len;
Jim_Obj *listObj = argv[1];
Jim_Obj *dictObj;
len = Jim_ListLength(interp, listObj);
if (len % 2) {
Jim_SetResultString(interp, "list must have an even number of elements", -1);
return JIM_ERR;
}
dictObj = Jim_GetVariable(interp, argv[0], JIM_UNSHARED);
if (!dictObj) {
return Jim_SetVariable(interp, argv[0], listObj);
}
else if (Jim_DictSize(interp, dictObj) < 0) {
return JIM_ERR;
}
if (Jim_IsShared(dictObj)) {
dictObj = Jim_DuplicateObj(interp, dictObj);
}
for (i = 0; i < len; i += 2) {
|
| ︙ | ︙ | |||
5549 5550 5551 5552 5553 5554 5555 5556 5557 5558 5559 5560 5561 5562 |
},
{ "size",
"arrayName",
array_cmd_size,
1,
1,
},
{ "unset",
"arrayName ?pattern?",
array_cmd_unset,
1,
2,
| > > > > > > > | 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 |
},
{ "size",
"arrayName",
array_cmd_size,
1,
1,
},
{ "stat",
"arrayName",
array_cmd_stat,
1,
1,
},
{ "unset",
"arrayName ?pattern?",
array_cmd_unset,
1,
2,
|
| ︙ | ︙ | |||
5595 5596 5597 5598 5599 5600 5601 | Jim_execInit(interp); Jim_clockInit(interp); Jim_arrayInit(interp); Jim_stdlibInit(interp); Jim_tclcompatInit(interp); return JIM_OK; } | < | 5754 5755 5756 5757 5758 5759 5760 5761 5762 5763 5764 5765 5766 5767 | Jim_execInit(interp); Jim_clockInit(interp); Jim_arrayInit(interp); Jim_stdlibInit(interp); Jim_tclcompatInit(interp); return JIM_OK; } #define JIM_OPTIMIZATION #include <stdio.h> #include <stdlib.h> #include <string.h> #include <stdarg.h> |
| ︙ | ︙ | |||
5659 5660 5661 5662 5663 5664 5665 | #define JIM_INTEGER_SPACE 24 const char *jim_tt_name(int type); #ifdef JIM_DEBUG_PANIC | | < | | 5817 5818 5819 5820 5821 5822 5823 5824 5825 5826 5827 5828 5829 5830 5831 5832 5833 5834 5835 5836 5837 5838 5839 5840 |
#define JIM_INTEGER_SPACE 24
const char *jim_tt_name(int type);
#ifdef JIM_DEBUG_PANIC
static void JimPanicDump(int fail_condition, const char *fmt, ...);
#define JimPanic(X) JimPanicDump X
#else
#define JimPanic(X)
#endif
static char JimEmptyStringRep[] = "";
static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int action);
static int ListSetIndex(Jim_Interp *interp, Jim_Obj *listPtr, int listindex, Jim_Obj *newObjPtr,
int flags);
static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands);
static Jim_Obj *JimExpandDictSugar(Jim_Interp *interp, Jim_Obj *objPtr);
static void SetDictSubstFromAny(Jim_Interp *interp, Jim_Obj *objPtr);
static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len);
static void JimSetFailedEnumResult(Jim_Interp *interp, const char *arg, const char *badtype,
|
| ︙ | ︙ | |||
5920 5921 5922 5923 5924 5925 5926 |
if (n > 0) {
n = utf8_strlen(s2, n);
}
return n;
}
#endif
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6077 6078 6079 6080 6081 6082 6083 6084 6085 6086 6087 6088 6089 6090 |
if (n > 0) {
n = utf8_strlen(s2, n);
}
return n;
}
#endif
static int JimCheckConversion(const char *str, const char *endptr)
{
if (str[0] == '\0' || str == endptr) {
return JIM_ERR;
}
if (endptr[0] != '\0') {
|
| ︙ | ︙ | |||
6068 6069 6070 6071 6072 6073 6074 |
else {
*widePtr = jim_strtoull(str, &endptr);
}
return JimCheckConversion(str, endptr);
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 6191 6192 6193 6194 6195 6196 6197 6198 6199 6200 6201 6202 6203 6204 |
else {
*widePtr = jim_strtoull(str, &endptr);
}
return JimCheckConversion(str, endptr);
}
int Jim_StringToDouble(const char *str, double *doublePtr)
{
char *endptr;
errno = 0;
|
| ︙ | ︙ | |||
6131 6132 6133 6134 6135 6136 6137 |
for (i = 0; i < e; i++) {
res *= b;
}
return res;
}
#ifdef JIM_DEBUG_PANIC
| | | | | | | | 6216 6217 6218 6219 6220 6221 6222 6223 6224 6225 6226 6227 6228 6229 6230 6231 6232 6233 6234 6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 |
for (i = 0; i < e; i++) {
res *= b;
}
return res;
}
#ifdef JIM_DEBUG_PANIC
static void JimPanicDump(int condition, const char *fmt, ...)
{
va_list ap;
if (!condition) {
return;
}
va_start(ap, fmt);
fprintf(stderr, "\nJIM INTERPRETER PANIC: ");
vfprintf(stderr, fmt, ap);
fprintf(stderr, "\n\n");
va_end(ap);
#ifdef HAVE_BACKTRACE
{
void *array[40];
int size, i;
char **strings;
size = backtrace(array, 40);
strings = backtrace_symbols(array, size);
for (i = 0; i < size; i++)
fprintf(stderr, "[backtrace] %s\n", strings[i]);
fprintf(stderr, "[backtrace] Include the above lines and the output\n");
fprintf(stderr, "[backtrace] of 'nm <executable>' in the bug report.\n");
}
#endif
exit(1);
}
#endif
|
| ︙ | ︙ | |||
6235 6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246 6247 6248 6249 6250 6251 6252 6253 6254 6255 6256 |
while (len--)
h += (h << 3) + *buf++;
return h;
}
static void JimResetHashTable(Jim_HashTable *ht)
{
ht->table = NULL;
ht->size = 0;
ht->sizemask = 0;
ht->used = 0;
ht->collisions = 0;
}
static void JimInitHashTableIterator(Jim_HashTable *ht, Jim_HashTableIterator *iter)
{
iter->ht = ht;
iter->index = -1;
iter->entry = NULL;
| > > > > > > | 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344 6345 6346 6347 |
while (len--)
h += (h << 3) + *buf++;
return h;
}
static void JimResetHashTable(Jim_HashTable *ht)
{
ht->table = NULL;
ht->size = 0;
ht->sizemask = 0;
ht->used = 0;
ht->collisions = 0;
#ifdef JIM_RANDOMISE_HASH
ht->uniq = (rand() ^ time(NULL) ^ clock());
#else
ht->uniq = 0;
#endif
}
static void JimInitHashTableIterator(Jim_HashTable *ht, Jim_HashTableIterator *iter)
{
iter->ht = ht;
iter->index = -1;
iter->entry = NULL;
|
| ︙ | ︙ | |||
6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296 6297 |
if (size <= ht->used)
return;
Jim_InitHashTable(&n, ht->type, ht->privdata);
n.size = realsize;
n.sizemask = realsize - 1;
n.table = Jim_Alloc(realsize * sizeof(Jim_HashEntry *));
memset(n.table, 0, realsize * sizeof(Jim_HashEntry *));
n.used = ht->used;
for (i = 0; ht->used > 0; i++) {
Jim_HashEntry *he, *nextHe;
| > > | 6375 6376 6377 6378 6379 6380 6381 6382 6383 6384 6385 6386 6387 6388 6389 6390 |
if (size <= ht->used)
return;
Jim_InitHashTable(&n, ht->type, ht->privdata);
n.size = realsize;
n.sizemask = realsize - 1;
n.table = Jim_Alloc(realsize * sizeof(Jim_HashEntry *));
n.uniq = ht->uniq;
memset(n.table, 0, realsize * sizeof(Jim_HashEntry *));
n.used = ht->used;
for (i = 0; ht->used > 0; i++) {
Jim_HashEntry *he, *nextHe;
|
| ︙ | ︙ | |||
6340 6341 6342 6343 6344 6345 6346 |
int Jim_ReplaceHashEntry(Jim_HashTable *ht, const void *key, void *val)
{
int existed;
Jim_HashEntry *entry;
entry = JimInsertHashEntry(ht, key, 1);
if (entry->key) {
| > > > > | > | > > > < | 6433 6434 6435 6436 6437 6438 6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458 6459 6460 6461 6462 6463 |
int Jim_ReplaceHashEntry(Jim_HashTable *ht, const void *key, void *val)
{
int existed;
Jim_HashEntry *entry;
entry = JimInsertHashEntry(ht, key, 1);
if (entry->key) {
if (ht->type->valDestructor && ht->type->valDup) {
void *newval = ht->type->valDup(ht->privdata, val);
ht->type->valDestructor(ht->privdata, entry->u.val);
entry->u.val = newval;
}
else {
Jim_FreeEntryVal(ht, entry);
Jim_SetHashVal(ht, entry, val);
}
existed = 1;
}
else {
Jim_SetHashKey(ht, entry, key);
Jim_SetHashVal(ht, entry, val);
existed = 0;
}
return existed;
}
int Jim_DeleteHashEntry(Jim_HashTable *ht, const void *key)
{
|
| ︙ | ︙ | |||
6518 6519 6520 6521 6522 6523 6524 |
static unsigned int JimStringCopyHTHashFunction(const void *key)
{
return Jim_GenHashFunction(key, strlen(key));
}
static void *JimStringCopyHTDup(void *privdata, const void *key)
{
| | | 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628 6629 6630 6631 6632 |
static unsigned int JimStringCopyHTHashFunction(const void *key)
{
return Jim_GenHashFunction(key, strlen(key));
}
static void *JimStringCopyHTDup(void *privdata, const void *key)
{
return Jim_StrDup(key);
}
static int JimStringCopyHTKeyCompare(void *privdata, const void *key1, const void *key2)
{
return strcmp(key1, key2) == 0;
}
|
| ︙ | ︙ | |||
6618 6619 6620 6621 6622 6623 6624 |
for (i = 0; i < stack->len; i++)
freeFunc(stack->vector[i]);
}
| | | 6718 6719 6720 6721 6722 6723 6724 6725 6726 6727 6728 6729 6730 6731 6732 |
for (i = 0; i < stack->len; i++)
freeFunc(stack->vector[i]);
}
#define JIM_TT_NONE 0
#define JIM_TT_STR 1
#define JIM_TT_ESC 2
#define JIM_TT_VAR 3
#define JIM_TT_DICTSUGAR 4
#define JIM_TT_CMD 5
#define JIM_TT_SEP 6
|
| ︙ | ︙ | |||
6650 6651 6652 6653 6654 6655 6656 6657 6658 6659 6660 6661 6662 6663 6664 6665 6666 6667 6668 6669 |
#define TOKEN_IS_SEP(type) (type >= JIM_TT_SEP && type <= JIM_TT_EOF)
#define JIM_PS_DEF 0
#define JIM_PS_QUOTE 1
#define JIM_PS_DICTSUGAR 2
struct JimParserCtx
{
const char *p;
int len;
int linenr;
const char *tstart;
const char *tend;
int tline;
int tt;
int eof;
int state;
int comment;
| > > > > > < < < < | < < < | | | 6750 6751 6752 6753 6754 6755 6756 6757 6758 6759 6760 6761 6762 6763 6764 6765 6766 6767 6768 6769 6770 6771 6772 6773 6774 6775 6776 6777 6778 6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789 6790 6791 6792 6793 6794 6795 6796 6797 6798 6799 6800 6801 6802 6803 6804 6805 6806 6807 6808 6809 6810 6811 |
#define TOKEN_IS_SEP(type) (type >= JIM_TT_SEP && type <= JIM_TT_EOF)
#define JIM_PS_DEF 0
#define JIM_PS_QUOTE 1
#define JIM_PS_DICTSUGAR 2
struct JimParseMissing {
int ch;
int line;
};
struct JimParserCtx
{
const char *p;
int len;
int linenr;
const char *tstart;
const char *tend;
int tline;
int tt;
int eof;
int state;
int comment;
struct JimParseMissing missing;
};
static int JimParseScript(struct JimParserCtx *pc);
static int JimParseSep(struct JimParserCtx *pc);
static int JimParseEol(struct JimParserCtx *pc);
static int JimParseCmd(struct JimParserCtx *pc);
static int JimParseQuote(struct JimParserCtx *pc);
static int JimParseVar(struct JimParserCtx *pc);
static int JimParseBrace(struct JimParserCtx *pc);
static int JimParseStr(struct JimParserCtx *pc);
static int JimParseComment(struct JimParserCtx *pc);
static void JimParseSubCmd(struct JimParserCtx *pc);
static int JimParseSubQuote(struct JimParserCtx *pc);
static Jim_Obj *JimParserGetTokenObj(Jim_Interp *interp, struct JimParserCtx *pc);
static void JimParserInit(struct JimParserCtx *pc, const char *prg, int len, int linenr)
{
pc->p = prg;
pc->len = len;
pc->tstart = NULL;
pc->tend = NULL;
pc->tline = 0;
pc->tt = JIM_TT_NONE;
pc->eof = 0;
pc->state = JIM_PS_DEF;
pc->linenr = linenr;
pc->comment = 1;
pc->missing.ch = ' ';
pc->missing.line = linenr;
}
static int JimParseScript(struct JimParserCtx *pc)
{
while (1) {
if (!pc->len) {
pc->tstart = pc->p;
|
| ︙ | ︙ | |||
6835 6836 6837 6838 6839 6840 6841 |
case '\n':
pc->linenr++;
break;
}
pc->p++;
pc->len--;
}
| | | | 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946 6947 6948 |
case '\n':
pc->linenr++;
break;
}
pc->p++;
pc->len--;
}
pc->missing.ch = '{';
pc->missing.line = pc->tline;
pc->tend = pc->p - 1;
}
static int JimParseSubQuote(struct JimParserCtx *pc)
{
int tt = JIM_TT_STR;
int line = pc->tline;
|
| ︙ | ︙ | |||
6882 6883 6884 6885 6886 6887 6888 |
case '$':
tt = JIM_TT_ESC;
break;
}
pc->p++;
pc->len--;
}
| | | | 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994 6995 |
case '$':
tt = JIM_TT_ESC;
break;
}
pc->p++;
pc->len--;
}
pc->missing.ch = '"';
pc->missing.line = line;
pc->tend = pc->p - 1;
return tt;
}
static void JimParseSubCmd(struct JimParserCtx *pc)
{
int level = 1;
|
| ︙ | ︙ | |||
6941 6942 6943 6944 6945 6946 6947 |
pc->linenr++;
break;
}
startofword = isspace(UCHAR(*pc->p));
pc->p++;
pc->len--;
}
| | | | 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 |
pc->linenr++;
break;
}
startofword = isspace(UCHAR(*pc->p));
pc->p++;
pc->len--;
}
pc->missing.ch = '[';
pc->missing.line = line;
pc->tend = pc->p - 1;
}
static int JimParseBrace(struct JimParserCtx *pc)
{
pc->tstart = pc->p + 1;
pc->tline = pc->linenr;
|
| ︙ | ︙ | |||
7086 7087 7088 7089 7090 7091 7092 |
return JimParseBrace(pc);
}
if (*pc->p == '"') {
pc->state = JIM_PS_QUOTE;
pc->p++;
pc->len--;
| | | > > > > | 7184 7185 7186 7187 7188 7189 7190 7191 7192 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 |
return JimParseBrace(pc);
}
if (*pc->p == '"') {
pc->state = JIM_PS_QUOTE;
pc->p++;
pc->len--;
pc->missing.line = pc->tline;
}
}
pc->tstart = pc->p;
pc->tline = pc->linenr;
while (1) {
if (pc->len == 0) {
if (pc->state == JIM_PS_QUOTE) {
pc->missing.ch = '"';
}
pc->tend = pc->p - 1;
pc->tt = JIM_TT_ESC;
return JIM_OK;
}
switch (*pc->p) {
case '\\':
if (pc->state == JIM_PS_DEF && *(pc->p + 1) == '\n') {
pc->tend = pc->p - 1;
pc->tt = JIM_TT_ESC;
return JIM_OK;
}
if (pc->len >= 2) {
if (*(pc->p + 1) == '\n') {
pc->linenr++;
}
pc->p++;
pc->len--;
}
else if (pc->len == 1) {
pc->missing.ch = '\\';
}
break;
case '(':
if (pc->len > 1 && pc->p[1] != '$') {
break;
}
case ')':
|
| ︙ | ︙ | |||
7174 7175 7176 7177 7178 7179 7180 |
}
return JIM_OK;
}
static int JimParseComment(struct JimParserCtx *pc)
{
while (*pc->p) {
| | < < | | > > > > > > > > > > > | 7276 7277 7278 7279 7280 7281 7282 7283 7284 7285 7286 7287 7288 7289 7290 7291 7292 7293 7294 7295 7296 7297 7298 7299 7300 7301 7302 7303 7304 7305 |
}
return JIM_OK;
}
static int JimParseComment(struct JimParserCtx *pc)
{
while (*pc->p) {
if (*pc->p == '\\') {
pc->p++;
pc->len--;
if (pc->len == 0) {
pc->missing.ch = '\\';
return JIM_OK;
}
if (*pc->p == '\n') {
pc->linenr++;
}
}
else if (*pc->p == '\n') {
pc->p++;
pc->len--;
pc->linenr++;
break;
}
pc->p++;
pc->len--;
}
return JIM_OK;
}
|
| ︙ | ︙ | |||
7402 7403 7404 7405 7406 7407 7408 |
struct JimParserCtx parser;
JimParserInit(&parser, s, len, 1);
while (!parser.eof) {
JimParseScript(&parser);
}
if (stateCharPtr) {
| | | | 7513 7514 7515 7516 7517 7518 7519 7520 7521 7522 7523 7524 7525 7526 7527 7528 7529 |
struct JimParserCtx parser;
JimParserInit(&parser, s, len, 1);
while (!parser.eof) {
JimParseScript(&parser);
}
if (stateCharPtr) {
*stateCharPtr = parser.missing.ch;
}
return parser.missing.ch == ' ';
}
static int JimParseListSep(struct JimParserCtx *pc);
static int JimParseListStr(struct JimParserCtx *pc);
static int JimParseListQuote(struct JimParserCtx *pc);
static int JimParseList(struct JimParserCtx *pc)
|
| ︙ | ︙ | |||
7660 7661 7662 7663 7664 7665 7666 7667 7668 7669 7670 7671 7672 7673 |
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
return objPtr->bytes;
}
static void FreeDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
static void DupDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static const Jim_ObjType dictSubstObjType = {
"dict-substitution",
FreeDictSubstInternalRep,
| > > > > > > | 7771 7772 7773 7774 7775 7776 7777 7778 7779 7780 7781 7782 7783 7784 7785 7786 7787 7788 7789 7790 |
if (objPtr->bytes == NULL) {
JimPanic((objPtr->typePtr->updateStringProc == NULL, "UpdateStringProc called against '%s' type.", objPtr->typePtr->name));
objPtr->typePtr->updateStringProc(objPtr);
}
return objPtr->bytes;
}
static void JimSetStringBytes(Jim_Obj *objPtr, const char *str)
{
objPtr->bytes = Jim_StrDup(str);
objPtr->length = strlen(str);
}
static void FreeDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
static void DupDictSubstInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static const Jim_ObjType dictSubstObjType = {
"dict-substitution",
FreeDictSubstInternalRep,
|
| ︙ | ︙ | |||
7701 7702 7703 7704 7705 7706 7707 |
};
static void DupStringInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
JIM_NOTUSED(interp);
dupPtr->internalRep.strValue.maxLength = srcPtr->length;
| < | 7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 7831 |
};
static void DupStringInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
JIM_NOTUSED(interp);
dupPtr->internalRep.strValue.maxLength = srcPtr->length;
dupPtr->internalRep.strValue.charLength = srcPtr->internalRep.strValue.charLength;
}
static int SetStringFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr->typePtr != &stringObjType) {
|
| ︙ | ︙ | |||
7750 7751 7752 7753 7754 7755 7756 |
if (len == -1)
len = strlen(s);
if (len == 0) {
objPtr->bytes = JimEmptyStringRep;
| < < > | 7866 7867 7868 7869 7870 7871 7872 7873 7874 7875 7876 7877 7878 7879 7880 7881 7882 7883 7884 7885 7886 |
if (len == -1)
len = strlen(s);
if (len == 0) {
objPtr->bytes = JimEmptyStringRep;
}
else {
objPtr->bytes = Jim_Alloc(len + 1);
memcpy(objPtr->bytes, s, len);
objPtr->bytes[len] = '\0';
}
objPtr->length = len;
objPtr->typePtr = NULL;
return objPtr;
}
|
| ︙ | ︙ | |||
7789 7790 7791 7792 7793 7794 7795 |
}
Jim_Obj *Jim_NewStringObjNoAlloc(Jim_Interp *interp, char *s, int len)
{
Jim_Obj *objPtr = Jim_NewObj(interp);
objPtr->bytes = s;
| | | 7904 7905 7906 7907 7908 7909 7910 7911 7912 7913 7914 7915 7916 7917 7918 |
}
Jim_Obj *Jim_NewStringObjNoAlloc(Jim_Interp *interp, char *s, int len)
{
Jim_Obj *objPtr = Jim_NewObj(interp);
objPtr->bytes = s;
objPtr->length = (len == -1) ? strlen(s) : len;
objPtr->typePtr = NULL;
return objPtr;
}
static void StringAppendString(Jim_Obj *objPtr, const char *str, int len)
{
int needlen;
|
| ︙ | ︙ | |||
7818 7819 7820 7821 7822 7823 7824 7825 7826 7827 7828 7829 7830 |
else {
objPtr->bytes = Jim_Realloc(objPtr->bytes, needlen + 1);
}
objPtr->internalRep.strValue.maxLength = needlen;
}
memcpy(objPtr->bytes + objPtr->length, str, len);
objPtr->bytes[objPtr->length + len] = '\0';
if (objPtr->internalRep.strValue.charLength >= 0) {
objPtr->internalRep.strValue.charLength += utf8_strlen(objPtr->bytes + objPtr->length, len);
}
objPtr->length += len;
}
| > < < < | | < < < | > > > | | | | < > | 7933 7934 7935 7936 7937 7938 7939 7940 7941 7942 7943 7944 7945 7946 7947 7948 7949 7950 7951 7952 7953 7954 7955 7956 7957 7958 7959 7960 7961 7962 7963 7964 7965 7966 7967 7968 7969 7970 7971 7972 7973 7974 7975 7976 7977 7978 7979 7980 7981 7982 7983 7984 7985 7986 7987 7988 7989 7990 7991 7992 7993 7994 7995 7996 |
else {
objPtr->bytes = Jim_Realloc(objPtr->bytes, needlen + 1);
}
objPtr->internalRep.strValue.maxLength = needlen;
}
memcpy(objPtr->bytes + objPtr->length, str, len);
objPtr->bytes[objPtr->length + len] = '\0';
if (objPtr->internalRep.strValue.charLength >= 0) {
objPtr->internalRep.strValue.charLength += utf8_strlen(objPtr->bytes + objPtr->length, len);
}
objPtr->length += len;
}
void Jim_AppendString(Jim_Interp *interp, Jim_Obj *objPtr, const char *str, int len)
{
JimPanic((Jim_IsShared(objPtr), "Jim_AppendString called with shared object"));
SetStringFromAny(interp, objPtr);
StringAppendString(objPtr, str, len);
}
void Jim_AppendObj(Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *appendObjPtr)
{
int len;
const char *str = Jim_GetString(appendObjPtr, &len);
Jim_AppendString(interp, objPtr, str, len);
}
void Jim_AppendStrings(Jim_Interp *interp, Jim_Obj *objPtr, ...)
{
va_list ap;
SetStringFromAny(interp, objPtr);
va_start(ap, objPtr);
while (1) {
const char *s = va_arg(ap, const char *);
if (s == NULL)
break;
Jim_AppendString(interp, objPtr, s, -1);
}
va_end(ap);
}
int Jim_StringEqObj(Jim_Obj *aObjPtr, Jim_Obj *bObjPtr)
{
if (aObjPtr == bObjPtr) {
return 1;
}
else {
int Alen, Blen;
const char *sA = Jim_GetString(aObjPtr, &Alen);
const char *sB = Jim_GetString(bObjPtr, &Blen);
return Alen == Blen && memcmp(sA, sB, Alen) == 0;
}
}
int Jim_StringMatchObj(Jim_Interp *interp, Jim_Obj *patternObjPtr, Jim_Obj *objPtr, int nocase)
{
return JimGlobMatch(Jim_String(patternObjPtr), Jim_String(objPtr), nocase);
}
|
| ︙ | ︙ | |||
8034 8035 8036 8037 8038 8039 8040 |
}
static void JimStrCopyUpperLower(char *dest, const char *str, int uc)
{
while (*str) {
int c;
str += utf8_tounicode(str, &c);
| | | 8147 8148 8149 8150 8151 8152 8153 8154 8155 8156 8157 8158 8159 8160 8161 |
}
static void JimStrCopyUpperLower(char *dest, const char *str, int uc)
{
while (*str) {
int c;
str += utf8_tounicode(str, &c);
dest += utf8_getchars(dest, uc ? utf8_upper(c) : utf8_lower(c));
}
*dest = 0;
}
static Jim_Obj *JimStringToLower(Jim_Interp *interp, Jim_Obj *strObjPtr)
{
char *buf;
|
| ︙ | ︙ | |||
8094 8095 8096 8097 8098 8099 8100 |
}
#ifdef JIM_UTF8
len *= 2;
#endif
buf = p = Jim_Alloc(len + 1);
str += utf8_tounicode(str, &c);
| | | 8207 8208 8209 8210 8211 8212 8213 8214 8215 8216 8217 8218 8219 8220 8221 |
}
#ifdef JIM_UTF8
len *= 2;
#endif
buf = p = Jim_Alloc(len + 1);
str += utf8_tounicode(str, &c);
p += utf8_getchars(p, utf8_title(c));
JimStrCopyUpperLower(p, str, 0);
return Jim_NewStringObjNoAlloc(interp, buf, -1);
}
static const char *utf8_memchr(const char *str, int len, int c)
|
| ︙ | ︙ | |||
8201 8202 8203 8204 8205 8206 8207 8208 8209 8210 8211 8212 8213 8214 |
nontrim = JimFindTrimRight(strObjPtr->bytes, len, trimchars, trimcharslen);
if (nontrim == NULL) {
return Jim_NewEmptyStringObj(interp);
}
if (nontrim == strObjPtr->bytes + len) {
return strObjPtr;
}
if (Jim_IsShared(strObjPtr)) {
strObjPtr = Jim_NewStringObj(interp, strObjPtr->bytes, (nontrim - strObjPtr->bytes));
}
else {
| > | 8314 8315 8316 8317 8318 8319 8320 8321 8322 8323 8324 8325 8326 8327 8328 |
nontrim = JimFindTrimRight(strObjPtr->bytes, len, trimchars, trimcharslen);
if (nontrim == NULL) {
return Jim_NewEmptyStringObj(interp);
}
if (nontrim == strObjPtr->bytes + len) {
return strObjPtr;
}
if (Jim_IsShared(strObjPtr)) {
strObjPtr = Jim_NewStringObj(interp, strObjPtr->bytes, (nontrim - strObjPtr->bytes));
}
else {
|
| ︙ | ︙ | |||
8224 8225 8226 8227 8228 8229 8230 |
{
Jim_Obj *objPtr = JimStringTrimLeft(interp, strObjPtr, trimcharsObjPtr);
strObjPtr = JimStringTrimRight(interp, objPtr, trimcharsObjPtr);
| > | < | | 8338 8339 8340 8341 8342 8343 8344 8345 8346 8347 8348 8349 8350 8351 8352 8353 8354 8355 |
{
Jim_Obj *objPtr = JimStringTrimLeft(interp, strObjPtr, trimcharsObjPtr);
strObjPtr = JimStringTrimRight(interp, objPtr, trimcharsObjPtr);
if (objPtr != strObjPtr && objPtr->refCount == 0) {
Jim_FreeNewObj(interp, objPtr);
}
return strObjPtr;
}
#ifdef HAVE_ISASCII
|
| ︙ | ︙ | |||
8268 8269 8270 8271 8272 8273 8274 |
if (Jim_GetEnum(interp, strClass, strclassnames, &strclass, "class", JIM_ERRMSG | JIM_ENUM_ABBREV) != JIM_OK) {
return JIM_ERR;
}
str = Jim_GetString(strObjPtr, &len);
if (len == 0) {
| | | | | 8382 8383 8384 8385 8386 8387 8388 8389 8390 8391 8392 8393 8394 8395 8396 8397 8398 8399 8400 8401 8402 8403 8404 8405 8406 8407 8408 8409 8410 8411 |
if (Jim_GetEnum(interp, strClass, strclassnames, &strclass, "class", JIM_ERRMSG | JIM_ENUM_ABBREV) != JIM_OK) {
return JIM_ERR;
}
str = Jim_GetString(strObjPtr, &len);
if (len == 0) {
Jim_SetResultBool(interp, !strict);
return JIM_OK;
}
switch (strclass) {
case STR_IS_INTEGER:
{
jim_wide w;
Jim_SetResultBool(interp, JimGetWideNoErr(interp, strObjPtr, &w) == JIM_OK);
return JIM_OK;
}
case STR_IS_DOUBLE:
{
double d;
Jim_SetResultBool(interp, Jim_GetDouble(interp, strObjPtr, &d) == JIM_OK && errno != ERANGE);
return JIM_OK;
}
case STR_IS_ALPHA: isclassfunc = isalpha; break;
case STR_IS_ALNUM: isclassfunc = isalnum; break;
case STR_IS_ASCII: isclassfunc = jim_isascii; break;
case STR_IS_DIGIT: isclassfunc = isdigit; break;
|
| ︙ | ︙ | |||
8305 8306 8307 8308 8309 8310 8311 |
case STR_IS_PUNCT: isclassfunc = ispunct; break;
default:
return JIM_ERR;
}
for (i = 0; i < len; i++) {
if (!isclassfunc(str[i])) {
| | | | > > | 8419 8420 8421 8422 8423 8424 8425 8426 8427 8428 8429 8430 8431 8432 8433 8434 8435 8436 8437 8438 8439 8440 8441 8442 8443 8444 8445 8446 8447 8448 8449 8450 8451 8452 8453 8454 8455 8456 8457 8458 8459 8460 8461 |
case STR_IS_PUNCT: isclassfunc = ispunct; break;
default:
return JIM_ERR;
}
for (i = 0; i < len; i++) {
if (!isclassfunc(str[i])) {
Jim_SetResultBool(interp, 0);
return JIM_OK;
}
}
Jim_SetResultBool(interp, 1);
return JIM_OK;
}
static const Jim_ObjType comparedStringObjType = {
"compared-string",
NULL,
NULL,
NULL,
JIM_TYPE_REFERENCES,
};
int Jim_CompareStringImmediate(Jim_Interp *interp, Jim_Obj *objPtr, const char *str)
{
if (objPtr->typePtr == &comparedStringObjType && objPtr->internalRep.ptr == str) {
return 1;
}
else {
const char *objStr = Jim_String(objPtr);
if (strcmp(str, objStr) != 0)
return 0;
if (objPtr->typePtr != &comparedStringObjType) {
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &comparedStringObjType;
}
objPtr->internalRep.ptr = (char *)str;
return 1;
}
|
| ︙ | ︙ | |||
8377 8378 8379 8380 8381 8382 8383 |
Jim_IncrRefCount(dupPtr->internalRep.sourceValue.fileNameObj);
}
static void JimSetSourceInfo(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *fileNameObj, int lineNumber)
{
JimPanic((Jim_IsShared(objPtr), "JimSetSourceInfo called with shared object"));
| | < < > < < | > < > < > > < < | < | 8493 8494 8495 8496 8497 8498 8499 8500 8501 8502 8503 8504 8505 8506 8507 8508 8509 8510 8511 8512 8513 8514 8515 8516 8517 8518 8519 8520 8521 8522 8523 8524 8525 8526 8527 8528 8529 8530 8531 8532 8533 8534 8535 8536 8537 8538 8539 8540 8541 8542 8543 8544 8545 8546 8547 8548 8549 8550 8551 8552 8553 8554 8555 8556 8557 8558 8559 8560 8561 8562 8563 8564 8565 8566 8567 8568 8569 8570 8571 8572 8573 8574 8575 8576 8577 8578 8579 8580 8581 8582 8583 8584 8585 8586 8587 8588 8589 8590 8591 |
Jim_IncrRefCount(dupPtr->internalRep.sourceValue.fileNameObj);
}
static void JimSetSourceInfo(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *fileNameObj, int lineNumber)
{
JimPanic((Jim_IsShared(objPtr), "JimSetSourceInfo called with shared object"));
JimPanic((objPtr->typePtr != NULL, "JimSetSourceInfo called with typed object"));
Jim_IncrRefCount(fileNameObj);
objPtr->internalRep.sourceValue.fileNameObj = fileNameObj;
objPtr->internalRep.sourceValue.lineNumber = lineNumber;
objPtr->typePtr = &sourceObjType;
}
static const Jim_ObjType scriptLineObjType = {
"scriptline",
NULL,
NULL,
NULL,
JIM_NONE,
};
static Jim_Obj *JimNewScriptLineObj(Jim_Interp *interp, int argc, int line)
{
Jim_Obj *objPtr;
#ifdef DEBUG_SHOW_SCRIPT
char buf[100];
snprintf(buf, sizeof(buf), "line=%d, argc=%d", line, argc);
objPtr = Jim_NewStringObj(interp, buf, -1);
#else
objPtr = Jim_NewEmptyStringObj(interp);
#endif
objPtr->typePtr = &scriptLineObjType;
objPtr->internalRep.scriptLineValue.argc = argc;
objPtr->internalRep.scriptLineValue.line = line;
return objPtr;
}
static void FreeScriptInternalRep(Jim_Interp *interp, Jim_Obj *objPtr);
static void DupScriptInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr);
static int JimSetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr);
static int JimParseCheckMissing(Jim_Interp *interp, int ch);
static const Jim_ObjType scriptObjType = {
"script",
FreeScriptInternalRep,
DupScriptInternalRep,
NULL,
JIM_TYPE_REFERENCES,
};
typedef struct ScriptToken
{
Jim_Obj *objPtr;
int type;
} ScriptToken;
typedef struct ScriptObj
{
ScriptToken *token;
Jim_Obj *fileNameObj;
int len;
int substFlags;
int inUse; /* Used to share a ScriptObj. Currently
only used by Jim_EvalObj() as protection against
shimmering of the currently evaluated object. */
int firstline;
int linenr;
} ScriptObj;
void FreeScriptInternalRep(Jim_Interp *interp, Jim_Obj *objPtr)
{
int i;
struct ScriptObj *script = (void *)objPtr->internalRep.ptr;
if (--script->inUse != 0)
return;
for (i = 0; i < script->len; i++) {
Jim_DecrRefCount(interp, script->token[i].objPtr);
}
Jim_Free(script->token);
Jim_DecrRefCount(interp, script->fileNameObj);
Jim_Free(script);
}
void DupScriptInternalRep(Jim_Interp *interp, Jim_Obj *srcPtr, Jim_Obj *dupPtr)
{
JIM_NOTUSED(interp);
JIM_NOTUSED(srcPtr);
dupPtr->typePtr = NULL;
}
typedef struct
{
const char *token;
int len;
|
| ︙ | ︙ | |||
8664 8665 8666 8667 8668 8669 8670 |
if (lineargs == 0) {
token--;
}
script->len = token - script->token;
| | > > > > > > > > > > > > > > > > > > > > > > > > > | 8776 8777 8778 8779 8780 8781 8782 8783 8784 8785 8786 8787 8788 8789 8790 8791 8792 8793 8794 8795 8796 8797 8798 8799 8800 8801 8802 8803 8804 8805 8806 8807 8808 8809 8810 8811 8812 8813 8814 8815 8816 8817 8818 8819 8820 8821 8822 8823 8824 8825 |
if (lineargs == 0) {
token--;
}
script->len = token - script->token;
JimPanic((script->len >= count, "allocated script array is too short"));
#ifdef DEBUG_SHOW_SCRIPT
printf("==== Script (%s) ====\n", Jim_String(script->fileNameObj));
for (i = 0; i < script->len; i++) {
const ScriptToken *t = &script->token[i];
printf("[%2d] %s %s\n", i, jim_tt_name(t->type), Jim_String(t->objPtr));
}
#endif
}
static int JimParseCheckMissing(Jim_Interp *interp, int ch)
{
const char *msg;
switch (ch) {
case '\\':
case ' ':
return JIM_OK;
case '[':
msg = "unmatched \"[\"";
break;
case '{':
msg = "missing close-brace";
break;
case '"':
default:
msg = "missing quote";
break;
}
Jim_SetResultString(interp, msg, -1);
return JIM_ERR;
}
static void SubstObjAddTokens(Jim_Interp *interp, struct ScriptObj *script,
ParseTokenList *tokenlist)
{
int i;
struct ScriptToken *token;
|
| ︙ | ︙ | |||
8697 8698 8699 8700 8701 8702 8703 |
Jim_IncrRefCount(token->objPtr);
token++;
}
script->len = i;
}
| | > < < < < < | > > | | > > | 8834 8835 8836 8837 8838 8839 8840 8841 8842 8843 8844 8845 8846 8847 8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 8862 8863 8864 8865 8866 8867 8868 8869 8870 8871 8872 8873 8874 8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 8894 8895 8896 8897 8898 8899 8900 8901 8902 8903 8904 8905 8906 8907 8908 8909 8910 8911 8912 8913 8914 |
Jim_IncrRefCount(token->objPtr);
token++;
}
script->len = i;
}
static int JimSetScriptFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
{
int scriptTextLen;
const char *scriptText = Jim_GetString(objPtr, &scriptTextLen);
struct JimParserCtx parser;
struct ScriptObj *script;
ParseTokenList tokenlist;
int line = 1;
int retcode = JIM_OK;
if (objPtr->typePtr == &sourceObjType) {
line = objPtr->internalRep.sourceValue.lineNumber;
}
ScriptTokenListInit(&tokenlist);
JimParserInit(&parser, scriptText, scriptTextLen, line);
while (!parser.eof) {
JimParseScript(&parser);
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
retcode = JimParseCheckMissing(interp, parser.missing.ch);
ScriptAddToken(&tokenlist, scriptText + scriptTextLen, 0, JIM_TT_EOF, 0);
script = Jim_Alloc(sizeof(*script));
memset(script, 0, sizeof(*script));
script->inUse = 1;
if (objPtr->typePtr == &sourceObjType) {
script->fileNameObj = objPtr->internalRep.sourceValue.fileNameObj;
}
else {
script->fileNameObj = interp->emptyObj;
}
script->linenr = parser.missing.line;
Jim_IncrRefCount(script->fileNameObj);
ScriptObjAddTokens(interp, script, &tokenlist);
ScriptTokenListFree(&tokenlist);
Jim_FreeIntRep(interp, objPtr);
Jim_SetIntRepPtr(objPtr, script);
objPtr->typePtr = &scriptObjType;
return retcode;
}
ScriptObj *Jim_GetScript(Jim_Interp *interp, Jim_Obj *objPtr)
{
if (objPtr == interp->emptyObj) {
objPtr = interp->nullScriptObj;
}
if (objPtr->typePtr != &scriptObjType || ((struct ScriptObj *)Jim_GetIntRepPtr(objPtr))->substFlags) {
if (JimSetScriptFromAny(interp, objPtr) == JIM_ERR) {
return NULL;
}
}
return (ScriptObj *) Jim_GetIntRepPtr(objPtr);
}
static void JimIncrCmdRefCount(Jim_Cmd *cmdPtr)
{
cmdPtr->inUse++;
|
| ︙ | ︙ | |||
8848 8849 8850 8851 8852 8853 8854 8855 8856 8857 8858 8859 8860 8861 |
else if (Jim_Length(interp->framePtr->nsObj)) {
nsObj = Jim_DuplicateObj(interp, interp->framePtr->nsObj);
Jim_AppendStrings(interp, nsObj, "::", name, NULL);
}
return nsObj;
}
static const char *JimQualifyName(Jim_Interp *interp, const char *name, Jim_Obj **objPtrPtr)
{
Jim_Obj *objPtr = interp->emptyObj;
if (name[0] == ':' && name[1] == ':') {
| > > > > > > > > > > > > > > > > | 8985 8986 8987 8988 8989 8990 8991 8992 8993 8994 8995 8996 8997 8998 8999 9000 9001 9002 9003 9004 9005 9006 9007 9008 9009 9010 9011 9012 9013 9014 |
else if (Jim_Length(interp->framePtr->nsObj)) {
nsObj = Jim_DuplicateObj(interp, interp->framePtr->nsObj);
Jim_AppendStrings(interp, nsObj, "::", name, NULL);
}
return nsObj;
}
Jim_Obj *Jim_MakeGlobalNamespaceName(Jim_Interp *interp, Jim_Obj *nameObjPtr)
{
Jim_Obj *resultObj;
const char *name = Jim_String(nameObjPtr);
if (name[0] == ':' && name[1] == ':') {
return nameObjPtr;
}
Jim_IncrRefCount(nameObjPtr);
resultObj = Jim_NewStringObj(interp, "::", -1);
Jim_AppendObj(interp, resultObj, nameObjPtr);
Jim_DecrRefCount(interp, nameObjPtr);
return resultObj;
}
static const char *JimQualifyName(Jim_Interp *interp, const char *name, Jim_Obj **objPtrPtr)
{
Jim_Obj *objPtr = interp->emptyObj;
if (name[0] == ':' && name[1] == ':') {
|
| ︙ | ︙ | |||
8875 8876 8877 8878 8879 8880 8881 8882 8883 8884 8885 8886 8887 8888 8889 8890 8891 8892 8893 |
#define JimFreeQualifiedName(INTERP, OBJ) Jim_DecrRefCount((INTERP), (OBJ))
#else
#define JimQualifyName(INTERP, NAME, DUMMY) (((NAME)[0] == ':' && (NAME)[1] == ':') ? (NAME) + 2 : (NAME))
#define JimFreeQualifiedName(INTERP, DUMMY) (void)(DUMMY)
#endif
static int JimCreateCommand(Jim_Interp *interp, const char *name, Jim_Cmd *cmd)
{
Jim_HashEntry *he = Jim_FindHashEntry(&interp->commands, name);
if (he) {
Jim_InterpIncrProcEpoch(interp);
}
if (he && interp->local) {
| > > > > > | | | 9028 9029 9030 9031 9032 9033 9034 9035 9036 9037 9038 9039 9040 9041 9042 9043 9044 9045 9046 9047 9048 9049 9050 9051 9052 9053 9054 9055 9056 9057 9058 9059 9060 |
#define JimFreeQualifiedName(INTERP, OBJ) Jim_DecrRefCount((INTERP), (OBJ))
#else
#define JimQualifyName(INTERP, NAME, DUMMY) (((NAME)[0] == ':' && (NAME)[1] == ':') ? (NAME) + 2 : (NAME))
#define JimFreeQualifiedName(INTERP, DUMMY) (void)(DUMMY)
Jim_Obj *Jim_MakeGlobalNamespaceName(Jim_Interp *interp, Jim_Obj *nameObjPtr)
{
return nameObjPtr;
}
#endif
static int JimCreateCommand(Jim_Interp *interp, const char *name, Jim_Cmd *cmd)
{
Jim_HashEntry *he = Jim_FindHashEntry(&interp->commands, name);
if (he) {
Jim_InterpIncrProcEpoch(interp);
}
if (he && interp->local) {
cmd->prevCmd = Jim_GetHashEntryVal(he);
Jim_SetHashVal(&interp->commands, he, cmd);
}
else {
if (he) {
Jim_DeleteHashEntry(&interp->commands, name);
}
|
| ︙ | ︙ | |||
8931 8932 8933 8934 8935 8936 8937 |
if (len == 0) {
return JIM_OK;
}
cmdPtr->u.proc.staticVars = Jim_Alloc(sizeof(Jim_HashTable));
Jim_InitHashTable(cmdPtr->u.proc.staticVars, &JimVariablesHashTableType, interp);
for (i = 0; i < len; i++) {
| | | | | | 9089 9090 9091 9092 9093 9094 9095 9096 9097 9098 9099 9100 9101 9102 9103 9104 9105 9106 9107 9108 9109 9110 9111 9112 9113 9114 9115 9116 9117 9118 9119 9120 9121 9122 |
if (len == 0) {
return JIM_OK;
}
cmdPtr->u.proc.staticVars = Jim_Alloc(sizeof(Jim_HashTable));
Jim_InitHashTable(cmdPtr->u.proc.staticVars, &JimVariablesHashTableType, interp);
for (i = 0; i < len; i++) {
Jim_Obj *objPtr, *initObjPtr, *nameObjPtr;
Jim_Var *varPtr;
int subLen;
objPtr = Jim_ListGetIndex(interp, staticsListObjPtr, i);
subLen = Jim_ListLength(interp, objPtr);
if (subLen == 1 || subLen == 2) {
nameObjPtr = Jim_ListGetIndex(interp, objPtr, 0);
if (subLen == 1) {
initObjPtr = Jim_GetVariable(interp, nameObjPtr, JIM_NONE);
if (initObjPtr == NULL) {
Jim_SetResultFormatted(interp,
"variable for initialization of static \"%#s\" not found in the local context",
nameObjPtr);
return JIM_ERR;
}
}
else {
initObjPtr = Jim_ListGetIndex(interp, objPtr, 1);
}
if (JimValidName(interp, "static variable", nameObjPtr) != JIM_OK) {
return JIM_ERR;
}
varPtr = Jim_Alloc(sizeof(*varPtr));
varPtr->objPtr = initObjPtr;
|
| ︙ | ︙ | |||
9036 9037 9038 9039 9040 9041 9042 |
for (i = 0; i < argListLen; i++) {
Jim_Obj *argPtr;
Jim_Obj *nameObjPtr;
Jim_Obj *defaultObjPtr;
int len;
| | | | | 9194 9195 9196 9197 9198 9199 9200 9201 9202 9203 9204 9205 9206 9207 9208 9209 9210 9211 9212 9213 9214 9215 9216 9217 9218 9219 9220 9221 9222 9223 9224 |
for (i = 0; i < argListLen; i++) {
Jim_Obj *argPtr;
Jim_Obj *nameObjPtr;
Jim_Obj *defaultObjPtr;
int len;
argPtr = Jim_ListGetIndex(interp, argListObjPtr, i);
len = Jim_ListLength(interp, argPtr);
if (len == 0) {
Jim_SetResultString(interp, "argument with no name", -1);
err:
JimDecrCmdRefCount(interp, cmdPtr);
return NULL;
}
if (len > 2) {
Jim_SetResultFormatted(interp, "too many fields in argument specifier \"%#s\"", argPtr);
goto err;
}
if (len == 2) {
nameObjPtr = Jim_ListGetIndex(interp, argPtr, 0);
defaultObjPtr = Jim_ListGetIndex(interp, argPtr, 1);
}
else {
nameObjPtr = argPtr;
defaultObjPtr = NULL;
}
|
| ︙ | ︙ | |||
9130 9131 9132 9133 9134 9135 9136 |
Jim_SetResultFormatted(interp, "can't rename \"%s\": command doesn't exist", oldName);
}
else if (Jim_FindHashEntry(&interp->commands, fqnew)) {
Jim_SetResultFormatted(interp, "can't rename to \"%s\": command already exists", newName);
}
else {
| | | 9288 9289 9290 9291 9292 9293 9294 9295 9296 9297 9298 9299 9300 9301 9302 |
Jim_SetResultFormatted(interp, "can't rename \"%s\": command doesn't exist", oldName);
}
else if (Jim_FindHashEntry(&interp->commands, fqnew)) {
Jim_SetResultFormatted(interp, "can't rename to \"%s\": command already exists", newName);
}
else {
cmdPtr = Jim_GetHashEntryVal(he);
JimIncrCmdRefCount(cmdPtr);
JimUpdateProcNamespace(interp, cmdPtr, fqnew);
Jim_AddHashEntry(&interp->commands, fqnew, cmdPtr);
Jim_DeleteHashEntry(&interp->commands, fqold);
|
| ︙ | ︙ | |||
9215 9216 9217 9218 9219 9220 9221 |
Jim_SetResultFormatted(interp, "invalid command name \"%#s\"", objPtr);
}
return NULL;
}
#ifdef jim_ext_namespace
found:
#endif
| | | 9373 9374 9375 9376 9377 9378 9379 9380 9381 9382 9383 9384 9385 9386 9387 |
Jim_SetResultFormatted(interp, "invalid command name \"%#s\"", objPtr);
}
return NULL;
}
#ifdef jim_ext_namespace
found:
#endif
cmd = Jim_GetHashEntryVal(he);
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &commandObjType;
objPtr->internalRep.cmdValue.procEpoch = interp->procEpoch;
objPtr->internalRep.cmdValue.cmdPtr = cmd;
objPtr->internalRep.cmdValue.nsObj = interp->framePtr->nsObj;
|
| ︙ | ︙ | |||
9321 9322 9323 9324 9325 9326 9327 |
}
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &variableObjType;
objPtr->internalRep.varValue.callFrameId = framePtr->id;
| | | 9479 9480 9481 9482 9483 9484 9485 9486 9487 9488 9489 9490 9491 9492 9493 |
}
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &variableObjType;
objPtr->internalRep.varValue.callFrameId = framePtr->id;
objPtr->internalRep.varValue.varPtr = Jim_GetHashEntryVal(he);
objPtr->internalRep.varValue.global = global;
return JIM_OK;
}
static int JimDictSugarSet(Jim_Interp *interp, Jim_Obj *ObjPtr, Jim_Obj *valObjPtr);
static Jim_Obj *JimDictSugarGet(Jim_Interp *interp, Jim_Obj *ObjPtr, int flags);
|
| ︙ | ︙ | |||
9639 9640 9641 9642 9643 9644 9645 |
else {
framePtr = interp->framePtr;
}
retval = Jim_DeleteHashEntry(&framePtr->vars, name);
if (retval == JIM_OK) {
| | | 9797 9798 9799 9800 9801 9802 9803 9804 9805 9806 9807 9808 9809 9810 9811 |
else {
framePtr = interp->framePtr;
}
retval = Jim_DeleteHashEntry(&framePtr->vars, name);
if (retval == JIM_OK) {
framePtr->id = interp->callFrameEpoch++;
}
}
}
if (retval != JIM_OK && (flags & JIM_ERRMSG)) {
Jim_SetResultFormatted(interp, "can't unset \"%#s\": no such variable", nameObjPtr);
}
return retval;
|
| ︙ | ︙ | |||
9723 9724 9725 9726 9727 9728 9729 |
dictObjPtr = Jim_GetVariable(interp, varObjPtr, JIM_ERRMSG);
if (!dictObjPtr) {
return NULL;
}
ret = Jim_DictKey(interp, dictObjPtr, keyObjPtr, &resObjPtr, JIM_NONE);
if (ret != JIM_OK) {
| < < | | < < < | | < < < | < < | < | 9881 9882 9883 9884 9885 9886 9887 9888 9889 9890 9891 9892 9893 9894 9895 9896 9897 9898 9899 9900 9901 |
dictObjPtr = Jim_GetVariable(interp, varObjPtr, JIM_ERRMSG);
if (!dictObjPtr) {
return NULL;
}
ret = Jim_DictKey(interp, dictObjPtr, keyObjPtr, &resObjPtr, JIM_NONE);
if (ret != JIM_OK) {
Jim_SetResultFormatted(interp,
"can't read \"%#s(%#s)\": %s array", varObjPtr, keyObjPtr,
ret < 0 ? "variable isn't" : "no such element in");
}
else if ((flags & JIM_UNSHARED) && Jim_IsShared(dictObjPtr)) {
Jim_SetVariable(interp, varObjPtr, Jim_DuplicateObj(interp, dictObjPtr));
}
return resObjPtr;
}
static Jim_Obj *JimDictSugarGet(Jim_Interp *interp, Jim_Obj *objPtr, int flags)
|
| ︙ | ︙ | |||
9841 9842 9843 9844 9845 9846 9847 9848 9849 9850 |
static Jim_CallFrame *JimCreateCallFrame(Jim_Interp *interp, Jim_CallFrame *parent, Jim_Obj *nsObj)
{
Jim_CallFrame *cf;
if (interp->freeFramesList) {
cf = interp->freeFramesList;
interp->freeFramesList = cf->next;
}
else {
cf = Jim_Alloc(sizeof(*cf));
| > > > > > > > > > > > > | > < < < < < < < < | < < < < < < < > | | | | | | | | > > | | | | < < < < | 9988 9989 9990 9991 9992 9993 9994 9995 9996 9997 9998 9999 10000 10001 10002 10003 10004 10005 10006 10007 10008 10009 10010 10011 10012 10013 10014 10015 10016 10017 10018 10019 10020 10021 10022 10023 10024 10025 10026 10027 10028 10029 10030 10031 10032 10033 10034 10035 10036 10037 10038 10039 10040 10041 10042 10043 10044 10045 10046 10047 10048 10049 10050 10051 10052 10053 10054 10055 10056 10057 10058 10059 10060 10061 10062 10063 10064 10065 10066 10067 10068 10069 10070 10071 10072 10073 10074 10075 10076 10077 10078 10079 10080 10081 10082 10083 10084 10085 10086 10087 10088 10089 10090 10091 10092 10093 10094 10095 10096 10097 10098 10099 10100 10101 10102 10103 10104 10105 10106 |
static Jim_CallFrame *JimCreateCallFrame(Jim_Interp *interp, Jim_CallFrame *parent, Jim_Obj *nsObj)
{
Jim_CallFrame *cf;
if (interp->freeFramesList) {
cf = interp->freeFramesList;
interp->freeFramesList = cf->next;
cf->argv = NULL;
cf->argc = 0;
cf->procArgsObjPtr = NULL;
cf->procBodyObjPtr = NULL;
cf->next = NULL;
cf->staticVars = NULL;
cf->localCommands = NULL;
cf->tailcall = 0;
cf->tailcallObj = NULL;
cf->tailcallCmd = NULL;
}
else {
cf = Jim_Alloc(sizeof(*cf));
memset(cf, 0, sizeof(*cf));
Jim_InitHashTable(&cf->vars, &JimVariablesHashTableType, interp);
}
cf->id = interp->callFrameEpoch++;
cf->parent = parent;
cf->level = parent ? parent->level + 1 : 0;
cf->nsObj = nsObj;
Jim_IncrRefCount(nsObj);
return cf;
}
static int JimDeleteLocalProcs(Jim_Interp *interp, Jim_Stack *localCommands)
{
if (localCommands) {
Jim_Obj *cmdNameObj;
while ((cmdNameObj = Jim_StackPop(localCommands)) != NULL) {
Jim_HashEntry *he;
Jim_Obj *fqObjName;
Jim_HashTable *ht = &interp->commands;
const char *fqname = JimQualifyName(interp, Jim_String(cmdNameObj), &fqObjName);
he = Jim_FindHashEntry(ht, fqname);
if (he) {
Jim_Cmd *cmd = Jim_GetHashEntryVal(he);
if (cmd->prevCmd) {
Jim_Cmd *prevCmd = cmd->prevCmd;
cmd->prevCmd = NULL;
JimDecrCmdRefCount(interp, cmd);
Jim_SetHashVal(ht, he, prevCmd);
}
else {
Jim_DeleteHashEntry(ht, fqname);
Jim_InterpIncrProcEpoch(interp);
}
}
Jim_DecrRefCount(interp, cmdNameObj);
JimFreeQualifiedName(interp, fqObjName);
}
Jim_FreeStack(localCommands);
Jim_Free(localCommands);
}
return JIM_OK;
}
#define JIM_FCF_FULL 0
#define JIM_FCF_REUSE 1
static void JimFreeCallFrame(Jim_Interp *interp, Jim_CallFrame *cf, int action)
{
JimDeleteLocalProcs(interp, cf->localCommands);
if (cf->procArgsObjPtr)
Jim_DecrRefCount(interp, cf->procArgsObjPtr);
if (cf->procBodyObjPtr)
Jim_DecrRefCount(interp, cf->procBodyObjPtr);
Jim_DecrRefCount(interp, cf->nsObj);
if (action == JIM_FCF_FULL || cf->vars.size != JIM_HT_INITIAL_SIZE)
Jim_FreeHashTable(&cf->vars);
else {
int i;
Jim_HashEntry **table = cf->vars.table, *he;
for (i = 0; i < JIM_HT_INITIAL_SIZE; i++) {
he = table[i];
while (he != NULL) {
Jim_HashEntry *nextEntry = he->next;
Jim_Var *varPtr = Jim_GetHashEntryVal(he);
Jim_DecrRefCount(interp, varPtr->objPtr);
Jim_Free(Jim_GetHashEntryKey(he));
Jim_Free(varPtr);
Jim_Free(he);
table[i] = NULL;
he = nextEntry;
}
}
cf->vars.used = 0;
}
cf->next = interp->freeFramesList;
interp->freeFramesList = cf;
}
#ifdef JIM_REFERENCES
static void JimReferencesHTValDestructor(void *interp, void *val)
{
|
| ︙ | ︙ | |||
10029 10030 10031 10032 10033 10034 10035 |
"reference",
NULL,
NULL,
UpdateStringOfReference,
JIM_TYPE_REFERENCES,
};
| | < < | < < < | | 10173 10174 10175 10176 10177 10178 10179 10180 10181 10182 10183 10184 10185 10186 10187 10188 10189 10190 10191 10192 |
"reference",
NULL,
NULL,
UpdateStringOfReference,
JIM_TYPE_REFERENCES,
};
static void UpdateStringOfReference(struct Jim_Obj *objPtr)
{
char buf[JIM_REFERENCE_SPACE + 1];
JimFormatReference(buf, objPtr->internalRep.refValue.refPtr, objPtr->internalRep.refValue.id);
JimSetStringBytes(objPtr, buf);
}
static int isrefchar(int c)
{
return (c == '_' || isalnum(c));
}
|
| ︙ | ︙ | |||
10094 10095 10096 10097 10098 10099 10100 |
goto badformat;
he = Jim_FindHashEntry(&interp->references, &value);
if (he == NULL) {
Jim_SetResultFormatted(interp, "invalid reference id \"%#s\"", objPtr);
return JIM_ERR;
}
| | | 10233 10234 10235 10236 10237 10238 10239 10240 10241 10242 10243 10244 10245 10246 10247 |
goto badformat;
he = Jim_FindHashEntry(&interp->references, &value);
if (he == NULL) {
Jim_SetResultFormatted(interp, "invalid reference id \"%#s\"", objPtr);
return JIM_ERR;
}
refPtr = Jim_GetHashEntryVal(he);
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &referenceObjType;
objPtr->internalRep.refValue.id = value;
objPtr->internalRep.refValue.refPtr = refPtr;
return JIM_OK;
|
| ︙ | ︙ | |||
10277 10278 10279 10280 10281 10282 10283 |
Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
return i;
}
void Jim_FreeInterp(Jim_Interp *i)
{
| | > > > > > > > | < < < < < | | | | | | > > | > | < | | | < < < < | 10416 10417 10418 10419 10420 10421 10422 10423 10424 10425 10426 10427 10428 10429 10430 10431 10432 10433 10434 10435 10436 10437 10438 10439 10440 10441 10442 10443 10444 10445 10446 10447 10448 10449 10450 10451 10452 10453 10454 10455 10456 10457 10458 10459 10460 10461 10462 10463 10464 10465 10466 10467 10468 10469 10470 10471 10472 10473 10474 10475 10476 10477 10478 10479 10480 10481 10482 10483 10484 10485 10486 10487 10488 10489 10490 10491 10492 10493 10494 10495 10496 10497 10498 10499 10500 10501 |
Jim_SetVariableStr(i, "tcl_platform(wordSize)", Jim_NewIntObj(i, sizeof(jim_wide)));
return i;
}
void Jim_FreeInterp(Jim_Interp *i)
{
Jim_CallFrame *cf, *cfx;
Jim_Obj *objPtr, *nextObjPtr;
for (cf = i->framePtr; cf; cf = cfx) {
cfx = cf->parent;
JimFreeCallFrame(i, cf, JIM_FCF_FULL);
}
Jim_DecrRefCount(i, i->emptyObj);
Jim_DecrRefCount(i, i->trueObj);
Jim_DecrRefCount(i, i->falseObj);
Jim_DecrRefCount(i, i->result);
Jim_DecrRefCount(i, i->stackTrace);
Jim_DecrRefCount(i, i->errorProc);
Jim_DecrRefCount(i, i->unknown);
Jim_DecrRefCount(i, i->errorFileNameObj);
Jim_DecrRefCount(i, i->currentScriptObj);
Jim_DecrRefCount(i, i->nullScriptObj);
Jim_FreeHashTable(&i->commands);
#ifdef JIM_REFERENCES
Jim_FreeHashTable(&i->references);
#endif
Jim_FreeHashTable(&i->packages);
Jim_Free(i->prngState);
Jim_FreeHashTable(&i->assocData);
#ifdef JIM_MAINTAINER
if (i->liveList != NULL) {
objPtr = i->liveList;
printf("\n-------------------------------------\n");
printf("Objects still in the free list:\n");
while (objPtr) {
const char *type = objPtr->typePtr ? objPtr->typePtr->name : "string";
if (objPtr->bytes && strlen(objPtr->bytes) > 20) {
printf("%p (%d) %-10s: '%.20s...'\n",
(void *)objPtr, objPtr->refCount, type, objPtr->bytes);
}
else {
printf("%p (%d) %-10s: '%s'\n",
(void *)objPtr, objPtr->refCount, type, objPtr->bytes ? objPtr->bytes : "(null)");
}
if (objPtr->typePtr == &sourceObjType) {
printf("FILE %s LINE %d\n",
Jim_String(objPtr->internalRep.sourceValue.fileNameObj),
objPtr->internalRep.sourceValue.lineNumber);
}
objPtr = objPtr->nextObjPtr;
}
printf("-------------------------------------\n\n");
JimPanic((1, "Live list non empty freeing the interpreter! Leak?"));
}
#endif
objPtr = i->freeList;
while (objPtr) {
nextObjPtr = objPtr->nextObjPtr;
Jim_Free(objPtr);
objPtr = nextObjPtr;
}
for (cf = i->freeFramesList; cf; cf = cfx) {
cfx = cf->next;
if (cf->vars.table)
Jim_FreeHashTable(&cf->vars);
Jim_Free(cf);
}
Jim_Free(i);
}
Jim_CallFrame *Jim_GetCallFrameByLevel(Jim_Interp *interp, Jim_Obj *levelObjPtr)
{
|
| ︙ | ︙ | |||
10453 10454 10455 10456 10457 10458 10459 |
if (len >= 3) {
if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
interp->addStackTrace = 1;
}
}
}
| < | 10592 10593 10594 10595 10596 10597 10598 10599 10600 10601 10602 10603 10604 10605 |
if (len >= 3) {
if (Jim_Length(Jim_ListGetIndex(interp, interp->stackTrace, len - 2)) == 0) {
interp->addStackTrace = 1;
}
}
}
static void JimAppendStackTrace(Jim_Interp *interp, const char *procname,
Jim_Obj *fileNameObj, int linenr)
{
if (strcmp(procname, "unknown") == 0) {
procname = "";
}
if (!*procname && !Jim_Length(fileNameObj)) {
|
| ︙ | ︙ | |||
10511 10512 10513 10514 10515 10516 10517 |
}
void *Jim_GetAssocData(Jim_Interp *interp, const char *key)
{
Jim_HashEntry *entryPtr = Jim_FindHashEntry(&interp->assocData, key);
if (entryPtr != NULL) {
| | < | 10649 10650 10651 10652 10653 10654 10655 10656 10657 10658 10659 10660 10661 10662 10663 |
}
void *Jim_GetAssocData(Jim_Interp *interp, const char *key)
{
Jim_HashEntry *entryPtr = Jim_FindHashEntry(&interp->assocData, key);
if (entryPtr != NULL) {
AssocDataValue *assocEntryPtr = Jim_GetHashEntryVal(entryPtr);
return assocEntryPtr->data;
}
return NULL;
}
int Jim_DeleteAssocData(Jim_Interp *interp, const char *key)
{
|
| ︙ | ︙ | |||
10550 10551 10552 10553 10554 10555 10556 |
UpdateStringOfInt,
JIM_TYPE_NONE,
};
static void UpdateStringOfInt(struct Jim_Obj *objPtr)
{
| < > > > > > > > > > | > > > > > > | > > > > | > > > > > | > | | 10687 10688 10689 10690 10691 10692 10693 10694 10695 10696 10697 10698 10699 10700 10701 10702 10703 10704 10705 10706 10707 10708 10709 10710 10711 10712 10713 10714 10715 10716 10717 10718 10719 10720 10721 10722 10723 10724 10725 10726 10727 10728 10729 10730 10731 10732 10733 10734 |
UpdateStringOfInt,
JIM_TYPE_NONE,
};
static void UpdateStringOfInt(struct Jim_Obj *objPtr)
{
char buf[JIM_INTEGER_SPACE + 1];
jim_wide wideValue = JimWideValue(objPtr);
int pos = 0;
if (wideValue == 0) {
buf[pos++] = '0';
}
else {
char tmp[JIM_INTEGER_SPACE];
int num = 0;
int i;
if (wideValue < 0) {
buf[pos++] = '-';
i = wideValue % 10;
tmp[num++] = (i > 0) ? (10 - i) : -i;
wideValue /= -10;
}
while (wideValue) {
tmp[num++] = wideValue % 10;
wideValue /= 10;
}
for (i = 0; i < num; i++) {
buf[pos++] = '0' + tmp[num - i - 1];
}
}
buf[pos] = 0;
JimSetStringBytes(objPtr, buf);
}
static int SetIntFromAny(Jim_Interp *interp, Jim_Obj *objPtr, int flags)
{
jim_wide wideValue;
const char *str;
if (objPtr->typePtr == &coercedDoubleObjType) {
objPtr->typePtr = &intObjType;
|
| ︙ | ︙ | |||
10651 10652 10653 10654 10655 10656 10657 |
"double",
NULL,
NULL,
UpdateStringOfDouble,
JIM_TYPE_NONE,
};
| > > > > > > > > > | > | > > > > > > > > > > > > > > | > > | > > > > > | > > > > > > > > | > > > | | | > | | 10812 10813 10814 10815 10816 10817 10818 10819 10820 10821 10822 10823 10824 10825 10826 10827 10828 10829 10830 10831 10832 10833 10834 10835 10836 10837 10838 10839 10840 10841 10842 10843 10844 10845 10846 10847 10848 10849 10850 10851 10852 10853 10854 10855 10856 10857 10858 10859 10860 10861 10862 10863 10864 10865 10866 10867 10868 10869 10870 10871 10872 10873 10874 10875 10876 10877 10878 10879 10880 |
"double",
NULL,
NULL,
UpdateStringOfDouble,
JIM_TYPE_NONE,
};
#ifndef HAVE_ISNAN
#undef isnan
#define isnan(X) ((X) != (X))
#endif
#ifndef HAVE_ISINF
#undef isinf
#define isinf(X) (1.0 / (X) == 0.0)
#endif
static void UpdateStringOfDouble(struct Jim_Obj *objPtr)
{
double value = objPtr->internalRep.doubleValue;
if (isnan(value)) {
JimSetStringBytes(objPtr, "NaN");
return;
}
if (isinf(value)) {
if (value < 0) {
JimSetStringBytes(objPtr, "-Inf");
}
else {
JimSetStringBytes(objPtr, "Inf");
}
return;
}
{
char buf[JIM_DOUBLE_SPACE + 1];
int i;
int len = sprintf(buf, "%.12g", value);
for (i = 0; i < len; i++) {
if (buf[i] == '.' || buf[i] == 'e') {
#if defined(JIM_SPRINTF_DOUBLE_NEEDS_FIX)
char *e = strchr(buf, 'e');
if (e && (e[1] == '-' || e[1] == '+') && e[2] == '0') {
e += 2;
memmove(e, e + 1, len - (e - buf));
}
#endif
break;
}
}
if (buf[i] == '\0') {
buf[i++] = '.';
buf[i++] = '0';
buf[i] = '\0';
}
JimSetStringBytes(objPtr, buf);
}
}
static int SetDoubleFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
double doubleValue;
jim_wide wideValue;
const char *str;
str = Jim_String(objPtr);
|
| ︙ | ︙ | |||
10874 10875 10876 10877 10878 10879 10880 |
}
}
return JIM_ELESTR_SIMPLE;
}
return JIM_ELESTR_QUOTE;
}
| | | | 11078 11079 11080 11081 11082 11083 11084 11085 11086 11087 11088 11089 11090 11091 11092 11093 11094 11095 11096 |
}
}
return JIM_ELESTR_SIMPLE;
}
return JIM_ELESTR_QUOTE;
}
static int BackslashQuoteString(const char *s, int len, char *q)
{
char *p = q;
while (len--) {
switch (*s) {
case ' ':
case '$':
case '"':
case '[':
case ']':
case '{':
|
| ︙ | ︙ | |||
10994 10995 10996 10997 10998 10999 11000 |
realLength += len + 2;
break;
case JIM_ELESTR_QUOTE:
if (i == 0 && strRep[0] == '#') {
*p++ = '\\';
realLength++;
}
| | | 11198 11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 |
realLength += len + 2;
break;
case JIM_ELESTR_QUOTE:
if (i == 0 && strRep[0] == '#') {
*p++ = '\\';
realLength++;
}
qlen = BackslashQuoteString(strRep, len, p);
p += qlen;
realLength += qlen;
break;
}
if (i + 1 != objc) {
*p++ = ' ';
|
| ︙ | ︙ | |||
11030 11031 11032 11033 11034 11035 11036 |
Jim_Obj *fileNameObj;
int linenr;
if (objPtr->typePtr == &listObjType) {
return JIM_OK;
}
| | | 11234 11235 11236 11237 11238 11239 11240 11241 11242 11243 11244 11245 11246 11247 11248 |
Jim_Obj *fileNameObj;
int linenr;
if (objPtr->typePtr == &listObjType) {
return JIM_OK;
}
if (Jim_IsDict(objPtr) && objPtr->bytes == NULL) {
Jim_Obj **listObjPtrPtr;
int len;
int i;
listObjPtrPtr = JimDictPairs(objPtr, &len);
for (i = 0; i < len; i++) {
Jim_IncrRefCount(listObjPtrPtr[i]);
|
| ︙ | ︙ | |||
11134 11135 11136 11137 11138 11139 11140 11141 11142 11143 11144 11145 11146 11147 11148 11149 11150 11151 11152 |
jmp_buf jmpbuf;
Jim_Obj *command;
Jim_Interp *interp;
enum {
JIM_LSORT_ASCII,
JIM_LSORT_NOCASE,
JIM_LSORT_INTEGER,
JIM_LSORT_COMMAND
} type;
int order;
int index;
int indexed;
int (*subfn)(Jim_Obj **, Jim_Obj **);
};
static struct lsort_info *sort_info;
static int ListSortIndexHelper(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
| > > | 11338 11339 11340 11341 11342 11343 11344 11345 11346 11347 11348 11349 11350 11351 11352 11353 11354 11355 11356 11357 11358 |
jmp_buf jmpbuf;
Jim_Obj *command;
Jim_Interp *interp;
enum {
JIM_LSORT_ASCII,
JIM_LSORT_NOCASE,
JIM_LSORT_INTEGER,
JIM_LSORT_REAL,
JIM_LSORT_COMMAND
} type;
int order;
int index;
int indexed;
int unique;
int (*subfn)(Jim_Obj **, Jim_Obj **);
};
static struct lsort_info *sort_info;
static int ListSortIndexHelper(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
|
| ︙ | ︙ | |||
11177 11178 11179 11180 11181 11182 11183 11184 11185 11186 11187 11188 11189 11190 |
if (Jim_GetWide(sort_info->interp, *lhsObj, &lhs) != JIM_OK ||
Jim_GetWide(sort_info->interp, *rhsObj, &rhs) != JIM_OK) {
longjmp(sort_info->jmpbuf, JIM_ERR);
}
return JimSign(lhs - rhs) * sort_info->order;
}
static int ListSortCommand(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
Jim_Obj *compare_script;
int rc;
jim_wide ret = 0;
| > > > > > > > > > > > > > > > > > | 11383 11384 11385 11386 11387 11388 11389 11390 11391 11392 11393 11394 11395 11396 11397 11398 11399 11400 11401 11402 11403 11404 11405 11406 11407 11408 11409 11410 11411 11412 11413 |
if (Jim_GetWide(sort_info->interp, *lhsObj, &lhs) != JIM_OK ||
Jim_GetWide(sort_info->interp, *rhsObj, &rhs) != JIM_OK) {
longjmp(sort_info->jmpbuf, JIM_ERR);
}
return JimSign(lhs - rhs) * sort_info->order;
}
static int ListSortReal(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
double lhs = 0, rhs = 0;
if (Jim_GetDouble(sort_info->interp, *lhsObj, &lhs) != JIM_OK ||
Jim_GetDouble(sort_info->interp, *rhsObj, &rhs) != JIM_OK) {
longjmp(sort_info->jmpbuf, JIM_ERR);
}
if (lhs == rhs) {
return 0;
}
if (lhs > rhs) {
return sort_info->order;
}
return -sort_info->order;
}
static int ListSortCommand(Jim_Obj **lhsObj, Jim_Obj **rhsObj)
{
Jim_Obj *compare_script;
int rc;
jim_wide ret = 0;
|
| ︙ | ︙ | |||
11199 11200 11201 11202 11203 11204 11205 11206 11207 11208 11209 11210 11211 11212 11213 11214 11215 11216 |
if (rc != JIM_OK || Jim_GetWide(sort_info->interp, Jim_GetResult(sort_info->interp), &ret) != JIM_OK) {
longjmp(sort_info->jmpbuf, rc);
}
return JimSign(ret) * sort_info->order;
}
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)
{
struct lsort_info *prev_info;
typedef int (qsort_comparator) (const void *, const void *);
int (*fn) (Jim_Obj **, Jim_Obj **);
Jim_Obj **vector;
int len;
int rc;
| > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > > > | > | 11422 11423 11424 11425 11426 11427 11428 11429 11430 11431 11432 11433 11434 11435 11436 11437 11438 11439 11440 11441 11442 11443 11444 11445 11446 11447 11448 11449 11450 11451 11452 11453 11454 11455 11456 11457 11458 11459 11460 11461 11462 11463 11464 11465 11466 11467 11468 11469 11470 11471 11472 11473 11474 11475 11476 11477 11478 11479 11480 11481 11482 11483 11484 11485 11486 11487 11488 11489 11490 11491 11492 11493 11494 11495 11496 11497 11498 11499 11500 11501 11502 11503 11504 11505 11506 11507 11508 11509 11510 11511 11512 11513 11514 11515 |
if (rc != JIM_OK || Jim_GetWide(sort_info->interp, Jim_GetResult(sort_info->interp), &ret) != JIM_OK) {
longjmp(sort_info->jmpbuf, rc);
}
return JimSign(ret) * sort_info->order;
}
static void ListRemoveDuplicates(Jim_Obj *listObjPtr, int (*comp)(Jim_Obj **lhs, Jim_Obj **rhs))
{
int src;
int dst = 0;
Jim_Obj **ele = listObjPtr->internalRep.listValue.ele;
for (src = 1; src < listObjPtr->internalRep.listValue.len; src++) {
if (comp(&ele[dst], &ele[src]) == 0) {
Jim_DecrRefCount(sort_info->interp, ele[dst]);
}
else {
dst++;
}
ele[dst] = ele[src];
}
ele[++dst] = ele[src];
listObjPtr->internalRep.listValue.len = dst;
}
static int ListSortElements(Jim_Interp *interp, Jim_Obj *listObjPtr, struct lsort_info *info)
{
struct lsort_info *prev_info;
typedef int (qsort_comparator) (const void *, const void *);
int (*fn) (Jim_Obj **, Jim_Obj **);
Jim_Obj **vector;
int len;
int rc;
JimPanic((Jim_IsShared(listObjPtr), "ListSortElements called with shared object"));
SetListFromAny(interp, listObjPtr);
prev_info = sort_info;
sort_info = info;
vector = listObjPtr->internalRep.listValue.ele;
len = listObjPtr->internalRep.listValue.len;
switch (info->type) {
case JIM_LSORT_ASCII:
fn = ListSortString;
break;
case JIM_LSORT_NOCASE:
fn = ListSortStringNoCase;
break;
case JIM_LSORT_INTEGER:
fn = ListSortInteger;
break;
case JIM_LSORT_REAL:
fn = ListSortReal;
break;
case JIM_LSORT_COMMAND:
fn = ListSortCommand;
break;
default:
fn = NULL;
JimPanic((1, "ListSort called with invalid sort type"));
}
if (info->indexed) {
info->subfn = fn;
fn = ListSortIndexHelper;
}
if ((rc = setjmp(info->jmpbuf)) == 0) {
qsort(vector, len, sizeof(Jim_Obj *), (qsort_comparator *) fn);
if (info->unique && len > 1) {
ListRemoveDuplicates(listObjPtr, fn);
}
Jim_InvalidateStringRep(listObjPtr);
}
sort_info = prev_info;
return rc;
}
static void ListInsertElements(Jim_Obj *listPtr, int idx, int elemc, Jim_Obj *const *elemVec)
{
|
| ︙ | ︙ | |||
11375 11376 11377 11378 11379 11380 11381 |
idx = listPtr->internalRep.listValue.len + idx;
Jim_DecrRefCount(interp, listPtr->internalRep.listValue.ele[idx]);
listPtr->internalRep.listValue.ele[idx] = newObjPtr;
Jim_IncrRefCount(newObjPtr);
return JIM_OK;
}
| | | 11630 11631 11632 11633 11634 11635 11636 11637 11638 11639 11640 11641 11642 11643 11644 |
idx = listPtr->internalRep.listValue.len + idx;
Jim_DecrRefCount(interp, listPtr->internalRep.listValue.ele[idx]);
listPtr->internalRep.listValue.ele[idx] = newObjPtr;
Jim_IncrRefCount(newObjPtr);
return JIM_OK;
}
int Jim_ListSetIndex(Jim_Interp *interp, Jim_Obj *varNamePtr,
Jim_Obj *const *indexv, int indexc, Jim_Obj *newObjPtr)
{
Jim_Obj *varObjPtr, *objPtr, *listObjPtr;
int shared, i, idx;
varObjPtr = objPtr = Jim_GetVariable(interp, varNamePtr, JIM_ERRMSG | JIM_UNSHARED);
if (objPtr == NULL)
|
| ︙ | ︙ | |||
11423 11424 11425 11426 11427 11428 11429 |
Jim_Obj *Jim_ListJoin(Jim_Interp *interp, Jim_Obj *listObjPtr, const char *joinStr, int joinStrLen)
{
int i;
int listLen = Jim_ListLength(interp, listObjPtr);
Jim_Obj *resObjPtr = Jim_NewEmptyStringObj(interp);
for (i = 0; i < listLen; ) {
| < < < | | 11678 11679 11680 11681 11682 11683 11684 11685 11686 11687 11688 11689 11690 11691 11692 |
Jim_Obj *Jim_ListJoin(Jim_Interp *interp, Jim_Obj *listObjPtr, const char *joinStr, int joinStrLen)
{
int i;
int listLen = Jim_ListLength(interp, listObjPtr);
Jim_Obj *resObjPtr = Jim_NewEmptyStringObj(interp);
for (i = 0; i < listLen; ) {
Jim_AppendObj(interp, resObjPtr, Jim_ListGetIndex(interp, listObjPtr, i));
if (++i != listLen) {
Jim_AppendString(interp, resObjPtr, joinStr, joinStrLen);
}
}
return resObjPtr;
}
|
| ︙ | ︙ | |||
11456 11457 11458 11459 11460 11461 11462 |
else {
int len = 0, objLen;
char *bytes, *p;
for (i = 0; i < objc; i++) {
| < | | | < > | | < | | > | 11708 11709 11710 11711 11712 11713 11714 11715 11716 11717 11718 11719 11720 11721 11722 11723 11724 11725 11726 11727 11728 11729 11730 11731 11732 11733 11734 11735 11736 11737 11738 11739 11740 11741 11742 11743 11744 11745 11746 11747 11748 11749 11750 11751 11752 11753 |
else {
int len = 0, objLen;
char *bytes, *p;
for (i = 0; i < objc; i++) {
len += Jim_Length(objv[i]);
}
if (objc)
len += objc - 1;
p = bytes = Jim_Alloc(len + 1);
for (i = 0; i < objc; i++) {
const char *s = Jim_GetString(objv[i], &objLen);
while (objLen && isspace(UCHAR(*s))) {
s++;
objLen--;
len--;
}
while (objLen && isspace(UCHAR(s[objLen - 1]))) {
if (objLen > 1 && s[objLen - 2] == '\\') {
break;
}
objLen--;
len--;
}
memcpy(p, s, objLen);
p += objLen;
if (i + 1 != objc) {
if (objLen)
*p++ = ' ';
else {
len--;
}
}
}
*p = '\0';
return Jim_NewStringObjNoAlloc(interp, bytes, len);
}
}
|
| ︙ | ︙ | |||
11532 11533 11534 11535 11536 11537 11538 11539 11540 11541 11542 11543 11544 11545 11546 |
return Jim_GenHashFunction((const unsigned char *)str, len);
}
static int JimObjectHTKeyCompare(void *privdata, const void *key1, const void *key2)
{
return Jim_StringEqObj((Jim_Obj *)key1, (Jim_Obj *)key2);
}
static void JimObjectHTKeyValDestructor(void *interp, void *val)
{
Jim_DecrRefCount(interp, (Jim_Obj *)val);
}
static const Jim_HashTableType JimDictHashTableType = {
JimObjectHTHashFunction,
| > > > > > > < < > > | 11783 11784 11785 11786 11787 11788 11789 11790 11791 11792 11793 11794 11795 11796 11797 11798 11799 11800 11801 11802 11803 11804 11805 11806 11807 11808 11809 11810 11811 11812 |
return Jim_GenHashFunction((const unsigned char *)str, len);
}
static int JimObjectHTKeyCompare(void *privdata, const void *key1, const void *key2)
{
return Jim_StringEqObj((Jim_Obj *)key1, (Jim_Obj *)key2);
}
static void *JimObjectHTKeyValDup(void *privdata, const void *val)
{
Jim_IncrRefCount((Jim_Obj *)val);
return (void *)val;
}
static void JimObjectHTKeyValDestructor(void *interp, void *val)
{
Jim_DecrRefCount(interp, (Jim_Obj *)val);
}
static const Jim_HashTableType JimDictHashTableType = {
JimObjectHTHashFunction,
JimObjectHTKeyValDup,
JimObjectHTKeyValDup,
JimObjectHTKeyCompare,
JimObjectHTKeyValDestructor,
JimObjectHTKeyValDestructor
};
static const Jim_ObjType dictObjType = {
"dict",
|
| ︙ | ︙ | |||
11578 11579 11580 11581 11582 11583 11584 |
dupHt = Jim_Alloc(sizeof(*dupHt));
Jim_InitHashTable(dupHt, &JimDictHashTableType, interp);
if (ht->size != 0)
Jim_ExpandHashTable(dupHt, ht->size);
JimInitHashTableIterator(ht, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
| < < < < < | | 11835 11836 11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 |
dupHt = Jim_Alloc(sizeof(*dupHt));
Jim_InitHashTable(dupHt, &JimDictHashTableType, interp);
if (ht->size != 0)
Jim_ExpandHashTable(dupHt, ht->size);
JimInitHashTableIterator(ht, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
Jim_AddHashEntry(dupHt, he->key, he->u.val);
}
dupPtr->internalRep.ptr = dupHt;
dupPtr->typePtr = &dictObjType;
}
static Jim_Obj **JimDictPairs(Jim_Obj *dictPtr, int *len)
|
| ︙ | ︙ | |||
11605 11606 11607 11608 11609 11610 11611 |
ht = dictPtr->internalRep.ptr;
objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *));
JimInitHashTableIterator(ht, &htiter);
i = 0;
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
| | | > > | > | | < < < < < < | < < < < < < < < < < | < < < < < < | | 11857 11858 11859 11860 11861 11862 11863 11864 11865 11866 11867 11868 11869 11870 11871 11872 11873 11874 11875 11876 11877 11878 11879 11880 11881 11882 11883 11884 11885 11886 11887 11888 11889 11890 11891 11892 11893 11894 11895 11896 11897 11898 11899 11900 11901 11902 11903 11904 11905 11906 11907 11908 11909 11910 11911 11912 11913 11914 11915 11916 11917 11918 11919 11920 11921 11922 11923 11924 11925 11926 11927 11928 11929 11930 11931 11932 11933 11934 11935 11936 11937 11938 11939 11940 11941 11942 11943 11944 11945 11946 11947 11948 11949 11950 11951 11952 11953 |
ht = dictPtr->internalRep.ptr;
objv = Jim_Alloc((ht->used * 2) * sizeof(Jim_Obj *));
JimInitHashTableIterator(ht, &htiter);
i = 0;
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
objv[i++] = Jim_GetHashEntryKey(he);
objv[i++] = Jim_GetHashEntryVal(he);
}
*len = i;
return objv;
}
static void UpdateStringOfDict(struct Jim_Obj *objPtr)
{
int len;
Jim_Obj **objv = JimDictPairs(objPtr, &len);
JimMakeListStringRep(objPtr, objv, len);
Jim_Free(objv);
}
static int SetDictFromAny(Jim_Interp *interp, struct Jim_Obj *objPtr)
{
int listlen;
if (objPtr->typePtr == &dictObjType) {
return JIM_OK;
}
if (Jim_IsList(objPtr) && Jim_IsShared(objPtr)) {
Jim_String(objPtr);
}
listlen = Jim_ListLength(interp, objPtr);
if (listlen % 2) {
Jim_SetResultString(interp, "missing value to go with key", -1);
return JIM_ERR;
}
else {
Jim_HashTable *ht;
int i;
ht = Jim_Alloc(sizeof(*ht));
Jim_InitHashTable(ht, &JimDictHashTableType, interp);
for (i = 0; i < listlen; i += 2) {
Jim_Obj *keyObjPtr = Jim_ListGetIndex(interp, objPtr, i);
Jim_Obj *valObjPtr = Jim_ListGetIndex(interp, objPtr, i + 1);
Jim_ReplaceHashEntry(ht, keyObjPtr, valObjPtr);
}
Jim_FreeIntRep(interp, objPtr);
objPtr->typePtr = &dictObjType;
objPtr->internalRep.ptr = ht;
return JIM_OK;
}
}
static int DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr)
{
Jim_HashTable *ht = objPtr->internalRep.ptr;
if (valueObjPtr == NULL) {
return Jim_DeleteHashEntry(ht, keyObjPtr);
}
Jim_ReplaceHashEntry(ht, keyObjPtr, valueObjPtr);
return JIM_OK;
}
int Jim_DictAddElement(Jim_Interp *interp, Jim_Obj *objPtr,
Jim_Obj *keyObjPtr, Jim_Obj *valueObjPtr)
{
JimPanic((Jim_IsShared(objPtr), "Jim_DictAddElement called with shared object"));
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return JIM_ERR;
}
Jim_InvalidateStringRep(objPtr);
return DictAddElement(interp, objPtr, keyObjPtr, valueObjPtr);
}
Jim_Obj *Jim_NewDictObj(Jim_Interp *interp, Jim_Obj *const *elements, int len)
{
Jim_Obj *objPtr;
int i;
|
| ︙ | ︙ | |||
11837 11838 11839 11840 11841 11842 11843 11844 11845 11846 11847 11848 11849 11850 |
if (newObjPtr == NULL) {
goto err;
}
objPtr = Jim_NewDictObj(interp, NULL, 0);
DictAddElement(interp, dictObjPtr, keyv[i], objPtr);
}
}
Jim_InvalidateStringRep(objPtr);
Jim_InvalidateStringRep(varObjPtr);
if (Jim_SetVariable(interp, varNamePtr, varObjPtr) != JIM_OK) {
goto err;
}
Jim_SetResult(interp, varObjPtr);
return JIM_OK;
| > | 12070 12071 12072 12073 12074 12075 12076 12077 12078 12079 12080 12081 12082 12083 12084 |
if (newObjPtr == NULL) {
goto err;
}
objPtr = Jim_NewDictObj(interp, NULL, 0);
DictAddElement(interp, dictObjPtr, keyv[i], objPtr);
}
}
Jim_InvalidateStringRep(objPtr);
Jim_InvalidateStringRep(varObjPtr);
if (Jim_SetVariable(interp, varNamePtr, varObjPtr) != JIM_OK) {
goto err;
}
Jim_SetResult(interp, varObjPtr);
return JIM_OK;
|
| ︙ | ︙ | |||
11862 11863 11864 11865 11866 11867 11868 |
"index",
NULL,
NULL,
UpdateStringOfIndex,
JIM_TYPE_NONE,
};
| | | | | > > | | < < > | > | | < < | | | > | | 12096 12097 12098 12099 12100 12101 12102 12103 12104 12105 12106 12107 12108 12109 12110 12111 12112 12113 12114 12115 12116 12117 12118 12119 12120 12121 12122 12123 12124 12125 12126 12127 12128 |
"index",
NULL,
NULL,
UpdateStringOfIndex,
JIM_TYPE_NONE,
};
static void UpdateStringOfIndex(struct Jim_Obj *objPtr)
{
if (objPtr->internalRep.intValue == -1) {
JimSetStringBytes(objPtr, "end");
}
else {
char buf[JIM_INTEGER_SPACE + 1];
if (objPtr->internalRep.intValue >= 0) {
sprintf(buf, "%d", objPtr->internalRep.intValue);
}
else {
sprintf(buf, "end%d", objPtr->internalRep.intValue + 1);
}
JimSetStringBytes(objPtr, buf);
}
}
static int SetIndexFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
int idx, end = 0;
const char *str;
char *endptr;
str = Jim_String(objPtr);
|
| ︙ | ︙ | |||
11951 11952 11953 11954 11955 11956 11957 |
int Jim_GetIndex(Jim_Interp *interp, Jim_Obj *objPtr, int *indexPtr)
{
if (objPtr->typePtr == &intObjType) {
jim_wide val = JimWideValue(objPtr);
| | > > > > | | < | 12186 12187 12188 12189 12190 12191 12192 12193 12194 12195 12196 12197 12198 12199 12200 12201 12202 12203 12204 12205 12206 |
int Jim_GetIndex(Jim_Interp *interp, Jim_Obj *objPtr, int *indexPtr)
{
if (objPtr->typePtr == &intObjType) {
jim_wide val = JimWideValue(objPtr);
if (val < 0)
*indexPtr = -INT_MAX;
else if (val > INT_MAX)
*indexPtr = INT_MAX;
else
*indexPtr = (int)val;
return JIM_OK;
}
if (objPtr->typePtr != &indexObjType && SetIndexFromAny(interp, objPtr) == JIM_ERR)
return JIM_ERR;
*indexPtr = objPtr->internalRep.intValue;
return JIM_OK;
}
|
| ︙ | ︙ | |||
11978 11979 11980 11981 11982 11983 11984 |
"exit",
"eval",
NULL
};
#define jimReturnCodesSize (sizeof(jimReturnCodes)/sizeof(*jimReturnCodes))
| < < | | 12216 12217 12218 12219 12220 12221 12222 12223 12224 12225 12226 12227 12228 12229 12230 12231 12232 12233 12234 12235 12236 12237 12238 12239 12240 12241 12242 12243 12244 12245 12246 12247 12248 |
"exit",
"eval",
NULL
};
#define jimReturnCodesSize (sizeof(jimReturnCodes)/sizeof(*jimReturnCodes))
static const Jim_ObjType returnCodeObjType = {
"return-code",
NULL,
NULL,
NULL,
JIM_TYPE_NONE,
};
const char *Jim_ReturnCode(int code)
{
if (code < 0 || code >= (int)jimReturnCodesSize) {
return "?";
}
else {
return jimReturnCodes[code];
}
}
static int SetReturnCodeFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
int returnCode;
jim_wide wideValue;
if (JimGetWideNoErr(interp, objPtr, &wideValue) != JIM_ERR)
returnCode = (int)wideValue;
|
| ︙ | ︙ | |||
12150 12151 12152 12153 12154 12155 12156 |
static Jim_Obj *ExprPop(struct JimExprState *e)
{
return e->stack[--e->stacklen];
}
static int JimExprOpNumUnary(Jim_Interp *interp, struct JimExprState *e)
{
| | < < < < > < < < < < > > > < < | < | 12386 12387 12388 12389 12390 12391 12392 12393 12394 12395 12396 12397 12398 12399 12400 12401 12402 12403 12404 12405 12406 12407 12408 12409 12410 12411 12412 12413 12414 12415 12416 12417 12418 12419 12420 12421 12422 12423 12424 12425 12426 12427 12428 12429 12430 12431 12432 12433 12434 12435 12436 12437 12438 12439 12440 12441 12442 12443 12444 12445 12446 12447 12448 12449 12450 12451 12452 |
static Jim_Obj *ExprPop(struct JimExprState *e)
{
return e->stack[--e->stacklen];
}
static int JimExprOpNumUnary(Jim_Interp *interp, struct JimExprState *e)
{
int intresult = 1;
int rc = JIM_OK;
Jim_Obj *A = ExprPop(e);
double dA, dC = 0;
jim_wide wA, wC = 0;
if ((A->typePtr != &doubleObjType || A->bytes) && JimGetWideNoErr(interp, A, &wA) == JIM_OK) {
switch (e->opcode) {
case JIM_EXPROP_FUNC_INT:
case JIM_EXPROP_FUNC_ROUND:
case JIM_EXPROP_UNARYPLUS:
wC = wA;
break;
case JIM_EXPROP_FUNC_DOUBLE:
dC = wA;
intresult = 0;
break;
case JIM_EXPROP_FUNC_ABS:
wC = wA >= 0 ? wA : -wA;
break;
case JIM_EXPROP_UNARYMINUS:
wC = -wA;
break;
case JIM_EXPROP_NOT:
wC = !wA;
break;
default:
abort();
}
}
else if ((rc = Jim_GetDouble(interp, A, &dA)) == JIM_OK) {
switch (e->opcode) {
case JIM_EXPROP_FUNC_INT:
wC = dA;
break;
case JIM_EXPROP_FUNC_ROUND:
wC = dA < 0 ? (dA - 0.5) : (dA + 0.5);
break;
case JIM_EXPROP_FUNC_DOUBLE:
case JIM_EXPROP_UNARYPLUS:
dC = dA;
intresult = 0;
break;
case JIM_EXPROP_FUNC_ABS:
dC = dA >= 0 ? dA : -dA;
intresult = 0;
break;
case JIM_EXPROP_UNARYMINUS:
dC = -dA;
intresult = 0;
break;
case JIM_EXPROP_NOT:
wC = !dA;
break;
default:
abort();
}
}
if (rc == JIM_OK) {
|
| ︙ | ︙ | |||
12425 12426 12427 12428 12429 12430 12431 |
return rc;
}
static int JimExprOpBin(Jim_Interp *interp, struct JimExprState *e)
{
| | < < | 12653 12654 12655 12656 12657 12658 12659 12660 12661 12662 12663 12664 12665 12666 12667 12668 12669 12670 12671 12672 12673 12674 12675 12676 12677 12678 12679 12680 |
return rc;
}
static int JimExprOpBin(Jim_Interp *interp, struct JimExprState *e)
{
int intresult = 1;
int rc = JIM_OK;
double dA, dB, dC = 0;
jim_wide wA, wB, wC = 0;
Jim_Obj *B = ExprPop(e);
Jim_Obj *A = ExprPop(e);
if ((A->typePtr != &doubleObjType || A->bytes) &&
(B->typePtr != &doubleObjType || B->bytes) &&
JimGetWideNoErr(interp, A, &wA) == JIM_OK && JimGetWideNoErr(interp, B, &wB) == JIM_OK) {
switch (e->opcode) {
case JIM_EXPROP_POW:
case JIM_EXPROP_FUNC_POW:
wC = JimPowWide(wA, wB);
break;
case JIM_EXPROP_ADD:
wC = wA + wB;
|
| ︙ | ︙ | |||
12494 12495 12496 12497 12498 12499 12500 12501 12502 12503 12504 12505 12506 12507 |
wC = wA != wB;
break;
default:
abort();
}
}
else if (Jim_GetDouble(interp, A, &dA) == JIM_OK && Jim_GetDouble(interp, B, &dB) == JIM_OK) {
switch (e->opcode) {
case JIM_EXPROP_POW:
case JIM_EXPROP_FUNC_POW:
#ifdef JIM_MATH_FUNCTIONS
dC = pow(dA, dB);
#else
Jim_SetResultString(interp, "unsupported", -1);
| > | 12720 12721 12722 12723 12724 12725 12726 12727 12728 12729 12730 12731 12732 12733 12734 |
wC = wA != wB;
break;
default:
abort();
}
}
else if (Jim_GetDouble(interp, A, &dA) == JIM_OK && Jim_GetDouble(interp, B, &dB) == JIM_OK) {
intresult = 0;
switch (e->opcode) {
case JIM_EXPROP_POW:
case JIM_EXPROP_FUNC_POW:
#ifdef JIM_MATH_FUNCTIONS
dC = pow(dA, dB);
#else
Jim_SetResultString(interp, "unsupported", -1);
|
| ︙ | ︙ | |||
12559 12560 12561 12562 12563 12564 12565 |
}
else {
int i = Jim_StringCompareObj(interp, A, B, 0);
| < < | 12786 12787 12788 12789 12790 12791 12792 12793 12794 12795 12796 12797 12798 12799 |
}
else {
int i = Jim_StringCompareObj(interp, A, B, 0);
switch (e->opcode) {
case JIM_EXPROP_LT:
wC = i < 0;
break;
case JIM_EXPROP_GT:
wC = i > 0;
break;
|
| ︙ | ︙ | |||
12608 12609 12610 12611 12612 12613 12614 |
static int JimSearchList(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_Obj *valObj)
{
int listlen;
int i;
listlen = Jim_ListLength(interp, listObjPtr);
for (i = 0; i < listlen; i++) {
| < < < < | | < < < | | | < < < < | 12833 12834 12835 12836 12837 12838 12839 12840 12841 12842 12843 12844 12845 12846 12847 12848 12849 12850 12851 12852 12853 12854 12855 12856 12857 12858 12859 12860 12861 12862 12863 12864 12865 12866 12867 12868 |
static int JimSearchList(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_Obj *valObj)
{
int listlen;
int i;
listlen = Jim_ListLength(interp, listObjPtr);
for (i = 0; i < listlen; i++) {
if (Jim_StringEqObj(Jim_ListGetIndex(interp, listObjPtr, i), valObj)) {
return 1;
}
}
return 0;
}
static int JimExprOpStrBin(Jim_Interp *interp, struct JimExprState *e)
{
Jim_Obj *B = ExprPop(e);
Jim_Obj *A = ExprPop(e);
jim_wide wC;
switch (e->opcode) {
case JIM_EXPROP_STREQ:
case JIM_EXPROP_STRNE:
wC = Jim_StringEqObj(A, B);
if (e->opcode == JIM_EXPROP_STRNE) {
wC = !wC;
}
break;
case JIM_EXPROP_STRIN:
wC = JimSearchList(interp, B, A);
break;
case JIM_EXPROP_STRNI:
wC = !JimSearchList(interp, B, A);
break;
default:
|
| ︙ | ︙ | |||
12816 12817 12818 12819 12820 12821 12822 |
{
LAZY_NONE,
LAZY_OP,
LAZY_LEFT,
LAZY_RIGHT
};
| > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > | < | < | 13030 13031 13032 13033 13034 13035 13036 13037 13038 13039 13040 13041 13042 13043 13044 13045 13046 13047 13048 13049 13050 13051 13052 13053 13054 13055 13056 13057 13058 13059 13060 13061 13062 13063 13064 13065 13066 13067 13068 13069 13070 13071 13072 13073 13074 13075 13076 13077 13078 13079 13080 13081 13082 13083 13084 13085 13086 13087 13088 13089 13090 13091 13092 13093 13094 13095 13096 13097 13098 13099 13100 13101 13102 13103 13104 13105 13106 13107 13108 13109 13110 13111 13112 13113 13114 13115 13116 13117 13118 13119 13120 13121 13122 13123 13124 13125 13126 13127 13128 13129 13130 13131 13132 13133 13134 13135 13136 13137 13138 13139 13140 13141 13142 13143 13144 13145 13146 13147 13148 13149 13150 13151 13152 13153 13154 13155 13156 13157 13158 13159 13160 13161 13162 13163 13164 13165 13166 13167 |
{
LAZY_NONE,
LAZY_OP,
LAZY_LEFT,
LAZY_RIGHT
};
#define OPRINIT(N, P, A, F) {N, F, P, A, LAZY_NONE, sizeof(N) - 1}
#define OPRINIT_LAZY(N, P, A, F, L) {N, F, P, A, L, sizeof(N) - 1}
static const struct Jim_ExprOperator Jim_ExprOperators[] = {
OPRINIT("*", 110, 2, JimExprOpBin),
OPRINIT("/", 110, 2, JimExprOpBin),
OPRINIT("%", 110, 2, JimExprOpIntBin),
OPRINIT("-", 100, 2, JimExprOpBin),
OPRINIT("+", 100, 2, JimExprOpBin),
OPRINIT("<<", 90, 2, JimExprOpIntBin),
OPRINIT(">>", 90, 2, JimExprOpIntBin),
OPRINIT("<<<", 90, 2, JimExprOpIntBin),
OPRINIT(">>>", 90, 2, JimExprOpIntBin),
OPRINIT("<", 80, 2, JimExprOpBin),
OPRINIT(">", 80, 2, JimExprOpBin),
OPRINIT("<=", 80, 2, JimExprOpBin),
OPRINIT(">=", 80, 2, JimExprOpBin),
OPRINIT("==", 70, 2, JimExprOpBin),
OPRINIT("!=", 70, 2, JimExprOpBin),
OPRINIT("&", 50, 2, JimExprOpIntBin),
OPRINIT("^", 49, 2, JimExprOpIntBin),
OPRINIT("|", 48, 2, JimExprOpIntBin),
OPRINIT_LAZY("&&", 10, 2, NULL, LAZY_OP),
OPRINIT_LAZY(NULL, 10, 2, JimExprOpAndLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 10, 2, JimExprOpAndOrRight, LAZY_RIGHT),
OPRINIT_LAZY("||", 9, 2, NULL, LAZY_OP),
OPRINIT_LAZY(NULL, 9, 2, JimExprOpOrLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 9, 2, JimExprOpAndOrRight, LAZY_RIGHT),
OPRINIT_LAZY("?", 5, 2, JimExprOpNull, LAZY_OP),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpTernaryLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT),
OPRINIT_LAZY(":", 5, 2, JimExprOpNull, LAZY_OP),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpColonLeft, LAZY_LEFT),
OPRINIT_LAZY(NULL, 5, 2, JimExprOpNull, LAZY_RIGHT),
OPRINIT("**", 250, 2, JimExprOpBin),
OPRINIT("eq", 60, 2, JimExprOpStrBin),
OPRINIT("ne", 60, 2, JimExprOpStrBin),
OPRINIT("in", 55, 2, JimExprOpStrBin),
OPRINIT("ni", 55, 2, JimExprOpStrBin),
OPRINIT("!", 150, 1, JimExprOpNumUnary),
OPRINIT("~", 150, 1, JimExprOpIntUnary),
OPRINIT(NULL, 150, 1, JimExprOpNumUnary),
OPRINIT(NULL, 150, 1, JimExprOpNumUnary),
OPRINIT("int", 200, 1, JimExprOpNumUnary),
OPRINIT("abs", 200, 1, JimExprOpNumUnary),
OPRINIT("double", 200, 1, JimExprOpNumUnary),
OPRINIT("round", 200, 1, JimExprOpNumUnary),
OPRINIT("rand", 200, 0, JimExprOpNone),
OPRINIT("srand", 200, 1, JimExprOpIntUnary),
#ifdef JIM_MATH_FUNCTIONS
OPRINIT("sin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("cos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("tan", 200, 1, JimExprOpDoubleUnary),
OPRINIT("asin", 200, 1, JimExprOpDoubleUnary),
OPRINIT("acos", 200, 1, JimExprOpDoubleUnary),
OPRINIT("atan", 200, 1, JimExprOpDoubleUnary),
OPRINIT("sinh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("cosh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("tanh", 200, 1, JimExprOpDoubleUnary),
OPRINIT("ceil", 200, 1, JimExprOpDoubleUnary),
OPRINIT("floor", 200, 1, JimExprOpDoubleUnary),
OPRINIT("exp", 200, 1, JimExprOpDoubleUnary),
OPRINIT("log", 200, 1, JimExprOpDoubleUnary),
OPRINIT("log10", 200, 1, JimExprOpDoubleUnary),
OPRINIT("sqrt", 200, 1, JimExprOpDoubleUnary),
OPRINIT("pow", 200, 2, JimExprOpBin),
#endif
};
#undef OPRINIT
#undef OPRINIT_LAZY
#define JIM_EXPR_OPERATORS_NUM \
(sizeof(Jim_ExprOperators)/sizeof(struct Jim_ExprOperator))
static int JimParseExpression(struct JimParserCtx *pc)
{
while (isspace(UCHAR(*pc->p)) || (*(pc->p) == '\\' && *(pc->p + 1) == '\n')) {
if (*pc->p == '\n') {
pc->linenr++;
}
pc->p++;
pc->len--;
}
pc->tline = pc->linenr;
pc->tstart = pc->p;
if (pc->len == 0) {
pc->tend = pc->p;
pc->tt = JIM_TT_EOL;
pc->eof = 1;
return JIM_OK;
}
switch (*(pc->p)) {
case '(':
pc->tt = JIM_TT_SUBEXPR_START;
goto singlechar;
case ')':
pc->tt = JIM_TT_SUBEXPR_END;
goto singlechar;
case ',':
pc->tt = JIM_TT_SUBEXPR_COMMA;
singlechar:
pc->tend = pc->p;
pc->p++;
pc->len--;
break;
case '[':
return JimParseCmd(pc);
case '$':
if (JimParseVar(pc) == JIM_ERR)
|
| ︙ | ︙ | |||
12985 12986 12987 12988 12989 12990 12991 |
break;
}
return JIM_OK;
}
static int JimParseExprNumber(struct JimParserCtx *pc)
{
| | < < < > < < < < < < | | < < < < < | < | < < < < | < < | < < < < < < < < < < < < < < < | < < > | | | | | < < | | | | 13203 13204 13205 13206 13207 13208 13209 13210 13211 13212 13213 13214 13215 13216 13217 13218 13219 13220 13221 13222 13223 13224 13225 13226 13227 13228 13229 13230 13231 13232 13233 13234 13235 13236 13237 13238 13239 13240 13241 13242 13243 13244 13245 13246 13247 13248 13249 13250 |
break;
}
return JIM_OK;
}
static int JimParseExprNumber(struct JimParserCtx *pc)
{
char *end;
pc->tt = JIM_TT_EXPR_INT;
jim_strtoull(pc->p, (char **)&pc->p);
if (strchr("eENnIi.", *pc->p) || pc->p == pc->tstart) {
if (strtod(pc->tstart, &end)) { }
if (end == pc->tstart)
return JIM_ERR;
if (end > pc->p) {
pc->tt = JIM_TT_EXPR_DOUBLE;
pc->p = end;
}
}
pc->tend = pc->p - 1;
pc->len -= (pc->p - pc->tstart);
return JIM_OK;
}
static int JimParseExprIrrational(struct JimParserCtx *pc)
{
const char *irrationals[] = { "NaN", "nan", "NAN", "Inf", "inf", "INF", NULL };
int i;
for (i = 0; irrationals[i]; i++) {
const char *irr = irrationals[i];
if (strncmp(irr, pc->p, 3) == 0) {
pc->p += 3;
pc->len -= 3;
pc->tend = pc->p - 1;
pc->tt = JIM_TT_EXPR_DOUBLE;
return JIM_OK;
}
}
return JIM_ERR;
}
|
| ︙ | ︙ | |||
13100 13101 13102 13103 13104 13105 13106 |
len--;
p++;
}
if (*p != '(') {
return JIM_ERR;
}
}
| < < | 13280 13281 13282 13283 13284 13285 13286 13287 13288 13289 13290 13291 13292 13293 13294 13295 13296 |
len--;
p++;
}
if (*p != '(') {
return JIM_ERR;
}
}
pc->tend = pc->p + bestLen - 1;
pc->p += bestLen;
pc->len -= bestLen;
pc->tt = bestIdx;
return JIM_OK;
}
static const struct Jim_ExprOperator *JimExprOperatorInfoByOpcode(int opcode)
{
|
| ︙ | ︙ | |||
13606 13607 13608 13609 13610 13611 13612 |
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
#ifdef DEBUG_SHOW_EXPR_TOKENS
{
int i;
| | > > > > > > | 13784 13785 13786 13787 13788 13789 13790 13791 13792 13793 13794 13795 13796 13797 13798 13799 13800 13801 13802 13803 13804 13805 13806 13807 13808 13809 13810 |
ScriptAddToken(&tokenlist, parser.tstart, parser.tend - parser.tstart + 1, parser.tt,
parser.tline);
}
#ifdef DEBUG_SHOW_EXPR_TOKENS
{
int i;
printf("==== Expr Tokens (%s) ====\n", Jim_String(fileNameObj));
for (i = 0; i < tokenlist.count; i++) {
printf("[%2d]@%d %s '%.*s'\n", i, tokenlist.list[i].line, jim_tt_name(tokenlist.list[i].type),
tokenlist.list[i].len, tokenlist.list[i].token);
}
}
#endif
if (JimParseCheckMissing(interp, parser.missing.ch) == JIM_ERR) {
ScriptTokenListFree(&tokenlist);
Jim_DecrRefCount(interp, fileNameObj);
return JIM_ERR;
}
expr = ExprCreateByteCode(interp, &tokenlist, fileNameObj);
ScriptTokenListFree(&tokenlist);
|
| ︙ | ︙ | |||
13663 13664 13665 13666 13667 13668 13669 13670 13671 13672 13673 13674 13675 13676 |
if (objPtr->typePtr != &exprObjType) {
if (SetExprFromAny(interp, objPtr) != JIM_OK) {
return NULL;
}
}
return (ExprByteCode *) Jim_GetIntRepPtr(objPtr);
}
#define JIM_EE_STATICSTACK_LEN 10
int Jim_EvalExpression(Jim_Interp *interp, Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr)
{
ExprByteCode *expr;
Jim_Obj *staticStack[JIM_EE_STATICSTACK_LEN];
| > > > > > > > > > > > > > > | 13847 13848 13849 13850 13851 13852 13853 13854 13855 13856 13857 13858 13859 13860 13861 13862 13863 13864 13865 13866 13867 13868 13869 13870 13871 13872 13873 13874 |
if (objPtr->typePtr != &exprObjType) {
if (SetExprFromAny(interp, objPtr) != JIM_OK) {
return NULL;
}
}
return (ExprByteCode *) Jim_GetIntRepPtr(objPtr);
}
#ifdef JIM_OPTIMIZATION
static Jim_Obj *JimExprIntValOrVar(Jim_Interp *interp, const ScriptToken *token)
{
if (token->type == JIM_TT_EXPR_INT)
return token->objPtr;
else if (token->type == JIM_TT_VAR)
return Jim_GetVariable(interp, token->objPtr, JIM_NONE);
else if (token->type == JIM_TT_DICTSUGAR)
return JimExpandDictSugar(interp, token->objPtr);
else
return NULL;
}
#endif
#define JIM_EE_STATICSTACK_LEN 10
int Jim_EvalExpression(Jim_Interp *interp, Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr)
{
ExprByteCode *expr;
Jim_Obj *staticStack[JIM_EE_STATICSTACK_LEN];
|
| ︙ | ︙ | |||
13686 13687 13688 13689 13690 13691 13692 |
#ifdef JIM_OPTIMIZATION
{
Jim_Obj *objPtr;
switch (expr->len) {
case 1:
| | | | < < < < < | < | < | | < | < | | | | < < < < < < | | | < < < < < < < < < < < < < < | < | | | | | | | | | | | | | | | | | | | | | | < | | | | | < < < > | 13884 13885 13886 13887 13888 13889 13890 13891 13892 13893 13894 13895 13896 13897 13898 13899 13900 13901 13902 13903 13904 13905 13906 13907 13908 13909 13910 13911 13912 13913 13914 13915 13916 13917 13918 13919 13920 13921 13922 13923 13924 13925 13926 13927 13928 13929 13930 13931 13932 13933 13934 13935 13936 13937 13938 13939 13940 13941 13942 13943 13944 13945 13946 13947 13948 13949 13950 13951 13952 13953 13954 13955 13956 |
#ifdef JIM_OPTIMIZATION
{
Jim_Obj *objPtr;
switch (expr->len) {
case 1:
objPtr = JimExprIntValOrVar(interp, &expr->token[0]);
if (objPtr) {
Jim_IncrRefCount(objPtr);
*exprResultPtrPtr = objPtr;
return JIM_OK;
}
break;
case 2:
if (expr->token[1].type == JIM_EXPROP_NOT) {
objPtr = JimExprIntValOrVar(interp, &expr->token[0]);
if (objPtr && JimIsWide(objPtr)) {
*exprResultPtrPtr = JimWideValue(objPtr) ? interp->falseObj : interp->trueObj;
Jim_IncrRefCount(*exprResultPtrPtr);
return JIM_OK;
}
}
break;
case 3:
objPtr = JimExprIntValOrVar(interp, &expr->token[0]);
if (objPtr && JimIsWide(objPtr)) {
Jim_Obj *objPtr2 = JimExprIntValOrVar(interp, &expr->token[1]);
if (objPtr2 && JimIsWide(objPtr2)) {
jim_wide wideValueA = JimWideValue(objPtr);
jim_wide wideValueB = JimWideValue(objPtr2);
int cmpRes;
switch (expr->token[2].type) {
case JIM_EXPROP_LT:
cmpRes = wideValueA < wideValueB;
break;
case JIM_EXPROP_LTE:
cmpRes = wideValueA <= wideValueB;
break;
case JIM_EXPROP_GT:
cmpRes = wideValueA > wideValueB;
break;
case JIM_EXPROP_GTE:
cmpRes = wideValueA >= wideValueB;
break;
case JIM_EXPROP_NUMEQ:
cmpRes = wideValueA == wideValueB;
break;
case JIM_EXPROP_NUMNE:
cmpRes = wideValueA != wideValueB;
break;
default:
goto noopt;
}
*exprResultPtrPtr = cmpRes ? interp->trueObj : interp->falseObj;
Jim_IncrRefCount(*exprResultPtrPtr);
return JIM_OK;
}
}
break;
}
}
noopt:
#endif
expr->inUse++;
if (expr->len > JIM_EE_STATICSTACK_LEN)
|
| ︙ | ︙ | |||
13950 13951 13952 13953 13954 13955 13956 |
JIM_NOTUSED(interp);
memcpy(newVec, srcPtr->internalRep.ptr, size);
dupPtr->internalRep.ptr = newVec;
dupPtr->typePtr = &scanFmtStringObjType;
}
| | | < < < | 14115 14116 14117 14118 14119 14120 14121 14122 14123 14124 14125 14126 14127 14128 14129 14130 14131 |
JIM_NOTUSED(interp);
memcpy(newVec, srcPtr->internalRep.ptr, size);
dupPtr->internalRep.ptr = newVec;
dupPtr->typePtr = &scanFmtStringObjType;
}
static void UpdateStringOfScanFmt(Jim_Obj *objPtr)
{
JimSetStringBytes(objPtr, ((ScanFmtStringObj *) objPtr->internalRep.ptr)->stringRep);
}
static int SetScanFmtFromAny(Jim_Interp *interp, Jim_Obj *objPtr)
{
ScanFmtStringObj *fmtObj;
char *buffer;
|
| ︙ | ︙ | |||
14169 14170 14171 14172 14173 14174 14175 |
size_t anchor = pos;
int i;
Jim_Obj *tmpObj = NULL;
*valObjPtr = 0;
if (descr->prefix) {
| < | 14331 14332 14333 14334 14335 14336 14337 14338 14339 14340 14341 14342 14343 14344 |
size_t anchor = pos;
int i;
Jim_Obj *tmpObj = NULL;
*valObjPtr = 0;
if (descr->prefix) {
for (i = 0; pos < strLen && descr->prefix[i]; ++i) {
if (isspace(UCHAR(descr->prefix[i])))
while (pos < strLen && isspace(UCHAR(str[pos])))
++pos;
else if (descr->prefix[i] != str[pos])
break;
|
| ︙ | ︙ | |||
14510 14511 14512 14513 14514 14515 14516 |
return retcode;
}
static int JimInvokeCommand(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
{
int retcode;
| | > > > > > > > > > > > > > > > > | | | > > > | > < < > > > | 14671 14672 14673 14674 14675 14676 14677 14678 14679 14680 14681 14682 14683 14684 14685 14686 14687 14688 14689 14690 14691 14692 14693 14694 14695 14696 14697 14698 14699 14700 14701 14702 14703 14704 14705 14706 14707 14708 14709 14710 14711 14712 14713 14714 14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 14729 |
return retcode;
}
static int JimInvokeCommand(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
{
int retcode;
Jim_Cmd *cmdPtr;
#if 0
printf("invoke");
int j;
for (j = 0; j < objc; j++) {
printf(" '%s'", Jim_String(objv[j]));
}
printf("\n");
#endif
if (interp->framePtr->tailcallCmd) {
cmdPtr = interp->framePtr->tailcallCmd;
interp->framePtr->tailcallCmd = NULL;
}
else {
cmdPtr = Jim_GetCommand(interp, objv[0], JIM_ERRMSG);
if (cmdPtr == NULL) {
return JimUnknown(interp, objc, objv);
}
JimIncrCmdRefCount(cmdPtr);
}
if (interp->evalDepth == interp->maxEvalDepth) {
Jim_SetResultString(interp, "Infinite eval recursion", -1);
retcode = JIM_ERR;
goto out;
}
interp->evalDepth++;
Jim_SetEmptyResult(interp);
if (cmdPtr->isproc) {
retcode = JimCallProcedure(interp, cmdPtr, objc, objv);
}
else {
interp->cmdPrivData = cmdPtr->u.native.privData;
retcode = cmdPtr->u.native.cmdProc(interp, objc, objv);
}
interp->evalDepth--;
out:
JimDecrCmdRefCount(interp, cmdPtr);
return retcode;
}
int Jim_EvalObjVector(Jim_Interp *interp, int objc, Jim_Obj *const *objv)
{
int i, retcode;
|
| ︙ | ︙ | |||
14715 14716 14717 14718 14719 14720 14721 14722 14723 14724 14725 14726 14727 14728 |
&& token[2].type == JIM_TT_VAR) {
objPtr->typePtr = &interpolatedObjType;
objPtr->internalRep.dictSubstValue.varNameObjPtr = token[0].objPtr;
objPtr->internalRep.dictSubstValue.indexObjPtr = intv[2];
Jim_IncrRefCount(intv[2]);
}
s = objPtr->bytes = Jim_Alloc(totlen + 1);
objPtr->length = totlen;
for (i = 0; i < tokens; i++) {
if (intv[i]) {
memcpy(s, intv[i]->bytes, intv[i]->length);
s += intv[i]->length;
| > > > > > | 14897 14898 14899 14900 14901 14902 14903 14904 14905 14906 14907 14908 14909 14910 14911 14912 14913 14914 14915 |
&& token[2].type == JIM_TT_VAR) {
objPtr->typePtr = &interpolatedObjType;
objPtr->internalRep.dictSubstValue.varNameObjPtr = token[0].objPtr;
objPtr->internalRep.dictSubstValue.indexObjPtr = intv[2];
Jim_IncrRefCount(intv[2]);
}
else if (tokens && intv[0] && intv[0]->typePtr == &sourceObjType) {
JimSetSourceInfo(interp, objPtr, intv[0]->internalRep.sourceValue.fileNameObj, intv[0]->internalRep.sourceValue.lineNumber);
}
s = objPtr->bytes = Jim_Alloc(totlen + 1);
objPtr->length = totlen;
for (i = 0; i < tokens; i++) {
if (intv[i]) {
memcpy(s, intv[i]->bytes, intv[i]->length);
s += intv[i]->length;
|
| ︙ | ︙ | |||
14770 14771 14772 14773 14774 14775 14776 14777 14778 14779 14780 14781 14782 14783 |
if (Jim_IsList(scriptObjPtr) && scriptObjPtr->bytes == NULL) {
return JimEvalObjList(interp, scriptObjPtr);
}
Jim_IncrRefCount(scriptObjPtr);
script = Jim_GetScript(interp, scriptObjPtr);
Jim_SetEmptyResult(interp);
token = script->token;
#ifdef JIM_OPTIMIZATION
if (script->len == 0) {
| > > > > | 14957 14958 14959 14960 14961 14962 14963 14964 14965 14966 14967 14968 14969 14970 14971 14972 14973 14974 |
if (Jim_IsList(scriptObjPtr) && scriptObjPtr->bytes == NULL) {
return JimEvalObjList(interp, scriptObjPtr);
}
Jim_IncrRefCount(scriptObjPtr);
script = Jim_GetScript(interp, scriptObjPtr);
if (script == NULL) {
Jim_DecrRefCount(interp, scriptObjPtr);
return JIM_ERR;
}
Jim_SetEmptyResult(interp);
token = script->token;
#ifdef JIM_OPTIMIZATION
if (script->len == 0) {
|
| ︙ | ︙ | |||
15044 15045 15046 15047 15048 15049 15050 |
else {
retcode = Jim_EvalObj(interp, scriptObj);
}
interp->framePtr = interp->framePtr->parent;
| < | < < < < < | 15235 15236 15237 15238 15239 15240 15241 15242 15243 15244 15245 15246 15247 15248 15249 15250 15251 15252 15253 15254 15255 15256 15257 15258 |
else {
retcode = Jim_EvalObj(interp, scriptObj);
}
interp->framePtr = interp->framePtr->parent;
JimFreeCallFrame(interp, callFramePtr, JIM_FCF_REUSE);
return retcode;
}
#endif
static int JimCallProcedure(Jim_Interp *interp, Jim_Cmd *cmd, int argc, Jim_Obj *const *argv)
{
Jim_CallFrame *callFramePtr;
int i, d, retcode, optargs;
ScriptObj *script;
if (argc - 1 < cmd->u.proc.reqArity ||
(cmd->u.proc.argsPos < 0 && argc - 1 > cmd->u.proc.reqArity + cmd->u.proc.optArity)) {
JimSetProcWrongArgs(interp, argv[0], cmd);
return JIM_ERR;
|
| ︙ | ︙ | |||
15143 15144 15145 15146 15147 15148 15149 |
}
}
retcode = Jim_EvalObj(interp, cmd->u.proc.bodyObjPtr);
badargset:
| | < < < < | | > | | | > > > | | > > | | < | | > | | > | | > | > < < < | 15328 15329 15330 15331 15332 15333 15334 15335 15336 15337 15338 15339 15340 15341 15342 15343 15344 15345 15346 15347 15348 15349 15350 15351 15352 15353 15354 15355 15356 15357 15358 15359 15360 15361 15362 15363 15364 15365 15366 15367 15368 15369 15370 15371 15372 15373 15374 15375 15376 15377 15378 15379 15380 15381 15382 15383 15384 15385 15386 15387 15388 |
}
}
retcode = Jim_EvalObj(interp, cmd->u.proc.bodyObjPtr);
badargset:
interp->framePtr = interp->framePtr->parent;
JimFreeCallFrame(interp, callFramePtr, JIM_FCF_REUSE);
if (interp->framePtr->tailcallObj) {
if (interp->framePtr->tailcall++ == 0) {
do {
Jim_Obj *tailcallObj = interp->framePtr->tailcallObj;
interp->framePtr->tailcallObj = NULL;
if (retcode == JIM_EVAL) {
retcode = Jim_EvalObjList(interp, tailcallObj);
if (retcode == JIM_RETURN) {
interp->returnLevel++;
}
}
Jim_DecrRefCount(interp, tailcallObj);
} while (interp->framePtr->tailcallObj);
if (interp->framePtr->tailcallCmd) {
JimDecrCmdRefCount(interp, interp->framePtr->tailcallCmd);
interp->framePtr->tailcallCmd = NULL;
}
}
interp->framePtr->tailcall--;
}
if (retcode == JIM_RETURN) {
if (--interp->returnLevel <= 0) {
retcode = interp->returnCode;
interp->returnCode = JIM_OK;
interp->returnLevel = 0;
}
}
else if (retcode == JIM_ERR) {
interp->addStackTrace++;
Jim_DecrRefCount(interp, interp->errorProc);
interp->errorProc = argv[0];
Jim_IncrRefCount(interp->errorProc);
}
return retcode;
}
int Jim_EvalSource(Jim_Interp *interp, const char *filename, int lineno, const char *script)
{
int retval;
Jim_Obj *scriptObjPtr;
|
| ︙ | ︙ | |||
15259 15260 15261 15262 15263 15264 15265 |
FILE *fp;
char *buf;
Jim_Obj *scriptObjPtr;
Jim_Obj *prevScriptObj;
struct stat sb;
int retcode;
int readlen;
| < | 15446 15447 15448 15449 15450 15451 15452 15453 15454 15455 15456 15457 15458 15459 |
FILE *fp;
char *buf;
Jim_Obj *scriptObjPtr;
Jim_Obj *prevScriptObj;
struct stat sb;
int retcode;
int readlen;
if (stat(filename, &sb) != 0 || (fp = fopen(filename, "rt")) == NULL) {
Jim_SetResultFormatted(interp, "couldn't read file \"%s\": %s", filename, strerror(errno));
return JIM_ERR;
}
if (sb.st_size == 0) {
fclose(fp);
|
| ︙ | ︙ | |||
15286 15287 15288 15289 15290 15291 15292 |
buf[readlen] = 0;
scriptObjPtr = Jim_NewStringObjNoAlloc(interp, buf, readlen);
JimSetSourceInfo(interp, scriptObjPtr, Jim_NewStringObj(interp, filename, -1), 1);
Jim_IncrRefCount(scriptObjPtr);
| | < < | < < < < < < < < < < < < | < < < < | 15472 15473 15474 15475 15476 15477 15478 15479 15480 15481 15482 15483 15484 15485 15486 15487 15488 |
buf[readlen] = 0;
scriptObjPtr = Jim_NewStringObjNoAlloc(interp, buf, readlen);
JimSetSourceInfo(interp, scriptObjPtr, Jim_NewStringObj(interp, filename, -1), 1);
Jim_IncrRefCount(scriptObjPtr);
if (Jim_GetScript(interp, scriptObjPtr) == NULL) {
JimAddErrorToStack(interp, JIM_ERR, (ScriptObj *)Jim_GetIntRepPtr(scriptObjPtr));
Jim_DecrRefCount(interp, scriptObjPtr);
return JIM_ERR;
}
prevScriptObj = interp->currentScriptObj;
interp->currentScriptObj = scriptObjPtr;
|
| ︙ | ︙ | |||
15473 15474 15475 15476 15477 15478 15479 |
Jim_SetResultFormatted(interp, "wrong # args: should be \"%#s\"", objPtr);
Jim_DecrRefCount(interp, objPtr);
}
typedef void JimHashtableIteratorCallbackType(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type);
| | | 15641 15642 15643 15644 15645 15646 15647 15648 15649 15650 15651 15652 15653 15654 15655 |
Jim_SetResultFormatted(interp, "wrong # args: should be \"%#s\"", objPtr);
Jim_DecrRefCount(interp, objPtr);
}
typedef void JimHashtableIteratorCallbackType(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type);
#define JimTrivialMatch(pattern) (strpbrk((pattern), "*[?\\") == NULL)
static Jim_Obj *JimHashtablePatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimHashtableIteratorCallbackType *callback, int type)
{
Jim_HashEntry *he;
Jim_Obj *listObjPtr = Jim_NewListObj(interp, NULL, 0);
|
| ︙ | ︙ | |||
15508 15509 15510 15511 15512 15513 15514 |
#define JIM_CMDLIST_COMMANDS 0
#define JIM_CMDLIST_PROCS 1
#define JIM_CMDLIST_CHANNELS 2
static void JimCommandMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
| | | 15676 15677 15678 15679 15680 15681 15682 15683 15684 15685 15686 15687 15688 15689 15690 |
#define JIM_CMDLIST_COMMANDS 0
#define JIM_CMDLIST_PROCS 1
#define JIM_CMDLIST_CHANNELS 2
static void JimCommandMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
Jim_Cmd *cmdPtr = Jim_GetHashEntryVal(he);
Jim_Obj *objPtr;
if (type == JIM_CMDLIST_PROCS && !cmdPtr->isproc) {
return;
}
|
| ︙ | ︙ | |||
15541 15542 15543 15544 15545 15546 15547 |
#define JIM_VARLIST_VARS 2
#define JIM_VARLIST_VALUES 0x1000
static void JimVariablesMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
| | | 15709 15710 15711 15712 15713 15714 15715 15716 15717 15718 15719 15720 15721 15722 15723 |
#define JIM_VARLIST_VARS 2
#define JIM_VARLIST_VALUES 0x1000
static void JimVariablesMatch(Jim_Interp *interp, Jim_Obj *listObjPtr,
Jim_HashEntry *he, int type)
{
Jim_Var *varPtr = Jim_GetHashEntryVal(he);
if (type != JIM_VARLIST_LOCALS || varPtr->linkFramePtr == NULL) {
Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, he->key, -1));
if (type & JIM_VARLIST_VALUES) {
Jim_ListAppendElement(interp, listObjPtr, varPtr->objPtr);
}
}
|
| ︙ | ︙ | |||
15863 15864 15865 15866 15867 15868 15869 |
int cmpOffset;
expr = JimGetExpression(interp, argv[2]);
incrScript = Jim_GetScript(interp, argv[3]);
| | | 16031 16032 16033 16034 16035 16036 16037 16038 16039 16040 16041 16042 16043 16044 16045 |
int cmpOffset;
expr = JimGetExpression(interp, argv[2]);
incrScript = Jim_GetScript(interp, argv[3]);
if (incrScript == NULL || incrScript->len != 3 || !expr || expr->len != 3) {
goto evalstart;
}
if (incrScript->token[1].type != JIM_TT_ESC ||
expr->token[0].type != JIM_TT_VAR ||
(expr->token[1].type != JIM_TT_EXPR_INT && expr->token[1].type != JIM_TT_VAR)) {
goto evalstart;
|
| ︙ | ︙ | |||
16086 16087 16088 16089 16090 16091 16092 |
{
return iter->idx >= Jim_ListLength(interp, iter->objPtr);
}
static int JimForeachMapHelper(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int doMap)
{
| | | 16254 16255 16256 16257 16258 16259 16260 16261 16262 16263 16264 16265 16266 16267 16268 |
{
return iter->idx >= Jim_ListLength(interp, iter->objPtr);
}
static int JimForeachMapHelper(Jim_Interp *interp, int argc, Jim_Obj *const *argv, int doMap)
{
int result = JIM_OK;
int i, numargs;
Jim_ListIter twoiters[2];
Jim_ListIter *iters;
Jim_Obj *script;
Jim_Obj *resultObj;
if (argc < 4 || argc % 2 != 0) {
|
| ︙ | ︙ | |||
16109 16110 16111 16112 16113 16114 16115 |
}
else {
iters = Jim_Alloc(numargs * sizeof(*iters));
}
for (i = 0; i < numargs; i++) {
JimListIterInit(&iters[i], argv[i + 1]);
if (i % 2 == 0 && JimListIterDone(interp, &iters[i])) {
| < | > > > > | 16277 16278 16279 16280 16281 16282 16283 16284 16285 16286 16287 16288 16289 16290 16291 16292 16293 16294 16295 16296 |
}
else {
iters = Jim_Alloc(numargs * sizeof(*iters));
}
for (i = 0; i < numargs; i++) {
JimListIterInit(&iters[i], argv[i + 1]);
if (i % 2 == 0 && JimListIterDone(interp, &iters[i])) {
result = JIM_ERR;
}
}
if (result != JIM_OK) {
Jim_SetResultString(interp, "foreach varlist is empty", -1);
return result;
}
if (doMap) {
resultObj = Jim_NewListObj(interp, NULL, 0);
}
else {
resultObj = interp->emptyObj;
|
| ︙ | ︙ | |||
16428 16429 16430 16431 16432 16433 16434 |
static int Jim_LindexCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr, *listObjPtr;
int i;
int idx;
| | | | 16599 16600 16601 16602 16603 16604 16605 16606 16607 16608 16609 16610 16611 16612 16613 16614 |
static int Jim_LindexCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr, *listObjPtr;
int i;
int idx;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "list ?index ...?");
return JIM_ERR;
}
objPtr = argv[1];
Jim_IncrRefCount(objPtr);
for (i = 2; i < argc; i++) {
listObjPtr = objPtr;
if (Jim_GetIndex(interp, argv[i], &idx) != JIM_OK) {
|
| ︙ | ︙ | |||
16545 16546 16547 16548 16549 16550 16551 |
}
if (commandObj) {
Jim_IncrRefCount(commandObj);
}
listlen = Jim_ListLength(interp, argv[0]);
for (i = 0; i < listlen; i++) {
| < > < | 16716 16717 16718 16719 16720 16721 16722 16723 16724 16725 16726 16727 16728 16729 16730 16731 16732 |
}
if (commandObj) {
Jim_IncrRefCount(commandObj);
}
listlen = Jim_ListLength(interp, argv[0]);
for (i = 0; i < listlen; i++) {
int eq = 0;
Jim_Obj *objPtr = Jim_ListGetIndex(interp, argv[0], i);
switch (opt_match) {
case OPT_EXACT:
eq = Jim_StringCompareObj(interp, argv[1], objPtr, opt_nocase) == 0;
break;
case OPT_GLOB:
eq = Jim_StringMatchObj(interp, argv[1], objPtr, opt_nocase);
|
| ︙ | ︙ | |||
16742 16743 16744 16745 16746 16747 16748 16749 16750 16751 16752 16753 |
static int Jim_LsetCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "listVar ?index...? newVal");
return JIM_ERR;
}
else if (argc == 3) {
if (Jim_SetVariable(interp, argv[1], argv[2]) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
| > | < < < | | > | > > > > > > | 16912 16913 16914 16915 16916 16917 16918 16919 16920 16921 16922 16923 16924 16925 16926 16927 16928 16929 16930 16931 16932 16933 16934 16935 16936 16937 16938 16939 16940 16941 16942 16943 16944 16945 16946 16947 16948 16949 16950 16951 16952 16953 16954 16955 16956 16957 16958 16959 16960 16961 16962 16963 16964 16965 16966 16967 16968 16969 16970 16971 16972 16973 16974 16975 16976 16977 16978 16979 16980 16981 16982 16983 16984 16985 16986 16987 16988 |
static int Jim_LsetCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc < 3) {
Jim_WrongNumArgs(interp, 1, argv, "listVar ?index...? newVal");
return JIM_ERR;
}
else if (argc == 3) {
if (Jim_SetVariable(interp, argv[1], argv[2]) != JIM_OK)
return JIM_ERR;
Jim_SetResult(interp, argv[2]);
return JIM_OK;
}
return Jim_ListSetIndex(interp, argv[1], argv + 2, argc - 3, argv[argc - 1]);
}
static int Jim_LsortCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const argv[])
{
static const char * const options[] = {
"-ascii", "-nocase", "-increasing", "-decreasing", "-command", "-integer", "-real", "-index", "-unique", NULL
};
enum
{ OPT_ASCII, OPT_NOCASE, OPT_INCREASING, OPT_DECREASING, OPT_COMMAND, OPT_INTEGER, OPT_REAL, OPT_INDEX, OPT_UNIQUE };
Jim_Obj *resObj;
int i;
int retCode;
struct lsort_info info;
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "?options? list");
return JIM_ERR;
}
info.type = JIM_LSORT_ASCII;
info.order = 1;
info.indexed = 0;
info.unique = 0;
info.command = NULL;
info.interp = interp;
for (i = 1; i < (argc - 1); i++) {
int option;
if (Jim_GetEnum(interp, argv[i], options, &option, NULL, JIM_ENUM_ABBREV | JIM_ERRMSG)
!= JIM_OK)
return JIM_ERR;
switch (option) {
case OPT_ASCII:
info.type = JIM_LSORT_ASCII;
break;
case OPT_NOCASE:
info.type = JIM_LSORT_NOCASE;
break;
case OPT_INTEGER:
info.type = JIM_LSORT_INTEGER;
break;
case OPT_REAL:
info.type = JIM_LSORT_REAL;
break;
case OPT_INCREASING:
info.order = 1;
break;
case OPT_DECREASING:
info.order = -1;
break;
case OPT_UNIQUE:
info.unique = 1;
break;
case OPT_COMMAND:
if (i >= (argc - 2)) {
Jim_SetResultString(interp, "\"-command\" option must be followed by comparison command", -1);
return JIM_ERR;
}
info.type = JIM_LSORT_COMMAND;
info.command = argv[i + 1];
|
| ︙ | ︙ | |||
16913 16914 16915 16916 16917 16918 16919 |
static int Jim_UplevelCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc >= 2) {
int retcode;
Jim_CallFrame *savedCallFrame, *targetCallFrame;
| | | < | > > > < < | < > | 17088 17089 17090 17091 17092 17093 17094 17095 17096 17097 17098 17099 17100 17101 17102 17103 17104 17105 17106 17107 17108 17109 17110 17111 17112 17113 17114 17115 17116 17117 17118 17119 17120 17121 17122 17123 17124 17125 17126 17127 17128 17129 17130 17131 17132 17133 17134 17135 17136 |
static int Jim_UplevelCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (argc >= 2) {
int retcode;
Jim_CallFrame *savedCallFrame, *targetCallFrame;
int savedTailcall;
const char *str;
savedCallFrame = interp->framePtr;
str = Jim_String(argv[1]);
if ((str[0] >= '0' && str[0] <= '9') || str[0] == '#') {
targetCallFrame = Jim_GetCallFrameByLevel(interp, argv[1]);
argc--;
argv++;
}
else {
targetCallFrame = Jim_GetCallFrameByLevel(interp, NULL);
}
if (targetCallFrame == NULL) {
return JIM_ERR;
}
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv - 1, "?level? command ?arg ...?");
return JIM_ERR;
}
interp->framePtr = targetCallFrame;
savedTailcall = interp->framePtr->tailcall;
interp->framePtr->tailcall = 0;
if (argc == 2) {
retcode = Jim_EvalObj(interp, argv[1]);
}
else {
retcode = Jim_EvalObj(interp, Jim_ConcatObj(interp, argc - 1, argv + 1));
}
interp->framePtr->tailcall = savedTailcall;
interp->framePtr = savedCallFrame;
return retcode;
}
else {
Jim_WrongNumArgs(interp, 1, argv, "?level? command ?arg ...?");
return JIM_ERR;
}
|
| ︙ | ︙ | |||
17062 17063 17064 17065 17066 17067 17068 |
}
return JIM_RETURN;
}
static int Jim_TailcallCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
| > > > > > > > > > > > > > > > > > > > > > > | > > > | > > | 17237 17238 17239 17240 17241 17242 17243 17244 17245 17246 17247 17248 17249 17250 17251 17252 17253 17254 17255 17256 17257 17258 17259 17260 17261 17262 17263 17264 17265 17266 17267 17268 17269 17270 17271 17272 17273 17274 17275 17276 17277 17278 17279 |
}
return JIM_RETURN;
}
static int Jim_TailcallCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
if (interp->framePtr->level == 0) {
Jim_SetResultString(interp, "tailcall can only be called from a proc or lambda", -1);
return JIM_ERR;
}
else if (argc >= 2) {
Jim_CallFrame *cf = interp->framePtr->parent;
Jim_Cmd *cmdPtr = Jim_GetCommand(interp, argv[1], JIM_ERRMSG);
if (cmdPtr == NULL) {
return JIM_ERR;
}
JimPanic((cf->tailcallCmd != NULL, "Already have a tailcallCmd"));
JimIncrCmdRefCount(cmdPtr);
cf->tailcallCmd = cmdPtr;
JimPanic((cf->tailcallObj != NULL, "Already have a tailcallobj"));
cf->tailcallObj = Jim_NewListObj(interp, argv + 1, argc - 1);
Jim_IncrRefCount(cf->tailcallObj);
return JIM_EVAL;
}
return JIM_OK;
}
static int JimAliasCmd(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *cmdList;
Jim_Obj *prefixListObj = Jim_CmdPrivData(interp);
|
| ︙ | ︙ | |||
17352 17353 17354 17355 17356 17357 17358 |
resultObjPtr = Jim_NewStringObj(interp, "", 0);
while (strLen) {
for (i = 0; i < numMaps; i += 2) {
Jim_Obj *objPtr;
const char *k;
int kl;
| | < | | 17554 17555 17556 17557 17558 17559 17560 17561 17562 17563 17564 17565 17566 17567 17568 17569 17570 17571 17572 17573 17574 17575 17576 17577 17578 17579 17580 |
resultObjPtr = Jim_NewStringObj(interp, "", 0);
while (strLen) {
for (i = 0; i < numMaps; i += 2) {
Jim_Obj *objPtr;
const char *k;
int kl;
objPtr = Jim_ListGetIndex(interp, mapListObjPtr, i);
k = Jim_String(objPtr);
kl = Jim_Utf8Length(interp, objPtr);
if (strLen >= kl && kl) {
int rc;
rc = JimStringCompareLen(str, k, kl, nocase);
if (rc == 0) {
if (noMatchStart) {
Jim_AppendString(interp, resultObjPtr, noMatchStart, str - noMatchStart);
noMatchStart = NULL;
}
Jim_AppendObj(interp, resultObjPtr, Jim_ListGetIndex(interp, mapListObjPtr, i + 1));
str += utf8_index(str, kl);
strLen -= kl;
break;
}
}
}
if (i == numMaps) {
|
| ︙ | ︙ | |||
17849 17850 17851 17852 17853 17854 17855 17856 17857 17858 17859 |
interp->signal_level += sig;
if (Jim_CheckSignal(interp)) {
exitCode = JIM_SIGNAL;
}
else {
exitCode = Jim_EvalObj(interp, argv[0]);
}
interp->signal_level -= sig;
| > > | | 18050 18051 18052 18053 18054 18055 18056 18057 18058 18059 18060 18061 18062 18063 18064 18065 18066 18067 18068 18069 18070 |
interp->signal_level += sig;
if (Jim_CheckSignal(interp)) {
exitCode = JIM_SIGNAL;
}
else {
exitCode = Jim_EvalObj(interp, argv[0]);
interp->errorFlag = 0;
}
interp->signal_level -= sig;
if (exitCode >= 0 && exitCode < max_ignore_code && (((unsigned jim_wide)1 << exitCode) & ignore_mask)) {
return exitCode;
}
if (sig && exitCode == JIM_SIGNAL) {
if (interp->signal_set_result) {
|
| ︙ | ︙ | |||
18007 18008 18009 18010 18011 18012 18013 |
Jim_HashEntry *he;
listObjPtr = Jim_NewListObj(interp, NULL, 0);
JimInitHashTableIterator(&interp->references, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
char buf[JIM_REFERENCE_SPACE + 1];
| | | 18210 18211 18212 18213 18214 18215 18216 18217 18218 18219 18220 18221 18222 18223 18224 |
Jim_HashEntry *he;
listObjPtr = Jim_NewListObj(interp, NULL, 0);
JimInitHashTableIterator(&interp->references, &htiter);
while ((he = Jim_NextHashEntry(&htiter)) != NULL) {
char buf[JIM_REFERENCE_SPACE + 1];
Jim_Reference *refPtr = Jim_GetHashEntryVal(he);
const unsigned long *refId = he->key;
JimFormatReference(buf, refPtr, *refId);
Jim_ListAppendElement(interp, listObjPtr, Jim_NewStringObj(interp, buf, -1));
}
Jim_SetResult(interp, listObjPtr);
return JIM_OK;
|
| ︙ | ︙ | |||
18041 18042 18043 18044 18045 18046 18047 |
typedef void JimDictMatchCallbackType(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_HashEntry *he, int type);
static void JimDictMatchKeys(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_HashEntry *he, int type)
{
Jim_ListAppendElement(interp, listObjPtr, (Jim_Obj *)he->key);
if (type & JIM_DICTMATCH_VALUES) {
| | | 18244 18245 18246 18247 18248 18249 18250 18251 18252 18253 18254 18255 18256 18257 18258 |
typedef void JimDictMatchCallbackType(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_HashEntry *he, int type);
static void JimDictMatchKeys(Jim_Interp *interp, Jim_Obj *listObjPtr, Jim_HashEntry *he, int type)
{
Jim_ListAppendElement(interp, listObjPtr, (Jim_Obj *)he->key);
if (type & JIM_DICTMATCH_VALUES) {
Jim_ListAppendElement(interp, listObjPtr, Jim_GetHashEntryVal(he));
}
}
static Jim_Obj *JimDictPatternMatch(Jim_Interp *interp, Jim_HashTable *ht, Jim_Obj *patternObjPtr,
JimDictMatchCallbackType *callback, int type)
{
Jim_HashEntry *he;
|
| ︙ | ︙ | |||
18090 18091 18092 18093 18094 18095 18096 18097 18098 18099 18100 18101 18102 |
{
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return -1;
}
return ((Jim_HashTable *)objPtr->internalRep.ptr)->used;
}
static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr;
int option;
static const char * const options[] = {
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > | > > | | | | > | > | > > | > | > > > | | < < | < | < | < | < < | > | | < < | < < > | < < | > > > | > > > > > | 18293 18294 18295 18296 18297 18298 18299 18300 18301 18302 18303 18304 18305 18306 18307 18308 18309 18310 18311 18312 18313 18314 18315 18316 18317 18318 18319 18320 18321 18322 18323 18324 18325 18326 18327 18328 18329 18330 18331 18332 18333 18334 18335 18336 18337 18338 18339 18340 18341 18342 18343 18344 18345 18346 18347 18348 18349 18350 18351 18352 18353 18354 18355 18356 18357 18358 18359 18360 18361 18362 18363 18364 18365 18366 18367 18368 18369 18370 18371 18372 18373 18374 18375 18376 18377 18378 18379 18380 18381 18382 18383 18384 18385 18386 18387 18388 18389 18390 18391 18392 18393 18394 18395 18396 18397 18398 18399 18400 18401 18402 18403 18404 18405 18406 18407 18408 18409 18410 18411 18412 18413 18414 18415 18416 18417 18418 18419 18420 18421 18422 18423 18424 18425 18426 18427 18428 18429 18430 18431 18432 18433 18434 18435 18436 18437 18438 18439 18440 18441 18442 18443 18444 18445 18446 18447 18448 18449 18450 18451 18452 18453 18454 18455 18456 18457 18458 18459 18460 18461 18462 18463 18464 18465 18466 18467 18468 18469 |
{
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return -1;
}
return ((Jim_HashTable *)objPtr->internalRep.ptr)->used;
}
int Jim_DictInfo(Jim_Interp *interp, Jim_Obj *objPtr)
{
Jim_HashTable *ht;
unsigned int i;
if (SetDictFromAny(interp, objPtr) != JIM_OK) {
return JIM_ERR;
}
ht = (Jim_HashTable *)objPtr->internalRep.ptr;
printf("%d entries in table, %d buckets\n", ht->used, ht->size);
for (i = 0; i < ht->size; i++) {
Jim_HashEntry *he = ht->table[i];
if (he) {
printf("%d: ", i);
while (he) {
printf(" %s", Jim_String(he->key));
he = he->next;
}
printf("\n");
}
}
return JIM_OK;
}
static int Jim_EvalEnsemble(Jim_Interp *interp, const char *basecmd, const char *subcmd, int argc, Jim_Obj *const *argv)
{
Jim_Obj *prefixObj = Jim_NewStringObj(interp, basecmd, -1);
Jim_AppendString(interp, prefixObj, " ", 1);
Jim_AppendString(interp, prefixObj, subcmd, -1);
return Jim_EvalObjPrefix(interp, prefixObj, argc, argv);
}
static int Jim_DictCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
Jim_Obj *objPtr;
int option;
static const char * const options[] = {
"create", "get", "set", "unset", "exists", "keys", "size", "info",
"merge", "with", "append", "lappend", "incr", "remove", "values", "for",
"replace", "update", NULL
};
enum
{
OPT_CREATE, OPT_GET, OPT_SET, OPT_UNSET, OPT_EXISTS, OPT_KEYS, OPT_SIZE, OPT_INFO,
OPT_MERGE, OPT_WITH, OPT_APPEND, OPT_LAPPEND, OPT_INCR, OPT_REMOVE, OPT_VALUES, OPT_FOR,
OPT_REPLACE, OPT_UPDATE,
};
if (argc < 2) {
Jim_WrongNumArgs(interp, 1, argv, "subcommand ?arguments ...?");
return JIM_ERR;
}
if (Jim_GetEnum(interp, argv[1], options, &option, "subcommand", JIM_ERRMSG) != JIM_OK) {
return JIM_ERR;
}
switch (option) {
case OPT_GET:
if (argc < 3) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary ?key ...?");
return JIM_ERR;
}
if (Jim_DictKeysVector(interp, argv[2], argv + 3, argc - 3, &objPtr,
JIM_ERRMSG) != JIM_OK) {
return JIM_ERR;
}
Jim_SetResult(interp, objPtr);
return JIM_OK;
case OPT_SET:
if (argc < 5) {
Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...? value");
return JIM_ERR;
}
return Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 4, argv[argc - 1], JIM_ERRMSG);
case OPT_EXISTS:
if (argc < 4) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary key ?key ...?");
return JIM_ERR;
}
else {
int rc = Jim_DictKeysVector(interp, argv[2], argv + 3, argc - 3, &objPtr, JIM_ERRMSG);
if (rc < 0) {
return JIM_ERR;
}
Jim_SetResultBool(interp, rc == JIM_OK);
return JIM_OK;
}
case OPT_UNSET:
if (argc < 4) {
Jim_WrongNumArgs(interp, 2, argv, "varName key ?key ...?");
return JIM_ERR;
}
if (Jim_SetDictKeysVector(interp, argv[2], argv + 3, argc - 3, NULL, 0) != JIM_OK) {
return JIM_ERR;
}
return JIM_OK;
case OPT_KEYS:
if (argc != 3 && argc != 4) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary ?pattern?");
return JIM_ERR;
}
return Jim_DictKeys(interp, argv[2], argc == 4 ? argv[3] : NULL);
case OPT_SIZE:
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary");
return JIM_ERR;
}
else if (Jim_DictSize(interp, argv[2]) < 0) {
return JIM_ERR;
}
Jim_SetResultInt(interp, Jim_DictSize(interp, argv[2]));
return JIM_OK;
case OPT_MERGE:
if (argc == 2) {
return JIM_OK;
}
if (Jim_DictSize(interp, argv[2]) < 0) {
return JIM_ERR;
}
break;
case OPT_UPDATE:
if (argc < 6 || argc % 2) {
argc = 2;
}
break;
case OPT_CREATE:
if (argc % 2) {
Jim_WrongNumArgs(interp, 2, argv, "?key value ...?");
return JIM_ERR;
}
objPtr = Jim_NewDictObj(interp, argv + 2, argc - 2);
Jim_SetResult(interp, objPtr);
return JIM_OK;
case OPT_INFO:
if (argc != 3) {
Jim_WrongNumArgs(interp, 2, argv, "dictionary");
return JIM_ERR;
}
return Jim_DictInfo(interp, argv[2]);
}
return Jim_EvalEnsemble(interp, "dict", options[option], argc - 2, argv + 2);
}
static int Jim_SubstCoreCommand(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
{
static const char * const options[] = {
"-nobackslashes", "-nocommands", "-novariables", NULL
|
| ︙ | ︙ | |||
18265 18266 18267 18268 18269 18270 18271 |
"script", "source", "stacktrace", "nameofexecutable", "returncodes",
"references", "alias", NULL
};
enum
{ INFO_BODY, INFO_STATICS, INFO_COMMANDS, INFO_PROCS, INFO_CHANNELS, INFO_EXISTS, INFO_GLOBALS, INFO_LEVEL,
INFO_FRAME, INFO_LOCALS, INFO_VARS, INFO_VERSION, INFO_PATCHLEVEL, INFO_COMPLETE, INFO_ARGS,
INFO_HOSTNAME, INFO_SCRIPT, INFO_SOURCE, INFO_STACKTRACE, INFO_NAMEOFEXECUTABLE,
| | | 18517 18518 18519 18520 18521 18522 18523 18524 18525 18526 18527 18528 18529 18530 18531 |
"script", "source", "stacktrace", "nameofexecutable", "returncodes",
"references", "alias", NULL
};
enum
{ INFO_BODY, INFO_STATICS, INFO_COMMANDS, INFO_PROCS, INFO_CHANNELS, INFO_EXISTS, INFO_GLOBALS, INFO_LEVEL,
INFO_FRAME, INFO_LOCALS, INFO_VARS, INFO_VERSION, INFO_PATCHLEVEL, INFO_COMPLETE, INFO_ARGS,
INFO_HOSTNAME, INFO_SCRIPT, INFO_SOURCE, INFO_STACKTRACE, INFO_NAMEOFEXECUTABLE,
INFO_RETURNCODES, INFO_REFERENCES, INFO_ALIAS,
};
#ifdef jim_ext_namespace
int nons = 0;
if (argc > 2 && Jim_CompareStringImmediate(interp, argv[1], "-nons")) {
|
| ︙ | ︙ | |||
19045 19046 19047 19048 19049 19050 19051 |
Jim_SetResultInt(interp, min+r);
return JIM_OK;
}
}
static const struct {
const char *name;
| | | 19297 19298 19299 19300 19301 19302 19303 19304 19305 19306 19307 19308 19309 19310 19311 |
Jim_SetResultInt(interp, min+r);
return JIM_OK;
}
}
static const struct {
const char *name;
Jim_CmdProc *cmdProc;
} Jim_CoreCommandsTable[] = {
{"alias", Jim_AliasCoreCommand},
{"set", Jim_SetCoreCommand},
{"unset", Jim_UnsetCoreCommand},
{"puts", Jim_PutsCoreCommand},
{"+", Jim_AddCoreCommand},
{"*", Jim_MulCoreCommand},
|
| ︙ | ︙ | |||
19277 19278 19279 19280 19281 19282 19283 19284 19285 19286 19287 19288 19289 19290 |
n++;
extra += l;
}
len += extra;
buf = Jim_Alloc(len + 1);
len = snprintf(buf, len + 1, format, params[0], params[1], params[2], params[3], params[4]);
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, buf, len));
}
#ifndef jim_ext_package
int Jim_PackageProvide(Jim_Interp *interp, const char *name, const char *ver, int flags)
| > > | 19529 19530 19531 19532 19533 19534 19535 19536 19537 19538 19539 19540 19541 19542 19543 19544 |
n++;
extra += l;
}
len += extra;
buf = Jim_Alloc(len + 1);
len = snprintf(buf, len + 1, format, params[0], params[1], params[2], params[3], params[4]);
va_end(args);
Jim_SetResult(interp, Jim_NewStringObjNoAlloc(interp, buf, len));
}
#ifndef jim_ext_package
int Jim_PackageProvide(Jim_Interp *interp, const char *name, const char *ver, int flags)
|
| ︙ | ︙ | |||
19528 19529 19530 19531 19532 19533 19534 |
}
}
#include <ctype.h>
#include <string.h>
| < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | < | | | | | | | < | | | | < | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > > > < < < > | > | | > > > | | | | | | | | | | 19782 19783 19784 19785 19786 19787 19788 19789 19790 19791 19792 19793 19794 19795 19796 19797 19798 19799 19800 19801 19802 19803 19804 19805 19806 19807 19808 19809 19810 19811 19812 19813 19814 19815 19816 19817 19818 19819 19820 19821 19822 19823 19824 19825 19826 19827 19828 19829 19830 19831 19832 19833 19834 19835 19836 19837 19838 19839 19840 19841 19842 19843 19844 19845 19846 19847 19848 19849 19850 19851 19852 19853 19854 19855 19856 19857 19858 19859 19860 19861 19862 19863 19864 19865 19866 19867 19868 19869 19870 19871 19872 19873 19874 19875 19876 19877 19878 19879 19880 19881 19882 19883 19884 19885 19886 19887 19888 19889 19890 19891 19892 19893 19894 19895 19896 19897 19898 19899 19900 19901 19902 19903 19904 19905 19906 19907 19908 19909 19910 19911 19912 19913 19914 19915 19916 19917 19918 19919 19920 19921 19922 19923 19924 19925 19926 19927 19928 19929 19930 19931 19932 19933 19934 19935 19936 19937 19938 19939 19940 19941 19942 19943 19944 19945 19946 19947 19948 19949 19950 19951 19952 19953 19954 19955 19956 19957 19958 19959 19960 19961 19962 19963 19964 19965 19966 19967 19968 19969 19970 19971 19972 19973 19974 19975 19976 19977 19978 19979 19980 19981 19982 19983 19984 19985 19986 19987 19988 19989 19990 19991 19992 19993 19994 19995 19996 19997 19998 19999 20000 20001 20002 20003 20004 20005 20006 20007 20008 20009 20010 20011 20012 20013 20014 20015 20016 20017 20018 20019 20020 20021 20022 20023 20024 20025 20026 20027 20028 20029 20030 20031 20032 20033 20034 20035 20036 20037 20038 20039 20040 20041 20042 20043 20044 20045 20046 20047 20048 20049 20050 20051 20052 20053 20054 20055 20056 20057 20058 20059 20060 20061 20062 20063 20064 20065 20066 20067 20068 20069 20070 20071 20072 20073 20074 20075 20076 20077 20078 20079 20080 20081 20082 20083 20084 20085 20086 20087 20088 20089 20090 20091 20092 20093 20094 20095 20096 20097 20098 20099 20100 20101 20102 20103 20104 20105 20106 20107 20108 20109 20110 20111 20112 20113 20114 20115 20116 20117 20118 20119 20120 20121 20122 20123 20124 20125 20126 20127 20128 20129 20130 20131 20132 20133 20134 20135 20136 20137 20138 20139 20140 20141 20142 20143 20144 20145 20146 20147 20148 20149 20150 20151 20152 20153 20154 20155 20156 20157 20158 20159 20160 20161 20162 20163 20164 20165 20166 20167 20168 20169 20170 20171 20172 20173 20174 20175 20176 20177 20178 20179 20180 20181 20182 20183 20184 20185 20186 20187 20188 20189 20190 20191 20192 20193 20194 20195 20196 20197 20198 20199 20200 20201 20202 20203 20204 20205 20206 20207 20208 20209 20210 20211 20212 20213 20214 20215 20216 20217 20218 20219 20220 20221 20222 20223 20224 20225 20226 20227 20228 20229 20230 20231 20232 20233 20234 20235 20236 20237 20238 20239 20240 20241 20242 20243 20244 |
}
}
#include <ctype.h>
#include <string.h>
#define JIM_INTEGER_SPACE 24
#define MAX_FLOAT_WIDTH 320
Jim_Obj *Jim_FormatString(Jim_Interp *interp, Jim_Obj *fmtObjPtr, int objc, Jim_Obj *const *objv)
{
const char *span, *format, *formatEnd, *msg;
int numBytes = 0, objIndex = 0, gotXpg = 0, gotSequential = 0;
static const char * const mixedXPG =
"cannot mix \"%\" and \"%n$\" conversion specifiers";
static const char * const badIndex[2] = {
"not enough arguments for all format specifiers",
"\"%n$\" argument index out of range"
};
int formatLen;
Jim_Obj *resultPtr;
char *num_buffer = NULL;
int num_buffer_size = 0;
span = format = Jim_GetString(fmtObjPtr, &formatLen);
formatEnd = format + formatLen;
resultPtr = Jim_NewEmptyStringObj(interp);
while (format != formatEnd) {
char *end;
int gotMinus, sawFlag;
int gotPrecision, useShort;
long width, precision;
int newXpg;
int ch;
int step;
int doubleType;
char pad = ' ';
char spec[2*JIM_INTEGER_SPACE + 12];
char *p;
int formatted_chars;
int formatted_bytes;
const char *formatted_buf;
step = utf8_tounicode(format, &ch);
format += step;
if (ch != '%') {
numBytes += step;
continue;
}
if (numBytes) {
Jim_AppendString(interp, resultPtr, span, numBytes);
numBytes = 0;
}
step = utf8_tounicode(format, &ch);
if (ch == '%') {
span = format;
numBytes = step;
format += step;
continue;
}
newXpg = 0;
if (isdigit(ch)) {
int position = strtoul(format, &end, 10);
if (*end == '$') {
newXpg = 1;
objIndex = position - 1;
format = end + 1;
step = utf8_tounicode(format, &ch);
}
}
if (newXpg) {
if (gotSequential) {
msg = mixedXPG;
goto errorMsg;
}
gotXpg = 1;
} else {
if (gotXpg) {
msg = mixedXPG;
goto errorMsg;
}
gotSequential = 1;
}
if ((objIndex < 0) || (objIndex >= objc)) {
msg = badIndex[gotXpg];
goto errorMsg;
}
p = spec;
*p++ = '%';
gotMinus = 0;
sawFlag = 1;
do {
switch (ch) {
case '-':
gotMinus = 1;
break;
case '0':
pad = ch;
break;
case ' ':
case '+':
case '#':
break;
default:
sawFlag = 0;
continue;
}
*p++ = ch;
format += step;
step = utf8_tounicode(format, &ch);
} while (sawFlag);
width = 0;
if (isdigit(ch)) {
width = strtoul(format, &end, 10);
format = end;
step = utf8_tounicode(format, &ch);
} else if (ch == '*') {
if (objIndex >= objc - 1) {
msg = badIndex[gotXpg];
goto errorMsg;
}
if (Jim_GetLong(interp, objv[objIndex], &width) != JIM_OK) {
goto error;
}
if (width < 0) {
width = -width;
if (!gotMinus) {
*p++ = '-';
gotMinus = 1;
}
}
objIndex++;
format += step;
step = utf8_tounicode(format, &ch);
}
gotPrecision = precision = 0;
if (ch == '.') {
gotPrecision = 1;
format += step;
step = utf8_tounicode(format, &ch);
}
if (isdigit(ch)) {
precision = strtoul(format, &end, 10);
format = end;
step = utf8_tounicode(format, &ch);
} else if (ch == '*') {
if (objIndex >= objc - 1) {
msg = badIndex[gotXpg];
goto errorMsg;
}
if (Jim_GetLong(interp, objv[objIndex], &precision) != JIM_OK) {
goto error;
}
if (precision < 0) {
precision = 0;
}
objIndex++;
format += step;
step = utf8_tounicode(format, &ch);
}
useShort = 0;
if (ch == 'h') {
useShort = 1;
format += step;
step = utf8_tounicode(format, &ch);
} else if (ch == 'l') {
format += step;
step = utf8_tounicode(format, &ch);
if (ch == 'l') {
format += step;
step = utf8_tounicode(format, &ch);
}
}
format += step;
span = format;
if (ch == 'i') {
ch = 'd';
}
doubleType = 0;
switch (ch) {
case '\0':
msg = "format string ended in middle of field specifier";
goto errorMsg;
case 's': {
formatted_buf = Jim_GetString(objv[objIndex], &formatted_bytes);
formatted_chars = Jim_Utf8Length(interp, objv[objIndex]);
if (gotPrecision && (precision < formatted_chars)) {
formatted_chars = precision;
formatted_bytes = utf8_index(formatted_buf, precision);
}
break;
}
case 'c': {
jim_wide code;
if (Jim_GetWide(interp, objv[objIndex], &code) != JIM_OK) {
goto error;
}
formatted_bytes = utf8_getchars(spec, code);
formatted_buf = spec;
formatted_chars = 1;
break;
}
case 'b': {
unsigned jim_wide w;
int length;
int i;
int j;
if (Jim_GetWide(interp, objv[objIndex], (jim_wide *)&w) != JIM_OK) {
goto error;
}
length = sizeof(w) * 8;
if (num_buffer_size < length + 1) {
num_buffer_size = length + 1;
num_buffer = Jim_Realloc(num_buffer, num_buffer_size);
}
j = 0;
for (i = length; i > 0; ) {
i--;
if (w & ((unsigned jim_wide)1 << i)) {
num_buffer[j++] = '1';
}
else if (j || i == 0) {
num_buffer[j++] = '0';
}
}
num_buffer[j] = 0;
formatted_chars = formatted_bytes = j;
formatted_buf = num_buffer;
break;
}
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
doubleType = 1;
case 'd':
case 'u':
case 'o':
case 'x':
case 'X': {
jim_wide w;
double d;
int length;
if (width) {
p += sprintf(p, "%ld", width);
}
if (gotPrecision) {
p += sprintf(p, ".%ld", precision);
}
if (doubleType) {
if (Jim_GetDouble(interp, objv[objIndex], &d) != JIM_OK) {
goto error;
}
length = MAX_FLOAT_WIDTH;
}
else {
if (Jim_GetWide(interp, objv[objIndex], &w) != JIM_OK) {
goto error;
}
length = JIM_INTEGER_SPACE;
if (useShort) {
if (ch == 'd') {
w = (short)w;
}
else {
w = (unsigned short)w;
}
}
*p++ = 'l';
#ifdef HAVE_LONG_LONG
if (sizeof(long long) == sizeof(jim_wide)) {
*p++ = 'l';
}
#endif
}
*p++ = (char) ch;
*p = '\0';
if (width > length) {
length = width;
}
if (gotPrecision) {
length += precision;
}
if (num_buffer_size < length + 1) {
num_buffer_size = length + 1;
num_buffer = Jim_Realloc(num_buffer, num_buffer_size);
}
if (doubleType) {
snprintf(num_buffer, length + 1, spec, d);
}
else {
formatted_bytes = snprintf(num_buffer, length + 1, spec, w);
}
formatted_chars = formatted_bytes = strlen(num_buffer);
formatted_buf = num_buffer;
break;
}
default: {
spec[0] = ch;
spec[1] = '\0';
Jim_SetResultFormatted(interp, "bad field specifier \"%s\"", spec);
goto error;
}
}
if (!gotMinus) {
while (formatted_chars < width) {
Jim_AppendString(interp, resultPtr, &pad, 1);
formatted_chars++;
}
}
Jim_AppendString(interp, resultPtr, formatted_buf, formatted_bytes);
while (formatted_chars < width) {
Jim_AppendString(interp, resultPtr, &pad, 1);
formatted_chars++;
}
objIndex += gotSequential;
}
if (numBytes) {
Jim_AppendString(interp, resultPtr, span, numBytes);
}
Jim_Free(num_buffer);
return resultPtr;
errorMsg:
Jim_SetResultString(interp, msg, -1);
error:
Jim_FreeNewObj(interp, resultPtr);
Jim_Free(num_buffer);
return NULL;
}
#if defined(JIM_REGEXP)
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#define REG_MAX_PAREN 100
#define END 0
#define BOL 1
#define EOL 2
#define ANY 3
#define ANYOF 4
#define ANYBUT 5
#define BRANCH 6
#define BACK 7
#define EXACTLY 8
#define NOTHING 9
#define REP 10
#define REPMIN 11
#define REPX 12
#define REPXMIN 13
#define WORDA 15
#define WORDZ 16
#define OPENNC 1000
#define OPEN 1001
#define CLOSENC 2000
#define CLOSE 2001
#define CLOSE_END (CLOSE+REG_MAX_PAREN)
#define REG_MAGIC 0xFADED00D
#define OP(preg, p) (preg->program[p])
#define NEXT(preg, p) (preg->program[p + 1])
#define OPERAND(p) ((p) + 2)
#define FAIL(R,M) { (R)->err = (M); return (M); }
#define ISMULT(c) ((c) == '*' || (c) == '+' || (c) == '?' || (c) == '{')
#define META "^$.[()|?{+*"
#define HASWIDTH 1
#define SIMPLE 2
#define SPSTART 4
#define WORST 0
#define MAX_REP_COUNT 1000000
static int reg(regex_t *preg, int paren , int *flagp );
static int regpiece(regex_t *preg, int *flagp );
static int regbranch(regex_t *preg, int *flagp );
static int regatom(regex_t *preg, int *flagp );
static int regnode(regex_t *preg, int op );
static int regnext(regex_t *preg, int p );
static void regc(regex_t *preg, int b );
static int reginsert(regex_t *preg, int op, int size, int opnd );
static void regtail(regex_t *preg, int p, int val);
static void regoptail(regex_t *preg, int p, int val );
static int regopsize(regex_t *preg, int p );
static int reg_range_find(const int *string, int c);
static const char *str_find(const char *string, int c, int nocase);
static int prefix_cmp(const int *prog, int proglen, const char *string, int nocase);
#ifdef DEBUG
|
| ︙ | ︙ | |||
19983 19984 19985 19986 19987 19988 19989 | if (exp == NULL) FAIL(preg, REG_ERR_NULL_ARGUMENT); preg->cflags = cflags; preg->regparse = exp; | < < < | 20271 20272 20273 20274 20275 20276 20277 20278 20279 20280 20281 20282 20283 20284 | if (exp == NULL) FAIL(preg, REG_ERR_NULL_ARGUMENT); preg->cflags = cflags; preg->regparse = exp; preg->proglen = (strlen(exp) + 1) * 5; preg->program = malloc(preg->proglen * sizeof(int)); if (preg->program == NULL) FAIL(preg, REG_ERR_NOMEM); |
| ︙ | ︙ | |||
20150 20151 20152 20153 20154 20155 20156 |
static int regpiece(regex_t *preg, int *flagp)
{
int ret;
char op;
int next;
int flags;
| < | 20435 20436 20437 20438 20439 20440 20441 20442 20443 20444 20445 20446 20447 20448 |
static int regpiece(regex_t *preg, int *flagp)
{
int ret;
char op;
int next;
int flags;
int min;
int max;
ret = regatom(preg, &flags);
if (ret == 0)
return 0;
|
| ︙ | ︙ | |||
20233 20234 20235 20236 20237 20238 20239 |
preg->regparse++;
if (ISMULT(*preg->regparse)) {
preg->err = REG_ERR_NESTED_COUNT;
return 0;
}
| | | 20517 20518 20519 20520 20521 20522 20523 20524 20525 20526 20527 20528 20529 20530 20531 |
preg->regparse++;
if (ISMULT(*preg->regparse)) {
preg->err = REG_ERR_NESTED_COUNT;
return 0;
}
return ret;
}
static void reg_addrange(regex_t *preg, int lower, int upper)
{
if (lower > upper) {
reg_addrange(preg, upper, lower);
}
|
| ︙ | ︙ | |||
20327 20328 20329 20330 20331 20332 20333 20334 20335 20336 20337 20338 20339 20340 |
s += n;
}
break;
case 'U':
if ((n = parse_hex(s, 8, ch)) > 0) {
s += n;
}
case 'x':
if ((n = parse_hex(s, 2, ch)) > 0) {
s += n;
}
break;
case '\0':
s--;
| > | 20611 20612 20613 20614 20615 20616 20617 20618 20619 20620 20621 20622 20623 20624 20625 |
s += n;
}
break;
case 'U':
if ((n = parse_hex(s, 8, ch)) > 0) {
s += n;
}
break;
case 'x':
if ((n = parse_hex(s, 2, ch)) > 0) {
s += n;
}
break;
case '\0':
s--;
|
| ︙ | ︙ | |||
20575 20576 20577 20578 20579 20580 20581 20582 20583 20584 20585 20586 20587 20588 |
}
static int regnode(regex_t *preg, int op)
{
reg_grow(preg, 2);
preg->program[preg->p++] = op;
preg->program[preg->p++] = 0;
return preg->p - 2;
}
| > | 20860 20861 20862 20863 20864 20865 20866 20867 20868 20869 20870 20871 20872 20873 20874 |
}
static int regnode(regex_t *preg, int op)
{
reg_grow(preg, 2);
preg->program[preg->p++] = op;
preg->program[preg->p++] = 0;
return preg->p - 2;
}
|
| ︙ | ︙ | |||
20604 20605 20606 20607 20608 20609 20610 | preg->program[opnd] = op; preg->p += size; return opnd + size; } | | | 20890 20891 20892 20893 20894 20895 20896 20897 20898 20899 20900 20901 20902 20903 20904 |
preg->program[opnd] = op;
preg->p += size;
return opnd + size;
}
static void regtail(regex_t *preg, int p, int val)
{
int scan;
int temp;
int offset;
scan = p;
|
| ︙ | ︙ | |||
20667 20668 20669 20670 20671 20672 20673 | preg->eflags = eflags; preg->pmatch = pmatch; preg->nmatch = nmatch; preg->start = string; | | | < < < < < | | < < < < | < < < < < < < < < < < | 20953 20954 20955 20956 20957 20958 20959 20960 20961 20962 20963 20964 20965 20966 20967 20968 20969 20970 20971 20972 |
preg->eflags = eflags;
preg->pmatch = pmatch;
preg->nmatch = nmatch;
preg->start = string;
for (scan = OPERAND(1); scan != 0; scan += regopsize(preg, scan)) {
int op = OP(preg, scan);
if (op == END)
break;
if (op == REPX || op == REPXMIN)
preg->program[scan + 4] = 0;
}
if (preg->regmust != 0) {
s = string;
while ((s = str_find(s, preg->program[preg->regmust], preg->cflags & REG_ICASE)) != NULL) {
if (prefix_cmp(preg->program + preg->regmust, preg->regmlen, s, preg->cflags & REG_ICASE) >= 0) {
|
| ︙ | ︙ | |||
20948 20949 20950 20951 20952 20953 20954 20955 20956 20957 20958 20959 20960 20961 |
}
static int regmatch(regex_t *preg, int prog)
{
int scan;
int next;
scan = prog;
#ifdef DEBUG
if (scan != 0 && regnarrate)
fprintf(stderr, "%s(\n", regprop(scan));
#endif
| > | 21214 21215 21216 21217 21218 21219 21220 21221 21222 21223 21224 21225 21226 21227 21228 |
}
static int regmatch(regex_t *preg, int prog)
{
int scan;
int next;
const char *save;
scan = prog;
#ifdef DEBUG
if (scan != 0 && regnarrate)
fprintf(stderr, "%s(\n", regprop(scan));
#endif
|
| ︙ | ︙ | |||
21036 21037 21038 21039 21040 21041 21042 | } preg->reginput += n; break; case NOTHING: break; case BACK: break; | | < < | | | | | | | | | | | | | < | < | < < < < < < < | | < > | | 21303 21304 21305 21306 21307 21308 21309 21310 21311 21312 21313 21314 21315 21316 21317 21318 21319 21320 21321 21322 21323 21324 21325 21326 21327 21328 21329 21330 21331 21332 21333 21334 21335 21336 21337 21338 21339 21340 21341 21342 21343 21344 21345 21346 21347 21348 21349 21350 21351 21352 21353 21354 21355 21356 21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 |
}
preg->reginput += n;
break;
case NOTHING:
break;
case BACK:
break;
case BRANCH:
if (OP(preg, next) != BRANCH)
next = OPERAND(scan);
else {
do {
save = preg->reginput;
if (regmatch(preg, OPERAND(scan))) {
return(1);
}
preg->reginput = save;
scan = regnext(preg, scan);
} while (scan != 0 && OP(preg, scan) == BRANCH);
return(0);
}
break;
case REP:
case REPMIN:
return regmatchsimplerepeat(preg, scan, OP(preg, scan) == REPMIN);
case REPX:
case REPXMIN:
return regmatchrepeat(preg, scan, OP(preg, scan) == REPXMIN);
case END:
return 1;
case OPENNC:
case CLOSENC:
return regmatch(preg, next);
default:
if (OP(preg, scan) >= OPEN+1 && OP(preg, scan) < CLOSE_END) {
save = preg->reginput;
if (regmatch(preg, next)) {
if (OP(preg, scan) < CLOSE) {
int no = OP(preg, scan) - OPEN;
if (no < preg->nmatch && preg->pmatch[no].rm_so == -1) {
preg->pmatch[no].rm_so = save - preg->start;
}
}
else {
int no = OP(preg, scan) - CLOSE;
if (no < preg->nmatch && preg->pmatch[no].rm_eo == -1) {
preg->pmatch[no].rm_eo = save - preg->start;
}
}
return(1);
}
return(0);
}
return REG_ERR_INTERNAL;
}
scan = next;
}
|
| ︙ | ︙ | |||
21179 21180 21181 21182 21183 21184 21185 21186 21187 21188 21189 21190 21191 21192 |
return 0;
if (OP(preg, p) == BACK)
return(p-offset);
else
return(p+offset);
}
size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
static const char *error_strings[] = {
"success",
"no match",
| > > > > > > > > > > > > > > > > > > > > > > | 21435 21436 21437 21438 21439 21440 21441 21442 21443 21444 21445 21446 21447 21448 21449 21450 21451 21452 21453 21454 21455 21456 21457 21458 21459 21460 21461 21462 21463 21464 21465 21466 21467 21468 21469 21470 |
return 0;
if (OP(preg, p) == BACK)
return(p-offset);
else
return(p+offset);
}
static int regopsize(regex_t *preg, int p )
{
switch (OP(preg, p)) {
case REP:
case REPMIN:
case REPX:
case REPXMIN:
return 5;
case ANYOF:
case ANYBUT:
case EXACTLY: {
int s = p + 2;
while (preg->program[s++]) {
}
return s - p;
}
}
return 2;
}
size_t regerror(int errcode, const regex_t *preg, char *errbuf, size_t errbuf_size)
{
static const char *error_strings[] = {
"success",
"no match",
|
| ︙ | ︙ | |||
21357 21358 21359 21360 21361 21362 21363 21364 21365 21366 21367 21368 21369 21370 21371 21372 21373 21374 21375 21376 21377 21378 21379 |
#endif
char *Jim_HistoryGetline(const char *prompt)
{
#ifdef USE_LINENOISE
return linenoise(prompt);
#else
char *line = malloc(MAX_LINE_LEN);
fputs(prompt, stdout);
fflush(stdout);
if (fgets(line, MAX_LINE_LEN, stdin) == NULL) {
free(line);
return NULL;
}
return line;
#endif
}
void Jim_HistoryLoad(const char *filename)
{
#ifdef USE_LINENOISE
| > > > > > | 21635 21636 21637 21638 21639 21640 21641 21642 21643 21644 21645 21646 21647 21648 21649 21650 21651 21652 21653 21654 21655 21656 21657 21658 21659 21660 21661 21662 |
#endif
char *Jim_HistoryGetline(const char *prompt)
{
#ifdef USE_LINENOISE
return linenoise(prompt);
#else
int len;
char *line = malloc(MAX_LINE_LEN);
fputs(prompt, stdout);
fflush(stdout);
if (fgets(line, MAX_LINE_LEN, stdin) == NULL) {
free(line);
return NULL;
}
len = strlen(line);
if (len && line[len - 1] == '\n') {
line[len - 1] = '\0';
}
return line;
#endif
}
void Jim_HistoryLoad(const char *filename)
{
#ifdef USE_LINENOISE
|
| ︙ | ︙ | |||
21420 21421 21422 21423 21424 21425 21426 |
int history_len = strlen(home) + sizeof("/.jim_history");
history_file = Jim_Alloc(history_len);
snprintf(history_file, history_len, "%s/.jim_history", home);
Jim_HistoryLoad(history_file);
}
#endif
| | | 21703 21704 21705 21706 21707 21708 21709 21710 21711 21712 21713 21714 21715 21716 21717 |
int history_len = strlen(home) + sizeof("/.jim_history");
history_file = Jim_Alloc(history_len);
snprintf(history_file, history_len, "%s/.jim_history", home);
Jim_HistoryLoad(history_file);
}
#endif
printf("Welcome to Jim version %d.%d\n",
JIM_VERSION / 100, JIM_VERSION % 100);
Jim_SetVariableStrWithStr(interp, JIM_INTERACTIVE, "1");
while (1) {
Jim_Obj *scriptObjPtr;
const char *result;
int reslen;
|
| ︙ | ︙ | |||
21532 21533 21534 21535 21536 21537 21538 21539 21540 21541 21542 21543 21544 21545 21546 21547 21548 21549 21550 21551 21552 21553 21554 21555 |
Jim_ListAppendElement(interp, listObj, obj);
}
Jim_SetVariableStr(interp, "argv", listObj);
Jim_SetVariableStr(interp, "argc", Jim_NewIntObj(interp, argc));
}
int main(int argc, char *const argv[])
{
int retcode;
Jim_Interp *interp;
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
printf("%d.%d\n", JIM_VERSION / 100, JIM_VERSION % 100);
return 0;
}
interp = Jim_CreateInterp();
Jim_RegisterCoreCommands(interp);
if (Jim_InitStaticExtensions(interp) != JIM_OK) {
| > > > > > > | < | < | < | 21815 21816 21817 21818 21819 21820 21821 21822 21823 21824 21825 21826 21827 21828 21829 21830 21831 21832 21833 21834 21835 21836 21837 21838 21839 21840 21841 21842 21843 21844 21845 21846 21847 21848 21849 21850 21851 21852 21853 21854 21855 21856 21857 21858 21859 21860 21861 21862 21863 21864 21865 21866 21867 21868 21869 21870 21871 21872 21873 21874 21875 21876 21877 21878 21879 21880 21881 21882 |
Jim_ListAppendElement(interp, listObj, obj);
}
Jim_SetVariableStr(interp, "argv", listObj);
Jim_SetVariableStr(interp, "argc", Jim_NewIntObj(interp, argc));
}
static void JimPrintErrorMessage(Jim_Interp *interp)
{
Jim_MakeErrorMessage(interp);
fprintf(stderr, "%s\n", Jim_String(Jim_GetResult(interp)));
}
int main(int argc, char *const argv[])
{
int retcode;
Jim_Interp *interp;
if (argc > 1 && strcmp(argv[1], "--version") == 0) {
printf("%d.%d\n", JIM_VERSION / 100, JIM_VERSION % 100);
return 0;
}
interp = Jim_CreateInterp();
Jim_RegisterCoreCommands(interp);
if (Jim_InitStaticExtensions(interp) != JIM_OK) {
JimPrintErrorMessage(interp);
}
Jim_SetVariableStrWithStr(interp, "jim_argv0", argv[0]);
Jim_SetVariableStrWithStr(interp, JIM_INTERACTIVE, argc == 1 ? "1" : "0");
retcode = Jim_initjimshInit(interp);
if (argc == 1) {
if (retcode == JIM_ERR) {
JimPrintErrorMessage(interp);
}
if (retcode != JIM_EXIT) {
JimSetArgv(interp, 0, NULL);
retcode = Jim_InteractivePrompt(interp);
}
}
else {
if (argc > 2 && strcmp(argv[1], "-e") == 0) {
JimSetArgv(interp, argc - 3, argv + 3);
retcode = Jim_Eval(interp, argv[2]);
if (retcode != JIM_ERR) {
printf("%s\n", Jim_String(Jim_GetResult(interp)));
}
}
else {
Jim_SetVariableStr(interp, "argv0", Jim_NewStringObj(interp, argv[1], -1));
JimSetArgv(interp, argc - 2, argv + 2);
retcode = Jim_EvalFile(interp, argv[1]);
}
if (retcode == JIM_ERR) {
JimPrintErrorMessage(interp);
}
}
if (retcode == JIM_EXIT) {
retcode = Jim_GetExitCode(interp);
}
else if (retcode == JIM_ERR) {
retcode = 1;
|
| ︙ | ︙ |
Changes to src/add.c.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
"_FOSSIL_-wal",
"_FOSSIL_-shm",
".fslckout",
".fslckout-journal",
".fslckout-wal",
".fslckout-shm",
| | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
"_FOSSIL_-wal",
"_FOSSIL_-shm",
".fslckout",
".fslckout-journal",
".fslckout-wal",
".fslckout-shm",
/* The use of ".fos" as the name of the checkout database is
** deprecated. Use ".fslckout" instead. At some point, the following
** entries should be removed. 2012-02-04 */
".fos",
".fos-journal",
".fos-wal",
".fos-shm",
};
|
| ︙ | ︙ | |||
121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
**
** Show all reserved filenames for the current check-out.
*/
void test_reserved_names(void){
int i;
const char *z;
int omitRepo = find_option("omitrepo",0,0)!=0;
db_must_be_within_tree();
for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
fossil_print("%3d: %s\n", i, z);
}
fossil_print("ALL: (%s)\n", fossil_all_reserved_names(omitRepo));
}
| > > > > | 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
**
** Show all reserved filenames for the current check-out.
*/
void test_reserved_names(void){
int i;
const char *z;
int omitRepo = find_option("omitrepo",0,0)!=0;
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
for(i=0; (z = fossil_reserved_name(i, omitRepo))!=0; i++){
fossil_print("%3d: %s\n", i, z);
}
fossil_print("ALL: (%s)\n", fossil_all_reserved_names(omitRepo));
}
|
| ︙ | ︙ | |||
175 176 177 178 179 180 181 | const char *zRepo; /* Name of the repository database file */ int nAdd = 0; /* Number of files added */ int i; /* Loop counter */ const char *zReserved; /* Name of a reserved file */ Blob repoName; /* Treename of the repository */ Stmt loop; /* SQL to loop over all files to add */ int (*xCmp)(const char*,const char*); | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
const char *zRepo; /* Name of the repository database file */
int nAdd = 0; /* Number of files added */
int i; /* Loop counter */
const char *zReserved; /* Name of a reserved file */
Blob repoName; /* Treename of the repository */
Stmt loop; /* SQL to loop over all files to add */
int (*xCmp)(const char*,const char*);
if( !file_tree_name(g.zRepositoryName, &repoName, 0) ){
blob_zero(&repoName);
zRepo = "";
}else{
zRepo = blob_str(&repoName);
}
if( filenames_are_case_sensitive() ){
|
| ︙ | ︙ | |||
231 232 233 234 235 236 237 | ** The --case-sensitive option determines whether or not filenames should ** be treated case sensitive or not. If the option is not given, the default ** depends on the global setting, or the operating system default, if not set. ** ** Options: ** ** --case-sensitive <BOOL> override case-sensitive setting | | | | | > > > | | 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 |
** The --case-sensitive option determines whether or not filenames should
** be treated case sensitive or not. If the option is not given, the default
** depends on the global setting, or the operating system default, if not set.
**
** Options:
**
** --case-sensitive <BOOL> override case-sensitive setting
** --dotfiles include files beginning with a dot (".")
** -f|--force Add files without prompting
** --ignore <CSG> ignore files matching patterns from the
** comma separated list of glob patterns.
** --clean <CSG> also ignore files matching patterns from
** the comma separated list of glob patterns.
**
** See also: addremove, rm
*/
void add_cmd(void){
int i; /* Loop counter */
int vid; /* Currently checked out version */
int nRoot; /* Full path characters in g.zLocalRoot */
const char *zCleanFlag; /* The --clean option or clean-glob setting */
const char *zIgnoreFlag; /* The --ignore option or ignore-glob setting */
Glob *pIgnore, *pClean; /* Ignore everything matching the glob patterns */
unsigned scanFlags = 0; /* Flags passed to vfile_scan() */
int forceFlag;
zCleanFlag = find_option("clean",0,1);
zIgnoreFlag = find_option("ignore",0,1);
forceFlag = find_option("force","f",0)!=0;
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
if( zCleanFlag==0 ){
zCleanFlag = db_get("clean-glob", 0);
}
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
vid = db_lget_int("checkout",0);
db_begin_transaction();
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
filename_collation());
pClean = glob_create(zCleanFlag);
pIgnore = glob_create(zIgnoreFlag);
nRoot = strlen(g.zLocalRoot);
/* Load the names of all files that are to be added into sfile temp table */
for(i=2; i<g.argc; i++){
char *zName;
int isDir;
Blob fullName;
/* file_tree_name() throws a fatal error if g.argv[i] is outside of the
|
| ︙ | ︙ | |||
343 344 345 346 347 348 349 |
**
** See also: addremove, add
*/
void delete_cmd(void){
int i;
Stmt loop;
| > > | | 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 |
**
** See also: addremove, add
*/
void delete_cmd(void){
int i;
Stmt loop;
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
db_begin_transaction();
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
filename_collation());
for(i=2; i<g.argc; i++){
Blob treeName;
char *zTreeName;
|
| ︙ | ︙ | |||
365 366 367 368 369 370 371 |
" OR (pathname>'%q/' %s AND pathname<'%q0' %s))"
" AND NOT deleted",
zTreeName, filename_collation(), zTreeName,
filename_collation(), zTreeName, filename_collation()
);
blob_reset(&treeName);
}
| | | 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
" OR (pathname>'%q/' %s AND pathname<'%q0' %s))"
" AND NOT deleted",
zTreeName, filename_collation(), zTreeName,
filename_collation(), zTreeName, filename_collation()
);
blob_reset(&treeName);
}
db_prepare(&loop, "SELECT x FROM sfile");
while( db_step(&loop)==SQLITE_ROW ){
fossil_print("DELETED %s\n", db_column_text(&loop, 0));
}
db_finalize(&loop);
db_multi_exec(
"UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
|
| ︙ | ︙ | |||
431 432 433 434 435 436 437 |
#else
caseSensitive = 1; /* Unix */
#endif
caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
}
if( !caseSensitive && g.localOpen ){
db_multi_exec(
| | | > | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
#else
caseSensitive = 1; /* Unix */
#endif
caseSensitive = db_get_boolean("case-sensitive",caseSensitive);
}
if( !caseSensitive && g.localOpen ){
db_multi_exec(
"CREATE INDEX IF NOT EXISTS %s.vfile_nocase"
" ON vfile(pathname COLLATE nocase)",
db_name("localdb")
);
}
}
return caseSensitive;
}
/*
|
| ︙ | ︙ | |||
480 481 482 483 484 485 486 | ** --case-sensitive option with the "case-sensitive" setting and the ** --clean option with the "clean-glob" setting. See the documentation ** on the "settings" command for further information. ** ** The -n|--dry-run option shows what would happen without actually doing anything. ** ** This command can be used to track third party software. | | | | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 |
** --case-sensitive option with the "case-sensitive" setting and the
** --clean option with the "clean-glob" setting. See the documentation
** on the "settings" command for further information.
**
** The -n|--dry-run option shows what would happen without actually doing anything.
**
** This command can be used to track third party software.
**
** Options:
** --case-sensitive <BOOL> override case-sensitive setting
** --dotfiles include files beginning with a dot (".")
** --ignore <CSG> ignore files matching patterns from the
** comma separated list of glob patterns.
** --clean <CSG> also ignore files matching patterns from
** the comma separated list of glob patterns.
** -n|--dry-run If given, display instead of run actions
|
| ︙ | ︙ | |||
508 509 510 511 512 513 514 |
int nAdd = 0;
int nDelete = 0;
Glob *pIgnore, *pClean;
if( !dryRunFlag ){
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
}
| | > > > | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
int nAdd = 0;
int nDelete = 0;
Glob *pIgnore, *pClean;
if( !dryRunFlag ){
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
}
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
if( zCleanFlag==0 ){
zCleanFlag = db_get("clean-glob", 0);
}
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
vid = db_lget_int("checkout",0);
db_begin_transaction();
/* step 1:
** Populate the temp table "sfile" with the names of all unmanaged
** files currently in the check-out, except for files that match the
** --ignore or ignore-glob patterns and dot-files. Then add all of
** the files in the sfile temp table to the set of managed files.
*/
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
filename_collation());
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
db_prepare(&q,
"SELECT pathname, %Q || pathname, deleted FROM vfile"
" WHERE NOT deleted"
" ORDER BY 1",
g.zLocalRoot
);
while( db_step(&q)==SQLITE_ROW ){
| | | | 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 |
db_prepare(&q,
"SELECT pathname, %Q || pathname, deleted FROM vfile"
" WHERE NOT deleted"
" ORDER BY 1",
g.zLocalRoot
);
while( db_step(&q)==SQLITE_ROW ){
const char *zFile;
const char *zPath;
zFile = db_column_text(&q, 0);
zPath = db_column_text(&q, 1);
if( !file_wd_isfile_or_link(zPath) ){
if( !dryRunFlag ){
db_multi_exec("UPDATE vfile SET deleted=1 WHERE pathname=%Q", zFile);
}
|
| ︙ | ︙ | |||
577 578 579 580 581 582 583 |
*/
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
zNew, filename_collation());
if( x>=0 ){
if( x==0 ){
fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
| | | 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 |
*/
static void mv_one_file(int vid, const char *zOrig, const char *zNew){
int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
zNew, filename_collation());
if( x>=0 ){
if( x==0 ){
fossil_fatal("cannot rename '%s' to '%s' since another file named '%s'"
" is currently under management", zOrig, zNew, zNew);
}else{
fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has "
"not yet been committed", zOrig, zNew, zNew);
}
}
fossil_print("RENAME %s %s\n", zOrig, zNew);
db_multi_exec(
|
| ︙ | ︙ | |||
616 617 618 619 620 621 622 |
void mv_cmd(void){
int i;
int vid;
char *zDest;
Blob dest;
Stmt q;
| < > > > > | 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 |
void mv_cmd(void){
int i;
int vid;
char *zDest;
Blob dest;
Stmt q;
db_must_be_within_tree();
/* We should be done with options.. */
verify_all_options();
vid = db_lget_int("checkout", 0);
if( vid==0 ){
fossil_fatal("no checkout rename files in");
}
if( g.argc<4 ){
usage("OLDNAME NEWNAME");
}
|
| ︙ | ︙ |
Changes to src/allrepo.c.
| ︙ | ︙ | |||
96 97 98 99 100 101 102 103 104 105 106 107 108 109 | ** caution should be exercised with this command because its ** effects cannot be undone. Use of the --dry-run option to ** carefully review the local checkouts to be operated upon ** and the --whatif option to carefully review the files to ** be deleted beforehand is highly recommended. The command ** line options supported by the clean command itself, if any ** are present, are passed along verbatim. ** ** extras Shows "extra" files from all local checkouts. The command ** line options supported by the extra command itself, if any ** are present, are passed along verbatim. ** ** ignore Arguments are repositories that should be ignored by ** subsequent clean, extras, list, pull, push, rebuild, and | > > | 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 | ** caution should be exercised with this command because its ** effects cannot be undone. Use of the --dry-run option to ** carefully review the local checkouts to be operated upon ** and the --whatif option to carefully review the files to ** be deleted beforehand is highly recommended. The command ** line options supported by the clean command itself, if any ** are present, are passed along verbatim. ** ** dbstat Run the "dbstat" command on all repositories. ** ** extras Shows "extra" files from all local checkouts. The command ** line options supported by the extra command itself, if any ** are present, are passed along verbatim. ** ** ignore Arguments are repositories that should be ignored by ** subsequent clean, extras, list, pull, push, rebuild, and |
| ︙ | ︙ | |||
127 128 129 130 131 132 133 | ** --randomize options are not supported. ** ** sync Run a "sync" on all repositories. Only the --verbose ** option is supported. ** ** setting Run the "setting", "set", or "unset" commands on all ** set repositories. These command are particularly useful in | | | 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | ** --randomize options are not supported. ** ** sync Run a "sync" on all repositories. Only the --verbose ** option is supported. ** ** setting Run the "setting", "set", or "unset" commands on all ** set repositories. These command are particularly useful in ** unset conjunction with the "max-loadavg" setting which cannot ** otherwise be set globally. ** ** Repositories are automatically added to the set of known repositories ** when one of the following commands are run against the repository: ** clone, info, pull, push, or sync. Even previously ignored repositories ** are added back to the list of repositories by these commands. ** |
| ︙ | ︙ | |||
188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
collect_argument(&extra, "force","f");
collect_argument_value(&extra, "ignore");
collect_argument_value(&extra, "keep");
collect_argument(&extra, "temp",0);
collect_argument(&extra, "verbose","v");
collect_argument(&extra, "whatif",0);
useCheckouts = 1;
}else if( strncmp(zCmd, "extras", n)==0 ){
if( showFile ){
zCmd = "extras --chdir";
}else{
zCmd = "extras --header --chdir";
}
collect_argument(&extra, "abs-paths",0);
| > > > > > > | 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 |
collect_argument(&extra, "force","f");
collect_argument_value(&extra, "ignore");
collect_argument_value(&extra, "keep");
collect_argument(&extra, "temp",0);
collect_argument(&extra, "verbose","v");
collect_argument(&extra, "whatif",0);
useCheckouts = 1;
}else if( strncmp(zCmd, "dbstat", n)==0 ){
zCmd = "dbstat --omit-version-info -R";
showLabel = 1;
quiet = 1;
collect_argument(&extra, "brief", "b");
collect_argument(&extra, "db-check", 0);
}else if( strncmp(zCmd, "extras", n)==0 ){
if( showFile ){
zCmd = "extras --chdir";
}else{
zCmd = "extras --header --chdir";
}
collect_argument(&extra, "abs-paths",0);
|
| ︙ | ︙ | |||
247 248 249 250 251 252 253 |
quiet = 1;
}else if( strncmp(zCmd, "ignore", n)==0 ){
int j;
useCheckouts = find_option("ckout","c",0)!=0;
verify_all_options();
db_begin_transaction();
for(j=3; j<g.argc; j++){
| | > > | | > | | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
quiet = 1;
}else if( strncmp(zCmd, "ignore", n)==0 ){
int j;
useCheckouts = find_option("ckout","c",0)!=0;
verify_all_options();
db_begin_transaction();
for(j=3; j<g.argc; j++){
Blob sql;
blob_zero(&sql);
blob_append_sql(&sql,
"DELETE FROM global_config WHERE name GLOB '%s:%q'",
useCheckouts?"ckout":"repo", g.argv[j]
);
if( dryRunFlag ){
fossil_print("%s\n", blob_sql_text(&sql));
}else{
db_multi_exec("%s", blob_sql_text(&sql));
}
blob_reset(&sql);
}
db_end_transaction(0);
return;
}else if( strncmp(zCmd, "info", n)==0 ){
zCmd = "info";
showLabel = 1;
quiet = 1;
|
| ︙ | ︙ | |||
336 337 338 339 340 341 342 |
** be found, remove those names from the ~/.fossil file.
*/
if( nToDel>0 ){
const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
if( dryRunFlag ){
fossil_print("%s\n", zSql);
}else{
| | | 347 348 349 350 351 352 353 354 355 356 357 |
** be found, remove those names from the ~/.fossil file.
*/
if( nToDel>0 ){
const char *zSql = "DELETE FROM global_config WHERE name IN toDel";
if( dryRunFlag ){
fossil_print("%s\n", zSql);
}else{
db_multi_exec("%s", zSql /*safe-for-%s*/ );
}
}
}
|
Changes to src/attach.c.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 |
const char *zTkt = P("tkt");
Blob sql;
Stmt q;
if( zPage && zTkt ) zTkt = 0;
login_check_credentials();
blob_zero(&sql);
| | | | | | | 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 |
const char *zTkt = P("tkt");
Blob sql;
Stmt q;
if( zPage && zTkt ) zTkt = 0;
login_check_credentials();
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT datetime(mtime%s), src, target, filename,"
" comment, user,"
" (SELECT uuid FROM blob WHERE rid=attachid), attachid"
" FROM attachment",
timeline_utc()
);
if( zPage ){
if( g.perm.RdWiki==0 ) login_needed();
style_header("Attachments To %h", zPage);
blob_append_sql(&sql, " WHERE target=%Q", zPage);
}else if( zTkt ){
if( g.perm.RdTkt==0 ) login_needed();
style_header("Attachments To Ticket %S", zTkt);
blob_append_sql(&sql, " WHERE target GLOB '%q*'", zTkt);
}else{
if( g.perm.RdTkt==0 && g.perm.RdWiki==0 ) login_needed();
style_header("All Attachments");
}
blob_append_sql(&sql, " ORDER BY mtime DESC");
db_prepare(&q, "%s", blob_sql_text(&sql));
@ <ol>
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
const char *zSrc = db_column_text(&q, 1);
const char *zTarget = db_column_text(&q, 2);
const char *zFilename = db_column_text(&q, 3);
const char *zComment = db_column_text(&q, 4);
|
| ︙ | ︙ | |||
286 287 288 289 290 291 292 |
manifest_destroy(pManifest);
blob_init(&content, aContent, szContent);
if( pManifest ){
blob_compress(&content, &content);
addCompress = 1;
}
needModerator =
| | | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
manifest_destroy(pManifest);
blob_init(&content, aContent, szContent);
if( pManifest ){
blob_compress(&content, &content);
addCompress = 1;
}
needModerator =
(zTkt!=0 && ticket_need_moderation(0)) ||
(zPage!=0 && wiki_need_moderation(0));
rid = content_put_ex(&content, 0, 0, 0, needModerator);
zUUID = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
blob_zero(&manifest);
for(i=n=0; zName[i]; i++){
if( zName[i]=='/' || zName[i]=='\\' ) n = i;
}
zName += n;
|
| ︙ | ︙ | |||
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
const char *zWikiName = 0; /* Wiki page name when attached to Wiki */
const char *zTktUuid = 0; /* Ticket ID when attached to a ticket */
int modPending; /* True if awaiting moderation */
const char *zModAction; /* Moderation action or NULL */
int isModerator; /* TRUE if user is the moderator */
const char *zMime; /* MIME Type */
Blob attach; /* Content of the attachment */
login_check_credentials();
if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; }
rid = name_to_rid_www("name");
if( rid==0 ){ fossil_redirect_home(); }
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
#if 0
/* Shunning here needs to get both the attachment control artifact and
** the object that is attached. */
if( g.perm.Admin ){
| > > | | > > | | 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
const char *zWikiName = 0; /* Wiki page name when attached to Wiki */
const char *zTktUuid = 0; /* Ticket ID when attached to a ticket */
int modPending; /* True if awaiting moderation */
const char *zModAction; /* Moderation action or NULL */
int isModerator; /* TRUE if user is the moderator */
const char *zMime; /* MIME Type */
Blob attach; /* Content of the attachment */
int fShowContent = 0;
const char *zLn = P("ln");
login_check_credentials();
if( !g.perm.RdTkt && !g.perm.RdWiki ){ login_needed(); return; }
rid = name_to_rid_www("name");
if( rid==0 ){ fossil_redirect_home(); }
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
#if 0
/* Shunning here needs to get both the attachment control artifact and
** the object that is attached. */
if( g.perm.Admin ){
if( db_exists("SELECT 1 FROM shun WHERE uuid='%q'", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?uuid=%s&sub=1",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
#endif
pAttach = manifest_get(rid, CFTYPE_ATTACHMENT, 0);
if( pAttach==0 ) fossil_redirect_home();
zTarget = pAttach->zAttachTarget;
zSrc = pAttach->zAttachSrc;
ridSrc = db_int(0,"SELECT rid FROM blob WHERE uuid='%q'", zSrc);
zName = pAttach->zAttachName;
zDesc = pAttach->zComment;
zMime = mimetype_from_name(zName);
fShowContent = zMime ? strncmp(zMime,"text/", 5)==0 : 0;
if( validate16(zTarget, strlen(zTarget))
&& db_exists("SELECT 1 FROM ticket WHERE tkt_uuid='%q'", zTarget)
){
zTktUuid = zTarget;
if( !g.perm.RdTkt ){ login_needed(); return; }
if( g.perm.WrTkt ){
style_submenu_element("Delete","Delete","%R/ainfo/%s?del", zUuid);
}
}else if( db_exists("SELECT 1 FROM tag WHERE tagname='wiki-%q'",zTarget) ){
|
| ︙ | ︙ | |||
462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
style_header("Attachment Details");
style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid);
@ <div class="section">Overview</div>
@ <p><table class="label-value">
@ <tr><th>Artifact ID:</th>
@ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a>
if( g.perm.Setup ){
@ (%d(rid))
| > > > > > | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 |
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
style_header("Attachment Details");
style_submenu_element("Raw", "Raw", "%R/artifact/%s", zUuid);
if(fShowContent){
style_submenu_element("Line Numbers", "Line Numbers",
"%R/ainfo/%s%s",zUuid,
((zLn&&*zLn) ? "" : "?ln=0"));
}
@ <div class="section">Overview</div>
@ <p><table class="label-value">
@ <tr><th>Artifact ID:</th>
@ <td>%z(href("%R/artifact/%s",zUuid))%s(zUuid)</a>
if( g.perm.Setup ){
@ (%d(rid))
|
| ︙ | ︙ | |||
492 493 494 495 496 497 498 |
hyperlink_to_user(pAttach->zUser, zDate, "</td></tr>");
@ <tr><th>Artifact Attached:</th>
@ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a>
if( g.perm.Setup ){
@ (%d(ridSrc))
}
@ <tr><th>Filename:</th><td>%h(zName)</td></tr>
| < | 501 502 503 504 505 506 507 508 509 510 511 512 513 514 |
hyperlink_to_user(pAttach->zUser, zDate, "</td></tr>");
@ <tr><th>Artifact Attached:</th>
@ <td>%z(href("%R/artifact/%s",zSrc))%s(zSrc)</a>
if( g.perm.Setup ){
@ (%d(ridSrc))
}
@ <tr><th>Filename:</th><td>%h(zName)</td></tr>
if( g.perm.Setup ){
@ <tr><th>MIME-Type:</th><td>%h(zMime)</td></tr>
}
@ <tr><th valign="top">Description:</th><td valign="top">%h(zDesc)</td></tr>
@ </table>
if( isModerator && modPending ){
|
| ︙ | ︙ | |||
515 516 517 518 519 520 521 |
@ </form>
@ </blockquote>
}
@ <div class="section">Content Appended</div>
@ <blockquote>
blob_zero(&attach);
| | < | 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 |
@ </form>
@ </blockquote>
}
@ <div class="section">Content Appended</div>
@ <blockquote>
blob_zero(&attach);
if( fShowContent ){
const char *z;
content_get(ridSrc, &attach);
blob_to_utf8_no_bom(&attach, 0);
z = blob_str(&attach);
if( zLn ){
output_text_with_line_numbers(z, zLn);
}else{
@ <pre>
|
| ︙ | ︙ |
Changes to src/bisect.c.
| ︙ | ︙ | |||
204 205 206 207 208 209 210 |
db_finalize(&q);
db_prepare(&q,
"SELECT bilog.seq, bilog.stat,"
" substr(blob.uuid,1,16), datetime(event.mtime)"
" FROM bilog, blob, event"
" WHERE blob.rid=bilog.rid AND event.objid=bilog.rid"
" AND event.type='ci'"
| | | | 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
db_finalize(&q);
db_prepare(&q,
"SELECT bilog.seq, bilog.stat,"
" substr(blob.uuid,1,16), datetime(event.mtime)"
" FROM bilog, blob, event"
" WHERE blob.rid=bilog.rid AND event.objid=bilog.rid"
" AND event.type='ci'"
" ORDER BY %s bilog.rowid ASC",
(sortByCkinTime ? "event.mtime DESC, " : "")
);
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%3d %-7s %s %s\n",
db_column_int(&q, 0),
db_column_text(&q, 1),
db_column_text(&q, 3),
db_column_text(&q, 2));
|
| ︙ | ︙ | |||
388 389 390 391 392 393 394 |
if( g.argc==3 ){
unsigned int i;
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
db_lget(z, (char*)aBisectOption[i].zDefault));
fossil_free(z);
| | | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
if( g.argc==3 ){
unsigned int i;
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
fossil_print(" %-15s %-6s ", aBisectOption[i].zName,
db_lget(z, (char*)aBisectOption[i].zDefault));
fossil_free(z);
comment_print(aBisectOption[i].zDesc, 0, 27, -1, g.comFmtFlags);
}
}else if( g.argc==4 || g.argc==5 ){
unsigned int i;
n = strlen(g.argv[3]);
for(i=0; i<sizeof(aBisectOption)/sizeof(aBisectOption[0]); i++){
if( strncmp(g.argv[3], aBisectOption[i].zName, n)==0 ){
char *z = mprintf("bisect-%s", aBisectOption[i].zName);
if( g.argc==5 ){
db_lset(z, g.argv[4]);
}
fossil_print("%s\n", db_lget(z, (char*)aBisectOption[i].zDefault));
fossil_free(z);
break;
|
| ︙ | ︙ |
Changes to src/blob.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | ** ******************************************************************************* ** ** A Blob is a variable-length containers for arbitrary string ** or binary data. */ #include "config.h" | > > > > | > > > > > > > | 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 |
**
*******************************************************************************
**
** A Blob is a variable-length containers for arbitrary string
** or binary data.
*/
#include "config.h"
#if defined(FOSSIL_ENABLE_MINIZ)
# define MINIZ_HEADER_FILE_ONLY
# include "miniz.c"
#else
# include <zlib.h>
#endif
#include "blob.h"
#if INTERFACE
/*
** A Blob can hold a string or a binary object of arbitrary size. The
** size changes as necessary.
*/
struct Blob {
unsigned int nUsed; /* Number of bytes used in aData[] */
unsigned int nAlloc; /* Number of bytes allocated for aData[] */
unsigned int iCursor; /* Next character of input to parse */
unsigned int blobFlags; /* One or more BLOBFLAG_* bits */
char *aData; /* Where the information is stored */
void (*xRealloc)(Blob*, unsigned int); /* Function to reallocate the buffer */
};
/*
** Allowed values for Blob.blobFlags
*/
#define BLOBFLAG_NotSQL 0x0001 /* Non-SQL text */
/*
** The current size of a Blob
*/
#define blob_size(X) ((X)->nUsed)
/*
** The buffer holding the blob data
|
| ︙ | ︙ | |||
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
void blobReallocMalloc(Blob *pBlob, unsigned int newSize){
if( newSize==0 ){
free(pBlob->aData);
pBlob->aData = 0;
pBlob->nAlloc = 0;
pBlob->nUsed = 0;
pBlob->iCursor = 0;
}else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){
char *pNew = fossil_realloc(pBlob->aData, newSize);
pBlob->aData = pNew;
pBlob->nAlloc = newSize;
if( pBlob->nUsed>pBlob->nAlloc ){
pBlob->nUsed = pBlob->nAlloc;
}
}
}
/*
** An initializer for Blobs
*/
#if INTERFACE
| > | | 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 |
void blobReallocMalloc(Blob *pBlob, unsigned int newSize){
if( newSize==0 ){
free(pBlob->aData);
pBlob->aData = 0;
pBlob->nAlloc = 0;
pBlob->nUsed = 0;
pBlob->iCursor = 0;
pBlob->blobFlags = 0;
}else if( newSize>pBlob->nAlloc || newSize<pBlob->nAlloc-4000 ){
char *pNew = fossil_realloc(pBlob->aData, newSize);
pBlob->aData = pNew;
pBlob->nAlloc = newSize;
if( pBlob->nUsed>pBlob->nAlloc ){
pBlob->nUsed = pBlob->nAlloc;
}
}
}
/*
** An initializer for Blobs
*/
#if INTERFACE
#define BLOB_INITIALIZER {0,0,0,0,0,blobReallocMalloc}
#endif
const Blob empty_blob = BLOB_INITIALIZER;
/*
** A reallocation function for when the initial string is in unmanaged
** space. Copy the string to memory obtained from malloc().
*/
|
| ︙ | ︙ | |||
210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
if( zData==0 ){
*pBlob = empty_blob;
}else{
if( size<=0 ) size = strlen(zData);
pBlob->nUsed = pBlob->nAlloc = size;
pBlob->aData = (char*)zData;
pBlob->iCursor = 0;
pBlob->xRealloc = blobReallocStatic;
}
}
/*
** Initialize a blob to a nul-terminated string.
** Any prior data in the blob is discarded.
| > | 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
if( zData==0 ){
*pBlob = empty_blob;
}else{
if( size<=0 ) size = strlen(zData);
pBlob->nUsed = pBlob->nAlloc = size;
pBlob->aData = (char*)zData;
pBlob->iCursor = 0;
pBlob->blobFlags = 0;
pBlob->xRealloc = blobReallocStatic;
}
}
/*
** Initialize a blob to a nul-terminated string.
** Any prior data in the blob is discarded.
|
| ︙ | ︙ | |||
241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
void blob_zero(Blob *pBlob){
static const char zEmpty[] = "";
assert_blob_is_reset(pBlob);
pBlob->nUsed = 0;
pBlob->nAlloc = 1;
pBlob->aData = (char*)zEmpty;
pBlob->iCursor = 0;
pBlob->xRealloc = blobReallocStatic;
}
/*
** Append text or data to the end of a blob.
*/
void blob_append(Blob *pBlob, const char *aData, int nData){
| > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
void blob_zero(Blob *pBlob){
static const char zEmpty[] = "";
assert_blob_is_reset(pBlob);
pBlob->nUsed = 0;
pBlob->nAlloc = 1;
pBlob->aData = (char*)zEmpty;
pBlob->iCursor = 0;
pBlob->blobFlags = 0;
pBlob->xRealloc = blobReallocStatic;
}
/*
** Append text or data to the end of a blob.
*/
void blob_append(Blob *pBlob, const char *aData, int nData){
|
| ︙ | ︙ | |||
285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
p->nUsed = 0;
}
if( p->aData[p->nUsed]!=0 ){
blob_materialize(p);
}
return p->aData;
}
/*
** Return a pointer to a null-terminated string for a blob.
**
** WARNING: If the blob is ephemeral, it might cause a '\000'
** character to be inserted into the middle of the parent blob.
** Example: Suppose p is a token extracted from some larger
| > > > > > > > > > > > > > > | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
p->nUsed = 0;
}
if( p->aData[p->nUsed]!=0 ){
blob_materialize(p);
}
return p->aData;
}
/*
** Return a pointer to a null-terminated string for a blob that has
** been created using blob_append_sql() and not blob_appendf(). If
** text was ever added using blob_appendf() then throw an error.
*/
char *blob_sql_text(Blob *p){
blob_is_init(p);
if( (p->blobFlags & BLOBFLAG_NotSQL) ){
fossil_fatal("Internal error: Use of blob_appendf() to construct SQL text");
}
return blob_str(p);
}
/*
** Return a pointer to a null-terminated string for a blob.
**
** WARNING: If the blob is ephemeral, it might cause a '\000'
** character to be inserted into the middle of the parent blob.
** Example: Suppose p is a token extracted from some larger
|
| ︙ | ︙ | |||
664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
int i;
for(i=0; i<nToken && blob_token(pIn, &aToken[i]); i++){}
return i;
}
/*
** Do printf-style string rendering and append the results to a blob.
*/
void blob_appendf(Blob *pBlob, const char *zFormat, ...){
if( pBlob ){
va_list ap;
va_start(ap, zFormat);
vxprintf(pBlob, zFormat, ap);
va_end(ap);
}
}
void blob_vappendf(Blob *pBlob, const char *zFormat, va_list ap){
| > > > > > > > > > > > > | 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 |
int i;
for(i=0; i<nToken && blob_token(pIn, &aToken[i]); i++){}
return i;
}
/*
** Do printf-style string rendering and append the results to a blob.
**
** The blob_appendf() version sets the BLOBFLAG_NotSQL bit in Blob.blobFlags
** whereas blob_append_sql() does not.
*/
void blob_appendf(Blob *pBlob, const char *zFormat, ...){
if( pBlob ){
va_list ap;
va_start(ap, zFormat);
vxprintf(pBlob, zFormat, ap);
va_end(ap);
pBlob->blobFlags |= BLOBFLAG_NotSQL;
}
}
void blob_append_sql(Blob *pBlob, const char *zFormat, ...){
if( pBlob ){
va_list ap;
va_start(ap, zFormat);
vxprintf(pBlob, zFormat, ap);
va_end(ap);
}
}
void blob_vappendf(Blob *pBlob, const char *zFormat, va_list ap){
|
| ︙ | ︙ |
Changes to src/branch.c.
| ︙ | ︙ | |||
250 251 252 253 254 255 256 |
** Options:
** -R|--repository FILE Run commands on repository FILE
*/
void branch_cmd(void){
int n;
const char *zCmd = "list";
db_find_and_open_repository(0, 0);
| < < < | 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
** Options:
** -R|--repository FILE Run commands on repository FILE
*/
void branch_cmd(void){
int n;
const char *zCmd = "list";
db_find_and_open_repository(0, 0);
if( g.argc>=3 ) zCmd = g.argv[2];
n = strlen(zCmd);
if( strncmp(zCmd,"new",n)==0 ){
branch_new();
}else if( (strncmp(zCmd,"list",n)==0)||(strncmp(zCmd, "ls", n)==0) ){
Stmt q;
int vid;
|
| ︙ | ︙ | |||
301 302 303 304 305 306 307 |
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if( colorTest ){
showClosed = 0;
showAll = 1;
}
| | | | 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if( colorTest ){
showClosed = 0;
showAll = 1;
}
style_header("%s", showClosed ? "Closed Branches" :
showAll ? "All Branches" : "Open Branches");
style_submenu_element("Timeline", "Timeline", "brtimeline");
if( showClosed ){
style_submenu_element("All", "All", "brlist?all");
style_submenu_element("Open","Open","brlist");
}else if( showAll ){
style_submenu_element("Closed", "Closed", "brlist?closed");
style_submenu_element("Open","Open","brlist");
|
| ︙ | ︙ |
Changes to src/browse.c.
| ︙ | ︙ | |||
493 494 495 496 497 498 499 |
zUuid);
}
}
if( linkTrunk ){
style_submenu_element("Trunk", "Trunk", "%s",
url_render(&sURI, "ci", "trunk", 0, 0));
}
| | | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
zUuid);
}
}
if( linkTrunk ){
style_submenu_element("Trunk", "Trunk", "%s",
url_render(&sURI, "ci", "trunk", 0, 0));
}
if( linkTip ){
style_submenu_element("Tip", "Tip", "%s",
url_render(&sURI, "ci", "tip", 0, 0));
}
if( !showDirOnly ){
style_submenu_element("Flat-View", "Flat-View", "%s",
url_render(&sURI, "type", "flat", 0, 0));
}
|
| ︙ | ︙ | |||
716 717 718 719 720 721 722 |
char *zClass;
const char *zExt = strrchr(zFilename, '.');
int isExt = zExt && zExt!=zFilename && zExt[1];
int i;
for( i=1; isExt && zExt[i]; i++ ) isExt &= fossil_isalnum(zExt[i]);
if( isExt ){
zClass = mprintf("file file-%s", zExt+1);
| | | | 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 |
char *zClass;
const char *zExt = strrchr(zFilename, '.');
int isExt = zExt && zExt!=zFilename && zExt[1];
int i;
for( i=1; isExt && zExt[i]; i++ ) isExt &= fossil_isalnum(zExt[i]);
if( isExt ){
zClass = mprintf("file file-%s", zExt+1);
for( i=5; zClass[i]; i++ ) zClass[i] = fossil_tolower(zClass[i]);
}else{
zClass = mprintf("file");
}
return zClass;
}
/*
** Look at all file containing in the version "vid". Construct a
** temporary table named "fileage" that contains the file-id for each
** files, the pathname, the check-in where the file was added, and the
** mtime on that checkin. If zGlob and *zGlob then only files matching
** the given glob are computed.
*/
int compute_fileage(int vid, const char* zGlob){
Manifest *pManifest;
ManifestFile *pFile;
int nFile = 0;
double vmtime;
Stmt ins;
Stmt q1, q2, q3;
Stmt upd;
|
| ︙ | ︙ | |||
757 758 759 760 761 762 763 |
if( pManifest==0 ) return 1;
manifest_file_rewind(pManifest);
db_prepare(&ins,
"INSERT INTO temp.fileage(fid, pathname)"
" SELECT rid, :path FROM blob WHERE uuid=:uuid"
);
while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
| | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 |
if( pManifest==0 ) return 1;
manifest_file_rewind(pManifest);
db_prepare(&ins,
"INSERT INTO temp.fileage(fid, pathname)"
" SELECT rid, :path FROM blob WHERE uuid=:uuid"
);
while( (pFile = manifest_file_next(pManifest, 0))!=0 ){
if( zGlob && sqlite3_strglob(zGlob, pFile->zName)!=0 ) continue;
db_bind_text(&ins, ":uuid", pFile->zUuid);
db_bind_text(&ins, ":path", pFile->zName);
db_step(&ins);
db_reset(&ins);
nFile++;
}
db_finalize(&ins);
|
| ︙ | ︙ | |||
813 814 815 816 817 818 819 |
** glob=STRING Only shows files matching this glob pattern
** (e.g. *.c or *.txt).
*/
void fileage_page(void){
int rid;
const char *zName;
char *zBaseTime;
| | | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 |
** glob=STRING Only shows files matching this glob pattern
** (e.g. *.c or *.txt).
*/
void fileage_page(void){
int rid;
const char *zName;
char *zBaseTime;
const char *zGlob;
Stmt q;
double baseTime;
int lastMid = -1;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
zName = P("name");
if( zName==0 ) zName = "tip";
rid = symbolic_name_to_rid(zName, "ci");
if( rid==0 ){
fossil_fatal("not a valid check-in: %s", zName);
}
style_submenu_element("Tree-View", "Tree-View", "%R/tree?ci=%T", zName);
style_header("File Ages");
zGlob = P("glob");
compute_fileage(rid,zGlob);
baseTime = db_double(0.0, "SELECT mtime FROM event WHERE objid=%d", rid);
zBaseTime = db_text("","SELECT datetime(%.20g%s)", baseTime, timeline_utc());
@ <h2>File Ages For Check-in
@ %z(href("%R/info?name=%T",zName))%h(zName)</a></h2>
@
|
| ︙ | ︙ |
Added src/builtin.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 |
/*
** Copyright (c) 2014 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This file contains built-in string and BLOB resources packaged as
** byte arrays.
*/
#include "config.h"
#include "builtin.h"
#include <assert.h>
/*
** The resources provided by this file are packaged by the "mkbuiltin.c"
** utility program during the built process and stored in the
** builtin_data.h file. Include that information here:
*/
#include "builtin_data.h"
/*
** Return a pointer to built-in content
*/
const unsigned char *builtin_file(const char *zFilename, int *piSize){
int lwr, upr, i;
lwr = 0;
upr = sizeof(aBuiltinFiles)/sizeof(aBuiltinFiles[0]) - 1;
while( upr>=lwr ){
i = (upr+lwr)/2;
if( strcmp(aBuiltinFiles[i].zName,zFilename)==0 ){
if( piSize ) *piSize = aBuiltinFiles[i].nByte;
return aBuiltinFiles[i].pData;
}
}
if( piSize ) *piSize = 0;
return 0;
}
/*
** COMMAND: test-builtin-list
**
** List the names and sizes of all built-in resources
*/
void test_builtin_list(void){
int i;
for(i=0; i<sizeof(aBuiltinFiles)/sizeof(aBuiltinFiles[0]); i++){
fossil_print("%-30s %6d\n", aBuiltinFiles[i].zName,aBuiltinFiles[i].nByte);
}
}
/*
** COMMAND: test-builtin-get
**
** Usage: %fossil test-builtin-get NAME ?OUTPUT-FILE?
*/
void test_builtin_get(void){
const unsigned char *pData;
int nByte;
Blob x;
if( g.argc!=3 && g.argc!=4 ){
usage("NAME ?OUTPUT-FILE?");
}
pData = builtin_file(g.argv[2], &nByte);
if( pData==0 ){
fossil_fatal("no such built-in file: [%s]", g.argv[2]);
}
blob_init(&x, (const char*)pData, nByte);
blob_write_to_file(&x, g.argc==4 ? g.argv[3] : "-");
blob_reset(&x);
}
|
Changes to src/cache.c.
| ︙ | ︙ | |||
59 60 61 62 63 64 65 |
}
rc = sqlite3_open(zDbName, &db);
fossil_free(zDbName);
if( rc ){
sqlite3_close(db);
return 0;
}
| | > | 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
}
rc = sqlite3_open(zDbName, &db);
fossil_free(zDbName);
if( rc ){
sqlite3_close(db);
return 0;
}
rc = sqlite3_exec(db,
"PRAGMA page_size=8192;"
"CREATE TABLE IF NOT EXISTS blob(id INTEGER PRIMARY KEY, data BLOB);"
"CREATE TABLE IF NOT EXISTS cache("
"key TEXT PRIMARY KEY," /* Key used to access the cache */
"id INT REFERENCES blob," /* The cache content */
"sz INT," /* Size of content in bytes */
"tm INT," /* Last access time (unix timestampe) */
"nref INT" /* Number of uses */
|
| ︙ | ︙ | |||
91 92 93 94 95 96 97 |
int rc;
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( rc ){
sqlite3_finalize(pStmt);
pStmt = 0;
}
| | | 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
int rc;
rc = sqlite3_prepare_v2(db, zSql, -1, &pStmt, 0);
if( rc ){
sqlite3_finalize(pStmt);
pStmt = 0;
}
return pStmt;
}
/*
** This routine implements an SQL function that renders a large integer
** compactly: ex: 12.3MB
*/
static void cache_sizename(
|
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0);
pStmt = cacheStmt(db, "INSERT INTO blob(data) VALUES(?1)");
if( pStmt==0 ) goto cache_write_end;
sqlite3_bind_blob(pStmt, 1, blob_buffer(pContent), blob_size(pContent),
SQLITE_STATIC);
if( sqlite3_step(pStmt)!=SQLITE_DONE ) goto cache_write_end;
sqlite3_finalize(pStmt);
| | | 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0);
pStmt = cacheStmt(db, "INSERT INTO blob(data) VALUES(?1)");
if( pStmt==0 ) goto cache_write_end;
sqlite3_bind_blob(pStmt, 1, blob_buffer(pContent), blob_size(pContent),
SQLITE_STATIC);
if( sqlite3_step(pStmt)!=SQLITE_DONE ) goto cache_write_end;
sqlite3_finalize(pStmt);
pStmt = cacheStmt(db,
"INSERT OR IGNORE INTO cache(key,sz,tm,nref,id)"
"VALUES(?1,?2,strftime('%s','now'),1,?3)"
);
if( pStmt==0 ) goto cache_write_end;
sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
sqlite3_bind_int(pStmt, 2, blob_size(pContent));
sqlite3_bind_int(pStmt, 3, sqlite3_last_insert_rowid(db));
|
| ︙ | ︙ | |||
199 200 201 202 203 204 205 | sqlite3_stmt *pStmt; int rc = 0; db = cacheOpen(0); if( db==0 ) return 0; sqlite3_busy_timeout(db, 10000); sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0); | | | | | | | | 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 259 260 261 262 263 264 265 266 267 268 |
sqlite3_stmt *pStmt;
int rc = 0;
db = cacheOpen(0);
if( db==0 ) return 0;
sqlite3_busy_timeout(db, 10000);
sqlite3_exec(db, "BEGIN IMMEDIATE", 0, 0, 0);
pStmt = cacheStmt(db,
"SELECT blob.data FROM cache, blob"
" WHERE cache.key=?1 AND cache.id=blob.id");
if( pStmt==0 ) goto cache_read_done;
sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
if( sqlite3_step(pStmt)==SQLITE_ROW ){
blob_append(pContent, sqlite3_column_blob(pStmt, 0),
sqlite3_column_bytes(pStmt, 0));
rc = 1;
sqlite3_reset(pStmt);
pStmt = cacheStmt(db,
"UPDATE cache SET nref=nref+1, tm=strftime('%s','now')"
" WHERE key=?1");
if( pStmt ){
sqlite3_bind_text(pStmt, 1, zKey, -1, SQLITE_STATIC);
sqlite3_step(pStmt);
}
}
sqlite3_finalize(pStmt);
cache_read_done:
sqlite3_exec(db, "COMMIT", 0, 0, 0);
sqlite3_close(db);
return rc;
}
/*
** COMMAND: cache*
** Usage: %fossil cache SUBCOMMAND
**
** Manage the cache used for potentially expensive web pages such as
** /zip and /tarball. SUBCOMMAND an be:
**
** clear Remove all entries from the cache.
**
** init Create the cache file if it does not already exists.
**
** list|ls List the keys and content sizes and other stats for
** all entries currently in the cache
**
** status Show a summary of cache status.
**
** The cache is stored in a file that is distinct from the repository
** but that is held in the same directory as the repository. To cache
** file can be deleted in order to completely disable the cache.
*/
void cache_cmd(void){
const char *zCmd;
int nCmd;
sqlite3 *db;
sqlite3_stmt *pStmt;
db_find_and_open_repository(0,0);
zCmd = g.argc>=3 ? g.argv[2] : "";
nCmd = (int)strlen(zCmd);
if( nCmd<=1 ){
fossil_fatal("Usage: %s cache SUBCOMMAND", g.argv[0]);
}
if( strncmp(zCmd, "init", nCmd)==0 ){
db = cacheOpen(0);
sqlite3_close(db);
if( db ){
fossil_print("cache already exists in file %z\n", cacheName());
|
| ︙ | ︙ | |||
279 280 281 282 283 284 285 |
if( db ){
sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
sqlite3_close(db);
fossil_print("cache cleared\n");
}else{
fossil_print("nothing to clear; cache does not exist\n");
}
| | | | 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
if( db ){
sqlite3_exec(db, "DELETE FROM cache; DELETE FROM blob; VACUUM;",0,0,0);
sqlite3_close(db);
fossil_print("cache cleared\n");
}else{
fossil_print("nothing to clear; cache does not exist\n");
}
}else if(( strncmp(zCmd, "list", nCmd)==0 ) || ( strncmp(zCmd, "ls", nCmd)==0 )){
db = cacheOpen(0);
if( db==0 ){
fossil_print("cache does not exist\n");
}else{
int nEntry = 0;
char *zDbName = cacheName();
cache_register_sizename(db);
pStmt = cacheStmt(db,
"SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
" FROM cache"
" ORDER BY tm DESC"
);
if( pStmt ){
while( sqlite3_step(pStmt)==SQLITE_ROW ){
fossil_print("%s %4d %8s %s\n",
|
| ︙ | ︙ | |||
335 336 337 338 339 340 341 |
style_header("Web Cache Status");
db = cacheOpen(0);
if( db==0 ){
@ The web-page cache is disabled for this repository
}else{
char *zDbName = cacheName();
cache_register_sizename(db);
| | | > > > > > > > > > > > > > > > > > > > > > > > > > > > | 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
style_header("Web Cache Status");
db = cacheOpen(0);
if( db==0 ){
@ The web-page cache is disabled for this repository
}else{
char *zDbName = cacheName();
cache_register_sizename(db);
pStmt = cacheStmt(db,
"SELECT key, sizename(sz), nRef, datetime(tm,'unixepoch')"
" FROM cache"
" ORDER BY tm DESC"
);
if( pStmt ){
@ <ol>
while( sqlite3_step(pStmt)==SQLITE_ROW ){
const unsigned char *zName = sqlite3_column_text(pStmt,0);
@ <li><p>%z(href("%R/cacheget?key=%T",zName))%h(zName)</a><br>
@ size: %s(sqlite3_column_text(pStmt,1))
@ hit-count: %d(sqlite3_column_int(pStmt,2))
@ last-access: %s(sqlite3_column_text(pStmt,3))</p></li>
}
sqlite3_finalize(pStmt);
@ </ol>
}
zDbName = cacheName();
bigSizeName(sizeof(zBuf), zBuf, file_size(zDbName));
@ <p>cache-file name: %h(zDbName)</p>
@ <p>cache-file size: %s(zBuf)</p>
fossil_free(zDbName);
sqlite3_close(db);
}
style_footer();
}
/*
** WEBPAGE: cacheget
**
** Usage: /cacheget?key=KEY
**
** Download a single entry for the cache, identified by KEY.
** This page is normally a hyperlink from the /cachestat page.
*/
void cache_getpage(void){
const char *zKey;
Blob content;
login_check_credentials();
if( !g.perm.Setup ){ login_needed(); return; }
zKey = PD("key","");
blob_zero(&content);
if( cache_read(&content, zKey)==0 ){
style_header("Cache Download Error");
@ The cache does not contain any entry with this key: "%h(zKey)"
style_footer();
return;
}
cgi_set_content(&content);
cgi_set_content_type("application/x-compressed");
}
|
Changes to src/captcha.c.
| ︙ | ︙ | |||
446 447 448 449 450 451 452 | } /* ** Translate a captcha seed value into the captcha password string. ** The returned string is static and overwritten on each call to ** this function. */ | | | 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
}
/*
** Translate a captcha seed value into the captcha password string.
** The returned string is static and overwritten on each call to
** this function.
*/
const char *captcha_decode(unsigned int seed){
const char *zSecret;
const char *z;
Blob b;
static char zRes[20];
zSecret = db_get("captcha-secret", 0);
if( zSecret==0 ){
|
| ︙ | ︙ | |||
515 516 517 518 519 520 521 |
if( strlen(zEntered)!=8 ) return 0;
for(i=0; i<8; i++){
char c = zEntered[i];
if( c>='A' && c<='F' ) c += 'a' - 'A';
if( c=='O' ) c = '0';
z[i] = c;
}
| | | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 |
if( strlen(zEntered)!=8 ) return 0;
for(i=0; i<8; i++){
char c = zEntered[i];
if( c>='A' && c<='F' ) c += 'a' - 'A';
if( c=='O' ) c = '0';
z[i] = c;
}
if( strncmp(zDecode,z,8)!=0 ) return 0;
return 1;
}
/*
** Generate a captcha display together with the necessary hidden parameter
** for the seed and the entry box into which the user will type the text of
** the captcha. This is typically done at the very bottom of a form.
|
| ︙ | ︙ |
Changes to src/cgi.c.
| ︙ | ︙ | |||
276 277 278 279 280 281 282 |
/*
** Return true if the response should be sent with Content-Encoding: gzip.
*/
static int is_gzippable(void){
if( strstr(PD("HTTP_ACCEPT_ENCODING", ""), "gzip")==0 ) return 0;
return strncmp(zContentType, "text/", 5)==0
| | | | 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
/*
** Return true if the response should be sent with Content-Encoding: gzip.
*/
static int is_gzippable(void){
if( strstr(PD("HTTP_ACCEPT_ENCODING", ""), "gzip")==0 ) return 0;
return strncmp(zContentType, "text/", 5)==0
|| sqlite3_strglob("application/*xml", zContentType)==0
|| sqlite3_strglob("application/*javascript", zContentType)==0;
}
/*
** Do a normal HTTP reply
*/
void cgi_reply(void){
int total_size;
|
| ︙ | ︙ | |||
305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
}
#endif
if( g.fullHttpReply ){
fprintf(g.httpOut, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus);
fprintf(g.httpOut, "Date: %s\r\n", cgi_rfc822_datestamp(time(0)));
fprintf(g.httpOut, "Connection: close\r\n");
}else{
fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus);
}
if( blob_size(&extraHeader)>0 ){
fprintf(g.httpOut, "%s", blob_buffer(&extraHeader));
}
| > | 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
}
#endif
if( g.fullHttpReply ){
fprintf(g.httpOut, "HTTP/1.0 %d %s\r\n", iReplyStatus, zReplyStatus);
fprintf(g.httpOut, "Date: %s\r\n", cgi_rfc822_datestamp(time(0)));
fprintf(g.httpOut, "Connection: close\r\n");
fprintf(g.httpOut, "X-UA-Compatible: IE=edge\r\n");
}else{
fprintf(g.httpOut, "Status: %d %s\r\n", iReplyStatus, zReplyStatus);
}
if( blob_size(&extraHeader)>0 ){
fprintf(g.httpOut, "%s", blob_buffer(&extraHeader));
}
|
| ︙ | ︙ | |||
749 750 751 752 753 754 755 |
unsigned int * n ){
if( ! state || !dest || !n ) return cson_rc.ArgError;
else {
CgiPostReadState * st = (CgiPostReadState *)state;
if( st->pos >= st->len ){
*n = 0;
return 0;
| | | 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 |
unsigned int * n ){
if( ! state || !dest || !n ) return cson_rc.ArgError;
else {
CgiPostReadState * st = (CgiPostReadState *)state;
if( st->pos >= st->len ){
*n = 0;
return 0;
}else if( !*n || ((st->pos + *n) > st->len) ){
return cson_rc.RangeError;
}else{
unsigned int rsz = (unsigned int)fread( dest, 1, *n, st->fh );
if( ! rsz ){
*n = rsz;
return feof(st->fh) ? 0 : cson_rc.IOError;
}else{
|
| ︙ | ︙ | |||
1573 1574 1575 1576 1577 1578 1579 |
malformed_request("incorrect transport_flip");
}
cgi_trace(zLine);
zToken = extract_token(zLine, &z);
if( zToken && strlen(zToken)==0 ){
/* look for path to fossil */
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
| | | 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 |
malformed_request("incorrect transport_flip");
}
cgi_trace(zLine);
zToken = extract_token(zLine, &z);
if( zToken && strlen(zToken)==0 ){
/* look for path to fossil */
if( fgets(zLine, sizeof(zLine),g.httpIn)==0 ){
if( zCmd==0 ){
malformed_request("missing fossil command");
}else{
/* no new command so exit */
fossil_exit(0);
}
}
cgi_trace(zLine);
|
| ︙ | ︙ | |||
1611 1612 1613 1614 1615 1616 1617 |
** and subsequent code handles the actual generation of the webpage.
*/
void cgi_handle_scgi_request(void){
char *zHdr;
char *zToFree;
int nHdr = 0;
int nRead;
| | < | | | 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 |
** and subsequent code handles the actual generation of the webpage.
*/
void cgi_handle_scgi_request(void){
char *zHdr;
char *zToFree;
int nHdr = 0;
int nRead;
int c, n, m;
while( (c = fgetc(g.httpIn))!=EOF && fossil_isdigit((char)c) ){
nHdr = nHdr*10 + (char)c - '0';
}
if( nHdr<16 ) malformed_request("SCGI header too short");
zToFree = zHdr = fossil_malloc(nHdr);
nRead = (int)fread(zHdr, 1, nHdr, g.httpIn);
if( nRead<nHdr ) malformed_request("cannot read entire SCGI header");
nHdr = nRead;
while( nHdr ){
|
| ︙ | ︙ | |||
1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 | #if INTERFACE /* ** Bitmap values for the flags parameter to cgi_http_server(). */ #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ #endif /* INTERFACE */ /* ** Maximum number of child processes that we can have running ** at one time before we start slowing things down. */ | > > | 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 | #if INTERFACE /* ** Bitmap values for the flags parameter to cgi_http_server(). */ #define HTTP_SERVER_LOCALHOST 0x0001 /* Bind to 127.0.0.1 only */ #define HTTP_SERVER_SCGI 0x0002 /* SCGI instead of HTTP */ #define HTTP_SERVER_HAD_REPOSITORY 0x0004 /* Was the repository open? */ #define HTTP_SERVER_HAD_CHECKOUT 0x0008 /* Was a checkout open? */ #endif /* INTERFACE */ /* ** Maximum number of child processes that we can have running ** at one time before we start slowing things down. */ |
| ︙ | ︙ | |||
1820 1821 1822 1823 1824 1825 1826 |
}
if( iPort>mxPort ) return 1;
listen(listener,10);
fossil_print("Listening for %s requests on TCP port %d\n",
(flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
fflush(stdout);
if( zBrowser ){
| > | | | 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 |
}
if( iPort>mxPort ) return 1;
listen(listener,10);
fossil_print("Listening for %s requests on TCP port %d\n",
(flags & HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
fflush(stdout);
if( zBrowser ){
assert( strstr(zBrowser,"%d")!=0 );
zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort);
#if defined(__CYGWIN__)
/* On Cygwin, we can do better than "echo" */
if( strncmp(zBrowser, "echo ", 5)==0 ){
wchar_t *wUrl = fossil_utf8_to_unicode(zBrowser+5);
wUrl[wcslen(wUrl)-2] = 0; /* Strip terminating " &" */
if( (size_t)ShellExecuteW(0, L"open", wUrl, 0, 0, 1)<33 ){
fossil_warning("cannot start browser\n");
}
}else
#endif
|
| ︙ | ︙ |
Changes to src/checkin.c.
| ︙ | ︙ | |||
50 51 52 53 54 55 56 |
Blob fname;
file_tree_name(g.argv[i], &fname, 1);
zName = blob_str(&fname);
if( fossil_strcmp(zName, ".")==0 ) {
blob_reset(&where);
break;
}
| > | | | | | > | | 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 |
Blob fname;
file_tree_name(g.argv[i], &fname, 1);
zName = blob_str(&fname);
if( fossil_strcmp(zName, ".")==0 ) {
blob_reset(&where);
break;
}
blob_append_sql(&where,
" %s (pathname=%Q %s) "
"OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
(blob_size(&where)>0) ? "OR" : "AND", zName,
filename_collation(), zName, filename_collation(),
zName, filename_collation()
);
}
db_prepare(&q,
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
" FROM vfile "
" WHERE is_selected(id) %s"
" AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1",
blob_sql_text(&where)
);
blob_zero(&rewrittenPathname);
while( db_step(&q)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q,0);
const char *zDisplayName = zPathname;
int isDeleted = db_column_int(&q, 1);
int isChnged = db_column_int(&q,2);
|
| ︙ | ︙ | |||
99 100 101 102 103 104 105 |
if( missingIsFatal ){
fossil_warning("missing file: %s", zDisplayName);
nErr++;
}
}
}else if( isNew ){
blob_appendf(report, "ADDED %s\n", zDisplayName);
| < < | 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
if( missingIsFatal ){
fossil_warning("missing file: %s", zDisplayName);
nErr++;
}
}
}else if( isNew ){
blob_appendf(report, "ADDED %s\n", zDisplayName);
}else if( isChnged ){
if( isChnged==2 ){
blob_appendf(report, "UPDATED_BY_MERGE %s\n", zDisplayName);
}else if( isChnged==3 ){
blob_appendf(report, "ADDED_BY_MERGE %s\n", zDisplayName);
}else if( isChnged==4 ){
blob_appendf(report, "UPDATED_BY_INTEGRATE %s\n", zDisplayName);
|
| ︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
int relativePaths = db_get_boolean("relative-paths", 1);
int absPathOption = find_option("abs-paths", 0, 0)!=0;
int relPathOption = find_option("rel-paths", 0, 0)!=0;
if( absPathOption ){ relativePaths = 0; }
if( relPathOption ){ relativePaths = 1; }
return relativePaths;
}
/*
** COMMAND: changes
**
** Usage: %fossil changes ?OPTIONS?
**
** Report on the edit status of all files in the current checkout.
| > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
int relativePaths = db_get_boolean("relative-paths", 1);
int absPathOption = find_option("abs-paths", 0, 0)!=0;
int relPathOption = find_option("rel-paths", 0, 0)!=0;
if( absPathOption ){ relativePaths = 0; }
if( relPathOption ){ relativePaths = 1; }
return relativePaths;
}
void print_changes(
int useSha1sum, /* Verify file status using SHA1 hashing rather
than relying on file mtimes. */
int showHdr, /* Identify the repository if there are changes */
int verboseFlag, /* Say "(none)" if there are no changes */
int cwdRelative /* Report relative to the current working dir */
){
Blob report;
int vid;
blob_zero(&report);
vid = db_lget_int("checkout", 0);
vfile_check_signature(vid, useSha1sum ? CKSIG_SHA1 : 0);
status_report(&report, "", 0, cwdRelative);
if( verboseFlag && blob_size(&report)==0 ){
blob_append(&report, " (none)\n", -1);
}
if( showHdr && blob_size(&report)>0 ){
fossil_print("Changes for %s at %s:\n", db_get("project-name","???"),
g.zLocalRoot);
}
blob_write_to_file(&report, "-");
blob_reset(&report);
}
/*
** COMMAND: changes
**
** Usage: %fossil changes ?OPTIONS?
**
** Report on the edit status of all files in the current checkout.
|
| ︙ | ︙ | |||
180 181 182 183 184 185 186 |
** than relying on file mtimes.
** --header Identify the repository if there are changes
** -v|--verbose Say "(none)" if there are no changes
**
** See also: extras, ls, status
*/
void changes_cmd(void){
| < < < < < < < < | | < | | < < > | 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 |
** than relying on file mtimes.
** --header Identify the repository if there are changes
** -v|--verbose Say "(none)" if there are no changes
**
** See also: extras, ls, status
*/
void changes_cmd(void){
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
int showHdr = find_option("header",0,0)!=0;
int verboseFlag = find_option("verbose","v",0)!=0;
int cwdRelative = 0;
db_must_be_within_tree();
cwdRelative = determine_cwd_relative_option();
/* We should be done with options.. */
verify_all_options();
print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);
}
/*
** COMMAND: status
**
** Usage: %fossil status ?OPTIONS?
**
|
| ︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
** --sha1sum Verify file status using SHA1 hashing rather
** than relying on file mtimes.
**
** See also: changes, extras, ls
*/
void status_cmd(void){
int vid;
db_must_be_within_tree();
/* 012345678901234 */
fossil_print("repository: %s\n", db_repository_filename());
fossil_print("local-root: %s\n", g.zLocalRoot);
if( g.zConfigDbName ){
fossil_print("config-db: %s\n", g.zConfigDbName);
}
vid = db_lget_int("checkout", 0);
if( vid ){
show_common_info(vid, "checkout:", 1, 1);
}
| > > > > > > > > > | | | 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
** --sha1sum Verify file status using SHA1 hashing rather
** than relying on file mtimes.
**
** See also: changes, extras, ls
*/
void status_cmd(void){
int vid;
int useSha1sum = find_option("sha1sum", 0, 0)!=0;
int showHdr = find_option("header",0,0)!=0;
int verboseFlag = find_option("verbose","v",0)!=0;
int cwdRelative = 0;
db_must_be_within_tree();
/* 012345678901234 */
cwdRelative = determine_cwd_relative_option();
/* We should be done with options.. */
verify_all_options();
fossil_print("repository: %s\n", db_repository_filename());
fossil_print("local-root: %s\n", g.zLocalRoot);
if( g.zConfigDbName ){
fossil_print("config-db: %s\n", g.zConfigDbName);
}
vid = db_lget_int("checkout", 0);
if( vid ){
show_common_info(vid, "checkout:", 1, 1);
}
db_record_repository_filename(0);
print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);
}
/*
** COMMAND: ls
**
** Usage: %fossil ls ?OPTIONS? ?VERSION? ?FILENAMES?
**
|
| ︙ | ︙ | |||
289 290 291 292 293 294 295 |
Blob fname;
file_tree_name(g.argv[i], &fname, 1);
zName = blob_str(&fname);
if( fossil_strcmp(zName, ".")==0 ) {
blob_reset(&where);
break;
}
| > | | | | | > | > | | 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
Blob fname;
file_tree_name(g.argv[i], &fname, 1);
zName = blob_str(&fname);
if( fossil_strcmp(zName, ".")==0 ) {
blob_reset(&where);
break;
}
blob_append_sql(&where,
" %s (pathname=%Q %s) "
"OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
(blob_size(&where)>0) ? "OR" : "WHERE", zName,
filename_collation(), zName, filename_collation(),
zName, filename_collation()
);
}
vfile_check_signature(vid, 0);
if( showAge ){
db_prepare(&q,
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0),"
" datetime(checkin_mtime(%d,rid),'unixepoch'%s)"
" FROM vfile %s"
" ORDER BY %s",
vid, timeline_utc(), blob_sql_text(&where), zOrderBy /*safe-for-%s*/
);
}else{
db_prepare(&q,
"SELECT pathname, deleted, rid, chnged, coalesce(origname!=pathname,0)"
" FROM vfile %s"
" ORDER BY %s", blob_sql_text(&where), zOrderBy /*safe-for-%s*/
);
}
blob_reset(&where);
while( db_step(&q)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q,0);
int isDeleted = db_column_int(&q, 1);
int isNew = db_column_int(&q,2)==0;
|
| ︙ | ︙ | |||
449 450 451 452 453 454 455 |
int showHdr = find_option("header",0,0)!=0;
int cwdRelative = 0;
Glob *pIgnore;
Blob rewrittenPathname;
const char *zPathname, *zDisplayName;
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
| < > > > > | 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
int showHdr = find_option("header",0,0)!=0;
int cwdRelative = 0;
Glob *pIgnore;
Blob rewrittenPathname;
const char *zPathname, *zDisplayName;
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
db_must_be_within_tree();
cwdRelative = determine_cwd_relative_option();
/* We should be done with options.. */
verify_all_options();
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
pIgnore = glob_create(zIgnoreFlag);
locate_unmanaged_files(g.argc-2, g.argv+2, scanFlags, pIgnore, 0);
glob_free(pIgnore);
db_prepare(&q,
|
| ︙ | ︙ | |||
568 569 570 571 572 573 574 |
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
if( find_option("allckouts",0,0)!=0 ) scanFlags |= SCAN_NESTED;
zIgnoreFlag = find_option("ignore",0,1);
verboseFlag = find_option("verbose","v",0)!=0;
zKeepFlag = find_option("keep",0,1);
zCleanFlag = find_option("clean",0,1);
| < | 598 599 600 601 602 603 604 605 606 607 608 609 610 611 |
if( find_option("dotfiles",0,0)!=0 ) scanFlags |= SCAN_ALL;
if( find_option("temp",0,0)!=0 ) scanFlags |= SCAN_TEMP;
if( find_option("allckouts",0,0)!=0 ) scanFlags |= SCAN_NESTED;
zIgnoreFlag = find_option("ignore",0,1);
verboseFlag = find_option("verbose","v",0)!=0;
zKeepFlag = find_option("keep",0,1);
zCleanFlag = find_option("clean",0,1);
db_must_be_within_tree();
if( zIgnoreFlag==0 ){
zIgnoreFlag = db_get("ignore-glob", 0);
}
if( zKeepFlag==0 ){
zKeepFlag = db_get("keep-glob", 0);
}
|
| ︙ | ︙ | |||
825 826 827 828 829 830 831 |
"#\n", -1
);
blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : login_name());
if( p->zBranch && p->zBranch[0] ){
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
}else{
char *zTags = info_tags_of_checkin(parent_rid, 1);
| > > > > > > > > > > > > | > | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 |
"#\n", -1
);
blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : login_name());
if( p->zBranch && p->zBranch[0] ){
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
}else{
char *zTags = info_tags_of_checkin(parent_rid, 1);
if( zTags || p->azTag ){
blob_append(&prompt, "# tags: ", 8);
if(zTags){
blob_appendf(&prompt, "%z%s", zTags, p->azTag ? ", " : "");
}
if(p->azTag){
int i = 0;
for( ; p->azTag[i]; ++i ){
blob_appendf(&prompt, "%s%s", p->azTag[i],
p->azTag[i+1] ? ", " : "");
}
}
blob_appendf(&prompt, "\n#\n");
}
}
status_report(&prompt, "# ", 1, 0);
if( g.markPrivate ){
blob_append(&prompt,
"# PRIVATE BRANCH: This check-in will be private and will not sync to\n"
"# repositories.\n"
"#\n", -1
|
| ︙ | ︙ | |||
869 870 871 872 873 874 875 |
int select_commit_files(void){
int result = 0;
assert( g.aCommitFile==0 );
if( g.argc>2 ){
int ii, jj=0;
Blob fname;
Stmt q;
| < < | | | 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 |
int select_commit_files(void){
int result = 0;
assert( g.aCommitFile==0 );
if( g.argc>2 ){
int ii, jj=0;
Blob fname;
Stmt q;
Bag toCommit;
blob_zero(&fname);
bag_init(&toCommit);
for(ii=2; ii<g.argc; ii++){
int cnt = 0;
file_tree_name(g.argv[ii], &fname, 1);
if( fossil_strcmp(blob_str(&fname),".")==0 ){
bag_clear(&toCommit);
return result;
}
db_prepare(&q,
"SELECT id FROM vfile WHERE pathname=%Q %s"
" OR (pathname>'%q/' %s AND pathname<'%q0' %s)",
blob_str(&fname), filename_collation(), blob_str(&fname),
filename_collation(), blob_str(&fname), filename_collation());
while( db_step(&q)==SQLITE_ROW ){
cnt++;
bag_insert(&toCommit, db_column_int(&q, 0));
}
db_finalize(&q);
if( cnt==0 ){
fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
|
| ︙ | ︙ | |||
1391 1392 1393 1394 1395 1396 1397 | ** The --branch option followed by a branch name causes the new ** check-in to be placed in a newly-created branch with the name ** passed to the --branch option. ** ** Use the --branchcolor option followed by a color name (ex: ** '#ffc0c0') to specify the background color of entries in the new ** branch when shown in the web timeline interface. The use of | | | 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | ** The --branch option followed by a branch name causes the new ** check-in to be placed in a newly-created branch with the name ** passed to the --branch option. ** ** Use the --branchcolor option followed by a color name (ex: ** '#ffc0c0') to specify the background color of entries in the new ** branch when shown in the web timeline interface. The use of ** the --branchcolor option is not recommended. Instead, let Fossil ** choose the branch color automatically. ** ** The --bgcolor option works like --branchcolor but only sets the ** background color for a single check-in. Subsequent check-ins revert ** to the default color. ** ** A check-in is not permitted to fork unless the --allow-fork option |
| ︙ | ︙ |
Changes to src/checkout.c.
| ︙ | ︙ | |||
58 59 60 61 62 63 64 |
*/
int load_vfile(const char *zName, int forceMissingFlag){
Blob uuid;
int vid;
blob_init(&uuid, zName, -1);
if( name_to_uuid(&uuid, 1, "ci") ){
| | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
*/
int load_vfile(const char *zName, int forceMissingFlag){
Blob uuid;
int vid;
blob_init(&uuid, zName, -1);
if( name_to_uuid(&uuid, 1, "ci") ){
fossil_fatal("%s", g.zErrMsg);
}
vid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid);
if( vid==0 ){
fossil_fatal("no such check-in: %s", g.argv[2]);
}
if( !is_a_version(vid) ){
fossil_fatal("object [%S] is not a check-in", blob_str(&uuid));
|
| ︙ | ︙ | |||
135 136 137 138 139 140 141 |
Blob manifest;
Blob hash;
if( db_get_boolean("manifest",0) ){
blob_zero(&manifest);
content_get(vid, &manifest);
zManFile = mprintf("%smanifest", g.zLocalRoot);
| < < > > > | 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 |
Blob manifest;
Blob hash;
if( db_get_boolean("manifest",0) ){
blob_zero(&manifest);
content_get(vid, &manifest);
zManFile = mprintf("%smanifest", g.zLocalRoot);
blob_zero(&hash);
sha1sum_blob(&manifest, &hash);
sterilize_manifest(&manifest);
blob_write_to_file(&manifest, zManFile);
free(zManFile);
zManFile = mprintf("%smanifest.uuid", g.zLocalRoot);
blob_append(&hash, "\n", 1);
blob_write_to_file(&hash, zManFile);
free(zManFile);
blob_reset(&hash);
}else{
if( !db_exists("SELECT 1 FROM vfile WHERE pathname='manifest'") ){
|
| ︙ | ︙ | |||
199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
db_must_be_within_tree();
db_begin_transaction();
forceFlag = find_option("force","f",0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
keepFlag = find_option("keep",0,0)!=0;
latestFlag = find_option("latest",0,0)!=0;
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
usage("VERSION|--latest ?--force? ?--keep?");
}
if( !forceFlag && unsaved_changes(0) ){
fossil_fatal("there are unsaved changes in the current checkout");
}
if( forceFlag ){
| > > > > | 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
db_must_be_within_tree();
db_begin_transaction();
forceFlag = find_option("force","f",0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
keepFlag = find_option("keep",0,0)!=0;
latestFlag = find_option("latest",0,0)!=0;
promptFlag = find_option("prompt",0,0)!=0 || forceFlag==0;
/* We should be done with options.. */
verify_all_options();
if( (latestFlag!=0 && g.argc!=2) || (latestFlag==0 && g.argc!=3) ){
usage("VERSION|--latest ?--force? ?--keep?");
}
if( !forceFlag && unsaved_changes(0) ){
fossil_fatal("there are unsaved changes in the current checkout");
}
if( forceFlag ){
|
| ︙ | ︙ | |||
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
** --force|-f necessary to close a check out with uncommitted changes
**
** See also: open
*/
void close_cmd(void){
int forceFlag = find_option("force","f",0)!=0;
db_must_be_within_tree();
if( !forceFlag && unsaved_changes(0) ){
fossil_fatal("there are unsaved changes in the current checkout");
}
if( !forceFlag
&& db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
db_name("localdb"))
&& db_exists("SELECT 1 FROM %s.stash", db_name("localdb"))
){
fossil_fatal("closing the checkout will delete your stash");
}
if( db_is_writeable("repository") ){
| > > > > | | 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 |
** --force|-f necessary to close a check out with uncommitted changes
**
** See also: open
*/
void close_cmd(void){
int forceFlag = find_option("force","f",0)!=0;
db_must_be_within_tree();
/* We should be done with options.. */
verify_all_options();
if( !forceFlag && unsaved_changes(0) ){
fossil_fatal("there are unsaved changes in the current checkout");
}
if( !forceFlag
&& db_exists("SELECT 1 FROM %s.sqlite_master WHERE name='stash'",
db_name("localdb"))
&& db_exists("SELECT 1 FROM %s.stash", db_name("localdb"))
){
fossil_fatal("closing the checkout will delete your stash");
}
if( db_is_writeable("repository") ){
char *zUnset = mprintf("ckout:%q", g.zLocalRoot);
db_unset(zUnset, 1);
fossil_free(zUnset);
}
unlink_local_database(1);
db_close(1);
unlink_local_database(0);
}
|
Changes to src/clone.c.
| ︙ | ︙ | |||
125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
zHttpAuth = find_option("httpauth","B",1);
zDefaultUser = find_option("admin-user","A",1);
clone_ssh_find_options();
url_proxy_options();
if( g.argc < 4 ){
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
}
db_open_config(0);
if( file_size(g.argv[3])>0 ){
fossil_fatal("file already exists: %s", g.argv[3]);
}
| > > > > | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 |
if( find_option("private",0,0)!=0 ) bPrivate = SYNC_PRIVATE;
if( find_option("once",0,0)!=0) urlFlags &= ~URL_REMEMBER;
zHttpAuth = find_option("httpauth","B",1);
zDefaultUser = find_option("admin-user","A",1);
clone_ssh_find_options();
url_proxy_options();
/* We should be done with options.. */
verify_all_options();
if( g.argc < 4 ){
usage("?OPTIONS? FILE-OR-URL NEW-REPOSITORY");
}
db_open_config(0);
if( file_size(g.argv[3])>0 ){
fossil_fatal("file already exists: %s", g.argv[3]);
}
|
| ︙ | ︙ | |||
233 234 235 236 237 238 239 |
}
/*
** Get the HTTP Authorization preference from db.
*/
char *get_httpauth(void){
char *zKey = mprintf("http-auth:%s", g.url.canonical);
| | > | 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
}
/*
** Get the HTTP Authorization preference from db.
*/
char *get_httpauth(void){
char *zKey = mprintf("http-auth:%s", g.url.canonical);
char * rc = unobscure(db_get(zKey, 0));
free(zKey);
return rc;
}
/*
** Set the HTTP Authorization preference in db.
*/
void set_httpauth(const char *zHttpAuth){
char *zKey = mprintf("http-auth:%s", g.url.canonical);
|
| ︙ | ︙ |
Added src/codecheck1.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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
/*
** Copyright (c) 2014 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
**
** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This program reads Fossil source code files and tries to verify that
** printf-style format strings are correct.
**
** This program implements a compile-time validation step on the Fossil
** source code. Running this program is entirely optional. Its role is
** similar to the -Wall compiler switch on gcc, or the scan-build utility
** of clang, or other static analyzers. The purpose is to try to identify
** problems in the source code at compile-time. The difference is that this
** static checker is specifically designed for the particular printf formatter
** implementation used by Fossil.
**
** Checks include:
**
** * Verify that vararg formatting routines like blob_printf() or
** db_multi_exec() have the correct number of arguments for their
** format string.
**
** * For routines designed to generate SQL, warn about the use of %s
** which might allow SQL injection.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <assert.h>
/*
** Malloc, aborting if it fails.
*/
void *safe_malloc(int nByte){
void *x = malloc(nByte);
if( x==0 ){
fprintf(stderr, "failed to allocate %d bytes\n", nByte);
exit(1);
}
return x;
}
void *safe_realloc(void *pOld, int nByte){
void *x = realloc(pOld, nByte);
if( x==0 ){
fprintf(stderr, "failed to allocate %d bytes\n", nByte);
exit(1);
}
return x;
}
/*
** Read the entire content of the file named zFilename into memory obtained
** from malloc(). Add a zero-terminator to the end.
** Return a pointer to that memory.
*/
static char *read_file(const char *zFilename){
FILE *in;
char *z;
int nByte;
int got;
in = fopen(zFilename, "rb");
if( in==0 ){
return 0;
}
fseek(in, 0, SEEK_END);
nByte = ftell(in);
fseek(in, 0, SEEK_SET);
z = safe_malloc( nByte+1 );
got = fread(z, 1, nByte, in);
z[got] = 0;
fclose(in);
return z;
}
/*
** When parsing the input file, the following token types are recognized.
*/
#define TK_SPACE 1 /* Whitespace or comments */
#define TK_ID 2 /* An identifier */
#define TK_STR 3 /* A string literal in double-quotes */
#define TK_OTHER 4 /* Any other token */
#define TK_EOF 99 /* End of file */
/*
** Determine the length and type of the token beginning at z[0]
*/
static int token_length(const char *z, int *pType, int *pLN){
int i;
if( z[0]==0 ){
*pType = TK_EOF;
return 0;
}
if( z[0]=='"' || z[0]=='\'' ){
for(i=1; z[i] && z[i]!=z[0]; i++){
if( z[i]=='\\' && z[i+1]!=0 ){
if( z[i+1]=='\n' ) (*pLN)++;
i++;
}
}
if( z[i]!=0 ) i++;
*pType = z[0]=='"' ? TK_STR : TK_OTHER;
return i;
}
if( isalnum(z[0]) || z[0]=='_' ){
for(i=1; isalnum(z[i]) || z[i]=='_'; i++){}
*pType = isalpha(z[0]) || z[0]=='_' ? TK_ID : TK_OTHER;
return i;
}
if( isspace(z[0]) ){
if( z[0]=='\n' ) (*pLN)++;
for(i=1; isspace(z[i]); i++){
if( z[i]=='\n' ) (*pLN)++;
}
*pType = TK_SPACE;
return i;
}
if( z[0]=='/' && z[1]=='*' ){
for(i=2; z[i] && (z[i]!='*' || z[i+1]!='/'); i++){
if( z[i]=='\n' ) (*pLN)++;
}
if( z[i] ) i += 2;
*pType = TK_SPACE;
return i;
}
if( z[0]=='/' && z[1]=='/' ){
for(i=2; z[i] && z[i]!='\n'; i++){}
if( z[i] ){
(*pLN)++;
i++;
}
*pType = TK_SPACE;
return i;
}
*pType = TK_OTHER;
return 1;
}
/*
** Return the next non-whitespace token
*/
const char *next_non_whitespace(const char *z, int *pLen, int *pType){
int len;
int eType;
int ln = 0;
while( (len = token_length(z, &eType, &ln))>0 && eType==TK_SPACE ){
z += len;
}
*pLen = len;
*pType = eType;
return z;
}
/*
** Return index into z[] for the first balanced TK_OTHER token with
** value cValue.
*/
static int distance_to(const char *z, char cVal){
int len;
int dist = 0;
int eType;
int nNest = 0;
int ln = 0;
while( z[0] && (len = token_length(z, &eType, &ln))>0 ){
if( eType==TK_OTHER ){
if( z[0]==cVal && nNest==0 ){
break;
}else if( z[0]=='(' ){
nNest++;
}else if( z[0]==')' ){
nNest--;
}
}
dist += len;
z += len;
}
return dist;
}
/*
** Return the first non-whitespace characters in z[]
*/
static const char *skip_space(const char *z){
while( isspace(z[0]) ){ z++; }
return z;
}
/*
** Return true if the input is a string literal.
*/
static int is_string_lit(const char *z){
int nu1, nu2;
z = next_non_whitespace(z, &nu1, &nu2);
return z[0]=='"';
}
/*
** Return true if the input is an expression of string literals:
**
** EXPR ? "..." : "..."
*/
static int is_string_expr(const char *z){
int len = 0, eType;
const char *zOrig = z;
len = distance_to(z, '?');
if( z[len]==0 && skip_space(z)[0]=='(' ){
z = skip_space(z) + 1;
len = distance_to(z, '?');
}
z += len;
if( z[0]=='?' ){
z++;
z = next_non_whitespace(z, &len, &eType);
if( eType==TK_STR ){
z += len;
z = next_non_whitespace(z, &len, &eType);
if( eType==TK_OTHER && z[0]==':' ){
z += len;
z = next_non_whitespace(z, &len, &eType);
if( eType==TK_STR ){
z += len;
z = next_non_whitespace(z, &len, &eType);
if( eType==TK_EOF ) return 1;
if( eType==TK_OTHER && z[0]==')' && skip_space(zOrig)[0]=='(' ){
z += len;
z = next_non_whitespace(z, &len, &eType);
if( eType==TK_EOF ) return 1;
}
}
}
}
}
return 0;
}
/*
** A list of functions that return strings that are safe to insert into
** SQL using %s.
*/
static const char *azSafeFunc[] = {
"filename_collation",
"db_name",
"timeline_utc",
"leaf_is_closed_sql",
"timeline_query_for_www",
"timeline_query_for_tty",
"blob_sql_text",
"glob_expr",
"fossil_all_reserved_names",
"configure_inop_rhs",
"db_setting_inop_rhs",
};
/*
** Return true if the input is an argument that is safe to use with %s
** while building an SQL statement.
*/
static int is_s_safe(const char *z){
int len, eType;
int i;
/* A string literal is safe for use with %s */
if( is_string_lit(z) ) return 1;
/* Certain functions are guaranteed to return a string that is safe
** for use with %s */
z = next_non_whitespace(z, &len, &eType);
for(i=0; i<sizeof(azSafeFunc)/sizeof(azSafeFunc[0]); i++){
if( eType==TK_ID
&& strncmp(z, azSafeFunc[i], len)==0
&& strlen(azSafeFunc[i])==len
){
return 1;
}
}
/* Expressions of the form: EXPR ? "..." : "...." can count as
** a string literal. */
if( is_string_expr(z) ) return 1;
/* If the "safe-for-%s" comment appears in the argument, then
** let it through */
if( strstr(z, "/*safe-for-%s*/")!=0 ) return 1;
return 0;
}
/*
** Processing flags
*/
#define FMT_NO_S 0x00001 /* Do not allow %s substitutions */
/*
** A list of internal Fossil interfaces that take a printf-style format
** string.
*/
struct {
const char *zFName; /* Name of the function */
int iFmtArg; /* Index of format argument. Leftmost is 1. */
unsigned fmtFlags; /* Processing flags */
} aFmtFunc[] = {
{ "blob_append_sql", 2, FMT_NO_S },
{ "blob_appendf", 2, 0 },
{ "cgi_panic", 1, 0 },
{ "cgi_redirectf", 1, 0 },
{ "db_blob", 2, FMT_NO_S },
{ "db_double", 2, FMT_NO_S },
{ "db_err", 1, 0 },
{ "db_exists", 1, FMT_NO_S },
{ "db_int", 2, FMT_NO_S },
{ "db_int64", 2, FMT_NO_S },
{ "db_multi_exec", 1, FMT_NO_S },
{ "db_optional_sql", 2, FMT_NO_S },
{ "db_prepare", 2, FMT_NO_S },
{ "db_prepare_ignore_error", 2, FMT_NO_S },
{ "db_static_prepare", 2, FMT_NO_S },
{ "db_text", 2, FMT_NO_S },
{ "form_begin", 2, 0 },
{ "fossil_error", 2, 0 },
{ "fossil_errorlog", 1, 0 },
{ "fossil_fatal", 1, 0 },
{ "fossil_fatal_recursive", 1, 0 },
{ "fossil_panic", 1, 0 },
{ "fossil_print", 1, 0 },
{ "fossil_trace", 1, 0 },
{ "fossil_warning", 1, 0 },
{ "href", 1, 0 },
{ "json_new_string_f", 1, 0 },
{ "mprintf", 1, 0 },
{ "socket_set_errmsg", 1, 0 },
{ "ssl_set_errmsg", 1, 0 },
{ "style_header", 1, 0 },
{ "style_set_current_page", 1, 0 },
{ "webpage_error", 1, 0 },
{ "xhref", 2, 0 },
};
/*
** Determine if the indentifier zIdent of length nIndent is a Fossil
** internal interface that uses a printf-style argument. Return zero if not.
** Return the index of the format string if true with the left-most
** argument having an index of 1.
*/
static int isFormatFunc(const char *zIdent, int nIdent, unsigned *pFlags){
int upr, lwr;
lwr = 0;
upr = sizeof(aFmtFunc)/sizeof(aFmtFunc[0]) - 1;
while( lwr<=upr ){
unsigned x = (lwr + upr)/2;
int c = strncmp(zIdent, aFmtFunc[x].zFName, nIdent);
if( c==0 ){
if( aFmtFunc[x].zFName[nIdent]==0 ){
*pFlags = aFmtFunc[x].fmtFlags;
return aFmtFunc[x].iFmtArg;
}
c = -1;
}
if( c<0 ){
upr = x - 1;
}else{
lwr = x + 1;
}
}
*pFlags = 0;
return 0;
}
/*
** Return the expected number of arguments for the format string.
** Return -1 if the value cannot be computed.
**
** For each argument less than nType, store the conversion character
** for that argument in cType[i].
*/
static int formatArgCount(const char *z, int nType, char *cType){
int nArg = 0;
int i, k;
int len;
int eType;
int ln = 0;
while( z[0] ){
len = token_length(z, &eType, &ln);
if( eType==TK_STR ){
for(i=1; i<len-1; i++){
if( z[i]!='%' ) continue;
if( z[i+1]=='%' ){ i++; continue; }
for(k=i+1; k<len && !isalpha(z[k]); k++){
if( z[k]=='*' || z[k]=='#' ){
if( nArg<nType ) cType[nArg] = z[k];
nArg++;
}
}
if( z[k]!='R' ){
if( nArg<nType ) cType[nArg] = z[k];
nArg++;
}
}
}
z += len;
}
return nArg;
}
/*
** The function call that begins at zFCall[0] (which is on line lnFCall of the
** original file) is a function that uses a printf-style format string
** on argument number fmtArg. It has processings flags fmtFlags. Do
** compile-time checking on this function, output any errors, and return
** the number of errors.
*/
static int checkFormatFunc(
const char *zFilename, /* Name of the file being processed */
const char *zFCall, /* Pointer to start of function call */
int lnFCall, /* Line number that holds z[0] */
int fmtArg, /* Format string should be this argument */
int fmtFlags /* Extra processing flags */
){
int szFName;
int eToken;
int ln = lnFCall;
int len;
const char *zStart;
char *z;
char *zCopy;
int nArg = 0;
const char **azArg = 0;
int i, k;
int nErr = 0;
char *acType;
szFName = token_length(zFCall, &eToken, &ln);
zStart = next_non_whitespace(zFCall+szFName, &len, &eToken);
assert( zStart[0]=='(' && len==1 );
len = distance_to(zStart+1, ')');
zCopy = safe_malloc( len + 1 );
memcpy(zCopy, zStart+1, len);
zCopy[len] = 0;
azArg = 0;
nArg = 0;
z = zCopy;
while( z[0] ){
len = distance_to(z, ',');
azArg = safe_realloc((char*)azArg, (sizeof(azArg[0])+1)*(nArg+1));
azArg[nArg++] = skip_space(z);
if( z[len]==0 ) break;
z[len] = 0;
for(i=len-1; i>0 && isspace(z[i]); i--){ z[i] = 0; }
z += len + 1;
}
acType = (char*)&azArg[nArg];
if( fmtArg>nArg ){
printf("%s:%d: too few arguments to %.*s()\n",
zFilename, lnFCall, szFName, zFCall);
nErr++;
}else{
const char *zFmt = azArg[fmtArg-1];
const char *zOverride = strstr(zFmt, "/*works-like:");
if( zOverride ) zFmt = zOverride + sizeof("/*works-like:")-1;
if( !is_string_lit(zFmt) ){
printf("%s:%d: %.*s() has non-constant format string\n",
zFilename, lnFCall, szFName, zFCall);
nErr++;
}else if( (k = formatArgCount(zFmt, nArg, acType))>=0
&& nArg!=fmtArg+k ){
printf("%s:%d: too %s arguments to %.*s() "
"- got %d and expected %d\n",
zFilename, lnFCall, (nArg<fmtArg+k ? "few" : "many"),
szFName, zFCall, nArg, fmtArg+k);
nErr++;
}else if( fmtFlags & FMT_NO_S ){
for(i=0; i<nArg && i<k; i++){
if( (acType[i]=='s' || acType[i]=='z' || acType[i]=='b')
&& !is_s_safe(azArg[fmtArg+i])
){
printf("%s:%d: Argument %d to %.*s() not safe for SQL\n",
zFilename, lnFCall, i+fmtArg, szFName, zFCall);
nErr++;
}
}
}
}
if( nErr ){
for(i=0; i<nArg; i++){
printf(" arg[%d]: %s\n", i, azArg[i]);
}
}
free((char*)azArg);
free(zCopy);
return nErr;
}
/*
** Do a design-rule check of format strings for the file named zName
** with content zContent. Write errors on standard output. Return
** the number of errors.
*/
static int scan_file(const char *zName, const char *zContent){
const char *z;
int ln = 0;
int szToken;
int eToken;
const char *zPrev;
int ePrev;
int szPrev;
int lnPrev;
int nCurly = 0;
int x;
unsigned fmtFlags = 0;
int nErr = 0;
if( zContent==0 ){
printf("cannot read file: %s\n", zName);
return 1;
}
for(z=zContent; z[0]; z += szToken){
szToken = token_length(z, &eToken, &ln);
if( eToken==TK_SPACE ) continue;
if( eToken==TK_OTHER ){
if( z[0]=='{' ){
nCurly++;
}else if( z[0]=='}' ){
nCurly--;
}else if( nCurly>0 && z[0]=='(' && ePrev==TK_ID
&& (x = isFormatFunc(zPrev,szPrev,&fmtFlags))>0 ){
nErr += checkFormatFunc(zName, zPrev, lnPrev, x, fmtFlags);
}
}
zPrev = z;
ePrev = eToken;
szPrev = szToken;
lnPrev = ln;
}
return nErr;
}
/*
** Check for format-string design rule violations on all files listed
** on the command-line.
*/
int main(int argc, char **argv){
int i;
int nErr = 0;
for(i=1; i<argc; i++){
char *zFile = read_file(argv[i]);
nErr += scan_file(argv[i], zFile);
free(zFile);
}
return nErr;
}
|
Changes to src/comformat.c.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #else # include <termios.h> # if defined(TIOCGWINSZ) # include <sys/ioctl.h> # endif #endif /* ** This is the previous value used by most external callers when they ** needed to specify a default maximum line length to be used with the ** comment_print() function. */ #ifndef COMMENT_LEGACY_LINE_LENGTH # define COMMENT_LEGACY_LINE_LENGTH (78) #endif /* | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | | > > > > | < | < < < < < < < < < < < | | < < < < < < < < < < < | | | | | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 |
#else
# include <termios.h>
# if defined(TIOCGWINSZ)
# include <sys/ioctl.h>
# endif
#endif
#if INTERFACE
#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
#define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */
#define COMMENT_PRINT_TRIM_CRLF ((u32)0x00000002) /* Trim leading CR/LF. */
#define COMMENT_PRINT_TRIM_SPACE ((u32)0x00000004) /* Trim leading/trailing. */
#define COMMENT_PRINT_WORD_BREAK ((u32)0x00000008) /* Break lines on words. */
#define COMMENT_PRINT_ORIG_BREAK ((u32)0x00000010) /* Break before original. */
#define COMMENT_PRINT_DEFAULT (COMMENT_PRINT_LEGACY) /* Defaults. */
#endif
/*
** This is the previous value used by most external callers when they
** needed to specify a default maximum line length to be used with the
** comment_print() function.
*/
#ifndef COMMENT_LEGACY_LINE_LENGTH
# define COMMENT_LEGACY_LINE_LENGTH (78)
#endif
/*
** This is the number of spaces to print when a tab character is seen.
*/
#ifndef COMMENT_TAB_WIDTH
# define COMMENT_TAB_WIDTH (8)
#endif
/*
** This function sets the maximum number of characters to print per line
** based on the detected terminal line width, if available; otherwise, it
** uses the legacy default terminal line width minus the amount to indent.
**
** Zero is returned to indicate any failure. One is returned to indicate
** the successful detection of the terminal line width. Negative one is
** returned to indicate the terminal line width is using the hard-coded
** legacy default value.
*/
static int comment_set_maxchars(
int indent,
int *pMaxChars
){
#if defined(_WIN32)
CONSOLE_SCREEN_BUFFER_INFO csbi;
memset(&csbi, 0, sizeof(CONSOLE_SCREEN_BUFFER_INFO));
if( GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &csbi) ){
*pMaxChars = csbi.srWindow.Right - csbi.srWindow.Left - indent;
return 1;
}
return 0;
#elif defined(TIOCGWINSZ)
struct winsize w;
memset(&w, 0, sizeof(struct winsize));
if( ioctl(0, TIOCGWINSZ, &w)!=-1 ){
*pMaxChars = w.ws_col - indent;
return 1;
}
return 0;
#else
/*
** Fallback to using more-or-less the "legacy semantics" of hard-coding
** the maximum line length to a value reasonable for the vast majority
** of supported systems.
*/
*pMaxChars = COMMENT_LEGACY_LINE_LENGTH - indent;
return -1;
#endif
}
/*
** This function checks the current line being printed against the original
** comment text. Upon matching, it emits a new line and updates the provided
** character and line counts, if applicable.
*/
static int comment_check_orig(
const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */
const char *zLine, /* [in] The comment line to print. */
int *pCharCnt, /* [in/out] Pointer to the line character count. */
int *pLineCnt /* [in/out] Pointer to the total line count. */
){
if( zOrigText && fossil_strcmp(zLine, zOrigText)==0 ){
fossil_print("\n");
if( pCharCnt ) *pCharCnt = 0;
if( pLineCnt ) (*pLineCnt)++;
return 1;
}
return 0;
}
/*
** This function scans the specified comment line starting just after the
** initial index and returns the index of the next spacing character -OR-
** zero if such a character cannot be found. For the purposes of this
** algorithm, the NUL character is treated the same as a spacing character.
*/
static int comment_next_space(
const char *zLine, /* [in] The comment line being printed. */
int index /* [in] The current character index being handled. */
){
int nextIndex = index + 1;
for(;;){
char c = zLine[nextIndex];
if( c==0 || fossil_isspace(c) ){
return nextIndex;
}
nextIndex++;
}
return 0; /* NOT REACHED */
}
/*
** This function is called when printing a logical comment line to perform
** the necessary indenting.
*/
static void comment_print_indent(
const char *zLine, /* [in] The comment line being printed. */
int indent, /* [in] Number of spaces to indent, zero for none. */
int trimCrLf, /* [in] Non-zero to trim leading/trailing CR/LF. */
int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */
int *piIndex /* [in/out] Pointer to first non-space character. */
){
if( indent>0 ){
fossil_print("%*s", indent, "");
}
if( zLine && piIndex ){
int index = *piIndex;
if( trimCrLf ){
while( zLine[index]=='\r' || zLine[index]=='\n' ){ index++; }
}
if( trimSpace ){
while( fossil_isspace(zLine[index]) ){ index++; }
}
*piIndex = index;
}
}
/*
** This function prints one logical line of a comment, stopping when it hits
** a new line -OR- runs out of space on the logical line.
*/
static void comment_print_line(
const char *zOrigText, /* [in] Original comment text ONLY, may be NULL. */
const char *zLine, /* [in] The comment line to print. */
int origIndent, /* [in] Number of spaces to indent before the original
** comment. */
int indent, /* [in] Number of spaces to indent, before the line
** to print. */
int lineChars, /* [in] Maximum number of characters to print. */
int trimCrLf, /* [in] Non-zero to trim leading/trailing CR/LF. */
int trimSpace, /* [in] Non-zero to trim leading/trailing spaces. */
int wordBreak, /* [in] Non-zero to try breaking on word boundaries. */
int origBreak, /* [in] Non-zero to break before original comment. */
int *pLineCnt, /* [in/out] Pointer to the total line count. */
const char **pzLine /* [out] Pointer to the end of the logical line. */
){
int index = 0, charCnt = 0, lineCnt = 0, maxChars;
if( !zLine ) return;
if( lineChars<=0 ) return;
comment_print_indent(zLine, indent, trimCrLf, trimSpace, &index);
maxChars = lineChars;
for(;;){
int useChars = 1;
char c = zLine[index];
if( c==0 ){
break;
}else{
if( origBreak && index>0 ){
const char *zCurrent = &zLine[index];
if( comment_check_orig(zOrigText, zCurrent, &charCnt, &lineCnt) ){
comment_print_indent(zCurrent, origIndent, trimCrLf, trimSpace,
&index);
maxChars = lineChars;
}
}
index++;
}
if( c=='\n' ){
lineCnt++;
charCnt = 0;
useChars = 0;
}else if( c=='\t' ){
int nextIndex = comment_next_space(zLine, index);
if( nextIndex<=0 || (nextIndex-index)>maxChars ){
break;
}
charCnt++;
useChars = COMMENT_TAB_WIDTH;
if( maxChars<useChars ){
fossil_print(" ");
break;
}
}else if( wordBreak && fossil_isspace(c) ){
int nextIndex = comment_next_space(zLine, index);
if( nextIndex<=0 || (nextIndex-index)>maxChars ){
break;
}
charCnt++;
}else{
charCnt++;
}
assert( c!='\n' || charCnt==0 );
fossil_print("%c", c);
maxChars -= useChars;
if( maxChars==0 ) break;
assert( maxChars>0 );
if( c=='\n' ) break;
}
if( charCnt>0 ){
fossil_print("\n");
lineCnt++;
}
if( pLineCnt ){
*pLineCnt += lineCnt;
}
if( pzLine ){
*pzLine = zLine + index;
}
}
/*
** This is the legacy comment printing algorithm. It is being retained
** for backward compatibility.
**
** Given a comment string, format that string for printing on a TTY.
** Assume that the output cursors is indent spaces from the left margin
** and that a single line can contain no more than 'width' characters.
** Indent all subsequent lines by 'indent'.
**
** Returns the number of new lines emitted.
*/
static int comment_print_legacy(
const char *zText, /* The comment text to be printed. */
int indent, /* Number of spaces to indent each non-initial line. */
int width /* Maximum number of characters per line. */
){
int maxChars = width - indent;
int si, sk, i, k;
int doIndent = 0;
char *zBuf;
char zBuffer[400];
int lineCnt = 0;
if( width<0 ){
comment_set_maxchars(indent, &maxChars);
}
if( zText==0 ) zText = "(NULL)";
if( maxChars<=0 ){
maxChars = strlen(zText);
}
if( maxChars >= (sizeof(zBuffer)) ){
zBuf = fossil_malloc(maxChars+1);
}else{
zBuf = zBuffer;
}
for(;;){
while( fossil_isspace(zText[0]) ){ zText++; }
if( zText[0]==0 ){
if( doIndent==0 ){
fossil_print("\n");
lineCnt = 1;
}
if( zBuf!=zBuffer) fossil_free(zBuf);
return lineCnt;
}
for(sk=si=i=k=0; zText[i] && k<maxChars; i++){
char c = zText[i];
if( fossil_isspace(c) ){
si = i;
sk = k;
if( k==0 || zBuf[k-1]!=' ' ){
zBuf[k++] = ' ';
}
|
| ︙ | ︙ | |||
128 129 130 131 132 133 134 135 136 137 138 139 |
zText += i;
zBuf[k] = 0;
}
fossil_print("%s\n", zBuf);
lineCnt++;
}
}
/*
**
** COMMAND: test-comment-format
**
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > | > > > > > > > > > > > > > > > > > > > > | < < > < | < < < < > | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > | > > | | 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 |
zText += i;
zBuf[k] = 0;
}
fossil_print("%s\n", zBuf);
lineCnt++;
}
}
/*
** This is the comment printing function. The comment printing algorithm
** contained within it attempts to preserve the formatting present within
** the comment string itself while honoring line width limitations. There
** are several flags that modify the default behavior of this function:
**
** COMMENT_PRINT_LEGACY: Forces use of the legacy comment printing
** algorithm. For backward compatibility,
** this is the default.
**
** COMMENT_PRINT_TRIM_CRLF: Trims leading and trailing carriage-returns
** and line-feeds where they do not materially
** impact pre-existing formatting (i.e. at the
** start of the comment string -AND- right
** before line indentation). This flag does
** not apply to the legacy comment printing
** algorithm. This flag may be combined with
** COMMENT_PRINT_TRIM_SPACE.
**
** COMMENT_PRINT_TRIM_SPACE: Trims leading and trailing spaces where they
** do not materially impact the pre-existing
** formatting (i.e. at the start of the comment
** string -AND- right before line indentation).
** This flag does not apply to the legacy
** comment printing algorithm. This flag may
** be combined with COMMENT_PRINT_TRIM_CRLF.
**
** COMMENT_PRINT_WORD_BREAK: Attempts to break lines on word boundaries
** while honoring the logical line length.
** If this flag is not specified, honoring the
** logical line length may result in breaking
** lines in the middle of words. This flag
** does not apply to the legacy comment
** printing algorithm.
**
** COMMENT_PRINT_ORIG_BREAK: Looks for the original comment text within
** the text being printed. Upon matching, a
** new line will be emitted, thus preserving
** more of the pre-existing formatting.
**
** Given a comment string, format that string for printing on a TTY.
** Assume that the output cursors is indent spaces from the left margin
** and that a single line can contain no more than 'width' characters.
** Indent all subsequent lines by 'indent'.
**
** Returns the number of new lines emitted.
*/
int comment_print(
const char *zText, /* The comment text to be printed. */
const char *zOrigText, /* Original comment text ONLY, may be NULL. */
int indent, /* Spaces to indent each non-initial line. */
int width, /* Maximum number of characters per line. */
int flags /* Zero or more "COMMENT_PRINT_*" flags. */
){
int maxChars = width - indent;
int legacy = flags & COMMENT_PRINT_LEGACY;
int trimCrLf = flags & COMMENT_PRINT_TRIM_CRLF;
int trimSpace = flags & COMMENT_PRINT_TRIM_SPACE;
int wordBreak = flags & COMMENT_PRINT_WORD_BREAK;
int origBreak = flags & COMMENT_PRINT_ORIG_BREAK;
int lineCnt = 0;
const char *zLine;
if( legacy ){
return comment_print_legacy(zText, indent, width);
}
if( width<0 ){
comment_set_maxchars(indent, &maxChars);
}
if( zText==0 ) zText = "(NULL)";
if( maxChars<=0 ){
maxChars = strlen(zText);
}
if( trimSpace ){
while( fossil_isspace(zText[0]) ){ zText++; }
}
if( zText[0]==0 ){
fossil_print("\n");
lineCnt++;
return lineCnt;
}
zLine = zText;
for(;;){
comment_print_line(zOrigText, zLine, indent, zLine>zText ? indent : 0,
maxChars, trimCrLf, trimSpace, wordBreak, origBreak,
&lineCnt, &zLine);
if( !zLine || !zLine[0] ) break;
}
return lineCnt;
}
/*
**
** COMMAND: test-comment-format
**
** Usage: %fossil test-comment-format ?OPTIONS? PREFIX TEXT ?ORIGTEXT?
**
** Test comment formatting and printing. Use for testing only.
**
** Options:
** --file The comment text is really just a file name to
** read it from.
** --decode Decode the text using the same method used when
** handling the value of a C-card from a manifest.
** --legacy Use the legacy comment printing algorithm.
** --trimcrlf Enable trimming of leading/trailing CR/LF.
** --trimspace Enable trimming of leading/trailing spaces.
** --wordbreak Attempt to break lines on word boundaries.
** --origbreak Attempt to break when the original comment text
** is detected.
** --indent Number of spaces to indent (default (-1) is to
** auto-detect). Zero means no indent.
** -W|--width <num> Width of lines (default (-1) is to auto-detect).
** Zero means no limit.
*/
void test_comment_format(void){
const char *zWidth;
const char *zIndent;
const char *zPrefix;
char *zText;
char *zOrigText;
int indent, width;
int fromFile = find_option("file", 0, 0)!=0;
int decode = find_option("decode", 0, 0)!=0;
int flags = COMMENT_PRINT_NONE;
if( find_option("legacy", 0, 0) ){
flags |= COMMENT_PRINT_LEGACY;
}
if( find_option("trimcrlf", 0, 0) ){
flags |= COMMENT_PRINT_TRIM_CRLF;
}
if( find_option("trimspace", 0, 0) ){
flags |= COMMENT_PRINT_TRIM_SPACE;
}
if( find_option("wordbreak", 0, 0) ){
flags |= COMMENT_PRINT_WORD_BREAK;
}
if( find_option("origbreak", 0, 0) ){
flags |= COMMENT_PRINT_ORIG_BREAK;
}
zWidth = find_option("width","W",1);
if( zWidth ){
width = atoi(zWidth);
}else{
width = -1; /* automatic */
}
zIndent = find_option("indent",0,1);
if( zIndent ){
indent = atoi(zIndent);
}else{
indent = -1; /* automatic */
}
if( g.argc!=4 && g.argc!=5 ){
usage("?OPTIONS? PREFIX TEXT ?ORIGTEXT?");
}
zPrefix = g.argv[2];
zText = g.argv[3];
if( g.argc==5 ){
zOrigText = g.argv[4];
}else{
zOrigText = 0;
}
if( fromFile ){
Blob fileData;
blob_read_from_file(&fileData, zText);
zText = mprintf("%s", blob_str(&fileData));
blob_reset(&fileData);
if( zOrigText ){
blob_read_from_file(&fileData, zOrigText);
zOrigText = mprintf("%s", blob_str(&fileData));
blob_reset(&fileData);
}
}
if( decode ){
zText = mprintf(fromFile?"%z":"%s" /*works-like:"%s"*/, zText);
defossilize(zText);
if( zOrigText ){
zOrigText = mprintf(fromFile?"%z":"%s" /*works-like:"%s"*/, zOrigText);
defossilize(zOrigText);
}
}
if( indent<0 ){
indent = strlen(zPrefix);
}
if( zPrefix && *zPrefix ){
fossil_print("%s", zPrefix);
}
fossil_print("(%d lines output)\n",
comment_print(zText, zOrigText, indent, width, flags));
if( zOrigText && zOrigText!=g.argv[4] ) fossil_free(zOrigText);
if( zText && zText!=g.argv[3] ) fossil_free(zText);
}
|
Changes to src/configure.c.
| ︙ | ︙ | |||
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
{ "index-page", CONFIGSET_SKIN },
{ "timeline-block-markup", CONFIGSET_SKIN },
{ "timeline-max-comment", CONFIGSET_SKIN },
{ "timeline-plaintext", CONFIGSET_SKIN },
{ "adunit", CONFIGSET_SKIN },
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
{ "adunit-omit-if-user", CONFIGSET_SKIN },
{ "th1-hooks", CONFIGSET_TH1 },
{ "th1-setup", CONFIGSET_TH1 },
{ "th1-uri-regexp", CONFIGSET_TH1 },
#ifdef FOSSIL_ENABLE_TCL
{ "tcl", CONFIGSET_TH1 },
{ "tcl-setup", CONFIGSET_TH1 },
#endif
| > > > > > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
{ "index-page", CONFIGSET_SKIN },
{ "timeline-block-markup", CONFIGSET_SKIN },
{ "timeline-max-comment", CONFIGSET_SKIN },
{ "timeline-plaintext", CONFIGSET_SKIN },
{ "adunit", CONFIGSET_SKIN },
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
{ "adunit-omit-if-user", CONFIGSET_SKIN },
#ifdef FOSSIL_ENABLE_TH1_DOCS
{ "th1-docs", CONFIGSET_TH1 },
#endif
#ifdef FOSSIL_ENABLE_TH1_HOOKS
{ "th1-hooks", CONFIGSET_TH1 },
#endif
{ "th1-setup", CONFIGSET_TH1 },
{ "th1-uri-regexp", CONFIGSET_TH1 },
#ifdef FOSSIL_ENABLE_TCL
{ "tcl", CONFIGSET_TH1 },
{ "tcl-setup", CONFIGSET_TH1 },
#endif
|
| ︙ | ︙ | |||
187 188 189 190 191 192 193 |
*/
const char *configure_inop_rhs(int iMask){
Blob x;
int i;
const char *zSep = "";
blob_zero(&x);
| | | | | | | 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 |
*/
const char *configure_inop_rhs(int iMask){
Blob x;
int i;
const char *zSep = "";
blob_zero(&x);
blob_append_sql(&x, "(");
for(i=0; i<count(aConfig); i++){
if( (aConfig[i].groupMask & iMask)==0 ) continue;
if( aConfig[i].zName[0]=='@' ) continue;
blob_append_sql(&x, "%s'%q'", zSep/*safe-for-%s*/, aConfig[i].zName);
zSep = ",";
}
blob_append_sql(&x, ")");
return blob_sql_text(&x);
}
/*
** Return the mask for the named configuration parameter if it can be
** safely exported. Return 0 if the parameter is not safe to export.
**
** "Safe" in the previous paragraph means the permission is created to
** export the property. In other words, the requesting side has presented
** login credentials and has sufficient capabilities to access the requested
** information.
*/
int configure_is_exportable(const char *zName){
int i;
int n = strlen(zName);
if( n>2 && zName[0]=='\'' && zName[n-1]=='\'' ){
zName++;
n -= 2;
}
for(i=0; i<count(aConfig); i++){
if( strncmp(zName, aConfig[i].zName, n)==0 && aConfig[i].zName[n]==0 ){
int m = aConfig[i].groupMask;
if( !g.perm.Admin ){
m &= ~CONFIGSET_USER;
}
if( !g.perm.RdAddr ){
m &= ~CONFIGSET_ADDR;
}
|
| ︙ | ︙ | |||
354 355 356 357 358 359 360 |
@ photo BLOB -- JPEG image of this user
@ );
@ INSERT INTO _xfer_reportfmt
@ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
@ INSERT INTO _xfer_user
@ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
;
| > | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
@ photo BLOB -- JPEG image of this user
@ );
@ INSERT INTO _xfer_reportfmt
@ SELECT rn,owner,title,cols,sqlcode FROM reportfmt;
@ INSERT INTO _xfer_user
@ SELECT uid,login,pw,cap,cookie,ipaddr,cexpire,info,photo FROM user;
;
assert( strchr(zSQL1,'%')==0 );
db_multi_exec(zSQL1 /*works-like:""*/);
/* When the replace flag is set, add triggers that run the first time
** that new data is seen. The triggers run only once and delete all the
** existing data.
*/
if( replaceFlag ){
static const char zSQL2[] =
|
| ︙ | ︙ | |||
383 384 385 386 387 388 389 |
@ END;
;
sqlite3_create_function(g.db, "config_is_reset", 1, SQLITE_UTF8, 0,
config_is_reset_function, 0, 0);
sqlite3_create_function(g.db, "config_reset", 1, SQLITE_UTF8, 0,
config_reset_function, 0, 0);
configHasBeenReset = 0;
| > | > | | 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 |
@ END;
;
sqlite3_create_function(g.db, "config_is_reset", 1, SQLITE_UTF8, 0,
config_is_reset_function, 0, 0);
sqlite3_create_function(g.db, "config_reset", 1, SQLITE_UTF8, 0,
config_reset_function, 0, 0);
configHasBeenReset = 0;
assert( strchr(zSQL2,'%')==0 );
db_multi_exec(zSQL2 /*works-like:""*/);
}
}
/*
** After receiving configuration data, call this routine to transfer
** the results into the main database.
*/
void configure_finalize_receive(void){
static const char zSQL[] =
@ DELETE FROM user;
@ INSERT INTO user SELECT * FROM _xfer_user;
@ DELETE FROM reportfmt;
@ INSERT INTO reportfmt SELECT * FROM _xfer_reportfmt;
@ DROP TABLE _xfer_user;
@ DROP TABLE _xfer_reportfmt;
;
assert( strchr(zSQL,'%')==0 );
db_multi_exec(zSQL /*works-like:""*/);
}
/*
** Mask of modified configuration sets
*/
static int rebuildMask = 0;
|
| ︙ | ︙ | |||
556 557 558 559 560 561 562 |
thisMask = configure_is_exportable(aType[ii].zName);
}
if( (thisMask & groupMask)==0 ) return;
blob_zero(&sql);
if( groupMask & CONFIGSET_OVERWRITE ){
if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
| | | | | | | > | | > | > | | | > | | 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
thisMask = configure_is_exportable(aType[ii].zName);
}
if( (thisMask & groupMask)==0 ) return;
blob_zero(&sql);
if( groupMask & CONFIGSET_OVERWRITE ){
if( (thisMask & configHasBeenReset)==0 && aType[ii].zName[0]!='/' ){
db_multi_exec("DELETE FROM \"%w\"", &aType[ii].zName[1]);
configHasBeenReset |= thisMask;
}
blob_append_sql(&sql, "REPLACE INTO ");
}else{
blob_append_sql(&sql, "INSERT OR IGNORE INTO ");
}
blob_append_sql(&sql, "\"%w\"(\"%w\", mtime", &zName[1], aType[ii].zPrimKey);
for(jj=2; jj<nToken; jj+=2){
blob_append_sql(&sql, ",\"%w\"", azToken[jj]);
}
blob_append_sql(&sql,") VALUES(%s,%s",
azToken[1] /*safe-for-%s*/, azToken[0] /*safe-for-%s*/);
for(jj=2; jj<nToken; jj+=2){
blob_append_sql(&sql, ",%s", azToken[jj+1] /*safe-for-%s*/);
}
db_multi_exec("%s)", blob_sql_text(&sql));
if( db_changes()==0 ){
blob_reset(&sql);
blob_append_sql(&sql, "UPDATE \"%w\" SET mtime=%s",
&zName[1], azToken[0]/*safe-for-%s*/);
for(jj=2; jj<nToken; jj+=2){
blob_append_sql(&sql, ", \"%w\"=%s",
azToken[jj], azToken[jj+1]/*safe-for-%s*/);
}
blob_append_sql(&sql, " WHERE \"%w\"=%s AND mtime<%s",
aType[ii].zPrimKey, azToken[1]/*safe-for-%s*/,
azToken[0]/*safe-for-%s*/);
db_multi_exec("%s", blob_sql_text(&sql));
}
blob_reset(&sql);
rebuildMask |= thisMask;
}else{
/* Otherwise, the old format */
if( (configure_is_exportable(zName) & groupMask)==0 ) return;
if( fossil_strcmp(zName, "logo-image")==0 ){
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
db_finalize(&ins);
}else if( zName[0]=='@' ){
/* Notice that we are evaluating arbitrary SQL received from the
** client. But this can only happen if the client has authenticated
** as an administrator, so presumably we trust the client at this
** point.
*/
| | | 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
db_finalize(&ins);
}else if( zName[0]=='@' ){
/* Notice that we are evaluating arbitrary SQL received from the
** client. But this can only happen if the client has authenticated
** as an administrator, so presumably we trust the client at this
** point.
*/
db_multi_exec("%s", blob_str(pContent) /*safe-for-%s*/);
}else{
db_multi_exec(
"REPLACE INTO config(name,value,mtime) VALUES(%Q,%Q,now())",
zName, blob_str(pContent)
);
}
}
|
| ︙ | ︙ | |||
959 960 961 962 963 964 965 |
db_create_default_users(0, 0);
}else if( fossil_strcmp(zName,"@concealed")==0 ){
db_multi_exec("DELETE FROM concealed");
}else if( fossil_strcmp(zName,"@shun")==0 ){
db_multi_exec("DELETE FROM shun");
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
db_multi_exec("DELETE FROM reportfmt");
| > | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 |
db_create_default_users(0, 0);
}else if( fossil_strcmp(zName,"@concealed")==0 ){
db_multi_exec("DELETE FROM concealed");
}else if( fossil_strcmp(zName,"@shun")==0 ){
db_multi_exec("DELETE FROM shun");
}else if( fossil_strcmp(zName,"@reportfmt")==0 ){
db_multi_exec("DELETE FROM reportfmt");
assert( strchr(zRepositorySchemaDefaultReports,'%')==0 );
db_multi_exec(zRepositorySchemaDefaultReports /*works-like:""*/);
}
}
db_end_transaction(0);
fossil_print("Configuration reset to factory defaults.\n");
fossil_print("To recover, use: %s %s import %s\n",
g.argv[0], g.argv[1], zBackup);
rebuildMask |= mask;
|
| ︙ | ︙ |
Changes to src/content.c.
| ︙ | ︙ | |||
556 557 558 559 560 561 562 |
isDephantomize = 1;
content_mark_available(rid);
}
}else{
/* We are creating a new entry */
db_prepare(&s1,
"INSERT INTO blob(rcvid,size,uuid,content)"
| | | | 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 |
isDephantomize = 1;
content_mark_available(rid);
}
}else{
/* We are creating a new entry */
db_prepare(&s1,
"INSERT INTO blob(rcvid,size,uuid,content)"
"VALUES(%d,%d,'%q',:data)",
g.rcvid, size, blob_str(&hash)
);
db_bind_blob(&s1, ":data", &cmpr);
db_exec(&s1);
rid = db_last_insert_rowid();
if( !pBlob ){
db_multi_exec("INSERT OR IGNORE INTO phantom VALUES(%d)", rid);
}
|
| ︙ | ︙ |
Changes to src/db.c.
| ︙ | ︙ | |||
175 176 177 178 179 180 181 |
}
for(i=0; db.doRollback==0 && i<db.nCommitHook; i++){
db.doRollback |= db.aHook[i].xHook();
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
| | | 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
}
for(i=0; db.doRollback==0 && i<db.nCommitHook; i++){
db.doRollback |= db.aHook[i].xHook();
}
while( db.pAllStmt ){
db_finalize(db.pAllStmt);
}
db_multi_exec("%s", db.doRollback ? "ROLLBACK" : "COMMIT");
db.doRollback = 0;
}
}
/*
** Force a rollback and shutdown the database
*/
|
| ︙ | ︙ | |||
626 627 628 629 630 631 632 | /* ** Execute a query. Return the first column of the first row ** of the result set as a string. Space to hold the string is ** obtained from malloc(). If the result set is empty, return ** zDefault instead. */ | | | 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 |
/*
** Execute a query. Return the first column of the first row
** of the result set as a string. Space to hold the string is
** obtained from malloc(). If the result set is empty, return
** zDefault instead.
*/
char *db_text(const char *zDefault, const char *zSql, ...){
va_list ap;
Stmt s;
char *z;
va_start(ap, zSql);
db_vprepare(&s, 0, zSql, ap);
va_end(ap);
if( db_step(&s)==SQLITE_ROW ){
|
| ︙ | ︙ | |||
662 663 664 665 666 667 668 |
const char *zSql;
va_list ap;
db = db_open(zFileName);
sqlite3_exec(db, "BEGIN EXCLUSIVE", 0, 0, 0);
rc = sqlite3_exec(db, zSchema, 0, 0, 0);
if( rc!=SQLITE_OK ){
| | | | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 |
const char *zSql;
va_list ap;
db = db_open(zFileName);
sqlite3_exec(db, "BEGIN EXCLUSIVE", 0, 0, 0);
rc = sqlite3_exec(db, zSchema, 0, 0, 0);
if( rc!=SQLITE_OK ){
db_err("%s", sqlite3_errmsg(db));
}
va_start(ap, zSchema);
while( (zSql = va_arg(ap, const char*))!=0 ){
rc = sqlite3_exec(db, zSql, 0, 0, 0);
if( rc!=SQLITE_OK ){
db_err("%s", sqlite3_errmsg(db));
}
}
va_end(ap);
sqlite3_exec(db, "COMMIT", 0, 0, 0);
sqlite3_close(db);
}
|
| ︙ | ︙ | |||
748 749 750 751 752 753 754 |
}
/*
** Detaches the zLabel database.
*/
void db_detach(const char *zLabel){
| | | | 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 |
}
/*
** Detaches the zLabel database.
*/
void db_detach(const char *zLabel){
db_multi_exec("DETACH DATABASE %Q", zLabel);
}
/*
** zDbName is the name of a database file. Attach zDbName using
** the name zLabel.
*/
void db_attach(const char *zDbName, const char *zLabel){
db_multi_exec("ATTACH DATABASE %Q AS %Q", zDbName, zLabel);
}
/*
** zDbName is the name of a database file. If no other database
** file is open, then open this one. If another database file is
** already open, then attach zDbName using the name zLabel.
*/
|
| ︙ | ︙ | |||
885 886 887 888 889 890 891 |
** zColumn
*/
static int db_local_table_exists_but_lacks_column(
const char *zTable,
const char *zColumn
){
char *zDef = db_text(0, "SELECT sql FROM %s.sqlite_master"
| | | | 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 |
** zColumn
*/
static int db_local_table_exists_but_lacks_column(
const char *zTable,
const char *zColumn
){
char *zDef = db_text(0, "SELECT sql FROM %s.sqlite_master"
" WHERE name==%Q /*scan*/",
db_name("localdb"), zTable);
int rc = 0;
if( zDef ){
char *zPattern = mprintf("* %s *", zColumn);
rc = sqlite3_strglob(zPattern, zDef)!=0;
fossil_free(zPattern);
fossil_free(zDef);
}
return rc;
}
/*
|
| ︙ | ︙ | |||
917 918 919 920 921 922 923 |
" WHERE name=='vfile'", db_name("localdb"));
if( zVFileDef==0 ) return 0;
/* If the "isexe" column is missing from the vfile table, then
** add it now. This code added on 2010-03-06. After all users have
** upgraded, this code can be safely deleted.
*/
| | | | 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
" WHERE name=='vfile'", db_name("localdb"));
if( zVFileDef==0 ) return 0;
/* If the "isexe" column is missing from the vfile table, then
** add it now. This code added on 2010-03-06. After all users have
** upgraded, this code can be safely deleted.
*/
if( sqlite3_strglob("* isexe *", zVFileDef)!=0 ){
db_multi_exec("ALTER TABLE vfile ADD COLUMN isexe BOOLEAN DEFAULT 0");
}
/* If "islink"/"isLink" columns are missing from tables, then
** add them now. This code added on 2011-01-17 and 2011-08-27.
** After all users have upgraded, this code can be safely deleted.
*/
if( sqlite3_strglob("* islink *", zVFileDef)!=0 ){
db_multi_exec("ALTER TABLE vfile ADD COLUMN islink BOOLEAN DEFAULT 0");
if( db_local_table_exists_but_lacks_column("stashfile", "isLink") ){
db_multi_exec("ALTER TABLE stashfile ADD COLUMN isLink BOOL DEFAULT 0");
}
if( db_local_table_exists_but_lacks_column("undo", "isLink") ){
db_multi_exec("ALTER TABLE undo ADD COLUMN isLink BOOLEAN DEFAULT 0");
}
|
| ︙ | ︙ | |||
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 |
** option to locate the repository. If no such option is available, then
** use the repository of the open checkout if there is one.
**
** Error out if the repository cannot be opened.
*/
void db_find_and_open_repository(int bFlags, int nArgUsed){
const char *zRep = find_repository_option();
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
zRep = g.argv[nArgUsed];
}
if( zRep==0 ){
if( db_open_local(0)==0 ){
goto rep_not_found;
}
| > > > | 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 |
** option to locate the repository. If no such option is available, then
** use the repository of the open checkout if there is one.
**
** Error out if the repository cannot be opened.
*/
void db_find_and_open_repository(int bFlags, int nArgUsed){
const char *zRep = find_repository_option();
if( zRep && file_isdir(zRep)==1 ){
goto rep_not_found;
}
if( zRep==0 && nArgUsed && g.argc==nArgUsed+1 ){
zRep = g.argv[nArgUsed];
}
if( zRep==0 ){
if( db_open_local(0)==0 ){
goto rep_not_found;
}
|
| ︙ | ︙ | |||
1114 1115 1116 1117 1118 1119 1120 |
/*
** Return TRUE if the schema is out-of-date
*/
int db_schema_is_outofdate(void){
return db_exists("SELECT 1 FROM config"
" WHERE name='aux-schema'"
| | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 |
/*
** Return TRUE if the schema is out-of-date
*/
int db_schema_is_outofdate(void){
return db_exists("SELECT 1 FROM config"
" WHERE name='aux-schema'"
" AND value<>%Q", AUX_SCHEMA);
}
/*
** Return true if the database is writeable
*/
int db_is_writeable(const char *zName){
return g.db!=0 && !sqlite3_db_readonly(g.db, db_name(zName));
|
| ︙ | ︙ | |||
1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 |
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('developer','','dei','Dev');"
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('reader','','kptw','Reader');"
);
}
}
/*
** Return a pointer to a string that contains the RHS of an IN operator
** that will select CONFIG table names that are in the list of control
** settings.
*/
const char *db_setting_inop_rhs(){
Blob x;
int i;
const char *zSep = "";
blob_zero(&x);
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | | | 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 |
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('developer','','dei','Dev');"
"INSERT OR IGNORE INTO user(login,pw,cap,info)"
" VALUES('reader','','kptw','Reader');"
);
}
}
/*
** This function sets the server and project codes if they do not already
** exist. Currently, it should be called only by the db_initial_setup()
** or cmd_webserver() functions, the latter being used to facilitate more
** robust integration with "canned image" environments (e.g. Docker).
*/
void db_setup_server_and_project_codes(
int optional
){
if( !optional ){
db_multi_exec(
"INSERT INTO config(name,value,mtime)"
" VALUES('server-code', lower(hex(randomblob(20))),now());"
"INSERT INTO config(name,value,mtime)"
" VALUES('project-code', lower(hex(randomblob(20))),now());"
);
}else if( db_is_writeable("repository") ){
if( db_get("server-code", 0)==0 ) {
db_multi_exec(
"INSERT INTO config(name,value,mtime)"
" VALUES('server-code', lower(hex(randomblob(20))),now());"
);
}
if( db_get("project-code", 0)==0 ) {
db_multi_exec(
"INSERT INTO config(name,value,mtime)"
" VALUES('project-code', lower(hex(randomblob(20))),now());"
);
}
}
}
/*
** Return a pointer to a string that contains the RHS of an IN operator
** that will select CONFIG table names that are in the list of control
** settings.
*/
const char *db_setting_inop_rhs(){
Blob x;
int i;
const char *zSep = "";
blob_zero(&x);
blob_append_sql(&x, "(");
for(i=0; ctrlSettings[i].name; i++){
blob_append_sql(&x, "%s%Q", zSep/*safe-for-%s*/, ctrlSettings[i].name);
zSep = ",";
}
blob_append_sql(&x, ")");
return blob_sql_text(&x);
}
/*
** Fill an empty repository database with the basic information for a
** repository. This function is shared between 'create_repository_cmd'
** ('new') and 'reconstruct_cmd' ('reconstruct'), both of which create
** new repositories.
|
| ︙ | ︙ | |||
1359 1360 1361 1362 1363 1364 1365 |
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
db_set("rebuilt", get_version(), 0);
if( makeServerCodes ){
| < < < < | < | 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 |
Blob hash;
Blob manifest;
db_set("content-schema", CONTENT_SCHEMA, 0);
db_set("aux-schema", AUX_SCHEMA, 0);
db_set("rebuilt", get_version(), 0);
if( makeServerCodes ){
db_setup_server_and_project_codes(0);
}
if( !db_is_global("autosync") ) db_set_int("autosync", 1, 0);
if( !db_is_global("localauth") ) db_set_int("localauth", 0, 0);
if( !db_is_global("timeline-plaintext") ){
db_set_int("timeline-plaintext", 1, 0);
}
db_create_default_users(0, zDefaultUser);
|
| ︙ | ︙ | |||
1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 |
** See also: clone
*/
void create_repository_cmd(void){
char *zPassword;
const char *zTemplate; /* Repository from which to copy settings */
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
zTemplate = find_option("template",0,1);
zDate = find_option("date-override",0,1);
zDefaultUser = find_option("admin-user","A",1);
find_option("empty", 0, 0); /* deprecated */
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
db_begin_transaction();
| > > > > > > | > | | > | 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 |
** See also: clone
*/
void create_repository_cmd(void){
char *zPassword;
const char *zTemplate; /* Repository from which to copy settings */
const char *zDate; /* Date of the initial check-in */
const char *zDefaultUser; /* Optional name of the default user */
int makeServerCodes;
zTemplate = find_option("template",0,1);
zDate = find_option("date-override",0,1);
zDefaultUser = find_option("admin-user","A",1);
makeServerCodes = find_option("docker", 0, 0)==0;
find_option("empty", 0, 0); /* deprecated */
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 ){
usage("REPOSITORY-NAME");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0);
if( zTemplate ) db_attach(zTemplate, "settingSrc");
db_begin_transaction();
db_initial_setup(zTemplate, zDate, zDefaultUser, makeServerCodes);
db_end_transaction(0);
if( zTemplate ) db_detach("settingSrc");
if( makeServerCodes ){
fossil_print("project-id: %s\n", db_get("project-code", 0));
fossil_print("server-id: %s\n", db_get("server-code", 0));
}
zPassword = db_text(0, "SELECT pw FROM user WHERE login=%Q", g.zLogin);
fossil_print("admin-user: %s (initial password is \"%s\")\n",
g.zLogin, zPassword);
}
/*
** SQL functions for debugging.
|
| ︙ | ︙ | |||
1930 1931 1932 1933 1934 1935 1936 | } /* ** Returns non-0 if the database (which must be open) table identified ** by zTableName has a column named zColName (case-sensitive), else ** returns 0. */ | | | | 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
}
/*
** Returns non-0 if the database (which must be open) table identified
** by zTableName has a column named zColName (case-sensitive), else
** returns 0.
*/
int db_table_has_column(const char *zTableName, const char *zColName){
Stmt q = empty_Stmt;
int rc = 0;
db_prepare( &q, "PRAGMA table_info(%Q)", zTableName );
while(SQLITE_ROW == db_step(&q)){
/* Columns: (cid, name, type, notnull, dflt_value, pk) */
const char *zCol = db_column_text(&q, 1);
if( 0==fossil_strcmp(zColName, zCol) ){
rc = 1;
break;
}
}
db_finalize(&q);
return rc;
|
| ︙ | ︙ | |||
1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 |
** as follows:
**
** ckout:%s
**
** Where %s is the checkout root. The value is the repository file.
*/
void db_record_repository_filename(const char *zName){
Blob full;
if( zName==0 ){
if( !g.localOpen ) return;
zName = db_repository_filename();
}
file_canonical_name(zName, &full, 0);
db_swap_connections();
db_multi_exec(
"INSERT OR IGNORE INTO global_config(name,value)"
| > > > > > > > > | < > > > > > > > | | > > > > | < > > | 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 |
** as follows:
**
** ckout:%s
**
** Where %s is the checkout root. The value is the repository file.
*/
void db_record_repository_filename(const char *zName){
char *zRepoSetting;
char *zCkoutSetting;
Blob full;
if( zName==0 ){
if( !g.localOpen ) return;
zName = db_repository_filename();
}
file_canonical_name(zName, &full, 0);
(void)filename_collation(); /* Initialize before connection swap */
db_swap_connections();
zRepoSetting = mprintf("repo:%q", blob_str(&full));
db_multi_exec(
"DELETE FROM global_config WHERE name %s = %Q;",
filename_collation(), zRepoSetting
);
db_multi_exec(
"INSERT OR IGNORE INTO global_config(name,value)"
"VALUES(%Q,1);",
zRepoSetting
);
fossil_free(zRepoSetting);
if( g.localOpen && g.zLocalRoot && g.zLocalRoot[0] ){
Blob localRoot;
file_canonical_name(g.zLocalRoot, &localRoot, 1);
zCkoutSetting = mprintf("ckout:%q", blob_str(&localRoot));
db_multi_exec(
"DELETE FROM global_config WHERE name %s = %Q;",
filename_collation(), zCkoutSetting
);
db_multi_exec(
"REPLACE INTO global_config(name, value)"
"VALUES(%Q,%Q);",
zCkoutSetting, blob_str(&full)
);
db_swap_connections();
db_optional_sql("repository",
"DELETE FROM config WHERE name %s = %Q;",
filename_collation(), zCkoutSetting
);
db_optional_sql("repository",
"REPLACE INTO config(name,value,mtime)"
"VALUES(%Q,1,now());",
zCkoutSetting
);
fossil_free(zCkoutSetting);
blob_reset(&localRoot);
}else{
db_swap_connections();
}
blob_reset(&full);
}
|
| ︙ | ︙ | |||
2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 |
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
url_proxy_options();
emptyFlag = find_option("empty",0,0)!=0;
keepFlag = find_option("keep",0,0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
allowNested = find_option("nested",0,0)!=0;
if( g.argc!=3 && g.argc!=4 ){
usage("REPOSITORY-FILENAME ?VERSION?");
}
if( !allowNested && db_open_local(0) ){
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
}
db_open_repository(g.argv[2]);
| > > > > | 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 |
static char *azNewArgv[] = { 0, "checkout", "--prompt", 0, 0, 0, 0 };
url_proxy_options();
emptyFlag = find_option("empty",0,0)!=0;
keepFlag = find_option("keep",0,0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
allowNested = find_option("nested",0,0)!=0;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 && g.argc!=4 ){
usage("REPOSITORY-FILENAME ?VERSION?");
}
if( !allowNested && db_open_local(0) ){
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
}
db_open_repository(g.argv[2]);
|
| ︙ | ︙ | |||
2131 2132 2133 2134 2135 2136 2137 |
** width is the length for the edit field on the behavior page, 0
** is used for on/off checkboxes.
** The behaviour page doesn't use a special layout. It lists all
** set-commands and displays the 'set'-help as info.
*/
#if INTERFACE
struct stControlSettings {
| | | | | 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 |
** width is the length for the edit field on the behavior page, 0
** is used for on/off checkboxes.
** The behaviour page doesn't use a special layout. It lists all
** set-commands and displays the 'set'-help as info.
*/
#if INTERFACE
struct stControlSettings {
const char *name; /* Name of the setting */
const char *var; /* Internal variable name used by db_set() */
int width; /* Width of display. 0 for boolean values. */
int versionable; /* Is this setting versionable? */
int forceTextArea; /* Force using a text area for display? */
const char *def; /* Default value */
};
#endif /* INTERFACE */
struct stControlSettings const ctrlSettings[] = {
{ "access-log", 0, 0, 0, 0, "off" },
{ "allow-symlinks", 0, 0, 1, 0, "off" },
{ "auto-captcha", "autocaptcha", 0, 0, 0, "on" },
{ "auto-hyperlink", 0, 0, 0, 0, "on", },
|
| ︙ | ︙ | |||
2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 |
{ "ssh-command", 0, 40, 0, 0, "" },
{ "ssl-ca-location", 0, 40, 0, 0, "" },
{ "ssl-identity", 0, 40, 0, 0, "" },
#ifdef FOSSIL_ENABLE_TCL
{ "tcl", 0, 0, 0, 0, "off" },
{ "tcl-setup", 0, 40, 1, 1, "" },
#endif
{ "th1-hooks", 0, 0, 0, 0, "off" },
{ "th1-setup", 0, 40, 1, 1, "" },
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
{ "web-browser", 0, 32, 0, 0, "" },
{ "white-foreground", 0, 0, 0, 0, "off" },
{ 0,0,0,0,0,0 }
};
| > > > > > | 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 |
{ "ssh-command", 0, 40, 0, 0, "" },
{ "ssl-ca-location", 0, 40, 0, 0, "" },
{ "ssl-identity", 0, 40, 0, 0, "" },
#ifdef FOSSIL_ENABLE_TCL
{ "tcl", 0, 0, 0, 0, "off" },
{ "tcl-setup", 0, 40, 1, 1, "" },
#endif
#ifdef FOSSIL_ENABLE_TH1_DOCS
{ "th1-docs", 0, 0, 0, 0, "off" },
#endif
#ifdef FOSSIL_ENABLE_TH1_HOOKS
{ "th1-hooks", 0, 0, 0, 0, "off" },
#endif
{ "th1-setup", 0, 40, 1, 1, "" },
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
{ "web-browser", 0, 32, 0, 0, "" },
{ "white-foreground", 0, 0, 0, 0, "off" },
{ 0,0,0,0,0,0 }
};
|
| ︙ | ︙ | |||
2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 | ** scripts to be evaluated from TH1. Additionally, the Tcl ** interpreter will be able to evaluate arbitrary TH1 ** expressions and scripts. Default: off. ** ** tcl-setup This is the setup script to be evaluated after creating ** (versionable) and initializing the Tcl interpreter. By default, this ** is empty and no extra setup is performed. ** ** th1-hooks If enabled (and Fossil was compiled with support for TH1 ** hooks), special TH1 commands will be called before and ** after any Fossil command or web page. Default: off. ** ** th1-setup This is the setup script to be evaluated after creating ** (versionable) and initializing the TH1 interpreter. By default, this | > > > > > > > > > > | 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 | ** scripts to be evaluated from TH1. Additionally, the Tcl ** interpreter will be able to evaluate arbitrary TH1 ** expressions and scripts. Default: off. ** ** tcl-setup This is the setup script to be evaluated after creating ** (versionable) and initializing the Tcl interpreter. By default, this ** is empty and no extra setup is performed. ** ** th1-docs WARNING: If enabled (and Fossil was compiled with TH1 ** support for embedded documentation files), this allows ** embedded documentation files to contain arbitrary TH1 ** scripts that are evaluated on the server. If native ** Tcl integration is also enabled, this setting has the ** potential to allow anybody with check-in privileges to ** do almost anything that the associated operating system ** user account could do. Extreme caution should be used ** when enabling this setting. Default: off. ** ** th1-hooks If enabled (and Fossil was compiled with support for TH1 ** hooks), special TH1 commands will be called before and ** after any Fossil command or web page. Default: off. ** ** th1-setup This is the setup script to be evaluated after creating ** (versionable) and initializing the TH1 interpreter. By default, this |
| ︙ | ︙ | |||
2452 2453 2454 2455 2456 2457 2458 |
if( !ctrlSettings[i].name ){
fossil_fatal("no such setting: %s", zName);
}
isManifest = fossil_strcmp(ctrlSettings[i].name, "manifest")==0;
if( isManifest && globalFlag ){
fossil_fatal("cannot set 'manifest' globally");
}
| > > > > > > > > > > > > > > > | | | | > > > > > | > > | 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 |
if( !ctrlSettings[i].name ){
fossil_fatal("no such setting: %s", zName);
}
isManifest = fossil_strcmp(ctrlSettings[i].name, "manifest")==0;
if( isManifest && globalFlag ){
fossil_fatal("cannot set 'manifest' globally");
}
if( unsetFlag || g.argc==4 ){
if( ctrlSettings[i+1].name
&& strncmp(ctrlSettings[i+1].name, zName, n)==0
&& ctrlSettings[i].name[n]!=0
){
fossil_print("ambiguous property prefix: %s\nMatching properties:\n",
zName);
while( ctrlSettings[i].name
&& strncmp(ctrlSettings[i].name, zName, n)==0
){
fossil_print("%s\n", ctrlSettings[i].name);
i++;
}
fossil_exit(1);
}else{
if( unsetFlag ){
db_unset(ctrlSettings[i].name, globalFlag);
}else{
db_set(ctrlSettings[i].name, g.argv[3], globalFlag);
}
}
}else{
isManifest = 0;
while( ctrlSettings[i].name
&& strncmp(ctrlSettings[i].name, zName, n)==0
){
print_setting(&ctrlSettings[i], db_open_local(0));
i++;
}
}
if( isManifest && g.localOpen ){
manifest_to_disk(db_lget_int("checkout", 0));
}
}else{
usage("?PROPERTY? ?VALUE? ?-global?");
}
|
| ︙ | ︙ | |||
2553 2554 2555 2556 2557 2558 2559 |
blob_append(&newSql, zOrigSql, j);
blob_append(&newSql, "PRIMARY KEY", -1);
zOrigSql += j+6;
j = -1;
}
}
blob_append(&newSql, zOrigSql, -1);
| | | | | | | | | | 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 |
blob_append(&newSql, zOrigSql, j);
blob_append(&newSql, "PRIMARY KEY", -1);
zOrigSql += j+6;
j = -1;
}
}
blob_append(&newSql, zOrigSql, -1);
blob_append_sql(&allSql,
"ALTER TABLE \"%w\" RENAME TO \"x_%w\";\n"
"%s WITHOUT ROWID;\n"
"INSERT INTO \"%w\" SELECT * FROM \"x_%w\";\n"
"DROP TABLE \"x_%w\";\n",
zTName, zTName, blob_sql_text(&newSql), zTName, zTName, zTName
);
fossil_print("Converting table %s of %s to WITHOUT ROWID.\n", zTName, g.argv[i]);
blob_reset(&newSql);
}
blob_append_sql(&allSql, "COMMIT;\n");
db_finalize(&q);
if( dryRun ){
fossil_print("SQL that would have been evaluated:\n");
fossil_print("-------------------------------------------------------------\n");
fossil_print("%s", blob_sql_text(&allSql));
}else{
db_multi_exec("%s", blob_sql_text(&allSql));
}
blob_reset(&allSql);
db_close(1);
}
}
|
Changes to src/delta.c.
| ︙ | ︙ | |||
63 64 65 66 67 68 69 | #if INTERFACE /* ** The "u32" type must be an unsigned 32-bit integer. Adjust this */ typedef unsigned int u32; /* | | | | 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 | #if INTERFACE /* ** The "u32" type must be an unsigned 32-bit integer. Adjust this */ typedef unsigned int u32; /* ** Must be a 16-bit value */ typedef short int s16; typedef unsigned short int u16; #endif /* INTERFACE */ /* ** The width of a hash window in bytes. The algorithm only works if this ** is a power of 2. */ #define NHASH 16 /* ** The current state of the rolling hash. ** ** z[] holds the values that have been hashed. z[] is a circular buffer. ** z[i] is the first entry and z[(i+NHASH-1)%NHASH] is the last entry of ** the window. ** ** Hash.a is the sum of all elements of hash.z[]. Hash.b is a weighted ** sum. Hash.b is z[i]*NHASH + z[i+1]*(NHASH-1) + ... + z[i+NHASH-1]*1. ** (Each index for z[] should be module NHASH, of course. The %NHASH operator ** is omitted in the prior expression for brevity.) */ |
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
return (pHash->a & 0xffff) | (((u32)(pHash->b & 0xffff))<<16);
}
/*
** Write an base-64 integer into the given buffer.
*/
static void putInt(unsigned int v, char **pz){
| | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
return (pHash->a & 0xffff) | (((u32)(pHash->b & 0xffff))<<16);
}
/*
** Write an base-64 integer into the given buffer.
*/
static void putInt(unsigned int v, char **pz){
static const char zDigits[] =
"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz~";
/* 123456789 123456789 123456789 123456789 123456789 123456789 123 */
int i, j;
char zBuf[20];
if( v==0 ){
*(*pz)++ = '0';
return;
|
| ︙ | ︙ | |||
227 228 229 230 231 232 233 | } return sum3; } /* ** Create a new delta. ** | | | | 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 | } return sum3; } /* ** Create a new delta. ** ** The delta is written into a preallocated buffer, zDelta, which ** should be at least 60 bytes longer than the target file, zOut. ** The delta string will be NUL-terminated, but it might also contain ** embedded NUL characters if either the zSrc or zOut files are ** binary. This function returns the length of the delta string ** in bytes, excluding the final NUL terminator character. ** ** Output Format: ** ** The delta begins with a base64 number followed by a newline. This ** number is the number of bytes in the TARGET file. Thus, given a ** delta file z, a program can compute the size of the output file ** simply by reading the first line and decoding the base-64 number ** found there. The delta_output_size() routine does exactly this. ** ** After the initial size number, the delta consists of a series of ** literal text segments and commands to copy from the SOURCE file. ** A copy command looks like this: ** ** NNN@MMM, ** ** where NNN is the number of bytes to be copied and MMM is the offset ** into the source file of the first byte (both base-64). If NNN is 0 ** it means copy the rest of the input file. Literal text is like this: |
| ︙ | ︙ | |||
281 282 283 284 285 286 287 | ** Next we begin scanning the target file using a sliding 16-byte ** window. The hash of the 16-byte window in the target is used to ** search for a matching section in the source file. When a match ** is found, a copy command is added to the delta. An effort is ** made to extend the matching section to regions that come before ** and after the 16-byte hash window. A copy command is only issued ** if the result would use less space that just quoting the text | | | 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 | ** Next we begin scanning the target file using a sliding 16-byte ** window. The hash of the 16-byte window in the target is used to ** search for a matching section in the source file. When a match ** is found, a copy command is added to the delta. An effort is ** made to extend the matching section to regions that come before ** and after the 16-byte hash window. A copy command is only issued ** if the result would use less space that just quoting the text ** literally. Literal text is added to the delta for sections that ** do not match or which can not be encoded efficiently using copy ** commands. */ int delta_create( const char *zSrc, /* The source or pattern file */ unsigned int lenSrc, /* Length of the source file */ const char *zOut, /* The target file */ |
| ︙ | ︙ | |||
354 355 356 357 358 359 360 |
int limit = 250;
hv = hash_32bit(&h) % nHash;
DEBUG2( printf("LOOKING: %4d [%s]\n", base+i, print16(&zOut[base+i])); )
iBlock = landmark[hv];
while( iBlock>=0 && (limit--)>0 ){
/*
| | | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 |
int limit = 250;
hv = hash_32bit(&h) % nHash;
DEBUG2( printf("LOOKING: %4d [%s]\n", base+i, print16(&zOut[base+i])); )
iBlock = landmark[hv];
while( iBlock>=0 && (limit--)>0 ){
/*
** The hash window has identified a potential match against
** landmark block iBlock. But we need to investigate further.
**
** Look for a region in zOut that matches zSrc. Anchor the search
** at zSrc[iSrc] and zOut[base+i]. Do not include anything prior to
** zOut[base] or after zOut[outLen] nor anything after zSrc[srcLen].
**
** Set cnt equal to the length of the match and set ofst so that
** zSrc[ofst] is the first element of the match. litsz is the number
** of characters between zOut[base] and the beginning of the match.
|
| ︙ | ︙ | |||
466 467 468 469 470 471 472 |
memcpy(zDelta, &zOut[base], lenOut-base);
zDelta += lenOut-base;
}
/* Output the final checksum record. */
putInt(checksum(zOut, lenOut), &zDelta);
*(zDelta++) = ';';
fossil_free(collide);
| | | | 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
memcpy(zDelta, &zOut[base], lenOut-base);
zDelta += lenOut-base;
}
/* Output the final checksum record. */
putInt(checksum(zOut, lenOut), &zDelta);
*(zDelta++) = ';';
fossil_free(collide);
return zDelta - zOrigDelta;
}
/*
** Return the size (in bytes) of the output from applying
** a delta.
**
** This routine is provided so that an procedure that is able
** to call delta_apply() can learn how much space is required
** for the output and hence allocate nor more space that is really
** needed.
*/
int delta_output_size(const char *zDelta, int lenDelta){
|
| ︙ | ︙ |
Changes to src/descendants.c.
| ︙ | ︙ | |||
128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
}
}
db_finalize(&ins);
db_finalize(&isBr);
db_finalize(&q1);
bag_clear(&pending);
bag_clear(&seen);
}
if( closeMode==1 ){
db_multi_exec(
"DELETE FROM leaves WHERE rid IN"
" (SELECT leaves.rid FROM leaves, tagxref"
" WHERE tagxref.rid=leaves.rid "
" AND tagxref.tagid=%d"
| > > > > > | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
}
}
db_finalize(&ins);
db_finalize(&isBr);
db_finalize(&q1);
bag_clear(&pending);
bag_clear(&seen);
}else{
db_multi_exec(
"INSERT INTO leaves"
" SELECT leaf.rid FROM leaf"
);
}
if( closeMode==1 ){
db_multi_exec(
"DELETE FROM leaves WHERE rid IN"
" (SELECT leaves.rid FROM leaves, tagxref"
" WHERE tagxref.rid=leaves.rid "
" AND tagxref.tagid=%d"
|
| ︙ | ︙ | |||
310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
width = atoi(zWidth);
if( (width!=0) && (width<=20) ){
fossil_fatal("-W|--width value must be >20 or 0");
}
}else{
width = -1;
}
if( g.argc==2 ){
base = db_lget_int("checkout", 0);
}else{
base = name_to_typed_rid(g.argv[2], "ci");
}
if( base==0 ) return;
compute_leaves(base, 0);
| > > > > | 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 |
width = atoi(zWidth);
if( (width!=0) && (width<=20) ){
fossil_fatal("-W|--width value must be >20 or 0");
}
}else{
width = -1;
}
/* We should be done with options.. */
verify_all_options();
if( g.argc==2 ){
base = db_lget_int("checkout", 0);
}else{
base = name_to_typed_rid(g.argv[2], "ci");
}
if( base==0 ) return;
compute_leaves(base, 0);
|
| ︙ | ︙ | |||
371 372 373 374 375 376 377 378 379 380 |
if( (width!=0) && (width<=39) ){
fossil_fatal("-W|--width value must be >39 or 0");
}
}else{
width = -1;
}
db_find_and_open_repository(0,0);
if( recomputeFlag ) leaf_rebuild();
blob_zero(&sql);
blob_append(&sql, timeline_query_for_tty(), -1);
| > > > > | | | | | | | 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 |
if( (width!=0) && (width<=39) ){
fossil_fatal("-W|--width value must be >39 or 0");
}
}else{
width = -1;
}
db_find_and_open_repository(0,0);
/* We should be done with options.. */
verify_all_options();
if( recomputeFlag ) leaf_rebuild();
blob_zero(&sql);
blob_append(&sql, timeline_query_for_tty(), -1);
blob_append_sql(&sql, " AND blob.rid IN leaf");
if( showClosed ){
blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
}else if( !showAll ){
blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
}
if( byBranch ){
db_prepare(&q, "%s ORDER BY nullif(branch,'trunk') COLLATE nocase,"
" event.mtime DESC",
blob_sql_text(&sql));
}else{
db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
}
blob_reset(&sql);
n = 0;
while( db_step(&q)==SQLITE_ROW ){
const char *zId = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
const char *zCom = db_column_text(&q, 3);
const char *zBr = db_column_text(&q, 7);
char *z;
if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
fossil_print("*** %s ***\n", zBr);
fossil_free(zLastBr);
zLastBr = fossil_strdup(zBr);
}
n++;
sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
fossil_print("%6s ", zLineNo);
z = mprintf("%s [%S] %s", zDate, zId, zCom);
comment_print(z, zCom, 7, width, g.comFmtFlags);
fossil_free(z);
}
fossil_free(zLastBr);
db_finalize(&q);
}
/*
|
| ︙ | ︙ | |||
459 460 461 462 463 464 465 |
}else if( showClosed ){
@ <h1>Closed leaves:</h1>
}else{
@ <h1>Open leaves:</h1>
}
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
| | | | | | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 |
}else if( showClosed ){
@ <h1>Closed leaves:</h1>
}else{
@ <h1>Open leaves:</h1>
}
blob_zero(&sql);
blob_append(&sql, timeline_query_for_www(), -1);
blob_append_sql(&sql, " AND blob.rid IN leaf");
if( showClosed ){
blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
}else if( !showAll ){
blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
}
db_prepare(&q, "%s ORDER BY event.mtime DESC", blob_sql_text(&sql));
blob_reset(&sql);
www_print_timeline(&q, TIMELINE_LEAFONLY, 0, 0, 0);
db_finalize(&q);
@ <br />
style_footer();
}
|
| ︙ | ︙ | |||
493 494 495 496 497 498 499 | Bag pending; Stmt ins; Stmt q; int rid; bag_init(&seen); bag_init(&pending); | | | 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
Bag pending;
Stmt ins;
Stmt q;
int rid;
bag_init(&seen);
bag_init(&pending);
db_prepare(&ins, "INSERT OR IGNORE INTO \"%w\" VALUES(:rid)", zTab);
db_prepare(&q, "SELECT mid FROM mlink WHERE fid=%d", fid);
while( db_step(&q)==SQLITE_ROW ){
int mid = db_column_int(&q, 0);
bag_insert(&pending, mid);
bag_insert(&seen, mid);
db_bind_int(&ins, ":rid", mid);
db_step(&ins);
|
| ︙ | ︙ | |||
516 517 518 519 520 521 522 |
if( usesFlags & USESFILE_DELETE ){
db_bind_int(&ins, ":rid", mid);
db_step(&ins);
db_reset(&ins);
}
}
db_finalize(&q);
| | | 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 |
if( usesFlags & USESFILE_DELETE ){
db_bind_int(&ins, ":rid", mid);
db_step(&ins);
db_reset(&ins);
}
}
db_finalize(&q);
db_prepare(&q, "SELECT cid FROM plink WHERE pid=:rid AND isprim");
while( (rid = bag_first(&pending))!=0 ){
bag_remove(&pending, rid);
db_bind_int(&q, ":rid", rid);
while( db_step(&q)==SQLITE_ROW ){
int mid = db_column_int(&q, 0);
if( bag_find(&seen, mid) ) continue;
|
| ︙ | ︙ |
Changes to src/diff.c.
| ︙ | ︙ | |||
592 593 594 595 596 597 598 |
static void sbsWriteColumn(Blob *pOut, Blob *pCol, int col){
blob_appendf(pOut,
"<td><div class=\"diff%scol\">\n"
"<pre>\n"
"%s"
"</pre>\n"
"</div></td>\n",
| | | 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
static void sbsWriteColumn(Blob *pOut, Blob *pCol, int col){
blob_appendf(pOut,
"<td><div class=\"diff%scol\">\n"
"<pre>\n"
"%s"
"</pre>\n"
"</div></td>\n",
(col % 3) ? (col == SBS_MKR ? "mkr" : "txt") : "ln",
blob_str(pCol)
);
}
/*
** Append a separator line to column iCol
*/
|
| ︙ | ︙ | |||
2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 |
annFlags = DIFF_IGNORE_EOLWS;
}
if( find_option("ignore-all-space","w",0)!=0 ){
annFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
}
fileVers = find_option("filevers",0,0)!=0;
db_must_be_within_tree();
if( g.argc<3 ) {
usage("FILENAME");
}
file_tree_name(g.argv[2], &treename, 1);
zFilename = blob_str(&treename);
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
if( fnid==0 ){
| > > > > | 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 |
annFlags = DIFF_IGNORE_EOLWS;
}
if( find_option("ignore-all-space","w",0)!=0 ){
annFlags = DIFF_IGNORE_ALLWS; /* stronger than DIFF_IGNORE_EOLWS */
}
fileVers = find_option("filevers",0,0)!=0;
db_must_be_within_tree();
/* We should be done with options.. */
verify_all_options();
if( g.argc<3 ) {
usage("FILENAME");
}
file_tree_name(g.argv[2], &treename, 1);
zFilename = blob_str(&treename);
fnid = db_int(0, "SELECT fnid FROM filename WHERE name=%Q", zFilename);
if( fnid==0 ){
|
| ︙ | ︙ |
Added src/diff.tcl.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
set prog {
package require Tk
array set CFG {
TITLE {Fossil Diff}
LN_COL_BG #dddddd
LN_COL_FG #444444
TXT_COL_BG #ffffff
TXT_COL_FG #000000
MKR_COL_BG #444444
MKR_COL_FG #dddddd
CHNG_BG #d0d0ff
ADD_BG #c0ffc0
RM_BG #ffc0c0
HR_FG #888888
HR_PAD_TOP 4
HR_PAD_BTM 8
FN_BG #444444
FN_FG #ffffff
FN_PAD 5
ERR_FG #ee0000
PADX 5
WIDTH 80
HEIGHT 45
LB_HEIGHT 25
}
if {![namespace exists ttk]} {
interp alias {} ::ttk::scrollbar {} ::scrollbar
interp alias {} ::ttk::menubutton {} ::menubutton
}
proc dehtml {x} {
set x [regsub -all {<[^>]*>} $x {}]
return [string map {& & < < > > ' ' " \"} $x]
}
proc cols {} {
return [list .lnA .txtA .mkr .lnB .txtB]
}
proc colType {c} {
regexp {[a-z]+} $c type
return $type
}
proc getLine {difftxt N iivar} {
upvar $iivar ii
if {$ii>=$N} {return -1}
set x [lindex $difftxt $ii]
incr ii
return $x
}
proc readDiffs {fossilcmd} {
global difftxt
if {![info exists difftxt]} {
set in [open $fossilcmd r]
fconfigure $in -encoding utf-8
set difftxt [split [read $in] \n]
close $in
}
set N [llength $difftxt]
set ii 0
set nDiffs 0
array set widths {txt 0 ln 0 mkr 0}
while {[set line [getLine $difftxt $N ii]] != -1} {
set fn2 {}
if {![regexp {^=+ (.*?) =+ versus =+ (.*?) =+$} $line all fn fn2]
&& ![regexp {^=+ (.*?) =+$} $line all fn]
} {
continue
}
set errMsg ""
set line [getLine $difftxt $N ii]
if {[string compare -length 6 $line "<table"]
&& ![regexp {<p[^>]*>(.+)} $line - errMsg]} {
continue
}
incr nDiffs
set idx [expr {$nDiffs > 1 ? [.txtA index end] : "1.0"}]
.wfiles.lb insert end $fn
foreach c [cols] {
if {$nDiffs > 1} {
$c insert end \n -
}
if {[colType $c] eq "txt"} {
$c insert end $fn\n fn
if {$fn2!=""} {set fn $fn2}
} else {
$c insert end \n fn
}
$c insert end \n -
if {$errMsg ne ""} continue
while {[getLine $difftxt $N ii] ne "<pre>"} continue
set type [colType $c]
set str {}
while {[set line [getLine $difftxt $N ii]] ne "</pre>"} {
set len [string length [dehtml $line]]
if {$len > $widths($type)} {
set widths($type) $len
}
append str $line\n
}
set re {<span class="diff([a-z]+)">([^<]*)</span>}
# Use \r as separator since it can't appear in the diff output (it gets
# converted to a space).
set str [regsub -all $re $str "\r\\1\r\\2\r"]
foreach {pre class mid} [split $str \r] {
if {$class ne ""} {
$c insert end [dehtml $pre] - [dehtml $mid] [list $class -]
} else {
$c insert end [dehtml $pre] -
}
}
}
if {$errMsg ne ""} {
foreach c {.txtA .txtB} {$c insert end [string trim $errMsg] err}
foreach c [cols] {$c insert end \n -}
}
}
foreach c [cols] {
set type [colType $c]
if {$type ne "txt"} {
$c config -width $widths($type)
}
$c config -state disabled
}
if {$nDiffs <= [.wfiles.lb cget -height]} {
.wfiles.lb config -height $nDiffs
grid remove .wfiles.sb
}
return $nDiffs
}
proc viewDiff {idx} {
.txtA yview $idx
.txtA xview moveto 0
}
proc cycleDiffs {{reverse 0}} {
if {$reverse} {
set range [.txtA tag prevrange fn @0,0 1.0]
if {$range eq ""} {
viewDiff {fn.last -1c}
} else {
viewDiff [lindex $range 0]
}
} else {
set range [.txtA tag nextrange fn {@0,0 +1c} end]
if {$range eq "" || [lindex [.txtA yview] 1] == 1} {
viewDiff fn.first
} else {
viewDiff [lindex $range 0]
}
}
}
proc xvis {col} {
set view [$col xview]
return [expr {[lindex $view 1]-[lindex $view 0]}]
}
proc scroll-x {args} {
set c .txt[expr {[xvis .txtA] < [xvis .txtB] ? "A" : "B"}]
eval $c xview $args
}
interp alias {} scroll-y {} .txtA yview
proc noop {args} {}
proc enableSync {axis} {
update idletasks
interp alias {} sync-$axis {}
rename _sync-$axis sync-$axis
}
proc disableSync {axis} {
rename sync-$axis _sync-$axis
interp alias {} sync-$axis {} noop
}
proc sync-x {col first last} {
disableSync x
$col xview moveto [expr {$first*[xvis $col]/($last-$first)}]
foreach side {A B} {
set sb .sbx$side
set xview [.txt$side xview]
if {[lindex $xview 0] > 0 || [lindex $xview 1] < 1} {
grid $sb
eval $sb set $xview
} else {
grid remove $sb
}
}
enableSync x
}
proc sync-y {first last} {
disableSync y
foreach c [cols] {
$c yview moveto $first
}
if {$first > 0 || $last < 1} {
grid .sby
.sby set $first $last
} else {
grid remove .sby
}
enableSync y
}
wm withdraw .
wm title . $CFG(TITLE)
wm iconname . $CFG(TITLE)
bind . <q> exit
bind . <Destroy> {after 0 exit}
bind . <Tab> {cycleDiffs; break}
bind . <<PrevWindow>> {cycleDiffs 1; break}
bind . <Return> {
event generate .bb.files <1>
event generate .bb.files <ButtonRelease-1>
break
}
foreach {key axis args} {
Up y {scroll -5 units}
Down y {scroll 5 units}
Left x {scroll -5 units}
Right x {scroll 5 units}
Prior y {scroll -1 page}
Next y {scroll 1 page}
Home y {moveto 0}
End y {moveto 1}
} {
bind . <$key> "scroll-$axis $args; break"
bind . <Shift-$key> continue
}
frame .bb
::ttk::menubutton .bb.files -text "Files"
toplevel .wfiles
wm withdraw .wfiles
update idletasks
wm transient .wfiles .
wm overrideredirect .wfiles 1
listbox .wfiles.lb -width 0 -height $CFG(LB_HEIGHT) -activestyle none \
-yscroll {.wfiles.sb set}
::ttk::scrollbar .wfiles.sb -command {.wfiles.lb yview}
grid .wfiles.lb .wfiles.sb -sticky ns
bind .bb.files <1> {
set x [winfo rootx %W]
set y [expr {[winfo rooty %W]+[winfo height %W]}]
wm geometry .wfiles +$x+$y
wm deiconify .wfiles
focus .wfiles.lb
}
bind .wfiles <FocusOut> {wm withdraw .wfiles}
bind .wfiles <Escape> {focus .}
foreach evt {1 Return} {
bind .wfiles.lb <$evt> {
catch {
set idx [lindex [.txtA tag ranges fn] [expr {[%W curselection]*2}]]
viewDiff $idx
}
focus .
break
}
}
bind .wfiles.lb <Motion> {
%W selection clear 0 end
%W selection set @%x,%y
}
foreach {side syncCol} {A .txtB B .txtA} {
set ln .ln$side
text $ln
$ln tag config - -justify right
set txt .txt$side
text $txt -width $CFG(WIDTH) -height $CFG(HEIGHT) -wrap none \
-xscroll "sync-x $syncCol"
catch {$txt config -tabstyle wordprocessor} ;# Required for Tk>=8.5
foreach tag {add rm chng} {
$txt tag config $tag -background $CFG([string toupper $tag]_BG)
$txt tag lower $tag
}
$txt tag config fn -background $CFG(FN_BG) -foreground $CFG(FN_FG) \
-justify center
$txt tag config err -foreground $CFG(ERR_FG)
}
text .mkr
foreach c [cols] {
set keyPrefix [string toupper [colType $c]]_COL_
if {[tk windowingsystem] eq "win32"} {$c config -font {courier 9}}
$c config -bg $CFG(${keyPrefix}BG) -fg $CFG(${keyPrefix}FG) -borderwidth 0 \
-padx $CFG(PADX) -yscroll sync-y
$c tag config hr -spacing1 $CFG(HR_PAD_TOP) -spacing3 $CFG(HR_PAD_BTM) \
-foreground $CFG(HR_FG)
$c tag config fn -spacing1 $CFG(FN_PAD) -spacing3 $CFG(FN_PAD)
bindtags $c ". $c Text all"
bind $c <1> {focus %W}
}
::ttk::scrollbar .sby -command {.txtA yview} -orient vertical
::ttk::scrollbar .sbxA -command {.txtA xview} -orient horizontal
::ttk::scrollbar .sbxB -command {.txtB xview} -orient horizontal
frame .spacer
if {[readDiffs $fossilcmd] == 0} {
tk_messageBox -type ok -title $CFG(TITLE) -message "No changes"
exit
}
update idletasks
proc saveDiff {} {
set fn [tk_getSaveFile]
if {$fn==""} return
set out [open $fn wb]
puts $out "#!/usr/bin/tclsh\n#\n# Run this script using 'tclsh' or 'wish'"
puts $out "# to see the graphical diff.\n#"
puts $out "set fossilcmd {}"
puts $out "set prog [list $::prog]"
puts $out "set difftxt \173"
foreach e $::difftxt {puts $out [list $e]}
puts $out "\175"
puts $out "eval \$prog"
close $out
}
proc invertDiff {} {
global CFG
array set x [grid info .txtA]
if {$x(-column)==1} {
grid config .lnB -column 0
grid config .txtB -column 1
.txtB tag config add -background $CFG(RM_BG)
grid config .lnA -column 3
grid config .txtA -column 4
.txtA tag config rm -background $CFG(ADD_BG)
} else {
grid config .lnA -column 0
grid config .txtA -column 1
.txtA tag config rm -background $CFG(RM_BG)
grid config .lnB -column 3
grid config .txtB -column 4
.txtB tag config add -background $CFG(ADD_BG)
}
.mkr config -state normal
set clt [.mkr search -all < 1.0 end]
set cgt [.mkr search -all > 1.0 end]
foreach c $clt {.mkr replace $c "$c +1 chars" >}
foreach c $cgt {.mkr replace $c "$c +1 chars" <}
.mkr config -state disabled
}
::ttk::button .bb.quit -text {Quit} -command exit
::ttk::button .bb.invert -text {Invert} -command invertDiff
::ttk::button .bb.save -text {Save As...} -command saveDiff
pack .bb.quit .bb.invert -side left
if {$fossilcmd!=""} {pack .bb.save -side left}
pack .bb.files -side left
grid rowconfigure . 1 -weight 1
grid columnconfigure . 1 -weight 1
grid columnconfigure . 4 -weight 1
grid .bb -row 0 -columnspan 6
eval grid [cols] -row 1 -sticky nsew
grid .sby -row 1 -column 5 -sticky ns
grid .sbxA -row 2 -columnspan 2 -sticky ew
grid .spacer -row 2 -column 2
grid .sbxB -row 2 -column 3 -columnspan 2 -sticky ew
.spacer config -height [winfo height .sbxA]
wm deiconify .
}
eval $prog
|
Changes to src/diffcmd.c.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
*/
#if defined(_WIN32)
# define NULL_DEVICE "NUL"
#else
# define NULL_DEVICE "/dev/null"
#endif
/*
** Print the "Index:" message that patches wants to see at the top of a diff.
*/
void diff_print_index(const char *zFile, u64 diffFlags){
if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
fossil_print("%s", z);
| > > > > > | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
*/
#if defined(_WIN32)
# define NULL_DEVICE "NUL"
#else
# define NULL_DEVICE "/dev/null"
#endif
/*
** Used when the name for the diff is unknown.
*/
#define DIFF_NO_NAME "(unknown)"
/*
** Print the "Index:" message that patches wants to see at the top of a diff.
*/
void diff_print_index(const char *zFile, u64 diffFlags){
if( (diffFlags & (DIFF_SIDEBYSIDE|DIFF_BRIEF))==0 ){
char *z = mprintf("Index: %s\n%.66c\n", zFile, '=');
fossil_print("%s", z);
|
| ︙ | ︙ | |||
135 136 137 138 139 140 141 |
int cnt = 0;
Blob nameFile1; /* Name of temporary file to old pFile1 content */
Blob cmd; /* Text of command to run */
if( !fIncludeBinary ){
Blob file2;
if( isBin1 ){
| | | | | 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 |
int cnt = 0;
Blob nameFile1; /* Name of temporary file to old pFile1 content */
Blob cmd; /* Text of command to run */
if( !fIncludeBinary ){
Blob file2;
if( isBin1 ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
return;
}
if( zBinGlob ){
Glob *pBinary = glob_create(zBinGlob);
if( glob_match(pBinary, zName) ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
glob_free(pBinary);
return;
}
glob_free(pBinary);
}
blob_zero(&file2);
if( file_wd_size(zFile2)>=0 ){
if( file_wd_islink(zFile2) ){
blob_read_link(&file2, zFile2);
}else{
blob_read_from_file(&file2, zFile2);
}
}
if( looks_like_binary(&file2) ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
blob_reset(&file2);
return;
}
blob_reset(&file2);
}
/* Construct a temporary file to hold pFile1 based on the name of
|
| ︙ | ︙ | |||
231 232 233 234 235 236 237 |
}else{
Blob cmd;
char zTemp1[300];
char zTemp2[300];
if( !fIncludeBinary ){
if( isBin1 || isBin2 ){
| | | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
}else{
Blob cmd;
char zTemp1[300];
char zTemp2[300];
if( !fIncludeBinary ){
if( isBin1 || isBin2 ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
return;
}
if( zBinGlob ){
Glob *pBinary = glob_create(zBinGlob);
if( glob_match(pBinary, zName) ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_BINARY);
glob_free(pBinary);
return;
}
glob_free(pBinary);
}
}
|
| ︙ | ︙ | |||
295 296 297 298 299 300 301 |
Blob content;
int isLink;
int isBin;
file_tree_name(zFileTreeName, &fname, 1);
historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0,
fIncludeBinary ? 0 : &isBin, 0);
if( !isLink != !file_wd_islink(zFrom) ){
| | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
Blob content;
int isLink;
int isBin;
file_tree_name(zFileTreeName, &fname, 1);
historical_version_of_file(zFrom, blob_str(&fname), &content, &isLink, 0,
fIncludeBinary ? 0 : &isBin, 0);
if( !isLink != !file_wd_islink(zFrom) ){
fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK);
}else{
diff_file(&content, isBin, zFileTreeName, zFileTreeName,
zDiffCmd, zBinGlob, fIncludeBinary, diffFlags);
}
blob_reset(&content);
blob_reset(&fname);
}
|
| ︙ | ︙ | |||
339 340 341 342 343 344 345 |
db_begin_transaction();
if( zFrom ){
int rid = name_to_typed_rid(zFrom, "ci");
if( !is_a_version(rid) ){
fossil_fatal("no such check-in: %s", zFrom);
}
load_vfile_from_rid(rid);
| | | | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
db_begin_transaction();
if( zFrom ){
int rid = name_to_typed_rid(zFrom, "ci");
if( !is_a_version(rid) ){
fossil_fatal("no such check-in: %s", zFrom);
}
load_vfile_from_rid(rid);
blob_append_sql(&sql,
"SELECT v2.pathname, v2.deleted, v2.chnged, v2.rid==0, v1.rid, v1.islink"
" FROM vfile v1, vfile v2 "
" WHERE v1.pathname=v2.pathname AND v1.vid=%d AND v2.vid=%d"
" AND (v2.deleted OR v2.chnged OR v1.mrid!=v2.rid)"
"UNION "
"SELECT pathname, 1, 0, 0, 0, islink"
" FROM vfile v1"
" WHERE v1.vid=%d"
" AND NOT EXISTS(SELECT 1 FROM vfile v2"
" WHERE v2.vid=%d AND v2.pathname=v1.pathname)"
"UNION "
"SELECT pathname, 0, 0, 1, 0, islink"
" FROM vfile v2"
" WHERE v2.vid=%d"
" AND NOT EXISTS(SELECT 1 FROM vfile v1"
" WHERE v1.vid=%d AND v1.pathname=v2.pathname)"
" ORDER BY 1",
rid, vid, rid, vid, vid, rid
);
}else{
blob_append_sql(&sql,
"SELECT pathname, deleted, chnged , rid==0, rid, islink"
" FROM vfile"
" WHERE vid=%d"
" AND (deleted OR chnged OR rid==0)"
" ORDER BY pathname",
vid
);
}
db_prepare(&q, "%s", blob_sql_text(&sql));
while( db_step(&q)==SQLITE_ROW ){
const char *zPathname = db_column_text(&q,0);
int isDeleted = db_column_int(&q, 1);
int isChnged = db_column_int(&q,2);
int isNew = db_column_int(&q,3);
int srcid = db_column_int(&q, 4);
int isLink = db_column_int(&q, 5);
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 |
}
if( showDiff ){
Blob content;
int isBin;
if( !isLink != !file_wd_islink(zFullName) ){
diff_print_index(zPathname, diffFlags);
diff_print_filenames(zPathname, zPathname, diffFlags);
| | | 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
}
if( showDiff ){
Blob content;
int isBin;
if( !isLink != !file_wd_islink(zFullName) ){
diff_print_index(zPathname, diffFlags);
diff_print_filenames(zPathname, zPathname, diffFlags);
fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK);
continue;
}
if( srcid>0 ){
content_get(srcid, &content);
}else{
blob_zero(&content);
}
|
| ︙ | ︙ | |||
455 456 457 458 459 460 461 |
zName = blob_str(&fname);
historical_version_of_file(zFrom, zName, &v1, &isLink1, 0,
fIncludeBinary ? 0 : &isBin1, 0);
historical_version_of_file(zTo, zName, &v2, &isLink2, 0,
fIncludeBinary ? 0 : &isBin2, 0);
if( isLink1 != isLink2 ){
diff_print_filenames(zName, zName, diffFlags);
| | | 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 |
zName = blob_str(&fname);
historical_version_of_file(zFrom, zName, &v1, &isLink1, 0,
fIncludeBinary ? 0 : &isBin1, 0);
historical_version_of_file(zTo, zName, &v2, &isLink2, 0,
fIncludeBinary ? 0 : &isBin2, 0);
if( isLink1 != isLink2 ){
diff_print_filenames(zName, zName, diffFlags);
fossil_print("%s",DIFF_CANNOT_COMPUTE_SYMLINK);
}else{
diff_file_mem(&v1, &v2, isBin1, isBin2, zName, zDiffCmd,
zBinGlob, fIncludeBinary, diffFlags);
}
blob_reset(&v1);
blob_reset(&v2);
blob_reset(&fname);
|
| ︙ | ︙ | |||
487 488 489 490 491 492 493 |
const char *zBinGlob,
int fIncludeBinary,
u64 diffFlags
){
Blob f1, f2;
int isBin1, isBin2;
int rid;
| | > > > > > > > | 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 |
const char *zBinGlob,
int fIncludeBinary,
u64 diffFlags
){
Blob f1, f2;
int isBin1, isBin2;
int rid;
const char *zName;
if( pFrom ){
zName = pFrom->zName;
}else if( pTo ){
zName = pTo->zName;
}else{
zName = DIFF_NO_NAME;
}
if( diffFlags & DIFF_BRIEF ) return;
diff_print_index(zName, diffFlags);
if( pFrom ){
rid = uuid_to_rid(pFrom->zUuid, 0);
content_get(rid, &f1);
}else{
blob_zero(&f1);
|
| ︙ | ︙ | |||
603 604 605 606 607 608 609 |
}else{
zDefault = 0;
zName = "diff-command";
}
return db_get(zName, zDefault);
}
| < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
}else{
zDefault = 0;
zName = "diff-command";
}
return db_get(zName, zDefault);
}
/*
** Show diff output in a Tcl/Tk window, in response to the --tk option
** to the diff command.
**
** If fossil has direct access to a Tcl interpreter (either loaded
** dynamically through stubs or linked in statically), we can use it
** directly. Otherwise:
|
| ︙ | ︙ | |||
1026 1027 1028 1029 1030 1031 1032 |
blob_appendf(&script, " {%/}", z);
}else{
int j;
blob_append(&script, " ", 1);
for(j=0; z[j]; j++) blob_appendf(&script, "\\%03o", (unsigned char)z[j]);
}
}
| | | | 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
blob_appendf(&script, " {%/}", z);
}else{
int j;
blob_append(&script, " ", 1);
for(j=0; z[j]; j++) blob_appendf(&script, "\\%03o", (unsigned char)z[j]);
}
}
blob_appendf(&script, "}\n%s", builtin_file("diff.tcl", 0));
if( zTempFile ){
blob_write_to_file(&script, zTempFile);
fossil_print("To see diff, run: tclsh \"%s\"\n", zTempFile);
}else{
#if defined(FOSSIL_ENABLE_TCL)
Th_FossilInit(TH_INIT_DEFAULT);
if( evaluateTclWithEvents(g.interp, &g.tcl, blob_str(&script),
blob_size(&script), 1, 0)==TCL_OK ){
blob_reset(&script);
return;
}
/*
* If evaluation of the Tcl script fails, the reason may be that Tk
* could not be found by the loaded Tcl, or that Tcl cannot be loaded
* dynamically (e.g. x64 Tcl with x86 Fossil). Therefore, fallback
|
| ︙ | ︙ |
Changes to src/doc.c.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 | /* ** Try to guess the mimetype from content. ** ** If the content is pure text, return NULL. ** ** For image types, attempt to return an appropriate mimetype | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
/*
** Try to guess the mimetype from content.
**
** If the content is pure text, return NULL.
**
** For image types, attempt to return an appropriate mimetype
** name like "image/gif" or "image/jpeg".
**
** For any other binary type, return "unknown/unknown".
*/
const char *mimetype_from_content(Blob *pBlob){
int i;
int n;
const unsigned char *x;
|
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
const char *mimetype_from_name(const char *zName){
const char *z;
int i;
int first, last;
int len;
char zSuffix[20];
| | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
const char *mimetype_from_name(const char *zName){
const char *z;
int i;
int first, last;
int len;
char zSuffix[20];
/* A table of mimetypes based on file suffixes.
** Suffixes must be in sorted order so that we can do a binary
** search to find the mime-type
*/
static const struct {
const char *zSuffix; /* The file suffix */
int size; /* Length of the suffix */
const char *zMimetype; /* The corresponding mimetype */
|
| ︙ | ︙ | |||
254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
{ "t", 1, "application/x-troff" },
{ "tar", 3, "application/x-tar" },
{ "tcl", 3, "application/x-tcl" },
{ "tex", 3, "application/x-tex" },
{ "texi", 4, "application/x-texinfo" },
{ "texinfo", 7, "application/x-texinfo" },
{ "tgz", 3, "application/x-tar-gz" },
{ "tif", 3, "image/tiff" },
{ "tiff", 4, "image/tiff" },
{ "tr", 2, "application/x-troff" },
{ "tsi", 3, "audio/TSP-audio" },
{ "tsp", 3, "application/dsptype" },
{ "tsv", 3, "text/tab-separated-values" },
{ "txt", 3, "text/plain" },
| > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
{ "t", 1, "application/x-troff" },
{ "tar", 3, "application/x-tar" },
{ "tcl", 3, "application/x-tcl" },
{ "tex", 3, "application/x-tex" },
{ "texi", 4, "application/x-texinfo" },
{ "texinfo", 7, "application/x-texinfo" },
{ "tgz", 3, "application/x-tar-gz" },
{ "th1", 3, "application/x-th1" },
{ "tif", 3, "image/tiff" },
{ "tiff", 4, "image/tiff" },
{ "tr", 2, "application/x-troff" },
{ "tsi", 3, "audio/TSP-audio" },
{ "tsp", 3, "application/dsptype" },
{ "tsv", 3, "text/tab-separated-values" },
{ "txt", 3, "text/plain" },
|
| ︙ | ︙ | |||
484 485 486 487 488 489 490 |
goto doc_not_found;
}
db_end_transaction(0);
}
blob_to_utf8_no_bom(&filebody, 0);
/* The file is now contained in the filebody blob. Deliver the
| | | | > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 |
goto doc_not_found;
}
db_end_transaction(0);
}
blob_to_utf8_no_bom(&filebody, 0);
/* The file is now contained in the filebody blob. Deliver the
** file to the user
*/
zMime = P("mimetype");
if( zMime==0 ){
zMime = mimetype_from_name(zName);
}
Th_Store("doc_name", zName);
Th_Store("doc_version", db_text(0, "SELECT '[' || substr(uuid,1,10) || ']'"
" FROM blob WHERE rid=%d", vid));
Th_Store("doc_date", db_text(0, "SELECT datetime(mtime) FROM event"
" WHERE objid=%d AND type='ci'", vid));
if( fossil_strcmp(zMime, "text/x-fossil-wiki")==0 ){
Blob title, tail;
if( wiki_find_title(&filebody, &title, &tail) ){
style_header("%s", blob_str(&title));
wiki_convert(&tail, 0, WIKI_BUTTONS);
}else{
style_header("Documentation");
wiki_convert(&filebody, 0, WIKI_BUTTONS);
}
style_footer();
}else if( fossil_strcmp(zMime, "text/x-markdown")==0 ){
Blob title = BLOB_INITIALIZER;
Blob tail = BLOB_INITIALIZER;
markdown_to_html(&filebody, &title, &tail);
if( blob_size(&title)>0 ){
style_header("%s", blob_str(&title));
}else{
style_header("Documentation");
}
blob_append(cgi_output_blob(), blob_buffer(&tail), blob_size(&tail));
style_footer();
}else if( fossil_strcmp(zMime, "text/plain")==0 ){
style_header("Documentation");
@ <blockquote><pre>
@ %h(blob_str(&filebody))
@ </pre></blockquote>
style_footer();
#ifdef FOSSIL_ENABLE_TH1_DOCS
}else if( db_get_boolean("th1-docs", 0) &&
fossil_strcmp(zMime, "application/x-th1")==0 ){
style_header("%h", zName);
Th_Render(blob_str(&filebody));
style_footer();
#endif
}else{
cgi_set_content_type(zMime);
cgi_set_content(&filebody);
}
return;
doc_not_found:
/* Jump here when unable to locate the document */
db_end_transaction(0);
style_header("Document Not Found");
@ <p>No such document: %h(zName)</p>
style_footer();
return;
}
/*
** The default logo.
*/
static const unsigned char aLogo[] = {
71, 73, 70, 56, 55, 97, 62, 0, 71, 0, 244, 0, 0, 85,
129, 149, 95, 136, 155, 99, 139, 157, 106, 144, 162, 113, 150, 166,
116, 152, 168, 127, 160, 175, 138, 168, 182, 148, 176, 188, 159, 184,
195, 170, 192, 202, 180, 199, 208, 184, 202, 210, 191, 207, 215, 201,
215, 221, 212, 223, 228, 223, 231, 235, 226, 227, 226, 226, 234, 237,
233, 239, 241, 240, 244, 246, 244, 247, 248, 255, 255, 255, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 44, 0, 0,
0, 0, 62, 0, 71, 0, 0, 5, 255, 96, 100, 141, 100, 105,
158, 168, 37, 41, 132, 192, 164, 112, 44, 207, 102, 99, 0, 56,
16, 84, 116, 239, 199, 141, 65, 110, 232, 248, 25, 141, 193, 161,
82, 113, 108, 202, 32, 55, 229, 210, 73, 61, 41, 164, 88, 102,
181, 10, 41, 96, 179, 91, 106, 35, 240, 5, 135, 143, 137, 242,
87, 123, 246, 33, 190, 81, 108, 163, 237, 198, 14, 30, 113, 233,
131, 78, 115, 72, 11, 115, 87, 101, 19, 124, 51, 66, 74, 8,
19, 16, 67, 100, 74, 133, 50, 15, 101, 135, 56, 11, 74, 6,
143, 49, 126, 106, 56, 8, 145, 67, 9, 152, 48, 139, 155, 5,
22, 13, 74, 115, 161, 41, 147, 101, 13, 130, 57, 132, 170, 40,
167, 155, 0, 94, 57, 3, 178, 48, 183, 181, 57, 160, 186, 40,
19, 141, 189, 0, 69, 192, 40, 16, 195, 155, 185, 199, 41, 201,
189, 191, 205, 193, 188, 131, 210, 49, 175, 88, 209, 214, 38, 19,
3, 11, 19, 111, 127, 60, 219, 39, 55, 204, 19, 11, 6, 100,
5, 10, 227, 228, 37, 163, 0, 239, 117, 56, 238, 243, 49, 195,
177, 247, 48, 158, 56, 251, 50, 216, 254, 197, 56, 128, 107, 158,
2, 125, 171, 114, 92, 218, 246, 96, 66, 3, 4, 50, 134, 176,
145, 6, 97, 64, 144, 24, 19, 136, 108, 91, 177, 160, 0, 194,
19, 253, 0, 216, 107, 214, 224, 192, 129, 5, 16, 83, 255, 244,
43, 213, 195, 24, 159, 27, 169, 64, 230, 88, 208, 227, 129, 182,
54, 4, 89, 158, 24, 181, 163, 199, 1, 155, 52, 233, 8, 130,
176, 83, 24, 128, 137, 50, 18, 32, 48, 48, 114, 11, 173, 137,
19, 110, 4, 64, 105, 1, 194, 30, 140, 68, 15, 24, 24, 224,
50, 76, 70, 0, 11, 171, 54, 26, 160, 181, 194, 149, 148, 40,
174, 148, 122, 64, 180, 208, 161, 17, 207, 112, 164, 1, 128, 96,
148, 78, 18, 21, 194, 33, 229, 51, 247, 65, 133, 97, 5, 250,
69, 229, 100, 34, 220, 128, 166, 116, 190, 62, 8, 167, 195, 170,
47, 163, 0, 130, 90, 152, 11, 160, 173, 170, 27, 154, 26, 91,
232, 151, 171, 18, 14, 162, 253, 98, 170, 18, 70, 171, 64, 219,
10, 67, 136, 134, 187, 116, 75, 180, 46, 179, 174, 135, 4, 189,
229, 231, 78, 40, 10, 62, 226, 164, 172, 64, 240, 167, 170, 10,
18, 124, 188, 10, 107, 65, 193, 94, 11, 93, 171, 28, 248, 17,
239, 46, 140, 78, 97, 34, 25, 153, 36, 99, 65, 130, 7, 203,
183, 168, 51, 34, 136, 25, 140, 10, 6, 16, 28, 255, 145, 241,
230, 140, 10, 66, 178, 167, 112, 48, 192, 128, 129, 9, 31, 141,
84, 138, 63, 163, 162, 2, 203, 206, 240, 56, 55, 98, 192, 188,
15, 185, 50, 160, 6, 0, 125, 62, 33, 214, 195, 33, 5, 24,
184, 25, 231, 14, 201, 245, 144, 23, 126, 104, 228, 0, 145, 2,
13, 140, 244, 212, 17, 21, 20, 176, 159, 17, 95, 225, 160, 128,
16, 1, 32, 224, 142, 32, 227, 125, 87, 64, 0, 16, 54, 129,
205, 2, 141, 76, 53, 130, 103, 37, 166, 64, 144, 107, 78, 196,
5, 192, 0, 54, 50, 229, 9, 141, 49, 84, 194, 35, 12, 196,
153, 48, 192, 137, 57, 84, 24, 7, 87, 159, 249, 240, 215, 143,
105, 241, 118, 149, 9, 139, 4, 64, 203, 141, 35, 140, 129, 131,
16, 222, 125, 231, 128, 2, 238, 17, 152, 66, 3, 5, 56, 224,
159, 103, 16, 76, 25, 75, 5, 11, 164, 215, 96, 9, 14, 16,
36, 225, 15, 11, 40, 144, 192, 156, 41, 10, 178, 199, 3, 66,
64, 80, 193, 3, 124, 90, 48, 129, 129, 102, 177, 18, 192, 154,
49, 84, 240, 208, 92, 22, 149, 96, 39, 9, 31, 74, 17, 94,
3, 8, 177, 199, 72, 59, 85, 76, 25, 216, 8, 139, 194, 197,
138, 163, 69, 96, 115, 0, 147, 72, 72, 84, 28, 14, 79, 86,
233, 230, 23, 113, 26, 160, 128, 3, 10, 58, 129, 103, 14, 159,
214, 163, 146, 117, 238, 213, 154, 128, 151, 109, 84, 64, 217, 13,
27, 10, 228, 39, 2, 235, 164, 168, 74, 8, 0, 59,
};
/*
** WEBPAGE: logo
**
** Return the logo image. This image is available to anybody who can see
** the login page. It is designed for use in the upper left-hand corner
|
| ︙ | ︙ |
Changes to src/encode.c.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 |
}
i++;
}
i = 0;
zOut = fossil_malloc( count+1 );
while( n-->0 && (c = *zIn)!=0 ){
switch( c ){
| | | | | | 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 |
}
i++;
}
i = 0;
zOut = fossil_malloc( count+1 );
while( n-->0 && (c = *zIn)!=0 ){
switch( c ){
case '<':
zOut[i++] = '&';
zOut[i++] = 'l';
zOut[i++] = 't';
zOut[i++] = ';';
break;
case '>':
zOut[i++] = '&';
zOut[i++] = 'g';
zOut[i++] = 't';
zOut[i++] = ';';
break;
case '&':
zOut[i++] = '&';
zOut[i++] = 'a';
zOut[i++] = 'm';
zOut[i++] = 'p';
zOut[i++] = ';';
break;
case '"':
zOut[i++] = '&';
zOut[i++] = 'q';
zOut[i++] = 'u';
zOut[i++] = 'o';
zOut[i++] = 't';
zOut[i++] = ';';
break;
|
| ︙ | ︙ | |||
179 180 181 182 183 184 185 | } /* ** Convert the input string into a form that is suitable for use as ** a token in the HTTP protocol. Spaces are encoded as '+' and special ** characters are encoded as "%HH" where HH is a two-digit hexidecimal ** representation of the character. The "/" character is not encoded | | | 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
}
/*
** Convert the input string into a form that is suitable for use as
** a token in the HTTP protocol. Spaces are encoded as '+' and special
** characters are encoded as "%HH" where HH is a two-digit hexidecimal
** representation of the character. The "/" character is not encoded
** by this routine.
*/
char *urlize(const char *z, int n){
return EncodeHttp(z, n, 0);
}
/*
** Convert a single HEX digit to an integer
|
| ︙ | ︙ | |||
325 326 327 328 329 330 331 | if( z[j] ) z[j] = 0; } /* ** The characters used for HTTP base64 encoding. */ | | | 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 | if( z[j] ) z[j] = 0; } /* ** The characters used for HTTP base64 encoding. */ static unsigned char zBase[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; /* ** Encode a string using a base-64 encoding. ** The encoding can be reversed using the <b>decode64</b> function. ** ** Space to hold the result comes from malloc(). |
| ︙ | ︙ | |||
364 365 366 367 368 369 370 |
z64[n++] = '=';
}
z64[n] = 0;
return z64;
}
/*
| | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
z64[n++] = '=';
}
z64[n] = 0;
return z64;
}
/*
** COMMAND: test-encode64
** Usage: %fossil test-encode64 STRING
*/
void test_encode64_cmd(void){
char *z;
int i;
for(i=2; i<g.argc; i++){
z = encode64(g.argv[i], -1);
|
| ︙ | ︙ | |||
429 430 431 432 433 434 435 | } zData[j] = 0; *pnByte = j; return zData; } /* | | | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 |
}
zData[j] = 0;
*pnByte = j;
return zData;
}
/*
** COMMAND: test-decode64
** Usage: %fossil test-decode64 STRING
*/
void test_decode64_cmd(void){
char *z;
int i, n;
for(i=2; i<g.argc; i++){
z = decode64(g.argv[i], &n);
|
| ︙ | ︙ | |||
452 453 454 455 456 457 458 | ** 0123456789abcdef ** */ /* ** The array used for encoding */ /* 123456789 12345 */ | | | | | | | | | | | | | | | | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 |
** 0123456789abcdef
**
*/
/*
** The array used for encoding
*/ /* 123456789 12345 */
static const char zEncode[] = "0123456789abcdef";
/*
** Encode a N-digit base-256 in base-16. Return zero on success
** and non-zero if there is an error.
*/
int encode16(const unsigned char *pIn, unsigned char *zOut, int N){
int i;
for(i=0; i<N; i++){
*(zOut++) = zEncode[pIn[i]>>4];
*(zOut++) = zEncode[pIn[i]&0xf];
}
*zOut = 0;
return 0;
}
/*
** An array for translating single base-16 characters into a value.
** Disallowed input characters have a value of 64. Upper and lower
** case is the same.
*/
static const char zDecode[] = {
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 64, 64, 64, 64, 64, 64,
64, 10, 11, 12, 13, 14, 15, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 10, 11, 12, 13, 14, 15, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
};
/*
** Decode a N-character base-16 number into base-256. N must be a
** multiple of 2. The output buffer must be at least N/2 characters
** in length
*/
int decode16(const unsigned char *zIn, unsigned char *pOut, int N){
int i, j;
if( (N&1)!=0 ) return 1;
for(i=j=0; i<N; i += 2, j++){
|
| ︙ | ︙ | |||
543 544 545 546 547 548 549 |
}
/* Randomness used for XOR-ing by the obscure() and unobscure() routines */
static const unsigned char aObscurer[16] = {
0xa7, 0x21, 0x31, 0xe3, 0x2a, 0x50, 0x2c, 0x86,
0x4c, 0xa4, 0x52, 0x25, 0xff, 0x49, 0x35, 0x85
};
| | | | | | 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 |
}
/* Randomness used for XOR-ing by the obscure() and unobscure() routines */
static const unsigned char aObscurer[16] = {
0xa7, 0x21, 0x31, 0xe3, 0x2a, 0x50, 0x2c, 0x86,
0x4c, 0xa4, 0x52, 0x25, 0xff, 0x49, 0x35, 0x85
};
/*
** Obscure plain text so that it is not easily readable.
**
** This is used for storing sensitive information (such as passwords) in a
** way that prevents their exposure through idle browsing. This is not
** encryption. Anybody who really wants the password can still get it.
**
** The text is XOR-ed with a repeating pattern then converted to hex.
** Space to hold the returned string is obtained from malloc and should
** be freed by the caller.
*/
char *obscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
zOut = fossil_malloc( n*2+3 );
sqlite3_randomness(1, &salt);
zOut[n+1] = (char)salt;
for(i=0; i<n; i++) zOut[i+n+2] = zIn[i]^aObscurer[i&0x0f]^salt;
encode16((unsigned char*)&zOut[n+1], (unsigned char*)zOut, n+1);
return zOut;
}
/*
** Undo the obscuring of text performed by obscure(). Or, if the input is
** not hexadecimal (meaning the input is not the output of obscure()) then
** do the equivalent of strdup().
**
** The result is memory obtained from malloc that should be freed by the caller.
*/
char *unobscure(const char *zIn){
int n, i;
unsigned char salt;
char *zOut;
if( zIn==0 ) return 0;
n = strlen(zIn);
zOut = fossil_malloc( n + 1 );
if( n<2
|| decode16((unsigned char*)zIn, &salt, 2)
|| decode16((unsigned char*)&zIn[2], (unsigned char*)zOut, n-2)
){
|
| ︙ | ︙ |
Changes to src/event.c.
| ︙ | ︙ | |||
117 118 119 120 121 122 123 |
*/
pEvent = manifest_get(rid, CFTYPE_EVENT, 0);
if( pEvent==0 ){
fossil_fatal("Object #%d is not an event", rid);
}
blob_init(&fullbody, pEvent->zWiki, -1);
if( wiki_find_title(&fullbody, &title, &tail) ){
| | | 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
*/
pEvent = manifest_get(rid, CFTYPE_EVENT, 0);
if( pEvent==0 ){
fossil_fatal("Object #%d is not an event", rid);
}
blob_init(&fullbody, pEvent->zWiki, -1);
if( wiki_find_title(&fullbody, &title, &tail) ){
style_header("%s", blob_str(&title));
}else{
style_header("Event %S", zEventId);
tail = fullbody;
}
if( g.perm.WrWiki && g.perm.Write && nextRid==0 ){
style_submenu_element("Edit", "Edit", "%s/eventedit?name=%s",
g.zTop, zEventId);
|
| ︙ | ︙ | |||
201 202 203 204 205 206 207 |
** Edit an event. If name is omitted, create a new event.
*/
void eventedit_page(void){
char *zTag;
int rid = 0;
Blob event;
const char *zEventId;
| < | 201 202 203 204 205 206 207 208 209 210 211 212 213 214 |
** Edit an event. If name is omitted, create a new event.
*/
void eventedit_page(void){
char *zTag;
int rid = 0;
Blob event;
const char *zEventId;
int n;
const char *z;
char *zBody = (char*)P("w");
char *zETime = (char*)P("t");
const char *zComment = P("c");
const char *zTags = P("g");
const char *zClr;
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
if( P("cancel")!=0 ){
cgi_redirectf("event?name=%T", zEventId);
return;
}
if( zBody==0 ){
zBody = mprintf("<i>Event Text</i>");
}
| | < | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
if( P("cancel")!=0 ){
cgi_redirectf("event?name=%T", zEventId);
return;
}
if( zBody==0 ){
zBody = mprintf("<i>Event Text</i>");
}
style_header("Edit Event %S", zEventId);
if( P("preview")!=0 ){
Blob title, tail, com;
@ <p><b>Timeline comment preview:</b></p>
@ <blockquote>
@ <table border="0">
if( zClr && zClr[0] ){
@ <tr><td style="background-color: %h(zClr);">
|
| ︙ | ︙ |
Changes to src/export.c.
| ︙ | ︙ | |||
69 70 71 72 73 74 75 |
}
if( zContact[i]=='<' ){
/*
** Found beginning of email address. Look for the end and extract
** the part.
*/
zEmail = mprintf("%s", &zContact[i]);
| | | | 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
}
if( zContact[i]=='<' ){
/*
** Found beginning of email address. Look for the end and extract
** the part.
*/
zEmail = mprintf("%s", &zContact[i]);
for(j=0; zEmail[j] && zEmail[j]!='>'; j++){}
if( zEmail[j]=='>' ) zEmail[j+1] = 0;
}else{
/*
** Found an end marker for email, but nothing else.
*/
zEmail = mprintf("<%s>", zUser);
}
/*
|
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | db_finalize(&q); db_finalize(&q2); db_finalize(&q3); /* Output the commit records. */ db_prepare(&q, | | | | 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
db_finalize(&q);
db_finalize(&q2);
db_finalize(&q3);
/* Output the commit records.
*/
db_prepare(&q,
"SELECT strftime('%%s',mtime), objid, coalesce(ecomment,comment),"
" coalesce(euser,user),"
" (SELECT value FROM tagxref WHERE rid=objid AND tagid=%d)"
" FROM event"
" WHERE type='ci' AND NOT EXISTS (SELECT 1 FROM oldcommit WHERE objid=rid)"
" ORDER BY mtime ASC",
TAG_BRANCH
);
db_prepare(&q2, "INSERT INTO oldcommit VALUES (:rid)");
|
| ︙ | ︙ |
Changes to src/file.c.
| ︙ | ︙ | |||
1100 1101 1102 1103 1104 1105 1106 |
** a boolean: "yes", "no", "true", "false", etc.
*/
void cmd_test_tree_name(void){
int i;
Blob x;
db_find_and_open_repository(0,0);
blob_zero(&x);
| < | 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 |
** a boolean: "yes", "no", "true", "false", etc.
*/
void cmd_test_tree_name(void){
int i;
Blob x;
db_find_and_open_repository(0,0);
blob_zero(&x);
for(i=2; i<g.argc; i++){
if( file_tree_name(g.argv[i], &x, 1) ){
fossil_print("%s\n", blob_buffer(&x));
blob_reset(&x);
}
}
}
|
| ︙ | ︙ |
Changes to src/finfo.c.
| ︙ | ︙ | |||
54 55 56 57 58 59 60 |
** -W|--width <num> Width of lines (default is to auto-detect). Must be
** >22 or 0 (= no limit, resulting in a single line per
** entry).
**
** See also: artifact, cat, descendants, info, leaves
*/
void finfo_cmd(void){
| < > > > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
** -W|--width <num> Width of lines (default is to auto-detect). Must be
** >22 or 0 (= no limit, resulting in a single line per
** entry).
**
** See also: artifact, cat, descendants, info, leaves
*/
void finfo_cmd(void){
db_must_be_within_tree();
if( find_option("status","s",0) ){
Stmt q;
Blob line;
Blob fname;
int vid;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 ) usage("-s|--status FILENAME");
vid = db_lget_int("checkout", 0);
if( vid==0 ){
fossil_fatal("no checkout to finfo files in");
}
vfile_check_signature(vid, CKSIG_ENOTFILE);
|
| ︙ | ︙ | |||
113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
fossil_print("%s\n", blob_str(&line));
blob_reset(&fname);
blob_reset(&line);
}else if( find_option("print","p",0) ){
Blob record;
Blob fname;
const char *zRevision = find_option("revision", "r", 1);
file_tree_name(g.argv[2], &fname, 1);
if( zRevision ){
historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0);
}else{
int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
&fname, filename_collation());
| > > > | 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
fossil_print("%s\n", blob_str(&line));
blob_reset(&fname);
blob_reset(&line);
}else if( find_option("print","p",0) ){
Blob record;
Blob fname;
const char *zRevision = find_option("revision", "r", 1);
/* We should be done with options.. */
verify_all_options();
file_tree_name(g.argv[2], &fname, 1);
if( zRevision ){
historical_version_of_file(zRevision, blob_str(&fname), &record, 0,0,0,0);
}else{
int rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
&fname, filename_collation());
|
| ︙ | ︙ | |||
156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
iWidth = atoi(zWidth);
if( (iWidth!=0) && (iWidth<=22) ){
fossil_fatal("-W|--width value must be >22 or 0");
}
}else{
iWidth = -1;
}
if( g.argc!=3 ){
usage("?-l|--log? ?-b|--brief? FILENAME");
}
file_tree_name(g.argv[2], &fname, 1);
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
&fname, filename_collation());
if( rid==0 ){
| > > > > | 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 |
iWidth = atoi(zWidth);
if( (iWidth!=0) && (iWidth<=22) ){
fossil_fatal("-W|--width value must be >22 or 0");
}
}else{
iWidth = -1;
}
/* We should be done with options.. */
verify_all_options();
if( g.argc!=3 ){
usage("?-l|--log? ?-b|--brief? FILENAME");
}
file_tree_name(g.argv[2], &fname, 1);
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
&fname, filename_collation());
if( rid==0 ){
|
| ︙ | ︙ | |||
197 198 199 200 201 202 203 |
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
const char *zBr = db_column_text(&q, 5);
char *zOut;
if( zBr==0 ) zBr = "trunk";
if( iBrief ){
fossil_print("%s ", zDate);
| | | | | | 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 |
const char *zCom = db_column_text(&q, 3);
const char *zUser = db_column_text(&q, 4);
const char *zBr = db_column_text(&q, 5);
char *zOut;
if( zBr==0 ) zBr = "trunk";
if( iBrief ){
fossil_print("%s ", zDate);
zOut = mprintf(
"[%S] %s (user: %s, artifact: [%S], branch: %s)",
zCiUuid, zCom, zUser, zFileUuid, zBr);
comment_print(zOut, zCom, 11, iWidth, g.comFmtFlags);
fossil_free(zOut);
}else{
blob_reset(&line);
blob_appendf(&line, "%.10s ", zCiUuid);
blob_appendf(&line, "%.10s ", zDate);
blob_appendf(&line, "%8.8s ", zUser);
blob_appendf(&line, "%8.8s ", zBr);
blob_appendf(&line,"%-39.39s", zCom );
comment_print(blob_str(&line), zCom, 0, iWidth, g.comFmtFlags);
}
}
db_finalize(&q);
blob_reset(&fname);
}
}
|
| ︙ | ︙ | |||
239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
void cat_cmd(void){
int i;
int rc;
Blob content, fname;
const char *zRev;
db_find_and_open_repository(0, 0);
zRev = find_option("r","r",1);
for(i=2; i<g.argc; i++){
file_tree_name(g.argv[i], &fname, 1);
blob_zero(&content);
rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0);
if( rc==0 ){
fossil_fatal("no such file: %s", g.argv[i]);
}
| > > > > | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
void cat_cmd(void){
int i;
int rc;
Blob content, fname;
const char *zRev;
db_find_and_open_repository(0, 0);
zRev = find_option("r","r",1);
/* We should be done with options.. */
verify_all_options();
for(i=2; i<g.argc; i++){
file_tree_name(g.argv[i], &fname, 1);
blob_zero(&content);
rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0);
if( rc==0 ){
fossil_fatal("no such file: %s", g.argv[i]);
}
|
| ︙ | ︙ | |||
304 305 306 307 308 309 310 |
if( baseCheckin ) firstChngOnly = 1;
if( !firstChngOnly ) url_add_parameter(&url, "fco", "0");
zPrevDate[0] = 0;
zFilename = PD("name","");
url_add_parameter(&url, "name", zFilename);
blob_zero(&sql);
| | | | | | | | | | | | | 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
if( baseCheckin ) firstChngOnly = 1;
if( !firstChngOnly ) url_add_parameter(&url, "fco", "0");
zPrevDate[0] = 0;
zFilename = PD("name","");
url_add_parameter(&url, "name", zFilename);
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT"
" datetime(event.mtime%s)," /* Date of change */
" coalesce(event.ecomment, event.comment)," /* Check-in comment */
" coalesce(event.euser, event.user)," /* User who made chng */
" mlink.pid," /* Parent file rid */
" mlink.fid," /* File rid */
" (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
" (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* Current file uuid */
" (SELECT uuid FROM blob WHERE rid=mlink.mid)," /* Check-in uuid */
" event.bgcolor," /* Background color */
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
" AND tagxref.rid=mlink.mid)," /* Tags */
" mlink.mid," /* check-in ID */
" mlink.pfnid", /* Previous filename */
timeline_utc(), TAG_BRANCH
);
if( firstChngOnly ){
#if 0
blob_append_sql(&sql, ", min(event.mtime)");
#else
blob_append_sql(&sql,
", min(CASE (SELECT value FROM tagxref"
" WHERE tagtype>0 AND tagid=%d"
" AND tagxref.rid=mlink.mid)"
" WHEN 'trunk' THEN event.mtime-10000 ELSE event.mtime END)",
TAG_BRANCH);
#endif
}
blob_append_sql(&sql,
" FROM mlink, event"
" WHERE mlink.fnid IN (SELECT fnid FROM filename WHERE name=%Q)"
" AND event.objid=mlink.mid",
zFilename
);
if( baseCheckin ){
compute_direct_ancestors(baseCheckin, 10000000);
blob_append_sql(&sql," AND mlink.mid IN (SELECT rid FROM ancestor)");
}
if( (zA = P("a"))!=0 ){
blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zA);
url_add_parameter(&url, "a", zA);
}
if( (zB = P("b"))!=0 ){
blob_append_sql(&sql, " AND event.mtime<=julianday('%q')", zB);
url_add_parameter(&url, "b", zB);
}
if( firstChngOnly ){
blob_append_sql(&sql, " GROUP BY mlink.fid");
}
blob_append_sql(&sql," ORDER BY event.mtime DESC /*sort*/");
if( (n = atoi(PD("n","0")))>0 ){
blob_append_sql(&sql, " LIMIT %d", n);
url_add_parameter(&url, "n", P("n"));
}
if( baseCheckin==0 ){
if( firstChngOnly ){
style_submenu_element("Full", "Show all changes","%s",
url_render(&url, "fco", "0", 0, 0));
}else{
style_submenu_element("Simplified",
"Show only first use of a change","%s",
url_render(&url, "fco", 0, 0, 0));
}
}
db_prepare(&q, "%s", blob_sql_text(&sql));
if( P("showsql")!=0 ){
@ <p>SQL: %h(blob_str(&sql))</p>
}
blob_reset(&sql);
blob_zero(&title);
if( baseCheckin ){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", baseCheckin);
|
| ︙ | ︙ | |||
415 416 417 418 419 420 421 |
if( uBg ){
zBgClr = hash_color(zUser);
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr);
}
gidx = graph_add_row(pGraph, frid, fpid>0 ? 1 : 0, &fpid, zBr, zBgClr,
zUuid, 0);
| | | 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 |
if( uBg ){
zBgClr = hash_color(zUser);
}else if( brBg || zBgClr==0 || zBgClr[0]==0 ){
zBgClr = strcmp(zBr,"trunk")==0 ? "" : hash_color(zBr);
}
gidx = graph_add_row(pGraph, frid, fpid>0 ? 1 : 0, &fpid, zBr, zBgClr,
zUuid, 0);
if( strncmp(zDate, zPrevDate, 10) ){
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
@ <tr><td>
@ <div class="divider">%s(zPrevDate)</div>
@ </td><td></td><td></td></tr>
}
memcpy(zTime, &zDate[11], 5);
zTime[5] = 0;
|
| ︙ | ︙ | |||
458 459 460 461 462 463 464 |
@ %z(href("%R/finfo?name=%t",zNewName))%h(zNewName)</a> by check-in
fossil_free(zNewName);
}else{
@ <b>Deleted</b> by check-in
}
}
hyperlink_to_uuid(zCkin);
| | | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 |
@ %z(href("%R/finfo?name=%t",zNewName))%h(zNewName)</a> by check-in
fossil_free(zNewName);
}else{
@ <b>Deleted</b> by check-in
}
}
hyperlink_to_uuid(zCkin);
@ %W(zCom) (user:
hyperlink_to_user(zUser, zDate, "");
@ branch: %h(zBr))
if( g.perm.Hyperlink && zUuid ){
const char *z = zFilename;
@ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
|
| ︙ | ︙ |
Changes to src/graph.c.
| ︙ | ︙ | |||
32 33 34 35 36 37 38 |
*/
struct GraphRow {
int rid; /* The rid for the check-in */
i8 nParent; /* Number of parents */
int *aParent; /* Array of parents. 0 element is primary .*/
char *zBranch; /* Branch name */
char *zBgClr; /* Background Color */
| | | 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
*/
struct GraphRow {
int rid; /* The rid for the check-in */
i8 nParent; /* Number of parents */
int *aParent; /* Array of parents. 0 element is primary .*/
char *zBranch; /* Branch name */
char *zBgClr; /* Background Color */
char zUuid[41]; /* Check-in for file ID */
GraphRow *pNext; /* Next row down in the list of all rows */
GraphRow *pPrev; /* Previous row */
int idx; /* Row index. First is 1. 0 used for "none" */
int idxTop; /* Direct descendent highest up on the graph */
GraphRow *pChild; /* Child immediately above this node */
|
| ︙ | ︙ |
Changes to src/gzip.c.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 | ** file. The GZIP format is described in RFC-1952. ** ** State information is stored in static variables, so this implementation ** can only be building up a single GZIP file at a time. */ #include "config.h" #include <assert.h> | > > > > | > | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
** file. The GZIP format is described in RFC-1952.
**
** State information is stored in static variables, so this implementation
** can only be building up a single GZIP file at a time.
*/
#include "config.h"
#include <assert.h>
#if defined(FOSSIL_ENABLE_MINIZ)
# define MINIZ_HEADER_FILE_ONLY
# include "miniz.c"
#else
# include <zlib.h>
#endif
#include "gzip.h"
/*
** State information for the GZIP file under construction.
*/
struct gzip_state {
int eState; /* 0: idle 1: header 2: compressing */
|
| ︙ | ︙ |
Changes to src/http.c.
| ︙ | ︙ | |||
77 78 79 80 81 82 83 |
}else{
/* Password failure while doing a sync from the command-line interface */
url_prompt_for_password();
zPw = g.url.passwd;
}
/* The login card wants the SHA1 hash of the password, so convert the
| | | 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
}else{
/* Password failure while doing a sync from the command-line interface */
url_prompt_for_password();
zPw = g.url.passwd;
}
/* The login card wants the SHA1 hash of the password, so convert the
** password to its SHA1 hash if it isn't already a SHA1 hash.
*/
/* fossil_print("\nzPw=[%s]\n", zPw); // TESTING ONLY */
if( zPw && zPw[0] ) zPw = sha1_shared_secret(zPw, zLogin, 0);
blob_append(&pw, zPw, -1);
sha1sum_blob(&pw, &sig);
blob_appendf(pLogin, "login %F %b %b\n", zLogin, &nonce, &sig);
|
| ︙ | ︙ | |||
165 166 167 168 169 170 171 |
char *zUser;
char *zPw;
char *zPrompt;
char *zHttpAuth = 0;
if( !isatty(fileno(stdin)) ) return 0;
zPrompt = mprintf("\n%s authorization required by\n%s\n",
g.url.isHttps==1 ? "Encrypted HTTPS" : "Unencrypted HTTP", g.url.canonical);
| | | 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
char *zUser;
char *zPw;
char *zPrompt;
char *zHttpAuth = 0;
if( !isatty(fileno(stdin)) ) return 0;
zPrompt = mprintf("\n%s authorization required by\n%s\n",
g.url.isHttps==1 ? "Encrypted HTTPS" : "Unencrypted HTTP", g.url.canonical);
fossil_print("%s", zPrompt);
free(zPrompt);
if ( g.url.user && g.url.passwd && use_fossil_creds_for_httpauth_prompt() ){
zHttpAuth = mprintf("%s:%s", g.url.user, g.url.passwd);
}else{
prompt_user("Basic Authorization user: ", &x);
zUser = mprintf("%b", &x);
zPrompt = mprintf("HTTP password for %b: ", &x);
|
| ︙ | ︙ | |||
212 213 214 215 216 217 218 |
int iHttpVersion; /* Which version of HTTP protocol server uses */
char *zLine; /* A single line of the reply header */
int i; /* Loop counter */
int isError = 0; /* True if the reply is an error message */
int isCompressed = 1; /* True if the reply is compressed */
if( transport_open(&g.url) ){
| | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
int iHttpVersion; /* Which version of HTTP protocol server uses */
char *zLine; /* A single line of the reply header */
int i; /* Loop counter */
int isError = 0; /* True if the reply is an error message */
int isCompressed = 1; /* True if the reply is compressed */
if( transport_open(&g.url) ){
fossil_warning("%s", transport_errmsg(&g.url));
return 1;
}
/* Construct the login card and prepare the complete payload */
blob_zero(&login);
if( useLogin ) http_build_login_card(pSend, &login);
if( g.fHttpTrace ){
|
| ︙ | ︙ |
Changes to src/http_transport.c.
| ︙ | ︙ | |||
255 256 257 258 259 260 261 |
** This routine is called when the outbound message is complete and
** it is time to being receiving a reply.
*/
void transport_flip(UrlData *pUrlData){
if( pUrlData->isFile ){
char *zCmd;
fclose(transport.pFile);
| | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 |
** This routine is called when the outbound message is complete and
** it is time to being receiving a reply.
*/
void transport_flip(UrlData *pUrlData){
if( pUrlData->isFile ){
char *zCmd;
fclose(transport.pFile);
zCmd = mprintf("\"%s\" http \"%s\" \"%s\" 127.0.0.1 \"%s\" --localauth",
g.nameOfExe, transport.zOutFile, transport.zInFile, pUrlData->name
);
fossil_system(zCmd);
free(zCmd);
transport.pFile = fossil_fopen(transport.zInFile, "rb");
}
}
|
| ︙ | ︙ |
Changes to src/import.c.
| ︙ | ︙ | |||
212 213 214 215 216 217 218 |
return fossil_strcmp(pA->zName, pB->zName);
}
/*
** Compare two strings for sorting.
*/
static int string_cmp(const void *pLeft, const void *pRight){
| | | | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 |
return fossil_strcmp(pA->zName, pB->zName);
}
/*
** Compare two strings for sorting.
*/
static int string_cmp(const void *pLeft, const void *pRight){
const char *zLeft = *(const char **)pLeft;
const char *zRight = *(const char **)pRight;
return fossil_strcmp(zLeft, zRight);
}
/* Forward reference */
static void import_prior_files(void);
/*
|
| ︙ | ︙ | |||
441 442 443 444 445 446 447 |
** Do not search past the mx-th file.
*/
static ImportFile *import_find_file(const char *zName, int *pI, int mx){
int i = *pI;
int nName = strlen(zName);
while( i<mx ){
const char *z = gg.aFile[i].zName;
| | | 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 |
** Do not search past the mx-th file.
*/
static ImportFile *import_find_file(const char *zName, int *pI, int mx){
int i = *pI;
int nName = strlen(zName);
while( i<mx ){
const char *z = gg.aFile[i].zName;
if( strncmp(zName, z, nName)==0 && (z[nName]==0 || z[nName]=='/') ){
*pI = i+1;
return &gg.aFile[i];
}
i++;
}
return 0;
}
|
| ︙ | ︙ | |||
486 487 488 489 490 491 492 |
char *zFrom;
char *zTo;
char zLine[1000];
gg.xFinish = finish_noop;
while( fgets(zLine, sizeof(zLine), pIn) ){
if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
| | | | 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
char *zFrom;
char *zTo;
char zLine[1000];
gg.xFinish = finish_noop;
while( fgets(zLine, sizeof(zLine), pIn) ){
if( zLine[0]=='\n' || zLine[0]=='#' ) continue;
if( strncmp(zLine, "blob", 4)==0 ){
gg.xFinish();
gg.xFinish = finish_blob;
}else
if( strncmp(zLine, "commit ", 7)==0 ){
gg.xFinish();
gg.xFinish = finish_commit;
trim_newline(&zLine[7]);
z = &zLine[7];
/* The argument to the "commit" line might match either of these
** patterns:
|
| ︙ | ︙ | |||
515 516 517 518 519 520 521 |
** of pattern B with the same TAGNAME, then only put the tag on the
** last commit that holds that tag.
**
** None of the above is explained in the git-fast-export
** documentation. We had to figure it out via trial and error.
*/
for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
| | | | | | | | | | | | | | | | | | 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 |
** of pattern B with the same TAGNAME, then only put the tag on the
** last commit that holds that tag.
**
** None of the above is explained in the git-fast-export
** documentation. We had to figure it out via trial and error.
*/
for(i=strlen(z)-1; i>=0 && z[i]!='/'; i--){}
gg.tagCommit = strncmp(&z[i-4], "tags", 4)==0; /* True for pattern B */
if( z[i+1]!=0 ) z += i+1;
if( fossil_strcmp(z, "master")==0 ) z = "trunk";
gg.zBranch = fossil_strdup(z);
gg.fromLoaded = 0;
}else
if( strncmp(zLine, "tag ", 4)==0 ){
gg.xFinish();
gg.xFinish = finish_tag;
trim_newline(&zLine[4]);
gg.zTag = fossil_strdup(&zLine[4]);
}else
if( strncmp(zLine, "reset ", 4)==0 ){
gg.xFinish();
}else
if( strncmp(zLine, "checkpoint", 10)==0 ){
gg.xFinish();
}else
if( strncmp(zLine, "feature", 7)==0 ){
gg.xFinish();
}else
if( strncmp(zLine, "option", 6)==0 ){
gg.xFinish();
}else
if( strncmp(zLine, "progress ", 9)==0 ){
gg.xFinish();
trim_newline(&zLine[9]);
fossil_print("%s\n", &zLine[9]);
fflush(stdout);
}else
if( strncmp(zLine, "data ", 5)==0 ){
fossil_free(gg.aData); gg.aData = 0;
gg.nData = atoi(&zLine[5]);
if( gg.nData ){
int got;
gg.aData = fossil_malloc( gg.nData+1 );
got = fread(gg.aData, 1, gg.nData, pIn);
if( got!=gg.nData ){
fossil_fatal("short read: got %d of %d bytes", got, gg.nData);
}
gg.aData[got] = 0;
if( gg.zComment==0 && gg.xFinish==finish_commit ){
gg.zComment = gg.aData;
gg.aData = 0;
gg.nData = 0;
}
}
}else
if( strncmp(zLine, "author ", 7)==0 ){
/* No-op */
}else
if( strncmp(zLine, "mark ", 5)==0 ){
trim_newline(&zLine[5]);
fossil_free(gg.zMark);
gg.zMark = fossil_strdup(&zLine[5]);
}else
if( strncmp(zLine, "tagger ", 7)==0 || strncmp(zLine, "committer ",10)==0 ){
sqlite3_int64 secSince1970;
for(i=0; zLine[i] && zLine[i]!='<'; i++){}
if( zLine[i]==0 ) goto malformed_line;
z = &zLine[i+1];
for(i=i+1; zLine[i] && zLine[i]!='>'; i++){}
if( zLine[i]==0 ) goto malformed_line;
zLine[i] = 0;
fossil_free(gg.zUser);
gg.zUser = fossil_strdup(z);
secSince1970 = 0;
for(i=i+2; fossil_isdigit(zLine[i]); i++){
secSince1970 = secSince1970*10 + zLine[i] - '0';
}
fossil_free(gg.zDate);
gg.zDate = db_text(0, "SELECT datetime(%lld, 'unixepoch')", secSince1970);
gg.zDate[10] = 'T';
}else
if( strncmp(zLine, "from ", 5)==0 ){
trim_newline(&zLine[5]);
fossil_free(gg.zFromMark);
gg.zFromMark = fossil_strdup(&zLine[5]);
fossil_free(gg.zFrom);
gg.zFrom = resolve_committish(&zLine[5]);
}else
if( strncmp(zLine, "merge ", 6)==0 ){
trim_newline(&zLine[6]);
if( gg.nMerge>=gg.nMergeAlloc ){
gg.nMergeAlloc = gg.nMergeAlloc*2 + 10;
gg.azMerge = fossil_realloc(gg.azMerge, gg.nMergeAlloc*sizeof(char*));
}
gg.azMerge[gg.nMerge] = resolve_committish(&zLine[6]);
if( gg.azMerge[gg.nMerge] ) gg.nMerge++;
}else
if( strncmp(zLine, "M ", 2)==0 ){
import_prior_files();
z = &zLine[2];
zPerm = next_token(&z);
zUuid = next_token(&z);
zName = rest_of_line(&z);
dequote_git_filename(zName);
i = 0;
pFile = import_find_file(zName, &i, gg.nFile);
if( pFile==0 ){
pFile = import_add_file();
pFile->zName = fossil_strdup(zName);
}
pFile->isExe = (fossil_strcmp(zPerm, "100755")==0);
pFile->isLink = (fossil_strcmp(zPerm, "120000")==0);
fossil_free(pFile->zUuid);
pFile->zUuid = resolve_committish(zUuid);
pFile->isFrom = 0;
}else
if( strncmp(zLine, "D ", 2)==0 ){
import_prior_files();
z = &zLine[2];
zName = rest_of_line(&z);
dequote_git_filename(zName);
i = 0;
while( (pFile = import_find_file(zName, &i, gg.nFile))!=0 ){
if( pFile->isFrom==0 ) continue;
fossil_free(pFile->zName);
fossil_free(pFile->zPrior);
fossil_free(pFile->zUuid);
*pFile = gg.aFile[--gg.nFile];
i--;
}
}else
if( strncmp(zLine, "C ", 2)==0 ){
int nFrom;
import_prior_files();
z = &zLine[2];
zFrom = next_token(&z);
zTo = rest_of_line(&z);
i = 0;
mx = gg.nFile;
|
| ︙ | ︙ | |||
663 664 665 666 667 668 669 |
}
pNew->isExe = pFile->isExe;
pNew->isLink = pFile->isLink;
pNew->zUuid = fossil_strdup(pFile->zUuid);
pNew->isFrom = 0;
}
}else
| | | 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
}
pNew->isExe = pFile->isExe;
pNew->isLink = pFile->isLink;
pNew->zUuid = fossil_strdup(pFile->zUuid);
pNew->isFrom = 0;
}
}else
if( strncmp(zLine, "R ", 2)==0 ){
int nFrom;
import_prior_files();
z = &zLine[2];
zFrom = next_token(&z);
zTo = rest_of_line(&z);
i = 0;
nFrom = strlen(zFrom);
|
| ︙ | ︙ | |||
691 692 693 694 695 696 697 |
pNew->isFrom = 0;
gg.nFile--;
*pFile = *pNew;
memset(pNew, 0, sizeof(*pNew));
}
fossil_fatal("cannot handle R records, use --full-tree");
}else
| | | | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 |
pNew->isFrom = 0;
gg.nFile--;
*pFile = *pNew;
memset(pNew, 0, sizeof(*pNew));
}
fossil_fatal("cannot handle R records, use --full-tree");
}else
if( strncmp(zLine, "deleteall", 9)==0 ){
gg.fromLoaded = 1;
}else
if( strncmp(zLine, "N ", 2)==0 ){
/* No-op */
}else
{
goto malformed_line;
}
}
|
| ︙ | ︙ |
Changes to src/info.c.
| ︙ | ︙ | |||
130 131 132 133 134 135 136 |
zTags = info_tags_of_checkin(rid, 0);
if( zTags && zTags[0] ){
fossil_print("tags: %s\n", zTags);
}
free(zTags);
if( zComment ){
fossil_print("comment: ");
| | | 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
zTags = info_tags_of_checkin(rid, 0);
if( zTags && zTags[0] ){
fossil_print("tags: %s\n", zTags);
}
free(zTags);
if( zComment ){
fossil_print("comment: ");
comment_print(zComment, 0, 14, -1, g.comFmtFlags);
free(zComment);
}
}
/*
** Print information about the URLs used to access a repository and
** checkouts in a repository.
|
| ︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 |
*/
void info_cmd(void){
i64 fsize;
int verboseFlag = find_option("verbose","v",0)!=0;
if( !verboseFlag ){
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
}
if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
db_open_config(0);
| > > > > < > | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
*/
void info_cmd(void){
i64 fsize;
int verboseFlag = find_option("verbose","v",0)!=0;
if( !verboseFlag ){
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
}
/* We should be done with options.. */
verify_all_options();
if( g.argc==3 && (fsize = file_size(g.argv[2]))>0 && (fsize&0x1ff)==0 ){
db_open_config(0);
db_open_repository(g.argv[2]);
db_record_repository_filename(g.argv[2]);
fossil_print("project-name: %s\n", db_get("project-name", "<unnamed>"));
fossil_print("project-code: %s\n", db_get("project-code", "<none>"));
extraRepoInfo();
return;
}
db_find_and_open_repository(0,0);
if( g.argc==2 ){
|
| ︙ | ︙ | |||
529 530 531 532 533 534 535 |
" WHERE blob.rid=%d"
" AND event.objid=%d",
timeline_utc(), timeline_utc(), rid, rid
);
sideBySide = !is_false(PD("sbs","1"));
if( db_step(&q1)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q1, 0);
| < | < | 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 |
" WHERE blob.rid=%d"
" AND event.objid=%d",
timeline_utc(), timeline_utc(), rid, rid
);
sideBySide = !is_false(PD("sbs","1"));
if( db_step(&q1)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q1, 0);
char *zEUser, *zEComment;
const char *zUser;
const char *zComment;
const char *zDate;
const char *zOrigDate;
style_header("Check-in [%S]", zUuid);
login_anonymous_available();
zEUser = db_text(0,
"SELECT value FROM tagxref"
" WHERE tagid=%d AND rid=%d AND tagtype>0",
TAG_USER, rid);
zEComment = db_text(0,
"SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
TAG_COMMENT, rid);
|
| ︙ | ︙ | |||
758 759 760 761 762 763 764 |
@ No such object: %h(P("name"))
style_footer();
return;
}
if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
if( strcmp(zModAction,"delete")==0 ){
moderation_disapprove(rid);
| > > > > > > | | > > > > | 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 |
@ No such object: %h(P("name"))
style_footer();
return;
}
if( g.perm.ModWiki && (zModAction = P("modaction"))!=0 ){
if( strcmp(zModAction,"delete")==0 ){
moderation_disapprove(rid);
/*
** Next, check if the wiki page still exists; if not, we cannot
** redirect to it.
*/
if( db_exists("SELECT 1 FROM tagxref JOIN tag USING(tagid)"
" WHERE rid=%d AND tagname LIKE 'wiki-%%'", rid) ){
cgi_redirectf("%R/wiki?name=%T", pWiki->zWikiTitle);
/*NOTREACHED*/
}else{
cgi_redirectf("%R/modreq");
/*NOTREACHED*/
}
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
style_header("Update of \"%h\"", pWiki->zWikiTitle);
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
|
| ︙ | ︙ | |||
985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
zFrom = P("from");
zTo = P("to");
if(zGlob && !*zGlob){
zGlob = NULL;
}
diffFlags = construct_diff_flags(verboseFlag, sideBySide);
zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
if( sideBySide || verboseFlag ){
style_submenu_element("Hide Diff", "hidediff",
"%R/vdiff?from=%T&to=%T&sbs=0%s%T%s",
zFrom, zTo,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( !sideBySide ){
| > > | 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 |
zFrom = P("from");
zTo = P("to");
if(zGlob && !*zGlob){
zGlob = NULL;
}
diffFlags = construct_diff_flags(verboseFlag, sideBySide);
zW = (diffFlags&DIFF_IGNORE_ALLWS)?"&w":"";
style_submenu_element("Path","path",
"%R/timeline?me=%T&you=%T", zFrom, zTo);
if( sideBySide || verboseFlag ){
style_submenu_element("Hide Diff", "hidediff",
"%R/vdiff?from=%T&to=%T&sbs=0%s%T%s",
zFrom, zTo,
zGlob ? "&glob=" : "", zGlob ? zGlob : "", zW);
}
if( !sideBySide ){
|
| ︙ | ︙ | |||
1057 1058 1059 1060 1061 1062 1063 |
cmp = +1;
}else if( pFileTo==0 ){
cmp = -1;
}else{
cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName);
}
if( cmp<0 ){
| | | | | | 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 |
cmp = +1;
}else if( pFileTo==0 ){
cmp = -1;
}else{
cmp = fossil_strcmp(pFileFrom->zName, pFileTo->zName);
}
if( cmp<0 ){
if( !zGlob || sqlite3_strglob(zGlob, pFileFrom->zName)==0 ){
append_file_change_line(pFileFrom->zName,
pFileFrom->zUuid, 0, 0, diffFlags, pRe, 0);
}
pFileFrom = manifest_file_next(pFrom, 0);
}else if( cmp>0 ){
if( !zGlob || sqlite3_strglob(zGlob, pFileTo->zName)==0 ){
append_file_change_line(pFileTo->zName,
0, pFileTo->zUuid, 0, diffFlags, pRe,
manifest_file_mperm(pFileTo));
}
pFileTo = manifest_file_next(pTo, 0);
}else if( fossil_strcmp(pFileFrom->zUuid, pFileTo->zUuid)==0 ){
pFileFrom = manifest_file_next(pFrom, 0);
pFileTo = manifest_file_next(pTo, 0);
}else{
if(!zGlob || (sqlite3_strglob(zGlob, pFileFrom->zName)==0
|| sqlite3_strglob(zGlob, pFileTo->zName)==0) ){
append_file_change_line(pFileFrom->zName,
pFileFrom->zUuid,
pFileTo->zUuid, 0, diffFlags, pRe,
manifest_file_mperm(pFileTo));
}
pFileFrom = manifest_file_next(pFrom, 0);
pFileTo = manifest_file_next(pTo, 0);
|
| ︙ | ︙ | |||
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 | #define OBJTYPE_WIKI 0x0004 #define OBJTYPE_TICKET 0x0008 #define OBJTYPE_ATTACHMENT 0x0010 #define OBJTYPE_EVENT 0x0020 #define OBJTYPE_TAG 0x0040 #define OBJTYPE_SYMLINK 0x0080 #define OBJTYPE_EXE 0x0100 #endif /* ** Write a description of an object to the www reply. ** ** If the object is a file then mention: ** ** * It's artifact ID ** * All its filenames ** * The check-in it was part of, with times and users ** ** If the object is a manifest, then mention: ** ** * It's artifact ID ** * date of check-in ** * Comment & user */ int object_description( int rid, /* The artifact ID */ | > > > > > > | | | 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 |
#define OBJTYPE_WIKI 0x0004
#define OBJTYPE_TICKET 0x0008
#define OBJTYPE_ATTACHMENT 0x0010
#define OBJTYPE_EVENT 0x0020
#define OBJTYPE_TAG 0x0040
#define OBJTYPE_SYMLINK 0x0080
#define OBJTYPE_EXE 0x0100
/*
** Possible flags for the second parameter to
** object_description()
*/
#define OBJDESC_DETAIL 0x0001 /* more detail */
#endif
/*
** Write a description of an object to the www reply.
**
** If the object is a file then mention:
**
** * It's artifact ID
** * All its filenames
** * The check-in it was part of, with times and users
**
** If the object is a manifest, then mention:
**
** * It's artifact ID
** * date of check-in
** * Comment & user
*/
int object_description(
int rid, /* The artifact ID */
u32 objdescFlags, /* Flags to control display */
Blob *pDownloadName /* Fill with an appropriate download name */
){
Stmt q;
int cnt = 0;
int nWiki = 0;
int objType = 0;
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
int showDetail = (objdescFlags & OBJDESC_DETAIL)!=0;
char *prevName = 0;
db_prepare(&q,
"SELECT filename.name, datetime(event.mtime),"
" coalesce(event.ecomment,event.comment),"
" coalesce(event.euser,event.user),"
" b.uuid, mlink.mperm,"
|
| ︙ | ︙ | |||
1158 1159 1160 1161 1162 1163 1164 |
const char *zName = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zVers = db_column_text(&q, 4);
int mPerm = db_column_int(&q, 5);
const char *zBr = db_column_text(&q, 6);
| | > > > > > > > > > | > > | | > > > | | > > > | | | 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 |
const char *zName = db_column_text(&q, 0);
const char *zDate = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 2);
const char *zUser = db_column_text(&q, 3);
const char *zVers = db_column_text(&q, 4);
int mPerm = db_column_int(&q, 5);
const char *zBr = db_column_text(&q, 6);
int sameFilename = prevName!=0 && fossil_strcmp(zName,prevName)==0;
if( sameFilename && !showDetail ){
if( cnt==1 ){
@ %z(href("%R/whatis/%s",zUuid))[more...]</a>
}
cnt++;
continue;
}
if( !sameFilename ){
if( prevName ) {
@ </ul>
}
if( mPerm==PERM_LNK ){
@ <li>Symbolic link
objType |= OBJTYPE_SYMLINK;
}else if( mPerm==PERM_EXE ){
@ <li>Executable file
objType |= OBJTYPE_EXE;
}else{
@ <li>File
}
objType |= OBJTYPE_CONTENT;
@ %z(href("%R/finfo?name=%T",zName))%h(zName)</a>
if( showDetail ){
@ <ul>
}
prevName = fossil_strdup(zName);
}
if( showDetail ){
@ <li>
hyperlink_to_date(zDate,"");
@ — part of check-in
hyperlink_to_uuid(zVers);
}else{
@ — part of checkin
hyperlink_to_uuid(zVers);
@ at
hyperlink_to_date(zDate,"");
}
if( zBr && zBr[0] ){
@ on branch %z(href("%R/timeline?r=%T",zBr))%h(zBr)</a>
}
@ — %!w(zCom) (user:
hyperlink_to_user(zUser,zDate,")");
if( g.perm.Hyperlink ){
@ %z(href("%R/finfo?name=%T&ci=%s",zName,zVers))[ancestry]</a>
@ %z(href("%R/annotate?filename=%T&checkin=%s",zName,zVers))
@ [annotate]</a>
@ %z(href("%R/blame?filename=%T&checkin=%s",zName,zVers))
@ [blame]</a>
}
cnt++;
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_append(pDownloadName, zName, -1);
}
}
if( prevName && showDetail ){
@ </ul>
}
@ </ul>
free(prevName);
db_finalize(&q);
db_prepare(&q,
"SELECT substr(tagname, 6, 10000), datetime(event.mtime),"
|
| ︙ | ︙ | |||
1325 1326 1327 1328 1329 1330 1331 |
}
db_finalize(&q);
if( cnt==0 ){
@ Control artifact.
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_appendf(pDownloadName, "%.10s.txt", zUuid);
}
| < < > > > > > > | 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 |
}
db_finalize(&q);
if( cnt==0 ){
@ Control artifact.
if( pDownloadName && blob_size(pDownloadName)==0 ){
blob_appendf(pDownloadName, "%.10s.txt", zUuid);
}
}
return objType;
}
/*
** WEBPAGE: fdiff
** URL: fdiff?v1=UUID&v2=UUID&patch&sbs=BOOLEAN®ex=REGEX
**
** Two arguments, v1 and v2, identify the files to be diffed. Show the
** difference between the two artifacts. Show diff side by side unless sbs
** is 0. Generate plaintext if "patch" is present.
**
** Additional parameters:
**
** verbose Show more detail when describing artifacts
*/
void diff_page(void){
int v1, v2;
int isPatch;
int sideBySide;
char *zV1;
char *zV2;
const char *zRe;
const char *zW; /* URL param for ignoring whitespace */
ReCompiled *pRe = 0;
u64 diffFlags;
u32 objdescFlags = 0;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
v1 = name_to_rid_www("v1");
v2 = name_to_rid_www("v2");
if( v1==0 || v2==0 ) fossil_redirect_home();
zRe = P("regex");
if( zRe ) re_compile(&pRe, zRe, 0);
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
isPatch = P("patch")!=0;
if( isPatch ){
Blob c1, c2, *pOut;
pOut = cgi_output_blob();
cgi_set_content_type("text/plain");
diffFlags = 4;
content_get(v1, &c1);
|
| ︙ | ︙ | |||
1407 1408 1409 1410 1411 1412 1413 |
if( P("smhdr")!=0 ){
@ <h2>Differences From Artifact
@ %z(href("%R/artifact/%s",zV1))[%S(zV1)]</a> To
@ %z(href("%R/artifact/%s",zV2))[%S(zV2)]</a>.</h2>
}else{
@ <h2>Differences From
@ Artifact %z(href("%R/artifact/%s",zV1))[%S(zV1)]</a>:</h2>
| | | | 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 |
if( P("smhdr")!=0 ){
@ <h2>Differences From Artifact
@ %z(href("%R/artifact/%s",zV1))[%S(zV1)]</a> To
@ %z(href("%R/artifact/%s",zV2))[%S(zV2)]</a>.</h2>
}else{
@ <h2>Differences From
@ Artifact %z(href("%R/artifact/%s",zV1))[%S(zV1)]</a>:</h2>
object_description(v1, objdescFlags, 0);
@ <h2>To Artifact %z(href("%R/artifact/%s",zV2))[%S(zV2)]</a>:</h2>
object_description(v2, objdescFlags, 0);
}
if( pRe ){
@ <b>Only differences that match regular expression "%h(zRe)"
@ are shown.</b>
}
@ <hr />
append_diff(zV1, zV2, diffFlags, pRe);
|
| ︙ | ︙ | |||
1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 |
/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
*/
void hexdump_page(void){
int rid;
Blob content;
Blob downloadName;
char *zUuid;
rid = name_to_rid_www("name");
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if( rid==0 ) fossil_redirect_home();
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
| > > > > > | > | | 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 |
/*
** WEBPAGE: hexdump
** URL: /hexdump?name=ARTIFACTID
**
** Show the complete content of a file identified by ARTIFACTID
** as preformatted text.
**
** Other parameters:
**
** verbose Show more detail when describing the object
*/
void hexdump_page(void){
int rid;
Blob content;
Blob downloadName;
char *zUuid;
u32 objdescFlags = 0;
rid = name_to_rid_www("name");
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if( rid==0 ) fossil_redirect_home();
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#delshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
style_header("Hex Artifact Content");
zUuid = db_text("?","SELECT uuid FROM blob WHERE rid=%d", rid);
if( g.perm.Setup ){
@ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
}else{
@ <h2>Artifact %s(zUuid):</h2>
}
blob_zero(&downloadName);
if( P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
object_description(rid, objdescFlags, &downloadName);
style_submenu_element("Download", "Download",
"%s/raw/%T?name=%s", g.zTop, blob_str(&downloadName), zUuid);
@ <hr />
content_get(rid, &content);
@ <blockquote><pre>
hexdump(&content);
@ </pre></blockquote>
|
| ︙ | ︙ | |||
1673 1674 1675 1676 1677 1678 1679 1680 |
if( iStart ){
@ <script>gebi('topln').scrollIntoView(true);</script>
}
}
/*
** WEBPAGE: artifact
| > > | > > | | > > > > | > | | | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 |
if( iStart ){
@ <script>gebi('topln').scrollIntoView(true);</script>
}
}
/*
** WEBPAGE: whatis
** WEBPAGE: artifact
**
** URL: /artifact/SHA1HASH
** URL: /artifact?ci=CHECKIN&filename=PATH
** URL: /whatis/SHA1HASH
**
** Additional query parameters:
**
** ln - show line numbers
** ln=N - highlight line number N
** ln=M-N - highlight lines M through N inclusive
** verbose - show more detail in the description
**
** The /artifact page show the complete content of a file
** identified by SHA1HASH as preformatted text. The
** /whatis page shows only a description of the file.
*/
void artifact_page(void){
int rid = 0;
Blob content;
const char *zMime;
Blob downloadName;
int renderAsWiki = 0;
int renderAsHtml = 0;
int objType;
int asText;
const char *zUuid;
u32 objdescFlags = 0;
int descOnly = fossil_strcmp(g.zPath,"whatis")==0;
const char *zLn = P("ln");
if( P("ci") && P("filename") ){
rid = artifact_from_ci_and_filename_www();
}
if( rid==0 ){
rid = name_to_rid_www("name");
}
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if( rid==0 ) fossil_redirect_home();
if( g.perm.Admin ){
const char *zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
if( descOnly || P("verbose")!=0 ) objdescFlags |= OBJDESC_DETAIL;
style_header("%s", descOnly ? "Artifact Description" : "Artifact Content");
zUuid = db_text("?", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( g.perm.Setup ){
@ <h2>Artifact %s(zUuid) (%d(rid)):</h2>
}else{
@ <h2>Artifact %s(zUuid):</h2>
}
blob_zero(&downloadName);
objType = object_description(rid, objdescFlags, &downloadName);
style_submenu_element("Download", "Download",
"%R/raw/%T?name=%s", blob_str(&downloadName), zUuid);
if( db_exists("SELECT 1 FROM mlink WHERE fid=%d", rid) ){
style_submenu_element("Checkins Using", "Checkins Using",
"%R/timeline?n=200&uf=%s",zUuid);
}
asText = P("txt")!=0;
|
| ︙ | ︙ | |||
1759 1760 1761 1762 1763 1764 1765 |
"%s/artifact/%s?txt=1", g.zTop, zUuid);
}
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid);
}
| > > > > > > | | | | | | | | | | | | | | | | < | | | | | | | | | | | | | | | | | > | 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 |
"%s/artifact/%s?txt=1", g.zTop, zUuid);
}
}
}
if( (objType & (OBJTYPE_WIKI|OBJTYPE_TICKET))!=0 ){
style_submenu_element("Parsed", "Parsed", "%R/info/%s", zUuid);
}
if( descOnly ){
style_submenu_element("Content", "Content", "%R/artifact/%s", zUuid);
}else{
style_submenu_element("Line Numbers", "Line Numbers",
"%R/info/%s%s",zUuid,
((zLn&&*zLn) ? "" : "?ln=0"));
@ <hr />
content_get(rid, &content);
if( renderAsWiki ){
wiki_render_by_mimetype(&content, zMime);
}else if( renderAsHtml ){
@ <iframe src="%R/raw/%T(blob_str(&downloadName))?name=%s(zUuid)"
@ width="100%%" frameborder="0" marginwidth="0" marginheight="0"
@ sandbox="allow-same-origin"
@ onload="this.height = this.contentDocument.documentElement.scrollHeight;">
@ </iframe>
}else{
style_submenu_element("Hex","Hex", "%s/hexdump?name=%s", g.zTop, zUuid);
blob_to_utf8_no_bom(&content, 0);
zMime = mimetype_from_content(&content);
@ <blockquote>
if( zMime==0 ){
const char *z;
z = blob_str(&content);
if( zLn ){
output_text_with_line_numbers(z, zLn);
}else{
@ <pre>
@ %h(z)
@ </pre>
}
}else if( strncmp(zMime, "image/", 6)==0 ){
@ <img src="%R/raw/%s(zUuid)?m=%s(zMime)" />
style_submenu_element("Image", "Image",
"%R/raw/%s?m=%s", zUuid, zMime);
}else{
@ <i>(file is %d(blob_size(&content)) bytes of binary data)</i>
}
@ </blockquote>
}
}
style_footer();
}
/*
** WEBPAGE: tinfo
** URL: /tinfo?name=ARTIFACTID
|
| ︙ | ︙ | |||
1818 1819 1820 1821 1822 1823 1824 |
char *zTktTitle;
login_check_credentials();
if( !g.perm.RdTkt ){ login_needed(); return; }
rid = name_to_rid_www("name");
if( rid==0 ){ fossil_redirect_home(); }
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( g.perm.Admin ){
| | > > > > > > | | > > > > | 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 |
char *zTktTitle;
login_check_credentials();
if( !g.perm.RdTkt ){ login_needed(); return; }
rid = name_to_rid_www("name");
if( rid==0 ){ fossil_redirect_home(); }
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", rid);
if( g.perm.Admin ){
if( db_exists("SELECT 1 FROM shun WHERE uuid=%Q", zUuid) ){
style_submenu_element("Unshun","Unshun", "%s/shun?accept=%s&sub=1#accshun",
g.zTop, zUuid);
}else{
style_submenu_element("Shun","Shun", "%s/shun?shun=%s#addshun",
g.zTop, zUuid);
}
}
pTktChng = manifest_get(rid, CFTYPE_TICKET, 0);
if( pTktChng==0 ) fossil_redirect_home();
zDate = db_text(0, "SELECT datetime(%.12f)", pTktChng->rDate);
memcpy(zTktName, pTktChng->zTicketUuid, UUID_SIZE+1);
if( g.perm.ModTkt && (zModAction = P("modaction"))!=0 ){
if( strcmp(zModAction,"delete")==0 ){
moderation_disapprove(rid);
/*
** Next, check if the ticket still exists; if not, we cannot
** redirect to it.
*/
if( db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'",
zTktName) ){
cgi_redirectf("%R/tktview/%s", zTktName);
/*NOTREACHED*/
}else{
cgi_redirectf("%R/modreq");
/*NOTREACHED*/
}
}
if( strcmp(zModAction,"approve")==0 ){
moderation_approve(rid);
}
}
zTktTitle = db_table_has_column( "ticket", "title" )
? db_text("(No title)", "SELECT title FROM ticket WHERE tkt_uuid=%Q", zTktName)
|
| ︙ | ︙ | |||
1953 1954 1955 1956 1957 1958 1959 |
return;
}else if( rc==2 ){
cgi_set_parameter("src","info");
ambiguous_page();
return;
}
zName = blob_str(&uuid);
| | | 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 |
return;
}else if( rc==2 ){
cgi_set_parameter("src","info");
ambiguous_page();
return;
}
zName = blob_str(&uuid);
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", zName);
if( rid==0 ){
style_header("Broken Link");
@ <p>No such object: %h(zName)</p>
style_footer();
return;
}
if( db_exists("SELECT 1 FROM mlink WHERE mid=%d", rid) ){
|
| ︙ | ︙ | |||
2098 2099 2100 2101 2102 2103 2104 |
@ <input type="radio" name="%s(zId)" value="%h(aColor[nColor].zColor)"
@ checked="checked" onclick="gebi('%s(zIdCustom)').select();" />
}
@ %h(aColor[i].zCName)</label>
@ <input type="text" name="%s(zIdCustom)"
@ id="%s(zIdCustom)" class="checkinUserColor"
@ value="%h(stdClrFound?"":zDefaultColor)"
| | > > | 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 |
@ <input type="radio" name="%s(zId)" value="%h(aColor[nColor].zColor)"
@ checked="checked" onclick="gebi('%s(zIdCustom)').select();" />
}
@ %h(aColor[i].zCName)</label>
@ <input type="text" name="%s(zIdCustom)"
@ id="%s(zIdCustom)" class="checkinUserColor"
@ value="%h(stdClrFound?"":zDefaultColor)"
@ onfocus="this.form.elements['%s(zId)'][%d(nColor)].checked = true;"
@ onload="this.blur();"
@ onblur="this.parentElement.style.backgroundColor = this.value ? ('#'+this.value.replace('#','')) : '';" />
@ </td>
@ </tr>
@ </table>
}
/*
** Do a comment comparison.
|
| ︙ | ︙ |
Changes to src/json.c.
| ︙ | ︙ | |||
16 17 18 19 20 21 22 | ** ******************************************************************************* ** ** Code for the JSON API. ** ** For notes regarding the public JSON interface, please see: ** | | | 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** ******************************************************************************* ** ** Code for the JSON API. ** ** For notes regarding the public JSON interface, please see: ** ** https://docs.google.com/document/d/1fXViveNhDbiXgCuE7QDXQOKeFzf2qNUkBEgiUvoqFN4/view ** ** ** Notes for hackers... ** ** Here's how command/page dispatching works: json_page_top() (in HTTP mode) or ** json_cmd_top() (in CLI mode) catch the "json" path/command. Those functions then ** dispatch to a JSON-mode-specific command/page handler with the type fossil_json_f(). |
| ︙ | ︙ | |||
55 56 57 58 59 60 61 | }; /* ** Returns true (non-0) if fossil appears to be running in JSON mode. */ | | | 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
};
/*
** Returns true (non-0) if fossil appears to be running in JSON mode.
*/
int fossil_has_json(){
return g.json.isJsonMode && (g.isHTTP || g.json.post.o);
}
/*
** Placeholder /json/XXX page impl for NYI (Not Yet Implemented)
** (but planned) pages/commands.
*/
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 | ** ** If an entry is found, this function guarantees that it will return ** either 0 or 1, as opposed to "0 or non-zero", so that clients can ** pass a different value as dflt. Thus they can use, e.g. -1 to know ** whether or not this function found a match (it will return -1 in ** that case). */ | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 |
**
** If an entry is found, this function guarantees that it will return
** either 0 or 1, as opposed to "0 or non-zero", so that clients can
** pass a different value as dflt. Thus they can use, e.g. -1 to know
** whether or not this function found a match (it will return -1 in
** that case).
*/
int json_getenv_bool(char const * pKey, int dflt ){
cson_value const * v = json_getenv(pKey);
const cson_type_id type = v ? cson_value_type_id(v) : CSON_TYPE_UNDEF;
switch(type){
case CSON_TYPE_INTEGER:
case CSON_TYPE_DOUBLE:
return cson_value_get_integer(v) ? 1 : 0;
case CSON_TYPE_STRING: {
|
| ︙ | ︙ | |||
473 474 475 476 477 478 479 | return json_find_option_cstr2(zKey, zCLILong, zCLIShort, -1); } /* ** The boolean equivalent of json_find_option_cstr(). ** If the option is not found, dftl is returned. */ | | | | | | | 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
return json_find_option_cstr2(zKey, zCLILong, zCLIShort, -1);
}
/*
** The boolean equivalent of json_find_option_cstr().
** If the option is not found, dftl is returned.
*/
int json_find_option_bool(char const * zKey,
char const * zCLILong,
char const * zCLIShort,
char dflt ){
int rc = -1;
if(!g.isHTTP){
if(NULL != find_option(zCLILong ? zCLILong : zKey,
zCLIShort, 0)){
rc = 1;
}
}
if((-1==rc) && fossil_has_json()){
|
| ︙ | ︙ | |||
1663 1664 1665 1666 1667 1668 1669 |
** to simplify the trivial use-cases (which don't need a Blob).
*/
cson_value * json_sql_to_array_of_obj(Blob * pSql, cson_array * pTgt,
char resetBlob){
Stmt q = empty_Stmt;
cson_value * pay = NULL;
assert( blob_size(pSql) > 0 );
| | | 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 |
** to simplify the trivial use-cases (which don't need a Blob).
*/
cson_value * json_sql_to_array_of_obj(Blob * pSql, cson_array * pTgt,
char resetBlob){
Stmt q = empty_Stmt;
cson_value * pay = NULL;
assert( blob_size(pSql) > 0 );
db_prepare(&q, "%s", blob_str(pSql) /*safe-for-%s*/);
if(resetBlob){
blob_reset(pSql);
}
pay = json_stmt_to_array_of_obj(&q, pTgt);
db_finalize(&q);
return pay;
|
| ︙ | ︙ | |||
1981 1982 1983 1984 1985 1986 1987 |
jv2 = cson_value_new_object();
jo2 = cson_value_get_object(jv2);
cson_object_set(jo, "sqlite", jv2);
sqlite3_snprintf(BufLen, zBuf, "%.19s [%.10s] (%s)",
sqlite3_sourceid(), &sqlite3_sourceid()[20], sqlite3_libversion());
SETBUF(jo2, "version");
zDb = db_name("repository");
| | | | | | | 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 |
jv2 = cson_value_new_object();
jo2 = cson_value_get_object(jv2);
cson_object_set(jo, "sqlite", jv2);
sqlite3_snprintf(BufLen, zBuf, "%.19s [%.10s] (%s)",
sqlite3_sourceid(), &sqlite3_sourceid()[20], sqlite3_libversion());
SETBUF(jo2, "version");
zDb = db_name("repository");
cson_object_set(jo2, "pageCount", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA \"%w\".page_count", zDb)));
cson_object_set(jo2, "pageSize", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA \"%w\".page_size", zDb)));
cson_object_set(jo2, "freeList", cson_value_new_integer((cson_int_t)db_int(0, "PRAGMA \"%w\".freelist_count", zDb)));
sqlite3_snprintf(BufLen, zBuf, "%s", db_text(0, "PRAGMA \"%w\".encoding", zDb));
SETBUF(jo2, "encoding");
sqlite3_snprintf(BufLen, zBuf, "%s", db_text(0, "PRAGMA \"%w\".journal_mode", zDb));
cson_object_set(jo2, "journalMode", *zBuf ? cson_value_new_string(zBuf, strlen(zBuf)) : cson_value_null());
return jv;
#undef SETBUF
}
|
| ︙ | ︙ | |||
2014 2015 2016 2017 2018 2019 2020 |
Blob * pOut, int filterByMode){
int i = 0;
for( ; zPages->name; ++zPages, ++i ){
if(filterByMode){
if(g.isHTTP && zPages->runMode < 0) continue;
else if(zPages->runMode > 0) continue;
}
| | | 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 |
Blob * pOut, int filterByMode){
int i = 0;
for( ; zPages->name; ++zPages, ++i ){
if(filterByMode){
if(g.isHTTP && zPages->runMode < 0) continue;
else if(zPages->runMode > 0) continue;
}
blob_append(pOut, zPages->name, -1);
if((zPages+1)->name){
blob_append(pOut, ", ",2);
}
}
return i;
}
|
| ︙ | ︙ |
Changes to src/json_config.c.
| ︙ | ︙ | |||
143 144 145 146 147 148 149 |
const struct JsonConfigProperty * prop = &JsonConfigProperties[0];
blob_append(&sql," OR name IN (",-1);
for( i = 0; prop->name; ++prop ){
if(prop->groupMask & confMask){
if( i++ ){
blob_append(&sql,",",1);
}
| | | | 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 |
const struct JsonConfigProperty * prop = &JsonConfigProperties[0];
blob_append(&sql," OR name IN (",-1);
for( i = 0; prop->name; ++prop ){
if(prop->groupMask & confMask){
if( i++ ){
blob_append(&sql,",",1);
}
blob_append_sql(&sql, "%Q", prop->name);
}
}
blob_append(&sql,") ", -1);
}
if( optSkinBackups ){
blob_append(&sql, " OR name GLOB 'skin:*'", -1);
}
blob_append(&sql," ORDER BY name", -1);
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
pay = cson_new_object();
while( (SQLITE_ROW==db_step(&q)) ){
cson_object_set(pay,
db_column_text(&q,0),
json_new_string(db_column_text(&q,1)));
}
|
| ︙ | ︙ |
Changes to src/json_detail.h.
| ︙ | ︙ | |||
255 256 257 258 259 260 261 | ** b) We are running in JSON CLI mode, but no POST data has been fed ** in. ** ** Whether or not we need to take args from CLI or POST data makes a ** difference in argument/parameter handling in many JSON routines, ** and thus this distinction. */ | | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
** b) We are running in JSON CLI mode, but no POST data has been fed
** in.
**
** Whether or not we need to take args from CLI or POST data makes a
** difference in argument/parameter handling in many JSON routines,
** and thus this distinction.
*/
int fossil_has_json();
enum json_get_changed_files_flags {
json_get_changed_files_ELIDE_PARENT = 1 << 0
};
#endif/*FOSSIL_JSON_DETAIL_H_INCLUDED*/
#endif /* FOSSIL_ENABLE_JSON */
|
Changes to src/json_finfo.c.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 |
}
zBefore = json_find_option_cstr("before",NULL,"b");
zAfter = json_find_option_cstr("after",NULL,"a");
limit = json_find_option_int("limit",NULL,"n", -1);
zCheckin = json_find_option_cstr("checkin",NULL,"ci");
| | | 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
}
zBefore = json_find_option_cstr("before",NULL,"b");
zAfter = json_find_option_cstr("after",NULL,"a");
limit = json_find_option_int("limit",NULL,"n", -1);
zCheckin = json_find_option_cstr("checkin",NULL,"ci");
blob_append_sql(&sql,
/*0*/ "SELECT b.uuid,"
/*1*/ " ci.uuid,"
/*2*/ " (SELECT uuid FROM blob WHERE rid=mlink.fid)," /* Current file uuid */
/*3*/ " cast(strftime('%%s',event.mtime) AS INTEGER),"
/*4*/ " coalesce(event.euser, event.user),"
/*5*/ " coalesce(event.ecomment, event.comment),"
/*6*/ " (SELECT uuid FROM blob WHERE rid=mlink.pid)," /* Parent file uuid */
|
| ︙ | ︙ | |||
91 92 93 94 95 96 97 |
/*printf("zCheckin=[%s], zU=[%s]", zCheckin, zU);*/
if(rc<=0){
json_set_err((rc<0) ? FSL_JSON_E_AMBIGUOUS_UUID : FSL_JSON_E_RESOURCE_NOT_FOUND,
"Checkin UUID %s.", (rc<0) ? "is ambiguous" : "not found");
blob_reset(&sql);
return NULL;
}
| | | | | | < | 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 |
/*printf("zCheckin=[%s], zU=[%s]", zCheckin, zU);*/
if(rc<=0){
json_set_err((rc<0) ? FSL_JSON_E_AMBIGUOUS_UUID : FSL_JSON_E_RESOURCE_NOT_FOUND,
"Checkin UUID %s.", (rc<0) ? "is ambiguous" : "not found");
blob_reset(&sql);
return NULL;
}
blob_append_sql(&sql, " AND ci.uuid='%q'", zU);
free(zU);
}else{
if( zAfter && *zAfter ){
blob_append_sql(&sql, " AND event.mtime>=julianday('%q')", zAfter);
sort = 1;
}else if( zBefore && *zBefore ){
blob_append_sql(&sql, " AND event.mtime<=julianday('%q')", zBefore);
}
}
blob_append_sql(&sql," ORDER BY event.mtime %s /*sort*/", (sort>0?"ASC":"DESC"));
/*printf("SQL=\n%s\n",blob_str(&sql));*/
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
pay = cson_new_object();
cson_object_set(pay, "name", json_new_string(zFilename));
if( limit > 0 ){
cson_object_set(pay, "limit", json_new_int(limit));
}
|
| ︙ | ︙ |
Changes to src/json_query.c.
| ︙ | ︙ | |||
62 63 64 65 66 67 68 |
json_set_err(FSL_JSON_E_MISSING_ARGS,
"'sql' (-s) argument is missing.");
return NULL;
}
zFmt = json_find_option_cstr2("format",NULL,"f",3);
if(!zFmt) zFmt = "o";
| | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
json_set_err(FSL_JSON_E_MISSING_ARGS,
"'sql' (-s) argument is missing.");
return NULL;
}
zFmt = json_find_option_cstr2("format",NULL,"f",3);
if(!zFmt) zFmt = "o";
db_prepare(&q,"%s", zSql/*safe-for-%s*/);
if( 0 == sqlite3_column_count( q.pStmt ) ){
json_set_err(FSL_JSON_E_USAGE,
"Input query has no result columns. "
"Only SELECT-like queries are supported.");
db_finalize(&q);
return NULL;
}
|
| ︙ | ︙ |
Changes to src/json_report.c.
| ︙ | ︙ | |||
202 203 204 205 206 207 208 |
limit = json_find_option_int("limit",NULL,"n",-1);
/* Copy over report's SQL...*/
blob_append(&sql, db_column_text(&q,0), -1);
zTitle = mprintf("%s", db_column_text(&q,1));
db_finalize(&q);
| | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
limit = json_find_option_int("limit",NULL,"n",-1);
/* Copy over report's SQL...*/
blob_append(&sql, db_column_text(&q,0), -1);
zTitle = mprintf("%s", db_column_text(&q,1));
db_finalize(&q);
db_prepare(&q, "%s", blob_sql_text(&sql));
/** Build the response... */
pay = cson_new_object();
cson_object_set(pay, "report", json_new_int(nReport));
cson_object_set(pay, "title", json_new_string(zTitle));
if(limit>0){
|
| ︙ | ︙ |
Changes to src/json_tag.c.
| ︙ | ︙ | |||
299 300 301 302 303 304 305 |
" AND event.type GLOB '%q'"
" AND blob.rid IN ("
" SELECT rid FROM tagxref"
" WHERE tagtype>0 AND tagid=%d"
" )"
" ORDER BY event.mtime DESC"
"%s LIMIT %d",
| | | 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
" AND event.type GLOB '%q'"
" AND blob.rid IN ("
" SELECT rid FROM tagxref"
" WHERE tagtype>0 AND tagid=%d"
" )"
" ORDER BY event.mtime DESC"
"%s LIMIT %d",
zSqlBase /*safe-for-%s*/, zType, tagid,
(limit>0)?"":"--", limit
);
listV = json_stmt_to_array_of_obj(&q, NULL);
db_finalize(&q);
}
if(!listV) {
|
| ︙ | ︙ | |||
440 441 442 443 444 445 446 |
-1
);
if(!fTicket){
blob_append(&sql, " AND tagname NOT GLOB('tkt-*') ", -1);
}
blob_append(&sql,
" ORDER BY tagname", -1);
| | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 |
-1
);
if(!fTicket){
blob_append(&sql, " AND tagname NOT GLOB('tkt-*') ", -1);
}
blob_append(&sql,
" ORDER BY tagname", -1);
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
cson_object_set(pay, "includeTickets", cson_value_new_bool(fTicket) );
while( SQLITE_ROW == db_step(&q) ){
const char *zName = db_column_text(&q, 0);
if(NULL==arV){
arV = cson_value_new_array();
ar = cson_value_get_array(arV);
|
| ︙ | ︙ |
Changes to src/json_timeline.c.
| ︙ | ︙ | |||
81 82 83 84 85 86 87 |
@ bgColor TEXT,
@ eventType TEXT,
@ tags TEXT,
@ tagId INTEGER,
@ brief TEXT
@ )
;
| | | 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
@ bgColor TEXT,
@ eventType TEXT,
@ tags TEXT,
@ tagId INTEGER,
@ brief TEXT
@ )
;
db_multi_exec("%s", zSql /*safe-for-%s*/);
}
/*
** Return a pointer to a constant string that forms the basis
** for a timeline query for the JSON interface.
*/
char const * json_timeline_query(void){
|
| ︙ | ︙ | |||
382 383 384 385 386 387 388 |
" coalesce(euser, user) as user,"
" blob.rid IN leaf as isLeaf,"
" bgcolor as bgColor"
" FROM event JOIN blob"
" WHERE blob.rid=event.objid",
-1);
| | | | | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 |
" coalesce(euser, user) as user,"
" blob.rid IN leaf as isLeaf,"
" bgcolor as bgColor"
" FROM event JOIN blob"
" WHERE blob.rid=event.objid",
-1);
blob_append_sql(&sql,
" AND event.type='ci'"
" AND blob.rid IN (SELECT rid FROM tagxref"
" WHERE tagtype>0 AND tagid=%d AND srcid!=0)"
" ORDER BY event.mtime DESC",
TAG_BRANCH);
limit = json_timeline_limit(20);
if(limit>0){
blob_append_sql(&sql," LIMIT %d ",limit);
}
db_prepare(&q,"%s", blob_sql_text(&sql));
blob_reset(&sql);
pay = json_stmt_to_array_of_obj(&q, NULL);
db_finalize(&q);
assert(NULL != pay);
if(pay){
/* get the array-form tags of each record. */
cson_string * tags = cson_new_string("tags",4);
|
| ︙ | ︙ | |||
480 481 482 483 484 485 486 |
} (void)0
#if 0
/* only for testing! */
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
SET("timelineSql");
#endif
| | | 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
} (void)0
#if 0
/* only for testing! */
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
SET("timelineSql");
#endif
db_multi_exec("%s", blob_buffer(&sql)/*safe-for-%s*/);
blob_reset(&sql);
db_prepare(&q, "SELECT "
" rid AS rid"
" FROM json_timeline"
" ORDER BY rowid");
listV = cson_value_new_array();
list = cson_value_get_array(listV);
|
| ︙ | ︙ | |||
545 546 547 548 549 550 551 |
}
#if 0
/* only for testing! */
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
SET("timelineSql");
#endif
| | | < | 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
}
#if 0
/* only for testing! */
tmp = cson_value_new_string(blob_buffer(&sql),strlen(blob_buffer(&sql)));
SET("timelineSql");
#endif
db_multi_exec("%s", blob_buffer(&sql) /*safe-for-%s*/);
blob_reset(&sql);
db_prepare(&q, "SELECT"
" uuid AS uuid,"
" mtime AS timestamp,"
#if 0
" timestampString AS timestampString,"
#endif
" comment AS comment, "
" user AS user,"
" eventType AS eventType"
#if 0
/* can wiki pages have tags? */
" tags AS tags," /*FIXME: split this into
a JSON array*/
" tagId AS tagId,"
#endif
" FROM json_timeline"
" ORDER BY rowid");
list = cson_new_array();
json_stmt_to_array_of_obj(&q, list);
cson_object_set(pay, "timeline", cson_array_value(list));
goto ok;
error:
assert( 0 != g.json.resultCode );
cson_value_free(payV);
|
| ︙ | ︙ | |||
605 606 607 608 609 610 611 |
pay = cson_value_get_object(payV);
check = json_timeline_setup_sql( "t", &sql, pay );
if(check){
json_set_err(check, "Query initialization failed.");
goto error;
}
| | | 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 |
pay = cson_value_get_object(payV);
check = json_timeline_setup_sql( "t", &sql, pay );
if(check){
json_set_err(check, "Query initialization failed.");
goto error;
}
db_multi_exec("%s", blob_buffer(&sql) /*safe-for-%s*/);
#define SET(K) if(0!=(check=cson_object_set(pay,K,tmp))){ \
json_set_err((cson_rc.AllocError==check) \
? FSL_JSON_E_ALLOC : FSL_JSON_E_UNKNOWN, \
"Object property insertion failed."); \
goto error;\
} (void)0
|
| ︙ | ︙ | |||
636 637 638 639 640 641 642 |
" timestampString AS timestampString,"
#endif
" user AS user,"
" eventType AS eventType,"
" comment AS comment,"
" brief AS briefComment"
" FROM json_timeline"
| | < | 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 |
" timestampString AS timestampString,"
#endif
" user AS user,"
" eventType AS eventType,"
" comment AS comment,"
" brief AS briefComment"
" FROM json_timeline"
" ORDER BY rowid");
listV = cson_value_new_array();
list = cson_value_get_array(listV);
tmp = listV;
SET("timeline");
while( (SQLITE_ROW == db_step(&q) )){
/* convert each row into a JSON object...*/
int rc;
|
| ︙ | ︙ |
Changes to src/json_user.c.
| ︙ | ︙ | |||
284 285 286 287 288 289 290 |
}
forceLogout = cson_value_true()
/* reminders: 1) does not allocate.
2) we do this because changing a name
invalidates any login token because the old name
is part of the token hash.
*/;
| | | | | | | | | | | 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
}
forceLogout = cson_value_true()
/* reminders: 1) does not allocate.
2) we do this because changing a name
invalidates any login token because the old name
is part of the token hash.
*/;
blob_append_sql(&sql, ", login=%Q", zNameNew);
++gotFields;
}
}
if( zCap && *zCap ){
if(!g.perm.Admin || !g.perm.Setup){
/* we "could" arguably silently ignore cap in this case. */
json_set_err(FSL_JSON_E_DENIED,
"Changing capabilities requires 'a' or 's' privileges.");
goto error;
}
blob_append_sql(&sql, ", cap=%Q", zCap);
++gotFields;
}
if( zPW && *zPW ){
if(!g.perm.Admin && !g.perm.Setup && !g.perm.Password){
json_set_err( FSL_JSON_E_DENIED,
"Password change requires 'a', 's', "
"or 'p' permissions.");
goto error;
}else{
#define TRY_LOGIN_GROUP 0 /* login group support is not yet implemented. */
#if !TRY_LOGIN_GROUP
char * zPWHash = NULL;
++gotFields;
zPWHash = sha1_shared_secret(zPW, zNameNew ? zNameNew : zName, NULL);
blob_append_sql(&sql, ", pw=%Q", zPWHash);
free(zPWHash);
#else
++gotFields;
blob_append_sql(&sql, ", pw=coalesce(shared_secret(%Q,%Q,"
"(SELECT value FROM config WHERE name='project-code')))",
zPW, zNameNew ? zNameNew : zName);
/* shared_secret() func is undefined? */
#endif
}
}
if( zInfo ){
blob_append_sql(&sql, ", info=%Q", zInfo);
++gotFields;
}
if((g.perm.Admin || g.perm.Setup)
&& forceLogout && cson_value_get_bool(forceLogout)){
blob_append(&sql, ", cookie=NULL, cexpire=NULL", -1);
++gotFields;
}
if(!gotFields){
json_set_err( FSL_JSON_E_MISSING_ARGS,
"Required user data are missing.");
goto error;
}
assert(uid>0);
#if !TRY_LOGIN_GROUP
blob_append_sql(&sql, " WHERE uid=%d", uid);
#else /* need name for login group support :/ */
blob_append_sql(&sql, " WHERE login=%Q", zName);
#endif
#if 0
puts(blob_str(&sql));
cson_output_FILE( cson_object_value(pUser), stdout, NULL );
#endif
db_prepare(&q, "%s", blob_sql_text(&sql));
db_exec(&q);
db_finalize(&q);
#if TRY_LOGIN_GROUP
if( zPW || cson_value_get_bool(forceLogout) ){
Blob groupSql = empty_blob;
char * zErr = NULL;
blob_append_sql(&groupSql,
"INSERT INTO user(login)"
" SELECT %Q WHERE NOT EXISTS(SELECT 1 FROM user WHERE login=%Q);",
zName, zName
);
blob_append(&groupSql, blob_str(&sql), blob_size(&sql));
login_group_sql(blob_str(&groupSql), NULL, NULL, &zErr);
blob_reset(&groupSql);
|
| ︙ | ︙ |
Changes to src/json_wiki.c.
| ︙ | ︙ | |||
373 374 375 376 377 378 379 |
contentLen = (int)cson_string_length_bytes(jstr);
if(contentLen){
blob_append(&content, cson_string_cstr(jstr),contentLen);
}
zMimeType = json_find_option_cstr("mimetype","mimetype","M");
| | | 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 |
contentLen = (int)cson_string_length_bytes(jstr);
if(contentLen){
blob_append(&content, cson_string_cstr(jstr),contentLen);
}
zMimeType = json_find_option_cstr("mimetype","mimetype","M");
wiki_cmd_commit(zPageName, 0==rid, &content, zMimeType, 0);
blob_reset(&content);
/*
Our return value here has a race condition: if this operation
is called concurrently for the same wiki page via two requests,
payV could reflect the results of the other save operation.
*/
payV = json_get_wiki_page_by_name(
|
| ︙ | ︙ | |||
442 443 444 445 446 447 448 |
}
blob_append(&sql,"SELECT"
" substr(tagname,6) as name"
" FROM tag WHERE tagname GLOB 'wiki-*'",
-1);
zGlob = json_find_option_cstr("glob",NULL,"g");
if(zGlob && *zGlob){
| | | | | < | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
}
blob_append(&sql,"SELECT"
" substr(tagname,6) as name"
" FROM tag WHERE tagname GLOB 'wiki-*'",
-1);
zGlob = json_find_option_cstr("glob",NULL,"g");
if(zGlob && *zGlob){
blob_append_sql(&sql," AND name %s GLOB %Q",
fInvert ? "NOT" : "", zGlob);
}else{
zGlob = json_find_option_cstr("like",NULL,"l");
if(zGlob && *zGlob){
blob_append_sql(&sql," AND name %s LIKE %Q",
fInvert ? "NOT" : "", zGlob);
}
}
blob_append(&sql," ORDER BY lower(name)", -1);
db_prepare(&q,"%s", blob_sql_text(&sql));
blob_reset(&sql);
listV = cson_value_new_array();
list = cson_value_get_array(listV);
while( SQLITE_ROW == db_step(&q) ){
cson_value * v;
if( verbose ){
char const * name = db_column_text(&q,0);
|
| ︙ | ︙ |
Changes to src/leaf.c.
| ︙ | ︙ | |||
37 38 39 40 41 42 43 |
@ SELECT 1 FROM plink
@ WHERE pid=%d
@ AND coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@ =coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.cid), 'trunk')
;
| > | | 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
@ SELECT 1 FROM plink
@ WHERE pid=%d
@ AND coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@ =coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.cid), 'trunk')
;
rc = db_int(0, zSql /*works-like:"%d,%d,%d"*/,
rid, TAG_BRANCH, TAG_BRANCH);
return rc==0;
}
/*
** Count the number of primary non-branch children for the given check-in.
**
** A primary child is one where the parent is the primary parent, not
|
| ︙ | ︙ | |||
61 62 63 64 65 66 67 |
@ SELECT count(*) FROM plink
@ WHERE pid=:pid AND isprim
@ AND coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@ =coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.cid), 'trunk')
;
| | | 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
@ SELECT count(*) FROM plink
@ WHERE pid=:pid AND isprim
@ AND coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.pid), 'trunk')
@ =coalesce((SELECT value FROM tagxref
@ WHERE tagid=%d AND rid=plink.cid), 'trunk')
;
db_static_prepare(&q, zSql /*works-like: "%d,%d"*/, TAG_BRANCH, TAG_BRANCH);
db_bind_int(&q, ":pid", pid);
if( db_step(&q)==SQLITE_ROW ){
nNonBranch = db_column_int(&q, 0);
}
db_reset(&q);
return nNonBranch;
}
|
| ︙ | ︙ |
Changes to src/loadctrl.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 |
/*
** Return the load average for the host processor
*/
double load_average(void){
#if !defined(_WIN32) && !defined(FOSSIL_OMIT_LOAD_AVERAGE)
double a[3];
if( getloadavg(a, 3)>0 ){
| | | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
/*
** Return the load average for the host processor
*/
double load_average(void){
#if !defined(_WIN32) && !defined(FOSSIL_OMIT_LOAD_AVERAGE)
double a[3];
if( getloadavg(a, 3)>0 ){
return a[0]>=0.000001 ? a[0] : 0.000001;
}
#endif
return 0.0;
}
/*
** COMMAND: test-loadavg
|
| ︙ | ︙ |
Changes to src/login.c.
| ︙ | ︙ | |||
206 207 208 209 210 211 212 | ** Searches for the user ID matching the given name and password. ** On success it returns a positive value. On error it returns 0. ** On serious (DB-level) error it will probably exit. ** ** zPassword may be either the plain-text form or the encrypted ** form of the user's password. */ | | | | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
** Searches for the user ID matching the given name and password.
** On success it returns a positive value. On error it returns 0.
** On serious (DB-level) error it will probably exit.
**
** zPassword may be either the plain-text form or the encrypted
** form of the user's password.
*/
int login_search_uid(const char *zUsername, const char *zPasswd){
char *zSha1Pw = sha1_shared_secret(zPasswd, zUsername, 0);
int const uid =
db_int(0,
"SELECT uid FROM user"
" WHERE login=%Q"
" AND length(cap)>0 AND length(pw)>0"
" AND login NOT IN ('anonymous','nobody','developer','reader')"
" AND (pw=%Q OR (length(pw)<>40 AND pw=%Q))",
|
| ︙ | ︙ | |||
229 230 231 232 233 234 235 | ** Generates a login cookie value for a non-anonymous user. ** ** The zHash parameter must be a random value which must be ** subsequently stored in user.cookie for later validation. ** ** The returned memory should be free()d after use. */ | | | | | | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
** Generates a login cookie value for a non-anonymous user.
**
** The zHash parameter must be a random value which must be
** subsequently stored in user.cookie for later validation.
**
** The returned memory should be free()d after use.
*/
char *login_gen_user_cookie_value(const char *zUsername, const char *zHash){
char *zProjCode = db_get("project-code",NULL);
char *zCode = abbreviated_project_code(zProjCode);
free(zProjCode);
assert((zUsername && *zUsername) && "Invalid user data.");
return mprintf("%s/%z/%s", zHash, zCode, zUsername);
}
/*
** Generates a login cookie for NON-ANONYMOUS users. Note that this
** function "could" figure out the uid by itself but it currently
** doesn't because the code which calls this already has the uid.
**
** This function also updates the user.cookie, user.ipaddr,
** and user.cexpire fields for the given user.
**
** If zDest is not NULL then the generated cookie is copied to
** *zDdest and ownership is transfered to the caller (who should
** eventually pass it to free()).
*/
void login_set_user_cookie(
const char *zUsername, /* User's name */
int uid, /* User's ID */
char **zDest /* Optional: store generated cookie value. */
){
const char *zCookieName = login_cookie_name();
const char *zExpire = db_get("cookie-expire","8766");
int expires = atoi(zExpire)*3600;
char *zHash;
char *zCookie;
const char *zIpAddr = PD("REMOTE_ADDR","nil"); /* IP address of user */
char *zRemoteAddr = ipPrefix(zIpAddr); /* Abbreviated IP address */
assert((zUsername && *zUsername) && (uid > 0) && "Invalid user data.");
zHash = db_text(0,
"SELECT cookie FROM user"
" WHERE uid=%d"
" AND ipaddr=%Q"
|
| ︙ | ︙ | |||
301 302 303 304 305 306 307 | ** ** If either zIpAddr or zRemoteAddr are NULL then REMOTE_ADDR ** is used. ** ** If zCookieDest is not NULL then the generated cookie is assigned to ** *zCookieDest and the caller must eventually free() it. */ | | | | | | 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
**
** If either zIpAddr or zRemoteAddr are NULL then REMOTE_ADDR
** is used.
**
** If zCookieDest is not NULL then the generated cookie is assigned to
** *zCookieDest and the caller must eventually free() it.
*/
void login_set_anon_cookie(const char *zIpAddr, char **zCookieDest ){
const char *zNow; /* Current time (julian day number) */
char *zCookie; /* The login cookie */
const char *zCookieName; /* Name of the login cookie */
Blob b; /* Blob used during cookie construction */
char *zRemoteAddr; /* Abbreviated IP address */
if(!zIpAddr){
zIpAddr = PD("REMOTE_ADDR","nil");
}
zRemoteAddr = ipPrefix(zIpAddr);
zCookieName = login_cookie_name();
zNow = db_text("0", "SELECT julianday('now')");
assert( zCookieName && zRemoteAddr && zIpAddr && zNow );
|
| ︙ | ︙ | |||
342 343 344 345 346 347 348 |
**
** This is a no-op if g.userUid is 0.
*/
void login_clear_login_data(){
if(!g.userUid){
return;
}else{
| | | 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 |
**
** This is a no-op if g.userUid is 0.
*/
void login_clear_login_data(){
if(!g.userUid){
return;
}else{
const char *cookie = login_cookie_name();
/* To logout, change the cookie value to an empty string */
cgi_set_cookie(cookie, "",
login_cookie_path(), -86400);
db_multi_exec("UPDATE user SET cookie=NULL, ipaddr=NULL, "
" cexpire=0 WHERE uid=%d"
" AND login NOT IN ('anonymous','nobody',"
" 'developer','reader')", g.userUid);
|
| ︙ | ︙ | |||
393 394 395 396 397 398 399 |
if( prefix_match("spider", zAgent+i) ) return 0;
if( prefix_match("crawl", zAgent+i) ) return 0;
/* If a URI appears in the User-Agent, it is probably a bot */
if( strncmp("http", zAgent+i,4)==0 ) return 0;
}
if( strncmp(zAgent, "Mozilla/", 8)==0 ){
if( atoi(&zAgent[8])<4 ) return 0; /* Many bots advertise as Mozilla/3 */
| | | | | | | 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
if( prefix_match("spider", zAgent+i) ) return 0;
if( prefix_match("crawl", zAgent+i) ) return 0;
/* If a URI appears in the User-Agent, it is probably a bot */
if( strncmp("http", zAgent+i,4)==0 ) return 0;
}
if( strncmp(zAgent, "Mozilla/", 8)==0 ){
if( atoi(&zAgent[8])<4 ) return 0; /* Many bots advertise as Mozilla/3 */
if( sqlite3_strglob("*Firefox/[1-9]*", zAgent)==0 ) return 1;
if( sqlite3_strglob("*Chrome/[1-9]*", zAgent)==0 ) return 1;
if( sqlite3_strglob("*(compatible;?MSIE?[1789]*", zAgent)==0 ) return 1;
if( sqlite3_strglob("*Trident/[1-9]*;?rv:[1-9]*", zAgent)==0 ) return 1; /* IE11+ */
if( sqlite3_strglob("*AppleWebKit/[1-9]*(KHTML*", zAgent)==0 ) return 1;
return 0;
}
if( strncmp(zAgent, "Opera/", 6)==0 ) return 1;
if( strncmp(zAgent, "Safari/", 7)==0 ) return 1;
if( strncmp(zAgent, "Lynx/", 5)==0 ) return 1;
if( strncmp(zAgent, "NetSurf/", 8)==0 ) return 1;
return 0;
|
| ︙ | ︙ | |||
627 628 629 630 631 632 633 |
@ the login to take.</p>
if( db_get_boolean("self-register", 0) ){
@ <p>If you do not have an account, you can
@ <a href="%s(g.zTop)/register?g=%T(P("G"))">create one</a>.
}
if( zAnonPw ){
unsigned int uSeed = captcha_seed();
| | | 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 |
@ the login to take.</p>
if( db_get_boolean("self-register", 0) ){
@ <p>If you do not have an account, you can
@ <a href="%s(g.zTop)/register?g=%T(P("G"))">create one</a>.
}
if( zAnonPw ){
unsigned int uSeed = captcha_seed();
const char *zDecoded = captcha_decode(uSeed);
int bAutoCaptcha = db_get_boolean("auto-captcha", 0);
char *zCaptcha = captcha_render(zDecoded);
@ <p><input type="hidden" name="cs" value="%u(uSeed)" />
@ Visitors may enter <b>anonymous</b> as the user-ID with
@ the 8-character hexadecimal password shown below:</p>
@ <div class="captcha"><table class="captcha"><tr><td><pre>
|
| ︙ | ︙ | |||
1235 1236 1237 1238 1239 1240 1241 |
**
** Generate the register page.
**
*/
void register_page(void){
const char *zUsername, *zPasswd, *zConfirm, *zContact, *zCS, *zPw, *zCap;
unsigned int uSeed;
| | | 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 |
**
** Generate the register page.
**
*/
void register_page(void){
const char *zUsername, *zPasswd, *zConfirm, *zContact, *zCS, *zPw, *zCap;
unsigned int uSeed;
const char *zDecoded;
char *zCaptcha;
if( !db_get_boolean("self-register", 0) ){
style_header("Registration not possible");
@ <p>This project does not allow user self-registration. Please contact the
@ project administrator to obtain an account.</p>
style_footer();
return;
|
| ︙ | ︙ | |||
1293 1294 1295 1296 1297 1298 1299 |
@ %s(zUsername) already exists.
@ </span></p>
}else{
char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
int uid;
db_multi_exec(
"INSERT INTO user(login,pw,cap,info,mtime)"
| | | 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 |
@ %s(zUsername) already exists.
@ </span></p>
}else{
char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
int uid;
db_multi_exec(
"INSERT INTO user(login,pw,cap,info,mtime)"
"VALUES(%B,%Q,%B,%B,strftime('%%s','now'))",
&login, zPw, &caps, &contact
);
free(zPw);
/* The user is registered, now just log him in. */
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
login_set_user_cookie( zUsername, uid, NULL );
|
| ︙ | ︙ | |||
1468 1469 1470 1471 1472 1473 1474 |
const char *zSelf; /* The ATTACH name of our repository */
*pzErrMsg = 0; /* Default to no errors */
zSelf = db_name("repository");
/* Get the full pathname of the other repository */
file_canonical_name(zRepo, &fullName, 0);
| | | | 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 |
const char *zSelf; /* The ATTACH name of our repository */
*pzErrMsg = 0; /* Default to no errors */
zSelf = db_name("repository");
/* Get the full pathname of the other repository */
file_canonical_name(zRepo, &fullName, 0);
zRepo = fossil_strdup(blob_str(&fullName));
blob_reset(&fullName);
/* Get the full pathname for our repository. Also the project code
** and project name for ourself. */
file_canonical_name(g.zRepositoryName, &fullName, 0);
zSelfRepo = fossil_strdup(blob_str(&fullName));
blob_reset(&fullName);
zSelfProjCode = db_get("project-code", "unknown");
zSelfLabel = db_get("project-name", 0);
if( zSelfLabel==0 ){
zSelfLabel = zSelfProjCode;
}
|
| ︙ | ︙ | |||
1499 1500 1501 1502 1503 1504 1505 |
}
rc = sqlite3_open_v2(
zRepo, &pOther,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
g.zVfsName
);
if( rc!=SQLITE_OK ){
| | | 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 |
}
rc = sqlite3_open_v2(
zRepo, &pOther,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
g.zVfsName
);
if( rc!=SQLITE_OK ){
*pzErrMsg = fossil_strdup(sqlite3_errmsg(pOther));
}else{
rc = sqlite3_exec(pOther, "SELECT count(*) FROM user", 0, 0, pzErrMsg);
}
sqlite3_close(pOther);
if( rc ) return;
/* Attach the other repository. Make sure the username/password is
|
| ︙ | ︙ | |||
1532 1533 1534 1535 1536 1537 1538 | /* Create all the necessary CONFIG table entries on both the ** other repository and on our own repository. */ zSelfProjCode = abbreviated_project_code(zSelfProjCode); zOtherProjCode = abbreviated_project_code(zOtherProjCode); db_begin_transaction(); db_multi_exec( | | | | | | 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 |
/* Create all the necessary CONFIG table entries on both the
** other repository and on our own repository.
*/
zSelfProjCode = abbreviated_project_code(zSelfProjCode);
zOtherProjCode = abbreviated_project_code(zOtherProjCode);
db_begin_transaction();
db_multi_exec(
"DELETE FROM \"%w\".config WHERE name GLOB 'peer-*';"
"INSERT INTO \"%w\".config(name,value) VALUES('peer-repo-%q',%Q);"
"INSERT INTO \"%w\".config(name,value) "
" SELECT 'peer-name-%q', value FROM other.config"
" WHERE name='project-name';",
zSelf,
zSelf, zOtherProjCode, zRepo,
zSelf, zOtherProjCode
);
db_multi_exec(
"INSERT OR IGNORE INTO other.config(name,value)"
" VALUES('login-group-name',%Q);"
"INSERT OR IGNORE INTO other.config(name,value)"
" VALUES('login-group-code',lower(hex(randomblob(8))));",
zNewName
);
db_multi_exec(
"REPLACE INTO \"%w\".config(name,value)"
" SELECT name, value FROM other.config"
" WHERE name GLOB 'peer-*' OR name GLOB 'login-group-*'",
zSelf
);
db_end_transaction(0);
db_multi_exec("DETACH other");
|
| ︙ | ︙ |
Changes to src/main.c.
| ︙ | ︙ | |||
31 32 33 34 35 36 37 | # include <windows.h> #else # include <errno.h> /* errno global */ #endif #ifdef FOSSIL_ENABLE_SSL # include "openssl/crypto.h" #endif | > > | > > > | 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | # include <windows.h> #else # include <errno.h> /* errno global */ #endif #ifdef FOSSIL_ENABLE_SSL # include "openssl/crypto.h" #endif #if defined(FOSSIL_ENABLE_MINIZ) # define MINIZ_HEADER_FILE_ONLY # include "miniz.c" #else # include <zlib.h> #endif #if INTERFACE #ifdef FOSSIL_ENABLE_TCL # include "tcl.h" #endif #ifdef FOSSIL_ENABLE_JSON # include "cson_amalgamation.h" /* JSON API. */ # include "json_detail.h" |
| ︙ | ︙ | |||
163 164 165 166 167 168 169 | FILE *httpIn; /* Accept HTTP input from here */ FILE *httpOut; /* Send HTTP output here */ int xlinkClusterOnly; /* Set when cloning. Only process clusters */ int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */ int *aCommitFile; /* Array of files to be committed */ int markPrivate; /* All new artifacts are private if true */ int clockSkewSeen; /* True if clocks on client and server out of sync */ | | > | 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 |
FILE *httpIn; /* Accept HTTP input from here */
FILE *httpOut; /* Send HTTP output here */
int xlinkClusterOnly; /* Set when cloning. Only process clusters */
int fTimeFormat; /* 1 for UTC. 2 for localtime. 0 not yet selected */
int *aCommitFile; /* Array of files to be committed */
int markPrivate; /* All new artifacts are private if true */
int clockSkewSeen; /* True if clocks on client and server out of sync */
int wikiFlags; /* Wiki conversion flags applied to %W */
char isHTTP; /* True if server/CGI modes, else assume CLI. */
char javascriptHyperlink; /* If true, set href= using script, not HTML */
Blob httpHeader; /* Complete text of the HTTP request header */
UrlData url; /* Information about current URL */
const char *zLogin; /* Login name. NULL or "" if not logged in. */
const char *zSSLIdentity; /* Value of --ssl-identity option, filename of
** SSL client identity */
int useLocalauth; /* No login required if from 127.0.0.1 */
int noPswd; /* Logged in without password (on 127.0.0.1) */
int userUid; /* Integer user id */
int isHuman; /* True if access by a human, not a spider or bot */
int comFmtFlags; /* Zero or more "COMMENT_PRINT_*" bit flags */
/* Information used to populate the RCVFROM table */
int rcvid; /* The rcvid. 0 if not yet defined. */
char *zIpAddr; /* The remote IP address */
char *zNonce; /* The nonce used for login */
/* permissions used by the server */
|
| ︙ | ︙ | |||
227 228 229 230 231 232 233 |
responses and always exit() with
code 0 to avoid an HTTP 500 error.
*/
int resultCode; /* used for passing back specific codes
** from /json callbacks. */
int errorDetailParanoia; /* 0=full error codes, 1=%10, 2=%100, 3=%1000 */
cson_output_opt outOpt; /* formatting options for JSON mode. */
| | | | | | | | | | | | | | | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 |
responses and always exit() with
code 0 to avoid an HTTP 500 error.
*/
int resultCode; /* used for passing back specific codes
** from /json callbacks. */
int errorDetailParanoia; /* 0=full error codes, 1=%10, 2=%100, 3=%1000 */
cson_output_opt outOpt; /* formatting options for JSON mode. */
cson_value *authToken; /* authentication token */
const char *jsonp; /* Name of JSONP function wrapper. */
unsigned char dispatchDepth /* Tells JSON command dispatching
which argument we are currently
working on. For this purpose, arg#0
is the "json" path/CLI arg.
*/;
struct { /* "garbage collector" */
cson_value *v;
cson_array *a;
} gc;
struct { /* JSON POST data. */
cson_value *v;
cson_array *a;
int offset; /* Tells us which PATH_INFO/CLI args
part holds the "json" command, so
that we can account for sub-repos
and path prefixes. This is handled
differently for CLI and CGI modes.
*/
const char *commandStr /*"command" request param.*/;
} cmd;
struct { /* JSON POST data. */
cson_value *v;
cson_object *o;
} post;
struct { /* GET/COOKIE params in JSON mode. */
cson_value *v;
cson_object *o;
} param;
struct {
cson_value *v;
cson_object *o;
} reqPayload; /* request payload object (if any) */
cson_array *warnings; /* response warnings */
int timerId; /* fetched from fossil_timer_start() */
} json;
#endif /* FOSSIL_ENABLE_JSON */
};
/*
** Macro for debugging:
|
| ︙ | ︙ | |||
389 390 391 392 393 394 395 | Blob file = empty_blob; /* Content of the file */ Blob line = empty_blob; /* One line of the file */ unsigned int nLine; /* Number of lines in the file*/ unsigned int i, j, k; /* Loop counters */ int n; /* Number of bytes in one line */ char *z; /* General use string pointer */ char **newArgv; /* New expanded g.argv under construction */ | | | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | Blob file = empty_blob; /* Content of the file */ Blob line = empty_blob; /* One line of the file */ unsigned int nLine; /* Number of lines in the file*/ unsigned int i, j, k; /* Loop counters */ int n; /* Number of bytes in one line */ char *z; /* General use string pointer */ char **newArgv; /* New expanded g.argv under construction */ const char *zFileName; /* input file name */ FILE *inFile; /* input FILE */ #if defined(_WIN32) wchar_t buf[MAX_PATH]; #endif g.argc = argc; g.argv = argv; |
| ︙ | ︙ | |||
488 489 490 491 492 493 494 |
zNewArgv[i] = fossil_strdup(argv[i]);
}
return zNewArgv;
}
#endif
/*
| | | | > > > > > > > > | | > > > > > > > > > > > > > > > | 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
zNewArgv[i] = fossil_strdup(argv[i]);
}
return zNewArgv;
}
#endif
/*
** Returns a name for a SQLite return code.
*/
static const char *fossil_sqlite_return_code_name(int rc){
static char zCode[30];
switch( rc & 0xff ){
case SQLITE_OK: return "SQLITE_OK";
case SQLITE_ERROR: return "SQLITE_ERROR";
case SQLITE_INTERNAL: return "SQLITE_INTERNAL";
case SQLITE_PERM: return "SQLITE_PERM";
case SQLITE_ABORT: return "SQLITE_ABORT";
case SQLITE_BUSY: return "SQLITE_BUSY";
case SQLITE_LOCKED: return "SQLITE_LOCKED";
case SQLITE_NOMEM: return "SQLITE_NOMEM";
case SQLITE_READONLY: return "SQLITE_READONLY";
case SQLITE_INTERRUPT: return "SQLITE_INTERRUPT";
case SQLITE_IOERR: return "SQLITE_IOERR";
case SQLITE_CORRUPT: return "SQLITE_CORRUPT";
case SQLITE_NOTFOUND: return "SQLITE_NOTFOUND";
case SQLITE_FULL: return "SQLITE_FULL";
case SQLITE_CANTOPEN: return "SQLITE_CANTOPEN";
case SQLITE_PROTOCOL: return "SQLITE_PROTOCOL";
case SQLITE_EMPTY: return "SQLITE_EMPTY";
case SQLITE_SCHEMA: return "SQLITE_SCHEMA";
case SQLITE_TOOBIG: return "SQLITE_TOOBIG";
case SQLITE_CONSTRAINT: return "SQLITE_CONSTRAINT";
case SQLITE_MISMATCH: return "SQLITE_MISMATCH";
case SQLITE_MISUSE: return "SQLITE_MISUSE";
case SQLITE_NOLFS: return "SQLITE_NOLFS";
case SQLITE_AUTH: return "SQLITE_AUTH";
case SQLITE_FORMAT: return "SQLITE_FORMAT";
case SQLITE_RANGE: return "SQLITE_RANGE";
case SQLITE_NOTADB: return "SQLITE_NOTADB";
case SQLITE_NOTICE: return "SQLITE_NOTICE";
case SQLITE_WARNING: return "SQLITE_WARNING";
case SQLITE_ROW: return "SQLITE_ROW";
case SQLITE_DONE: return "SQLITE_DONE";
default: {
sqlite3_snprintf(sizeof(zCode), zCode, "SQLite return code %d", rc);
}
}
return zCode;
}
/* Error logs from SQLite */
static void fossil_sqlite_log(void *notUsed, int iCode, const char *zErrmsg){
#ifdef __APPLE__
/* Disable the file alias warning on apple products because Time Machine
** creates lots of aliases and the warning alarms people. */
if( iCode==SQLITE_WARNING ) return;
#endif
if( iCode==SQLITE_SCHEMA ) return;
fossil_warning("%s: %s", fossil_sqlite_return_code_name(iCode), zErrmsg);
}
/*
** This function attempts to find command line options known to contain
** bitwise flags and initializes the associated global variables. After
** this function executes, all global variables (i.e. in the "g" struct)
** containing option-settable bitwise flag fields must be initialized.
*/
static void fossil_init_flags_from_options(void){
const char *zValue = find_option("comfmtflags", 0, 1);
if( zValue ){
g.comFmtFlags = atoi(zValue);
}else{
g.comFmtFlags = COMMENT_PRINT_DEFAULT;
}
}
/*
** This procedure runs first.
*/
#if defined(_WIN32) && !defined(BROKEN_MINGW_CMDLINE)
int _dowildcard = -1; /* This turns on command-line globbing in MinGW-w64 */
|
| ︙ | ︙ | |||
554 555 556 557 558 559 560 |
const char *zCmdName = "unknown";
int idx;
int rc;
if( sqlite3_libversion_number()<3008003 ){
fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.3",
sqlite3_libversion());
}
| | | 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 |
const char *zCmdName = "unknown";
int idx;
int rc;
if( sqlite3_libversion_number()<3008003 ){
fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.3",
sqlite3_libversion());
}
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
memset(&g, 0, sizeof(g));
g.now = time(0);
g.httpHeader = empty_blob;
#ifdef FOSSIL_ENABLE_JSON
#if defined(NDEBUG)
g.json.errorDetailParanoia = 2 /* FIXME: make configurable
|
| ︙ | ︙ | |||
579 580 581 582 583 584 585 586 587 588 589 590 591 592 |
expand_args_option(argc, argv);
#ifdef FOSSIL_ENABLE_TCL
memset(&g.tcl, 0, sizeof(TclContext));
g.tcl.argc = g.argc;
g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
#endif
g.mainTimerId = fossil_timer_start();
g.zVfsName = find_option("vfs",0,1);
if( g.zVfsName==0 ){
g.zVfsName = fossil_getenv("FOSSIL_VFS");
}
if( g.zVfsName ){
sqlite3_vfs *pVfs = sqlite3_vfs_find(g.zVfsName);
if( pVfs ){
| > | 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 |
expand_args_option(argc, argv);
#ifdef FOSSIL_ENABLE_TCL
memset(&g.tcl, 0, sizeof(TclContext));
g.tcl.argc = g.argc;
g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
#endif
g.mainTimerId = fossil_timer_start();
capture_case_sensitive_option();
g.zVfsName = find_option("vfs",0,1);
if( g.zVfsName==0 ){
g.zVfsName = fossil_getenv("FOSSIL_VFS");
}
if( g.zVfsName ){
sqlite3_vfs *pVfs = sqlite3_vfs_find(g.zVfsName);
if( pVfs ){
|
| ︙ | ︙ | |||
632 633 634 635 636 637 638 639 640 641 642 643 644 645 |
#ifdef FOSSIL_ENABLE_TH1_HOOKS
g.fNoThHook = find_option("no-th-hook", 0, 0)!=0;
#endif
g.zHttpAuth = 0;
g.zLogin = find_option("user", "U", 1);
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
g.zErrlog = find_option("errorlog", 0, 1);
if( find_option("utc",0,0) ) g.fTimeFormat = 1;
if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
if( zChdir && file_chdir(zChdir, 0) ){
fossil_fatal("unable to change directories to %s", zChdir);
}
if( find_option("help",0,0)!=0 ){
/* --help anywhere on the command line is translated into
| > | 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 |
#ifdef FOSSIL_ENABLE_TH1_HOOKS
g.fNoThHook = find_option("no-th-hook", 0, 0)!=0;
#endif
g.zHttpAuth = 0;
g.zLogin = find_option("user", "U", 1);
g.zSSLIdentity = find_option("ssl-identity", 0, 1);
g.zErrlog = find_option("errorlog", 0, 1);
fossil_init_flags_from_options();
if( find_option("utc",0,0) ) g.fTimeFormat = 1;
if( find_option("localtime",0,0) ) g.fTimeFormat = 2;
if( zChdir && file_chdir(zChdir, 0) ){
fossil_fatal("unable to change directories to %s", zChdir);
}
if( find_option("help",0,0)!=0 ){
/* --help anywhere on the command line is translated into
|
| ︙ | ︙ | |||
918 919 920 921 922 923 924 925 |
**
** Print the source code version number for the fossil executable.
** If the verbose option is specified, additional details will
** be output about what optional features this binary was compiled
** with
*/
void version_cmd(void){
fossil_print("This is fossil version %s\n", get_version());
| > > | > > > > > > > > > > > > | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 |
**
** Print the source code version number for the fossil executable.
** If the verbose option is specified, additional details will
** be output about what optional features this binary was compiled
** with
*/
void version_cmd(void){
int verboseFlag = 0;
fossil_print("This is fossil version %s\n", get_version());
verboseFlag = find_option("verbose","v",0)!=0;
/* We should be done with options.. */
verify_all_options();
if(!verboseFlag){
return;
}else{
#if defined(FOSSIL_ENABLE_TCL)
int rc;
const char *zRc;
#endif
fossil_print("Compiled on %s %s using %s (%d-bit)\n",
__DATE__, __TIME__, COMPILER_NAME, sizeof(void*)*8);
fossil_print("SQLite %s %.30s\n", sqlite3_libversion(), sqlite3_sourceid());
fossil_print("Schema version %s\n", AUX_SCHEMA);
#if defined(FOSSIL_ENABLE_MINIZ)
fossil_print("miniz %s, loaded %s\n", MZ_VERSION, mz_version());
#else
fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
#endif
#if defined(FOSSIL_ENABLE_SSL)
fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
#endif
#if defined(FOSSIL_ENABLE_TH1_DOCS)
fossil_print("TH1_DOCS\n");
#endif
#if defined(FOSSIL_ENABLE_TH1_HOOKS)
fossil_print("TH1_HOOKS\n");
#endif
#if defined(FOSSIL_ENABLE_TCL)
Th_FossilInit(TH_INIT_DEFAULT | TH_INIT_FORCE_TCL);
rc = Th_Eval(g.interp, 0, "tclInvoke info patchlevel", -1);
|
| ︙ | ︙ | |||
979 980 981 982 983 984 985 |
** %fossil help --t|-test Show test commands only
** %fossil help --x|-aux Show auxiliary commands only
** %fossil help --w|-www Show list of WWW pages
*/
void help_cmd(void){
int rc, idx, isPage = 0;
const char *z;
| | | | 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 |
** %fossil help --t|-test Show test commands only
** %fossil help --x|-aux Show auxiliary commands only
** %fossil help --w|-www Show list of WWW pages
*/
void help_cmd(void){
int rc, idx, isPage = 0;
const char *z;
const char *zCmdOrPage;
const char *zCmdOrPagePlural;
if( g.argc<3 ){
z = g.argv[0];
fossil_print(
"Usage: %s help COMMAND\n"
"Common COMMANDs: (use \"%s help -a|--all\" for a complete list)\n",
z, z);
command_list(0, CMDFLAG_1ST_TIER);
|
| ︙ | ︙ | |||
1049 1050 1051 1052 1053 1054 1055 |
}
/*
** WEBPAGE: help
** URL: /help/CMD
*/
void help_page(void){
| | | | 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
}
/*
** WEBPAGE: help
** URL: /help/CMD
*/
void help_page(void){
const char *zCmd = P("cmd");
if( zCmd==0 ) zCmd = P("name");
style_header("Command-line Help");
if( zCmd ){
int rc, idx;
char *z, *s, *d;
const char *zCmdOrPage = ('/'==*zCmd) ? "page" : "command";
style_submenu_element("Command-List", "Command-List", "%s/help", g.zTop);
@ <h1>The "%s(zCmd)" %s(zCmdOrPage):</h1>
rc = name_search(zCmd, aCommand, count(aCommand), 0, &idx);
if( rc==1 ){
@ unknown command: %s(zCmd)
}else if( rc==2 ){
@ ambiguous command prefix: %s(zCmd)
|
| ︙ | ︙ | |||
1392 1393 1394 1395 1396 1397 1398 |
szFile = 1;
break;
}
if( szFile==0 ){
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
szFile = file_size(zRepo);
}
| | | | 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 |
szFile = 1;
break;
}
if( szFile==0 ){
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
szFile = file_size(zRepo);
}
if( szFile<0 && i>0 ){
const char *zMimetype;
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
zRepo[j] = 0;
if( zPathInfo[i]=='/' && file_isdir(zRepo)==1 ){
fossil_free(zToFree);
i++;
continue;
}
if( pFileGlob!=0
&& file_isfile(zRepo)
&& glob_match(pFileGlob, zRepo)
&& sqlite3_strglob("*.fossil*",zRepo)!=0
&& (zMimetype = mimetype_from_name(zRepo))!=0
&& strcmp(zMimetype, "application/x-fossil-artifact")!=0
){
Blob content;
blob_read_from_file(&content, zRepo);
cgi_set_content_type(zMimetype);
cgi_set_content(&content);
|
| ︙ | ︙ | |||
1648 1649 1650 1651 1652 1653 1654 | } /* If the CGI program contains one or more lines of the form ** ** redirect: repository-filename http://hostname/path/%s ** ** then control jumps here. Search each repository for an artifact ID | | | | | 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 | } /* If the CGI program contains one or more lines of the form ** ** redirect: repository-filename http://hostname/path/%s ** ** then control jumps here. Search each repository for an artifact ID ** or ticket ID that matches the "name" CGI parameter and for the ** first match, redirect to the corresponding URL with the "name" CGI ** parameter inserted. Paint an error page if no match is found. ** ** If there is a line of the form: ** ** redirect: * URL ** ** Then a redirect is made to URL if no match is found. Otherwise a ** very primitive error message is returned. |
| ︙ | ︙ | |||
1675 1676 1677 1678 1679 1680 1681 |
if( zName && validate16(zName, strlen(zName)) ){
for(i=0; i<nRedirect; i++){
if( fossil_strcmp(azRedirect[i*2],"*")==0 ){
zNotFound = azRedirect[i*2+1];
continue;
}
db_open_repository(azRedirect[i*2]);
| | > | | | 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 |
if( zName && validate16(zName, strlen(zName)) ){
for(i=0; i<nRedirect; i++){
if( fossil_strcmp(azRedirect[i*2],"*")==0 ){
zNotFound = azRedirect[i*2+1];
continue;
}
db_open_repository(azRedirect[i*2]);
if( db_exists("SELECT 1 FROM blob WHERE uuid GLOB '%q*'", zName) ||
db_exists("SELECT 1 FROM ticket WHERE tkt_uuid GLOB '%q*'", zName) ){
cgi_redirectf(azRedirect[i*2+1] /*works-like:"%s"*/, zName);
return;
}
db_close(1);
}
}
if( zNotFound ){
cgi_redirectf(zNotFound /*works-like:"%s"*/, zName);
}else{
@ <html>
@ <head><title>No Such Object</title></head>
@ <body>
@ <p>No such object: <b>%h(zName)</b></p>
@ </body>
cgi_reply();
|
| ︙ | ︙ | |||
1798 1799 1800 1801 1802 1803 1804 |
redirect_web_page(nRedirect, azRedirect);
}else{
process_one_web_page(zNotFound, pFileGlob);
}
}
/*
| | | | | | | | | | | | | | 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 |
redirect_web_page(nRedirect, azRedirect);
}else{
process_one_web_page(zNotFound, pFileGlob);
}
}
/*
** If g.argv[arg] exists then it is either the name of a repository
** that will be used by a server, or else it is a directory that
** contains multiple repositories that can be served. If g.argv[arg]
** is a directory, the repositories it contains must be named
** "*.fossil". If g.argv[arg] does not exists, then we must be within
** a check-out and the repository to be served is the repository of
** that check-out.
**
** Open the repository to be served if it is known. If g.argv[arg] is
** a directory full of repositories, then set g.zRepositoryName to
** the name of that directory and the specific repository will be
** opened later by process_one_web_page() based on the content of
** the PATH_INFO variable.
**
** If disallowDir is set, then the directory full of repositories method
** is disallowed.
*/
static void find_server_repository(int disallowDir, int arg){
if( g.argc<=arg ){
db_must_be_within_tree();
}else if( file_isdir(g.argv[arg])==1 ){
if( disallowDir ){
fossil_fatal("\"%s\" is a directory, not a repository file", g.argv[arg]);
}else{
g.zRepositoryName = mprintf("%s", g.argv[arg]);
file_simplify_name(g.zRepositoryName, -1, 0);
}
}else{
db_open_repository(g.argv[arg]);
}
}
/*
** undocumented format:
**
** fossil http INFILE OUTFILE IPADDR ?REPOSITORY?
**
** The argv==6 form is used by the win32 server only.
**
** COMMAND: http*
**
** Usage: %fossil http ?REPOSITORY? ?OPTIONS?
**
** Handle a single HTTP request appearing on stdin. The resulting webpage
** is delivered on stdout. This method is used to launch an HTTP request
** handler from inetd, for example. The argument is the name of the
** repository.
**
** If REPOSITORY is a directory that contains one or more repositories,
|
| ︙ | ︙ | |||
1881 1882 1883 1884 1885 1886 1887 |
** --files GLOB comma-separate glob patterns for static file to serve
** --baseurl URL base URL (useful with reverse proxies)
** --scgi Interpret input as SCGI rather than HTTP
**
** See also: cgi, server, winsrv
*/
void cmd_http(void){
| | | 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 |
** --files GLOB comma-separate glob patterns for static file to serve
** --baseurl URL base URL (useful with reverse proxies)
** --scgi Interpret input as SCGI rather than HTTP
**
** See also: cgi, server, winsrv
*/
void cmd_http(void){
const char *zIpAddr = 0;
const char *zNotFound;
const char *zHost;
const char *zAltBase;
const char *zFileGlob;
int useSCGI;
/* The winhttp module passes the --files option as --files-urlenc with
|
| ︙ | ︙ | |||
1906 1907 1908 1909 1910 1911 1912 |
}
zNotFound = find_option("notfound", 0, 1);
g.useLocalauth = find_option("localauth", 0, 0)!=0;
g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
useSCGI = find_option("scgi", 0, 0)!=0;
zAltBase = find_option("baseurl", 0, 1);
if( zAltBase ) set_base_url(zAltBase);
| | > > > > > > > | | | | | > | < | 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 |
}
zNotFound = find_option("notfound", 0, 1);
g.useLocalauth = find_option("localauth", 0, 0)!=0;
g.sslNotAvailable = find_option("nossl", 0, 0)!=0;
useSCGI = find_option("scgi", 0, 0)!=0;
zAltBase = find_option("baseurl", 0, 1);
if( zAltBase ) set_base_url(zAltBase);
if( find_option("https",0,0)!=0 ){
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
cgi_replace_parameter("HTTPS","on");
}
zHost = find_option("host", 0, 1);
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
g.cgiOutput = 1;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
fossil_fatal("no repository specified");
}
g.fullHttpReply = 1;
if( g.argc>=5 ){
g.httpIn = fossil_fopen(g.argv[2], "rb");
g.httpOut = fossil_fopen(g.argv[3], "wb");
zIpAddr = g.argv[4];
find_server_repository(0, 5);
}else{
g.httpIn = stdin;
g.httpOut = stdout;
find_server_repository(0, 2);
}
if( zIpAddr==0 ){
zIpAddr = cgi_ssh_remote_addr(0);
if( zIpAddr && zIpAddr[0] ){
g.fSshClient |= CGI_SSH_CLIENT;
}
}
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
if( useSCGI ){
cgi_handle_scgi_request();
}else if( g.fSshClient & CGI_SSH_CLIENT ){
ssh_request_loop(zIpAddr, glob_create(zFileGlob));
}else{
cgi_handle_http_request(zIpAddr);
|
| ︙ | ︙ | |||
1969 1970 1971 1972 1973 1974 1975 |
const char *zIpAddr; /* IP address of remote client */
Th_InitTraceLog();
login_set_capabilities("sx", 0);
g.useLocalauth = 1;
g.httpIn = stdin;
g.httpOut = stdout;
| | | 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 |
const char *zIpAddr; /* IP address of remote client */
Th_InitTraceLog();
login_set_capabilities("sx", 0);
g.useLocalauth = 1;
g.httpIn = stdin;
g.httpOut = stdout;
find_server_repository(0, 2);
g.cgiOutput = 1;
g.fullHttpReply = 1;
zIpAddr = cgi_ssh_remote_addr(0);
if( zIpAddr && zIpAddr[0] ){
g.fSshClient |= CGI_SSH_CLIENT;
ssh_request_loop(zIpAddr, 0);
}else{
|
| ︙ | ︙ | |||
2075 2076 2077 2078 2079 2080 2081 |
char *zIpAddr = 0; /* Bind to this IP address */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
| | > > > > > > > | > > > > | | 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 |
char *zIpAddr = 0; /* Bind to this IP address */
#if defined(_WIN32)
const char *zStopperFile; /* Name of file used to terminate server */
zStopperFile = find_option("stopper", 0, 1);
#endif
zFileGlob = find_option("files-urlenc",0,1);
if( zFileGlob ){
char *z = mprintf("%s", zFileGlob);
dehttpize(z);
zFileGlob = z;
}else{
zFileGlob = find_option("files",0,1);
}
g.useLocalauth = find_option("localauth", 0, 0)!=0;
Th_InitTraceLog();
zPort = find_option("port", "P", 1);
zNotFound = find_option("notfound", 0, 1);
zAltBase = find_option("baseurl", 0, 1);
if( find_option("scgi", 0, 0)!=0 ) flags |= HTTP_SERVER_SCGI;
if( zAltBase ){
set_base_url(zAltBase);
}
if( find_option("localhost", 0, 0)!=0 ){
flags |= HTTP_SERVER_LOCALHOST;
}
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 ) usage("?REPOSITORY?");
isUiCmd = g.argv[1][0]=='u';
if( isUiCmd ){
flags |= HTTP_SERVER_LOCALHOST;
g.useLocalauth = 1;
}
find_server_repository(isUiCmd && zNotFound==0, 2);
if( zPort ){
int i;
for(i=strlen(zPort)-1; i>=0 && zPort[i]!=':'; i--){}
if( i>0 ){
zIpAddr = mprintf("%.*s", i, zPort);
zPort += i+1;
}
|
| ︙ | ︙ | |||
2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 |
#endif
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
if( zIpAddr ){
zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
}else{
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
}
}
db_close(1);
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
fossil_fatal("unable to listen on TCP socket %d", iPort);
}
g.sslNotAvailable = 1;
g.httpIn = stdin;
g.httpOut = stdout;
if( g.fHttpTrace || g.fSqlTrace ){
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
}
g.cgiOutput = 1;
| > > > > | > > | 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 |
#endif
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
if( zIpAddr ){
zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
}else{
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
}
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
}else{
db_setup_server_and_project_codes(1);
}
db_close(1);
if( cgi_http_server(iPort, mxPort, zBrowserCmd, zIpAddr, flags) ){
fossil_fatal("unable to listen on TCP socket %d", iPort);
}
g.sslNotAvailable = 1;
g.httpIn = stdin;
g.httpOut = stdout;
if( g.fHttpTrace || g.fSqlTrace ){
fprintf(stderr, "====== SERVER pid %d =======\n", getpid());
}
g.cgiOutput = 1;
find_server_repository(isUiCmd && zNotFound==0, 2);
g.zRepositoryName = enter_chroot_jail(g.zRepositoryName);
if( flags & HTTP_SERVER_SCGI ){
cgi_handle_scgi_request();
}else{
cgi_handle_http_request(0);
}
process_one_web_page(zNotFound, glob_create(zFileGlob));
#else
/* Win32 implementation */
if( isUiCmd ){
zBrowser = db_get("web-browser", "start");
if( zIpAddr ){
zBrowserCmd = mprintf("%s http://%s:%%d/ &", zBrowser, zIpAddr);
}else{
zBrowserCmd = mprintf("%s http://localhost:%%d/ &", zBrowser);
}
if( g.repositoryOpen ) flags |= HTTP_SERVER_HAD_REPOSITORY;
if( g.localOpen ) flags |= HTTP_SERVER_HAD_CHECKOUT;
}
db_close(1);
if( win32_http_service(iPort, zNotFound, zFileGlob, flags) ){
win32_http_server(iPort, mxPort, zBrowserCmd,
zStopperFile, zNotFound, zFileGlob, zIpAddr, flags);
}
#endif
|
| ︙ | ︙ |
Changes to src/main.mk.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/builtin.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ |
| ︙ | ︙ | |||
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ | > > > > | 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 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c EXTRA_FILES = \ $(SRCDIR)/diff.tcl TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/builtin_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ |
| ︙ | ︙ | |||
244 245 246 247 248 249 250 251 252 253 254 255 256 257 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ | > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/builtin.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ |
| ︙ | ︙ | |||
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 | all: $(OBJDIR) $(APPNAME) install: $(APPNAME) mkdir -p $(INSTALLDIR) mv $(APPNAME) $(INSTALLDIR) $(OBJDIR): -mkdir $(OBJDIR) $(OBJDIR)/translate: $(SRCDIR)/translate.c $(BCC) -o $(OBJDIR)/translate $(SRCDIR)/translate.c $(OBJDIR)/makeheaders: $(SRCDIR)/makeheaders.c $(BCC) -o $(OBJDIR)/makeheaders $(SRCDIR)/makeheaders.c $(OBJDIR)/mkindex: $(SRCDIR)/mkindex.c $(BCC) -o $(OBJDIR)/mkindex $(SRCDIR)/mkindex.c $(OBJDIR)/mkversion: $(SRCDIR)/mkversion.c $(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c # WARNING. DANGER. Running the test suite modifies the repository the # build is done from, i.e. the checkout belongs to. Do not sync/push # the repository after running the tests. test: $(OBJDIR) $(APPNAME) $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion $(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h # Setup the options used to compile the included SQLite library. | > > > > > > > > > > | > > > > > | | > > > > > > > > > | > > > > > > > | > | | > > > > | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | > | | > | | > | | > | | > | | > | | > | | > > > > > > > > > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | | | | > > > | | 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 |
all: $(OBJDIR) $(APPNAME)
install: $(APPNAME)
mkdir -p $(INSTALLDIR)
mv $(APPNAME) $(INSTALLDIR)
codecheck: $(TRANS_SRC) $(OBJDIR)/codecheck1
$(OBJDIR)/codecheck1 $(TRANS_SRC)
$(OBJDIR):
-mkdir $(OBJDIR)
$(OBJDIR)/translate: $(SRCDIR)/translate.c
$(BCC) -o $(OBJDIR)/translate $(SRCDIR)/translate.c
$(OBJDIR)/makeheaders: $(SRCDIR)/makeheaders.c
$(BCC) -o $(OBJDIR)/makeheaders $(SRCDIR)/makeheaders.c
$(OBJDIR)/mkindex: $(SRCDIR)/mkindex.c
$(BCC) -o $(OBJDIR)/mkindex $(SRCDIR)/mkindex.c
$(OBJDIR)/mkbuiltin: $(SRCDIR)/mkbuiltin.c
$(BCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR)/mkbuiltin.c
$(OBJDIR)/mkversion: $(SRCDIR)/mkversion.c
$(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
$(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
$(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
# WARNING. DANGER. Running the test suite modifies the repository the
# build is done from, i.e. the checkout belongs to. Do not sync/push
# the repository after running the tests.
test: $(OBJDIR) $(APPNAME)
$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
# Setup the options used to compile the included SQLite library.
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
# Setup the options used to compile the included SQLite shell.
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
-DSQLITE_SHELL_DBNAME_PROC=fossil_open
# Setup the options used to compile the included miniz library.
MINIZ_OPTIONS = -DMINIZ_NO_STDIO \
-DMINIZ_NO_TIME \
-DMINIZ_NO_ARCHIVE_APIS
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
# to 1. If it is set to 1, then there is no need to build or link
# the sqlite3.o object. Instead, the system SQLite will be linked
# using -lsqlite3.
SQLITE3_OBJ.1 =
SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
SQLITE3_OBJ. = $(SQLITE3_OBJ.0)
# The FOSSIL_ENABLE_MINIZ variable may be undefined, set to 0, or
# set to 1. If it is set to 1, the miniz library included in the
# source tree should be used; otherwise, it should not.
MINIZ_OBJ.0 =
MINIZ_OBJ.1 = $(OBJDIR)/miniz.o
MINIZ_OBJ. = $(MINIZ_OBJ.0)
EXTRAOBJ = \
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \
$(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \
$(OBJDIR)/shell.o \
$(OBJDIR)/th.o \
$(OBJDIR)/th_lang.o \
$(OBJDIR)/th_tcl.o \
$(OBJDIR)/cson_amalgamation.o
$(APPNAME): $(OBJDIR)/headers $(OBJDIR)/codecheck1 $(OBJ) $(EXTRAOBJ)
$(OBJDIR)/codecheck1 $(TRANS_SRC)
$(TCC) -o $(APPNAME) $(OBJ) $(EXTRAOBJ) $(LIB)
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
# noop
clean:
rm -rf $(OBJDIR)/* $(APPNAME)
$(OBJDIR)/page_index.h: $(TRANS_SRC) $(OBJDIR)/mkindex
$(OBJDIR)/mkindex $(TRANS_SRC) >$@
$(OBJDIR)/builtin_data.h: $(OBJDIR)/mkbuiltin $(EXTRA_FILES)
$(OBJDIR)/mkbuiltin $(EXTRA_FILES) >$@
$(OBJDIR)/headers: $(OBJDIR)/page_index.h $(OBJDIR)/builtin_data.h $(OBJDIR)/makeheaders $(OBJDIR)/VERSION.h
$(OBJDIR)/makeheaders $(OBJDIR)/add_.c:$(OBJDIR)/add.h \
$(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h \
$(OBJDIR)/attach_.c:$(OBJDIR)/attach.h \
$(OBJDIR)/bag_.c:$(OBJDIR)/bag.h \
$(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h \
$(OBJDIR)/blob_.c:$(OBJDIR)/blob.h \
$(OBJDIR)/branch_.c:$(OBJDIR)/branch.h \
$(OBJDIR)/browse_.c:$(OBJDIR)/browse.h \
$(OBJDIR)/builtin_.c:$(OBJDIR)/builtin.h \
$(OBJDIR)/cache_.c:$(OBJDIR)/cache.h \
$(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h \
$(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h \
$(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h \
$(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h \
$(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h \
$(OBJDIR)/clone_.c:$(OBJDIR)/clone.h \
$(OBJDIR)/comformat_.c:$(OBJDIR)/comformat.h \
$(OBJDIR)/configure_.c:$(OBJDIR)/configure.h \
$(OBJDIR)/content_.c:$(OBJDIR)/content.h \
$(OBJDIR)/db_.c:$(OBJDIR)/db.h \
$(OBJDIR)/delta_.c:$(OBJDIR)/delta.h \
$(OBJDIR)/deltacmd_.c:$(OBJDIR)/deltacmd.h \
$(OBJDIR)/descendants_.c:$(OBJDIR)/descendants.h \
$(OBJDIR)/diff_.c:$(OBJDIR)/diff.h \
$(OBJDIR)/diffcmd_.c:$(OBJDIR)/diffcmd.h \
$(OBJDIR)/doc_.c:$(OBJDIR)/doc.h \
$(OBJDIR)/encode_.c:$(OBJDIR)/encode.h \
$(OBJDIR)/event_.c:$(OBJDIR)/event.h \
$(OBJDIR)/export_.c:$(OBJDIR)/export.h \
$(OBJDIR)/file_.c:$(OBJDIR)/file.h \
$(OBJDIR)/finfo_.c:$(OBJDIR)/finfo.h \
$(OBJDIR)/fusefs_.c:$(OBJDIR)/fusefs.h \
$(OBJDIR)/glob_.c:$(OBJDIR)/glob.h \
$(OBJDIR)/graph_.c:$(OBJDIR)/graph.h \
$(OBJDIR)/gzip_.c:$(OBJDIR)/gzip.h \
$(OBJDIR)/http_.c:$(OBJDIR)/http.h \
$(OBJDIR)/http_socket_.c:$(OBJDIR)/http_socket.h \
$(OBJDIR)/http_ssl_.c:$(OBJDIR)/http_ssl.h \
$(OBJDIR)/http_transport_.c:$(OBJDIR)/http_transport.h \
$(OBJDIR)/import_.c:$(OBJDIR)/import.h \
$(OBJDIR)/info_.c:$(OBJDIR)/info.h \
$(OBJDIR)/json_.c:$(OBJDIR)/json.h \
$(OBJDIR)/json_artifact_.c:$(OBJDIR)/json_artifact.h \
$(OBJDIR)/json_branch_.c:$(OBJDIR)/json_branch.h \
$(OBJDIR)/json_config_.c:$(OBJDIR)/json_config.h \
$(OBJDIR)/json_diff_.c:$(OBJDIR)/json_diff.h \
$(OBJDIR)/json_dir_.c:$(OBJDIR)/json_dir.h \
$(OBJDIR)/json_finfo_.c:$(OBJDIR)/json_finfo.h \
$(OBJDIR)/json_login_.c:$(OBJDIR)/json_login.h \
$(OBJDIR)/json_query_.c:$(OBJDIR)/json_query.h \
$(OBJDIR)/json_report_.c:$(OBJDIR)/json_report.h \
$(OBJDIR)/json_status_.c:$(OBJDIR)/json_status.h \
$(OBJDIR)/json_tag_.c:$(OBJDIR)/json_tag.h \
$(OBJDIR)/json_timeline_.c:$(OBJDIR)/json_timeline.h \
$(OBJDIR)/json_user_.c:$(OBJDIR)/json_user.h \
$(OBJDIR)/json_wiki_.c:$(OBJDIR)/json_wiki.h \
$(OBJDIR)/leaf_.c:$(OBJDIR)/leaf.h \
$(OBJDIR)/loadctrl_.c:$(OBJDIR)/loadctrl.h \
$(OBJDIR)/login_.c:$(OBJDIR)/login.h \
$(OBJDIR)/lookslike_.c:$(OBJDIR)/lookslike.h \
$(OBJDIR)/main_.c:$(OBJDIR)/main.h \
$(OBJDIR)/manifest_.c:$(OBJDIR)/manifest.h \
$(OBJDIR)/markdown_.c:$(OBJDIR)/markdown.h \
$(OBJDIR)/markdown_html_.c:$(OBJDIR)/markdown_html.h \
$(OBJDIR)/md5_.c:$(OBJDIR)/md5.h \
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
$(OBJDIR)/rebuild_.c:$(OBJDIR)/rebuild.h \
$(OBJDIR)/regexp_.c:$(OBJDIR)/regexp.h \
$(OBJDIR)/report_.c:$(OBJDIR)/report.h \
$(OBJDIR)/rss_.c:$(OBJDIR)/rss.h \
$(OBJDIR)/schema_.c:$(OBJDIR)/schema.h \
$(OBJDIR)/search_.c:$(OBJDIR)/search.h \
$(OBJDIR)/setup_.c:$(OBJDIR)/setup.h \
$(OBJDIR)/sha1_.c:$(OBJDIR)/sha1.h \
$(OBJDIR)/shun_.c:$(OBJDIR)/shun.h \
$(OBJDIR)/skins_.c:$(OBJDIR)/skins.h \
$(OBJDIR)/sqlcmd_.c:$(OBJDIR)/sqlcmd.h \
$(OBJDIR)/stash_.c:$(OBJDIR)/stash.h \
$(OBJDIR)/stat_.c:$(OBJDIR)/stat.h \
$(OBJDIR)/style_.c:$(OBJDIR)/style.h \
$(OBJDIR)/sync_.c:$(OBJDIR)/sync.h \
$(OBJDIR)/tag_.c:$(OBJDIR)/tag.h \
$(OBJDIR)/tar_.c:$(OBJDIR)/tar.h \
$(OBJDIR)/th_main_.c:$(OBJDIR)/th_main.h \
$(OBJDIR)/timeline_.c:$(OBJDIR)/timeline.h \
$(OBJDIR)/tkt_.c:$(OBJDIR)/tkt.h \
$(OBJDIR)/tktsetup_.c:$(OBJDIR)/tktsetup.h \
$(OBJDIR)/undo_.c:$(OBJDIR)/undo.h \
$(OBJDIR)/unicode_.c:$(OBJDIR)/unicode.h \
$(OBJDIR)/update_.c:$(OBJDIR)/update.h \
$(OBJDIR)/url_.c:$(OBJDIR)/url.h \
$(OBJDIR)/user_.c:$(OBJDIR)/user.h \
$(OBJDIR)/utf8_.c:$(OBJDIR)/utf8.h \
$(OBJDIR)/util_.c:$(OBJDIR)/util.h \
$(OBJDIR)/verify_.c:$(OBJDIR)/verify.h \
$(OBJDIR)/vfile_.c:$(OBJDIR)/vfile.h \
$(OBJDIR)/wiki_.c:$(OBJDIR)/wiki.h \
$(OBJDIR)/wikiformat_.c:$(OBJDIR)/wikiformat.h \
$(OBJDIR)/winfile_.c:$(OBJDIR)/winfile.h \
$(OBJDIR)/winhttp_.c:$(OBJDIR)/winhttp.h \
$(OBJDIR)/wysiwyg_.c:$(OBJDIR)/wysiwyg.h \
$(OBJDIR)/xfer_.c:$(OBJDIR)/xfer.h \
$(OBJDIR)/xfersetup_.c:$(OBJDIR)/xfersetup.h \
$(OBJDIR)/zip_.c:$(OBJDIR)/zip.h \
$(SRCDIR)/sqlite3.h \
$(SRCDIR)/th.h \
$(OBJDIR)/VERSION.h
touch $(OBJDIR)/headers
$(OBJDIR)/headers: Makefile
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/json_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
Makefile:
$(OBJDIR)/add_.c: $(SRCDIR)/add.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/add.c >$@
$(OBJDIR)/add.o: $(OBJDIR)/add_.c $(OBJDIR)/add.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/add.o -c $(OBJDIR)/add_.c
$(OBJDIR)/add.h: $(OBJDIR)/headers
$(OBJDIR)/allrepo_.c: $(SRCDIR)/allrepo.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/allrepo.c >$@
$(OBJDIR)/allrepo.o: $(OBJDIR)/allrepo_.c $(OBJDIR)/allrepo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/allrepo.o -c $(OBJDIR)/allrepo_.c
$(OBJDIR)/allrepo.h: $(OBJDIR)/headers
$(OBJDIR)/attach_.c: $(SRCDIR)/attach.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/attach.c >$@
$(OBJDIR)/attach.o: $(OBJDIR)/attach_.c $(OBJDIR)/attach.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/attach.o -c $(OBJDIR)/attach_.c
$(OBJDIR)/attach.h: $(OBJDIR)/headers
$(OBJDIR)/bag_.c: $(SRCDIR)/bag.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/bag.c >$@
$(OBJDIR)/bag.o: $(OBJDIR)/bag_.c $(OBJDIR)/bag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bag.o -c $(OBJDIR)/bag_.c
$(OBJDIR)/bag.h: $(OBJDIR)/headers
$(OBJDIR)/bisect_.c: $(SRCDIR)/bisect.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/bisect.c >$@
$(OBJDIR)/bisect.o: $(OBJDIR)/bisect_.c $(OBJDIR)/bisect.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bisect.o -c $(OBJDIR)/bisect_.c
$(OBJDIR)/bisect.h: $(OBJDIR)/headers
$(OBJDIR)/blob_.c: $(SRCDIR)/blob.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/blob.c >$@
$(OBJDIR)/blob.o: $(OBJDIR)/blob_.c $(OBJDIR)/blob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/blob.o -c $(OBJDIR)/blob_.c
$(OBJDIR)/blob.h: $(OBJDIR)/headers
$(OBJDIR)/branch_.c: $(SRCDIR)/branch.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/branch.c >$@
$(OBJDIR)/branch.o: $(OBJDIR)/branch_.c $(OBJDIR)/branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/branch.o -c $(OBJDIR)/branch_.c
$(OBJDIR)/branch.h: $(OBJDIR)/headers
$(OBJDIR)/browse_.c: $(SRCDIR)/browse.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/browse.c >$@
$(OBJDIR)/browse.o: $(OBJDIR)/browse_.c $(OBJDIR)/browse.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/browse.o -c $(OBJDIR)/browse_.c
$(OBJDIR)/browse.h: $(OBJDIR)/headers
$(OBJDIR)/builtin_.c: $(SRCDIR)/builtin.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/builtin.c >$@
$(OBJDIR)/builtin.o: $(OBJDIR)/builtin_.c $(OBJDIR)/builtin.h $(OBJDIR)/builtin_data.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/builtin.o -c $(OBJDIR)/builtin_.c
$(OBJDIR)/builtin.h: $(OBJDIR)/headers
$(OBJDIR)/cache_.c: $(SRCDIR)/cache.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/cache.c >$@
$(OBJDIR)/cache.o: $(OBJDIR)/cache_.c $(OBJDIR)/cache.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cache.o -c $(OBJDIR)/cache_.c
$(OBJDIR)/cache.h: $(OBJDIR)/headers
$(OBJDIR)/captcha_.c: $(SRCDIR)/captcha.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/captcha.c >$@
$(OBJDIR)/captcha.o: $(OBJDIR)/captcha_.c $(OBJDIR)/captcha.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/captcha.o -c $(OBJDIR)/captcha_.c
$(OBJDIR)/captcha.h: $(OBJDIR)/headers
$(OBJDIR)/cgi_.c: $(SRCDIR)/cgi.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/cgi.c >$@
$(OBJDIR)/cgi.o: $(OBJDIR)/cgi_.c $(OBJDIR)/cgi.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cgi.o -c $(OBJDIR)/cgi_.c
$(OBJDIR)/cgi.h: $(OBJDIR)/headers
$(OBJDIR)/checkin_.c: $(SRCDIR)/checkin.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/checkin.c >$@
$(OBJDIR)/checkin.o: $(OBJDIR)/checkin_.c $(OBJDIR)/checkin.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkin.o -c $(OBJDIR)/checkin_.c
$(OBJDIR)/checkin.h: $(OBJDIR)/headers
$(OBJDIR)/checkout_.c: $(SRCDIR)/checkout.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/checkout.c >$@
$(OBJDIR)/checkout.o: $(OBJDIR)/checkout_.c $(OBJDIR)/checkout.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkout.o -c $(OBJDIR)/checkout_.c
$(OBJDIR)/checkout.h: $(OBJDIR)/headers
$(OBJDIR)/clearsign_.c: $(SRCDIR)/clearsign.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/clearsign.c >$@
$(OBJDIR)/clearsign.o: $(OBJDIR)/clearsign_.c $(OBJDIR)/clearsign.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clearsign.o -c $(OBJDIR)/clearsign_.c
$(OBJDIR)/clearsign.h: $(OBJDIR)/headers
$(OBJDIR)/clone_.c: $(SRCDIR)/clone.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/clone.c >$@
$(OBJDIR)/clone.o: $(OBJDIR)/clone_.c $(OBJDIR)/clone.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clone.o -c $(OBJDIR)/clone_.c
$(OBJDIR)/clone.h: $(OBJDIR)/headers
$(OBJDIR)/comformat_.c: $(SRCDIR)/comformat.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/comformat.c >$@
$(OBJDIR)/comformat.o: $(OBJDIR)/comformat_.c $(OBJDIR)/comformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/comformat.o -c $(OBJDIR)/comformat_.c
$(OBJDIR)/comformat.h: $(OBJDIR)/headers
$(OBJDIR)/configure_.c: $(SRCDIR)/configure.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/configure.c >$@
$(OBJDIR)/configure.o: $(OBJDIR)/configure_.c $(OBJDIR)/configure.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/configure.o -c $(OBJDIR)/configure_.c
$(OBJDIR)/configure.h: $(OBJDIR)/headers
$(OBJDIR)/content_.c: $(SRCDIR)/content.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/content.c >$@
$(OBJDIR)/content.o: $(OBJDIR)/content_.c $(OBJDIR)/content.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/content.o -c $(OBJDIR)/content_.c
$(OBJDIR)/content.h: $(OBJDIR)/headers
$(OBJDIR)/db_.c: $(SRCDIR)/db.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/db.c >$@
$(OBJDIR)/db.o: $(OBJDIR)/db_.c $(OBJDIR)/db.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/db.o -c $(OBJDIR)/db_.c
$(OBJDIR)/db.h: $(OBJDIR)/headers
$(OBJDIR)/delta_.c: $(SRCDIR)/delta.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/delta.c >$@
$(OBJDIR)/delta.o: $(OBJDIR)/delta_.c $(OBJDIR)/delta.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/delta.o -c $(OBJDIR)/delta_.c
$(OBJDIR)/delta.h: $(OBJDIR)/headers
$(OBJDIR)/deltacmd_.c: $(SRCDIR)/deltacmd.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/deltacmd.c >$@
$(OBJDIR)/deltacmd.o: $(OBJDIR)/deltacmd_.c $(OBJDIR)/deltacmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/deltacmd.o -c $(OBJDIR)/deltacmd_.c
$(OBJDIR)/deltacmd.h: $(OBJDIR)/headers
$(OBJDIR)/descendants_.c: $(SRCDIR)/descendants.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/descendants.c >$@
$(OBJDIR)/descendants.o: $(OBJDIR)/descendants_.c $(OBJDIR)/descendants.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/descendants.o -c $(OBJDIR)/descendants_.c
$(OBJDIR)/descendants.h: $(OBJDIR)/headers
$(OBJDIR)/diff_.c: $(SRCDIR)/diff.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/diff.c >$@
$(OBJDIR)/diff.o: $(OBJDIR)/diff_.c $(OBJDIR)/diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diff.o -c $(OBJDIR)/diff_.c
$(OBJDIR)/diff.h: $(OBJDIR)/headers
$(OBJDIR)/diffcmd_.c: $(SRCDIR)/diffcmd.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/diffcmd.c >$@
$(OBJDIR)/diffcmd.o: $(OBJDIR)/diffcmd_.c $(OBJDIR)/diffcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diffcmd.o -c $(OBJDIR)/diffcmd_.c
$(OBJDIR)/diffcmd.h: $(OBJDIR)/headers
$(OBJDIR)/doc_.c: $(SRCDIR)/doc.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/doc.c >$@
$(OBJDIR)/doc.o: $(OBJDIR)/doc_.c $(OBJDIR)/doc.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/doc.o -c $(OBJDIR)/doc_.c
$(OBJDIR)/doc.h: $(OBJDIR)/headers
$(OBJDIR)/encode_.c: $(SRCDIR)/encode.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/encode.c >$@
$(OBJDIR)/encode.o: $(OBJDIR)/encode_.c $(OBJDIR)/encode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/encode.o -c $(OBJDIR)/encode_.c
$(OBJDIR)/encode.h: $(OBJDIR)/headers
$(OBJDIR)/event_.c: $(SRCDIR)/event.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/event.c >$@
$(OBJDIR)/event.o: $(OBJDIR)/event_.c $(OBJDIR)/event.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/event.o -c $(OBJDIR)/event_.c
$(OBJDIR)/event.h: $(OBJDIR)/headers
$(OBJDIR)/export_.c: $(SRCDIR)/export.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/export.c >$@
$(OBJDIR)/export.o: $(OBJDIR)/export_.c $(OBJDIR)/export.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/export.o -c $(OBJDIR)/export_.c
$(OBJDIR)/export.h: $(OBJDIR)/headers
$(OBJDIR)/file_.c: $(SRCDIR)/file.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/file.c >$@
$(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c
$(OBJDIR)/file.h: $(OBJDIR)/headers
$(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/finfo.c >$@
$(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c
$(OBJDIR)/finfo.h: $(OBJDIR)/headers
$(OBJDIR)/fusefs_.c: $(SRCDIR)/fusefs.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/fusefs.c >$@
$(OBJDIR)/fusefs.o: $(OBJDIR)/fusefs_.c $(OBJDIR)/fusefs.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/fusefs.o -c $(OBJDIR)/fusefs_.c
$(OBJDIR)/fusefs.h: $(OBJDIR)/headers
$(OBJDIR)/glob_.c: $(SRCDIR)/glob.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/glob.c >$@
$(OBJDIR)/glob.o: $(OBJDIR)/glob_.c $(OBJDIR)/glob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/glob.o -c $(OBJDIR)/glob_.c
$(OBJDIR)/glob.h: $(OBJDIR)/headers
$(OBJDIR)/graph_.c: $(SRCDIR)/graph.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/graph.c >$@
$(OBJDIR)/graph.o: $(OBJDIR)/graph_.c $(OBJDIR)/graph.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/graph.o -c $(OBJDIR)/graph_.c
$(OBJDIR)/graph.h: $(OBJDIR)/headers
$(OBJDIR)/gzip_.c: $(SRCDIR)/gzip.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/gzip.c >$@
$(OBJDIR)/gzip.o: $(OBJDIR)/gzip_.c $(OBJDIR)/gzip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/gzip.o -c $(OBJDIR)/gzip_.c
$(OBJDIR)/gzip.h: $(OBJDIR)/headers
$(OBJDIR)/http_.c: $(SRCDIR)/http.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/http.c >$@
$(OBJDIR)/http.o: $(OBJDIR)/http_.c $(OBJDIR)/http.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http.o -c $(OBJDIR)/http_.c
$(OBJDIR)/http.h: $(OBJDIR)/headers
$(OBJDIR)/http_socket_.c: $(SRCDIR)/http_socket.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/http_socket.c >$@
$(OBJDIR)/http_socket.o: $(OBJDIR)/http_socket_.c $(OBJDIR)/http_socket.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_socket.o -c $(OBJDIR)/http_socket_.c
$(OBJDIR)/http_socket.h: $(OBJDIR)/headers
$(OBJDIR)/http_ssl_.c: $(SRCDIR)/http_ssl.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/http_ssl.c >$@
$(OBJDIR)/http_ssl.o: $(OBJDIR)/http_ssl_.c $(OBJDIR)/http_ssl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_ssl.o -c $(OBJDIR)/http_ssl_.c
$(OBJDIR)/http_ssl.h: $(OBJDIR)/headers
$(OBJDIR)/http_transport_.c: $(SRCDIR)/http_transport.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/http_transport.c >$@
$(OBJDIR)/http_transport.o: $(OBJDIR)/http_transport_.c $(OBJDIR)/http_transport.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_transport.o -c $(OBJDIR)/http_transport_.c
$(OBJDIR)/http_transport.h: $(OBJDIR)/headers
$(OBJDIR)/import_.c: $(SRCDIR)/import.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/import.c >$@
$(OBJDIR)/import.o: $(OBJDIR)/import_.c $(OBJDIR)/import.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/import.o -c $(OBJDIR)/import_.c
$(OBJDIR)/import.h: $(OBJDIR)/headers
$(OBJDIR)/info_.c: $(SRCDIR)/info.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/info.c >$@
$(OBJDIR)/info.o: $(OBJDIR)/info_.c $(OBJDIR)/info.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/info.o -c $(OBJDIR)/info_.c
$(OBJDIR)/info.h: $(OBJDIR)/headers
$(OBJDIR)/json_.c: $(SRCDIR)/json.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json.c >$@
$(OBJDIR)/json.o: $(OBJDIR)/json_.c $(OBJDIR)/json.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json.o -c $(OBJDIR)/json_.c
$(OBJDIR)/json.h: $(OBJDIR)/headers
$(OBJDIR)/json_artifact_.c: $(SRCDIR)/json_artifact.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_artifact.c >$@
$(OBJDIR)/json_artifact.o: $(OBJDIR)/json_artifact_.c $(OBJDIR)/json_artifact.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_artifact.o -c $(OBJDIR)/json_artifact_.c
$(OBJDIR)/json_artifact.h: $(OBJDIR)/headers
$(OBJDIR)/json_branch_.c: $(SRCDIR)/json_branch.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_branch.c >$@
$(OBJDIR)/json_branch.o: $(OBJDIR)/json_branch_.c $(OBJDIR)/json_branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_branch.o -c $(OBJDIR)/json_branch_.c
$(OBJDIR)/json_branch.h: $(OBJDIR)/headers
$(OBJDIR)/json_config_.c: $(SRCDIR)/json_config.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_config.c >$@
$(OBJDIR)/json_config.o: $(OBJDIR)/json_config_.c $(OBJDIR)/json_config.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_config.o -c $(OBJDIR)/json_config_.c
$(OBJDIR)/json_config.h: $(OBJDIR)/headers
$(OBJDIR)/json_diff_.c: $(SRCDIR)/json_diff.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_diff.c >$@
$(OBJDIR)/json_diff.o: $(OBJDIR)/json_diff_.c $(OBJDIR)/json_diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_diff.o -c $(OBJDIR)/json_diff_.c
$(OBJDIR)/json_diff.h: $(OBJDIR)/headers
$(OBJDIR)/json_dir_.c: $(SRCDIR)/json_dir.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_dir.c >$@
$(OBJDIR)/json_dir.o: $(OBJDIR)/json_dir_.c $(OBJDIR)/json_dir.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_dir.o -c $(OBJDIR)/json_dir_.c
$(OBJDIR)/json_dir.h: $(OBJDIR)/headers
$(OBJDIR)/json_finfo_.c: $(SRCDIR)/json_finfo.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_finfo.c >$@
$(OBJDIR)/json_finfo.o: $(OBJDIR)/json_finfo_.c $(OBJDIR)/json_finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_finfo.o -c $(OBJDIR)/json_finfo_.c
$(OBJDIR)/json_finfo.h: $(OBJDIR)/headers
$(OBJDIR)/json_login_.c: $(SRCDIR)/json_login.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_login.c >$@
$(OBJDIR)/json_login.o: $(OBJDIR)/json_login_.c $(OBJDIR)/json_login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_login.o -c $(OBJDIR)/json_login_.c
$(OBJDIR)/json_login.h: $(OBJDIR)/headers
$(OBJDIR)/json_query_.c: $(SRCDIR)/json_query.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_query.c >$@
$(OBJDIR)/json_query.o: $(OBJDIR)/json_query_.c $(OBJDIR)/json_query.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_query.o -c $(OBJDIR)/json_query_.c
$(OBJDIR)/json_query.h: $(OBJDIR)/headers
$(OBJDIR)/json_report_.c: $(SRCDIR)/json_report.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_report.c >$@
$(OBJDIR)/json_report.o: $(OBJDIR)/json_report_.c $(OBJDIR)/json_report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_report.o -c $(OBJDIR)/json_report_.c
$(OBJDIR)/json_report.h: $(OBJDIR)/headers
$(OBJDIR)/json_status_.c: $(SRCDIR)/json_status.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_status.c >$@
$(OBJDIR)/json_status.o: $(OBJDIR)/json_status_.c $(OBJDIR)/json_status.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_status.o -c $(OBJDIR)/json_status_.c
$(OBJDIR)/json_status.h: $(OBJDIR)/headers
$(OBJDIR)/json_tag_.c: $(SRCDIR)/json_tag.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_tag.c >$@
$(OBJDIR)/json_tag.o: $(OBJDIR)/json_tag_.c $(OBJDIR)/json_tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_tag.o -c $(OBJDIR)/json_tag_.c
$(OBJDIR)/json_tag.h: $(OBJDIR)/headers
$(OBJDIR)/json_timeline_.c: $(SRCDIR)/json_timeline.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_timeline.c >$@
$(OBJDIR)/json_timeline.o: $(OBJDIR)/json_timeline_.c $(OBJDIR)/json_timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_timeline.o -c $(OBJDIR)/json_timeline_.c
$(OBJDIR)/json_timeline.h: $(OBJDIR)/headers
$(OBJDIR)/json_user_.c: $(SRCDIR)/json_user.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_user.c >$@
$(OBJDIR)/json_user.o: $(OBJDIR)/json_user_.c $(OBJDIR)/json_user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_user.o -c $(OBJDIR)/json_user_.c
$(OBJDIR)/json_user.h: $(OBJDIR)/headers
$(OBJDIR)/json_wiki_.c: $(SRCDIR)/json_wiki.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/json_wiki.c >$@
$(OBJDIR)/json_wiki.o: $(OBJDIR)/json_wiki_.c $(OBJDIR)/json_wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_wiki.o -c $(OBJDIR)/json_wiki_.c
$(OBJDIR)/json_wiki.h: $(OBJDIR)/headers
$(OBJDIR)/leaf_.c: $(SRCDIR)/leaf.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/leaf.c >$@
$(OBJDIR)/leaf.o: $(OBJDIR)/leaf_.c $(OBJDIR)/leaf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/leaf.o -c $(OBJDIR)/leaf_.c
$(OBJDIR)/leaf.h: $(OBJDIR)/headers
$(OBJDIR)/loadctrl_.c: $(SRCDIR)/loadctrl.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/loadctrl.c >$@
$(OBJDIR)/loadctrl.o: $(OBJDIR)/loadctrl_.c $(OBJDIR)/loadctrl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/loadctrl.o -c $(OBJDIR)/loadctrl_.c
$(OBJDIR)/loadctrl.h: $(OBJDIR)/headers
$(OBJDIR)/login_.c: $(SRCDIR)/login.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/login.c >$@
$(OBJDIR)/login.o: $(OBJDIR)/login_.c $(OBJDIR)/login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/login.o -c $(OBJDIR)/login_.c
$(OBJDIR)/login.h: $(OBJDIR)/headers
$(OBJDIR)/lookslike_.c: $(SRCDIR)/lookslike.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/lookslike.c >$@
$(OBJDIR)/lookslike.o: $(OBJDIR)/lookslike_.c $(OBJDIR)/lookslike.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/lookslike.o -c $(OBJDIR)/lookslike_.c
$(OBJDIR)/lookslike.h: $(OBJDIR)/headers
$(OBJDIR)/main_.c: $(SRCDIR)/main.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/main.c >$@
$(OBJDIR)/main.o: $(OBJDIR)/main_.c $(OBJDIR)/main.h $(OBJDIR)/page_index.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/main.o -c $(OBJDIR)/main_.c
$(OBJDIR)/main.h: $(OBJDIR)/headers
$(OBJDIR)/manifest_.c: $(SRCDIR)/manifest.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/manifest.c >$@
$(OBJDIR)/manifest.o: $(OBJDIR)/manifest_.c $(OBJDIR)/manifest.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/manifest.o -c $(OBJDIR)/manifest_.c
$(OBJDIR)/manifest.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_.c: $(SRCDIR)/markdown.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/markdown.c >$@
$(OBJDIR)/markdown.o: $(OBJDIR)/markdown_.c $(OBJDIR)/markdown.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown.o -c $(OBJDIR)/markdown_.c
$(OBJDIR)/markdown.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_html_.c: $(SRCDIR)/markdown_html.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/markdown_html.c >$@
$(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
$(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
$(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/md5.c >$@
$(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/md5.o -c $(OBJDIR)/md5_.c
$(OBJDIR)/md5.h: $(OBJDIR)/headers
$(OBJDIR)/merge_.c: $(SRCDIR)/merge.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/merge.c >$@
$(OBJDIR)/merge.o: $(OBJDIR)/merge_.c $(OBJDIR)/merge.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge.o -c $(OBJDIR)/merge_.c
$(OBJDIR)/merge.h: $(OBJDIR)/headers
$(OBJDIR)/merge3_.c: $(SRCDIR)/merge3.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/merge3.c >$@
$(OBJDIR)/merge3.o: $(OBJDIR)/merge3_.c $(OBJDIR)/merge3.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge3.o -c $(OBJDIR)/merge3_.c
$(OBJDIR)/merge3.h: $(OBJDIR)/headers
$(OBJDIR)/moderate_.c: $(SRCDIR)/moderate.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/moderate.c >$@
$(OBJDIR)/moderate.o: $(OBJDIR)/moderate_.c $(OBJDIR)/moderate.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/moderate.o -c $(OBJDIR)/moderate_.c
$(OBJDIR)/moderate.h: $(OBJDIR)/headers
$(OBJDIR)/name_.c: $(SRCDIR)/name.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/name.c >$@
$(OBJDIR)/name.o: $(OBJDIR)/name_.c $(OBJDIR)/name.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/name.o -c $(OBJDIR)/name_.c
$(OBJDIR)/name.h: $(OBJDIR)/headers
$(OBJDIR)/path_.c: $(SRCDIR)/path.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/path.c >$@
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
$(OBJDIR)/path.h: $(OBJDIR)/headers
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/pivot.c >$@
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pivot.o -c $(OBJDIR)/pivot_.c
$(OBJDIR)/pivot.h: $(OBJDIR)/headers
$(OBJDIR)/popen_.c: $(SRCDIR)/popen.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/popen.c >$@
$(OBJDIR)/popen.o: $(OBJDIR)/popen_.c $(OBJDIR)/popen.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/popen.o -c $(OBJDIR)/popen_.c
$(OBJDIR)/popen.h: $(OBJDIR)/headers
$(OBJDIR)/pqueue_.c: $(SRCDIR)/pqueue.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/pqueue.c >$@
$(OBJDIR)/pqueue.o: $(OBJDIR)/pqueue_.c $(OBJDIR)/pqueue.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pqueue.o -c $(OBJDIR)/pqueue_.c
$(OBJDIR)/pqueue.h: $(OBJDIR)/headers
$(OBJDIR)/printf_.c: $(SRCDIR)/printf.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/printf.c >$@
$(OBJDIR)/printf.o: $(OBJDIR)/printf_.c $(OBJDIR)/printf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/printf.o -c $(OBJDIR)/printf_.c
$(OBJDIR)/printf.h: $(OBJDIR)/headers
$(OBJDIR)/rebuild_.c: $(SRCDIR)/rebuild.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/rebuild.c >$@
$(OBJDIR)/rebuild.o: $(OBJDIR)/rebuild_.c $(OBJDIR)/rebuild.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rebuild.o -c $(OBJDIR)/rebuild_.c
$(OBJDIR)/rebuild.h: $(OBJDIR)/headers
$(OBJDIR)/regexp_.c: $(SRCDIR)/regexp.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/regexp.c >$@
$(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
$(OBJDIR)/regexp.h: $(OBJDIR)/headers
$(OBJDIR)/report_.c: $(SRCDIR)/report.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/report.c >$@
$(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/report.o -c $(OBJDIR)/report_.c
$(OBJDIR)/report.h: $(OBJDIR)/headers
$(OBJDIR)/rss_.c: $(SRCDIR)/rss.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/rss.c >$@
$(OBJDIR)/rss.o: $(OBJDIR)/rss_.c $(OBJDIR)/rss.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rss.o -c $(OBJDIR)/rss_.c
$(OBJDIR)/rss.h: $(OBJDIR)/headers
$(OBJDIR)/schema_.c: $(SRCDIR)/schema.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/schema.c >$@
$(OBJDIR)/schema.o: $(OBJDIR)/schema_.c $(OBJDIR)/schema.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/schema.o -c $(OBJDIR)/schema_.c
$(OBJDIR)/schema.h: $(OBJDIR)/headers
$(OBJDIR)/search_.c: $(SRCDIR)/search.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/search.c >$@
$(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c
$(OBJDIR)/search.h: $(OBJDIR)/headers
$(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/setup.c >$@
$(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c
$(OBJDIR)/setup.h: $(OBJDIR)/headers
$(OBJDIR)/sha1_.c: $(SRCDIR)/sha1.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/sha1.c >$@
$(OBJDIR)/sha1.o: $(OBJDIR)/sha1_.c $(OBJDIR)/sha1.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sha1.o -c $(OBJDIR)/sha1_.c
$(OBJDIR)/sha1.h: $(OBJDIR)/headers
$(OBJDIR)/shun_.c: $(SRCDIR)/shun.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/shun.c >$@
$(OBJDIR)/shun.o: $(OBJDIR)/shun_.c $(OBJDIR)/shun.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/shun.o -c $(OBJDIR)/shun_.c
$(OBJDIR)/shun.h: $(OBJDIR)/headers
$(OBJDIR)/skins_.c: $(SRCDIR)/skins.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/skins.c >$@
$(OBJDIR)/skins.o: $(OBJDIR)/skins_.c $(OBJDIR)/skins.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/skins.o -c $(OBJDIR)/skins_.c
$(OBJDIR)/skins.h: $(OBJDIR)/headers
$(OBJDIR)/sqlcmd_.c: $(SRCDIR)/sqlcmd.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/sqlcmd.c >$@
$(OBJDIR)/sqlcmd.o: $(OBJDIR)/sqlcmd_.c $(OBJDIR)/sqlcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sqlcmd.o -c $(OBJDIR)/sqlcmd_.c
$(OBJDIR)/sqlcmd.h: $(OBJDIR)/headers
$(OBJDIR)/stash_.c: $(SRCDIR)/stash.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/stash.c >$@
$(OBJDIR)/stash.o: $(OBJDIR)/stash_.c $(OBJDIR)/stash.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stash.o -c $(OBJDIR)/stash_.c
$(OBJDIR)/stash.h: $(OBJDIR)/headers
$(OBJDIR)/stat_.c: $(SRCDIR)/stat.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/stat.c >$@
$(OBJDIR)/stat.o: $(OBJDIR)/stat_.c $(OBJDIR)/stat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stat.o -c $(OBJDIR)/stat_.c
$(OBJDIR)/stat.h: $(OBJDIR)/headers
$(OBJDIR)/style_.c: $(SRCDIR)/style.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/style.c >$@
$(OBJDIR)/style.o: $(OBJDIR)/style_.c $(OBJDIR)/style.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/style.o -c $(OBJDIR)/style_.c
$(OBJDIR)/style.h: $(OBJDIR)/headers
$(OBJDIR)/sync_.c: $(SRCDIR)/sync.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/sync.c >$@
$(OBJDIR)/sync.o: $(OBJDIR)/sync_.c $(OBJDIR)/sync.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sync.o -c $(OBJDIR)/sync_.c
$(OBJDIR)/sync.h: $(OBJDIR)/headers
$(OBJDIR)/tag_.c: $(SRCDIR)/tag.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/tag.c >$@
$(OBJDIR)/tag.o: $(OBJDIR)/tag_.c $(OBJDIR)/tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tag.o -c $(OBJDIR)/tag_.c
$(OBJDIR)/tag.h: $(OBJDIR)/headers
$(OBJDIR)/tar_.c: $(SRCDIR)/tar.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/tar.c >$@
$(OBJDIR)/tar.o: $(OBJDIR)/tar_.c $(OBJDIR)/tar.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tar.o -c $(OBJDIR)/tar_.c
$(OBJDIR)/tar.h: $(OBJDIR)/headers
$(OBJDIR)/th_main_.c: $(SRCDIR)/th_main.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/th_main.c >$@
$(OBJDIR)/th_main.o: $(OBJDIR)/th_main_.c $(OBJDIR)/th_main.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/th_main.o -c $(OBJDIR)/th_main_.c
$(OBJDIR)/th_main.h: $(OBJDIR)/headers
$(OBJDIR)/timeline_.c: $(SRCDIR)/timeline.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/timeline.c >$@
$(OBJDIR)/timeline.o: $(OBJDIR)/timeline_.c $(OBJDIR)/timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/timeline.o -c $(OBJDIR)/timeline_.c
$(OBJDIR)/timeline.h: $(OBJDIR)/headers
$(OBJDIR)/tkt_.c: $(SRCDIR)/tkt.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/tkt.c >$@
$(OBJDIR)/tkt.o: $(OBJDIR)/tkt_.c $(OBJDIR)/tkt.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tkt.o -c $(OBJDIR)/tkt_.c
$(OBJDIR)/tkt.h: $(OBJDIR)/headers
$(OBJDIR)/tktsetup_.c: $(SRCDIR)/tktsetup.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/tktsetup.c >$@
$(OBJDIR)/tktsetup.o: $(OBJDIR)/tktsetup_.c $(OBJDIR)/tktsetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tktsetup.o -c $(OBJDIR)/tktsetup_.c
$(OBJDIR)/tktsetup.h: $(OBJDIR)/headers
$(OBJDIR)/undo_.c: $(SRCDIR)/undo.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/undo.c >$@
$(OBJDIR)/undo.o: $(OBJDIR)/undo_.c $(OBJDIR)/undo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/undo.o -c $(OBJDIR)/undo_.c
$(OBJDIR)/undo.h: $(OBJDIR)/headers
$(OBJDIR)/unicode_.c: $(SRCDIR)/unicode.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/unicode.c >$@
$(OBJDIR)/unicode.o: $(OBJDIR)/unicode_.c $(OBJDIR)/unicode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/unicode.o -c $(OBJDIR)/unicode_.c
$(OBJDIR)/unicode.h: $(OBJDIR)/headers
$(OBJDIR)/update_.c: $(SRCDIR)/update.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/update.c >$@
$(OBJDIR)/update.o: $(OBJDIR)/update_.c $(OBJDIR)/update.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/update.o -c $(OBJDIR)/update_.c
$(OBJDIR)/update.h: $(OBJDIR)/headers
$(OBJDIR)/url_.c: $(SRCDIR)/url.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/url.c >$@
$(OBJDIR)/url.o: $(OBJDIR)/url_.c $(OBJDIR)/url.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/url.o -c $(OBJDIR)/url_.c
$(OBJDIR)/url.h: $(OBJDIR)/headers
$(OBJDIR)/user_.c: $(SRCDIR)/user.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/user.c >$@
$(OBJDIR)/user.o: $(OBJDIR)/user_.c $(OBJDIR)/user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/user.o -c $(OBJDIR)/user_.c
$(OBJDIR)/user.h: $(OBJDIR)/headers
$(OBJDIR)/utf8_.c: $(SRCDIR)/utf8.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/utf8.c >$@
$(OBJDIR)/utf8.o: $(OBJDIR)/utf8_.c $(OBJDIR)/utf8.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/utf8.o -c $(OBJDIR)/utf8_.c
$(OBJDIR)/utf8.h: $(OBJDIR)/headers
$(OBJDIR)/util_.c: $(SRCDIR)/util.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/util.c >$@
$(OBJDIR)/util.o: $(OBJDIR)/util_.c $(OBJDIR)/util.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/util.o -c $(OBJDIR)/util_.c
$(OBJDIR)/util.h: $(OBJDIR)/headers
$(OBJDIR)/verify_.c: $(SRCDIR)/verify.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/verify.c >$@
$(OBJDIR)/verify.o: $(OBJDIR)/verify_.c $(OBJDIR)/verify.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/verify.o -c $(OBJDIR)/verify_.c
$(OBJDIR)/verify.h: $(OBJDIR)/headers
$(OBJDIR)/vfile_.c: $(SRCDIR)/vfile.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/vfile.c >$@
$(OBJDIR)/vfile.o: $(OBJDIR)/vfile_.c $(OBJDIR)/vfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/vfile.o -c $(OBJDIR)/vfile_.c
$(OBJDIR)/vfile.h: $(OBJDIR)/headers
$(OBJDIR)/wiki_.c: $(SRCDIR)/wiki.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/wiki.c >$@
$(OBJDIR)/wiki.o: $(OBJDIR)/wiki_.c $(OBJDIR)/wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wiki.o -c $(OBJDIR)/wiki_.c
$(OBJDIR)/wiki.h: $(OBJDIR)/headers
$(OBJDIR)/wikiformat_.c: $(SRCDIR)/wikiformat.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/wikiformat.c >$@
$(OBJDIR)/wikiformat.o: $(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
$(OBJDIR)/wikiformat.h: $(OBJDIR)/headers
$(OBJDIR)/winfile_.c: $(SRCDIR)/winfile.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/winfile.c >$@
$(OBJDIR)/winfile.o: $(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
$(OBJDIR)/winfile.h: $(OBJDIR)/headers
$(OBJDIR)/winhttp_.c: $(SRCDIR)/winhttp.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/winhttp.c >$@
$(OBJDIR)/winhttp.o: $(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
$(OBJDIR)/winhttp.h: $(OBJDIR)/headers
$(OBJDIR)/wysiwyg_.c: $(SRCDIR)/wysiwyg.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/wysiwyg.c >$@
$(OBJDIR)/wysiwyg.o: $(OBJDIR)/wysiwyg_.c $(OBJDIR)/wysiwyg.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wysiwyg.o -c $(OBJDIR)/wysiwyg_.c
$(OBJDIR)/wysiwyg.h: $(OBJDIR)/headers
$(OBJDIR)/xfer_.c: $(SRCDIR)/xfer.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/xfer.c >$@
$(OBJDIR)/xfer.o: $(OBJDIR)/xfer_.c $(OBJDIR)/xfer.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfer.o -c $(OBJDIR)/xfer_.c
$(OBJDIR)/xfer.h: $(OBJDIR)/headers
$(OBJDIR)/xfersetup_.c: $(SRCDIR)/xfersetup.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/xfersetup.c >$@
$(OBJDIR)/xfersetup.o: $(OBJDIR)/xfersetup_.c $(OBJDIR)/xfersetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfersetup.o -c $(OBJDIR)/xfersetup_.c
$(OBJDIR)/xfersetup.h: $(OBJDIR)/headers
$(OBJDIR)/zip_.c: $(SRCDIR)/zip.c $(OBJDIR)/translate
$(OBJDIR)/translate $(SRCDIR)/zip.c >$@
$(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
$(OBJDIR)/zip.h: $(OBJDIR)/headers
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h
$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $@
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -c $(SRCDIR)/th.c -o $@
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -c $(SRCDIR)/th_lang.c -o $@
$(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
$(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
$(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
$(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@
#
# The list of all the targets that do not correspond to real files. This stops
# 'make' from getting confused when someone makes an error in a rule.
#
.PHONY: all install test clean
|
Changes to src/makeheaders.c.
| ︙ | ︙ | |||
35 36 37 38 39 40 41 42 43 44 45 | */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <memory.h> #include <sys/stat.h> #include <assert.h> #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__) # ifndef WIN32 # define WIN32 # endif | > > < | 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | */ #include <stdio.h> #include <stdlib.h> #include <ctype.h> #include <memory.h> #include <sys/stat.h> #include <assert.h> #include <string.h> #if defined( __MINGW32__) || defined(__DMC__) || defined(_MSC_VER) || defined(__POCC__) # ifndef WIN32 # define WIN32 # endif #else # include <unistd.h> #endif /* ** Macros for debugging. */ |
| ︙ | ︙ |
Changes to src/makemake.tcl.
| ︙ | ︙ | |||
10 11 12 13 14 15 16 | # Run this script while in the "src" subdirectory. Like this: # # tclsh makemake.tcl # ############################################################################# # Basenames of all source files that get preprocessed using | | > > > > | 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 |
# Run this script while in the "src" subdirectory. Like this:
#
# tclsh makemake.tcl
#
#############################################################################
# Basenames of all source files that get preprocessed using
# "translate" and "makeheaders". To add new C-language source files to the
# project, simply add the basename to this list and rerun this script.
#
# Set the separate extra_files variable further down for how to add non-C
# files, such as string and BLOB resources.
#
set src {
add
allrepo
attach
bag
bisect
blob
branch
browse
builtin
cache
captcha
cgi
checkin
checkout
clearsign
clone
|
| ︙ | ︙ | |||
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 |
winhttp
wysiwyg
xfer
xfersetup
zip
http_ssl
}
# Options used to compile the included SQLite library.
#
set SQLITE_OPTIONS {
-DSQLITE_OMIT_LOAD_EXTENSION=1
-DSQLITE_ENABLE_LOCKING_STYLE=0
-DSQLITE_THREADSAFE=0
-DSQLITE_DEFAULT_FILE_FORMAT=4
-DSQLITE_OMIT_DEPRECATED
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
}
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
# Options used to compile the included SQLite shell.
#
set SHELL_OPTIONS {
-Dmain=sqlite3_shell
-DSQLITE_OMIT_LOAD_EXTENSION=1
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
-DSQLITE_SHELL_DBNAME_PROC=fossil_open
}
# Options used to compile the included SQLite shell on Windows.
#
set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
lappend SHELL_WIN32_OPTIONS -Daccess=file_access
lappend SHELL_WIN32_OPTIONS -Dsystem=fossil_system
lappend SHELL_WIN32_OPTIONS -Dgetenv=fossil_getenv
| > > > > > > > > > > > > > > > | 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 |
winhttp
wysiwyg
xfer
xfersetup
zip
http_ssl
}
# Additional resource files that get built into the executable.
#
set extra_files {
diff.tcl
}
# Options used to compile the included SQLite library.
#
set SQLITE_OPTIONS {
-DNDEBUG=1
-DSQLITE_OMIT_LOAD_EXTENSION=1
-DSQLITE_ENABLE_LOCKING_STYLE=0
-DSQLITE_THREADSAFE=0
-DSQLITE_DEFAULT_FILE_FORMAT=4
-DSQLITE_OMIT_DEPRECATED
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
}
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
# Options used to compile the included SQLite shell.
#
set SHELL_OPTIONS {
-Dmain=sqlite3_shell
-DSQLITE_OMIT_LOAD_EXTENSION=1
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE)
-DSQLITE_SHELL_DBNAME_PROC=fossil_open
}
# miniz (libz drop-in alternative) precompiler flags.
#
set MINIZ_OPTIONS {
-DMINIZ_NO_STDIO
-DMINIZ_NO_TIME
-DMINIZ_NO_ARCHIVE_APIS
}
# Options used to compile the included SQLite shell on Windows.
#
set SHELL_WIN32_OPTIONS $SHELL_OPTIONS
lappend SHELL_WIN32_OPTIONS -Daccess=file_access
lappend SHELL_WIN32_OPTIONS -Dsystem=fossil_system
lappend SHELL_WIN32_OPTIONS -Dgetenv=fossil_getenv
|
| ︙ | ︙ | |||
206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
}
writeln -nonewline "SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
}
writeln "\n"
writeln -nonewline "TRANS_SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/${s}_.c"
}
writeln "\n"
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
writeln "APPNAME = $name\$(E)"
writeln "\n"
writeln [string map [list \
<<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n "] \
| > > > > > | > > > > > > > > > > > > > | | > > > > > > > > > | | > | | | | | > > | > | | < > | | | | | | > | > > > > | | > | | | | | | | | > > > | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 |
XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR) -I$(OBJDIR)
}
writeln -nonewline "SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
}
writeln "\n"
writeln -nonewline "EXTRA_FILES ="
foreach s [lsort $extra_files] {
writeln -nonewline " \\\n \$(SRCDIR)/$s"
}
writeln "\n"
writeln -nonewline "TRANS_SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/${s}_.c"
}
writeln "\n"
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
writeln "APPNAME = $name\$(E)"
writeln "\n"
writeln [string map [list \
<<<SQLITE_OPTIONS>>> [join $SQLITE_OPTIONS " \\\n "] \
<<<SHELL_OPTIONS>>> [join $SHELL_OPTIONS " \\\n "] \
<<<MINIZ_OPTIONS>>> [join $MINIZ_OPTIONS " \\\n "]] {
all: $(OBJDIR) $(APPNAME)
install: $(APPNAME)
mkdir -p $(INSTALLDIR)
mv $(APPNAME) $(INSTALLDIR)
codecheck: $(TRANS_SRC) $(OBJDIR)/codecheck1
$(OBJDIR)/codecheck1 $(TRANS_SRC)
$(OBJDIR):
-mkdir $(OBJDIR)
$(OBJDIR)/translate: $(SRCDIR)/translate.c
$(BCC) -o $(OBJDIR)/translate $(SRCDIR)/translate.c
$(OBJDIR)/makeheaders: $(SRCDIR)/makeheaders.c
$(BCC) -o $(OBJDIR)/makeheaders $(SRCDIR)/makeheaders.c
$(OBJDIR)/mkindex: $(SRCDIR)/mkindex.c
$(BCC) -o $(OBJDIR)/mkindex $(SRCDIR)/mkindex.c
$(OBJDIR)/mkbuiltin: $(SRCDIR)/mkbuiltin.c
$(BCC) -o $(OBJDIR)/mkbuiltin $(SRCDIR)/mkbuiltin.c
$(OBJDIR)/mkversion: $(SRCDIR)/mkversion.c
$(BCC) -o $(OBJDIR)/mkversion $(SRCDIR)/mkversion.c
$(OBJDIR)/codecheck1: $(SRCDIR)/codecheck1.c
$(BCC) -o $(OBJDIR)/codecheck1 $(SRCDIR)/codecheck1.c
# WARNING. DANGER. Running the test suite modifies the repository the
# build is done from, i.e. the checkout belongs to. Do not sync/push
# the repository after running the tests.
test: $(OBJDIR) $(APPNAME)
$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION $(OBJDIR)/mkversion
$(OBJDIR)/mkversion $(SRCDIR)/../manifest.uuid \
$(SRCDIR)/../manifest \
$(SRCDIR)/../VERSION >$(OBJDIR)/VERSION.h
# Setup the options used to compile the included SQLite library.
SQLITE_OPTIONS = <<<SQLITE_OPTIONS>>>
# Setup the options used to compile the included SQLite shell.
SHELL_OPTIONS = <<<SHELL_OPTIONS>>>
# Setup the options used to compile the included miniz library.
MINIZ_OPTIONS = <<<MINIZ_OPTIONS>>>
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
# to 1. If it is set to 1, then there is no need to build or link
# the sqlite3.o object. Instead, the system SQLite will be linked
# using -lsqlite3.
SQLITE3_OBJ.1 =
SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
SQLITE3_OBJ. = $(SQLITE3_OBJ.0)
# The FOSSIL_ENABLE_MINIZ variable may be undefined, set to 0, or
# set to 1. If it is set to 1, the miniz library included in the
# source tree should be used; otherwise, it should not.
MINIZ_OBJ.0 =
MINIZ_OBJ.1 = $(OBJDIR)/miniz.o
MINIZ_OBJ. = $(MINIZ_OBJ.0)
}]
writeln [string map [list <<<NEXT_LINE>>> \\] {
EXTRAOBJ = <<<NEXT_LINE>>>
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
$(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) <<<NEXT_LINE>>>
$(OBJDIR)/shell.o <<<NEXT_LINE>>>
$(OBJDIR)/th.o <<<NEXT_LINE>>>
$(OBJDIR)/th_lang.o <<<NEXT_LINE>>>
$(OBJDIR)/th_tcl.o <<<NEXT_LINE>>>
$(OBJDIR)/cson_amalgamation.o
}]
writeln {
$(APPNAME): $(OBJDIR)/headers $(OBJDIR)/codecheck1 $(OBJ) $(EXTRAOBJ)
$(OBJDIR)/codecheck1 $(TRANS_SRC)
$(TCC) -o $(APPNAME) $(OBJ) $(EXTRAOBJ) $(LIB)
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
# noop
clean:
rm -rf $(OBJDIR)/* $(APPNAME)
}
set mhargs {}
foreach s [lsort $src] {
append mhargs "\$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h <<<NEXT_LINE>>>"
set extra_h($s) { }
}
append mhargs "\$(SRCDIR)/sqlite3.h <<<NEXT_LINE>>>"
append mhargs "\$(SRCDIR)/th.h <<<NEXT_LINE>>>"
#append mhargs "\$(SRCDIR)/cson_amalgamation.h <<<NEXT_LINE>>>"
append mhargs "\$(OBJDIR)/VERSION.h"
set mhargs [string map [list <<<NEXT_LINE>>> \\\n\t] $mhargs]
writeln "\$(OBJDIR)/page_index.h: \$(TRANS_SRC) \$(OBJDIR)/mkindex"
writeln "\t\$(OBJDIR)/mkindex \$(TRANS_SRC) >\$@\n"
writeln "\$(OBJDIR)/builtin_data.h: \$(OBJDIR)/mkbuiltin \$(EXTRA_FILES)"
writeln "\t\$(OBJDIR)/mkbuiltin \$(EXTRA_FILES) >\$@\n"
writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(OBJDIR)/makeheaders \$(OBJDIR)/VERSION.h"
writeln "\t\$(OBJDIR)/makeheaders $mhargs"
writeln "\ttouch \$(OBJDIR)/headers"
writeln "\$(OBJDIR)/headers: Makefile"
writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/json_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h"
writeln "Makefile:"
set extra_h(main) " \$(OBJDIR)/page_index.h "
set extra_h(builtin) " \$(OBJDIR)/builtin_data.h "
foreach s [lsort $src] {
writeln "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(OBJDIR)/translate"
writeln "\t\$(OBJDIR)/translate \$(SRCDIR)/$s.c >\$@\n"
writeln "\$(OBJDIR)/$s.o:\t\$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h$extra_h($s)\$(SRCDIR)/config.h"
writeln "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c\n"
writeln "\$(OBJDIR)/$s.h:\t\$(OBJDIR)/headers\n"
}
writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c"
writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$@\n"
writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h"
writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$@\n"
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$@\n"
writeln "\$(OBJDIR)/th_tcl.o:\t\$(SRCDIR)/th_tcl.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th_tcl.c -o \$@\n"
writeln {
$(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
$(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@
#
# The list of all the targets that do not correspond to real files. This stops
# 'make' from getting confused when someone makes an error in a rule.
#
.PHONY: all install test clean
|
| ︙ | ︙ | |||
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 | #### Enable JSON (http://www.json.org) support using "cson" # # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # # FOSSIL_ENABLE_SSL = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | | | 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 | #### Enable JSON (http://www.json.org) support using "cson" # # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # # FOSSIL_ENABLE_SSL = 1 #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 #### Enable TH1 scripts in embedded documentation files # # FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 #### Use 'system' SQLite # # USE_SYSTEM_SQLITE = 1 #### Use the miniz compression library # # FOSSIL_ENABLE_MINIZ = 1 #### Use the Tcl source directory instead of the install directory? # This is useful when Tcl has been compiled statically with MinGW. # FOSSIL_TCL_SOURCE = 1 #### Check if the workaround for the MinGW command line handling needs to # be enabled by default. # ifndef MINGW_IS_32BIT_ONLY ifeq (,$(findstring w64-mingw32,$(PREFIX))) MINGW_IS_32BIT_ONLY = 1 endif endif #### The directories where the zlib include and library files are located. # ZINCDIR = $(SRCDIR)/../compat/zlib ZLIBDIR = $(SRCDIR)/../compat/zlib ifndef X64 ifneq (,$(findstring x86_64-w64-mingw32,$(PREFIX))) X64 = 1 endif endif ifndef X64 SSLCONFIG = mingw ZLIBCONFIG = LOC="-DASMV -DASMINF" OBJA="inffas86.o match.o" LIBTARGETS = $(ZLIBDIR)/inffas86.o $(ZLIBDIR)/match.o else SSLCONFIG = mingw64 ZLIBCONFIG = LIBTARGETS = endif ifndef FOSSIL_ENABLE_MINIZ SSLCONFIG += --with-zlib-lib=$(PWD)/$(ZLIBDIR) --with-zlib-include=$(PWD)/$(ZLIBDIR) zlib endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLINCDIR = $(SRCDIR)/../compat/openssl-1.0.1j/include OPENSSLLIBDIR = $(SRCDIR)/../compat/openssl-1.0.1j #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If # this points to the Tcl source code directory, this directory must # have "generic" and "win" sub-directories. The recommended usage |
| ︙ | ︙ | |||
499 500 501 502 503 504 505 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | > > > > > > | > > > > > > > > > > > > > > > > | 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)gcc -Os -Wall #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ TCC += -L$(ZLIBDIR) -I$(ZINCDIR) endif #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g endif #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) ifndef FOSSIL_ENABLE_MINIZ RCC += -I$(ZINCDIR) endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -L$(OPENSSLLIBDIR) -I$(OPENSSLINCDIR) RCC += -I$(OPENSSLINCDIR) endif # With Tcl support ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_TCL_SOURCE TCC += -L$(TCLSRCDIR)/win -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win RCC += -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win else TCC += -L$(TCLLIBDIR) -I$(TCLINCDIR) RCC += -I$(TCLINCDIR) endif endif # With miniz (i.e. instead of zlib) ifdef FOSSIL_ENABLE_MINIZ TCC += -DFOSSIL_ENABLE_MINIZ=1 RCC += -DFOSSIL_ENABLE_MINIZ=1 endif # With MinGW command line handling workaround ifdef MINGW_IS_32BIT_ONLY TCC += -DBROKEN_MINGW_CMDLINE=1 RCC += -DBROKEN_MINGW_CMDLINE=1 endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif # With TH1 embedded docs support ifdef FOSSIL_ENABLE_TH1_DOCS TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 endif |
| ︙ | ︙ | |||
577 578 579 580 581 582 583 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static | | > > > | > | > | > > > > > > | 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static #### MinGW: If available, use the Unicode capable runtime startup code. # ifndef MINGW_IS_32BIT_ONLY LIB += -municode endif #### SQLite: If enabled, use the system SQLite library. # ifdef USE_SYSTEM_SQLITE LIB += -lsqlite3 endif #### OpenSSL: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_SSL LIB += -lssl -lcrypto -lgdi32 endif #### Tcl: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_TCL LIB += $(LIBTCL) endif #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library. There are no # other mandatory dependencies. # LIB += -lmingwex #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ LIB += -lz endif #### These libraries MUST appear in the same order as they do for Tcl # or linking with it will not work (exact reason unknown). # ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_ENABLE_TCL_STUBS LIB += -lkernel32 -lws2_32 |
| ︙ | ︙ | |||
641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 |
#--------------------------------------------------------
XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR)
}
writeln -nonewline "SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
}
writeln "\n"
writeln -nonewline "TRANS_SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/${s}_.c"
}
writeln "\n"
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
| > > > > > | > | | | | > > > | | | | > > > > > | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 |
#--------------------------------------------------------
XTCC = $(TCC) $(CFLAGS) -I. -I$(SRCDIR)
}
writeln -nonewline "SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(SRCDIR)/$s.c"
}
writeln "\n"
writeln -nonewline "EXTRA_FILES ="
foreach s [lsort $extra_files] {
writeln -nonewline " \\\n \$(SRCDIR)/$s"
}
writeln "\n"
writeln -nonewline "TRANS_SRC ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/${s}_.c"
}
writeln "\n"
writeln -nonewline "OBJ ="
foreach s [lsort $src] {
writeln -nonewline " \\\n \$(OBJDIR)/$s.o"
}
writeln "\n"
writeln "APPNAME = ${name}.exe"
writeln "APPTARGETS ="
writeln {
#### If the USE_WINDOWS variable exists, it is assumed that we are building
# inside of a Windows-style shell; otherwise, it is assumed that we are
# building inside of a Unix-style shell. Note that the "move" command is
# broken when attempting to use it from the Windows shell via MinGW make
# because the SHELL variable is only used for certain commands that are
# recognized internally by make.
#
ifdef USE_WINDOWS
TRANSLATE = $(subst /,\,$(OBJDIR)/translate.exe)
MAKEHEADERS = $(subst /,\,$(OBJDIR)/makeheaders.exe)
MKINDEX = $(subst /,\,$(OBJDIR)/mkindex.exe)
MKBUILTIN = $(subst /,\,$(OBJDIR)/mkbuiltin.exe)
MKVERSION = $(subst /,\,$(OBJDIR)/mkversion.exe)
CODECHECK1 = $(subst /,\,$(OBJDIR)/codecheck1.exe)
CAT = type
CP = copy
GREP = find
MV = copy
RM = del /Q
MKDIR = -mkdir
RMDIR = rmdir /S /Q
else
TRANSLATE = $(OBJDIR)/translate.exe
MAKEHEADERS = $(OBJDIR)/makeheaders.exe
MKINDEX = $(OBJDIR)/mkindex.exe
MKBUILTIN = $(OBJDIR)/mkbuiltin.exe
MKVERSION = $(OBJDIR)/mkversion.exe
CODECHECK1 = $(OBJDIR)/codecheck1.exe
CAT = cat
CP = cp
GREP = grep
MV = mv
RM = rm -f
MKDIR = -mkdir -p
RMDIR = rm -rf
endif}
writeln {
all: $(OBJDIR) $(APPNAME)
$(OBJDIR)/fossil.o: $(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h
ifdef USE_WINDOWS
$(CAT) $(subst /,\,$(SRCDIR)\miniz.c) | $(GREP) "define MZ_VERSION" > $(subst /,\,$(OBJDIR)\minizver.h)
$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR))
$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR))
$(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR))
else
$(CAT) $(SRCDIR)/miniz.c | $(GREP) "define MZ_VERSION" > $(OBJDIR)/minizver.h
$(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR)
$(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR)
$(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR)
endif
$(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o
install: $(OBJDIR) $(APPNAME)
|
| ︙ | ︙ | |||
716 717 718 719 720 721 722 | $(OBJDIR): ifdef USE_WINDOWS $(MKDIR) $(subst /,\,$(OBJDIR)) else $(MKDIR) $(OBJDIR) endif | | | | | | | > > > | | > > > | | | > > > > > > > > > | | > | | | | | > > | > > > > > > > > > > > | | > > > > > > | > | | 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 |
$(OBJDIR):
ifdef USE_WINDOWS
$(MKDIR) $(subst /,\,$(OBJDIR))
else
$(MKDIR) $(OBJDIR)
endif
$(TRANSLATE): $(SRCDIR)/translate.c
$(BCC) -o $@ $(SRCDIR)/translate.c
$(MAKEHEADERS): $(SRCDIR)/makeheaders.c
$(BCC) -o $@ $(SRCDIR)/makeheaders.c
$(MKINDEX): $(SRCDIR)/mkindex.c
$(BCC) -o $@ $(SRCDIR)/mkindex.c
$(MKBUILTIN): $(SRCDIR)/mkbuiltin.c
$(BCC) -o $@ $(SRCDIR)/mkbuiltin.c
$(MKVERSION): $(SRCDIR)/mkversion.c
$(BCC) -o $@ $(SRCDIR)/mkversion.c
$(CODECHECK1): $(SRCDIR)/codecheck1.c
$(BCC) -o $@ $(SRCDIR)/codecheck1.c
# WARNING. DANGER. Running the test suite modifies the repository the
# build is done from, i.e. the checkout belongs to. Do not sync/push
# the repository after running the tests.
test: $(OBJDIR) $(APPNAME)
$(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME)
$(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(MKVERSION)
$(MKVERSION) $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$@
# The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set
# to 1. If it is set to 1, then there is no need to build or link
# the sqlite3.o object. Instead, the system SQLite will be linked
# using -lsqlite3.
SQLITE3_OBJ.1 =
SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o
SQLITE3_OBJ. = $(SQLITE3_OBJ.0)
# The FOSSIL_ENABLE_MINIZ variable may be undefined, set to 0, or
# set to 1. If it is set to 1, the miniz library included in the
# source tree should be used; otherwise, it should not.
MINIZ_OBJ.0 =
MINIZ_OBJ.1 = $(OBJDIR)/miniz.o
MINIZ_OBJ. = $(MINIZ_OBJ.0)
}
writeln [string map [list <<<NEXT_LINE>>> \\] {
EXTRAOBJ = <<<NEXT_LINE>>>
$(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) <<<NEXT_LINE>>>
$(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) <<<NEXT_LINE>>>
$(OBJDIR)/shell.o <<<NEXT_LINE>>>
$(OBJDIR)/th.o <<<NEXT_LINE>>>
$(OBJDIR)/th_lang.o <<<NEXT_LINE>>>
$(OBJDIR)/th_tcl.o <<<NEXT_LINE>>>
$(OBJDIR)/cson_amalgamation.o
}]
writeln {
zlib:
$(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) $(ZLIBCONFIG) -f win32/Makefile.gcc libz.a
clean-zlib:
$(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) -f win32/Makefile.gcc clean
$(ZLIBDIR)/inffas86.o:
$(TCC) -c -o $@ -DASMINF -I$(ZLIBDIR) -O3 $(ZLIBDIR)/contrib/inflate86/inffas86.c
$(ZLIBDIR)/match.o:
$(TCC) -c -o $@ -DASMV $(ZLIBDIR)/contrib/asm686/match.S
ifndef FOSSIL_ENABLE_MINIZ
LIBTARGETS += zlib
endif
openssl: $(LIBTARGETS)
cd $(OPENSSLLIBDIR);./Configure --cross-compile-prefix=$(PREFIX) $(SSLCONFIG)
$(MAKE) -C $(OPENSSLLIBDIR) build_libs
clean-openssl:
$(MAKE) -C $(OPENSSLLIBDIR) clean
tcl:
cd $(TCLSRCDIR)/win;./configure
$(MAKE) -C $(TCLSRCDIR)/win $(TCLTARGET)
clean-tcl:
$(MAKE) -C $(TCLSRCDIR)/win distclean
APPTARGETS += $(LIBTARGETS)
ifdef FOSSIL_BUILD_SSL
APPTARGETS += openssl
endif
$(APPNAME): $(OBJDIR)/headers $(CODECHECK1) $(OBJ) $(EXTRAOBJ) $(OBJDIR)/fossil.o $(APPTARGETS)
$(CODECHECK1) $(TRANS_SRC)
$(TCC) -o $@ $(OBJ) $(EXTRAOBJ) $(LIB) $(OBJDIR)/fossil.o
# This rule prevents make from using its default rules to try build
# an executable named "manifest" out of the file named "manifest.c"
#
$(SRCDIR)/../manifest:
# noop
|
| ︙ | ︙ | |||
802 803 804 805 806 807 808 |
$(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION)
}
set mhargs {}
foreach s [lsort $src] {
if {[string length $mhargs] > 0} {append mhargs " \\\n\t\t"}
append mhargs "\$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h"
| | | | > > > > | | > | | | > > > | > > > > | | | | | | > > > | 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
$(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION)
}
set mhargs {}
foreach s [lsort $src] {
if {[string length $mhargs] > 0} {append mhargs " \\\n\t\t"}
append mhargs "\$(OBJDIR)/${s}_.c:\$(OBJDIR)/$s.h"
set extra_h($s) { }
}
append mhargs " \\\n\t\t\$(SRCDIR)/sqlite3.h"
append mhargs " \\\n\t\t\$(SRCDIR)/th.h"
append mhargs " \\\n\t\t\$(OBJDIR)/VERSION.h"
writeln "\$(OBJDIR)/page_index.h: \$(TRANS_SRC) \$(MKINDEX)"
writeln "\t\$(MKINDEX) \$(TRANS_SRC) >\$@\n"
writeln "\$(OBJDIR)/builtin_data.h:\t\$(MKBUILTIN) \$(EXTRA_FILES)"
writeln "\t\$(MKBUILTIN) \$(EXTRA_FILES) >\$@\n"
writeln "\$(OBJDIR)/headers:\t\$(OBJDIR)/page_index.h \$(OBJDIR)/builtin_data.h \$(MAKEHEADERS) \$(OBJDIR)/VERSION.h"
writeln "\t\$(MAKEHEADERS) $mhargs"
writeln "\techo Done >\$(OBJDIR)/headers\n"
writeln "\$(OBJDIR)/headers: Makefile\n"
writeln "Makefile:\n"
set extra_h(main) " \$(OBJDIR)/page_index.h "
set extra_h(builtin) " \$(OBJDIR)/builtin_data.h "
foreach s [lsort $src] {
writeln "\$(OBJDIR)/${s}_.c:\t\$(SRCDIR)/$s.c \$(TRANSLATE)"
writeln "\t\$(TRANSLATE) \$(SRCDIR)/$s.c >\$@\n"
writeln "\$(OBJDIR)/$s.o:\t\$(OBJDIR)/${s}_.c \$(OBJDIR)/$s.h$extra_h($s)\$(SRCDIR)/config.h"
writeln "\t\$(XTCC) -o \$(OBJDIR)/$s.o -c \$(OBJDIR)/${s}_.c\n"
writeln "\$(OBJDIR)/${s}.h:\t\$(OBJDIR)/headers\n"
}
set SQLITE_WIN32_OPTIONS $SQLITE_OPTIONS
lappend SQLITE_WIN32_OPTIONS -DSQLITE_WIN32_NO_ANSI
set MINGW_SQLITE_OPTIONS $SQLITE_WIN32_OPTIONS
lappend MINGW_SQLITE_OPTIONS -D_HAVE__MINGW_H
lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MALLOC_H
lappend MINGW_SQLITE_OPTIONS -DSQLITE_USE_MSIZE
set MINIZ_WIN32_OPTIONS $MINIZ_OPTIONS
set j " \\\n "
writeln "SQLITE_OPTIONS = [join $MINGW_SQLITE_OPTIONS $j]\n"
set j " \\\n "
writeln "SHELL_OPTIONS = [join $SHELL_WIN32_OPTIONS $j]\n"
set j " \\\n "
writeln "MINIZ_OPTIONS = [join $MINIZ_WIN32_OPTIONS $j]\n"
writeln "\$(OBJDIR)/sqlite3.o:\t\$(SRCDIR)/sqlite3.c \$(SRCDIR)/../win/Makefile.mingw"
writeln "\t\$(XTCC) \$(SQLITE_OPTIONS) \$(SQLITE_CFLAGS) -c \$(SRCDIR)/sqlite3.c -o \$@\n"
writeln "\$(OBJDIR)/cson_amalgamation.o:\t\$(SRCDIR)/cson_amalgamation.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/cson_amalgamation.c -o \$@\n"
writeln "\$(OBJDIR)/json.o \$(OBJDIR)/json_artifact.o \$(OBJDIR)/json_branch.o \$(OBJDIR)/json_config.o \$(OBJDIR)/json_diff.o \$(OBJDIR)/json_dir.o \$(OBJDIR)/jsos_finfo.o \$(OBJDIR)/json_login.o \$(OBJDIR)/json_query.o \$(OBJDIR)/json_report.o \$(OBJDIR)/json_status.o \$(OBJDIR)/json_tag.o \$(OBJDIR)/json_timeline.o \$(OBJDIR)/json_user.o \$(OBJDIR)/json_wiki.o : \$(SRCDIR)/json_detail.h\n"
writeln "\$(OBJDIR)/shell.o:\t\$(SRCDIR)/shell.c \$(SRCDIR)/sqlite3.h \$(SRCDIR)/../win/Makefile.mingw"
writeln "\t\$(XTCC) \$(SHELL_OPTIONS) \$(SHELL_CFLAGS) -c \$(SRCDIR)/shell.c -o \$@\n"
writeln "\$(OBJDIR)/th.o:\t\$(SRCDIR)/th.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th.c -o \$@\n"
writeln "\$(OBJDIR)/th_lang.o:\t\$(SRCDIR)/th_lang.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th_lang.c -o \$@\n"
writeln "\$(OBJDIR)/th_tcl.o:\t\$(SRCDIR)/th_tcl.c"
writeln "\t\$(XTCC) -c \$(SRCDIR)/th_tcl.c -o \$@\n"
writeln "\$(OBJDIR)/miniz.o:\t\$(SRCDIR)/miniz.c"
writeln "\t\$(XTCC) \$(MINIZ_OPTIONS) -c \$(SRCDIR)/miniz.c -o \$@\n"
close $output_file
#
# End of the win/Makefile.mingw output
##############################################################################
##############################################################################
##############################################################################
|
| ︙ | ︙ | |||
914 915 916 917 918 919 920 | RC=$(DMDIR)\bin\rcc RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__ APPNAME = $(OBJDIR)\fossil$(E) all: $(APPNAME) | | | > | 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 | RC=$(DMDIR)\bin\rcc RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__ APPNAME = $(OBJDIR)\fossil$(E) all: $(APPNAME) $(APPNAME) : translate$E mkindex$E codecheck1$E headers $(OBJ) $(OBJDIR)\link cd $(OBJDIR) codecheck1$E $(SRC) $(DMDIR)\bin\link @link $(OBJDIR)\fossil.res: $B\win\fossil.rc $(RC) $(RCFLAGS) -o$@ $** $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res} writeln -nonewline "\t+echo " |
| ︙ | ︙ | |||
943 944 945 946 947 948 949 | makeheaders$E: $(SRCDIR)\makeheaders.c $(BCC) -o$@ $** mkindex$E: $(SRCDIR)\mkindex.c $(BCC) -o$@ $** | > > > | > > > | | > > > | | 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 | makeheaders$E: $(SRCDIR)\makeheaders.c $(BCC) -o$@ $** mkindex$E: $(SRCDIR)\mkindex.c $(BCC) -o$@ $** mkbuiltin$E: $(SRCDIR)\mkbuiltin.c $(BCC) -o$@ $** mkversion$E: $(SRCDIR)\mkversion.c $(BCC) -o$@ $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) -o$@ $** $(OBJDIR)\shell$O : $(SRCDIR)\shell.c $(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $** $(OBJDIR)\sqlite3$O : $(SRCDIR)\sqlite3.c $(TCC) -o$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $** $(OBJDIR)\th$O : $(SRCDIR)\th.c $(TCC) -o$@ -c $** $(OBJDIR)\th_lang$O : $(SRCDIR)\th_lang.c $(TCC) -o$@ -c $** $(OBJDIR)\cson_amalgamation.h : $(SRCDIR)\cson_amalgamation.h cp $@ $@ VERSION.h : mkversion$E $B\manifest.uuid $B\manifest $B\VERSION +$** > $@ page_index.h: mkindex$E $(SRC) +$** > $@ builtin_data.h: mkbuiltin$E $(EXTRA_FILES) +$** > $@ clean: -del $(OBJDIR)\*.obj -del *.obj *_.c *.h *.map realclean: -del $(APPNAME) translate$E mkindex$E makeheaders$E mkversion$E codecheck1$E mkbuiltin$E $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h |
| ︙ | ︙ | |||
999 1000 1001 1002 1003 1004 1005 |
foreach s [lsort $src] {
writeln "\$(OBJDIR)\\$s\$O : ${s}_.c ${s}.h"
writeln "\t\$(TCC) -o\$@ -c ${s}_.c\n"
writeln "${s}_.c : \$(SRCDIR)\\$s.c"
writeln "\t+translate\$E \$** > \$@\n"
}
| | | 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 |
foreach s [lsort $src] {
writeln "\$(OBJDIR)\\$s\$O : ${s}_.c ${s}.h"
writeln "\t\$(TCC) -o\$@ -c ${s}_.c\n"
writeln "${s}_.c : \$(SRCDIR)\\$s.c"
writeln "\t+translate\$E \$** > \$@\n"
}
writeln -nonewline "headers: makeheaders\$E page_index.h builtin_data.h VERSION.h\n\t +makeheaders\$E "
foreach s [lsort $src] {
writeln -nonewline "${s}_.c:$s.h "
}
writeln "\$(SRCDIR)\\sqlite3.h \$(SRCDIR)\\th.h VERSION.h \$(SRCDIR)\\cson_amalgamation.h"
writeln "\t@copy /Y nul: headers"
close $output_file
|
| ︙ | ︙ | |||
1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 |
set output_file [open ../win/Makefile.msc w]
fconfigure $output_file -translation binary
writeln {#
##############################################################################
# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
##############################################################################
#
# This file is automatically generated. Instead of editing this
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
# to regenerate this file.
#
| > > > > > > > > | | | | | | | > > > > > > > > > > > > > > > > > > | > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | > > > > > | | > > > > | > > > > > > > > > > > > > > > | > > > > > > > > > > > | > > > > > > > | > > > > > > | > > > | 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 |
set output_file [open ../win/Makefile.msc w]
fconfigure $output_file -translation binary
writeln {#
##############################################################################
# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
##############################################################################
#
# This Makefile will only function correctly if used from a sub-directory
# that is a direct child of the top-level directory for this project.
#
!if !exist("..\.fossil-settings")
!error "Please change the current directory to the one containing this file."
!endif
#
# This file is automatically generated. Instead of editing this
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
# to regenerate this file.
#
B = ..
SRCDIR = $B\src
OBJDIR = .
OX = .
O = .obj
E = .exe
P = .pdb
# Perl is only necessary if OpenSSL support is enabled and it must
# be built from source code. The PERLDIR variable should point to
# the directory containing the main Perl binary (i.e. "perl.exe").
PERLDIR = C:\Perl\bin
PERL = perl.exe
# Uncomment to enable debug symbols
# DEBUG = 1
# Uncomment to support Windows XP with Visual Studio 201x
# FOSSIL_ENABLE_WINXP = 1
# Uncomment to enable JSON API
# FOSSIL_ENABLE_JSON = 1
# Uncomment to enable miniz usage
# FOSSIL_ENABLE_MINIZ = 1
# Uncomment to enable SSL support
# FOSSIL_ENABLE_SSL = 1
# Uncomment to build SSL libraries
# FOSSIL_BUILD_SSL = 1
# Uncomment to enable TH1 scripts in embedded documentation files
# FOSSIL_ENABLE_TH1_DOCS = 1
# Uncomment to enable TH1 hooks
# FOSSIL_ENABLE_TH1_HOOKS = 1
# Uncomment to enable Tcl support
# FOSSIL_ENABLE_TCL = 1
!ifdef FOSSIL_ENABLE_SSL
SSLDIR = $(B)\compat\openssl-1.0.1j
SSLINCDIR = $(SSLDIR)\inc32
SSLLIBDIR = $(SSLDIR)\out32
SSLLFLAGS = /nologo /opt:ref /debug
SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
!message Using 'x64' platform for OpenSSL...
SSLCONFIG = VC-WIN64A no-asm
SSLSETUP = ms\do_win64a.bat
SSLNMAKE = ms\nt.mak all
!elseif "$(PLATFORM)"=="ia64"
!message Using 'ia64' platform for OpenSSL...
SSLCONFIG = VC-WIN64I no-asm
SSLSETUP = ms\do_win64i.bat
SSLNMAKE = ms\nt.mak all
!else
!message Assuming 'x86' platform for OpenSSL...
SSLCONFIG = VC-WIN32 no-asm
SSLSETUP = ms\do_ms.bat
SSLNMAKE = ms\nt.mak all
!endif
!endif
!ifdef FOSSIL_ENABLE_TCL
TCLDIR = $(B)\compat\tcl-8.6
TCLSRCDIR = $(TCLDIR)
TCLINCDIR = $(TCLSRCDIR)\generic
!endif
# zlib options
ZINCDIR = $(B)\compat\zlib
ZLIBDIR = $(B)\compat\zlib
ZLIB = zlib.lib
INCL = /I. /I$(SRCDIR) /I$B\win\include
!ifndef FOSSIL_ENABLE_MINIZ
INCL = $(INCL) /I$(ZINCDIR)
!endif
!ifdef FOSSIL_ENABLE_SSL
INCL = $(INCL) /I$(SSLINCDIR)
!endif
!ifdef FOSSIL_ENABLE_TCL
INCL = $(INCL) /I$(TCLINCDIR)
!endif
CFLAGS = /nologo
LDFLAGS = /NODEFAULTLIB:msvcrt /MANIFEST:NO
!ifdef FOSSIL_ENABLE_WINXP
XPCFLAGS = $(XPCFLAGS) /D_USING_V110_SDK71_=1
CFLAGS = $(CFLAGS) $(XPCFLAGS)
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.02
!else
XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.01
!endif
LDFLAGS = $(LDFLAGS) $(XPLDFLAGS)
!endif
!ifdef DEBUG
CFLAGS = $(CFLAGS) /Zi /MTd /Od
LDFLAGS = $(LDFLAGS) /DEBUG
!else
CFLAGS = $(CFLAGS) /MT /O2
!endif
BCC = $(CC) $(CFLAGS)
TCC = $(CC) /c $(CFLAGS) $(MSCDEF) $(INCL)
RCC = rc /D_WIN32 /D_MSC_VER $(MSCDEF) $(INCL)
LIBS = ws2_32.lib advapi32.lib
LIBDIR =
!ifndef FOSSIL_ENABLE_MINIZ
LIBS = $(LIBS) $(ZLIB)
LIBDIR = $(LIBDIR) /LIBPATH:$(ZLIBDIR)
!endif
!ifdef FOSSIL_ENABLE_MINIZ
TCC = $(TCC) /DFOSSIL_ENABLE_MINIZ=1
RCC = $(RCC) /DFOSSIL_ENABLE_MINIZ=1
!endif
!ifdef FOSSIL_ENABLE_JSON
TCC = $(TCC) /DFOSSIL_ENABLE_JSON=1
RCC = $(RCC) /DFOSSIL_ENABLE_JSON=1
!endif
!ifdef FOSSIL_ENABLE_SSL
TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
LIBS = $(LIBS) $(SSLLIB)
LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
!endif
!ifdef FOSSIL_ENABLE_TH1_DOCS
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
!endif
!ifdef FOSSIL_ENABLE_TH1_HOOKS
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_HOOKS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_HOOKS=1
!endif
!ifdef FOSSIL_ENABLE_TCL
TCC = $(TCC) /DFOSSIL_ENABLE_TCL=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL=1
TCC = $(TCC) /DFOSSIL_ENABLE_TCL_STUBS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL_STUBS=1
TCC = $(TCC) /DFOSSIL_ENABLE_TCL_PRIVATE_STUBS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL_PRIVATE_STUBS=1
TCC = $(TCC) /DUSE_TCL_STUBS=1
RCC = $(RCC) /DUSE_TCL_STUBS=1
!endif
}
regsub -all {[-]D} [join $SQLITE_WIN32_OPTIONS { }] {/D} MSC_SQLITE_OPTIONS
set j " \\\n "
writeln "SQLITE_OPTIONS = [join $MSC_SQLITE_OPTIONS $j]\n"
regsub -all {[-]D} [join $SHELL_WIN32_OPTIONS { }] {/D} MSC_SHELL_OPTIONS
set j " \\\n "
writeln "SHELL_OPTIONS = [join $MSC_SHELL_OPTIONS $j]\n"
regsub -all {[-]D} [join $MINIZ_WIN32_OPTIONS { }] {/D} MSC_MINIZ_OPTIONS
set j " \\\n "
writeln "MINIZ_OPTIONS = [join $MSC_MINIZ_OPTIONS $j]\n"
writeln -nonewline "SRC = "
set i 0
foreach s [lsort $src] {
if {$i > 0} {
writeln " \\"
writeln -nonewline " "
}
writeln -nonewline "${s}_.c"; incr i
}
writeln "\n"
writeln -nonewline "EXTRA_FILES = "
set i 0
foreach s [lsort $extra_files] {
if {$i > 0} {
writeln " \\"
writeln -nonewline " "
}
writeln -nonewline "\$(SRCDIR)\\${s}"; incr i
}
writeln "\n"
set AdditionalObj [list shell sqlite3 th th_lang th_tcl cson_amalgamation]
writeln -nonewline "OBJ = "
set i 0
foreach s [lsort [concat $src $AdditionalObj]] {
if {$i > 0} {
writeln " \\"
writeln -nonewline " "
}
writeln -nonewline "\$(OX)\\$s\$O"; incr i
}
if {$i > 0} {
writeln " \\"
}
writeln "!ifdef FOSSIL_ENABLE_MINIZ"
writeln -nonewline " "
writeln "\$(OX)\\miniz\$O \\"; incr i
writeln "!endif"
writeln -nonewline " \$(OX)\\fossil.res\n\n"
writeln {
APPNAME = $(OX)\fossil$(E)
PDBNAME = $(OX)\fossil$(P)
APPTARGETS =
all: $(OX) $(APPNAME)
zlib:
@echo Building zlib from "$(ZLIBDIR)"...
!ifdef FOSSIL_ENABLE_WINXP
@pushd "$(ZLIBDIR)" && $(MAKE) /f win32\Makefile.msc $(ZLIB) "CC=cl $(XPCFLAGS)" "LD=link $(XPLDFLAGS)" && popd
!else
@pushd "$(ZLIBDIR)" && $(MAKE) /f win32\Makefile.msc $(ZLIB) && popd
!endif
!ifdef FOSSIL_ENABLE_SSL
openssl:
@echo Building OpenSSL from "$(SSLDIR)"...
!if "$(PERLDIR)" != ""
@set PATH=$(PERLDIR);$(PATH)
!endif
@pushd "$(SSLDIR)" && $(PERL) Configure $(SSLCONFIG) && popd
@pushd "$(SSLDIR)" && call $(SSLSETUP) && popd
!ifdef FOSSIL_ENABLE_WINXP
@pushd "$(SSLDIR)" && $(MAKE) /f $(SSLNMAKE) "CC=cl $(XPCFLAGS)" "LFLAGS=$(SSLLFLAGS) $(XPLDFLAGS)" && popd
!else
@pushd "$(SSLDIR)" && $(MAKE) /f $(SSLNMAKE) && popd
!endif
!endif
!ifndef FOSSIL_ENABLE_MINIZ
APPTARGETS = $(APPTARGETS) zlib
!endif
!ifdef FOSSIL_ENABLE_SSL
!ifdef FOSSIL_BUILD_SSL
APPTARGETS = $(APPTARGETS) openssl
!endif
!endif
$(APPNAME) : $(APPTARGETS) translate$E mkindex$E codecheck1$E headers $(OBJ) $(OX)\linkopts
cd $(OX)
codecheck1$E $(SRC)
link $(LDFLAGS) /OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
$(OX)\linkopts: $B\win\Makefile.msc}
set redir {>}
foreach s [lsort [concat $src $AdditionalObj]] {
writeln "\techo \$(OX)\\$s.obj $redir \$@"
set redir {>>}
}
set redir {>>}
writeln "!ifdef FOSSIL_ENABLE_MINIZ"
writeln "\techo \$(OX)\\miniz.obj $redir \$@"
writeln "!endif"
writeln "\techo \$(LIBS) $redir \$@"
writeln {
$(OX):
@-mkdir $@
translate$E: $(SRCDIR)\translate.c
$(BCC) $**
makeheaders$E: $(SRCDIR)\makeheaders.c
$(BCC) $**
mkindex$E: $(SRCDIR)\mkindex.c
$(BCC) $**
mkbuiltin$E: $(SRCDIR)\mkbuiltin.c
$(BCC) $**
mkversion$E: $(SRCDIR)\mkversion.c
$(BCC) $**
codecheck1$E: $(SRCDIR)\codecheck1.c
$(BCC) $**
$(OX)\shell$O : $(SRCDIR)\shell.c $B\win\Makefile.msc
$(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c
$(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c $B\win\Makefile.msc
$(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SRCDIR)\sqlite3.c
$(OX)\th$O : $(SRCDIR)\th.c
$(TCC) /Fo$@ -c $**
$(OX)\th_lang$O : $(SRCDIR)\th_lang.c
$(TCC) /Fo$@ -c $**
$(OX)\th_tcl$O : $(SRCDIR)\th_tcl.c
$(TCC) /Fo$@ -c $**
$(OX)\miniz$O : $(SRCDIR)\miniz.c
$(TCC) /Fo$@ -c $(MINIZ_OPTIONS) $(SRCDIR)\miniz.c
VERSION.h : mkversion$E $B\manifest.uuid $B\manifest $B\VERSION
$** > $@
$(OX)\cson_amalgamation$O : $(SRCDIR)\cson_amalgamation.c
$(TCC) /Fo$@ /c $**
page_index.h: mkindex$E $(SRC)
$** > $@
builtin_data.h: mkbuiltin$E $(EXTRA_FILES)
$** > $@
clean:
-del $(OX)\*.obj
-del *.obj
-del *_.c
-del *.h
|
| ︙ | ︙ | |||
1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 | -del translate$P -del mkindex$E -del mkindex$P -del makeheaders$E -del makeheaders$P -del mkversion$E -del mkversion$P $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h | > > > > | 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 | -del translate$P -del mkindex$E -del mkindex$P -del makeheaders$E -del makeheaders$P -del mkversion$E -del mkversion$P -del codecheck1$E -del codecheck1$P -del mkbuiltin$E -del mkbuiltin$P $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h |
| ︙ | ︙ | |||
1262 1263 1264 1265 1266 1267 1268 |
writeln "${s}_.c : \$(SRCDIR)\\$s.c"
writeln "\ttranslate\$E \$** > \$@\n"
}
writeln "fossil.res : \$B\\win\\fossil.rc"
writeln "\t\$(RCC) /fo \$@ \$**\n"
| | | 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 |
writeln "${s}_.c : \$(SRCDIR)\\$s.c"
writeln "\ttranslate\$E \$** > \$@\n"
}
writeln "fossil.res : \$B\\win\\fossil.rc"
writeln "\t\$(RCC) /fo \$@ \$**\n"
writeln "headers: makeheaders\$E page_index.h builtin_data.h VERSION.h"
writeln -nonewline "\tmakeheaders\$E "
set i 0
foreach s [lsort $src] {
if {$i > 0} {
writeln " \\"
writeln -nonewline "\t\t\t"
}
|
| ︙ | ︙ | |||
1292 1293 1294 1295 1296 1297 1298 | # Begin win/Makefile.PellesCGMake output # puts "building ../win/Makefile.PellesCGMake" set output_file [open ../win/Makefile.PellesCGMake w] fconfigure $output_file -translation binary writeln [string map [list \ | | | 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 |
# Begin win/Makefile.PellesCGMake output
#
puts "building ../win/Makefile.PellesCGMake"
set output_file [open ../win/Makefile.PellesCGMake w]
fconfigure $output_file -translation binary
writeln [string map [list \
<<<SQLITE_OPTIONS>>> [join $SQLITE_WIN32_OPTIONS { }] \
<<<SHELL_OPTIONS>>> [join $SHELL_WIN32_OPTIONS { }]] {#
##############################################################################
# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
##############################################################################
#
# This file is automatically generated. Instead of editing this
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
|
| ︙ | ︙ | |||
1327 1328 1329 1330 1331 1332 1333 | # zlib sources 1.2.5 # Windows XP SP 2 # and # PellesC 6.00.4 # gmake 3.80 # zlib sources 1.2.5 # Windows 7 Home Premium | | | | 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 | # zlib sources 1.2.5 # Windows XP SP 2 # and # PellesC 6.00.4 # gmake 3.80 # zlib sources 1.2.5 # Windows 7 Home Premium # # PellesCDir=c:\Programme\PellesC # Select between 32/64 bit code, default is 32 bit #TARGETVERSION=64 ifeq ($(TARGETVERSION),64) # 64 bit version |
| ︙ | ︙ | |||
1372 1373 1374 1375 1376 1377 1378 | # define commands for building the windows resource files RESOURCE=fossil.res RC=$(PellesCDir)\bin\porc.exe RCFLAGS=$(INCLUDE) -D__POCC__=1 -D_M_X$(TARGETVERSION) # define the special utilities files, needed to generate # the automatically generated source files | | | | | 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 | # define commands for building the windows resource files RESOURCE=fossil.res RC=$(PellesCDir)\bin\porc.exe RCFLAGS=$(INCLUDE) -D__POCC__=1 -D_M_X$(TARGETVERSION) # define the special utilities files, needed to generate # the automatically generated source files UTILS=translate.exe mkindex.exe makeheaders.exe mkbuiltin.exe UTILS_OBJ=$(UTILS:.exe=.obj) UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c)) # define the SQLite files, which need special flags on compile SQLITESRC=sqlite3.c ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf)) SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj)) SQLITEDEFINES=<<<SQLITE_OPTIONS>>> # define the SQLite shell files, which need special flags on compile SQLITESHELLSRC=shell.c ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf)) SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj)) SQLITESHELLDEFINES=<<<SHELL_OPTIONS>>> # define the th scripting files, which need special flags on compile THSRC=th.c th_lang.c |
| ︙ | ︙ | |||
1411 1412 1413 1414 1415 1416 1417 | TRANSLATEDOBJ=$(TRANSLATEDSRC:.c=.obj) # main target file is the application APPLICATION=fossil.exe # define the standard make target .PHONY: default | | | 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 | TRANSLATEDOBJ=$(TRANSLATEDSRC:.c=.obj) # main target file is the application APPLICATION=fossil.exe # define the standard make target .PHONY: default default: page_index.h builtin_data.h headers $(APPLICATION) # symbolic target to generate the source generate utils .PHONY: utils utils: $(UTILS) # link utils $(UTILS) version.exe: %.exe: %.obj |
| ︙ | ︙ | |||
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 | # generate the translated c-source files $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe translate.exe $< >$@ # generate the index source, containing all web references,.. page_index.h: $(TRANSLATEDSRC) mkindex.exe mkindex.exe $(TRANSLATEDSRC) >$@ # extracting version info from manifest VERSION.h: version.exe ..\manifest.uuid ..\manifest ..\VERSION | > > > | | | 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 | # generate the translated c-source files $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe translate.exe $< >$@ # generate the index source, containing all web references,.. page_index.h: $(TRANSLATEDSRC) mkindex.exe mkindex.exe $(TRANSLATEDSRC) >$@ builtin_data.h: $(EXTRA_FILES) mkbuiltin.exe mkbuiltin.exe $(EXTRA_FILES) >$@ # extracting version info from manifest VERSION.h: version.exe ..\manifest.uuid ..\manifest ..\VERSION version.exe ..\manifest.uuid ..\manifest ..\VERSION >$@ # generate the simplified headers headers: makeheaders.exe page_index.h builtin_data.h VERSION.h ../src/sqlite3.h ../src/th.h VERSION.h makeheaders.exe $(foreach ts,$(TRANSLATEDSRC),$(ts):$(ts:_.c=.h)) ../src/sqlite3.h ../src/th.h VERSION.h echo Done >$@ # compile C sources with relevant options $(TRANSLATEDOBJ): %_.obj: %_.c %.h $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@" |
| ︙ | ︙ |
Changes to src/manifest.c.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
#define PERM_LNK 2 /* symlink */
/*
** Flags for use with manifest_crosslink().
*/
#define MC_NONE 0 /* default handling */
#define MC_PERMIT_HOOKS 1 /* permit hooks to execute */
/*
** A single F-card within a manifest
*/
struct ManifestFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
| > | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#define PERM_LNK 2 /* symlink */
/*
** Flags for use with manifest_crosslink().
*/
#define MC_NONE 0 /* default handling */
#define MC_PERMIT_HOOKS 1 /* permit hooks to execute */
#define MC_NO_ERRORS 2 /* do not issue errors for a bad parse */
/*
** A single F-card within a manifest
*/
struct ManifestFile {
char *zName; /* Name of a file */
char *zUuid; /* UUID of the file */
|
| ︙ | ︙ | |||
227 228 229 230 231 232 233 |
/*
** Remove the PGP signature from the artifact, if there is one.
*/
static void remove_pgp_signature(char **pz, int *pn){
char *z = *pz;
int n = *pn;
int i;
| | | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 |
/*
** Remove the PGP signature from the artifact, if there is one.
*/
static void remove_pgp_signature(char **pz, int *pn){
char *z = *pz;
int n = *pn;
int i;
if( strncmp(z, "-----BEGIN PGP SIGNED MESSAGE-----", 34)!=0 ) return;
for(i=34; i<n && !after_blank_line(z+i); i++){}
if( i>=n ) return;
z += i;
n -= i;
*pz = z;
for(i=n-1; i>=0; i--){
if( z[i]=='\n' && strncmp(&z[i],"\n-----BEGIN PGP SIGNATURE-", 25)==0 ){
n = i+1;
break;
}
}
*pn = n;
return;
}
|
| ︙ | ︙ | |||
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
char cPrevType = 0;
char cType;
char *z;
int n;
char *zUuid;
int sz = 0;
int isRepeat, hasSelfRefTag = 0;
static Bag seen;
const char *zErr = 0;
if( rid==0 ){
isRepeat = 1;
}else if( bag_find(&seen, rid) ){
isRepeat = 1;
}else{
isRepeat = 0;
bag_insert(&seen, rid);
}
/* Every control artifact ends with a '\n' character. Exit early
** if that is not the case for this artifact.
*/
if( !isRepeat ) g.parseCnt[0]++;
z = blob_materialize(pContent);
n = blob_size(pContent);
| > | | | 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
char cPrevType = 0;
char cType;
char *z;
int n;
char *zUuid;
int sz = 0;
int isRepeat, hasSelfRefTag = 0;
Blob bUuid = BLOB_INITIALIZER;
static Bag seen;
const char *zErr = 0;
if( rid==0 ){
isRepeat = 1;
}else if( bag_find(&seen, rid) ){
isRepeat = 1;
}else{
isRepeat = 0;
bag_insert(&seen, rid);
}
/* Every control artifact ends with a '\n' character. Exit early
** if that is not the case for this artifact.
*/
if( !isRepeat ) g.parseCnt[0]++;
z = blob_materialize(pContent);
n = blob_size(pContent);
if( pErr && (n<=0 || z[n-1]!='\n') ){
blob_reset(pContent);
blob_append(pErr, n ? "not terminated with \\n" : "zero-length", -1);
return 0;
}
/* Strip off the PGP signature if there is one.
*/
remove_pgp_signature(&z, &n);
|
| ︙ | ︙ | |||
401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
/* Then verify the Z-card.
*/
if( verify_z_card(z, n)==2 ){
blob_reset(pContent);
blob_appendf(pErr, "incorrect Z-card cksum");
return 0;
}
/* Allocate a Manifest object to hold the parsed control artifact.
*/
p = fossil_malloc( sizeof(*p) );
memset(p, 0, sizeof(*p));
memcpy(&p->content, pContent, sizeof(p->content));
p->rid = rid;
| > > > > > | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
/* Then verify the Z-card.
*/
if( verify_z_card(z, n)==2 ){
blob_reset(pContent);
blob_appendf(pErr, "incorrect Z-card cksum");
return 0;
}
/* Store the UUID (before modifying the blob) only for error
** reporting purposes.
*/
sha1sum_blob(pContent, &bUuid);
/* Allocate a Manifest object to hold the parsed control artifact.
*/
p = fossil_malloc( sizeof(*p) );
memset(p, 0, sizeof(*p));
memcpy(&p->content, pContent, sizeof(p->content));
p->rid = rid;
|
| ︙ | ︙ | |||
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 |
if( p->rDate<=0.0 ) SYNTAX("missing date on control");
if( p->zMimetype ) SYNTAX("N-card in control");
if( !seenZ ) SYNTAX("missing Z-card on control");
p->type = CFTYPE_CONTROL;
}
md5sum_init();
if( !isRepeat ) g.parseCnt[p->type]++;
return p;
manifest_syntax_error:
if( zErr ){
blob_appendf(pErr, "line %d: %s", lineNo, zErr);
}else{
blob_appendf(pErr, "unknown error on line %d", lineNo);
}
md5sum_init();
manifest_destroy(p);
| > > > > > | 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 |
if( p->rDate<=0.0 ) SYNTAX("missing date on control");
if( p->zMimetype ) SYNTAX("N-card in control");
if( !seenZ ) SYNTAX("missing Z-card on control");
p->type = CFTYPE_CONTROL;
}
md5sum_init();
if( !isRepeat ) g.parseCnt[p->type]++;
blob_reset(&bUuid);
return p;
manifest_syntax_error:
if(bUuid.nUsed){
blob_appendf(pErr, "manifest [%.40s] ", blob_str(&bUuid));
blob_reset(&bUuid);
}
if( zErr ){
blob_appendf(pErr, "line %d: %s", lineNo, zErr);
}else{
blob_appendf(pErr, "unknown error on line %d", lineNo);
}
md5sum_init();
manifest_destroy(p);
|
| ︙ | ︙ | |||
1520 1521 1522 1523 1524 1525 1526 |
}
}
db_prepare(&q, "SELECT uuid FROM pending_tkt");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
if( permitHooks && rc==TH_OK ){
| | | 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 |
}
}
db_prepare(&q, "SELECT uuid FROM pending_tkt");
while( db_step(&q)==SQLITE_ROW ){
const char *zUuid = db_column_text(&q, 0);
ticket_rebuild_entry(zUuid);
if( permitHooks && rc==TH_OK ){
rc = xfer_run_script(zScript, zUuid, 0);
}
}
db_finalize(&q);
db_multi_exec("DROP TABLE pending_tkt");
/* If multiple check-ins happen close together in time, adjust their
** times by a few milliseconds to make sure they appear in chronological
|
| ︙ | ︙ | |||
1587 1588 1589 1590 1591 1592 1593 |
blob_zero(&brief);
if( once ){
once = 0;
zTitleExpr = db_get("ticket-title-expr", "title");
zStatusColumn = db_get("ticket-status-column", "status");
}
zTitle = db_text("unknown",
| | | | 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 |
blob_zero(&brief);
if( once ){
once = 0;
zTitleExpr = db_get("ticket-title-expr", "title");
zStatusColumn = db_get("ticket-status-column", "status");
}
zTitle = db_text("unknown",
"SELECT \"%w\" FROM ticket WHERE tkt_uuid=%Q",
zTitleExpr, pManifest->zTicketUuid
);
if( !isNew ){
for(i=0; i<pManifest->nField; i++){
if( fossil_strcmp(pManifest->aField[i].zName, zStatusColumn)==0 ){
zNewStatus = pManifest->aField[i].zValue;
}
}
if( zNewStatus ){
blob_appendf(&comment, "%h ticket [%s|%S]: <i>%h</i>",
zNewStatus, pManifest->zTicketUuid, pManifest->zTicketUuid, zTitle
);
if( pManifest->nField>1 ){
blob_appendf(&comment, " plus %d other change%s",
pManifest->nField-1, pManifest->nField==2 ? "" : "s");
}
blob_appendf(&brief, "%h ticket [%s|%S].",
zNewStatus, pManifest->zTicketUuid, pManifest->zTicketUuid);
}else{
zNewStatus = db_text("unknown",
"SELECT \"%w\" FROM ticket WHERE tkt_uuid=%Q",
zStatusColumn, pManifest->zTicketUuid
);
blob_appendf(&comment, "Ticket [%s|%S] <i>%h</i> status still %h with "
"%d other change%s",
pManifest->zTicketUuid, pManifest->zTicketUuid, zTitle, zNewStatus,
pManifest->nField, pManifest->nField==1 ? "" : "s"
);
|
| ︙ | ︙ | |||
1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 |
"VALUES('t',%d,%.17g,%d,%Q,%Q,%Q)",
tktTagId, pManifest->rDate, rid, pManifest->zUser,
blob_str(&comment), blob_str(&brief)
);
blob_reset(&comment);
blob_reset(&brief);
}
/*
** This is the comparison function used to sort the tag array.
*/
static int tag_compare(const void *a, const void *b){
struct TagType *pA = (struct TagType*)a;
struct TagType *pB = (struct TagType*)b;
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 |
"VALUES('t',%d,%.17g,%d,%Q,%Q,%Q)",
tktTagId, pManifest->rDate, rid, pManifest->zUser,
blob_str(&comment), blob_str(&brief)
);
blob_reset(&comment);
blob_reset(&brief);
}
/*
** Add an extra line of text to the end of a manifest to prevent it being
** recognized as a valid manifest.
**
** This routine is called prior to writing out the text of a manifest as
** the "manifest" file in the root of a repository when
** "fossil setting manifest on" is enabled. That way, if the files of
** the project are imported into a different Fossil project, the manifest
** file will not be interpreted as a control artifact in that other project.
**
** Normally it is sufficient to simply append the extra line of text.
** However, if the manifest is PGP signed then the extra line has to be
** inserted before the PGP signature (thus invalidating the signature).
*/
void sterilize_manifest(Blob *p){
char *z, *zOrig;
int n, nOrig;
static const char zExtraLine[] =
"# Remove this line to create a well-formed manifest.\n";
z = zOrig = blob_materialize(p);
n = nOrig = blob_size(p);
remove_pgp_signature(&z, &n);
if( z==zOrig ){
blob_append(p, zExtraLine, -1);
}else{
int iEnd;
Blob copy;
memcpy(©, p, sizeof(copy));
blob_init(p, 0, 0);
iEnd = (int)(&z[n] - zOrig);
blob_append(p, zOrig, iEnd);
blob_append(p, zExtraLine, -1);
blob_append(p, &zOrig[iEnd], -1);
blob_zero(©);
}
}
/*
** This is the comparison function used to sort the tag array.
*/
static int tag_compare(const void *a, const void *b){
struct TagType *pA = (struct TagType*)a;
struct TagType *pB = (struct TagType*)b;
|
| ︙ | ︙ | |||
1693 1694 1695 1696 1697 1698 1699 |
const char *zScript = 0;
const char *zUuid = 0;
if( (p = manifest_cache_find(rid))!=0 ){
blob_reset(pContent);
}else if( (p = manifest_parse(pContent, rid, 0))==0 ){
assert( blob_is_reset(pContent) || pContent==0 );
| > | > > | > | > > | 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 |
const char *zScript = 0;
const char *zUuid = 0;
if( (p = manifest_cache_find(rid))!=0 ){
blob_reset(pContent);
}else if( (p = manifest_parse(pContent, rid, 0))==0 ){
assert( blob_is_reset(pContent) || pContent==0 );
if( (flags & MC_NO_ERRORS)==0 ){
fossil_error(1, "syntax error in manifest [%s]",
db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
}
return 0;
}
if( g.xlinkClusterOnly && p->type!=CFTYPE_CLUSTER ){
manifest_destroy(p);
assert( blob_is_reset(pContent) );
if( (flags & MC_NO_ERRORS)==0 ) fossil_error(1, "no manifest");
return 0;
}
if( p->type==CFTYPE_MANIFEST && fetch_baseline(p, 0) ){
manifest_destroy(p);
assert( blob_is_reset(pContent) );
if( (flags & MC_NO_ERRORS)==0 ){
fossil_error(1, "cannot fetch baseline for manifest [%s]",
db_text(0, "SELECT uuid FROM blob WHERE rid=%d",rid));
}
return 0;
}
db_begin_transaction();
if( p->type==CFTYPE_MANIFEST ){
if( permitHooks ){
zScript = xfer_commit_code();
zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
|
| ︙ | ︙ | |||
1854 1855 1856 1857 1858 1859 1860 |
" bgcolor,euser,ecomment)"
"VALUES('w',%.17g,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
p->rDate, rid, p->zUser, zComment,
TAG_BGCOLOR, rid,
| < | 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 |
" bgcolor,euser,ecomment)"
"VALUES('w',%.17g,%d,%Q,%Q,"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d AND tagtype>1),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d),"
" (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d));",
p->rDate, rid, p->zUser, zComment,
TAG_BGCOLOR, rid,
TAG_USER, rid,
TAG_COMMENT, rid
);
fossil_free(zComment);
}
if( p->type==CFTYPE_EVENT ){
char *zTag = mprintf("event-%s", p->zEventId);
|
| ︙ | ︙ | |||
1918 1919 1920 1921 1922 1923 1924 |
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
fossil_free(zTag);
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
p->zTicketUuid);
}
if( p->type==CFTYPE_ATTACHMENT ){
char *zComment = 0;
| | | | 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 |
tag_insert(zTag, 1, 0, rid, p->rDate, rid);
fossil_free(zTag);
db_multi_exec("INSERT OR IGNORE INTO pending_tkt VALUES(%Q)",
p->zTicketUuid);
}
if( p->type==CFTYPE_ATTACHMENT ){
char *zComment = 0;
const char isAdd = (p->zAttachSrc && p->zAttachSrc[0]) ? 1 : 0;
const char attachToType = fossil_is_uuid(p->zAttachTarget)
? 't' /* attach to ticket */
: 'w' /* attach to wiki page */;
db_multi_exec(
"INSERT INTO attachment(attachid, mtime, src, target,"
"filename, comment, user)"
"VALUES(%d,%.17g,%Q,%Q,%Q,%Q,%Q);",
rid, p->rDate, p->zAttachSrc, p->zAttachTarget, p->zAttachName,
|
| ︙ | ︙ | |||
1986 1987 1988 1989 1990 1991 1992 |
if( i==0 || fossil_strcmp(zTagUuid, p->aTag[i-1].zUuid)!=0 ){
blob_appendf(&comment,
" Edit [%s|%S]:",
zTagUuid, zTagUuid);
branchMove = 0;
if( permitHooks && db_exists("SELECT 1 FROM event, blob"
" WHERE event.type='ci' AND event.objid=blob.rid"
| | | 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 |
if( i==0 || fossil_strcmp(zTagUuid, p->aTag[i-1].zUuid)!=0 ){
blob_appendf(&comment,
" Edit [%s|%S]:",
zTagUuid, zTagUuid);
branchMove = 0;
if( permitHooks && db_exists("SELECT 1 FROM event, blob"
" WHERE event.type='ci' AND event.objid=blob.rid"
" AND blob.uuid=%Q", zTagUuid) ){
zScript = xfer_commit_code();
zUuid = zTagUuid;
}
}
zName = p->aTag[i].zName;
zValue = p->aTag[i].zValue;
if( strcmp(zName, "*branch")==0 ){
|
| ︙ | ︙ | |||
2064 2065 2066 2067 2068 2069 2070 |
);
blob_reset(&comment);
}
db_end_transaction(0);
if( permitHooks ){
rc = xfer_run_common_script();
if( rc==TH_OK ){
| | | 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 |
);
blob_reset(&comment);
}
db_end_transaction(0);
if( permitHooks ){
rc = xfer_run_common_script();
if( rc==TH_OK ){
rc = xfer_run_script(zScript, zUuid, 0);
}
}
if( p->type==CFTYPE_MANIFEST ){
manifest_cache_insert(p);
}else{
manifest_destroy(p);
}
|
| ︙ | ︙ |
Changes to src/markdown.c.
| ︙ | ︙ | |||
388 389 390 391 392 393 394 |
j = i;
while( i<size
&& data[i]!='>'
&& data[i]!='\''
&& data[i]!='"'
&& data[i]!=' '
&& data[i]!='\t'
| | | 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
j = i;
while( i<size
&& data[i]!='>'
&& data[i]!='\''
&& data[i]!='"'
&& data[i]!=' '
&& data[i]!='\t'
&& data[i]!='\n'
){
i++;
}
if( i>=size ) return 0;
if( i>j && data[i]=='>' ) return i+1;
/* one of the forbidden chars has been found */
*autolink = MKDA_NOT_AUTOLINK;
|
| ︙ | ︙ |
Changes to src/markdown_html.c.
| ︙ | ︙ | |||
80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
i++;
}
}
}
/* HTML block tags */
static void html_raw_block(struct Blob *ob, struct Blob *text, void *opaque){
char *data = blob_buffer(text);
size_t first = 0, size = blob_size(text);
INTER_BLOCK(ob);
while( first<size && data[first]=='\n' ) first++;
while( size>first && data[size-1]=='\n' ) size--;
| > > > > > > > > > > | 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
i++;
}
}
}
/* HTML block tags */
static void html_prolog(struct Blob *ob, void *opaque){
INTER_BLOCK(ob);
BLOB_APPEND_LITTERAL(ob, "<div class=\"markdown\">\n");
}
static void html_epilog(struct Blob *ob, void *opaque){
INTER_BLOCK(ob);
BLOB_APPEND_LITTERAL(ob, "</div>\n");
}
static void html_raw_block(struct Blob *ob, struct Blob *text, void *opaque){
char *data = blob_buffer(text);
size_t first = 0, size = blob_size(text);
INTER_BLOCK(ob);
while( first<size && data[first]=='\n' ) first++;
while( size>first && data[size-1]=='\n' ) size--;
|
| ︙ | ︙ | |||
362 363 364 365 366 367 368 |
void markdown_to_html(
struct Blob *input_markdown,
struct Blob *output_title,
struct Blob *output_body
){
struct mkd_renderer html_renderer = {
| | > > | 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 |
void markdown_to_html(
struct Blob *input_markdown,
struct Blob *output_title,
struct Blob *output_body
){
struct mkd_renderer html_renderer = {
/* prolog and epilog */
html_prolog,
html_epilog,
/* block level elements */
html_blockcode,
html_blockquote,
html_raw_block,
html_header,
html_hrule,
|
| ︙ | ︙ | |||
395 396 397 398 399 400 401 |
/* low level elements */
0, /* entities are copied verbatim */
html_normal_text,
/* misc. parameters */
64, /* maximum stack */
"*_", /* emphasis characters */
| | > | 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
/* low level elements */
0, /* entities are copied verbatim */
html_normal_text,
/* misc. parameters */
64, /* maximum stack */
"*_", /* emphasis characters */
0 /* opaque data */
};
html_renderer.opaque = output_title;
blob_reset(output_title);
blob_reset(output_body);
markdown(output_body, input_markdown, &html_renderer);
}
|
Changes to src/merge.c.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 |
}
fossil_print("%-*s [%S] by %s on %s\n%*s",
indent-1, zLabel,
db_column_text(&q, 3),
db_column_text(&q, 1),
db_column_text(&q, 0),
indent, "");
| | | 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
}
fossil_print("%-*s [%S] by %s on %s\n%*s",
indent-1, zLabel,
db_column_text(&q, 3),
db_column_text(&q, 1),
db_column_text(&q, 0),
indent, "");
comment_print(zCom, db_column_text(&q,2), indent, -1, g.comFmtFlags);
fossil_free(zCom);
}
db_finalize(&q);
}
/*
|
| ︙ | ︙ | |||
143 144 145 146 147 148 149 |
zBinGlob = find_option("binary",0,1);
dryRunFlag = find_option("dry-run","n",0)!=0;
if( !dryRunFlag ){
dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */
}
forceFlag = find_option("force","f",0)!=0;
zPivot = find_option("baseline",0,1);
| < | 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
zBinGlob = find_option("binary",0,1);
dryRunFlag = find_option("dry-run","n",0)!=0;
if( !dryRunFlag ){
dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */
}
forceFlag = find_option("force","f",0)!=0;
zPivot = find_option("baseline",0,1);
verify_all_options();
db_must_be_within_tree();
if( zBinGlob==0 ) zBinGlob = db_get("binary-glob",0);
vid = db_lget_int("checkout", 0);
if( vid==0 ){
fossil_fatal("nothing is checked out");
}
|
| ︙ | ︙ | |||
208 209 210 211 212 213 214 |
" WHERE event.objid=%d AND blob.rid=%d",
timeline_utc(), mid, mid
);
if( db_step(&q)==SQLITE_ROW ){
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
db_column_text(&q, 0), db_column_text(&q, 1),
db_column_text(&q, 3), db_column_text(&q, 2));
| | | 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
" WHERE event.objid=%d AND blob.rid=%d",
timeline_utc(), mid, mid
);
if( db_step(&q)==SQLITE_ROW ){
char *zCom = mprintf("Merging fork [%S] at %s by %s: \"%s\"",
db_column_text(&q, 0), db_column_text(&q, 1),
db_column_text(&q, 3), db_column_text(&q, 2));
comment_print(zCom, db_column_text(&q,2), 0, -1, g.comFmtFlags);
fossil_free(zCom);
}
db_finalize(&q);
}else{
usage("?OPTIONS? ?VERSION?");
return;
}
|
| ︙ | ︙ | |||
642 643 644 645 646 647 648 |
}
if( nOverwrite ){
fossil_warning("WARNING: %d unmanaged files were overwritten",
nOverwrite);
}
if( dryRunFlag ){
fossil_warning("REMINDER: this was a dry run -"
| | | 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
}
if( nOverwrite ){
fossil_warning("WARNING: %d unmanaged files were overwritten",
nOverwrite);
}
if( dryRunFlag ){
fossil_warning("REMINDER: this was a dry run -"
" no files were actually changed.");
}
/*
** Clean up the mid and pid VFILE entries. Then commit the changes.
*/
db_multi_exec("DELETE FROM vfile WHERE vid!=%d", vid);
if( pickFlag ){
|
| ︙ | ︙ |
Changes to src/merge3.c.
| ︙ | ︙ | |||
134 135 136 137 138 139 140 | } return i; } /* ** Text of boundary markers for merge conflicts. */ | | | 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
}
return i;
}
/*
** Text of boundary markers for merge conflicts.
*/
static const char *const mergeMarker[] = {
/*123456789 123456789 123456789 123456789 123456789 123456789 123456789*/
"<<<<<<< BEGIN MERGE CONFLICT: local copy shown first <<<<<<<<<<<<<<<\n",
"======= COMMON ANCESTOR content follows ============================\n",
"======= MERGED IN content follows ==================================\n",
">>>>>>> END MERGE CONFLICT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n"
};
|
| ︙ | ︙ | |||
266 267 268 269 270 271 272 |
*/
int sz = 1; /* Size of the conflict in lines */
nConflict++;
while( !ends_at_CPY(&aC1[i1], sz) || !ends_at_CPY(&aC2[i2], sz) ){
sz++;
}
DEBUG( printf("CONFLICT %d\n", sz); )
| | | | | | 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 |
*/
int sz = 1; /* Size of the conflict in lines */
nConflict++;
while( !ends_at_CPY(&aC1[i1], sz) || !ends_at_CPY(&aC2[i2], sz) ){
sz++;
}
DEBUG( printf("CONFLICT %d\n", sz); )
blob_append(pOut, mergeMarker[0], -1);
i1 = output_one_side(pOut, pV1, aC1, i1, sz);
blob_append(pOut, mergeMarker[1], -1);
blob_copy_lines(pOut, pPivot, sz);
blob_append(pOut, mergeMarker[2], -1);
i2 = output_one_side(pOut, pV2, aC2, i2, sz);
blob_append(pOut, mergeMarker[3], -1);
}
/* If we are finished with an edit triple, advance to the next
** triple.
*/
if( i1<limit1 && aC1[i1]==0 && aC1[i1+1]==0 && aC1[i1+2]==0 ) i1+=3;
if( i2<limit2 && aC2[i2]==0 && aC2[i2+1]==0 && aC2[i2+2]==0 ) i2+=3;
|
| ︙ | ︙ | |||
366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
** cp Xup.c Xbase.c
** # Verify that everything still works
** fossil commit
**
*/
void delta_3waymerge_cmd(void){
Blob pivot, v1, v2, merged;
if( g.argc!=6 ){
usage("PIVOT V1 V2 MERGED");
}
if( blob_read_from_file(&pivot, g.argv[2])<0 ){
fossil_fatal("cannot read %s\n", g.argv[2]);
}
if( blob_read_from_file(&v1, g.argv[3])<0 ){
| > > > > | 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
** cp Xup.c Xbase.c
** # Verify that everything still works
** fossil commit
**
*/
void delta_3waymerge_cmd(void){
Blob pivot, v1, v2, merged;
/* We should be done with options.. */
verify_all_options();
if( g.argc!=6 ){
usage("PIVOT V1 V2 MERGED");
}
if( blob_read_from_file(&pivot, g.argv[2])<0 ){
fossil_fatal("cannot read %s\n", g.argv[2]);
}
if( blob_read_from_file(&v1, g.argv[3])<0 ){
|
| ︙ | ︙ |
Added src/miniz.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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 2663 2664 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682 2683 2684 2685 2686 2687 2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 2743 2744 2745 2746 2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792 2793 2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053 3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 3199 3200 3201 3202 3203 3204 3205 3206 3207 3208 3209 3210 3211 3212 3213 3214 3215 3216 3217 3218 3219 3220 3221 3222 3223 3224 3225 3226 3227 3228 3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249 3250 3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261 3262 3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273 3274 3275 3276 3277 3278 3279 3280 3281 3282 3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293 3294 3295 3296 3297 3298 3299 3300 3301 3302 3303 3304 3305 3306 3307 3308 3309 3310 3311 3312 3313 3314 3315 3316 3317 3318 3319 3320 3321 3322 3323 3324 3325 3326 3327 3328 3329 3330 3331 3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 3346 3347 3348 3349 3350 3351 3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362 3363 3364 3365 3366 3367 3368 3369 3370 3371 3372 3373 3374 3375 3376 3377 3378 3379 3380 3381 3382 3383 3384 3385 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 3430 3431 3432 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 3524 3525 3526 3527 3528 3529 3530 3531 3532 3533 3534 3535 3536 3537 3538 3539 3540 3541 3542 3543 3544 3545 3546 3547 3548 3549 3550 3551 3552 3553 3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 3568 3569 3570 3571 3572 3573 3574 3575 3576 3577 3578 3579 3580 3581 3582 3583 3584 3585 3586 3587 3588 3589 3590 3591 3592 3593 3594 3595 3596 3597 3598 3599 3600 3601 3602 3603 3604 3605 3606 3607 3608 3609 3610 3611 3612 3613 3614 3615 3616 3617 3618 3619 3620 3621 3622 3623 3624 3625 3626 3627 3628 3629 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 3645 3646 3647 3648 3649 3650 3651 3652 3653 3654 3655 3656 3657 3658 3659 3660 3661 3662 3663 3664 3665 3666 3667 3668 3669 3670 3671 3672 3673 3674 3675 3676 3677 3678 3679 3680 3681 3682 3683 3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 3703 3704 3705 3706 3707 3708 3709 3710 3711 3712 3713 3714 3715 3716 3717 3718 3719 3720 3721 3722 3723 3724 3725 3726 3727 3728 3729 3730 3731 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 3747 3748 3749 3750 3751 3752 3753 3754 3755 3756 3757 3758 3759 3760 3761 3762 3763 3764 3765 3766 3767 3768 3769 3770 3771 3772 3773 3774 3775 3776 3777 3778 3779 3780 3781 3782 3783 3784 3785 3786 3787 3788 3789 3790 3791 3792 3793 3794 3795 3796 3797 3798 3799 3800 3801 3802 3803 3804 3805 3806 3807 3808 3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 3825 3826 3827 3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 3844 3845 3846 3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 3932 3933 3934 3935 3936 3937 3938 3939 3940 3941 3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 3960 3961 3962 3963 3964 3965 3966 3967 3968 3969 3970 3971 3972 3973 3974 3975 3976 3977 3978 3979 3980 3981 3982 3983 3984 3985 3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 4009 4010 4011 4012 4013 4014 4015 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 4057 4058 4059 4060 4061 4062 4063 4064 4065 4066 4067 4068 4069 4070 4071 4072 4073 4074 4075 4076 4077 4078 4079 4080 4081 4082 4083 4084 4085 4086 4087 4088 4089 4090 4091 4092 4093 4094 4095 4096 4097 4098 4099 4100 4101 4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 4178 4179 4180 4181 4182 4183 4184 4185 4186 4187 4188 4189 4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 4216 4217 4218 4219 4220 4221 4222 4223 4224 4225 4226 4227 4228 4229 4230 4231 4232 4233 4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 4274 4275 4276 4277 4278 4279 4280 4281 4282 4283 4284 4285 4286 4287 4288 4289 4290 4291 4292 4293 4294 4295 4296 4297 4298 4299 4300 4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339 4340 4341 4342 4343 4344 4345 4346 4347 4348 4349 4350 4351 4352 4353 4354 4355 4356 4357 4358 4359 4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389 4390 4391 4392 4393 4394 4395 4396 4397 4398 4399 4400 4401 4402 4403 4404 4405 4406 4407 4408 4409 4410 4411 4412 4413 4414 4415 4416 4417 4418 4419 4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 4434 4435 4436 4437 4438 4439 4440 4441 4442 4443 4444 4445 4446 4447 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 4487 4488 4489 4490 4491 4492 4493 4494 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 4522 4523 4524 4525 4526 4527 4528 4529 4530 4531 4532 4533 4534 4535 4536 4537 4538 4539 4540 4541 4542 4543 4544 4545 4546 4547 4548 4549 4550 4551 4552 4553 4554 4555 4556 4557 4558 4559 4560 4561 4562 4563 4564 4565 4566 4567 4568 4569 4570 4571 4572 4573 4574 4575 4576 4577 4578 4579 4580 4581 4582 4583 4584 4585 4586 4587 4588 4589 4590 4591 4592 4593 4594 4595 4596 4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612 4613 4614 4615 4616 4617 4618 4619 4620 4621 4622 4623 4624 4625 4626 4627 4628 4629 4630 4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645 4646 4647 4648 4649 4650 4651 4652 4653 4654 4655 4656 4657 4658 4659 4660 4661 4662 4663 4664 4665 4666 4667 4668 4669 4670 4671 4672 4673 4674 4675 4676 4677 4678 4679 4680 4681 4682 4683 4684 4685 4686 4687 4688 4689 4690 4691 4692 4693 4694 4695 4696 4697 4698 4699 4700 4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 4781 4782 4783 4784 4785 4786 4787 4788 4789 4790 4791 4792 4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827 4828 4829 4830 4831 4832 4833 4834 4835 4836 4837 4838 4839 4840 4841 4842 4843 4844 4845 4846 4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869 4870 4871 4872 4873 4874 4875 4876 4877 4878 4879 4880 4881 4882 4883 4884 4885 4886 4887 4888 4889 4890 4891 4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904 4905 4906 4907 4908 4909 4910 4911 4912 4913 4914 4915 4916 |
/* miniz.c v1.15 - public domain deflate/inflate, zlib-subset, ZIP reading/writing/appending, PNG writing
See "unlicense" statement at the end of this file.
Rich Geldreich <richgel99@gmail.com>, last updated Oct. 13, 2013
Implements RFC 1950: http://www.ietf.org/rfc/rfc1950.txt and RFC 1951: http://www.ietf.org/rfc/rfc1951.txt
Most API's defined in miniz.c are optional. For example, to disable the archive related functions just define
MINIZ_NO_ARCHIVE_APIS, or to get rid of all stdio usage define MINIZ_NO_STDIO (see the list below for more macros).
* Change History
10/13/13 v1.15 r4 - Interim bugfix release while I work on the next major release with Zip64 support (almost there!):
- Critical fix for the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY bug (thanks kahmyong.moon@hp.com) which could cause locate files to not find files. This bug
would only have occured in earlier versions if you explicitly used this flag, OR if you used mz_zip_extract_archive_file_to_heap() or mz_zip_add_mem_to_archive_file_in_place()
(which used this flag). If you can't switch to v1.15 but want to fix this bug, just remove the uses of this flag from both helper funcs (and of course don't use the flag).
- Bugfix in mz_zip_reader_extract_to_mem_no_alloc() from kymoon when pUser_read_buf is not NULL and compressed size is > uncompressed size
- Fixing mz_zip_reader_extract_*() funcs so they don't try to extract compressed data from directory entries, to account for weird zipfiles which contain zero-size compressed data on dir entries.
Hopefully this fix won't cause any issues on weird zip archives, because it assumes the low 16-bits of zip external attributes are DOS attributes (which I believe they always are in practice).
- Fixing mz_zip_reader_is_file_a_directory() so it doesn't check the internal attributes, just the filename and external attributes
- mz_zip_reader_init_file() - missing MZ_FCLOSE() call if the seek failed
- Added cmake support for Linux builds which builds all the examples, tested with clang v3.3 and gcc v4.6.
- Clang fix for tdefl_write_image_to_png_file_in_memory() from toffaletti
- Merged MZ_FORCEINLINE fix from hdeanclark
- Fix <time.h> include before config #ifdef, thanks emil.brink
- Added tdefl_write_image_to_png_file_in_memory_ex(): supports Y flipping (super useful for OpenGL apps), and explicit control over the compression level (so you can
set it to 1 for real-time compression).
- Merged in some compiler fixes from paulharris's github repro.
- Retested this build under Windows (VS 2010, including static analysis), tcc 0.9.26, gcc v4.6 and clang v3.3.
- Added example6.c, which dumps an image of the mandelbrot set to a PNG file.
- Modified example2 to help test the MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY flag more.
- In r3: Bugfix to mz_zip_writer_add_file() found during merge: Fix possible src file fclose() leak if alignment bytes+local header file write faiiled
- In r4: Minor bugfix to mz_zip_writer_add_from_zip_reader(): Was pushing the wrong central dir header offset, appears harmless in this release, but it became a problem in the zip64 branch
5/20/12 v1.14 - MinGW32/64 GCC 4.6.1 compiler fixes: added MZ_FORCEINLINE, #include <time.h> (thanks fermtect).
5/19/12 v1.13 - From jason@cornsyrup.org and kelwert@mtu.edu - Fix mz_crc32() so it doesn't compute the wrong CRC-32's when mz_ulong is 64-bit.
- Temporarily/locally slammed in "typedef unsigned long mz_ulong" and re-ran a randomized regression test on ~500k files.
- Eliminated a bunch of warnings when compiling with GCC 32-bit/64.
- Ran all examples, miniz.c, and tinfl.c through MSVC 2008's /analyze (static analysis) option and fixed all warnings (except for the silly
"Use of the comma-operator in a tested expression.." analysis warning, which I purposely use to work around a MSVC compiler warning).
- Created 32-bit and 64-bit Codeblocks projects/workspace. Built and tested Linux executables. The codeblocks workspace is compatible with Linux+Win32/x64.
- Added miniz_tester solution/project, which is a useful little app derived from LZHAM's tester app that I use as part of the regression test.
- Ran miniz.c and tinfl.c through another series of regression testing on ~500,000 files and archives.
- Modified example5.c so it purposely disables a bunch of high-level functionality (MINIZ_NO_STDIO, etc.). (Thanks to corysama for the MINIZ_NO_STDIO bug report.)
- Fix ftell() usage in examples so they exit with an error on files which are too large (a limitation of the examples, not miniz itself).
4/12/12 v1.12 - More comments, added low-level example5.c, fixed a couple minor level_and_flags issues in the archive API's.
level_and_flags can now be set to MZ_DEFAULT_COMPRESSION. Thanks to Bruce Dawson <bruced@valvesoftware.com> for the feedback/bug report.
5/28/11 v1.11 - Added statement from unlicense.org
5/27/11 v1.10 - Substantial compressor optimizations:
- Level 1 is now ~4x faster than before. The L1 compressor's throughput now varies between 70-110MB/sec. on a
- Core i7 (actual throughput varies depending on the type of data, and x64 vs. x86).
- Improved baseline L2-L9 compression perf. Also, greatly improved compression perf. issues on some file types.
- Refactored the compression code for better readability and maintainability.
- Added level 10 compression level (L10 has slightly better ratio than level 9, but could have a potentially large
drop in throughput on some files).
5/15/11 v1.09 - Initial stable release.
* Low-level Deflate/Inflate implementation notes:
Compression: Use the "tdefl" API's. The compressor supports raw, static, and dynamic blocks, lazy or
greedy parsing, match length filtering, RLE-only, and Huffman-only streams. It performs and compresses
approximately as well as zlib.
Decompression: Use the "tinfl" API's. The entire decompressor is implemented as a single function
coroutine: see tinfl_decompress(). It supports decompression into a 32KB (or larger power of 2) wrapping buffer, or into a memory
block large enough to hold the entire file.
The low-level tdefl/tinfl API's do not make any use of dynamic memory allocation.
* zlib-style API notes:
miniz.c implements a fairly large subset of zlib. There's enough functionality present for it to be a drop-in
zlib replacement in many apps:
The z_stream struct, optional memory allocation callbacks
deflateInit/deflateInit2/deflate/deflateReset/deflateEnd/deflateBound
inflateInit/inflateInit2/inflate/inflateEnd
compress, compress2, compressBound, uncompress
CRC-32, Adler-32 - Using modern, minimal code size, CPU cache friendly routines.
Supports raw deflate streams or standard zlib streams with adler-32 checking.
Limitations:
The callback API's are not implemented yet. No support for gzip headers or zlib static dictionaries.
I've tried to closely emulate zlib's various flavors of stream flushing and return status codes, but
there are no guarantees that miniz.c pulls this off perfectly.
* PNG writing: See the tdefl_write_image_to_png_file_in_memory() function, originally written by
Alex Evans. Supports 1-4 bytes/pixel images.
* ZIP archive API notes:
The ZIP archive API's where designed with simplicity and efficiency in mind, with just enough abstraction to
get the job done with minimal fuss. There are simple API's to retrieve file information, read files from
existing archives, create new archives, append new files to existing archives, or clone archive data from
one archive to another. It supports archives located in memory or the heap, on disk (using stdio.h),
or you can specify custom file read/write callbacks.
- Archive reading: Just call this function to read a single file from a disk archive:
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name,
size_t *pSize, mz_uint zip_flags);
For more complex cases, use the "mz_zip_reader" functions. Upon opening an archive, the entire central
directory is located and read as-is into memory, and subsequent file access only occurs when reading individual files.
- Archives file scanning: The simple way is to use this function to scan a loaded archive for a specific file:
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
The locate operation can optionally check file comments too, which (as one example) can be used to identify
multiple versions of the same file in an archive. This function uses a simple linear search through the central
directory, so it's not very fast.
Alternately, you can iterate through all the files in an archive (using mz_zip_reader_get_num_files()) and
retrieve detailed info on each file by calling mz_zip_reader_file_stat().
- Archive creation: Use the "mz_zip_writer" functions. The ZIP writer immediately writes compressed file data
to disk and builds an exact image of the central directory in memory. The central directory image is written
all at once at the end of the archive file when the archive is finalized.
The archive writer can optionally align each file's local header and file data to any power of 2 alignment,
which can be useful when the archive will be read from optical media. Also, the writer supports placing
arbitrary data blobs at the very beginning of ZIP archives. Archives written using either feature are still
readable by any ZIP tool.
- Archive appending: The simple way to add a single file to an archive is to call this function:
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name,
const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
The archive will be created if it doesn't already exist, otherwise it'll be appended to.
Note the appending is done in-place and is not an atomic operation, so if something goes wrong
during the operation it's possible the archive could be left without a central directory (although the local
file headers and file data will be fine, so the archive will be recoverable).
For more complex archive modification scenarios:
1. The safest way is to use a mz_zip_reader to read the existing archive, cloning only those bits you want to
preserve into a new archive using using the mz_zip_writer_add_from_zip_reader() function (which compiles the
compressed file data as-is). When you're done, delete the old archive and rename the newly written archive, and
you're done. This is safe but requires a bunch of temporary disk space or heap memory.
2. Or, you can convert an mz_zip_reader in-place to an mz_zip_writer using mz_zip_writer_init_from_reader(),
append new files as needed, then finalize the archive which will write an updated central directory to the
original archive. (This is basically what mz_zip_add_mem_to_archive_file_in_place() does.) There's a
possibility that the archive's central directory could be lost with this method if anything goes wrong, though.
- ZIP archive support limitations:
No zip64 or spanning support. Extraction functions can only handle unencrypted, stored or deflated files.
Requires streams capable of seeking.
* This is a header file library, like stb_image.c. To get only a header file, either cut and paste the
below header, or create miniz.h, #define MINIZ_HEADER_FILE_ONLY, and then include miniz.c from it.
* Important: For best perf. be sure to customize the below macros for your target platform:
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
#define MINIZ_LITTLE_ENDIAN 1
#define MINIZ_HAS_64BIT_REGISTERS 1
* On platforms using glibc, Be sure to "#define _LARGEFILE64_SOURCE 1" before including miniz.c to ensure miniz
uses the 64-bit variants: fopen64(), stat64(), etc. Otherwise you won't be able to process large files
(i.e. 32-bit stat() fails for me on files > 0x7FFFFFFF bytes).
*/
#ifndef MINIZ_HEADER_INCLUDED
#define MINIZ_HEADER_INCLUDED
#include <stdlib.h>
// Defines to completely disable specific portions of miniz.c:
// If all macros here are defined the only functionality remaining will be CRC-32, adler-32, tinfl, and tdefl.
// Define MINIZ_NO_STDIO to disable all usage and any functions which rely on stdio for file I/O.
//#define MINIZ_NO_STDIO
// If MINIZ_NO_TIME is specified then the ZIP archive functions will not be able to get the current time, or
// get/set file times, and the C run-time funcs that get/set times won't be called.
// The current downside is the times written to your archives will be from 1979.
//#define MINIZ_NO_TIME
// Define MINIZ_NO_ARCHIVE_APIS to disable all ZIP archive API's.
//#define MINIZ_NO_ARCHIVE_APIS
// Define MINIZ_NO_ARCHIVE_APIS to disable all writing related ZIP archive API's.
//#define MINIZ_NO_ARCHIVE_WRITING_APIS
// Define MINIZ_NO_ZLIB_APIS to remove all ZLIB-style compression/decompression API's.
//#define MINIZ_NO_ZLIB_APIS
// Define MINIZ_NO_ZLIB_COMPATIBLE_NAME to disable zlib names, to prevent conflicts against stock zlib.
//#define MINIZ_NO_ZLIB_COMPATIBLE_NAMES
// Define MINIZ_NO_MALLOC to disable all calls to malloc, free, and realloc.
// Note if MINIZ_NO_MALLOC is defined then the user must always provide custom user alloc/free/realloc
// callbacks to the zlib and archive API's, and a few stand-alone helper API's which don't provide custom user
// functions (such as tdefl_compress_mem_to_heap() and tinfl_decompress_mem_to_heap()) won't work.
//#define MINIZ_NO_MALLOC
#if defined(__TINYC__) && (defined(__linux) || defined(__linux__))
// TODO: Work around "error: include file 'sys\utime.h' when compiling with tcc on Linux
#define MINIZ_NO_TIME
#endif
#if !defined(MINIZ_NO_TIME) && !defined(MINIZ_NO_ARCHIVE_APIS)
#include <time.h>
#endif
#if defined(_M_IX86) || defined(_M_X64) || defined(__i386__) || defined(__i386) || defined(__i486__) || defined(__i486) || defined(i386) || defined(__ia64__) || defined(__x86_64__)
// MINIZ_X86_OR_X64_CPU is only used to help set the below macros.
#define MINIZ_X86_OR_X64_CPU 1
#endif
#if (__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__) || MINIZ_X86_OR_X64_CPU
// Set MINIZ_LITTLE_ENDIAN to 1 if the processor is little endian.
#define MINIZ_LITTLE_ENDIAN 1
#endif
#if MINIZ_X86_OR_X64_CPU
// Set MINIZ_USE_UNALIGNED_LOADS_AND_STORES to 1 on CPU's that permit efficient integer loads and stores from unaligned addresses.
#define MINIZ_USE_UNALIGNED_LOADS_AND_STORES 1
#endif
#if defined(_M_X64) || defined(_WIN64) || defined(__MINGW64__) || defined(_LP64) || defined(__LP64__) || defined(__ia64__) || defined(__x86_64__)
// Set MINIZ_HAS_64BIT_REGISTERS to 1 if operations on 64-bit integers are reasonably fast (and don't involve compiler generated calls to helper functions).
#define MINIZ_HAS_64BIT_REGISTERS 1
#endif
#ifdef __cplusplus
extern "C" {
#endif
// ------------------- zlib-style API Definitions.
// For more compatibility with zlib, miniz.c uses unsigned long for some parameters/struct members. Beware: mz_ulong can be either 32 or 64-bits!
typedef unsigned long mz_ulong;
// mz_free() internally uses the MZ_FREE() macro (which by default calls free() unless you've modified the MZ_MALLOC macro) to release a block allocated from the heap.
void mz_free(void *p);
#define MZ_ADLER32_INIT (1)
// mz_adler32() returns the initial adler-32 value to use when called with ptr==NULL.
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len);
#define MZ_CRC32_INIT (0)
// mz_crc32() returns the initial CRC-32 value to use when called with ptr==NULL.
mz_ulong mz_crc32(mz_ulong crc, const unsigned char *ptr, size_t buf_len);
// Compression strategies.
enum { MZ_DEFAULT_STRATEGY = 0, MZ_FILTERED = 1, MZ_HUFFMAN_ONLY = 2, MZ_RLE = 3, MZ_FIXED = 4 };
// Method
#define MZ_DEFLATED 8
#ifndef MINIZ_NO_ZLIB_APIS
// Heap allocation callbacks.
// Note that mz_alloc_func parameter types purpsosely differ from zlib's: items/size is size_t, not unsigned long.
typedef void *(*mz_alloc_func)(void *opaque, size_t items, size_t size);
typedef void (*mz_free_func)(void *opaque, void *address);
typedef void *(*mz_realloc_func)(void *opaque, void *address, size_t items, size_t size);
#define MZ_VERSION "9.1.15"
#define MZ_VERNUM 0x91F0
#define MZ_VER_MAJOR 9
#define MZ_VER_MINOR 1
#define MZ_VER_REVISION 15
#define MZ_VER_SUBREVISION 0
// Flush values. For typical usage you only need MZ_NO_FLUSH and MZ_FINISH. The other values are for advanced use (refer to the zlib docs).
enum { MZ_NO_FLUSH = 0, MZ_PARTIAL_FLUSH = 1, MZ_SYNC_FLUSH = 2, MZ_FULL_FLUSH = 3, MZ_FINISH = 4, MZ_BLOCK = 5 };
// Return status codes. MZ_PARAM_ERROR is non-standard.
enum { MZ_OK = 0, MZ_STREAM_END = 1, MZ_NEED_DICT = 2, MZ_ERRNO = -1, MZ_STREAM_ERROR = -2, MZ_DATA_ERROR = -3, MZ_MEM_ERROR = -4, MZ_BUF_ERROR = -5, MZ_VERSION_ERROR = -6, MZ_PARAM_ERROR = -10000 };
// Compression levels: 0-9 are the standard zlib-style levels, 10 is best possible compression (not zlib compatible, and may be very slow), MZ_DEFAULT_COMPRESSION=MZ_DEFAULT_LEVEL.
enum { MZ_NO_COMPRESSION = 0, MZ_BEST_SPEED = 1, MZ_BEST_COMPRESSION = 9, MZ_UBER_COMPRESSION = 10, MZ_DEFAULT_LEVEL = 6, MZ_DEFAULT_COMPRESSION = -1 };
// Window bits
#define MZ_DEFAULT_WINDOW_BITS 15
struct mz_internal_state;
// Compression/decompression stream struct.
typedef struct mz_stream_s
{
const unsigned char *next_in; // pointer to next byte to read
unsigned int avail_in; // number of bytes available at next_in
mz_ulong total_in; // total number of bytes consumed so far
unsigned char *next_out; // pointer to next byte to write
unsigned int avail_out; // number of bytes that can be written to next_out
mz_ulong total_out; // total number of bytes produced so far
char *msg; // error msg (unused)
struct mz_internal_state *state; // internal state, allocated by zalloc/zfree
mz_alloc_func zalloc; // optional heap allocation function (defaults to malloc)
mz_free_func zfree; // optional heap free function (defaults to free)
void *opaque; // heap alloc function user pointer
int data_type; // data_type (unused)
mz_ulong adler; // adler32 of the source or uncompressed data
mz_ulong reserved; // not used
} mz_stream;
typedef mz_stream *mz_streamp;
// Returns the version string of miniz.c.
const char *mz_version(void);
// mz_deflateInit() initializes a compressor with default options:
// Parameters:
// pStream must point to an initialized mz_stream struct.
// level must be between [MZ_NO_COMPRESSION, MZ_BEST_COMPRESSION].
// level 1 enables a specially optimized compression function that's been optimized purely for performance, not ratio.
// (This special func. is currently only enabled when MINIZ_USE_UNALIGNED_LOADS_AND_STORES and MINIZ_LITTLE_ENDIAN are defined.)
// Return values:
// MZ_OK on success.
// MZ_STREAM_ERROR if the stream is bogus.
// MZ_PARAM_ERROR if the input parameters are bogus.
// MZ_MEM_ERROR on out of memory.
int mz_deflateInit(mz_streamp pStream, int level);
// mz_deflateInit2() is like mz_deflate(), except with more control:
// Additional parameters:
// method must be MZ_DEFLATED
// window_bits must be MZ_DEFAULT_WINDOW_BITS (to wrap the deflate stream with zlib header/adler-32 footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate/no header or footer)
// mem_level must be between [1, 9] (it's checked but ignored by miniz.c)
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy);
// Quickly resets a compressor without having to reallocate anything. Same as calling mz_deflateEnd() followed by mz_deflateInit()/mz_deflateInit2().
int mz_deflateReset(mz_streamp pStream);
// mz_deflate() compresses the input to output, consuming as much of the input and producing as much output as possible.
// Parameters:
// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members.
// flush may be MZ_NO_FLUSH, MZ_PARTIAL_FLUSH/MZ_SYNC_FLUSH, MZ_FULL_FLUSH, or MZ_FINISH.
// Return values:
// MZ_OK on success (when flushing, or if more input is needed but not available, and/or there's more output to be written but the output buffer is full).
// MZ_STREAM_END if all input has been consumed and all output bytes have been written. Don't call mz_deflate() on the stream anymore.
// MZ_STREAM_ERROR if the stream is bogus.
// MZ_PARAM_ERROR if one of the parameters is invalid.
// MZ_BUF_ERROR if no forward progress is possible because the input and/or output buffers are empty. (Fill up the input buffer or free up some output space and try again.)
int mz_deflate(mz_streamp pStream, int flush);
// mz_deflateEnd() deinitializes a compressor:
// Return values:
// MZ_OK on success.
// MZ_STREAM_ERROR if the stream is bogus.
int mz_deflateEnd(mz_streamp pStream);
// mz_deflateBound() returns a (very) conservative upper bound on the amount of data that could be generated by deflate(), assuming flush is set to only MZ_NO_FLUSH or MZ_FINISH.
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len);
// Single-call compression functions mz_compress() and mz_compress2():
// Returns MZ_OK on success, or one of the error codes from mz_deflate() on failure.
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level);
// mz_compressBound() returns a (very) conservative upper bound on the amount of data that could be generated by calling mz_compress().
mz_ulong mz_compressBound(mz_ulong source_len);
// Initializes a decompressor.
int mz_inflateInit(mz_streamp pStream);
// mz_inflateInit2() is like mz_inflateInit() with an additional option that controls the window size and whether or not the stream has been wrapped with a zlib header/footer:
// window_bits must be MZ_DEFAULT_WINDOW_BITS (to parse zlib header/footer) or -MZ_DEFAULT_WINDOW_BITS (raw deflate).
int mz_inflateInit2(mz_streamp pStream, int window_bits);
// Decompresses the input stream to the output, consuming only as much of the input as needed, and writing as much to the output as possible.
// Parameters:
// pStream is the stream to read from and write to. You must initialize/update the next_in, avail_in, next_out, and avail_out members.
// flush may be MZ_NO_FLUSH, MZ_SYNC_FLUSH, or MZ_FINISH.
// On the first call, if flush is MZ_FINISH it's assumed the input and output buffers are both sized large enough to decompress the entire stream in a single call (this is slightly faster).
// MZ_FINISH implies that there are no more source bytes available beside what's already in the input buffer, and that the output buffer is large enough to hold the rest of the decompressed data.
// Return values:
// MZ_OK on success. Either more input is needed but not available, and/or there's more output to be written but the output buffer is full.
// MZ_STREAM_END if all needed input has been consumed and all output bytes have been written. For zlib streams, the adler-32 of the decompressed data has also been verified.
// MZ_STREAM_ERROR if the stream is bogus.
// MZ_DATA_ERROR if the deflate stream is invalid.
// MZ_PARAM_ERROR if one of the parameters is invalid.
// MZ_BUF_ERROR if no forward progress is possible because the input buffer is empty but the inflater needs more input to continue, or if the output buffer is not large enough. Call mz_inflate() again
// with more input data, or with more room in the output buffer (except when using single call decompression, described above).
int mz_inflate(mz_streamp pStream, int flush);
// Deinitializes a decompressor.
int mz_inflateEnd(mz_streamp pStream);
// Single-call decompression.
// Returns MZ_OK on success, or one of the error codes from mz_inflate() on failure.
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len);
// Returns a string description of the specified error code, or NULL if the error code is invalid.
const char *mz_error(int err);
// Redefine zlib-compatible names to miniz equivalents, so miniz.c can be used as a drop-in replacement for the subset of zlib that miniz.c supports.
// Define MINIZ_NO_ZLIB_COMPATIBLE_NAMES to disable zlib-compatibility if you use zlib in the same project.
#ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
typedef unsigned char Byte;
typedef unsigned int uInt;
typedef mz_ulong uLong;
typedef Byte Bytef;
typedef uInt uIntf;
typedef char charf;
typedef int intf;
typedef void *voidpf;
typedef uLong uLongf;
typedef void *voidp;
typedef void *const voidpc;
#define Z_NULL 0
#define Z_NO_FLUSH MZ_NO_FLUSH
#define Z_PARTIAL_FLUSH MZ_PARTIAL_FLUSH
#define Z_SYNC_FLUSH MZ_SYNC_FLUSH
#define Z_FULL_FLUSH MZ_FULL_FLUSH
#define Z_FINISH MZ_FINISH
#define Z_BLOCK MZ_BLOCK
#define Z_OK MZ_OK
#define Z_STREAM_END MZ_STREAM_END
#define Z_NEED_DICT MZ_NEED_DICT
#define Z_ERRNO MZ_ERRNO
#define Z_STREAM_ERROR MZ_STREAM_ERROR
#define Z_DATA_ERROR MZ_DATA_ERROR
#define Z_MEM_ERROR MZ_MEM_ERROR
#define Z_BUF_ERROR MZ_BUF_ERROR
#define Z_VERSION_ERROR MZ_VERSION_ERROR
#define Z_PARAM_ERROR MZ_PARAM_ERROR
#define Z_NO_COMPRESSION MZ_NO_COMPRESSION
#define Z_BEST_SPEED MZ_BEST_SPEED
#define Z_BEST_COMPRESSION MZ_BEST_COMPRESSION
#define Z_DEFAULT_COMPRESSION MZ_DEFAULT_COMPRESSION
#define Z_DEFAULT_STRATEGY MZ_DEFAULT_STRATEGY
#define Z_FILTERED MZ_FILTERED
#define Z_HUFFMAN_ONLY MZ_HUFFMAN_ONLY
#define Z_RLE MZ_RLE
#define Z_FIXED MZ_FIXED
#define Z_DEFLATED MZ_DEFLATED
#define Z_DEFAULT_WINDOW_BITS MZ_DEFAULT_WINDOW_BITS
#define alloc_func mz_alloc_func
#define free_func mz_free_func
#define internal_state mz_internal_state
#define z_stream mz_stream
#define deflateInit mz_deflateInit
#define deflateInit2 mz_deflateInit2
#define deflateReset mz_deflateReset
#define deflate mz_deflate
#define deflateEnd mz_deflateEnd
#define deflateBound mz_deflateBound
#define compress mz_compress
#define compress2 mz_compress2
#define compressBound mz_compressBound
#define inflateInit mz_inflateInit
#define inflateInit2 mz_inflateInit2
#define inflate mz_inflate
#define inflateEnd mz_inflateEnd
#define uncompress mz_uncompress
#define crc32 mz_crc32
#define adler32 mz_adler32
#define MAX_WBITS 15
#define MAX_MEM_LEVEL 9
#define zError mz_error
#define ZLIB_VERSION MZ_VERSION
#define ZLIB_VERNUM MZ_VERNUM
#define ZLIB_VER_MAJOR MZ_VER_MAJOR
#define ZLIB_VER_MINOR MZ_VER_MINOR
#define ZLIB_VER_REVISION MZ_VER_REVISION
#define ZLIB_VER_SUBREVISION MZ_VER_SUBREVISION
#define zlibVersion mz_version
#define zlib_version mz_version()
#endif // #ifndef MINIZ_NO_ZLIB_COMPATIBLE_NAMES
#endif // MINIZ_NO_ZLIB_APIS
// ------------------- Types and macros
typedef unsigned char mz_uint8;
typedef signed short mz_int16;
typedef unsigned short mz_uint16;
typedef unsigned int mz_uint32;
typedef unsigned int mz_uint;
typedef long long mz_int64;
typedef unsigned long long mz_uint64;
typedef int mz_bool;
#define MZ_FALSE (0)
#define MZ_TRUE (1)
// An attempt to work around MSVC's spammy "warning C4127: conditional expression is constant" message.
#ifdef _MSC_VER
#define MZ_MACRO_END while (0, 0)
#else
#define MZ_MACRO_END while (0)
#endif
// ------------------- ZIP archive reading/writing
#ifndef MINIZ_NO_ARCHIVE_APIS
enum
{
MZ_ZIP_MAX_IO_BUF_SIZE = 64*1024,
MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE = 260,
MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE = 256
};
typedef struct
{
mz_uint32 m_file_index;
mz_uint32 m_central_dir_ofs;
mz_uint16 m_version_made_by;
mz_uint16 m_version_needed;
mz_uint16 m_bit_flag;
mz_uint16 m_method;
#ifndef MINIZ_NO_TIME
time_t m_time;
#endif
mz_uint32 m_crc32;
mz_uint64 m_comp_size;
mz_uint64 m_uncomp_size;
mz_uint16 m_internal_attr;
mz_uint32 m_external_attr;
mz_uint64 m_local_header_ofs;
mz_uint32 m_comment_size;
char m_filename[MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE];
char m_comment[MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE];
} mz_zip_archive_file_stat;
typedef size_t (*mz_file_read_func)(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n);
typedef size_t (*mz_file_write_func)(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n);
struct mz_zip_internal_state_tag;
typedef struct mz_zip_internal_state_tag mz_zip_internal_state;
typedef enum
{
MZ_ZIP_MODE_INVALID = 0,
MZ_ZIP_MODE_READING = 1,
MZ_ZIP_MODE_WRITING = 2,
MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED = 3
} mz_zip_mode;
typedef struct mz_zip_archive_tag
{
mz_uint64 m_archive_size;
mz_uint64 m_central_directory_file_ofs;
mz_uint m_total_files;
mz_zip_mode m_zip_mode;
mz_uint m_file_offset_alignment;
mz_alloc_func m_pAlloc;
mz_free_func m_pFree;
mz_realloc_func m_pRealloc;
void *m_pAlloc_opaque;
mz_file_read_func m_pRead;
mz_file_write_func m_pWrite;
void *m_pIO_opaque;
mz_zip_internal_state *m_pState;
} mz_zip_archive;
typedef enum
{
MZ_ZIP_FLAG_CASE_SENSITIVE = 0x0100,
MZ_ZIP_FLAG_IGNORE_PATH = 0x0200,
MZ_ZIP_FLAG_COMPRESSED_DATA = 0x0400,
MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY = 0x0800
} mz_zip_flags;
// ZIP archive reading
// Inits a ZIP archive reader.
// These functions read and validate the archive's central directory.
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags);
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags);
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags);
#endif
// Returns the total number of files in the archive.
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip);
// Returns detailed information about an archive file entry.
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat);
// Determines if an archive file entry is a directory entry.
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index);
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index);
// Retrieves the filename of an archive file entry.
// Returns the number of bytes written to pFilename, or if filename_buf_size is 0 this function returns the number of bytes needed to fully store the filename.
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size);
// Attempts to locates a file in the archive's central directory.
// Valid flags: MZ_ZIP_FLAG_CASE_SENSITIVE, MZ_ZIP_FLAG_IGNORE_PATH
// Returns -1 if the file cannot be found.
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags);
// Extracts a archive file to a memory buffer using no memory allocation.
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size);
// Extracts a archive file to a memory buffer.
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags);
// Extracts a archive file to a dynamically allocated heap buffer.
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags);
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags);
// Extracts a archive file using a callback function to output the file's data.
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags);
#ifndef MINIZ_NO_STDIO
// Extracts a archive file to a disk file and sets its last accessed and modified times.
// This function only extracts files, not archive directory records.
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags);
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags);
#endif
// Ends archive reading, freeing all allocations, and closing the input archive file if mz_zip_reader_init_file() was used.
mz_bool mz_zip_reader_end(mz_zip_archive *pZip);
// ZIP archive writing
#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
// Inits a ZIP archive writer.
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size);
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size);
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning);
#endif
// Converts a ZIP archive reader object into a writer object, to allow efficient in-place file appends to occur on an existing archive.
// For archives opened using mz_zip_reader_init_file, pFilename must be the archive's filename so it can be reopened for writing. If the file can't be reopened, mz_zip_reader_end() will be called.
// For archives opened using mz_zip_reader_init_mem, the memory block must be growable using the realloc callback (which defaults to realloc unless you've overridden it).
// Finally, for archives opened using mz_zip_reader_init, the mz_zip_archive's user provided m_pWrite function cannot be NULL.
// Note: In-place archive modification is not recommended unless you know what you're doing, because if execution stops or something goes wrong before
// the archive is finalized the file's central directory will be hosed.
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename);
// Adds the contents of a memory buffer to an archive. These functions record the current local time into the archive.
// To add a directory entry, call this method with an archive name ending in a forwardslash with empty buffer.
// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION.
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags);
mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32);
#ifndef MINIZ_NO_STDIO
// Adds the contents of a disk file to an archive. This function also records the disk file's modified time into the archive.
// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION.
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
#endif
// Adds a file to an archive by fully cloning the data from another archive.
// This function fully clones the source file's compressed data (no recompression), along with its full filename, extra data, and comment fields.
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index);
// Finalizes the archive by writing the central directory records followed by the end of central directory record.
// After an archive is finalized, the only valid call on the mz_zip_archive struct is mz_zip_writer_end().
// An archive must be manually finalized by calling this function for it to be valid.
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip);
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize);
// Ends archive writing, freeing all allocations, and closing the output file if mz_zip_writer_init_file() was used.
// Note for the archive to be valid, it must have been finalized before ending.
mz_bool mz_zip_writer_end(mz_zip_archive *pZip);
// Misc. high-level helper functions:
// mz_zip_add_mem_to_archive_file_in_place() efficiently (but not atomically) appends a memory blob to a ZIP archive.
// level_and_flags - compression level (0-10, see MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc.) logically OR'd with zero or more mz_zip_flags, or just set to MZ_DEFAULT_COMPRESSION.
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags);
// Reads a single file from an archive into a heap block.
// Returns NULL on failure.
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint zip_flags);
#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
#endif // #ifndef MINIZ_NO_ARCHIVE_APIS
// ------------------- Low-level Decompression API Definitions
// Decompression flags used by tinfl_decompress().
// TINFL_FLAG_PARSE_ZLIB_HEADER: If set, the input has a valid zlib header and ends with an adler32 checksum (it's a valid zlib stream). Otherwise, the input is a raw deflate stream.
// TINFL_FLAG_HAS_MORE_INPUT: If set, there are more input bytes available beyond the end of the supplied input buffer. If clear, the input buffer contains all remaining input.
// TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF: If set, the output buffer is large enough to hold the entire decompressed stream. If clear, the output buffer is at least the size of the dictionary (typically 32KB).
// TINFL_FLAG_COMPUTE_ADLER32: Force adler-32 checksum computation of the decompressed bytes.
enum
{
TINFL_FLAG_PARSE_ZLIB_HEADER = 1,
TINFL_FLAG_HAS_MORE_INPUT = 2,
TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF = 4,
TINFL_FLAG_COMPUTE_ADLER32 = 8
};
// High level decompression functions:
// tinfl_decompress_mem_to_heap() decompresses a block in memory to a heap block allocated via malloc().
// On entry:
// pSrc_buf, src_buf_len: Pointer and size of the Deflate or zlib source data to decompress.
// On return:
// Function returns a pointer to the decompressed data, or NULL on failure.
// *pOut_len will be set to the decompressed data's size, which could be larger than src_buf_len on uncompressible data.
// The caller must call mz_free() on the returned block when it's no longer needed.
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
// tinfl_decompress_mem_to_mem() decompresses a block in memory to another block in memory.
// Returns TINFL_DECOMPRESS_MEM_TO_MEM_FAILED on failure, or the number of bytes written on success.
#define TINFL_DECOMPRESS_MEM_TO_MEM_FAILED ((size_t)(-1))
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
// tinfl_decompress_mem_to_callback() decompresses a block in memory to an internal 32KB buffer, and a user provided callback function will be called to flush the buffer.
// Returns 1 on success or 0 on failure.
typedef int (*tinfl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser);
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
struct tinfl_decompressor_tag; typedef struct tinfl_decompressor_tag tinfl_decompressor;
// Max size of LZ dictionary.
#define TINFL_LZ_DICT_SIZE 32768
// Return status.
typedef enum
{
TINFL_STATUS_BAD_PARAM = -3,
TINFL_STATUS_ADLER32_MISMATCH = -2,
TINFL_STATUS_FAILED = -1,
TINFL_STATUS_DONE = 0,
TINFL_STATUS_NEEDS_MORE_INPUT = 1,
TINFL_STATUS_HAS_MORE_OUTPUT = 2
} tinfl_status;
// Initializes the decompressor to its initial state.
#define tinfl_init(r) do { (r)->m_state = 0; } MZ_MACRO_END
#define tinfl_get_adler32(r) (r)->m_check_adler32
// Main low-level decompressor coroutine function. This is the only function actually needed for decompression. All the other functions are just high-level helpers for improved usability.
// This is a universal API, i.e. it can be used as a building block to build any desired higher level decompression API. In the limit case, it can be called once per every byte input or output.
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags);
// Internal/private bits follow.
enum
{
TINFL_MAX_HUFF_TABLES = 3, TINFL_MAX_HUFF_SYMBOLS_0 = 288, TINFL_MAX_HUFF_SYMBOLS_1 = 32, TINFL_MAX_HUFF_SYMBOLS_2 = 19,
TINFL_FAST_LOOKUP_BITS = 10, TINFL_FAST_LOOKUP_SIZE = 1 << TINFL_FAST_LOOKUP_BITS
};
typedef struct
{
mz_uint8 m_code_size[TINFL_MAX_HUFF_SYMBOLS_0];
mz_int16 m_look_up[TINFL_FAST_LOOKUP_SIZE], m_tree[TINFL_MAX_HUFF_SYMBOLS_0 * 2];
} tinfl_huff_table;
#if MINIZ_HAS_64BIT_REGISTERS
#define TINFL_USE_64BIT_BITBUF 1
#endif
#if TINFL_USE_64BIT_BITBUF
typedef mz_uint64 tinfl_bit_buf_t;
#define TINFL_BITBUF_SIZE (64)
#else
typedef mz_uint32 tinfl_bit_buf_t;
#define TINFL_BITBUF_SIZE (32)
#endif
struct tinfl_decompressor_tag
{
mz_uint32 m_state, m_num_bits, m_zhdr0, m_zhdr1, m_z_adler32, m_final, m_type, m_check_adler32, m_dist, m_counter, m_num_extra, m_table_sizes[TINFL_MAX_HUFF_TABLES];
tinfl_bit_buf_t m_bit_buf;
size_t m_dist_from_out_buf_start;
tinfl_huff_table m_tables[TINFL_MAX_HUFF_TABLES];
mz_uint8 m_raw_header[4], m_len_codes[TINFL_MAX_HUFF_SYMBOLS_0 + TINFL_MAX_HUFF_SYMBOLS_1 + 137];
};
// ------------------- Low-level Compression API Definitions
// Set TDEFL_LESS_MEMORY to 1 to use less memory (compression will be slightly slower, and raw/dynamic blocks will be output more frequently).
#define TDEFL_LESS_MEMORY 0
// tdefl_init() compression flags logically OR'd together (low 12 bits contain the max. number of probes per dictionary search):
// TDEFL_DEFAULT_MAX_PROBES: The compressor defaults to 128 dictionary probes per dictionary search. 0=Huffman only, 1=Huffman+LZ (fastest/crap compression), 4095=Huffman+LZ (slowest/best compression).
enum
{
TDEFL_HUFFMAN_ONLY = 0, TDEFL_DEFAULT_MAX_PROBES = 128, TDEFL_MAX_PROBES_MASK = 0xFFF
};
// TDEFL_WRITE_ZLIB_HEADER: If set, the compressor outputs a zlib header before the deflate data, and the Adler-32 of the source data at the end. Otherwise, you'll get raw deflate data.
// TDEFL_COMPUTE_ADLER32: Always compute the adler-32 of the input data (even when not writing zlib headers).
// TDEFL_GREEDY_PARSING_FLAG: Set to use faster greedy parsing, instead of more efficient lazy parsing.
// TDEFL_NONDETERMINISTIC_PARSING_FLAG: Enable to decrease the compressor's initialization time to the minimum, but the output may vary from run to run given the same input (depending on the contents of memory).
// TDEFL_RLE_MATCHES: Only look for RLE matches (matches with a distance of 1)
// TDEFL_FILTER_MATCHES: Discards matches <= 5 chars if enabled.
// TDEFL_FORCE_ALL_STATIC_BLOCKS: Disable usage of optimized Huffman tables.
// TDEFL_FORCE_ALL_RAW_BLOCKS: Only use raw (uncompressed) deflate blocks.
// The low 12 bits are reserved to control the max # of hash probes per dictionary lookup (see TDEFL_MAX_PROBES_MASK).
enum
{
TDEFL_WRITE_ZLIB_HEADER = 0x01000,
TDEFL_COMPUTE_ADLER32 = 0x02000,
TDEFL_GREEDY_PARSING_FLAG = 0x04000,
TDEFL_NONDETERMINISTIC_PARSING_FLAG = 0x08000,
TDEFL_RLE_MATCHES = 0x10000,
TDEFL_FILTER_MATCHES = 0x20000,
TDEFL_FORCE_ALL_STATIC_BLOCKS = 0x40000,
TDEFL_FORCE_ALL_RAW_BLOCKS = 0x80000
};
// High level compression functions:
// tdefl_compress_mem_to_heap() compresses a block in memory to a heap block allocated via malloc().
// On entry:
// pSrc_buf, src_buf_len: Pointer and size of source block to compress.
// flags: The max match finder probes (default is 128) logically OR'd against the above flags. Higher probes are slower but improve compression.
// On return:
// Function returns a pointer to the compressed data, or NULL on failure.
// *pOut_len will be set to the compressed data's size, which could be larger than src_buf_len on uncompressible data.
// The caller must free() the returned block when it's no longer needed.
void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags);
// tdefl_compress_mem_to_mem() compresses a block in memory to another block in memory.
// Returns 0 on failure.
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags);
// Compresses an image to a compressed PNG file in memory.
// On entry:
// pImage, w, h, and num_chans describe the image to compress. num_chans may be 1, 2, 3, or 4.
// The image pitch in bytes per scanline will be w*num_chans. The leftmost pixel on the top scanline is stored first in memory.
// level may range from [0,10], use MZ_NO_COMPRESSION, MZ_BEST_SPEED, MZ_BEST_COMPRESSION, etc. or a decent default is MZ_DEFAULT_LEVEL
// If flip is true, the image will be flipped on the Y axis (useful for OpenGL apps).
// On return:
// Function returns a pointer to the compressed data, or NULL on failure.
// *pLen_out will be set to the size of the PNG image file.
// The caller must mz_free() the returned heap block (which will typically be larger than *pLen_out) when it's no longer needed.
void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip);
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out);
// Output stream interface. The compressor uses this interface to write compressed data. It'll typically be called TDEFL_OUT_BUF_SIZE at a time.
typedef mz_bool (*tdefl_put_buf_func_ptr)(const void* pBuf, int len, void *pUser);
// tdefl_compress_mem_to_output() compresses a block to an output stream. The above helpers use this function internally.
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
enum { TDEFL_MAX_HUFF_TABLES = 3, TDEFL_MAX_HUFF_SYMBOLS_0 = 288, TDEFL_MAX_HUFF_SYMBOLS_1 = 32, TDEFL_MAX_HUFF_SYMBOLS_2 = 19, TDEFL_LZ_DICT_SIZE = 32768, TDEFL_LZ_DICT_SIZE_MASK = TDEFL_LZ_DICT_SIZE - 1, TDEFL_MIN_MATCH_LEN = 3, TDEFL_MAX_MATCH_LEN = 258 };
// TDEFL_OUT_BUF_SIZE MUST be large enough to hold a single entire compressed output block (using static/fixed Huffman codes).
#if TDEFL_LESS_MEMORY
enum { TDEFL_LZ_CODE_BUF_SIZE = 24 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 12, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS };
#else
enum { TDEFL_LZ_CODE_BUF_SIZE = 64 * 1024, TDEFL_OUT_BUF_SIZE = (TDEFL_LZ_CODE_BUF_SIZE * 13 ) / 10, TDEFL_MAX_HUFF_SYMBOLS = 288, TDEFL_LZ_HASH_BITS = 15, TDEFL_LEVEL1_HASH_SIZE_MASK = 4095, TDEFL_LZ_HASH_SHIFT = (TDEFL_LZ_HASH_BITS + 2) / 3, TDEFL_LZ_HASH_SIZE = 1 << TDEFL_LZ_HASH_BITS };
#endif
// The low-level tdefl functions below may be used directly if the above helper functions aren't flexible enough. The low-level functions don't make any heap allocations, unlike the above helper functions.
typedef enum
{
TDEFL_STATUS_BAD_PARAM = -2,
TDEFL_STATUS_PUT_BUF_FAILED = -1,
TDEFL_STATUS_OKAY = 0,
TDEFL_STATUS_DONE = 1,
} tdefl_status;
// Must map to MZ_NO_FLUSH, MZ_SYNC_FLUSH, etc. enums
typedef enum
{
TDEFL_NO_FLUSH = 0,
TDEFL_SYNC_FLUSH = 2,
TDEFL_FULL_FLUSH = 3,
TDEFL_FINISH = 4
} tdefl_flush;
// tdefl's compression state structure.
typedef struct
{
tdefl_put_buf_func_ptr m_pPut_buf_func;
void *m_pPut_buf_user;
mz_uint m_flags, m_max_probes[2];
int m_greedy_parsing;
mz_uint m_adler32, m_lookahead_pos, m_lookahead_size, m_dict_size;
mz_uint8 *m_pLZ_code_buf, *m_pLZ_flags, *m_pOutput_buf, *m_pOutput_buf_end;
mz_uint m_num_flags_left, m_total_lz_bytes, m_lz_code_buf_dict_pos, m_bits_in, m_bit_buffer;
mz_uint m_saved_match_dist, m_saved_match_len, m_saved_lit, m_output_flush_ofs, m_output_flush_remaining, m_finished, m_block_index, m_wants_to_finish;
tdefl_status m_prev_return_status;
const void *m_pIn_buf;
void *m_pOut_buf;
size_t *m_pIn_buf_size, *m_pOut_buf_size;
tdefl_flush m_flush;
const mz_uint8 *m_pSrc;
size_t m_src_buf_left, m_out_buf_ofs;
mz_uint8 m_dict[TDEFL_LZ_DICT_SIZE + TDEFL_MAX_MATCH_LEN - 1];
mz_uint16 m_huff_count[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
mz_uint16 m_huff_codes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
mz_uint8 m_huff_code_sizes[TDEFL_MAX_HUFF_TABLES][TDEFL_MAX_HUFF_SYMBOLS];
mz_uint8 m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE];
mz_uint16 m_next[TDEFL_LZ_DICT_SIZE];
mz_uint16 m_hash[TDEFL_LZ_HASH_SIZE];
mz_uint8 m_output_buf[TDEFL_OUT_BUF_SIZE];
} tdefl_compressor;
// Initializes the compressor.
// There is no corresponding deinit() function because the tdefl API's do not dynamically allocate memory.
// pBut_buf_func: If NULL, output data will be supplied to the specified callback. In this case, the user should call the tdefl_compress_buffer() API for compression.
// If pBut_buf_func is NULL the user should always call the tdefl_compress() API.
// flags: See the above enums (TDEFL_HUFFMAN_ONLY, TDEFL_WRITE_ZLIB_HEADER, etc.)
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags);
// Compresses a block of data, consuming as much of the specified input buffer as possible, and writing as much compressed data to the specified output buffer as possible.
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush);
// tdefl_compress_buffer() is only usable when the tdefl_init() is called with a non-NULL tdefl_put_buf_func_ptr.
// tdefl_compress_buffer() always consumes the entire input buffer.
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush);
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d);
mz_uint32 tdefl_get_adler32(tdefl_compressor *d);
// Can't use tdefl_create_comp_flags_from_zip_params if MINIZ_NO_ZLIB_APIS isn't defined, because it uses some of its macros.
#ifndef MINIZ_NO_ZLIB_APIS
// Create tdefl_compress() flags given zlib-style compression parameters.
// level may range from [0,10] (where 10 is absolute max compression, but may be much slower on some files)
// window_bits may be -15 (raw deflate) or 15 (zlib)
// strategy may be either MZ_DEFAULT_STRATEGY, MZ_FILTERED, MZ_HUFFMAN_ONLY, MZ_RLE, or MZ_FIXED
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy);
#endif // #ifndef MINIZ_NO_ZLIB_APIS
#ifdef __cplusplus
}
#endif
#endif // MINIZ_HEADER_INCLUDED
// ------------------- End of Header: Implementation follows. (If you only want the header, define MINIZ_HEADER_FILE_ONLY.)
#ifndef MINIZ_HEADER_FILE_ONLY
typedef unsigned char mz_validate_uint16[sizeof(mz_uint16)==2 ? 1 : -1];
typedef unsigned char mz_validate_uint32[sizeof(mz_uint32)==4 ? 1 : -1];
typedef unsigned char mz_validate_uint64[sizeof(mz_uint64)==8 ? 1 : -1];
#include <string.h>
#include <assert.h>
#define MZ_ASSERT(x) assert(x)
#ifdef MINIZ_NO_MALLOC
#define MZ_MALLOC(x) NULL
#define MZ_FREE(x) (void)x, ((void)0)
#define MZ_REALLOC(p, x) NULL
#else
#define MZ_MALLOC(x) malloc(x)
#define MZ_FREE(x) free(x)
#define MZ_REALLOC(p, x) realloc(p, x)
#endif
#define MZ_MAX(a,b) (((a)>(b))?(a):(b))
#define MZ_MIN(a,b) (((a)<(b))?(a):(b))
#define MZ_CLEAR_OBJ(obj) memset(&(obj), 0, sizeof(obj))
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
#define MZ_READ_LE16(p) *((const mz_uint16 *)(p))
#define MZ_READ_LE32(p) *((const mz_uint32 *)(p))
#else
#define MZ_READ_LE16(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U))
#define MZ_READ_LE32(p) ((mz_uint32)(((const mz_uint8 *)(p))[0]) | ((mz_uint32)(((const mz_uint8 *)(p))[1]) << 8U) | ((mz_uint32)(((const mz_uint8 *)(p))[2]) << 16U) | ((mz_uint32)(((const mz_uint8 *)(p))[3]) << 24U))
#endif
#ifdef _MSC_VER
#define MZ_FORCEINLINE __forceinline
#elif defined(__GNUC__)
#define MZ_FORCEINLINE inline __attribute__((__always_inline__))
#else
#define MZ_FORCEINLINE inline
#endif
#ifdef __cplusplus
extern "C" {
#endif
// ------------------- zlib-style API's
mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len)
{
mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16); size_t block_len = buf_len % 5552;
if (!ptr) return MZ_ADLER32_INIT;
while (buf_len) {
for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {
s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
}
for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
}
return (s2 << 16) + s1;
}
// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/
mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len)
{
static const mz_uint32 s_crc32[16] = { 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4, 0x4db26158, 0x5005713c,
0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c, 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c };
mz_uint32 crcu32 = (mz_uint32)crc;
if (!ptr) return MZ_CRC32_INIT;
crcu32 = ~crcu32; while (buf_len--) { mz_uint8 b = *ptr++; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)]; crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)]; }
return ~crcu32;
}
void mz_free(void *p)
{
MZ_FREE(p);
}
#ifndef MINIZ_NO_ZLIB_APIS
static void *def_alloc_func(void *opaque, size_t items, size_t size) { (void)opaque, (void)items, (void)size; return MZ_MALLOC(items * size); }
static void def_free_func(void *opaque, void *address) { (void)opaque, (void)address; MZ_FREE(address); }
static void *def_realloc_func(void *opaque, void *address, size_t items, size_t size) { (void)opaque, (void)address, (void)items, (void)size; return MZ_REALLOC(address, items * size); }
const char *mz_version(void)
{
return MZ_VERSION;
}
int mz_deflateInit(mz_streamp pStream, int level)
{
return mz_deflateInit2(pStream, level, MZ_DEFLATED, MZ_DEFAULT_WINDOW_BITS, 9, MZ_DEFAULT_STRATEGY);
}
int mz_deflateInit2(mz_streamp pStream, int level, int method, int window_bits, int mem_level, int strategy)
{
tdefl_compressor *pComp;
mz_uint comp_flags = TDEFL_COMPUTE_ADLER32 | tdefl_create_comp_flags_from_zip_params(level, window_bits, strategy);
if (!pStream) return MZ_STREAM_ERROR;
if ((method != MZ_DEFLATED) || ((mem_level < 1) || (mem_level > 9)) || ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS))) return MZ_PARAM_ERROR;
pStream->data_type = 0;
pStream->adler = MZ_ADLER32_INIT;
pStream->msg = NULL;
pStream->reserved = 0;
pStream->total_in = 0;
pStream->total_out = 0;
if (!pStream->zalloc) pStream->zalloc = def_alloc_func;
if (!pStream->zfree) pStream->zfree = def_free_func;
pComp = (tdefl_compressor *)pStream->zalloc(pStream->opaque, 1, sizeof(tdefl_compressor));
if (!pComp)
return MZ_MEM_ERROR;
pStream->state = (struct mz_internal_state *)pComp;
if (tdefl_init(pComp, NULL, NULL, comp_flags) != TDEFL_STATUS_OKAY)
{
mz_deflateEnd(pStream);
return MZ_PARAM_ERROR;
}
return MZ_OK;
}
int mz_deflateReset(mz_streamp pStream)
{
if ((!pStream) || (!pStream->state) || (!pStream->zalloc) || (!pStream->zfree)) return MZ_STREAM_ERROR;
pStream->total_in = pStream->total_out = 0;
tdefl_init((tdefl_compressor*)pStream->state, NULL, NULL, ((tdefl_compressor*)pStream->state)->m_flags);
return MZ_OK;
}
int mz_deflate(mz_streamp pStream, int flush)
{
size_t in_bytes, out_bytes;
mz_ulong orig_total_in, orig_total_out;
int mz_status = MZ_OK;
if ((!pStream) || (!pStream->state) || (flush < 0) || (flush > MZ_FINISH) || (!pStream->next_out)) return MZ_STREAM_ERROR;
if (!pStream->avail_out) return MZ_BUF_ERROR;
if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH;
if (((tdefl_compressor*)pStream->state)->m_prev_return_status == TDEFL_STATUS_DONE)
return (flush == MZ_FINISH) ? MZ_STREAM_END : MZ_BUF_ERROR;
orig_total_in = pStream->total_in; orig_total_out = pStream->total_out;
for ( ; ; )
{
tdefl_status defl_status;
in_bytes = pStream->avail_in; out_bytes = pStream->avail_out;
defl_status = tdefl_compress((tdefl_compressor*)pStream->state, pStream->next_in, &in_bytes, pStream->next_out, &out_bytes, (tdefl_flush)flush);
pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes;
pStream->total_in += (mz_uint)in_bytes; pStream->adler = tdefl_get_adler32((tdefl_compressor*)pStream->state);
pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes;
pStream->total_out += (mz_uint)out_bytes;
if (defl_status < 0)
{
mz_status = MZ_STREAM_ERROR;
break;
}
else if (defl_status == TDEFL_STATUS_DONE)
{
mz_status = MZ_STREAM_END;
break;
}
else if (!pStream->avail_out)
break;
else if ((!pStream->avail_in) && (flush != MZ_FINISH))
{
if ((flush) || (pStream->total_in != orig_total_in) || (pStream->total_out != orig_total_out))
break;
return MZ_BUF_ERROR; // Can't make forward progress without some input.
}
}
return mz_status;
}
int mz_deflateEnd(mz_streamp pStream)
{
if (!pStream) return MZ_STREAM_ERROR;
if (pStream->state)
{
pStream->zfree(pStream->opaque, pStream->state);
pStream->state = NULL;
}
return MZ_OK;
}
mz_ulong mz_deflateBound(mz_streamp pStream, mz_ulong source_len)
{
(void)pStream;
// This is really over conservative. (And lame, but it's actually pretty tricky to compute a true upper bound given the way tdefl's blocking works.)
return MZ_MAX(128 + (source_len * 110) / 100, 128 + source_len + ((source_len / (31 * 1024)) + 1) * 5);
}
int mz_compress2(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len, int level)
{
int status;
mz_stream stream;
memset(&stream, 0, sizeof(stream));
// In case mz_ulong is 64-bits (argh I hate longs).
if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR;
stream.next_in = pSource;
stream.avail_in = (mz_uint32)source_len;
stream.next_out = pDest;
stream.avail_out = (mz_uint32)*pDest_len;
status = mz_deflateInit(&stream, level);
if (status != MZ_OK) return status;
status = mz_deflate(&stream, MZ_FINISH);
if (status != MZ_STREAM_END)
{
mz_deflateEnd(&stream);
return (status == MZ_OK) ? MZ_BUF_ERROR : status;
}
*pDest_len = stream.total_out;
return mz_deflateEnd(&stream);
}
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
{
return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION);
}
mz_ulong mz_compressBound(mz_ulong source_len)
{
return mz_deflateBound(NULL, source_len);
}
typedef struct
{
tinfl_decompressor m_decomp;
mz_uint m_dict_ofs, m_dict_avail, m_first_call, m_has_flushed; int m_window_bits;
mz_uint8 m_dict[TINFL_LZ_DICT_SIZE];
tinfl_status m_last_status;
} inflate_state;
int mz_inflateInit2(mz_streamp pStream, int window_bits)
{
inflate_state *pDecomp;
if (!pStream) return MZ_STREAM_ERROR;
if ((window_bits != MZ_DEFAULT_WINDOW_BITS) && (-window_bits != MZ_DEFAULT_WINDOW_BITS)) return MZ_PARAM_ERROR;
pStream->data_type = 0;
pStream->adler = 0;
pStream->msg = NULL;
pStream->total_in = 0;
pStream->total_out = 0;
pStream->reserved = 0;
if (!pStream->zalloc) pStream->zalloc = def_alloc_func;
if (!pStream->zfree) pStream->zfree = def_free_func;
pDecomp = (inflate_state*)pStream->zalloc(pStream->opaque, 1, sizeof(inflate_state));
if (!pDecomp) return MZ_MEM_ERROR;
pStream->state = (struct mz_internal_state *)pDecomp;
tinfl_init(&pDecomp->m_decomp);
pDecomp->m_dict_ofs = 0;
pDecomp->m_dict_avail = 0;
pDecomp->m_last_status = TINFL_STATUS_NEEDS_MORE_INPUT;
pDecomp->m_first_call = 1;
pDecomp->m_has_flushed = 0;
pDecomp->m_window_bits = window_bits;
return MZ_OK;
}
int mz_inflateInit(mz_streamp pStream)
{
return mz_inflateInit2(pStream, MZ_DEFAULT_WINDOW_BITS);
}
int mz_inflate(mz_streamp pStream, int flush)
{
inflate_state* pState;
mz_uint n, first_call, decomp_flags = TINFL_FLAG_COMPUTE_ADLER32;
size_t in_bytes, out_bytes, orig_avail_in;
tinfl_status status;
if ((!pStream) || (!pStream->state)) return MZ_STREAM_ERROR;
if (flush == MZ_PARTIAL_FLUSH) flush = MZ_SYNC_FLUSH;
if ((flush) && (flush != MZ_SYNC_FLUSH) && (flush != MZ_FINISH)) return MZ_STREAM_ERROR;
pState = (inflate_state*)pStream->state;
if (pState->m_window_bits > 0) decomp_flags |= TINFL_FLAG_PARSE_ZLIB_HEADER;
orig_avail_in = pStream->avail_in;
first_call = pState->m_first_call; pState->m_first_call = 0;
if (pState->m_last_status < 0) return MZ_DATA_ERROR;
if (pState->m_has_flushed && (flush != MZ_FINISH)) return MZ_STREAM_ERROR;
pState->m_has_flushed |= (flush == MZ_FINISH);
if ((flush == MZ_FINISH) && (first_call))
{
// MZ_FINISH on the first call implies that the input and output buffers are large enough to hold the entire compressed/decompressed file.
decomp_flags |= TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF;
in_bytes = pStream->avail_in; out_bytes = pStream->avail_out;
status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pStream->next_out, pStream->next_out, &out_bytes, decomp_flags);
pState->m_last_status = status;
pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes; pStream->total_in += (mz_uint)in_bytes;
pStream->adler = tinfl_get_adler32(&pState->m_decomp);
pStream->next_out += (mz_uint)out_bytes; pStream->avail_out -= (mz_uint)out_bytes; pStream->total_out += (mz_uint)out_bytes;
if (status < 0)
return MZ_DATA_ERROR;
else if (status != TINFL_STATUS_DONE)
{
pState->m_last_status = TINFL_STATUS_FAILED;
return MZ_BUF_ERROR;
}
return MZ_STREAM_END;
}
// flush != MZ_FINISH then we must assume there's more input.
if (flush != MZ_FINISH) decomp_flags |= TINFL_FLAG_HAS_MORE_INPUT;
if (pState->m_dict_avail)
{
n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n;
pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
return ((pState->m_last_status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
}
for ( ; ; )
{
in_bytes = pStream->avail_in;
out_bytes = TINFL_LZ_DICT_SIZE - pState->m_dict_ofs;
status = tinfl_decompress(&pState->m_decomp, pStream->next_in, &in_bytes, pState->m_dict, pState->m_dict + pState->m_dict_ofs, &out_bytes, decomp_flags);
pState->m_last_status = status;
pStream->next_in += (mz_uint)in_bytes; pStream->avail_in -= (mz_uint)in_bytes;
pStream->total_in += (mz_uint)in_bytes; pStream->adler = tinfl_get_adler32(&pState->m_decomp);
pState->m_dict_avail = (mz_uint)out_bytes;
n = MZ_MIN(pState->m_dict_avail, pStream->avail_out);
memcpy(pStream->next_out, pState->m_dict + pState->m_dict_ofs, n);
pStream->next_out += n; pStream->avail_out -= n; pStream->total_out += n;
pState->m_dict_avail -= n; pState->m_dict_ofs = (pState->m_dict_ofs + n) & (TINFL_LZ_DICT_SIZE - 1);
if (status < 0)
return MZ_DATA_ERROR; // Stream is corrupted (there could be some uncompressed data left in the output dictionary - oh well).
else if ((status == TINFL_STATUS_NEEDS_MORE_INPUT) && (!orig_avail_in))
return MZ_BUF_ERROR; // Signal caller that we can't make forward progress without supplying more input or by setting flush to MZ_FINISH.
else if (flush == MZ_FINISH)
{
// The output buffer MUST be large to hold the remaining uncompressed data when flush==MZ_FINISH.
if (status == TINFL_STATUS_DONE)
return pState->m_dict_avail ? MZ_BUF_ERROR : MZ_STREAM_END;
// status here must be TINFL_STATUS_HAS_MORE_OUTPUT, which means there's at least 1 more byte on the way. If there's no more room left in the output buffer then something is wrong.
else if (!pStream->avail_out)
return MZ_BUF_ERROR;
}
else if ((status == TINFL_STATUS_DONE) || (!pStream->avail_in) || (!pStream->avail_out) || (pState->m_dict_avail))
break;
}
return ((status == TINFL_STATUS_DONE) && (!pState->m_dict_avail)) ? MZ_STREAM_END : MZ_OK;
}
int mz_inflateEnd(mz_streamp pStream)
{
if (!pStream)
return MZ_STREAM_ERROR;
if (pStream->state)
{
pStream->zfree(pStream->opaque, pStream->state);
pStream->state = NULL;
}
return MZ_OK;
}
int mz_uncompress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len)
{
mz_stream stream;
int status;
memset(&stream, 0, sizeof(stream));
// In case mz_ulong is 64-bits (argh I hate longs).
if ((source_len | *pDest_len) > 0xFFFFFFFFU) return MZ_PARAM_ERROR;
stream.next_in = pSource;
stream.avail_in = (mz_uint32)source_len;
stream.next_out = pDest;
stream.avail_out = (mz_uint32)*pDest_len;
status = mz_inflateInit(&stream);
if (status != MZ_OK)
return status;
status = mz_inflate(&stream, MZ_FINISH);
if (status != MZ_STREAM_END)
{
mz_inflateEnd(&stream);
return ((status == MZ_BUF_ERROR) && (!stream.avail_in)) ? MZ_DATA_ERROR : status;
}
*pDest_len = stream.total_out;
return mz_inflateEnd(&stream);
}
const char *mz_error(int err)
{
static struct { int m_err; const char *m_pDesc; } s_error_descs[] =
{
{ MZ_OK, "" }, { MZ_STREAM_END, "stream end" }, { MZ_NEED_DICT, "need dictionary" }, { MZ_ERRNO, "file error" }, { MZ_STREAM_ERROR, "stream error" },
{ MZ_DATA_ERROR, "data error" }, { MZ_MEM_ERROR, "out of memory" }, { MZ_BUF_ERROR, "buf error" }, { MZ_VERSION_ERROR, "version error" }, { MZ_PARAM_ERROR, "parameter error" }
};
mz_uint i; for (i = 0; i < sizeof(s_error_descs) / sizeof(s_error_descs[0]); ++i) if (s_error_descs[i].m_err == err) return s_error_descs[i].m_pDesc;
return NULL;
}
#endif //MINIZ_NO_ZLIB_APIS
// ------------------- Low-level Decompression (completely independent from all compression API's)
#define TINFL_MEMCPY(d, s, l) memcpy(d, s, l)
#define TINFL_MEMSET(p, c, l) memset(p, c, l)
#define TINFL_CR_BEGIN switch(r->m_state) { case 0:
#define TINFL_CR_RETURN(state_index, result) do { status = result; r->m_state = state_index; goto common_exit; case state_index:; } MZ_MACRO_END
#define TINFL_CR_RETURN_FOREVER(state_index, result) do { for ( ; ; ) { TINFL_CR_RETURN(state_index, result); } } MZ_MACRO_END
#define TINFL_CR_FINISH }
// TODO: If the caller has indicated that there's no more input, and we attempt to read beyond the input buf, then something is wrong with the input because the inflator never
// reads ahead more than it needs to. Currently TINFL_GET_BYTE() pads the end of the stream with 0's in this scenario.
#define TINFL_GET_BYTE(state_index, c) do { \
if (pIn_buf_cur >= pIn_buf_end) { \
for ( ; ; ) { \
if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT) { \
TINFL_CR_RETURN(state_index, TINFL_STATUS_NEEDS_MORE_INPUT); \
if (pIn_buf_cur < pIn_buf_end) { \
c = *pIn_buf_cur++; \
break; \
} \
} else { \
c = 0; \
break; \
} \
} \
} else c = *pIn_buf_cur++; } MZ_MACRO_END
#define TINFL_NEED_BITS(state_index, n) do { mz_uint c; TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; } while (num_bits < (mz_uint)(n))
#define TINFL_SKIP_BITS(state_index, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
#define TINFL_GET_BITS(state_index, b, n) do { if (num_bits < (mz_uint)(n)) { TINFL_NEED_BITS(state_index, n); } b = bit_buf & ((1 << (n)) - 1); bit_buf >>= (n); num_bits -= (n); } MZ_MACRO_END
// TINFL_HUFF_BITBUF_FILL() is only used rarely, when the number of bytes remaining in the input buffer falls below 2.
// It reads just enough bytes from the input stream that are needed to decode the next Huffman code (and absolutely no more). It works by trying to fully decode a
// Huffman code by using whatever bits are currently present in the bit buffer. If this fails, it reads another byte, and tries again until it succeeds or until the
// bit buffer contains >=15 bits (deflate's max. Huffman code size).
#define TINFL_HUFF_BITBUF_FILL(state_index, pHuff) \
do { \
temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]; \
if (temp >= 0) { \
code_len = temp >> 9; \
if ((code_len) && (num_bits >= code_len)) \
break; \
} else if (num_bits > TINFL_FAST_LOOKUP_BITS) { \
code_len = TINFL_FAST_LOOKUP_BITS; \
do { \
temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; \
} while ((temp < 0) && (num_bits >= (code_len + 1))); if (temp >= 0) break; \
} TINFL_GET_BYTE(state_index, c); bit_buf |= (((tinfl_bit_buf_t)c) << num_bits); num_bits += 8; \
} while (num_bits < 15);
// TINFL_HUFF_DECODE() decodes the next Huffman coded symbol. It's more complex than you would initially expect because the zlib API expects the decompressor to never read
// beyond the final byte of the deflate stream. (In other words, when this macro wants to read another byte from the input, it REALLY needs another byte in order to fully
// decode the next Huffman code.) Handling this properly is particularly important on raw deflate (non-zlib) streams, which aren't followed by a byte aligned adler-32.
// The slow path is only executed at the very end of the input buffer.
#define TINFL_HUFF_DECODE(state_index, sym, pHuff) do { \
int temp; mz_uint code_len, c; \
if (num_bits < 15) { \
if ((pIn_buf_end - pIn_buf_cur) < 2) { \
TINFL_HUFF_BITBUF_FILL(state_index, pHuff); \
} else { \
bit_buf |= (((tinfl_bit_buf_t)pIn_buf_cur[0]) << num_bits) | (((tinfl_bit_buf_t)pIn_buf_cur[1]) << (num_bits + 8)); pIn_buf_cur += 2; num_bits += 16; \
} \
} \
if ((temp = (pHuff)->m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0) \
code_len = temp >> 9, temp &= 511; \
else { \
code_len = TINFL_FAST_LOOKUP_BITS; do { temp = (pHuff)->m_tree[~temp + ((bit_buf >> code_len++) & 1)]; } while (temp < 0); \
} sym = temp; bit_buf >>= code_len; num_bits -= code_len; } MZ_MACRO_END
tinfl_status tinfl_decompress(tinfl_decompressor *r, const mz_uint8 *pIn_buf_next, size_t *pIn_buf_size, mz_uint8 *pOut_buf_start, mz_uint8 *pOut_buf_next, size_t *pOut_buf_size, const mz_uint32 decomp_flags)
{
static const int s_length_base[31] = { 3,4,5,6,7,8,9,10,11,13, 15,17,19,23,27,31,35,43,51,59, 67,83,99,115,131,163,195,227,258,0,0 };
static const int s_length_extra[31]= { 0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0 };
static const int s_dist_base[32] = { 1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193, 257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0};
static const int s_dist_extra[32] = { 0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
static const mz_uint8 s_length_dezigzag[19] = { 16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15 };
static const int s_min_table_sizes[3] = { 257, 1, 4 };
tinfl_status status = TINFL_STATUS_FAILED; mz_uint32 num_bits, dist, counter, num_extra; tinfl_bit_buf_t bit_buf;
const mz_uint8 *pIn_buf_cur = pIn_buf_next, *const pIn_buf_end = pIn_buf_next + *pIn_buf_size;
mz_uint8 *pOut_buf_cur = pOut_buf_next, *const pOut_buf_end = pOut_buf_next + *pOut_buf_size;
size_t out_buf_size_mask = (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF) ? (size_t)-1 : ((pOut_buf_next - pOut_buf_start) + *pOut_buf_size) - 1, dist_from_out_buf_start;
// Ensure the output buffer's size is a power of 2, unless the output buffer is large enough to hold the entire output file (in which case it doesn't matter).
if (((out_buf_size_mask + 1) & out_buf_size_mask) || (pOut_buf_next < pOut_buf_start)) { *pIn_buf_size = *pOut_buf_size = 0; return TINFL_STATUS_BAD_PARAM; }
num_bits = r->m_num_bits; bit_buf = r->m_bit_buf; dist = r->m_dist; counter = r->m_counter; num_extra = r->m_num_extra; dist_from_out_buf_start = r->m_dist_from_out_buf_start;
TINFL_CR_BEGIN
bit_buf = num_bits = dist = counter = num_extra = r->m_zhdr0 = r->m_zhdr1 = 0; r->m_z_adler32 = r->m_check_adler32 = 1;
if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER)
{
TINFL_GET_BYTE(1, r->m_zhdr0); TINFL_GET_BYTE(2, r->m_zhdr1);
counter = (((r->m_zhdr0 * 256 + r->m_zhdr1) % 31 != 0) || (r->m_zhdr1 & 32) || ((r->m_zhdr0 & 15) != 8));
if (!(decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)) counter |= (((1U << (8U + (r->m_zhdr0 >> 4))) > 32768U) || ((out_buf_size_mask + 1) < (size_t)(1U << (8U + (r->m_zhdr0 >> 4)))));
if (counter) { TINFL_CR_RETURN_FOREVER(36, TINFL_STATUS_FAILED); }
}
do
{
TINFL_GET_BITS(3, r->m_final, 3); r->m_type = r->m_final >> 1;
if (r->m_type == 0)
{
TINFL_SKIP_BITS(5, num_bits & 7);
for (counter = 0; counter < 4; ++counter) { if (num_bits) TINFL_GET_BITS(6, r->m_raw_header[counter], 8); else TINFL_GET_BYTE(7, r->m_raw_header[counter]); }
if ((counter = (r->m_raw_header[0] | (r->m_raw_header[1] << 8))) != (mz_uint)(0xFFFF ^ (r->m_raw_header[2] | (r->m_raw_header[3] << 8)))) { TINFL_CR_RETURN_FOREVER(39, TINFL_STATUS_FAILED); }
while ((counter) && (num_bits))
{
TINFL_GET_BITS(51, dist, 8);
while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(52, TINFL_STATUS_HAS_MORE_OUTPUT); }
*pOut_buf_cur++ = (mz_uint8)dist;
counter--;
}
while (counter)
{
size_t n; while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(9, TINFL_STATUS_HAS_MORE_OUTPUT); }
while (pIn_buf_cur >= pIn_buf_end)
{
if (decomp_flags & TINFL_FLAG_HAS_MORE_INPUT)
{
TINFL_CR_RETURN(38, TINFL_STATUS_NEEDS_MORE_INPUT);
}
else
{
TINFL_CR_RETURN_FOREVER(40, TINFL_STATUS_FAILED);
}
}
n = MZ_MIN(MZ_MIN((size_t)(pOut_buf_end - pOut_buf_cur), (size_t)(pIn_buf_end - pIn_buf_cur)), counter);
TINFL_MEMCPY(pOut_buf_cur, pIn_buf_cur, n); pIn_buf_cur += n; pOut_buf_cur += n; counter -= (mz_uint)n;
}
}
else if (r->m_type == 3)
{
TINFL_CR_RETURN_FOREVER(10, TINFL_STATUS_FAILED);
}
else
{
if (r->m_type == 1)
{
mz_uint8 *p = r->m_tables[0].m_code_size; mz_uint i;
r->m_table_sizes[0] = 288; r->m_table_sizes[1] = 32; TINFL_MEMSET(r->m_tables[1].m_code_size, 5, 32);
for ( i = 0; i <= 143; ++i) *p++ = 8; for ( ; i <= 255; ++i) *p++ = 9; for ( ; i <= 279; ++i) *p++ = 7; for ( ; i <= 287; ++i) *p++ = 8;
}
else
{
for (counter = 0; counter < 3; counter++) { TINFL_GET_BITS(11, r->m_table_sizes[counter], "\05\05\04"[counter]); r->m_table_sizes[counter] += s_min_table_sizes[counter]; }
MZ_CLEAR_OBJ(r->m_tables[2].m_code_size); for (counter = 0; counter < r->m_table_sizes[2]; counter++) { mz_uint s; TINFL_GET_BITS(14, s, 3); r->m_tables[2].m_code_size[s_length_dezigzag[counter]] = (mz_uint8)s; }
r->m_table_sizes[2] = 19;
}
for ( ; (int)r->m_type >= 0; r->m_type--)
{
int tree_next, tree_cur; tinfl_huff_table *pTable;
mz_uint i, j, used_syms, total, sym_index, next_code[17], total_syms[16]; pTable = &r->m_tables[r->m_type]; MZ_CLEAR_OBJ(total_syms); MZ_CLEAR_OBJ(pTable->m_look_up); MZ_CLEAR_OBJ(pTable->m_tree);
for (i = 0; i < r->m_table_sizes[r->m_type]; ++i) total_syms[pTable->m_code_size[i]]++;
used_syms = 0, total = 0; next_code[0] = next_code[1] = 0;
for (i = 1; i <= 15; ++i) { used_syms += total_syms[i]; next_code[i + 1] = (total = ((total + total_syms[i]) << 1)); }
if ((65536 != total) && (used_syms > 1))
{
TINFL_CR_RETURN_FOREVER(35, TINFL_STATUS_FAILED);
}
for (tree_next = -1, sym_index = 0; sym_index < r->m_table_sizes[r->m_type]; ++sym_index)
{
mz_uint rev_code = 0, l, cur_code, code_size = pTable->m_code_size[sym_index]; if (!code_size) continue;
cur_code = next_code[code_size]++; for (l = code_size; l > 0; l--, cur_code >>= 1) rev_code = (rev_code << 1) | (cur_code & 1);
if (code_size <= TINFL_FAST_LOOKUP_BITS) { mz_int16 k = (mz_int16)((code_size << 9) | sym_index); while (rev_code < TINFL_FAST_LOOKUP_SIZE) { pTable->m_look_up[rev_code] = k; rev_code += (1 << code_size); } continue; }
if (0 == (tree_cur = pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)])) { pTable->m_look_up[rev_code & (TINFL_FAST_LOOKUP_SIZE - 1)] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; }
rev_code >>= (TINFL_FAST_LOOKUP_BITS - 1);
for (j = code_size; j > (TINFL_FAST_LOOKUP_BITS + 1); j--)
{
tree_cur -= ((rev_code >>= 1) & 1);
if (!pTable->m_tree[-tree_cur - 1]) { pTable->m_tree[-tree_cur - 1] = (mz_int16)tree_next; tree_cur = tree_next; tree_next -= 2; } else tree_cur = pTable->m_tree[-tree_cur - 1];
}
tree_cur -= ((rev_code >>= 1) & 1); pTable->m_tree[-tree_cur - 1] = (mz_int16)sym_index;
}
if (r->m_type == 2)
{
for (counter = 0; counter < (r->m_table_sizes[0] + r->m_table_sizes[1]); )
{
mz_uint s; TINFL_HUFF_DECODE(16, dist, &r->m_tables[2]); if (dist < 16) { r->m_len_codes[counter++] = (mz_uint8)dist; continue; }
if ((dist == 16) && (!counter))
{
TINFL_CR_RETURN_FOREVER(17, TINFL_STATUS_FAILED);
}
num_extra = "\02\03\07"[dist - 16]; TINFL_GET_BITS(18, s, num_extra); s += "\03\03\013"[dist - 16];
TINFL_MEMSET(r->m_len_codes + counter, (dist == 16) ? r->m_len_codes[counter - 1] : 0, s); counter += s;
}
if ((r->m_table_sizes[0] + r->m_table_sizes[1]) != counter)
{
TINFL_CR_RETURN_FOREVER(21, TINFL_STATUS_FAILED);
}
TINFL_MEMCPY(r->m_tables[0].m_code_size, r->m_len_codes, r->m_table_sizes[0]); TINFL_MEMCPY(r->m_tables[1].m_code_size, r->m_len_codes + r->m_table_sizes[0], r->m_table_sizes[1]);
}
}
for ( ; ; )
{
mz_uint8 *pSrc;
for ( ; ; )
{
if (((pIn_buf_end - pIn_buf_cur) < 4) || ((pOut_buf_end - pOut_buf_cur) < 2))
{
TINFL_HUFF_DECODE(23, counter, &r->m_tables[0]);
if (counter >= 256)
break;
while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(24, TINFL_STATUS_HAS_MORE_OUTPUT); }
*pOut_buf_cur++ = (mz_uint8)counter;
}
else
{
int sym2; mz_uint code_len;
#if TINFL_USE_64BIT_BITBUF
if (num_bits < 30) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE32(pIn_buf_cur)) << num_bits); pIn_buf_cur += 4; num_bits += 32; }
#else
if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; }
#endif
if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0)
code_len = sym2 >> 9;
else
{
code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0);
}
counter = sym2; bit_buf >>= code_len; num_bits -= code_len;
if (counter & 256)
break;
#if !TINFL_USE_64BIT_BITBUF
if (num_bits < 15) { bit_buf |= (((tinfl_bit_buf_t)MZ_READ_LE16(pIn_buf_cur)) << num_bits); pIn_buf_cur += 2; num_bits += 16; }
#endif
if ((sym2 = r->m_tables[0].m_look_up[bit_buf & (TINFL_FAST_LOOKUP_SIZE - 1)]) >= 0)
code_len = sym2 >> 9;
else
{
code_len = TINFL_FAST_LOOKUP_BITS; do { sym2 = r->m_tables[0].m_tree[~sym2 + ((bit_buf >> code_len++) & 1)]; } while (sym2 < 0);
}
bit_buf >>= code_len; num_bits -= code_len;
pOut_buf_cur[0] = (mz_uint8)counter;
if (sym2 & 256)
{
pOut_buf_cur++;
counter = sym2;
break;
}
pOut_buf_cur[1] = (mz_uint8)sym2;
pOut_buf_cur += 2;
}
}
if ((counter &= 511) == 256) break;
num_extra = s_length_extra[counter - 257]; counter = s_length_base[counter - 257];
if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(25, extra_bits, num_extra); counter += extra_bits; }
TINFL_HUFF_DECODE(26, dist, &r->m_tables[1]);
num_extra = s_dist_extra[dist]; dist = s_dist_base[dist];
if (num_extra) { mz_uint extra_bits; TINFL_GET_BITS(27, extra_bits, num_extra); dist += extra_bits; }
dist_from_out_buf_start = pOut_buf_cur - pOut_buf_start;
if ((dist > dist_from_out_buf_start) && (decomp_flags & TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF))
{
TINFL_CR_RETURN_FOREVER(37, TINFL_STATUS_FAILED);
}
pSrc = pOut_buf_start + ((dist_from_out_buf_start - dist) & out_buf_size_mask);
if ((MZ_MAX(pOut_buf_cur, pSrc) + counter) > pOut_buf_end)
{
while (counter--)
{
while (pOut_buf_cur >= pOut_buf_end) { TINFL_CR_RETURN(53, TINFL_STATUS_HAS_MORE_OUTPUT); }
*pOut_buf_cur++ = pOut_buf_start[(dist_from_out_buf_start++ - dist) & out_buf_size_mask];
}
continue;
}
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
else if ((counter >= 9) && (counter <= dist))
{
const mz_uint8 *pSrc_end = pSrc + (counter & ~7);
do
{
((mz_uint32 *)pOut_buf_cur)[0] = ((const mz_uint32 *)pSrc)[0];
((mz_uint32 *)pOut_buf_cur)[1] = ((const mz_uint32 *)pSrc)[1];
pOut_buf_cur += 8;
} while ((pSrc += 8) < pSrc_end);
if ((counter &= 7) < 3)
{
if (counter)
{
pOut_buf_cur[0] = pSrc[0];
if (counter > 1)
pOut_buf_cur[1] = pSrc[1];
pOut_buf_cur += counter;
}
continue;
}
}
#endif
do
{
pOut_buf_cur[0] = pSrc[0];
pOut_buf_cur[1] = pSrc[1];
pOut_buf_cur[2] = pSrc[2];
pOut_buf_cur += 3; pSrc += 3;
} while ((int)(counter -= 3) > 2);
if ((int)counter > 0)
{
pOut_buf_cur[0] = pSrc[0];
if ((int)counter > 1)
pOut_buf_cur[1] = pSrc[1];
pOut_buf_cur += counter;
}
}
}
} while (!(r->m_final & 1));
if (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER)
{
TINFL_SKIP_BITS(32, num_bits & 7); for (counter = 0; counter < 4; ++counter) { mz_uint s; if (num_bits) TINFL_GET_BITS(41, s, 8); else TINFL_GET_BYTE(42, s); r->m_z_adler32 = (r->m_z_adler32 << 8) | s; }
}
TINFL_CR_RETURN_FOREVER(34, TINFL_STATUS_DONE);
TINFL_CR_FINISH
common_exit:
r->m_num_bits = num_bits; r->m_bit_buf = bit_buf; r->m_dist = dist; r->m_counter = counter; r->m_num_extra = num_extra; r->m_dist_from_out_buf_start = dist_from_out_buf_start;
*pIn_buf_size = pIn_buf_cur - pIn_buf_next; *pOut_buf_size = pOut_buf_cur - pOut_buf_next;
if ((decomp_flags & (TINFL_FLAG_PARSE_ZLIB_HEADER | TINFL_FLAG_COMPUTE_ADLER32)) && (status >= 0))
{
const mz_uint8 *ptr = pOut_buf_next; size_t buf_len = *pOut_buf_size;
mz_uint32 i, s1 = r->m_check_adler32 & 0xffff, s2 = r->m_check_adler32 >> 16; size_t block_len = buf_len % 5552;
while (buf_len)
{
for (i = 0; i + 7 < block_len; i += 8, ptr += 8)
{
s1 += ptr[0], s2 += s1; s1 += ptr[1], s2 += s1; s1 += ptr[2], s2 += s1; s1 += ptr[3], s2 += s1;
s1 += ptr[4], s2 += s1; s1 += ptr[5], s2 += s1; s1 += ptr[6], s2 += s1; s1 += ptr[7], s2 += s1;
}
for ( ; i < block_len; ++i) s1 += *ptr++, s2 += s1;
s1 %= 65521U, s2 %= 65521U; buf_len -= block_len; block_len = 5552;
}
r->m_check_adler32 = (s2 << 16) + s1; if ((status == TINFL_STATUS_DONE) && (decomp_flags & TINFL_FLAG_PARSE_ZLIB_HEADER) && (r->m_check_adler32 != r->m_z_adler32)) status = TINFL_STATUS_ADLER32_MISMATCH;
}
return status;
}
// Higher level helper functions.
void *tinfl_decompress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
{
tinfl_decompressor decomp; void *pBuf = NULL, *pNew_buf; size_t src_buf_ofs = 0, out_buf_capacity = 0;
*pOut_len = 0;
tinfl_init(&decomp);
for ( ; ; )
{
size_t src_buf_size = src_buf_len - src_buf_ofs, dst_buf_size = out_buf_capacity - *pOut_len, new_out_buf_capacity;
tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf + src_buf_ofs, &src_buf_size, (mz_uint8*)pBuf, pBuf ? (mz_uint8*)pBuf + *pOut_len : NULL, &dst_buf_size,
(flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);
if ((status < 0) || (status == TINFL_STATUS_NEEDS_MORE_INPUT))
{
MZ_FREE(pBuf); *pOut_len = 0; return NULL;
}
src_buf_ofs += src_buf_size;
*pOut_len += dst_buf_size;
if (status == TINFL_STATUS_DONE) break;
new_out_buf_capacity = out_buf_capacity * 2; if (new_out_buf_capacity < 128) new_out_buf_capacity = 128;
pNew_buf = MZ_REALLOC(pBuf, new_out_buf_capacity);
if (!pNew_buf)
{
MZ_FREE(pBuf); *pOut_len = 0; return NULL;
}
pBuf = pNew_buf; out_buf_capacity = new_out_buf_capacity;
}
return pBuf;
}
size_t tinfl_decompress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
{
tinfl_decompressor decomp; tinfl_status status; tinfl_init(&decomp);
status = tinfl_decompress(&decomp, (const mz_uint8*)pSrc_buf, &src_buf_len, (mz_uint8*)pOut_buf, (mz_uint8*)pOut_buf, &out_buf_len, (flags & ~TINFL_FLAG_HAS_MORE_INPUT) | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF);
return (status != TINFL_STATUS_DONE) ? TINFL_DECOMPRESS_MEM_TO_MEM_FAILED : out_buf_len;
}
int tinfl_decompress_mem_to_callback(const void *pIn_buf, size_t *pIn_buf_size, tinfl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
{
int result = 0;
tinfl_decompressor decomp;
mz_uint8 *pDict = (mz_uint8*)MZ_MALLOC(TINFL_LZ_DICT_SIZE); size_t in_buf_ofs = 0, dict_ofs = 0;
if (!pDict)
return TINFL_STATUS_FAILED;
tinfl_init(&decomp);
for ( ; ; )
{
size_t in_buf_size = *pIn_buf_size - in_buf_ofs, dst_buf_size = TINFL_LZ_DICT_SIZE - dict_ofs;
tinfl_status status = tinfl_decompress(&decomp, (const mz_uint8*)pIn_buf + in_buf_ofs, &in_buf_size, pDict, pDict + dict_ofs, &dst_buf_size,
(flags & ~(TINFL_FLAG_HAS_MORE_INPUT | TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF)));
in_buf_ofs += in_buf_size;
if ((dst_buf_size) && (!(*pPut_buf_func)(pDict + dict_ofs, (int)dst_buf_size, pPut_buf_user)))
break;
if (status != TINFL_STATUS_HAS_MORE_OUTPUT)
{
result = (status == TINFL_STATUS_DONE);
break;
}
dict_ofs = (dict_ofs + dst_buf_size) & (TINFL_LZ_DICT_SIZE - 1);
}
MZ_FREE(pDict);
*pIn_buf_size = in_buf_ofs;
return result;
}
// ------------------- Low-level Compression (independent from all decompression API's)
// Purposely making these tables static for faster init and thread safety.
static const mz_uint16 s_tdefl_len_sym[256] = {
257,258,259,260,261,262,263,264,265,265,266,266,267,267,268,268,269,269,269,269,270,270,270,270,271,271,271,271,272,272,272,272,
273,273,273,273,273,273,273,273,274,274,274,274,274,274,274,274,275,275,275,275,275,275,275,275,276,276,276,276,276,276,276,276,
277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,277,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,278,
279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,279,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,280,
281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,281,
282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,282,
283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,283,
284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,284,285 };
static const mz_uint8 s_tdefl_len_extra[256] = {
0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,
4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,0 };
static const mz_uint8 s_tdefl_small_dist_sym[512] = {
0,1,2,3,4,4,5,5,6,6,6,6,7,7,7,7,8,8,8,8,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,11,11,11,11,11,11,
11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
14,14,14,14,14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17 };
static const mz_uint8 s_tdefl_small_dist_extra[512] = {
0,0,0,0,1,1,1,1,2,2,2,2,2,2,2,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,
5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
7,7,7,7,7,7,7,7 };
static const mz_uint8 s_tdefl_large_dist_sym[128] = {
0,0,18,19,20,20,21,21,22,22,22,22,23,23,23,23,24,24,24,24,24,24,24,24,25,25,25,25,25,25,25,25,26,26,26,26,26,26,26,26,26,26,26,26,
26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
28,28,28,28,28,28,28,28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29 };
static const mz_uint8 s_tdefl_large_dist_extra[128] = {
0,0,8,8,9,9,9,9,10,10,10,10,10,10,10,10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,
13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13 };
// Radix sorts tdefl_sym_freq[] array by 16-bit key m_key. Returns ptr to sorted values.
typedef struct { mz_uint16 m_key, m_sym_index; } tdefl_sym_freq;
static tdefl_sym_freq* tdefl_radix_sort_syms(mz_uint num_syms, tdefl_sym_freq* pSyms0, tdefl_sym_freq* pSyms1)
{
mz_uint32 total_passes = 2, pass_shift, pass, i, hist[256 * 2]; tdefl_sym_freq* pCur_syms = pSyms0, *pNew_syms = pSyms1; MZ_CLEAR_OBJ(hist);
for (i = 0; i < num_syms; i++) { mz_uint freq = pSyms0[i].m_key; hist[freq & 0xFF]++; hist[256 + ((freq >> 8) & 0xFF)]++; }
while ((total_passes > 1) && (num_syms == hist[(total_passes - 1) * 256])) total_passes--;
for (pass_shift = 0, pass = 0; pass < total_passes; pass++, pass_shift += 8)
{
const mz_uint32* pHist = &hist[pass << 8];
mz_uint offsets[256], cur_ofs = 0;
for (i = 0; i < 256; i++) { offsets[i] = cur_ofs; cur_ofs += pHist[i]; }
for (i = 0; i < num_syms; i++) pNew_syms[offsets[(pCur_syms[i].m_key >> pass_shift) & 0xFF]++] = pCur_syms[i];
{ tdefl_sym_freq* t = pCur_syms; pCur_syms = pNew_syms; pNew_syms = t; }
}
return pCur_syms;
}
// tdefl_calculate_minimum_redundancy() originally written by: Alistair Moffat, alistair@cs.mu.oz.au, Jyrki Katajainen, jyrki@diku.dk, November 1996.
static void tdefl_calculate_minimum_redundancy(tdefl_sym_freq *A, int n)
{
int root, leaf, next, avbl, used, dpth;
if (n==0) return; else if (n==1) { A[0].m_key = 1; return; }
A[0].m_key += A[1].m_key; root = 0; leaf = 2;
for (next=1; next < n-1; next++)
{
if (leaf>=n || A[root].m_key<A[leaf].m_key) { A[next].m_key = A[root].m_key; A[root++].m_key = (mz_uint16)next; } else A[next].m_key = A[leaf++].m_key;
if (leaf>=n || (root<next && A[root].m_key<A[leaf].m_key)) { A[next].m_key = (mz_uint16)(A[next].m_key + A[root].m_key); A[root++].m_key = (mz_uint16)next; } else A[next].m_key = (mz_uint16)(A[next].m_key + A[leaf++].m_key);
}
A[n-2].m_key = 0; for (next=n-3; next>=0; next--) A[next].m_key = A[A[next].m_key].m_key+1;
avbl = 1; used = dpth = 0; root = n-2; next = n-1;
while (avbl>0)
{
while (root>=0 && (int)A[root].m_key==dpth) { used++; root--; }
while (avbl>used) { A[next--].m_key = (mz_uint16)(dpth); avbl--; }
avbl = 2*used; dpth++; used = 0;
}
}
// Limits canonical Huffman code table's max code size.
enum { TDEFL_MAX_SUPPORTED_HUFF_CODESIZE = 32 };
static void tdefl_huffman_enforce_max_code_size(int *pNum_codes, int code_list_len, int max_code_size)
{
int i; mz_uint32 total = 0; if (code_list_len <= 1) return;
for (i = max_code_size + 1; i <= TDEFL_MAX_SUPPORTED_HUFF_CODESIZE; i++) pNum_codes[max_code_size] += pNum_codes[i];
for (i = max_code_size; i > 0; i--) total += (((mz_uint32)pNum_codes[i]) << (max_code_size - i));
while (total != (1UL << max_code_size))
{
pNum_codes[max_code_size]--;
for (i = max_code_size - 1; i > 0; i--) if (pNum_codes[i]) { pNum_codes[i]--; pNum_codes[i + 1] += 2; break; }
total--;
}
}
static void tdefl_optimize_huffman_table(tdefl_compressor *d, int table_num, int table_len, int code_size_limit, int static_table)
{
int i, j, l, num_codes[1 + TDEFL_MAX_SUPPORTED_HUFF_CODESIZE]; mz_uint next_code[TDEFL_MAX_SUPPORTED_HUFF_CODESIZE + 1]; MZ_CLEAR_OBJ(num_codes);
if (static_table)
{
for (i = 0; i < table_len; i++) num_codes[d->m_huff_code_sizes[table_num][i]]++;
}
else
{
tdefl_sym_freq syms0[TDEFL_MAX_HUFF_SYMBOLS], syms1[TDEFL_MAX_HUFF_SYMBOLS], *pSyms;
int num_used_syms = 0;
const mz_uint16 *pSym_count = &d->m_huff_count[table_num][0];
for (i = 0; i < table_len; i++) if (pSym_count[i]) { syms0[num_used_syms].m_key = (mz_uint16)pSym_count[i]; syms0[num_used_syms++].m_sym_index = (mz_uint16)i; }
pSyms = tdefl_radix_sort_syms(num_used_syms, syms0, syms1); tdefl_calculate_minimum_redundancy(pSyms, num_used_syms);
for (i = 0; i < num_used_syms; i++) num_codes[pSyms[i].m_key]++;
tdefl_huffman_enforce_max_code_size(num_codes, num_used_syms, code_size_limit);
MZ_CLEAR_OBJ(d->m_huff_code_sizes[table_num]); MZ_CLEAR_OBJ(d->m_huff_codes[table_num]);
for (i = 1, j = num_used_syms; i <= code_size_limit; i++)
for (l = num_codes[i]; l > 0; l--) d->m_huff_code_sizes[table_num][pSyms[--j].m_sym_index] = (mz_uint8)(i);
}
next_code[1] = 0; for (j = 0, i = 2; i <= code_size_limit; i++) next_code[i] = j = ((j + num_codes[i - 1]) << 1);
for (i = 0; i < table_len; i++)
{
mz_uint rev_code = 0, code, code_size; if ((code_size = d->m_huff_code_sizes[table_num][i]) == 0) continue;
code = next_code[code_size]++; for (l = code_size; l > 0; l--, code >>= 1) rev_code = (rev_code << 1) | (code & 1);
d->m_huff_codes[table_num][i] = (mz_uint16)rev_code;
}
}
#define TDEFL_PUT_BITS(b, l) do { \
mz_uint bits = b; mz_uint len = l; MZ_ASSERT(bits <= ((1U << len) - 1U)); \
d->m_bit_buffer |= (bits << d->m_bits_in); d->m_bits_in += len; \
while (d->m_bits_in >= 8) { \
if (d->m_pOutput_buf < d->m_pOutput_buf_end) \
*d->m_pOutput_buf++ = (mz_uint8)(d->m_bit_buffer); \
d->m_bit_buffer >>= 8; \
d->m_bits_in -= 8; \
} \
} MZ_MACRO_END
#define TDEFL_RLE_PREV_CODE_SIZE() { if (rle_repeat_count) { \
if (rle_repeat_count < 3) { \
d->m_huff_count[2][prev_code_size] = (mz_uint16)(d->m_huff_count[2][prev_code_size] + rle_repeat_count); \
while (rle_repeat_count--) packed_code_sizes[num_packed_code_sizes++] = prev_code_size; \
} else { \
d->m_huff_count[2][16] = (mz_uint16)(d->m_huff_count[2][16] + 1); packed_code_sizes[num_packed_code_sizes++] = 16; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_repeat_count - 3); \
} rle_repeat_count = 0; } }
#define TDEFL_RLE_ZERO_CODE_SIZE() { if (rle_z_count) { \
if (rle_z_count < 3) { \
d->m_huff_count[2][0] = (mz_uint16)(d->m_huff_count[2][0] + rle_z_count); while (rle_z_count--) packed_code_sizes[num_packed_code_sizes++] = 0; \
} else if (rle_z_count <= 10) { \
d->m_huff_count[2][17] = (mz_uint16)(d->m_huff_count[2][17] + 1); packed_code_sizes[num_packed_code_sizes++] = 17; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 3); \
} else { \
d->m_huff_count[2][18] = (mz_uint16)(d->m_huff_count[2][18] + 1); packed_code_sizes[num_packed_code_sizes++] = 18; packed_code_sizes[num_packed_code_sizes++] = (mz_uint8)(rle_z_count - 11); \
} rle_z_count = 0; } }
static mz_uint8 s_tdefl_packed_code_size_syms_swizzle[] = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 };
static void tdefl_start_dynamic_block(tdefl_compressor *d)
{
int num_lit_codes, num_dist_codes, num_bit_lengths; mz_uint i, total_code_sizes_to_pack, num_packed_code_sizes, rle_z_count, rle_repeat_count, packed_code_sizes_index;
mz_uint8 code_sizes_to_pack[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], packed_code_sizes[TDEFL_MAX_HUFF_SYMBOLS_0 + TDEFL_MAX_HUFF_SYMBOLS_1], prev_code_size = 0xFF;
d->m_huff_count[0][256] = 1;
tdefl_optimize_huffman_table(d, 0, TDEFL_MAX_HUFF_SYMBOLS_0, 15, MZ_FALSE);
tdefl_optimize_huffman_table(d, 1, TDEFL_MAX_HUFF_SYMBOLS_1, 15, MZ_FALSE);
for (num_lit_codes = 286; num_lit_codes > 257; num_lit_codes--) if (d->m_huff_code_sizes[0][num_lit_codes - 1]) break;
for (num_dist_codes = 30; num_dist_codes > 1; num_dist_codes--) if (d->m_huff_code_sizes[1][num_dist_codes - 1]) break;
memcpy(code_sizes_to_pack, &d->m_huff_code_sizes[0][0], num_lit_codes);
memcpy(code_sizes_to_pack + num_lit_codes, &d->m_huff_code_sizes[1][0], num_dist_codes);
total_code_sizes_to_pack = num_lit_codes + num_dist_codes; num_packed_code_sizes = 0; rle_z_count = 0; rle_repeat_count = 0;
memset(&d->m_huff_count[2][0], 0, sizeof(d->m_huff_count[2][0]) * TDEFL_MAX_HUFF_SYMBOLS_2);
for (i = 0; i < total_code_sizes_to_pack; i++)
{
mz_uint8 code_size = code_sizes_to_pack[i];
if (!code_size)
{
TDEFL_RLE_PREV_CODE_SIZE();
if (++rle_z_count == 138) { TDEFL_RLE_ZERO_CODE_SIZE(); }
}
else
{
TDEFL_RLE_ZERO_CODE_SIZE();
if (code_size != prev_code_size)
{
TDEFL_RLE_PREV_CODE_SIZE();
d->m_huff_count[2][code_size] = (mz_uint16)(d->m_huff_count[2][code_size] + 1); packed_code_sizes[num_packed_code_sizes++] = code_size;
}
else if (++rle_repeat_count == 6)
{
TDEFL_RLE_PREV_CODE_SIZE();
}
}
prev_code_size = code_size;
}
if (rle_repeat_count) { TDEFL_RLE_PREV_CODE_SIZE(); } else { TDEFL_RLE_ZERO_CODE_SIZE(); }
tdefl_optimize_huffman_table(d, 2, TDEFL_MAX_HUFF_SYMBOLS_2, 7, MZ_FALSE);
TDEFL_PUT_BITS(2, 2);
TDEFL_PUT_BITS(num_lit_codes - 257, 5);
TDEFL_PUT_BITS(num_dist_codes - 1, 5);
for (num_bit_lengths = 18; num_bit_lengths >= 0; num_bit_lengths--) if (d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[num_bit_lengths]]) break;
num_bit_lengths = MZ_MAX(4, (num_bit_lengths + 1)); TDEFL_PUT_BITS(num_bit_lengths - 4, 4);
for (i = 0; (int)i < num_bit_lengths; i++) TDEFL_PUT_BITS(d->m_huff_code_sizes[2][s_tdefl_packed_code_size_syms_swizzle[i]], 3);
for (packed_code_sizes_index = 0; packed_code_sizes_index < num_packed_code_sizes; )
{
mz_uint code = packed_code_sizes[packed_code_sizes_index++]; MZ_ASSERT(code < TDEFL_MAX_HUFF_SYMBOLS_2);
TDEFL_PUT_BITS(d->m_huff_codes[2][code], d->m_huff_code_sizes[2][code]);
if (code >= 16) TDEFL_PUT_BITS(packed_code_sizes[packed_code_sizes_index++], "\02\03\07"[code - 16]);
}
}
static void tdefl_start_static_block(tdefl_compressor *d)
{
mz_uint i;
mz_uint8 *p = &d->m_huff_code_sizes[0][0];
for (i = 0; i <= 143; ++i) *p++ = 8;
for ( ; i <= 255; ++i) *p++ = 9;
for ( ; i <= 279; ++i) *p++ = 7;
for ( ; i <= 287; ++i) *p++ = 8;
memset(d->m_huff_code_sizes[1], 5, 32);
tdefl_optimize_huffman_table(d, 0, 288, 15, MZ_TRUE);
tdefl_optimize_huffman_table(d, 1, 32, 15, MZ_TRUE);
TDEFL_PUT_BITS(1, 2);
}
static const mz_uint mz_bitmasks[17] = { 0x0000, 0x0001, 0x0003, 0x0007, 0x000F, 0x001F, 0x003F, 0x007F, 0x00FF, 0x01FF, 0x03FF, 0x07FF, 0x0FFF, 0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF };
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
{
mz_uint flags;
mz_uint8 *pLZ_codes;
mz_uint8 *pOutput_buf = d->m_pOutput_buf;
mz_uint8 *pLZ_code_buf_end = d->m_pLZ_code_buf;
mz_uint64 bit_buffer = d->m_bit_buffer;
mz_uint bits_in = d->m_bits_in;
#define TDEFL_PUT_BITS_FAST(b, l) { bit_buffer |= (((mz_uint64)(b)) << bits_in); bits_in += (l); }
flags = 1;
for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < pLZ_code_buf_end; flags >>= 1)
{
if (flags == 1)
flags = *pLZ_codes++ | 0x100;
if (flags & 1)
{
mz_uint s0, s1, n0, n1, sym, num_extra_bits;
mz_uint match_len = pLZ_codes[0], match_dist = *(const mz_uint16 *)(pLZ_codes + 1); pLZ_codes += 3;
MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS_FAST(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
// This sequence coaxes MSVC into using cmov's vs. jmp's.
s0 = s_tdefl_small_dist_sym[match_dist & 511];
n0 = s_tdefl_small_dist_extra[match_dist & 511];
s1 = s_tdefl_large_dist_sym[match_dist >> 8];
n1 = s_tdefl_large_dist_extra[match_dist >> 8];
sym = (match_dist < 512) ? s0 : s1;
num_extra_bits = (match_dist < 512) ? n0 : n1;
MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS_FAST(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
}
else
{
mz_uint lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
{
flags >>= 1;
lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
if (((flags & 2) == 0) && (pLZ_codes < pLZ_code_buf_end))
{
flags >>= 1;
lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS_FAST(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
}
}
}
if (pOutput_buf >= d->m_pOutput_buf_end)
return MZ_FALSE;
*(mz_uint64*)pOutput_buf = bit_buffer;
pOutput_buf += (bits_in >> 3);
bit_buffer >>= (bits_in & ~7);
bits_in &= 7;
}
#undef TDEFL_PUT_BITS_FAST
d->m_pOutput_buf = pOutput_buf;
d->m_bits_in = 0;
d->m_bit_buffer = 0;
while (bits_in)
{
mz_uint32 n = MZ_MIN(bits_in, 16);
TDEFL_PUT_BITS((mz_uint)bit_buffer & mz_bitmasks[n], n);
bit_buffer >>= n;
bits_in -= n;
}
TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);
return (d->m_pOutput_buf < d->m_pOutput_buf_end);
}
#else
static mz_bool tdefl_compress_lz_codes(tdefl_compressor *d)
{
mz_uint flags;
mz_uint8 *pLZ_codes;
flags = 1;
for (pLZ_codes = d->m_lz_code_buf; pLZ_codes < d->m_pLZ_code_buf; flags >>= 1)
{
if (flags == 1)
flags = *pLZ_codes++ | 0x100;
if (flags & 1)
{
mz_uint sym, num_extra_bits;
mz_uint match_len = pLZ_codes[0], match_dist = (pLZ_codes[1] | (pLZ_codes[2] << 8)); pLZ_codes += 3;
MZ_ASSERT(d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS(d->m_huff_codes[0][s_tdefl_len_sym[match_len]], d->m_huff_code_sizes[0][s_tdefl_len_sym[match_len]]);
TDEFL_PUT_BITS(match_len & mz_bitmasks[s_tdefl_len_extra[match_len]], s_tdefl_len_extra[match_len]);
if (match_dist < 512)
{
sym = s_tdefl_small_dist_sym[match_dist]; num_extra_bits = s_tdefl_small_dist_extra[match_dist];
}
else
{
sym = s_tdefl_large_dist_sym[match_dist >> 8]; num_extra_bits = s_tdefl_large_dist_extra[match_dist >> 8];
}
MZ_ASSERT(d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS(d->m_huff_codes[1][sym], d->m_huff_code_sizes[1][sym]);
TDEFL_PUT_BITS(match_dist & mz_bitmasks[num_extra_bits], num_extra_bits);
}
else
{
mz_uint lit = *pLZ_codes++;
MZ_ASSERT(d->m_huff_code_sizes[0][lit]);
TDEFL_PUT_BITS(d->m_huff_codes[0][lit], d->m_huff_code_sizes[0][lit]);
}
}
TDEFL_PUT_BITS(d->m_huff_codes[0][256], d->m_huff_code_sizes[0][256]);
return (d->m_pOutput_buf < d->m_pOutput_buf_end);
}
#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN && MINIZ_HAS_64BIT_REGISTERS
static mz_bool tdefl_compress_block(tdefl_compressor *d, mz_bool static_block)
{
if (static_block)
tdefl_start_static_block(d);
else
tdefl_start_dynamic_block(d);
return tdefl_compress_lz_codes(d);
}
static int tdefl_flush_block(tdefl_compressor *d, int flush)
{
mz_uint saved_bit_buf, saved_bits_in;
mz_uint8 *pSaved_output_buf;
mz_bool comp_block_succeeded = MZ_FALSE;
int n, use_raw_block = ((d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS) != 0) && (d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size;
mz_uint8 *pOutput_buf_start = ((d->m_pPut_buf_func == NULL) && ((*d->m_pOut_buf_size - d->m_out_buf_ofs) >= TDEFL_OUT_BUF_SIZE)) ? ((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs) : d->m_output_buf;
d->m_pOutput_buf = pOutput_buf_start;
d->m_pOutput_buf_end = d->m_pOutput_buf + TDEFL_OUT_BUF_SIZE - 16;
MZ_ASSERT(!d->m_output_flush_remaining);
d->m_output_flush_ofs = 0;
d->m_output_flush_remaining = 0;
*d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> d->m_num_flags_left);
d->m_pLZ_code_buf -= (d->m_num_flags_left == 8);
if ((d->m_flags & TDEFL_WRITE_ZLIB_HEADER) && (!d->m_block_index))
{
TDEFL_PUT_BITS(0x78, 8); TDEFL_PUT_BITS(0x01, 8);
}
TDEFL_PUT_BITS(flush == TDEFL_FINISH, 1);
pSaved_output_buf = d->m_pOutput_buf; saved_bit_buf = d->m_bit_buffer; saved_bits_in = d->m_bits_in;
if (!use_raw_block)
comp_block_succeeded = tdefl_compress_block(d, (d->m_flags & TDEFL_FORCE_ALL_STATIC_BLOCKS) || (d->m_total_lz_bytes < 48));
// If the block gets expanded, forget the current contents of the output buffer and send a raw block instead.
if ( ((use_raw_block) || ((d->m_total_lz_bytes) && ((d->m_pOutput_buf - pSaved_output_buf + 1U) >= d->m_total_lz_bytes))) &&
((d->m_lookahead_pos - d->m_lz_code_buf_dict_pos) <= d->m_dict_size) )
{
mz_uint i; d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
TDEFL_PUT_BITS(0, 2);
if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); }
for (i = 2; i; --i, d->m_total_lz_bytes ^= 0xFFFF)
{
TDEFL_PUT_BITS(d->m_total_lz_bytes & 0xFFFF, 16);
}
for (i = 0; i < d->m_total_lz_bytes; ++i)
{
TDEFL_PUT_BITS(d->m_dict[(d->m_lz_code_buf_dict_pos + i) & TDEFL_LZ_DICT_SIZE_MASK], 8);
}
}
// Check for the extremely unlikely (if not impossible) case of the compressed block not fitting into the output buffer when using dynamic codes.
else if (!comp_block_succeeded)
{
d->m_pOutput_buf = pSaved_output_buf; d->m_bit_buffer = saved_bit_buf, d->m_bits_in = saved_bits_in;
tdefl_compress_block(d, MZ_TRUE);
}
if (flush)
{
if (flush == TDEFL_FINISH)
{
if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); }
if (d->m_flags & TDEFL_WRITE_ZLIB_HEADER) { mz_uint i, a = d->m_adler32; for (i = 0; i < 4; i++) { TDEFL_PUT_BITS((a >> 24) & 0xFF, 8); a <<= 8; } }
}
else
{
mz_uint i, z = 0; TDEFL_PUT_BITS(0, 3); if (d->m_bits_in) { TDEFL_PUT_BITS(0, 8 - d->m_bits_in); } for (i = 2; i; --i, z ^= 0xFFFF) { TDEFL_PUT_BITS(z & 0xFFFF, 16); }
}
}
MZ_ASSERT(d->m_pOutput_buf < d->m_pOutput_buf_end);
memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8; d->m_lz_code_buf_dict_pos += d->m_total_lz_bytes; d->m_total_lz_bytes = 0; d->m_block_index++;
if ((n = (int)(d->m_pOutput_buf - pOutput_buf_start)) != 0)
{
if (d->m_pPut_buf_func)
{
*d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;
if (!(*d->m_pPut_buf_func)(d->m_output_buf, n, d->m_pPut_buf_user))
return (d->m_prev_return_status = TDEFL_STATUS_PUT_BUF_FAILED);
}
else if (pOutput_buf_start == d->m_output_buf)
{
int bytes_to_copy = (int)MZ_MIN((size_t)n, (size_t)(*d->m_pOut_buf_size - d->m_out_buf_ofs));
memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf, bytes_to_copy);
d->m_out_buf_ofs += bytes_to_copy;
if ((n -= bytes_to_copy) != 0)
{
d->m_output_flush_ofs = bytes_to_copy;
d->m_output_flush_remaining = n;
}
}
else
{
d->m_out_buf_ofs += n;
}
}
return d->m_output_flush_remaining;
}
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
#define TDEFL_READ_UNALIGNED_WORD(p) *(const mz_uint16*)(p)
static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len)
{
mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len;
mz_uint num_probes_left = d->m_max_probes[match_len >= 32];
const mz_uint16 *s = (const mz_uint16*)(d->m_dict + pos), *p, *q;
mz_uint16 c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]), s01 = TDEFL_READ_UNALIGNED_WORD(s);
MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return;
for ( ; ; )
{
for ( ; ; )
{
if (--num_probes_left == 0) return;
#define TDEFL_PROBE \
next_probe_pos = d->m_next[probe_pos]; \
if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \
probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
if (TDEFL_READ_UNALIGNED_WORD(&d->m_dict[probe_pos + match_len - 1]) == c01) break;
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
}
if (!dist) break; q = (const mz_uint16*)(d->m_dict + probe_pos); if (TDEFL_READ_UNALIGNED_WORD(q) != s01) continue; p = s; probe_len = 32;
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
if (!probe_len)
{
*pMatch_dist = dist; *pMatch_len = MZ_MIN(max_match_len, TDEFL_MAX_MATCH_LEN); break;
}
else if ((probe_len = ((mz_uint)(p - s) * 2) + (mz_uint)(*(const mz_uint8*)p == *(const mz_uint8*)q)) > match_len)
{
*pMatch_dist = dist; if ((*pMatch_len = match_len = MZ_MIN(max_match_len, probe_len)) == max_match_len) break;
c01 = TDEFL_READ_UNALIGNED_WORD(&d->m_dict[pos + match_len - 1]);
}
}
}
#else
static MZ_FORCEINLINE void tdefl_find_match(tdefl_compressor *d, mz_uint lookahead_pos, mz_uint max_dist, mz_uint max_match_len, mz_uint *pMatch_dist, mz_uint *pMatch_len)
{
mz_uint dist, pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK, match_len = *pMatch_len, probe_pos = pos, next_probe_pos, probe_len;
mz_uint num_probes_left = d->m_max_probes[match_len >= 32];
const mz_uint8 *s = d->m_dict + pos, *p, *q;
mz_uint8 c0 = d->m_dict[pos + match_len], c1 = d->m_dict[pos + match_len - 1];
MZ_ASSERT(max_match_len <= TDEFL_MAX_MATCH_LEN); if (max_match_len <= match_len) return;
for ( ; ; )
{
for ( ; ; )
{
if (--num_probes_left == 0) return;
#define TDEFL_PROBE \
next_probe_pos = d->m_next[probe_pos]; \
if ((!next_probe_pos) || ((dist = (mz_uint16)(lookahead_pos - next_probe_pos)) > max_dist)) return; \
probe_pos = next_probe_pos & TDEFL_LZ_DICT_SIZE_MASK; \
if ((d->m_dict[probe_pos + match_len] == c0) && (d->m_dict[probe_pos + match_len - 1] == c1)) break;
TDEFL_PROBE; TDEFL_PROBE; TDEFL_PROBE;
}
if (!dist) break; p = s; q = d->m_dict + probe_pos; for (probe_len = 0; probe_len < max_match_len; probe_len++) if (*p++ != *q++) break;
if (probe_len > match_len)
{
*pMatch_dist = dist; if ((*pMatch_len = match_len = probe_len) == max_match_len) return;
c0 = d->m_dict[pos + match_len]; c1 = d->m_dict[pos + match_len - 1];
}
}
}
#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
static mz_bool tdefl_compress_fast(tdefl_compressor *d)
{
// Faster, minimally featured LZRW1-style match+parse loop with better register utilization. Intended for applications where raw throughput is valued more highly than ratio.
mz_uint lookahead_pos = d->m_lookahead_pos, lookahead_size = d->m_lookahead_size, dict_size = d->m_dict_size, total_lz_bytes = d->m_total_lz_bytes, num_flags_left = d->m_num_flags_left;
mz_uint8 *pLZ_code_buf = d->m_pLZ_code_buf, *pLZ_flags = d->m_pLZ_flags;
mz_uint cur_pos = lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;
while ((d->m_src_buf_left) || ((d->m_flush) && (lookahead_size)))
{
const mz_uint TDEFL_COMP_FAST_LOOKAHEAD_SIZE = 4096;
mz_uint dst_pos = (lookahead_pos + lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;
mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(d->m_src_buf_left, TDEFL_COMP_FAST_LOOKAHEAD_SIZE - lookahead_size);
d->m_src_buf_left -= num_bytes_to_process;
lookahead_size += num_bytes_to_process;
while (num_bytes_to_process)
{
mz_uint32 n = MZ_MIN(TDEFL_LZ_DICT_SIZE - dst_pos, num_bytes_to_process);
memcpy(d->m_dict + dst_pos, d->m_pSrc, n);
if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
memcpy(d->m_dict + TDEFL_LZ_DICT_SIZE + dst_pos, d->m_pSrc, MZ_MIN(n, (TDEFL_MAX_MATCH_LEN - 1) - dst_pos));
d->m_pSrc += n;
dst_pos = (dst_pos + n) & TDEFL_LZ_DICT_SIZE_MASK;
num_bytes_to_process -= n;
}
dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - lookahead_size, dict_size);
if ((!d->m_flush) && (lookahead_size < TDEFL_COMP_FAST_LOOKAHEAD_SIZE)) break;
while (lookahead_size >= 4)
{
mz_uint cur_match_dist, cur_match_len = 1;
mz_uint8 *pCur_dict = d->m_dict + cur_pos;
mz_uint first_trigram = (*(const mz_uint32 *)pCur_dict) & 0xFFFFFF;
mz_uint hash = (first_trigram ^ (first_trigram >> (24 - (TDEFL_LZ_HASH_BITS - 8)))) & TDEFL_LEVEL1_HASH_SIZE_MASK;
mz_uint probe_pos = d->m_hash[hash];
d->m_hash[hash] = (mz_uint16)lookahead_pos;
if (((cur_match_dist = (mz_uint16)(lookahead_pos - probe_pos)) <= dict_size) && ((*(const mz_uint32 *)(d->m_dict + (probe_pos &= TDEFL_LZ_DICT_SIZE_MASK)) & 0xFFFFFF) == first_trigram))
{
const mz_uint16 *p = (const mz_uint16 *)pCur_dict;
const mz_uint16 *q = (const mz_uint16 *)(d->m_dict + probe_pos);
mz_uint32 probe_len = 32;
do { } while ( (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) &&
(TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (TDEFL_READ_UNALIGNED_WORD(++p) == TDEFL_READ_UNALIGNED_WORD(++q)) && (--probe_len > 0) );
cur_match_len = ((mz_uint)(p - (const mz_uint16 *)pCur_dict) * 2) + (mz_uint)(*(const mz_uint8 *)p == *(const mz_uint8 *)q);
if (!probe_len)
cur_match_len = cur_match_dist ? TDEFL_MAX_MATCH_LEN : 0;
if ((cur_match_len < TDEFL_MIN_MATCH_LEN) || ((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)))
{
cur_match_len = 1;
*pLZ_code_buf++ = (mz_uint8)first_trigram;
*pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
d->m_huff_count[0][(mz_uint8)first_trigram]++;
}
else
{
mz_uint32 s0, s1;
cur_match_len = MZ_MIN(cur_match_len, lookahead_size);
MZ_ASSERT((cur_match_len >= TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 1) && (cur_match_dist <= TDEFL_LZ_DICT_SIZE));
cur_match_dist--;
pLZ_code_buf[0] = (mz_uint8)(cur_match_len - TDEFL_MIN_MATCH_LEN);
*(mz_uint16 *)(&pLZ_code_buf[1]) = (mz_uint16)cur_match_dist;
pLZ_code_buf += 3;
*pLZ_flags = (mz_uint8)((*pLZ_flags >> 1) | 0x80);
s0 = s_tdefl_small_dist_sym[cur_match_dist & 511];
s1 = s_tdefl_large_dist_sym[cur_match_dist >> 8];
d->m_huff_count[1][(cur_match_dist < 512) ? s0 : s1]++;
d->m_huff_count[0][s_tdefl_len_sym[cur_match_len - TDEFL_MIN_MATCH_LEN]]++;
}
}
else
{
*pLZ_code_buf++ = (mz_uint8)first_trigram;
*pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
d->m_huff_count[0][(mz_uint8)first_trigram]++;
}
if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
total_lz_bytes += cur_match_len;
lookahead_pos += cur_match_len;
dict_size = MZ_MIN(dict_size + cur_match_len, TDEFL_LZ_DICT_SIZE);
cur_pos = (cur_pos + cur_match_len) & TDEFL_LZ_DICT_SIZE_MASK;
MZ_ASSERT(lookahead_size >= cur_match_len);
lookahead_size -= cur_match_len;
if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
{
int n;
d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
if ((n = tdefl_flush_block(d, 0)) != 0)
return (n < 0) ? MZ_FALSE : MZ_TRUE;
total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left;
}
}
while (lookahead_size)
{
mz_uint8 lit = d->m_dict[cur_pos];
total_lz_bytes++;
*pLZ_code_buf++ = lit;
*pLZ_flags = (mz_uint8)(*pLZ_flags >> 1);
if (--num_flags_left == 0) { num_flags_left = 8; pLZ_flags = pLZ_code_buf++; }
d->m_huff_count[0][lit]++;
lookahead_pos++;
dict_size = MZ_MIN(dict_size + 1, TDEFL_LZ_DICT_SIZE);
cur_pos = (cur_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK;
lookahead_size--;
if (pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8])
{
int n;
d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
if ((n = tdefl_flush_block(d, 0)) != 0)
return (n < 0) ? MZ_FALSE : MZ_TRUE;
total_lz_bytes = d->m_total_lz_bytes; pLZ_code_buf = d->m_pLZ_code_buf; pLZ_flags = d->m_pLZ_flags; num_flags_left = d->m_num_flags_left;
}
}
}
d->m_lookahead_pos = lookahead_pos; d->m_lookahead_size = lookahead_size; d->m_dict_size = dict_size;
d->m_total_lz_bytes = total_lz_bytes; d->m_pLZ_code_buf = pLZ_code_buf; d->m_pLZ_flags = pLZ_flags; d->m_num_flags_left = num_flags_left;
return MZ_TRUE;
}
#endif // MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
static MZ_FORCEINLINE void tdefl_record_literal(tdefl_compressor *d, mz_uint8 lit)
{
d->m_total_lz_bytes++;
*d->m_pLZ_code_buf++ = lit;
*d->m_pLZ_flags = (mz_uint8)(*d->m_pLZ_flags >> 1); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; }
d->m_huff_count[0][lit]++;
}
static MZ_FORCEINLINE void tdefl_record_match(tdefl_compressor *d, mz_uint match_len, mz_uint match_dist)
{
mz_uint32 s0, s1;
MZ_ASSERT((match_len >= TDEFL_MIN_MATCH_LEN) && (match_dist >= 1) && (match_dist <= TDEFL_LZ_DICT_SIZE));
d->m_total_lz_bytes += match_len;
d->m_pLZ_code_buf[0] = (mz_uint8)(match_len - TDEFL_MIN_MATCH_LEN);
match_dist -= 1;
d->m_pLZ_code_buf[1] = (mz_uint8)(match_dist & 0xFF);
d->m_pLZ_code_buf[2] = (mz_uint8)(match_dist >> 8); d->m_pLZ_code_buf += 3;
*d->m_pLZ_flags = (mz_uint8)((*d->m_pLZ_flags >> 1) | 0x80); if (--d->m_num_flags_left == 0) { d->m_num_flags_left = 8; d->m_pLZ_flags = d->m_pLZ_code_buf++; }
s0 = s_tdefl_small_dist_sym[match_dist & 511]; s1 = s_tdefl_large_dist_sym[(match_dist >> 8) & 127];
d->m_huff_count[1][(match_dist < 512) ? s0 : s1]++;
if (match_len >= TDEFL_MIN_MATCH_LEN) d->m_huff_count[0][s_tdefl_len_sym[match_len - TDEFL_MIN_MATCH_LEN]]++;
}
static mz_bool tdefl_compress_normal(tdefl_compressor *d)
{
const mz_uint8 *pSrc = d->m_pSrc; size_t src_buf_left = d->m_src_buf_left;
tdefl_flush flush = d->m_flush;
while ((src_buf_left) || ((flush) && (d->m_lookahead_size)))
{
mz_uint len_to_move, cur_match_dist, cur_match_len, cur_pos;
// Update dictionary and hash chains. Keeps the lookahead size equal to TDEFL_MAX_MATCH_LEN.
if ((d->m_lookahead_size + d->m_dict_size) >= (TDEFL_MIN_MATCH_LEN - 1))
{
mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK, ins_pos = d->m_lookahead_pos + d->m_lookahead_size - 2;
mz_uint hash = (d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK];
mz_uint num_bytes_to_process = (mz_uint)MZ_MIN(src_buf_left, TDEFL_MAX_MATCH_LEN - d->m_lookahead_size);
const mz_uint8 *pSrc_end = pSrc + num_bytes_to_process;
src_buf_left -= num_bytes_to_process;
d->m_lookahead_size += num_bytes_to_process;
while (pSrc != pSrc_end)
{
mz_uint8 c = *pSrc++; d->m_dict[dst_pos] = c; if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1)) d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
hash = ((hash << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1);
d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos);
dst_pos = (dst_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK; ins_pos++;
}
}
else
{
while ((src_buf_left) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN))
{
mz_uint8 c = *pSrc++;
mz_uint dst_pos = (d->m_lookahead_pos + d->m_lookahead_size) & TDEFL_LZ_DICT_SIZE_MASK;
src_buf_left--;
d->m_dict[dst_pos] = c;
if (dst_pos < (TDEFL_MAX_MATCH_LEN - 1))
d->m_dict[TDEFL_LZ_DICT_SIZE + dst_pos] = c;
if ((++d->m_lookahead_size + d->m_dict_size) >= TDEFL_MIN_MATCH_LEN)
{
mz_uint ins_pos = d->m_lookahead_pos + (d->m_lookahead_size - 1) - 2;
mz_uint hash = ((d->m_dict[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] << (TDEFL_LZ_HASH_SHIFT * 2)) ^ (d->m_dict[(ins_pos + 1) & TDEFL_LZ_DICT_SIZE_MASK] << TDEFL_LZ_HASH_SHIFT) ^ c) & (TDEFL_LZ_HASH_SIZE - 1);
d->m_next[ins_pos & TDEFL_LZ_DICT_SIZE_MASK] = d->m_hash[hash]; d->m_hash[hash] = (mz_uint16)(ins_pos);
}
}
}
d->m_dict_size = MZ_MIN(TDEFL_LZ_DICT_SIZE - d->m_lookahead_size, d->m_dict_size);
if ((!flush) && (d->m_lookahead_size < TDEFL_MAX_MATCH_LEN))
break;
// Simple lazy/greedy parsing state machine.
len_to_move = 1; cur_match_dist = 0; cur_match_len = d->m_saved_match_len ? d->m_saved_match_len : (TDEFL_MIN_MATCH_LEN - 1); cur_pos = d->m_lookahead_pos & TDEFL_LZ_DICT_SIZE_MASK;
if (d->m_flags & (TDEFL_RLE_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS))
{
if ((d->m_dict_size) && (!(d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS)))
{
mz_uint8 c = d->m_dict[(cur_pos - 1) & TDEFL_LZ_DICT_SIZE_MASK];
cur_match_len = 0; while (cur_match_len < d->m_lookahead_size) { if (d->m_dict[cur_pos + cur_match_len] != c) break; cur_match_len++; }
if (cur_match_len < TDEFL_MIN_MATCH_LEN) cur_match_len = 0; else cur_match_dist = 1;
}
}
else
{
tdefl_find_match(d, d->m_lookahead_pos, d->m_dict_size, d->m_lookahead_size, &cur_match_dist, &cur_match_len);
}
if (((cur_match_len == TDEFL_MIN_MATCH_LEN) && (cur_match_dist >= 8U*1024U)) || (cur_pos == cur_match_dist) || ((d->m_flags & TDEFL_FILTER_MATCHES) && (cur_match_len <= 5)))
{
cur_match_dist = cur_match_len = 0;
}
if (d->m_saved_match_len)
{
if (cur_match_len > d->m_saved_match_len)
{
tdefl_record_literal(d, (mz_uint8)d->m_saved_lit);
if (cur_match_len >= 128)
{
tdefl_record_match(d, cur_match_len, cur_match_dist);
d->m_saved_match_len = 0; len_to_move = cur_match_len;
}
else
{
d->m_saved_lit = d->m_dict[cur_pos]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len;
}
}
else
{
tdefl_record_match(d, d->m_saved_match_len, d->m_saved_match_dist);
len_to_move = d->m_saved_match_len - 1; d->m_saved_match_len = 0;
}
}
else if (!cur_match_dist)
tdefl_record_literal(d, d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]);
else if ((d->m_greedy_parsing) || (d->m_flags & TDEFL_RLE_MATCHES) || (cur_match_len >= 128))
{
tdefl_record_match(d, cur_match_len, cur_match_dist);
len_to_move = cur_match_len;
}
else
{
d->m_saved_lit = d->m_dict[MZ_MIN(cur_pos, sizeof(d->m_dict) - 1)]; d->m_saved_match_dist = cur_match_dist; d->m_saved_match_len = cur_match_len;
}
// Move the lookahead forward by len_to_move bytes.
d->m_lookahead_pos += len_to_move;
MZ_ASSERT(d->m_lookahead_size >= len_to_move);
d->m_lookahead_size -= len_to_move;
d->m_dict_size = MZ_MIN(d->m_dict_size + len_to_move, TDEFL_LZ_DICT_SIZE);
// Check if it's time to flush the current LZ codes to the internal output buffer.
if ( (d->m_pLZ_code_buf > &d->m_lz_code_buf[TDEFL_LZ_CODE_BUF_SIZE - 8]) ||
( (d->m_total_lz_bytes > 31*1024) && (((((mz_uint)(d->m_pLZ_code_buf - d->m_lz_code_buf) * 115) >> 7) >= d->m_total_lz_bytes) || (d->m_flags & TDEFL_FORCE_ALL_RAW_BLOCKS))) )
{
int n;
d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left;
if ((n = tdefl_flush_block(d, 0)) != 0)
return (n < 0) ? MZ_FALSE : MZ_TRUE;
}
}
d->m_pSrc = pSrc; d->m_src_buf_left = src_buf_left;
return MZ_TRUE;
}
static tdefl_status tdefl_flush_output_buffer(tdefl_compressor *d)
{
if (d->m_pIn_buf_size)
{
*d->m_pIn_buf_size = d->m_pSrc - (const mz_uint8 *)d->m_pIn_buf;
}
if (d->m_pOut_buf_size)
{
size_t n = MZ_MIN(*d->m_pOut_buf_size - d->m_out_buf_ofs, d->m_output_flush_remaining);
memcpy((mz_uint8 *)d->m_pOut_buf + d->m_out_buf_ofs, d->m_output_buf + d->m_output_flush_ofs, n);
d->m_output_flush_ofs += (mz_uint)n;
d->m_output_flush_remaining -= (mz_uint)n;
d->m_out_buf_ofs += n;
*d->m_pOut_buf_size = d->m_out_buf_ofs;
}
return (d->m_finished && !d->m_output_flush_remaining) ? TDEFL_STATUS_DONE : TDEFL_STATUS_OKAY;
}
tdefl_status tdefl_compress(tdefl_compressor *d, const void *pIn_buf, size_t *pIn_buf_size, void *pOut_buf, size_t *pOut_buf_size, tdefl_flush flush)
{
if (!d)
{
if (pIn_buf_size) *pIn_buf_size = 0;
if (pOut_buf_size) *pOut_buf_size = 0;
return TDEFL_STATUS_BAD_PARAM;
}
d->m_pIn_buf = pIn_buf; d->m_pIn_buf_size = pIn_buf_size;
d->m_pOut_buf = pOut_buf; d->m_pOut_buf_size = pOut_buf_size;
d->m_pSrc = (const mz_uint8 *)(pIn_buf); d->m_src_buf_left = pIn_buf_size ? *pIn_buf_size : 0;
d->m_out_buf_ofs = 0;
d->m_flush = flush;
if ( ((d->m_pPut_buf_func != NULL) == ((pOut_buf != NULL) || (pOut_buf_size != NULL))) || (d->m_prev_return_status != TDEFL_STATUS_OKAY) ||
(d->m_wants_to_finish && (flush != TDEFL_FINISH)) || (pIn_buf_size && *pIn_buf_size && !pIn_buf) || (pOut_buf_size && *pOut_buf_size && !pOut_buf) )
{
if (pIn_buf_size) *pIn_buf_size = 0;
if (pOut_buf_size) *pOut_buf_size = 0;
return (d->m_prev_return_status = TDEFL_STATUS_BAD_PARAM);
}
d->m_wants_to_finish |= (flush == TDEFL_FINISH);
if ((d->m_output_flush_remaining) || (d->m_finished))
return (d->m_prev_return_status = tdefl_flush_output_buffer(d));
#if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
if (((d->m_flags & TDEFL_MAX_PROBES_MASK) == 1) &&
((d->m_flags & TDEFL_GREEDY_PARSING_FLAG) != 0) &&
((d->m_flags & (TDEFL_FILTER_MATCHES | TDEFL_FORCE_ALL_RAW_BLOCKS | TDEFL_RLE_MATCHES)) == 0))
{
if (!tdefl_compress_fast(d))
return d->m_prev_return_status;
}
else
#endif // #if MINIZ_USE_UNALIGNED_LOADS_AND_STORES && MINIZ_LITTLE_ENDIAN
{
if (!tdefl_compress_normal(d))
return d->m_prev_return_status;
}
if ((d->m_flags & (TDEFL_WRITE_ZLIB_HEADER | TDEFL_COMPUTE_ADLER32)) && (pIn_buf))
d->m_adler32 = (mz_uint32)mz_adler32(d->m_adler32, (const mz_uint8 *)pIn_buf, d->m_pSrc - (const mz_uint8 *)pIn_buf);
if ((flush) && (!d->m_lookahead_size) && (!d->m_src_buf_left) && (!d->m_output_flush_remaining))
{
if (tdefl_flush_block(d, flush) < 0)
return d->m_prev_return_status;
d->m_finished = (flush == TDEFL_FINISH);
if (flush == TDEFL_FULL_FLUSH) { MZ_CLEAR_OBJ(d->m_hash); MZ_CLEAR_OBJ(d->m_next); d->m_dict_size = 0; }
}
return (d->m_prev_return_status = tdefl_flush_output_buffer(d));
}
tdefl_status tdefl_compress_buffer(tdefl_compressor *d, const void *pIn_buf, size_t in_buf_size, tdefl_flush flush)
{
MZ_ASSERT(d->m_pPut_buf_func); return tdefl_compress(d, pIn_buf, &in_buf_size, NULL, NULL, flush);
}
tdefl_status tdefl_init(tdefl_compressor *d, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
{
d->m_pPut_buf_func = pPut_buf_func; d->m_pPut_buf_user = pPut_buf_user;
d->m_flags = (mz_uint)(flags); d->m_max_probes[0] = 1 + ((flags & 0xFFF) + 2) / 3; d->m_greedy_parsing = (flags & TDEFL_GREEDY_PARSING_FLAG) != 0;
d->m_max_probes[1] = 1 + (((flags & 0xFFF) >> 2) + 2) / 3;
if (!(flags & TDEFL_NONDETERMINISTIC_PARSING_FLAG)) MZ_CLEAR_OBJ(d->m_hash);
d->m_lookahead_pos = d->m_lookahead_size = d->m_dict_size = d->m_total_lz_bytes = d->m_lz_code_buf_dict_pos = d->m_bits_in = 0;
d->m_output_flush_ofs = d->m_output_flush_remaining = d->m_finished = d->m_block_index = d->m_bit_buffer = d->m_wants_to_finish = 0;
d->m_pLZ_code_buf = d->m_lz_code_buf + 1; d->m_pLZ_flags = d->m_lz_code_buf; d->m_num_flags_left = 8;
d->m_pOutput_buf = d->m_output_buf; d->m_pOutput_buf_end = d->m_output_buf; d->m_prev_return_status = TDEFL_STATUS_OKAY;
d->m_saved_match_dist = d->m_saved_match_len = d->m_saved_lit = 0; d->m_adler32 = 1;
d->m_pIn_buf = NULL; d->m_pOut_buf = NULL;
d->m_pIn_buf_size = NULL; d->m_pOut_buf_size = NULL;
d->m_flush = TDEFL_NO_FLUSH; d->m_pSrc = NULL; d->m_src_buf_left = 0; d->m_out_buf_ofs = 0;
memset(&d->m_huff_count[0][0], 0, sizeof(d->m_huff_count[0][0]) * TDEFL_MAX_HUFF_SYMBOLS_0);
memset(&d->m_huff_count[1][0], 0, sizeof(d->m_huff_count[1][0]) * TDEFL_MAX_HUFF_SYMBOLS_1);
return TDEFL_STATUS_OKAY;
}
tdefl_status tdefl_get_prev_return_status(tdefl_compressor *d)
{
return d->m_prev_return_status;
}
mz_uint32 tdefl_get_adler32(tdefl_compressor *d)
{
return d->m_adler32;
}
mz_bool tdefl_compress_mem_to_output(const void *pBuf, size_t buf_len, tdefl_put_buf_func_ptr pPut_buf_func, void *pPut_buf_user, int flags)
{
tdefl_compressor *pComp; mz_bool succeeded; if (((buf_len) && (!pBuf)) || (!pPut_buf_func)) return MZ_FALSE;
pComp = (tdefl_compressor*)MZ_MALLOC(sizeof(tdefl_compressor)); if (!pComp) return MZ_FALSE;
succeeded = (tdefl_init(pComp, pPut_buf_func, pPut_buf_user, flags) == TDEFL_STATUS_OKAY);
succeeded = succeeded && (tdefl_compress_buffer(pComp, pBuf, buf_len, TDEFL_FINISH) == TDEFL_STATUS_DONE);
MZ_FREE(pComp); return succeeded;
}
typedef struct
{
size_t m_size, m_capacity;
mz_uint8 *m_pBuf;
mz_bool m_expandable;
} tdefl_output_buffer;
static mz_bool tdefl_output_buffer_putter(const void *pBuf, int len, void *pUser)
{
tdefl_output_buffer *p = (tdefl_output_buffer *)pUser;
size_t new_size = p->m_size + len;
if (new_size > p->m_capacity)
{
size_t new_capacity = p->m_capacity; mz_uint8 *pNew_buf; if (!p->m_expandable) return MZ_FALSE;
do { new_capacity = MZ_MAX(128U, new_capacity << 1U); } while (new_size > new_capacity);
pNew_buf = (mz_uint8*)MZ_REALLOC(p->m_pBuf, new_capacity); if (!pNew_buf) return MZ_FALSE;
p->m_pBuf = pNew_buf; p->m_capacity = new_capacity;
}
memcpy((mz_uint8*)p->m_pBuf + p->m_size, pBuf, len); p->m_size = new_size;
return MZ_TRUE;
}
void *tdefl_compress_mem_to_heap(const void *pSrc_buf, size_t src_buf_len, size_t *pOut_len, int flags)
{
tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf);
if (!pOut_len) return MZ_FALSE; else *pOut_len = 0;
out_buf.m_expandable = MZ_TRUE;
if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return NULL;
*pOut_len = out_buf.m_size; return out_buf.m_pBuf;
}
size_t tdefl_compress_mem_to_mem(void *pOut_buf, size_t out_buf_len, const void *pSrc_buf, size_t src_buf_len, int flags)
{
tdefl_output_buffer out_buf; MZ_CLEAR_OBJ(out_buf);
if (!pOut_buf) return 0;
out_buf.m_pBuf = (mz_uint8*)pOut_buf; out_buf.m_capacity = out_buf_len;
if (!tdefl_compress_mem_to_output(pSrc_buf, src_buf_len, tdefl_output_buffer_putter, &out_buf, flags)) return 0;
return out_buf.m_size;
}
#ifndef MINIZ_NO_ZLIB_APIS
static const mz_uint s_tdefl_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
// level may actually range from [0,10] (10 is a "hidden" max level, where we want a bit more compression and it's fine if throughput to fall off a cliff on some files).
mz_uint tdefl_create_comp_flags_from_zip_params(int level, int window_bits, int strategy)
{
mz_uint comp_flags = s_tdefl_num_probes[(level >= 0) ? MZ_MIN(10, level) : MZ_DEFAULT_LEVEL] | ((level <= 3) ? TDEFL_GREEDY_PARSING_FLAG : 0);
if (window_bits > 0) comp_flags |= TDEFL_WRITE_ZLIB_HEADER;
if (!level) comp_flags |= TDEFL_FORCE_ALL_RAW_BLOCKS;
else if (strategy == MZ_FILTERED) comp_flags |= TDEFL_FILTER_MATCHES;
else if (strategy == MZ_HUFFMAN_ONLY) comp_flags &= ~TDEFL_MAX_PROBES_MASK;
else if (strategy == MZ_FIXED) comp_flags |= TDEFL_FORCE_ALL_STATIC_BLOCKS;
else if (strategy == MZ_RLE) comp_flags |= TDEFL_RLE_MATCHES;
return comp_flags;
}
#endif //MINIZ_NO_ZLIB_APIS
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable:4204) // nonstandard extension used : non-constant aggregate initializer (also supported by GNU C and C99, so no big deal)
#endif
// Simple PNG writer function by Alex Evans, 2011. Released into the public domain: https://gist.github.com/908299, more context at
// http://altdevblogaday.org/2011/04/06/a-smaller-jpg-encoder/.
// This is actually a modification of Alex's original code so PNG files generated by this function pass pngcheck.
void *tdefl_write_image_to_png_file_in_memory_ex(const void *pImage, int w, int h, int num_chans, size_t *pLen_out, mz_uint level, mz_bool flip)
{
// Using a local copy of this array here in case MINIZ_NO_ZLIB_APIS was defined.
static const mz_uint s_tdefl_png_num_probes[11] = { 0, 1, 6, 32, 16, 32, 128, 256, 512, 768, 1500 };
tdefl_compressor *pComp = (tdefl_compressor *)MZ_MALLOC(sizeof(tdefl_compressor)); tdefl_output_buffer out_buf; int i, bpl = w * num_chans, y, z; mz_uint32 c; *pLen_out = 0;
if (!pComp) return NULL;
MZ_CLEAR_OBJ(out_buf); out_buf.m_expandable = MZ_TRUE; out_buf.m_capacity = 57+MZ_MAX(64, (1+bpl)*h); if (NULL == (out_buf.m_pBuf = (mz_uint8*)MZ_MALLOC(out_buf.m_capacity))) { MZ_FREE(pComp); return NULL; }
// write dummy header
for (z = 41; z; --z) tdefl_output_buffer_putter(&z, 1, &out_buf);
// compress image data
tdefl_init(pComp, tdefl_output_buffer_putter, &out_buf, s_tdefl_png_num_probes[MZ_MIN(10, level)] | TDEFL_WRITE_ZLIB_HEADER);
for (y = 0; y < h; ++y) { tdefl_compress_buffer(pComp, &z, 1, TDEFL_NO_FLUSH); tdefl_compress_buffer(pComp, (mz_uint8*)pImage + (flip ? (h - 1 - y) : y) * bpl, bpl, TDEFL_NO_FLUSH); }
if (tdefl_compress_buffer(pComp, NULL, 0, TDEFL_FINISH) != TDEFL_STATUS_DONE) { MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; }
// write real header
*pLen_out = out_buf.m_size-41;
{
static const mz_uint8 chans[] = {0x00, 0x00, 0x04, 0x02, 0x06};
mz_uint8 pnghdr[41]={0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a,0x00,0x00,0x00,0x0d,0x49,0x48,0x44,0x52,
0,0,(mz_uint8)(w>>8),(mz_uint8)w,0,0,(mz_uint8)(h>>8),(mz_uint8)h,8,chans[num_chans],0,0,0,0,0,0,0,
(mz_uint8)(*pLen_out>>24),(mz_uint8)(*pLen_out>>16),(mz_uint8)(*pLen_out>>8),(mz_uint8)*pLen_out,0x49,0x44,0x41,0x54};
c=(mz_uint32)mz_crc32(MZ_CRC32_INIT,pnghdr+12,17); for (i=0; i<4; ++i, c<<=8) ((mz_uint8*)(pnghdr+29))[i]=(mz_uint8)(c>>24);
memcpy(out_buf.m_pBuf, pnghdr, 41);
}
// write footer (IDAT CRC-32, followed by IEND chunk)
if (!tdefl_output_buffer_putter("\0\0\0\0\0\0\0\0\x49\x45\x4e\x44\xae\x42\x60\x82", 16, &out_buf)) { *pLen_out = 0; MZ_FREE(pComp); MZ_FREE(out_buf.m_pBuf); return NULL; }
c = (mz_uint32)mz_crc32(MZ_CRC32_INIT,out_buf.m_pBuf+41-4, *pLen_out+4); for (i=0; i<4; ++i, c<<=8) (out_buf.m_pBuf+out_buf.m_size-16)[i] = (mz_uint8)(c >> 24);
// compute final size of file, grab compressed data buffer and return
*pLen_out += 57; MZ_FREE(pComp); return out_buf.m_pBuf;
}
void *tdefl_write_image_to_png_file_in_memory(const void *pImage, int w, int h, int num_chans, size_t *pLen_out)
{
// Level 6 corresponds to TDEFL_DEFAULT_MAX_PROBES or MZ_DEFAULT_LEVEL (but we can't depend on MZ_DEFAULT_LEVEL being available in case the zlib API's where #defined out)
return tdefl_write_image_to_png_file_in_memory_ex(pImage, w, h, num_chans, pLen_out, 6, MZ_FALSE);
}
#ifdef _MSC_VER
#pragma warning (pop)
#endif
// ------------------- .ZIP archive reading
#ifndef MINIZ_NO_ARCHIVE_APIS
#ifdef MINIZ_NO_STDIO
#define MZ_FILE void *
#else
#include <stdio.h>
#include <sys/stat.h>
#if defined(_MSC_VER) || defined(__MINGW64__)
static FILE *mz_fopen(const char *pFilename, const char *pMode)
{
FILE* pFile = NULL;
fopen_s(&pFile, pFilename, pMode);
return pFile;
}
static FILE *mz_freopen(const char *pPath, const char *pMode, FILE *pStream)
{
FILE* pFile = NULL;
if (freopen_s(&pFile, pPath, pMode, pStream))
return NULL;
return pFile;
}
#ifndef MINIZ_NO_TIME
#include <sys/utime.h>
#endif
#define MZ_FILE FILE
#define MZ_FOPEN mz_fopen
#define MZ_FCLOSE fclose
#define MZ_FREAD fread
#define MZ_FWRITE fwrite
#define MZ_FTELL64 _ftelli64
#define MZ_FSEEK64 _fseeki64
#define MZ_FILE_STAT_STRUCT _stat
#define MZ_FILE_STAT _stat
#define MZ_FFLUSH fflush
#define MZ_FREOPEN mz_freopen
#define MZ_DELETE_FILE remove
#elif defined(__MINGW32__)
#ifndef MINIZ_NO_TIME
#include <sys/utime.h>
#endif
#define MZ_FILE FILE
#define MZ_FOPEN(f, m) fopen(f, m)
#define MZ_FCLOSE fclose
#define MZ_FREAD fread
#define MZ_FWRITE fwrite
#define MZ_FTELL64 ftello64
#define MZ_FSEEK64 fseeko64
#define MZ_FILE_STAT_STRUCT _stat
#define MZ_FILE_STAT _stat
#define MZ_FFLUSH fflush
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
#define MZ_DELETE_FILE remove
#elif defined(__TINYC__)
#ifndef MINIZ_NO_TIME
#include <sys/utime.h>
#endif
#define MZ_FILE FILE
#define MZ_FOPEN(f, m) fopen(f, m)
#define MZ_FCLOSE fclose
#define MZ_FREAD fread
#define MZ_FWRITE fwrite
#define MZ_FTELL64 ftell
#define MZ_FSEEK64 fseek
#define MZ_FILE_STAT_STRUCT stat
#define MZ_FILE_STAT stat
#define MZ_FFLUSH fflush
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
#define MZ_DELETE_FILE remove
#elif defined(__GNUC__) && _LARGEFILE64_SOURCE
#ifndef MINIZ_NO_TIME
#include <utime.h>
#endif
#define MZ_FILE FILE
#define MZ_FOPEN(f, m) fopen64(f, m)
#define MZ_FCLOSE fclose
#define MZ_FREAD fread
#define MZ_FWRITE fwrite
#define MZ_FTELL64 ftello64
#define MZ_FSEEK64 fseeko64
#define MZ_FILE_STAT_STRUCT stat64
#define MZ_FILE_STAT stat64
#define MZ_FFLUSH fflush
#define MZ_FREOPEN(p, m, s) freopen64(p, m, s)
#define MZ_DELETE_FILE remove
#else
#ifndef MINIZ_NO_TIME
#include <utime.h>
#endif
#define MZ_FILE FILE
#define MZ_FOPEN(f, m) fopen(f, m)
#define MZ_FCLOSE fclose
#define MZ_FREAD fread
#define MZ_FWRITE fwrite
#define MZ_FTELL64 ftello
#define MZ_FSEEK64 fseeko
#define MZ_FILE_STAT_STRUCT stat
#define MZ_FILE_STAT stat
#define MZ_FFLUSH fflush
#define MZ_FREOPEN(f, m, s) freopen(f, m, s)
#define MZ_DELETE_FILE remove
#endif // #ifdef _MSC_VER
#endif // #ifdef MINIZ_NO_STDIO
#define MZ_TOLOWER(c) ((((c) >= 'A') && ((c) <= 'Z')) ? ((c) - 'A' + 'a') : (c))
// Various ZIP archive enums. To completely avoid cross platform compiler alignment and platform endian issues, miniz.c doesn't use structs for any of this stuff.
enum
{
// ZIP archive identifiers and record sizes
MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG = 0x06054b50, MZ_ZIP_CENTRAL_DIR_HEADER_SIG = 0x02014b50, MZ_ZIP_LOCAL_DIR_HEADER_SIG = 0x04034b50,
MZ_ZIP_LOCAL_DIR_HEADER_SIZE = 30, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE = 46, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE = 22,
// Central directory header record offsets
MZ_ZIP_CDH_SIG_OFS = 0, MZ_ZIP_CDH_VERSION_MADE_BY_OFS = 4, MZ_ZIP_CDH_VERSION_NEEDED_OFS = 6, MZ_ZIP_CDH_BIT_FLAG_OFS = 8,
MZ_ZIP_CDH_METHOD_OFS = 10, MZ_ZIP_CDH_FILE_TIME_OFS = 12, MZ_ZIP_CDH_FILE_DATE_OFS = 14, MZ_ZIP_CDH_CRC32_OFS = 16,
MZ_ZIP_CDH_COMPRESSED_SIZE_OFS = 20, MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS = 24, MZ_ZIP_CDH_FILENAME_LEN_OFS = 28, MZ_ZIP_CDH_EXTRA_LEN_OFS = 30,
MZ_ZIP_CDH_COMMENT_LEN_OFS = 32, MZ_ZIP_CDH_DISK_START_OFS = 34, MZ_ZIP_CDH_INTERNAL_ATTR_OFS = 36, MZ_ZIP_CDH_EXTERNAL_ATTR_OFS = 38, MZ_ZIP_CDH_LOCAL_HEADER_OFS = 42,
// Local directory header offsets
MZ_ZIP_LDH_SIG_OFS = 0, MZ_ZIP_LDH_VERSION_NEEDED_OFS = 4, MZ_ZIP_LDH_BIT_FLAG_OFS = 6, MZ_ZIP_LDH_METHOD_OFS = 8, MZ_ZIP_LDH_FILE_TIME_OFS = 10,
MZ_ZIP_LDH_FILE_DATE_OFS = 12, MZ_ZIP_LDH_CRC32_OFS = 14, MZ_ZIP_LDH_COMPRESSED_SIZE_OFS = 18, MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS = 22,
MZ_ZIP_LDH_FILENAME_LEN_OFS = 26, MZ_ZIP_LDH_EXTRA_LEN_OFS = 28,
// End of central directory offsets
MZ_ZIP_ECDH_SIG_OFS = 0, MZ_ZIP_ECDH_NUM_THIS_DISK_OFS = 4, MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS = 6, MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS = 8,
MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS = 10, MZ_ZIP_ECDH_CDIR_SIZE_OFS = 12, MZ_ZIP_ECDH_CDIR_OFS_OFS = 16, MZ_ZIP_ECDH_COMMENT_SIZE_OFS = 20,
};
typedef struct
{
void *m_p;
size_t m_size, m_capacity;
mz_uint m_element_size;
} mz_zip_array;
struct mz_zip_internal_state_tag
{
mz_zip_array m_central_dir;
mz_zip_array m_central_dir_offsets;
mz_zip_array m_sorted_central_dir_offsets;
MZ_FILE *m_pFile;
void *m_pMem;
size_t m_mem_size;
size_t m_mem_capacity;
};
#define MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(array_ptr, element_size) (array_ptr)->m_element_size = element_size
#define MZ_ZIP_ARRAY_ELEMENT(array_ptr, element_type, index) ((element_type *)((array_ptr)->m_p))[index]
static MZ_FORCEINLINE void mz_zip_array_clear(mz_zip_archive *pZip, mz_zip_array *pArray)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pArray->m_p);
memset(pArray, 0, sizeof(mz_zip_array));
}
static mz_bool mz_zip_array_ensure_capacity(mz_zip_archive *pZip, mz_zip_array *pArray, size_t min_new_capacity, mz_uint growing)
{
void *pNew_p; size_t new_capacity = min_new_capacity; MZ_ASSERT(pArray->m_element_size); if (pArray->m_capacity >= min_new_capacity) return MZ_TRUE;
if (growing) { new_capacity = MZ_MAX(1, pArray->m_capacity); while (new_capacity < min_new_capacity) new_capacity *= 2; }
if (NULL == (pNew_p = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pArray->m_p, pArray->m_element_size, new_capacity))) return MZ_FALSE;
pArray->m_p = pNew_p; pArray->m_capacity = new_capacity;
return MZ_TRUE;
}
static MZ_FORCEINLINE mz_bool mz_zip_array_reserve(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_capacity, mz_uint growing)
{
if (new_capacity > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_capacity, growing)) return MZ_FALSE; }
return MZ_TRUE;
}
static MZ_FORCEINLINE mz_bool mz_zip_array_resize(mz_zip_archive *pZip, mz_zip_array *pArray, size_t new_size, mz_uint growing)
{
if (new_size > pArray->m_capacity) { if (!mz_zip_array_ensure_capacity(pZip, pArray, new_size, growing)) return MZ_FALSE; }
pArray->m_size = new_size;
return MZ_TRUE;
}
static MZ_FORCEINLINE mz_bool mz_zip_array_ensure_room(mz_zip_archive *pZip, mz_zip_array *pArray, size_t n)
{
return mz_zip_array_reserve(pZip, pArray, pArray->m_size + n, MZ_TRUE);
}
static MZ_FORCEINLINE mz_bool mz_zip_array_push_back(mz_zip_archive *pZip, mz_zip_array *pArray, const void *pElements, size_t n)
{
size_t orig_size = pArray->m_size; if (!mz_zip_array_resize(pZip, pArray, orig_size + n, MZ_TRUE)) return MZ_FALSE;
memcpy((mz_uint8*)pArray->m_p + orig_size * pArray->m_element_size, pElements, n * pArray->m_element_size);
return MZ_TRUE;
}
#ifndef MINIZ_NO_TIME
static time_t mz_zip_dos_to_time_t(int dos_time, int dos_date)
{
struct tm tm;
memset(&tm, 0, sizeof(tm)); tm.tm_isdst = -1;
tm.tm_year = ((dos_date >> 9) & 127) + 1980 - 1900; tm.tm_mon = ((dos_date >> 5) & 15) - 1; tm.tm_mday = dos_date & 31;
tm.tm_hour = (dos_time >> 11) & 31; tm.tm_min = (dos_time >> 5) & 63; tm.tm_sec = (dos_time << 1) & 62;
return mktime(&tm);
}
static void mz_zip_time_to_dos_time(time_t time, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
{
#ifdef _MSC_VER
struct tm tm_struct;
struct tm *tm = &tm_struct;
errno_t err = localtime_s(tm, &time);
if (err)
{
*pDOS_date = 0; *pDOS_time = 0;
return;
}
#else
struct tm *tm = localtime(&time);
#endif
*pDOS_time = (mz_uint16)(((tm->tm_hour) << 11) + ((tm->tm_min) << 5) + ((tm->tm_sec) >> 1));
*pDOS_date = (mz_uint16)(((tm->tm_year + 1900 - 1980) << 9) + ((tm->tm_mon + 1) << 5) + tm->tm_mday);
}
#endif
#ifndef MINIZ_NO_STDIO
static mz_bool mz_zip_get_file_modified_time(const char *pFilename, mz_uint16 *pDOS_time, mz_uint16 *pDOS_date)
{
#ifdef MINIZ_NO_TIME
(void)pFilename; *pDOS_date = *pDOS_time = 0;
#else
struct MZ_FILE_STAT_STRUCT file_stat;
// On Linux with x86 glibc, this call will fail on large files (>= 0x80000000 bytes) unless you compiled with _LARGEFILE64_SOURCE. Argh.
if (MZ_FILE_STAT(pFilename, &file_stat) != 0)
return MZ_FALSE;
mz_zip_time_to_dos_time(file_stat.st_mtime, pDOS_time, pDOS_date);
#endif // #ifdef MINIZ_NO_TIME
return MZ_TRUE;
}
#ifndef MINIZ_NO_TIME
static mz_bool mz_zip_set_file_times(const char *pFilename, time_t access_time, time_t modified_time)
{
struct utimbuf t; t.actime = access_time; t.modtime = modified_time;
return !utime(pFilename, &t);
}
#endif // #ifndef MINIZ_NO_TIME
#endif // #ifndef MINIZ_NO_STDIO
static mz_bool mz_zip_reader_init_internal(mz_zip_archive *pZip, mz_uint32 flags)
{
(void)flags;
if ((!pZip) || (pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
return MZ_FALSE;
if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func;
if (!pZip->m_pFree) pZip->m_pFree = def_free_func;
if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func;
pZip->m_zip_mode = MZ_ZIP_MODE_READING;
pZip->m_archive_size = 0;
pZip->m_central_directory_file_ofs = 0;
pZip->m_total_files = 0;
if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
return MZ_FALSE;
memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32));
return MZ_TRUE;
}
static MZ_FORCEINLINE mz_bool mz_zip_reader_filename_less(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, mz_uint r_index)
{
const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
const mz_uint8 *pR = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, r_index));
mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS), r_len = MZ_READ_LE16(pR + MZ_ZIP_CDH_FILENAME_LEN_OFS);
mz_uint8 l = 0, r = 0;
pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE; pR += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
pE = pL + MZ_MIN(l_len, r_len);
while (pL < pE)
{
if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))
break;
pL++; pR++;
}
return (pL == pE) ? (l_len < r_len) : (l < r);
}
#define MZ_SWAP_UINT32(a, b) do { mz_uint32 t = a; a = b; b = t; } MZ_MACRO_END
// Heap sort of lowercased filenames, used to help accelerate plain central directory searches by mz_zip_reader_locate_file(). (Could also use qsort(), but it could allocate memory.)
static void mz_zip_reader_sort_central_dir_offsets_by_filename(mz_zip_archive *pZip)
{
mz_zip_internal_state *pState = pZip->m_pState;
const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
const mz_zip_array *pCentral_dir = &pState->m_central_dir;
mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
const int size = pZip->m_total_files;
int start = (size - 2) >> 1, end;
while (start >= 0)
{
int child, root = start;
for ( ; ; )
{
if ((child = (root << 1) + 1) >= size)
break;
child += (((child + 1) < size) && (mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1])));
if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
break;
MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child;
}
start--;
}
end = size - 1;
while (end > 0)
{
int child, root = 0;
MZ_SWAP_UINT32(pIndices[end], pIndices[0]);
for ( ; ; )
{
if ((child = (root << 1) + 1) >= end)
break;
child += (((child + 1) < end) && mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[child], pIndices[child + 1]));
if (!mz_zip_reader_filename_less(pCentral_dir, pCentral_dir_offsets, pIndices[root], pIndices[child]))
break;
MZ_SWAP_UINT32(pIndices[root], pIndices[child]); root = child;
}
end--;
}
}
static mz_bool mz_zip_reader_read_central_dir(mz_zip_archive *pZip, mz_uint32 flags)
{
mz_uint cdir_size, num_this_disk, cdir_disk_index;
mz_uint64 cdir_ofs;
mz_int64 cur_file_ofs;
const mz_uint8 *p;
mz_uint32 buf_u32[4096 / sizeof(mz_uint32)]; mz_uint8 *pBuf = (mz_uint8 *)buf_u32;
mz_bool sort_central_dir = ((flags & MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY) == 0);
// Basic sanity checks - reject files which are too small, and check the first 4 bytes of the file to make sure a local header is there.
if (pZip->m_archive_size < MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
return MZ_FALSE;
// Find the end of central directory record by scanning the file from the end towards the beginning.
cur_file_ofs = MZ_MAX((mz_int64)pZip->m_archive_size - (mz_int64)sizeof(buf_u32), 0);
for ( ; ; )
{
int i, n = (int)MZ_MIN(sizeof(buf_u32), pZip->m_archive_size - cur_file_ofs);
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, n) != (mz_uint)n)
return MZ_FALSE;
for (i = n - 4; i >= 0; --i)
if (MZ_READ_LE32(pBuf + i) == MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG)
break;
if (i >= 0)
{
cur_file_ofs += i;
break;
}
if ((!cur_file_ofs) || ((pZip->m_archive_size - cur_file_ofs) >= (0xFFFF + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)))
return MZ_FALSE;
cur_file_ofs = MZ_MAX(cur_file_ofs - (sizeof(buf_u32) - 3), 0);
}
// Read and verify the end of central directory record.
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE)
return MZ_FALSE;
if ((MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_SIG_OFS) != MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG) ||
((pZip->m_total_files = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS)) != MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS)))
return MZ_FALSE;
num_this_disk = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_THIS_DISK_OFS);
cdir_disk_index = MZ_READ_LE16(pBuf + MZ_ZIP_ECDH_NUM_DISK_CDIR_OFS);
if (((num_this_disk | cdir_disk_index) != 0) && ((num_this_disk != 1) || (cdir_disk_index != 1)))
return MZ_FALSE;
if ((cdir_size = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_SIZE_OFS)) < pZip->m_total_files * MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)
return MZ_FALSE;
cdir_ofs = MZ_READ_LE32(pBuf + MZ_ZIP_ECDH_CDIR_OFS_OFS);
if ((cdir_ofs + (mz_uint64)cdir_size) > pZip->m_archive_size)
return MZ_FALSE;
pZip->m_central_directory_file_ofs = cdir_ofs;
if (pZip->m_total_files)
{
mz_uint i, n;
// Read the entire central directory into a heap block, and allocate another heap block to hold the unsorted central dir file record offsets, and another to hold the sorted indices.
if ((!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir, cdir_size, MZ_FALSE)) ||
(!mz_zip_array_resize(pZip, &pZip->m_pState->m_central_dir_offsets, pZip->m_total_files, MZ_FALSE)))
return MZ_FALSE;
if (sort_central_dir)
{
if (!mz_zip_array_resize(pZip, &pZip->m_pState->m_sorted_central_dir_offsets, pZip->m_total_files, MZ_FALSE))
return MZ_FALSE;
}
if (pZip->m_pRead(pZip->m_pIO_opaque, cdir_ofs, pZip->m_pState->m_central_dir.m_p, cdir_size) != cdir_size)
return MZ_FALSE;
// Now create an index into the central directory file records, do some basic sanity checking on each record, and check for zip64 entries (which are not yet supported).
p = (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p;
for (n = cdir_size, i = 0; i < pZip->m_total_files; ++i)
{
mz_uint total_header_size, comp_size, decomp_size, disk_index;
if ((n < MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) || (MZ_READ_LE32(p) != MZ_ZIP_CENTRAL_DIR_HEADER_SIG))
return MZ_FALSE;
MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, i) = (mz_uint32)(p - (const mz_uint8 *)pZip->m_pState->m_central_dir.m_p);
if (sort_central_dir)
MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_sorted_central_dir_offsets, mz_uint32, i) = i;
comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
decomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
if (((!MZ_READ_LE32(p + MZ_ZIP_CDH_METHOD_OFS)) && (decomp_size != comp_size)) || (decomp_size && !comp_size) || (decomp_size == 0xFFFFFFFF) || (comp_size == 0xFFFFFFFF))
return MZ_FALSE;
disk_index = MZ_READ_LE16(p + MZ_ZIP_CDH_DISK_START_OFS);
if ((disk_index != num_this_disk) && (disk_index != 1))
return MZ_FALSE;
if (((mz_uint64)MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS) + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + comp_size) > pZip->m_archive_size)
return MZ_FALSE;
if ((total_header_size = MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS)) > n)
return MZ_FALSE;
n -= total_header_size; p += total_header_size;
}
}
if (sort_central_dir)
mz_zip_reader_sort_central_dir_offsets_by_filename(pZip);
return MZ_TRUE;
}
mz_bool mz_zip_reader_init(mz_zip_archive *pZip, mz_uint64 size, mz_uint32 flags)
{
if ((!pZip) || (!pZip->m_pRead))
return MZ_FALSE;
if (!mz_zip_reader_init_internal(pZip, flags))
return MZ_FALSE;
pZip->m_archive_size = size;
if (!mz_zip_reader_read_central_dir(pZip, flags))
{
mz_zip_reader_end(pZip);
return MZ_FALSE;
}
return MZ_TRUE;
}
static size_t mz_zip_mem_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
{
mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
size_t s = (file_ofs >= pZip->m_archive_size) ? 0 : (size_t)MZ_MIN(pZip->m_archive_size - file_ofs, n);
memcpy(pBuf, (const mz_uint8 *)pZip->m_pState->m_pMem + file_ofs, s);
return s;
}
mz_bool mz_zip_reader_init_mem(mz_zip_archive *pZip, const void *pMem, size_t size, mz_uint32 flags)
{
if (!mz_zip_reader_init_internal(pZip, flags))
return MZ_FALSE;
pZip->m_archive_size = size;
pZip->m_pRead = mz_zip_mem_read_func;
pZip->m_pIO_opaque = pZip;
#ifdef __cplusplus
pZip->m_pState->m_pMem = const_cast<void *>(pMem);
#else
pZip->m_pState->m_pMem = (void *)pMem;
#endif
pZip->m_pState->m_mem_size = size;
if (!mz_zip_reader_read_central_dir(pZip, flags))
{
mz_zip_reader_end(pZip);
return MZ_FALSE;
}
return MZ_TRUE;
}
#ifndef MINIZ_NO_STDIO
static size_t mz_zip_file_read_func(void *pOpaque, mz_uint64 file_ofs, void *pBuf, size_t n)
{
mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);
if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))
return 0;
return MZ_FREAD(pBuf, 1, n, pZip->m_pState->m_pFile);
}
mz_bool mz_zip_reader_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint32 flags)
{
mz_uint64 file_size;
MZ_FILE *pFile = MZ_FOPEN(pFilename, "rb");
if (!pFile)
return MZ_FALSE;
if (MZ_FSEEK64(pFile, 0, SEEK_END))
{
MZ_FCLOSE(pFile);
return MZ_FALSE;
}
file_size = MZ_FTELL64(pFile);
if (!mz_zip_reader_init_internal(pZip, flags))
{
MZ_FCLOSE(pFile);
return MZ_FALSE;
}
pZip->m_pRead = mz_zip_file_read_func;
pZip->m_pIO_opaque = pZip;
pZip->m_pState->m_pFile = pFile;
pZip->m_archive_size = file_size;
if (!mz_zip_reader_read_central_dir(pZip, flags))
{
mz_zip_reader_end(pZip);
return MZ_FALSE;
}
return MZ_TRUE;
}
#endif // #ifndef MINIZ_NO_STDIO
mz_uint mz_zip_reader_get_num_files(mz_zip_archive *pZip)
{
return pZip ? pZip->m_total_files : 0;
}
static MZ_FORCEINLINE const mz_uint8 *mz_zip_reader_get_cdh(mz_zip_archive *pZip, mz_uint file_index)
{
if ((!pZip) || (!pZip->m_pState) || (file_index >= pZip->m_total_files) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
return NULL;
return &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
}
mz_bool mz_zip_reader_is_file_encrypted(mz_zip_archive *pZip, mz_uint file_index)
{
mz_uint m_bit_flag;
const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
if (!p)
return MZ_FALSE;
m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
return (m_bit_flag & 1);
}
mz_bool mz_zip_reader_is_file_a_directory(mz_zip_archive *pZip, mz_uint file_index)
{
mz_uint filename_len, external_attr;
const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
if (!p)
return MZ_FALSE;
// First see if the filename ends with a '/' character.
filename_len = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
if (filename_len)
{
if (*(p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_len - 1) == '/')
return MZ_TRUE;
}
// Bugfix: This code was also checking if the internal attribute was non-zero, which wasn't correct.
// Most/all zip writers (hopefully) set DOS file/directory attributes in the low 16-bits, so check for the DOS directory flag and ignore the source OS ID in the created by field.
// FIXME: Remove this check? Is it necessary - we already check the filename.
external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);
if ((external_attr & 0x10) != 0)
return MZ_TRUE;
return MZ_FALSE;
}
mz_bool mz_zip_reader_file_stat(mz_zip_archive *pZip, mz_uint file_index, mz_zip_archive_file_stat *pStat)
{
mz_uint n;
const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
if ((!p) || (!pStat))
return MZ_FALSE;
// Unpack the central directory record.
pStat->m_file_index = file_index;
pStat->m_central_dir_ofs = MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index);
pStat->m_version_made_by = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_MADE_BY_OFS);
pStat->m_version_needed = MZ_READ_LE16(p + MZ_ZIP_CDH_VERSION_NEEDED_OFS);
pStat->m_bit_flag = MZ_READ_LE16(p + MZ_ZIP_CDH_BIT_FLAG_OFS);
pStat->m_method = MZ_READ_LE16(p + MZ_ZIP_CDH_METHOD_OFS);
#ifndef MINIZ_NO_TIME
pStat->m_time = mz_zip_dos_to_time_t(MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_TIME_OFS), MZ_READ_LE16(p + MZ_ZIP_CDH_FILE_DATE_OFS));
#endif
pStat->m_crc32 = MZ_READ_LE32(p + MZ_ZIP_CDH_CRC32_OFS);
pStat->m_comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
pStat->m_uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
pStat->m_internal_attr = MZ_READ_LE16(p + MZ_ZIP_CDH_INTERNAL_ATTR_OFS);
pStat->m_external_attr = MZ_READ_LE32(p + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS);
pStat->m_local_header_ofs = MZ_READ_LE32(p + MZ_ZIP_CDH_LOCAL_HEADER_OFS);
// Copy as much of the filename and comment as possible.
n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILENAME_SIZE - 1);
memcpy(pStat->m_filename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n); pStat->m_filename[n] = '\0';
n = MZ_READ_LE16(p + MZ_ZIP_CDH_COMMENT_LEN_OFS); n = MZ_MIN(n, MZ_ZIP_MAX_ARCHIVE_FILE_COMMENT_SIZE - 1);
pStat->m_comment_size = n;
memcpy(pStat->m_comment, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(p + MZ_ZIP_CDH_EXTRA_LEN_OFS), n); pStat->m_comment[n] = '\0';
return MZ_TRUE;
}
mz_uint mz_zip_reader_get_filename(mz_zip_archive *pZip, mz_uint file_index, char *pFilename, mz_uint filename_buf_size)
{
mz_uint n;
const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
if (!p) { if (filename_buf_size) pFilename[0] = '\0'; return 0; }
n = MZ_READ_LE16(p + MZ_ZIP_CDH_FILENAME_LEN_OFS);
if (filename_buf_size)
{
n = MZ_MIN(n, filename_buf_size - 1);
memcpy(pFilename, p + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n);
pFilename[n] = '\0';
}
return n + 1;
}
static MZ_FORCEINLINE mz_bool mz_zip_reader_string_equal(const char *pA, const char *pB, mz_uint len, mz_uint flags)
{
mz_uint i;
if (flags & MZ_ZIP_FLAG_CASE_SENSITIVE)
return 0 == memcmp(pA, pB, len);
for (i = 0; i < len; ++i)
if (MZ_TOLOWER(pA[i]) != MZ_TOLOWER(pB[i]))
return MZ_FALSE;
return MZ_TRUE;
}
static MZ_FORCEINLINE int mz_zip_reader_filename_compare(const mz_zip_array *pCentral_dir_array, const mz_zip_array *pCentral_dir_offsets, mz_uint l_index, const char *pR, mz_uint r_len)
{
const mz_uint8 *pL = &MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_array, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(pCentral_dir_offsets, mz_uint32, l_index)), *pE;
mz_uint l_len = MZ_READ_LE16(pL + MZ_ZIP_CDH_FILENAME_LEN_OFS);
mz_uint8 l = 0, r = 0;
pL += MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
pE = pL + MZ_MIN(l_len, r_len);
while (pL < pE)
{
if ((l = MZ_TOLOWER(*pL)) != (r = MZ_TOLOWER(*pR)))
break;
pL++; pR++;
}
return (pL == pE) ? (int)(l_len - r_len) : (l - r);
}
static int mz_zip_reader_locate_file_binary_search(mz_zip_archive *pZip, const char *pFilename)
{
mz_zip_internal_state *pState = pZip->m_pState;
const mz_zip_array *pCentral_dir_offsets = &pState->m_central_dir_offsets;
const mz_zip_array *pCentral_dir = &pState->m_central_dir;
mz_uint32 *pIndices = &MZ_ZIP_ARRAY_ELEMENT(&pState->m_sorted_central_dir_offsets, mz_uint32, 0);
const int size = pZip->m_total_files;
const mz_uint filename_len = (mz_uint)strlen(pFilename);
int l = 0, h = size - 1;
while (l <= h)
{
int m = (l + h) >> 1, file_index = pIndices[m], comp = mz_zip_reader_filename_compare(pCentral_dir, pCentral_dir_offsets, file_index, pFilename, filename_len);
if (!comp)
return file_index;
else if (comp < 0)
l = m + 1;
else
h = m - 1;
}
return -1;
}
int mz_zip_reader_locate_file(mz_zip_archive *pZip, const char *pName, const char *pComment, mz_uint flags)
{
mz_uint file_index; size_t name_len, comment_len;
if ((!pZip) || (!pZip->m_pState) || (!pName) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
return -1;
if (((flags & (MZ_ZIP_FLAG_IGNORE_PATH | MZ_ZIP_FLAG_CASE_SENSITIVE)) == 0) && (!pComment) && (pZip->m_pState->m_sorted_central_dir_offsets.m_size))
return mz_zip_reader_locate_file_binary_search(pZip, pName);
name_len = strlen(pName); if (name_len > 0xFFFF) return -1;
comment_len = pComment ? strlen(pComment) : 0; if (comment_len > 0xFFFF) return -1;
for (file_index = 0; file_index < pZip->m_total_files; file_index++)
{
const mz_uint8 *pHeader = &MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir, mz_uint8, MZ_ZIP_ARRAY_ELEMENT(&pZip->m_pState->m_central_dir_offsets, mz_uint32, file_index));
mz_uint filename_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_FILENAME_LEN_OFS);
const char *pFilename = (const char *)pHeader + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE;
if (filename_len < name_len)
continue;
if (comment_len)
{
mz_uint file_extra_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_EXTRA_LEN_OFS), file_comment_len = MZ_READ_LE16(pHeader + MZ_ZIP_CDH_COMMENT_LEN_OFS);
const char *pFile_comment = pFilename + filename_len + file_extra_len;
if ((file_comment_len != comment_len) || (!mz_zip_reader_string_equal(pComment, pFile_comment, file_comment_len, flags)))
continue;
}
if ((flags & MZ_ZIP_FLAG_IGNORE_PATH) && (filename_len))
{
int ofs = filename_len - 1;
do
{
if ((pFilename[ofs] == '/') || (pFilename[ofs] == '\\') || (pFilename[ofs] == ':'))
break;
} while (--ofs >= 0);
ofs++;
pFilename += ofs; filename_len -= ofs;
}
if ((filename_len == name_len) && (mz_zip_reader_string_equal(pName, pFilename, filename_len, flags)))
return file_index;
}
return -1;
}
mz_bool mz_zip_reader_extract_to_mem_no_alloc(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
{
int status = TINFL_STATUS_DONE;
mz_uint64 needed_size, cur_file_ofs, comp_remaining, out_buf_ofs = 0, read_buf_size, read_buf_ofs = 0, read_buf_avail;
mz_zip_archive_file_stat file_stat;
void *pRead_buf;
mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
tinfl_decompressor inflator;
if ((buf_size) && (!pBuf))
return MZ_FALSE;
if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
return MZ_FALSE;
// Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes)
if (!file_stat.m_comp_size)
return MZ_TRUE;
// Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers).
// I'm torn how to handle this case - should it fail instead?
if (mz_zip_reader_is_file_a_directory(pZip, file_index))
return MZ_TRUE;
// Encryption and patch files are not supported.
if (file_stat.m_bit_flag & (1 | 32))
return MZ_FALSE;
// This function only supports stored and deflate.
if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED))
return MZ_FALSE;
// Ensure supplied output buffer is large enough.
needed_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? file_stat.m_comp_size : file_stat.m_uncomp_size;
if (buf_size < needed_size)
return MZ_FALSE;
// Read and parse the local directory entry.
cur_file_ofs = file_stat.m_local_header_ofs;
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
return MZ_FALSE;
if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
return MZ_FALSE;
cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)
return MZ_FALSE;
if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method))
{
// The file is stored or the caller has requested the compressed data.
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pBuf, (size_t)needed_size) != needed_size)
return MZ_FALSE;
return ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) != 0) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) == file_stat.m_crc32);
}
// Decompress the file either directly from memory or from a file input buffer.
tinfl_init(&inflator);
if (pZip->m_pState->m_pMem)
{
// Read directly from the archive in memory.
pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;
read_buf_size = read_buf_avail = file_stat.m_comp_size;
comp_remaining = 0;
}
else if (pUser_read_buf)
{
// Use a user provided read buffer.
if (!user_read_buf_size)
return MZ_FALSE;
pRead_buf = (mz_uint8 *)pUser_read_buf;
read_buf_size = user_read_buf_size;
read_buf_avail = 0;
comp_remaining = file_stat.m_comp_size;
}
else
{
// Temporarily allocate a read buffer.
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) && (read_buf_size > 0x7FFFFFFF))
#endif
return MZ_FALSE;
if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
return MZ_FALSE;
read_buf_avail = 0;
comp_remaining = file_stat.m_comp_size;
}
do
{
size_t in_buf_size, out_buf_size = (size_t)(file_stat.m_uncomp_size - out_buf_ofs);
if ((!read_buf_avail) && (!pZip->m_pState->m_pMem))
{
read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
{
status = TINFL_STATUS_FAILED;
break;
}
cur_file_ofs += read_buf_avail;
comp_remaining -= read_buf_avail;
read_buf_ofs = 0;
}
in_buf_size = (size_t)read_buf_avail;
status = tinfl_decompress(&inflator, (mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pBuf, (mz_uint8 *)pBuf + out_buf_ofs, &out_buf_size, TINFL_FLAG_USING_NON_WRAPPING_OUTPUT_BUF | (comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0));
read_buf_avail -= in_buf_size;
read_buf_ofs += in_buf_size;
out_buf_ofs += out_buf_size;
} while (status == TINFL_STATUS_NEEDS_MORE_INPUT);
if (status == TINFL_STATUS_DONE)
{
// Make sure the entire file was decompressed, and check its CRC.
if ((out_buf_ofs != file_stat.m_uncomp_size) || (mz_crc32(MZ_CRC32_INIT, (const mz_uint8 *)pBuf, (size_t)file_stat.m_uncomp_size) != file_stat.m_crc32))
status = TINFL_STATUS_FAILED;
}
if ((!pZip->m_pState->m_pMem) && (!pUser_read_buf))
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
return status == TINFL_STATUS_DONE;
}
mz_bool mz_zip_reader_extract_file_to_mem_no_alloc(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags, void *pUser_read_buf, size_t user_read_buf_size)
{
int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);
if (file_index < 0)
return MZ_FALSE;
return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, pUser_read_buf, user_read_buf_size);
}
mz_bool mz_zip_reader_extract_to_mem(mz_zip_archive *pZip, mz_uint file_index, void *pBuf, size_t buf_size, mz_uint flags)
{
return mz_zip_reader_extract_to_mem_no_alloc(pZip, file_index, pBuf, buf_size, flags, NULL, 0);
}
mz_bool mz_zip_reader_extract_file_to_mem(mz_zip_archive *pZip, const char *pFilename, void *pBuf, size_t buf_size, mz_uint flags)
{
return mz_zip_reader_extract_file_to_mem_no_alloc(pZip, pFilename, pBuf, buf_size, flags, NULL, 0);
}
void *mz_zip_reader_extract_to_heap(mz_zip_archive *pZip, mz_uint file_index, size_t *pSize, mz_uint flags)
{
mz_uint64 comp_size, uncomp_size, alloc_size;
const mz_uint8 *p = mz_zip_reader_get_cdh(pZip, file_index);
void *pBuf;
if (pSize)
*pSize = 0;
if (!p)
return NULL;
comp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
uncomp_size = MZ_READ_LE32(p + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS);
alloc_size = (flags & MZ_ZIP_FLAG_COMPRESSED_DATA) ? comp_size : uncomp_size;
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) && (alloc_size > 0x7FFFFFFF))
#endif
return NULL;
if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)alloc_size)))
return NULL;
if (!mz_zip_reader_extract_to_mem(pZip, file_index, pBuf, (size_t)alloc_size, flags))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
return NULL;
}
if (pSize) *pSize = (size_t)alloc_size;
return pBuf;
}
void *mz_zip_reader_extract_file_to_heap(mz_zip_archive *pZip, const char *pFilename, size_t *pSize, mz_uint flags)
{
int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);
if (file_index < 0)
{
if (pSize) *pSize = 0;
return MZ_FALSE;
}
return mz_zip_reader_extract_to_heap(pZip, file_index, pSize, flags);
}
mz_bool mz_zip_reader_extract_to_callback(mz_zip_archive *pZip, mz_uint file_index, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
{
int status = TINFL_STATUS_DONE; mz_uint file_crc32 = MZ_CRC32_INIT;
mz_uint64 read_buf_size, read_buf_ofs = 0, read_buf_avail, comp_remaining, out_buf_ofs = 0, cur_file_ofs;
mz_zip_archive_file_stat file_stat;
void *pRead_buf = NULL; void *pWrite_buf = NULL;
mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
return MZ_FALSE;
// Empty file, or a directory (but not always a directory - I've seen odd zips with directories that have compressed data which inflates to 0 bytes)
if (!file_stat.m_comp_size)
return MZ_TRUE;
// Entry is a subdirectory (I've seen old zips with dir entries which have compressed deflate data which inflates to 0 bytes, but these entries claim to uncompress to 512 bytes in the headers).
// I'm torn how to handle this case - should it fail instead?
if (mz_zip_reader_is_file_a_directory(pZip, file_index))
return MZ_TRUE;
// Encryption and patch files are not supported.
if (file_stat.m_bit_flag & (1 | 32))
return MZ_FALSE;
// This function only supports stored and deflate.
if ((!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (file_stat.m_method != 0) && (file_stat.m_method != MZ_DEFLATED))
return MZ_FALSE;
// Read and parse the local directory entry.
cur_file_ofs = file_stat.m_local_header_ofs;
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
return MZ_FALSE;
if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
return MZ_FALSE;
cur_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
if ((cur_file_ofs + file_stat.m_comp_size) > pZip->m_archive_size)
return MZ_FALSE;
// Decompress the file either directly from memory or from a file input buffer.
if (pZip->m_pState->m_pMem)
{
pRead_buf = (mz_uint8 *)pZip->m_pState->m_pMem + cur_file_ofs;
read_buf_size = read_buf_avail = file_stat.m_comp_size;
comp_remaining = 0;
}
else
{
read_buf_size = MZ_MIN(file_stat.m_comp_size, MZ_ZIP_MAX_IO_BUF_SIZE);
if (NULL == (pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)read_buf_size)))
return MZ_FALSE;
read_buf_avail = 0;
comp_remaining = file_stat.m_comp_size;
}
if ((flags & MZ_ZIP_FLAG_COMPRESSED_DATA) || (!file_stat.m_method))
{
// The file is stored or the caller has requested the compressed data.
if (pZip->m_pState->m_pMem)
{
#ifdef _MSC_VER
if (((0, sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF))
#else
if (((sizeof(size_t) == sizeof(mz_uint32))) && (file_stat.m_comp_size > 0xFFFFFFFF))
#endif
return MZ_FALSE;
if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)file_stat.m_comp_size) != file_stat.m_comp_size)
status = TINFL_STATUS_FAILED;
else if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)file_stat.m_comp_size);
cur_file_ofs += file_stat.m_comp_size;
out_buf_ofs += file_stat.m_comp_size;
comp_remaining = 0;
}
else
{
while (comp_remaining)
{
read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
{
status = TINFL_STATUS_FAILED;
break;
}
if (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
file_crc32 = (mz_uint32)mz_crc32(file_crc32, (const mz_uint8 *)pRead_buf, (size_t)read_buf_avail);
if (pCallback(pOpaque, out_buf_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
{
status = TINFL_STATUS_FAILED;
break;
}
cur_file_ofs += read_buf_avail;
out_buf_ofs += read_buf_avail;
comp_remaining -= read_buf_avail;
}
}
}
else
{
tinfl_decompressor inflator;
tinfl_init(&inflator);
if (NULL == (pWrite_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, TINFL_LZ_DICT_SIZE)))
status = TINFL_STATUS_FAILED;
else
{
do
{
mz_uint8 *pWrite_buf_cur = (mz_uint8 *)pWrite_buf + (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
size_t in_buf_size, out_buf_size = TINFL_LZ_DICT_SIZE - (out_buf_ofs & (TINFL_LZ_DICT_SIZE - 1));
if ((!read_buf_avail) && (!pZip->m_pState->m_pMem))
{
read_buf_avail = MZ_MIN(read_buf_size, comp_remaining);
if (pZip->m_pRead(pZip->m_pIO_opaque, cur_file_ofs, pRead_buf, (size_t)read_buf_avail) != read_buf_avail)
{
status = TINFL_STATUS_FAILED;
break;
}
cur_file_ofs += read_buf_avail;
comp_remaining -= read_buf_avail;
read_buf_ofs = 0;
}
in_buf_size = (size_t)read_buf_avail;
status = tinfl_decompress(&inflator, (const mz_uint8 *)pRead_buf + read_buf_ofs, &in_buf_size, (mz_uint8 *)pWrite_buf, pWrite_buf_cur, &out_buf_size, comp_remaining ? TINFL_FLAG_HAS_MORE_INPUT : 0);
read_buf_avail -= in_buf_size;
read_buf_ofs += in_buf_size;
if (out_buf_size)
{
if (pCallback(pOpaque, out_buf_ofs, pWrite_buf_cur, out_buf_size) != out_buf_size)
{
status = TINFL_STATUS_FAILED;
break;
}
file_crc32 = (mz_uint32)mz_crc32(file_crc32, pWrite_buf_cur, out_buf_size);
if ((out_buf_ofs += out_buf_size) > file_stat.m_uncomp_size)
{
status = TINFL_STATUS_FAILED;
break;
}
}
} while ((status == TINFL_STATUS_NEEDS_MORE_INPUT) || (status == TINFL_STATUS_HAS_MORE_OUTPUT));
}
}
if ((status == TINFL_STATUS_DONE) && (!(flags & MZ_ZIP_FLAG_COMPRESSED_DATA)))
{
// Make sure the entire file was decompressed, and check its CRC.
if ((out_buf_ofs != file_stat.m_uncomp_size) || (file_crc32 != file_stat.m_crc32))
status = TINFL_STATUS_FAILED;
}
if (!pZip->m_pState->m_pMem)
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
if (pWrite_buf)
pZip->m_pFree(pZip->m_pAlloc_opaque, pWrite_buf);
return status == TINFL_STATUS_DONE;
}
mz_bool mz_zip_reader_extract_file_to_callback(mz_zip_archive *pZip, const char *pFilename, mz_file_write_func pCallback, void *pOpaque, mz_uint flags)
{
int file_index = mz_zip_reader_locate_file(pZip, pFilename, NULL, flags);
if (file_index < 0)
return MZ_FALSE;
return mz_zip_reader_extract_to_callback(pZip, file_index, pCallback, pOpaque, flags);
}
#ifndef MINIZ_NO_STDIO
static size_t mz_zip_file_write_callback(void *pOpaque, mz_uint64 ofs, const void *pBuf, size_t n)
{
(void)ofs; return MZ_FWRITE(pBuf, 1, n, (MZ_FILE*)pOpaque);
}
mz_bool mz_zip_reader_extract_to_file(mz_zip_archive *pZip, mz_uint file_index, const char *pDst_filename, mz_uint flags)
{
mz_bool status;
mz_zip_archive_file_stat file_stat;
MZ_FILE *pFile;
if (!mz_zip_reader_file_stat(pZip, file_index, &file_stat))
return MZ_FALSE;
pFile = MZ_FOPEN(pDst_filename, "wb");
if (!pFile)
return MZ_FALSE;
status = mz_zip_reader_extract_to_callback(pZip, file_index, mz_zip_file_write_callback, pFile, flags);
if (MZ_FCLOSE(pFile) == EOF)
return MZ_FALSE;
#ifndef MINIZ_NO_TIME
if (status)
mz_zip_set_file_times(pDst_filename, file_stat.m_time, file_stat.m_time);
#endif
return status;
}
#endif // #ifndef MINIZ_NO_STDIO
mz_bool mz_zip_reader_end(mz_zip_archive *pZip)
{
if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
return MZ_FALSE;
if (pZip->m_pState)
{
mz_zip_internal_state *pState = pZip->m_pState; pZip->m_pState = NULL;
mz_zip_array_clear(pZip, &pState->m_central_dir);
mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);
mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);
#ifndef MINIZ_NO_STDIO
if (pState->m_pFile)
{
MZ_FCLOSE(pState->m_pFile);
pState->m_pFile = NULL;
}
#endif // #ifndef MINIZ_NO_STDIO
pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
}
pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;
return MZ_TRUE;
}
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_reader_extract_file_to_file(mz_zip_archive *pZip, const char *pArchive_filename, const char *pDst_filename, mz_uint flags)
{
int file_index = mz_zip_reader_locate_file(pZip, pArchive_filename, NULL, flags);
if (file_index < 0)
return MZ_FALSE;
return mz_zip_reader_extract_to_file(pZip, file_index, pDst_filename, flags);
}
#endif
// ------------------- .ZIP archive writing
#ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
static void mz_write_le16(mz_uint8 *p, mz_uint16 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); }
static void mz_write_le32(mz_uint8 *p, mz_uint32 v) { p[0] = (mz_uint8)v; p[1] = (mz_uint8)(v >> 8); p[2] = (mz_uint8)(v >> 16); p[3] = (mz_uint8)(v >> 24); }
#define MZ_WRITE_LE16(p, v) mz_write_le16((mz_uint8 *)(p), (mz_uint16)(v))
#define MZ_WRITE_LE32(p, v) mz_write_le32((mz_uint8 *)(p), (mz_uint32)(v))
mz_bool mz_zip_writer_init(mz_zip_archive *pZip, mz_uint64 existing_size)
{
if ((!pZip) || (pZip->m_pState) || (!pZip->m_pWrite) || (pZip->m_zip_mode != MZ_ZIP_MODE_INVALID))
return MZ_FALSE;
if (pZip->m_file_offset_alignment)
{
// Ensure user specified file offset alignment is a power of 2.
if (pZip->m_file_offset_alignment & (pZip->m_file_offset_alignment - 1))
return MZ_FALSE;
}
if (!pZip->m_pAlloc) pZip->m_pAlloc = def_alloc_func;
if (!pZip->m_pFree) pZip->m_pFree = def_free_func;
if (!pZip->m_pRealloc) pZip->m_pRealloc = def_realloc_func;
pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
pZip->m_archive_size = existing_size;
pZip->m_central_directory_file_ofs = 0;
pZip->m_total_files = 0;
if (NULL == (pZip->m_pState = (mz_zip_internal_state *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(mz_zip_internal_state))))
return MZ_FALSE;
memset(pZip->m_pState, 0, sizeof(mz_zip_internal_state));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir, sizeof(mz_uint8));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_central_dir_offsets, sizeof(mz_uint32));
MZ_ZIP_ARRAY_SET_ELEMENT_SIZE(&pZip->m_pState->m_sorted_central_dir_offsets, sizeof(mz_uint32));
return MZ_TRUE;
}
static size_t mz_zip_heap_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
{
mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
mz_zip_internal_state *pState = pZip->m_pState;
mz_uint64 new_size = MZ_MAX(file_ofs + n, pState->m_mem_size);
#ifdef _MSC_VER
if ((!n) || ((0, sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))
#else
if ((!n) || ((sizeof(size_t) == sizeof(mz_uint32)) && (new_size > 0x7FFFFFFF)))
#endif
return 0;
if (new_size > pState->m_mem_capacity)
{
void *pNew_block;
size_t new_capacity = MZ_MAX(64, pState->m_mem_capacity); while (new_capacity < new_size) new_capacity *= 2;
if (NULL == (pNew_block = pZip->m_pRealloc(pZip->m_pAlloc_opaque, pState->m_pMem, 1, new_capacity)))
return 0;
pState->m_pMem = pNew_block; pState->m_mem_capacity = new_capacity;
}
memcpy((mz_uint8 *)pState->m_pMem + file_ofs, pBuf, n);
pState->m_mem_size = (size_t)new_size;
return n;
}
mz_bool mz_zip_writer_init_heap(mz_zip_archive *pZip, size_t size_to_reserve_at_beginning, size_t initial_allocation_size)
{
pZip->m_pWrite = mz_zip_heap_write_func;
pZip->m_pIO_opaque = pZip;
if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning))
return MZ_FALSE;
if (0 != (initial_allocation_size = MZ_MAX(initial_allocation_size, size_to_reserve_at_beginning)))
{
if (NULL == (pZip->m_pState->m_pMem = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, initial_allocation_size)))
{
mz_zip_writer_end(pZip);
return MZ_FALSE;
}
pZip->m_pState->m_mem_capacity = initial_allocation_size;
}
return MZ_TRUE;
}
#ifndef MINIZ_NO_STDIO
static size_t mz_zip_file_write_func(void *pOpaque, mz_uint64 file_ofs, const void *pBuf, size_t n)
{
mz_zip_archive *pZip = (mz_zip_archive *)pOpaque;
mz_int64 cur_ofs = MZ_FTELL64(pZip->m_pState->m_pFile);
if (((mz_int64)file_ofs < 0) || (((cur_ofs != (mz_int64)file_ofs)) && (MZ_FSEEK64(pZip->m_pState->m_pFile, (mz_int64)file_ofs, SEEK_SET))))
return 0;
return MZ_FWRITE(pBuf, 1, n, pZip->m_pState->m_pFile);
}
mz_bool mz_zip_writer_init_file(mz_zip_archive *pZip, const char *pFilename, mz_uint64 size_to_reserve_at_beginning)
{
MZ_FILE *pFile;
pZip->m_pWrite = mz_zip_file_write_func;
pZip->m_pIO_opaque = pZip;
if (!mz_zip_writer_init(pZip, size_to_reserve_at_beginning))
return MZ_FALSE;
if (NULL == (pFile = MZ_FOPEN(pFilename, "wb")))
{
mz_zip_writer_end(pZip);
return MZ_FALSE;
}
pZip->m_pState->m_pFile = pFile;
if (size_to_reserve_at_beginning)
{
mz_uint64 cur_ofs = 0; char buf[4096]; MZ_CLEAR_OBJ(buf);
do
{
size_t n = (size_t)MZ_MIN(sizeof(buf), size_to_reserve_at_beginning);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_ofs, buf, n) != n)
{
mz_zip_writer_end(pZip);
return MZ_FALSE;
}
cur_ofs += n; size_to_reserve_at_beginning -= n;
} while (size_to_reserve_at_beginning);
}
return MZ_TRUE;
}
#endif // #ifndef MINIZ_NO_STDIO
mz_bool mz_zip_writer_init_from_reader(mz_zip_archive *pZip, const char *pFilename)
{
mz_zip_internal_state *pState;
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_READING))
return MZ_FALSE;
// No sense in trying to write to an archive that's already at the support max size
if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + MZ_ZIP_LOCAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))
return MZ_FALSE;
pState = pZip->m_pState;
if (pState->m_pFile)
{
#ifdef MINIZ_NO_STDIO
pFilename; return MZ_FALSE;
#else
// Archive is being read from stdio - try to reopen as writable.
if (pZip->m_pIO_opaque != pZip)
return MZ_FALSE;
if (!pFilename)
return MZ_FALSE;
pZip->m_pWrite = mz_zip_file_write_func;
if (NULL == (pState->m_pFile = MZ_FREOPEN(pFilename, "r+b", pState->m_pFile)))
{
// The mz_zip_archive is now in a bogus state because pState->m_pFile is NULL, so just close it.
mz_zip_reader_end(pZip);
return MZ_FALSE;
}
#endif // #ifdef MINIZ_NO_STDIO
}
else if (pState->m_pMem)
{
// Archive lives in a memory block. Assume it's from the heap that we can resize using the realloc callback.
if (pZip->m_pIO_opaque != pZip)
return MZ_FALSE;
pState->m_mem_capacity = pState->m_mem_size;
pZip->m_pWrite = mz_zip_heap_write_func;
}
// Archive is being read via a user provided read function - make sure the user has specified a write function too.
else if (!pZip->m_pWrite)
return MZ_FALSE;
// Start writing new files at the archive's current central directory location.
pZip->m_archive_size = pZip->m_central_directory_file_ofs;
pZip->m_zip_mode = MZ_ZIP_MODE_WRITING;
pZip->m_central_directory_file_ofs = 0;
return MZ_TRUE;
}
mz_bool mz_zip_writer_add_mem(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, mz_uint level_and_flags)
{
return mz_zip_writer_add_mem_ex(pZip, pArchive_name, pBuf, buf_size, NULL, 0, level_and_flags, 0, 0);
}
typedef struct
{
mz_zip_archive *m_pZip;
mz_uint64 m_cur_archive_file_ofs;
mz_uint64 m_comp_size;
} mz_zip_writer_add_state;
static mz_bool mz_zip_writer_add_put_buf_callback(const void* pBuf, int len, void *pUser)
{
mz_zip_writer_add_state *pState = (mz_zip_writer_add_state *)pUser;
if ((int)pState->m_pZip->m_pWrite(pState->m_pZip->m_pIO_opaque, pState->m_cur_archive_file_ofs, pBuf, len) != len)
return MZ_FALSE;
pState->m_cur_archive_file_ofs += len;
pState->m_comp_size += len;
return MZ_TRUE;
}
static mz_bool mz_zip_writer_create_local_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date)
{
(void)pZip;
memset(pDst, 0, MZ_ZIP_LOCAL_DIR_HEADER_SIZE);
MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_SIG_OFS, MZ_ZIP_LOCAL_DIR_HEADER_SIG);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_VERSION_NEEDED_OFS, method ? 20 : 0);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_BIT_FLAG_OFS, bit_flags);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_METHOD_OFS, method);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_TIME_OFS, dos_time);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILE_DATE_OFS, dos_date);
MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_CRC32_OFS, uncomp_crc32);
MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_COMPRESSED_SIZE_OFS, comp_size);
MZ_WRITE_LE32(pDst + MZ_ZIP_LDH_DECOMPRESSED_SIZE_OFS, uncomp_size);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_FILENAME_LEN_OFS, filename_size);
MZ_WRITE_LE16(pDst + MZ_ZIP_LDH_EXTRA_LEN_OFS, extra_size);
return MZ_TRUE;
}
static mz_bool mz_zip_writer_create_central_dir_header(mz_zip_archive *pZip, mz_uint8 *pDst, mz_uint16 filename_size, mz_uint16 extra_size, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes)
{
(void)pZip;
memset(pDst, 0, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_SIG_OFS, MZ_ZIP_CENTRAL_DIR_HEADER_SIG);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_VERSION_NEEDED_OFS, method ? 20 : 0);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_BIT_FLAG_OFS, bit_flags);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_METHOD_OFS, method);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_TIME_OFS, dos_time);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILE_DATE_OFS, dos_date);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_CRC32_OFS, uncomp_crc32);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS, comp_size);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_DECOMPRESSED_SIZE_OFS, uncomp_size);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_FILENAME_LEN_OFS, filename_size);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_EXTRA_LEN_OFS, extra_size);
MZ_WRITE_LE16(pDst + MZ_ZIP_CDH_COMMENT_LEN_OFS, comment_size);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_EXTERNAL_ATTR_OFS, ext_attributes);
MZ_WRITE_LE32(pDst + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_header_ofs);
return MZ_TRUE;
}
static mz_bool mz_zip_writer_add_to_central_dir(mz_zip_archive *pZip, const char *pFilename, mz_uint16 filename_size, const void *pExtra, mz_uint16 extra_size, const void *pComment, mz_uint16 comment_size, mz_uint64 uncomp_size, mz_uint64 comp_size, mz_uint32 uncomp_crc32, mz_uint16 method, mz_uint16 bit_flags, mz_uint16 dos_time, mz_uint16 dos_date, mz_uint64 local_header_ofs, mz_uint32 ext_attributes)
{
mz_zip_internal_state *pState = pZip->m_pState;
mz_uint32 central_dir_ofs = (mz_uint32)pState->m_central_dir.m_size;
size_t orig_central_dir_size = pState->m_central_dir.m_size;
mz_uint8 central_dir_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];
// No zip64 support yet
if ((local_header_ofs > 0xFFFFFFFF) || (((mz_uint64)pState->m_central_dir.m_size + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + filename_size + extra_size + comment_size) > 0xFFFFFFFF))
return MZ_FALSE;
if (!mz_zip_writer_create_central_dir_header(pZip, central_dir_header, filename_size, extra_size, comment_size, uncomp_size, comp_size, uncomp_crc32, method, bit_flags, dos_time, dos_date, local_header_ofs, ext_attributes))
return MZ_FALSE;
if ((!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_dir_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE)) ||
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pFilename, filename_size)) ||
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pExtra, extra_size)) ||
(!mz_zip_array_push_back(pZip, &pState->m_central_dir, pComment, comment_size)) ||
(!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, ¢ral_dir_ofs, 1)))
{
// Try to push the central directory array back into its original state.
mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
return MZ_FALSE;
}
return MZ_TRUE;
}
static mz_bool mz_zip_writer_validate_archive_name(const char *pArchive_name)
{
// Basic ZIP archive filename validity checks: Valid filenames cannot start with a forward slash, cannot contain a drive letter, and cannot use DOS-style backward slashes.
if (*pArchive_name == '/')
return MZ_FALSE;
while (*pArchive_name)
{
if ((*pArchive_name == '\\') || (*pArchive_name == ':'))
return MZ_FALSE;
pArchive_name++;
}
return MZ_TRUE;
}
static mz_uint mz_zip_writer_compute_padding_needed_for_file_alignment(mz_zip_archive *pZip)
{
mz_uint32 n;
if (!pZip->m_file_offset_alignment)
return 0;
n = (mz_uint32)(pZip->m_archive_size & (pZip->m_file_offset_alignment - 1));
return (pZip->m_file_offset_alignment - n) & (pZip->m_file_offset_alignment - 1);
}
static mz_bool mz_zip_writer_write_zeros(mz_zip_archive *pZip, mz_uint64 cur_file_ofs, mz_uint32 n)
{
char buf[4096];
memset(buf, 0, MZ_MIN(sizeof(buf), n));
while (n)
{
mz_uint32 s = MZ_MIN(sizeof(buf), n);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_file_ofs, buf, s) != s)
return MZ_FALSE;
cur_file_ofs += s; n -= s;
}
return MZ_TRUE;
}
mz_bool mz_zip_writer_add_mem_ex(mz_zip_archive *pZip, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags, mz_uint64 uncomp_size, mz_uint32 uncomp_crc32)
{
mz_uint16 method = 0, dos_time = 0, dos_date = 0;
mz_uint level, ext_attributes = 0, num_alignment_padding_bytes;
mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, comp_size = 0;
size_t archive_name_size;
mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
tdefl_compressor *pComp = NULL;
mz_bool store_data_uncompressed;
mz_zip_internal_state *pState;
if ((int)level_and_flags < 0)
level_and_flags = MZ_DEFAULT_LEVEL;
level = level_and_flags & 0xF;
store_data_uncompressed = ((!level) || (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA));
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || ((buf_size) && (!pBuf)) || (!pArchive_name) || ((comment_size) && (!pComment)) || (pZip->m_total_files == 0xFFFF) || (level > MZ_UBER_COMPRESSION))
return MZ_FALSE;
pState = pZip->m_pState;
if ((!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)) && (uncomp_size))
return MZ_FALSE;
// No zip64 support yet
if ((buf_size > 0xFFFFFFFF) || (uncomp_size > 0xFFFFFFFF))
return MZ_FALSE;
if (!mz_zip_writer_validate_archive_name(pArchive_name))
return MZ_FALSE;
#ifndef MINIZ_NO_TIME
{
time_t cur_time; time(&cur_time);
mz_zip_time_to_dos_time(cur_time, &dos_time, &dos_date);
}
#endif // #ifndef MINIZ_NO_TIME
archive_name_size = strlen(pArchive_name);
if (archive_name_size > 0xFFFF)
return MZ_FALSE;
num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
// no zip64 support yet
if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF))
return MZ_FALSE;
if ((archive_name_size) && (pArchive_name[archive_name_size - 1] == '/'))
{
// Set DOS Subdirectory attribute bit.
ext_attributes |= 0x10;
// Subdirectories cannot contain data.
if ((buf_size) || (uncomp_size))
return MZ_FALSE;
}
// Try to do any allocations before writing to the archive, so if an allocation fails the file remains unmodified. (A good idea if we're doing an in-place modification.)
if ((!mz_zip_array_ensure_room(pZip, &pState->m_central_dir, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + archive_name_size + comment_size)) || (!mz_zip_array_ensure_room(pZip, &pState->m_central_dir_offsets, 1)))
return MZ_FALSE;
if ((!store_data_uncompressed) && (buf_size))
{
if (NULL == (pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor))))
return MZ_FALSE;
}
if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header)))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
return MZ_FALSE;
}
local_dir_header_ofs += num_alignment_padding_bytes;
if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); }
cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header);
MZ_CLEAR_OBJ(local_dir_header);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
return MZ_FALSE;
}
cur_archive_file_ofs += archive_name_size;
if (!(level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA))
{
uncomp_crc32 = (mz_uint32)mz_crc32(MZ_CRC32_INIT, (const mz_uint8*)pBuf, buf_size);
uncomp_size = buf_size;
if (uncomp_size <= 3)
{
level = 0;
store_data_uncompressed = MZ_TRUE;
}
}
if (store_data_uncompressed)
{
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pBuf, buf_size) != buf_size)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
return MZ_FALSE;
}
cur_archive_file_ofs += buf_size;
comp_size = buf_size;
if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)
method = MZ_DEFLATED;
}
else if (buf_size)
{
mz_zip_writer_add_state state;
state.m_pZip = pZip;
state.m_cur_archive_file_ofs = cur_archive_file_ofs;
state.m_comp_size = 0;
if ((tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY) ||
(tdefl_compress_buffer(pComp, pBuf, buf_size, TDEFL_FINISH) != TDEFL_STATUS_DONE))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
return MZ_FALSE;
}
comp_size = state.m_comp_size;
cur_archive_file_ofs = state.m_cur_archive_file_ofs;
method = MZ_DEFLATED;
}
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
pComp = NULL;
// no zip64 support yet
if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
return MZ_FALSE;
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date))
return MZ_FALSE;
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
return MZ_FALSE;
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes))
return MZ_FALSE;
pZip->m_total_files++;
pZip->m_archive_size = cur_archive_file_ofs;
return MZ_TRUE;
}
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_writer_add_file(mz_zip_archive *pZip, const char *pArchive_name, const char *pSrc_filename, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags)
{
mz_uint uncomp_crc32 = MZ_CRC32_INIT, level, num_alignment_padding_bytes;
mz_uint16 method = 0, dos_time = 0, dos_date = 0, ext_attributes = 0;
mz_uint64 local_dir_header_ofs = pZip->m_archive_size, cur_archive_file_ofs = pZip->m_archive_size, uncomp_size = 0, comp_size = 0;
size_t archive_name_size;
mz_uint8 local_dir_header[MZ_ZIP_LOCAL_DIR_HEADER_SIZE];
MZ_FILE *pSrc_file = NULL;
if ((int)level_and_flags < 0)
level_and_flags = MZ_DEFAULT_LEVEL;
level = level_and_flags & 0xF;
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) || (!pArchive_name) || ((comment_size) && (!pComment)) || (level > MZ_UBER_COMPRESSION))
return MZ_FALSE;
if (level_and_flags & MZ_ZIP_FLAG_COMPRESSED_DATA)
return MZ_FALSE;
if (!mz_zip_writer_validate_archive_name(pArchive_name))
return MZ_FALSE;
archive_name_size = strlen(pArchive_name);
if (archive_name_size > 0xFFFF)
return MZ_FALSE;
num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
// no zip64 support yet
if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE + comment_size + archive_name_size) > 0xFFFFFFFF))
return MZ_FALSE;
if (!mz_zip_get_file_modified_time(pSrc_filename, &dos_time, &dos_date))
return MZ_FALSE;
pSrc_file = MZ_FOPEN(pSrc_filename, "rb");
if (!pSrc_file)
return MZ_FALSE;
MZ_FSEEK64(pSrc_file, 0, SEEK_END);
uncomp_size = MZ_FTELL64(pSrc_file);
MZ_FSEEK64(pSrc_file, 0, SEEK_SET);
if (uncomp_size > 0xFFFFFFFF)
{
// No zip64 support yet
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
if (uncomp_size <= 3)
level = 0;
if (!mz_zip_writer_write_zeros(pZip, cur_archive_file_ofs, num_alignment_padding_bytes + sizeof(local_dir_header)))
{
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
local_dir_header_ofs += num_alignment_padding_bytes;
if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); }
cur_archive_file_ofs += num_alignment_padding_bytes + sizeof(local_dir_header);
MZ_CLEAR_OBJ(local_dir_header);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pArchive_name, archive_name_size) != archive_name_size)
{
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
cur_archive_file_ofs += archive_name_size;
if (uncomp_size)
{
mz_uint64 uncomp_remaining = uncomp_size;
void *pRead_buf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, MZ_ZIP_MAX_IO_BUF_SIZE);
if (!pRead_buf)
{
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
if (!level)
{
while (uncomp_remaining)
{
mz_uint n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, uncomp_remaining);
if ((MZ_FREAD(pRead_buf, 1, n, pSrc_file) != n) || (pZip->m_pWrite(pZip->m_pIO_opaque, cur_archive_file_ofs, pRead_buf, n) != n))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, n);
uncomp_remaining -= n;
cur_archive_file_ofs += n;
}
comp_size = uncomp_size;
}
else
{
mz_bool result = MZ_FALSE;
mz_zip_writer_add_state state;
tdefl_compressor *pComp = (tdefl_compressor *)pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, sizeof(tdefl_compressor));
if (!pComp)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
state.m_pZip = pZip;
state.m_cur_archive_file_ofs = cur_archive_file_ofs;
state.m_comp_size = 0;
if (tdefl_init(pComp, mz_zip_writer_add_put_buf_callback, &state, tdefl_create_comp_flags_from_zip_params(level, -15, MZ_DEFAULT_STRATEGY)) != TDEFL_STATUS_OKAY)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
for ( ; ; )
{
size_t in_buf_size = (mz_uint32)MZ_MIN(uncomp_remaining, MZ_ZIP_MAX_IO_BUF_SIZE);
tdefl_status status;
if (MZ_FREAD(pRead_buf, 1, in_buf_size, pSrc_file) != in_buf_size)
break;
uncomp_crc32 = (mz_uint32)mz_crc32(uncomp_crc32, (const mz_uint8 *)pRead_buf, in_buf_size);
uncomp_remaining -= in_buf_size;
status = tdefl_compress_buffer(pComp, pRead_buf, in_buf_size, uncomp_remaining ? TDEFL_NO_FLUSH : TDEFL_FINISH);
if (status == TDEFL_STATUS_DONE)
{
result = MZ_TRUE;
break;
}
else if (status != TDEFL_STATUS_OKAY)
break;
}
pZip->m_pFree(pZip->m_pAlloc_opaque, pComp);
if (!result)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
MZ_FCLOSE(pSrc_file);
return MZ_FALSE;
}
comp_size = state.m_comp_size;
cur_archive_file_ofs = state.m_cur_archive_file_ofs;
method = MZ_DEFLATED;
}
pZip->m_pFree(pZip->m_pAlloc_opaque, pRead_buf);
}
MZ_FCLOSE(pSrc_file); pSrc_file = NULL;
// no zip64 support yet
if ((comp_size > 0xFFFFFFFF) || (cur_archive_file_ofs > 0xFFFFFFFF))
return MZ_FALSE;
if (!mz_zip_writer_create_local_dir_header(pZip, local_dir_header, (mz_uint16)archive_name_size, 0, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date))
return MZ_FALSE;
if (pZip->m_pWrite(pZip->m_pIO_opaque, local_dir_header_ofs, local_dir_header, sizeof(local_dir_header)) != sizeof(local_dir_header))
return MZ_FALSE;
if (!mz_zip_writer_add_to_central_dir(pZip, pArchive_name, (mz_uint16)archive_name_size, NULL, 0, pComment, comment_size, uncomp_size, comp_size, uncomp_crc32, method, 0, dos_time, dos_date, local_dir_header_ofs, ext_attributes))
return MZ_FALSE;
pZip->m_total_files++;
pZip->m_archive_size = cur_archive_file_ofs;
return MZ_TRUE;
}
#endif // #ifndef MINIZ_NO_STDIO
mz_bool mz_zip_writer_add_from_zip_reader(mz_zip_archive *pZip, mz_zip_archive *pSource_zip, mz_uint file_index)
{
mz_uint n, bit_flags, num_alignment_padding_bytes;
mz_uint64 comp_bytes_remaining, local_dir_header_ofs;
mz_uint64 cur_src_file_ofs, cur_dst_file_ofs;
mz_uint32 local_header_u32[(MZ_ZIP_LOCAL_DIR_HEADER_SIZE + sizeof(mz_uint32) - 1) / sizeof(mz_uint32)]; mz_uint8 *pLocal_header = (mz_uint8 *)local_header_u32;
mz_uint8 central_header[MZ_ZIP_CENTRAL_DIR_HEADER_SIZE];
size_t orig_central_dir_size;
mz_zip_internal_state *pState;
void *pBuf; const mz_uint8 *pSrc_central_header;
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING))
return MZ_FALSE;
if (NULL == (pSrc_central_header = mz_zip_reader_get_cdh(pSource_zip, file_index)))
return MZ_FALSE;
pState = pZip->m_pState;
num_alignment_padding_bytes = mz_zip_writer_compute_padding_needed_for_file_alignment(pZip);
// no zip64 support yet
if ((pZip->m_total_files == 0xFFFF) || ((pZip->m_archive_size + num_alignment_padding_bytes + MZ_ZIP_LOCAL_DIR_HEADER_SIZE + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))
return MZ_FALSE;
cur_src_file_ofs = MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS);
cur_dst_file_ofs = pZip->m_archive_size;
if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
return MZ_FALSE;
if (MZ_READ_LE32(pLocal_header) != MZ_ZIP_LOCAL_DIR_HEADER_SIG)
return MZ_FALSE;
cur_src_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;
if (!mz_zip_writer_write_zeros(pZip, cur_dst_file_ofs, num_alignment_padding_bytes))
return MZ_FALSE;
cur_dst_file_ofs += num_alignment_padding_bytes;
local_dir_header_ofs = cur_dst_file_ofs;
if (pZip->m_file_offset_alignment) { MZ_ASSERT((local_dir_header_ofs & (pZip->m_file_offset_alignment - 1)) == 0); }
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pLocal_header, MZ_ZIP_LOCAL_DIR_HEADER_SIZE) != MZ_ZIP_LOCAL_DIR_HEADER_SIZE)
return MZ_FALSE;
cur_dst_file_ofs += MZ_ZIP_LOCAL_DIR_HEADER_SIZE;
n = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_EXTRA_LEN_OFS);
comp_bytes_remaining = n + MZ_READ_LE32(pSrc_central_header + MZ_ZIP_CDH_COMPRESSED_SIZE_OFS);
if (NULL == (pBuf = pZip->m_pAlloc(pZip->m_pAlloc_opaque, 1, (size_t)MZ_MAX(sizeof(mz_uint32) * 4, MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining)))))
return MZ_FALSE;
while (comp_bytes_remaining)
{
n = (mz_uint)MZ_MIN(MZ_ZIP_MAX_IO_BUF_SIZE, comp_bytes_remaining);
if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, n) != n)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
return MZ_FALSE;
}
cur_src_file_ofs += n;
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
return MZ_FALSE;
}
cur_dst_file_ofs += n;
comp_bytes_remaining -= n;
}
bit_flags = MZ_READ_LE16(pLocal_header + MZ_ZIP_LDH_BIT_FLAG_OFS);
if (bit_flags & 8)
{
// Copy data descriptor
if (pSource_zip->m_pRead(pSource_zip->m_pIO_opaque, cur_src_file_ofs, pBuf, sizeof(mz_uint32) * 4) != sizeof(mz_uint32) * 4)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
return MZ_FALSE;
}
n = sizeof(mz_uint32) * ((MZ_READ_LE32(pBuf) == 0x08074b50) ? 4 : 3);
if (pZip->m_pWrite(pZip->m_pIO_opaque, cur_dst_file_ofs, pBuf, n) != n)
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
return MZ_FALSE;
}
cur_src_file_ofs += n;
cur_dst_file_ofs += n;
}
pZip->m_pFree(pZip->m_pAlloc_opaque, pBuf);
// no zip64 support yet
if (cur_dst_file_ofs > 0xFFFFFFFF)
return MZ_FALSE;
orig_central_dir_size = pState->m_central_dir.m_size;
memcpy(central_header, pSrc_central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE);
MZ_WRITE_LE32(central_header + MZ_ZIP_CDH_LOCAL_HEADER_OFS, local_dir_header_ofs);
if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, central_header, MZ_ZIP_CENTRAL_DIR_HEADER_SIZE))
return MZ_FALSE;
n = MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_FILENAME_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_EXTRA_LEN_OFS) + MZ_READ_LE16(pSrc_central_header + MZ_ZIP_CDH_COMMENT_LEN_OFS);
if (!mz_zip_array_push_back(pZip, &pState->m_central_dir, pSrc_central_header + MZ_ZIP_CENTRAL_DIR_HEADER_SIZE, n))
{
mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
return MZ_FALSE;
}
if (pState->m_central_dir.m_size > 0xFFFFFFFF)
return MZ_FALSE;
n = (mz_uint32)orig_central_dir_size;
if (!mz_zip_array_push_back(pZip, &pState->m_central_dir_offsets, &n, 1))
{
mz_zip_array_resize(pZip, &pState->m_central_dir, orig_central_dir_size, MZ_FALSE);
return MZ_FALSE;
}
pZip->m_total_files++;
pZip->m_archive_size = cur_dst_file_ofs;
return MZ_TRUE;
}
mz_bool mz_zip_writer_finalize_archive(mz_zip_archive *pZip)
{
mz_zip_internal_state *pState;
mz_uint64 central_dir_ofs, central_dir_size;
mz_uint8 hdr[MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE];
if ((!pZip) || (!pZip->m_pState) || (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING))
return MZ_FALSE;
pState = pZip->m_pState;
// no zip64 support yet
if ((pZip->m_total_files > 0xFFFF) || ((pZip->m_archive_size + pState->m_central_dir.m_size + MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIZE) > 0xFFFFFFFF))
return MZ_FALSE;
central_dir_ofs = 0;
central_dir_size = 0;
if (pZip->m_total_files)
{
// Write central directory
central_dir_ofs = pZip->m_archive_size;
central_dir_size = pState->m_central_dir.m_size;
pZip->m_central_directory_file_ofs = central_dir_ofs;
if (pZip->m_pWrite(pZip->m_pIO_opaque, central_dir_ofs, pState->m_central_dir.m_p, (size_t)central_dir_size) != central_dir_size)
return MZ_FALSE;
pZip->m_archive_size += central_dir_size;
}
// Write end of central directory record
MZ_CLEAR_OBJ(hdr);
MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_SIG_OFS, MZ_ZIP_END_OF_CENTRAL_DIR_HEADER_SIG);
MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_NUM_ENTRIES_ON_DISK_OFS, pZip->m_total_files);
MZ_WRITE_LE16(hdr + MZ_ZIP_ECDH_CDIR_TOTAL_ENTRIES_OFS, pZip->m_total_files);
MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_SIZE_OFS, central_dir_size);
MZ_WRITE_LE32(hdr + MZ_ZIP_ECDH_CDIR_OFS_OFS, central_dir_ofs);
if (pZip->m_pWrite(pZip->m_pIO_opaque, pZip->m_archive_size, hdr, sizeof(hdr)) != sizeof(hdr))
return MZ_FALSE;
#ifndef MINIZ_NO_STDIO
if ((pState->m_pFile) && (MZ_FFLUSH(pState->m_pFile) == EOF))
return MZ_FALSE;
#endif // #ifndef MINIZ_NO_STDIO
pZip->m_archive_size += sizeof(hdr);
pZip->m_zip_mode = MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED;
return MZ_TRUE;
}
mz_bool mz_zip_writer_finalize_heap_archive(mz_zip_archive *pZip, void **pBuf, size_t *pSize)
{
if ((!pZip) || (!pZip->m_pState) || (!pBuf) || (!pSize))
return MZ_FALSE;
if (pZip->m_pWrite != mz_zip_heap_write_func)
return MZ_FALSE;
if (!mz_zip_writer_finalize_archive(pZip))
return MZ_FALSE;
*pBuf = pZip->m_pState->m_pMem;
*pSize = pZip->m_pState->m_mem_size;
pZip->m_pState->m_pMem = NULL;
pZip->m_pState->m_mem_size = pZip->m_pState->m_mem_capacity = 0;
return MZ_TRUE;
}
mz_bool mz_zip_writer_end(mz_zip_archive *pZip)
{
mz_zip_internal_state *pState;
mz_bool status = MZ_TRUE;
if ((!pZip) || (!pZip->m_pState) || (!pZip->m_pAlloc) || (!pZip->m_pFree) || ((pZip->m_zip_mode != MZ_ZIP_MODE_WRITING) && (pZip->m_zip_mode != MZ_ZIP_MODE_WRITING_HAS_BEEN_FINALIZED)))
return MZ_FALSE;
pState = pZip->m_pState;
pZip->m_pState = NULL;
mz_zip_array_clear(pZip, &pState->m_central_dir);
mz_zip_array_clear(pZip, &pState->m_central_dir_offsets);
mz_zip_array_clear(pZip, &pState->m_sorted_central_dir_offsets);
#ifndef MINIZ_NO_STDIO
if (pState->m_pFile)
{
MZ_FCLOSE(pState->m_pFile);
pState->m_pFile = NULL;
}
#endif // #ifndef MINIZ_NO_STDIO
if ((pZip->m_pWrite == mz_zip_heap_write_func) && (pState->m_pMem))
{
pZip->m_pFree(pZip->m_pAlloc_opaque, pState->m_pMem);
pState->m_pMem = NULL;
}
pZip->m_pFree(pZip->m_pAlloc_opaque, pState);
pZip->m_zip_mode = MZ_ZIP_MODE_INVALID;
return status;
}
#ifndef MINIZ_NO_STDIO
mz_bool mz_zip_add_mem_to_archive_file_in_place(const char *pZip_filename, const char *pArchive_name, const void *pBuf, size_t buf_size, const void *pComment, mz_uint16 comment_size, mz_uint level_and_flags)
{
mz_bool status, created_new_archive = MZ_FALSE;
mz_zip_archive zip_archive;
struct MZ_FILE_STAT_STRUCT file_stat;
MZ_CLEAR_OBJ(zip_archive);
if ((int)level_and_flags < 0)
level_and_flags = MZ_DEFAULT_LEVEL;
if ((!pZip_filename) || (!pArchive_name) || ((buf_size) && (!pBuf)) || ((comment_size) && (!pComment)) || ((level_and_flags & 0xF) > MZ_UBER_COMPRESSION))
return MZ_FALSE;
if (!mz_zip_writer_validate_archive_name(pArchive_name))
return MZ_FALSE;
if (MZ_FILE_STAT(pZip_filename, &file_stat) != 0)
{
// Create a new archive.
if (!mz_zip_writer_init_file(&zip_archive, pZip_filename, 0))
return MZ_FALSE;
created_new_archive = MZ_TRUE;
}
else
{
// Append to an existing archive.
if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, level_and_flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY))
return MZ_FALSE;
if (!mz_zip_writer_init_from_reader(&zip_archive, pZip_filename))
{
mz_zip_reader_end(&zip_archive);
return MZ_FALSE;
}
}
status = mz_zip_writer_add_mem_ex(&zip_archive, pArchive_name, pBuf, buf_size, pComment, comment_size, level_and_flags, 0, 0);
// Always finalize, even if adding failed for some reason, so we have a valid central directory. (This may not always succeed, but we can try.)
if (!mz_zip_writer_finalize_archive(&zip_archive))
status = MZ_FALSE;
if (!mz_zip_writer_end(&zip_archive))
status = MZ_FALSE;
if ((!status) && (created_new_archive))
{
// It's a new archive and something went wrong, so just delete it.
int ignoredStatus = MZ_DELETE_FILE(pZip_filename);
(void)ignoredStatus;
}
return status;
}
void *mz_zip_extract_archive_file_to_heap(const char *pZip_filename, const char *pArchive_name, size_t *pSize, mz_uint flags)
{
int file_index;
mz_zip_archive zip_archive;
void *p = NULL;
if (pSize)
*pSize = 0;
if ((!pZip_filename) || (!pArchive_name))
return NULL;
MZ_CLEAR_OBJ(zip_archive);
if (!mz_zip_reader_init_file(&zip_archive, pZip_filename, flags | MZ_ZIP_FLAG_DO_NOT_SORT_CENTRAL_DIRECTORY))
return NULL;
if ((file_index = mz_zip_reader_locate_file(&zip_archive, pArchive_name, NULL, flags)) >= 0)
p = mz_zip_reader_extract_to_heap(&zip_archive, file_index, pSize, flags);
mz_zip_reader_end(&zip_archive);
return p;
}
#endif // #ifndef MINIZ_NO_STDIO
#endif // #ifndef MINIZ_NO_ARCHIVE_WRITING_APIS
#endif // #ifndef MINIZ_NO_ARCHIVE_APIS
#ifdef __cplusplus
}
#endif
#endif // MINIZ_HEADER_FILE_ONLY
/*
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or
distribute this software, either in source code form or as a compiled
binary, for any purpose, commercial or non-commercial, and by any
means.
In jurisdictions that recognize copyright laws, the author or authors
of this software dedicate any and all copyright interest in the
software to the public domain. We make this dedication for the benefit
of the public at large and to the detriment of our heirs and
successors. We intend this dedication to be an overt act of
relinquishment in perpetuity of all present and future rights to this
software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
For more information, please refer to <http://unlicense.org/>
*/
|
Added src/mkbuiltin.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 |
/*
** Copyright (c) 2014 D. Richard Hipp
**
** This program is free software; you can redistribute it and/or
** modify it under the terms of the Simplified BSD License (also
** known as the "2-Clause License" or "FreeBSD License".)
** This program is distributed in the hope that it will be useful,
** but without any warranty; without even the implied warranty of
** merchantability or fitness for a particular purpose.
**
** Author contact information:
** drh@hwaci.com
** http://www.hwaci.com/drh/
**
*******************************************************************************
**
** This is a stand-alone utility program that is part of the Fossil build
** process. This program reads files named on the command line and converts
** them into ANSI-C static char array variables. Output is written onto
** standard output.
**
** The makefiles use this utility package various resources (large scripts,
** GIF images, etc) that are separate files in the source code as byte
** arrays in the resulting executable.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
** Read the entire content of the file named zFilename into memory obtained
** from malloc() and retur a pointer to that memory. Write the size of the
** file into *pnByte.
*/
static unsigned char *read_file(const char *zFilename, int *pnByte){
FILE *in;
unsigned char *z;
int nByte;
int got;
in = fopen(zFilename, "rb");
if( in==0 ){
return 0;
}
fseek(in, 0, SEEK_END);
*pnByte = nByte = ftell(in);
fseek(in, 0, SEEK_SET);
z = malloc( nByte+1 );
if( z==0 ){
fprintf(stderr, "failed to allocate %d bytes\n", nByte+1);
exit(1);
}
got = fread(z, 1, nByte, in);
fclose(in);
z[got] = 0;
return z;
}
/*
** There is an instance of the following for each file translated.
*/
typedef struct Resource Resource;
struct Resource {
const char *zName;
int nByte;
};
/*
** Compare two Resource objects for sorting purposes. They sort
** in zName order so that Fossil can search for resources using
** a binary search.
*/
static int compareResource(const void *a, const void *b){
Resource *pA = (Resource*)a;
Resource *pB = (Resource*)b;
return strcmp(pA->zName, pB->zName);
}
int main(int argc, char **argv){
int i, sz;
int j, n;
Resource *aRes;
int nRes = argc-1;
unsigned char *pData;
int nErr = 0;
aRes = malloc( nRes*sizeof(aRes[0]) );
if( aRes==0 ){
fprintf(stderr, "malloc failed\n");
return 1;
}
for(i=0; i<argc-1; i++){
aRes[i].zName = argv[i+1];
}
qsort(aRes, nRes, sizeof(aRes[0]), compareResource);
printf("/* Automatically generated code: Do not edit.\n**\n"
"** Rerun the \"mkbuiltin.c\" program or rerun the Fossil\n"
"** makefile to update this source file.\n"
"*/\n");
for(i=0; i<nRes; i++){
pData = read_file(aRes[i].zName, &sz);
if( pData==0 ){
fprintf(stderr, "Cannot open file [%s]\n", aRes[i].zName);
nErr++;
continue;
}
aRes[i].nByte = sz;
printf("/* Content of file %s */\n", aRes[i].zName);
printf("static const unsigned char bidata%d[%d] = {\n ",
i, sz+1);
for(j=n=0; j<=sz; j++){
printf("%3d", pData[j]);
if( j==sz ){
printf(" };\n");
}else if( n==14 ){
printf(",\n ");
n = 0;
}else{
printf(", ");
n++;
}
}
free(pData);
}
printf("typedef struct BuiltinFileTable BuiltinFileTable;\n");
printf("struct BuiltinFileTable {\n");
printf(" const char *zName;\n");
printf(" const unsigned char *pData;\n");
printf(" int nByte;\n");
printf("};\n");
printf("static const BuiltinFileTable aBuiltinFiles[] = {\n");
for(i=0; i<nRes; i++){
const char *zTail;
const char *z = aRes[i].zName;
zTail = z;
while( z && z[0] ){
if( z[0]=='/' || z[0]=='\\' ) zTail = &z[1];
z++;
}
printf(" { \"%s\", bidata%d, %d },\n", zTail, i, aRes[i].nByte);
}
printf("};\n");
return nErr;
}
|
Changes to src/moderate.c.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
/*
** Create a table to represent pending moderation requests, if the
** table does not already exist.
*/
void moderation_table_create(void){
db_multi_exec(
| | | | 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
/*
** Create a table to represent pending moderation requests, if the
** table does not already exist.
*/
void moderation_table_create(void){
db_multi_exec(
"CREATE TABLE IF NOT EXISTS %s.modreq(\n"
" objid INTEGER PRIMARY KEY,\n" /* Record pending approval */
" attachRid INT,\n" /* Object attached */
" tktid TEXT\n" /* Associated ticket id */
");\n", db_name("repository")
);
}
/*
** Return TRUE if the modreq table exists
*/
int moderation_table_exists(void){
|
| ︙ | ︙ | |||
71 72 73 74 75 76 77 |
"mlink", "mid",
"mlink", "fid",
"tagxref", "srcid",
"tagxref", "rid",
};
int i;
for(i=0; i<sizeof(aTabField)/sizeof(aTabField[0]); i+=2){
| | | 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
"mlink", "mid",
"mlink", "fid",
"tagxref", "srcid",
"tagxref", "rid",
};
int i;
for(i=0; i<sizeof(aTabField)/sizeof(aTabField[0]); i+=2){
if( db_exists("SELECT 1 FROM \"%w\" WHERE \"%w\"=%d",
aTabField[i], aTabField[i+1], rid) ) return 1;
}
return 0;
}
/*
** Delete a moderation item given by objid
|
| ︙ | ︙ | |||
150 151 152 153 154 155 156 |
login_check_credentials();
if( !g.perm.RdWiki && !g.perm.RdTkt ){ login_needed(); return; }
style_header("Pending Moderation Requests");
@ <h2>All Pending Moderation Requests</h2>
if( moderation_table_exists() ){
blob_init(&sql, timeline_query_for_www(), -1);
| | | | 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
login_check_credentials();
if( !g.perm.RdWiki && !g.perm.RdTkt ){ login_needed(); return; }
style_header("Pending Moderation Requests");
@ <h2>All Pending Moderation Requests</h2>
if( moderation_table_exists() ){
blob_init(&sql, timeline_query_for_www(), -1);
blob_append_sql(&sql,
" AND event.objid IN (SELECT objid FROM modreq)"
" ORDER BY event.mtime DESC"
);
db_prepare(&q, "%s", blob_sql_text(&sql));
www_print_timeline(&q, 0, 0, 0, 0);
db_finalize(&q);
}
style_footer();
}
|
Changes to src/name.c.
| ︙ | ︙ | |||
214 215 216 217 218 219 220 |
if( nTag>=4 && nTag<=UUID_SIZE && validate16(zTag, nTag) ){
Stmt q;
char zUuid[UUID_SIZE+1];
memcpy(zUuid, zTag, nTag+1);
canonical16(zUuid, nTag);
rid = 0;
if( zType[0]=='*' ){
| | | | 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
if( nTag>=4 && nTag<=UUID_SIZE && validate16(zTag, nTag) ){
Stmt q;
char zUuid[UUID_SIZE+1];
memcpy(zUuid, zTag, nTag+1);
canonical16(zUuid, nTag);
rid = 0;
if( zType[0]=='*' ){
db_prepare(&q, "SELECT rid FROM blob WHERE uuid GLOB '%q*'", zUuid);
}else{
db_prepare(&q,
"SELECT blob.rid"
" FROM blob, event"
" WHERE blob.uuid GLOB '%q*'"
" AND event.objid=blob.rid"
" AND event.type GLOB '%q'",
zUuid, zType
);
}
if( db_step(&q)==SQLITE_ROW ){
rid = db_column_int(&q, 0);
|
| ︙ | ︙ | |||
257 258 259 260 261 262 263 |
if( strcmp(zType,"*")==0 ){
rid = atoi(zTag);
}else{
rid = db_int(0,
"SELECT event.objid"
" FROM event"
" WHERE event.objid=%s"
| | | 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
if( strcmp(zType,"*")==0 ){
rid = atoi(zTag);
}else{
rid = db_int(0,
"SELECT event.objid"
" FROM event"
" WHERE event.objid=%s"
" AND event.type GLOB '%q'", zTag /*safe-for-%s*/, zType);
}
}
}
return rid;
}
/*
|
| ︙ | ︙ | |||
307 308 309 310 311 312 313 | ** treat errors as fatal. zName must be a UUID, as described for ** name_to_uuid(). zType is also as described for that function. If ** zName does not resolve, 0 is returned. If it is ambiguous, a ** negative value is returned. On success the rid is returned and ** pUuid (if it is not NULL) is set to the a newly-allocated string, ** the full UUID, which must eventually be free()d by the caller. */ | | | 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
** treat errors as fatal. zName must be a UUID, as described for
** name_to_uuid(). zType is also as described for that function. If
** zName does not resolve, 0 is returned. If it is ambiguous, a
** negative value is returned. On success the rid is returned and
** pUuid (if it is not NULL) is set to the a newly-allocated string,
** the full UUID, which must eventually be free()d by the caller.
*/
int name_to_uuid2(const char *zName, const char *zType, char **pUuid){
int rid = symbolic_name_to_rid(zName, zType);
if((rid>0) && pUuid){
*pUuid = db_text(NULL, "SELECT uuid FROM blob WHERE rid=%d", rid);
}
return rid;
}
|
| ︙ | ︙ | |||
552 553 554 555 556 557 558 |
/* Report any HIDDEN, PRIVATE, CLUSTER, or CLOSED tags on this artifact */
db_prepare(&q,
"SELECT tagname"
" FROM tag JOIN tagxref ON tag.tagid=tagxref.tagid"
" WHERE tagxref.rid=%d"
" AND tag.tagid IN (5,6,7,9)"
" ORDER BY 1",
| | | 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 |
/* Report any HIDDEN, PRIVATE, CLUSTER, or CLOSED tags on this artifact */
db_prepare(&q,
"SELECT tagname"
" FROM tag JOIN tagxref ON tag.tagid=tagxref.tagid"
" WHERE tagxref.rid=%d"
" AND tag.tagid IN (5,6,7,9)"
" ORDER BY 1",
rid
);
cnt = 0;
while( db_step(&q)==SQLITE_ROW ){
const char *zPrefix = cnt++ ? ", " : "raw-tags: ";
fossil_print("%s%s", zPrefix, db_column_text(&q,0));
}
if( cnt ) fossil_print("\n");
|
| ︙ | ︙ | |||
580 581 582 583 584 585 586 |
case 't': zType = "Ticket-change"; break;
case 'g': zType = "Tag-change"; break;
default: zType = "Unknown"; break;
}
fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
db_column_text(&q, 1));
fossil_print("comment: ");
| | | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
case 't': zType = "Ticket-change"; break;
case 'g': zType = "Tag-change"; break;
default: zType = "Unknown"; break;
}
fossil_print("type: %s by %s on %s\n", zType, db_column_text(&q,2),
db_column_text(&q, 1));
fossil_print("comment: ");
comment_print(db_column_text(&q,3), 0, 12, -1, g.comFmtFlags);
}
db_finalize(&q);
/* Check to see if this object is used as a file in a check-in */
db_prepare(&q,
"SELECT filename.name, blob.uuid, datetime(event.mtime%s),"
" coalesce(euser,user), coalesce(ecomment,comment)"
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 |
while( db_step(&q)==SQLITE_ROW ){
fossil_print("file: %s\n", db_column_text(&q,0));
fossil_print(" part of [%S] by %s on %s\n",
db_column_text(&q, 1),
db_column_text(&q, 3),
db_column_text(&q, 2));
fossil_print(" ");
| | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 |
while( db_step(&q)==SQLITE_ROW ){
fossil_print("file: %s\n", db_column_text(&q,0));
fossil_print(" part of [%S] by %s on %s\n",
db_column_text(&q, 1),
db_column_text(&q, 3),
db_column_text(&q, 2));
fossil_print(" ");
comment_print(db_column_text(&q,4), 0, 12, -1, g.comFmtFlags);
}
db_finalize(&q);
/* Check to see if this object is used as an attachment */
db_prepare(&q,
"SELECT attachment.filename,"
" attachment.comment,"
|
| ︙ | ︙ | |||
637 638 639 640 641 642 643 |
}else{
fossil_print(" via %s\n",
db_column_text(&q,7));
}
fossil_print(" by user %s on %s\n",
db_column_text(&q,2), db_column_text(&q,3));
fossil_print(" ");
| | > > > > | 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
}else{
fossil_print(" via %s\n",
db_column_text(&q,7));
}
fossil_print(" by user %s on %s\n",
db_column_text(&q,2), db_column_text(&q,3));
fossil_print(" ");
comment_print(db_column_text(&q,1), 0, 12, -1, g.comFmtFlags);
}
db_finalize(&q);
}
/*
** COMMAND: whatis*
** Usage: %fossil whatis NAME
**
** Resolve the symbol NAME into its canonical 40-character SHA1-hash
** artifact name and provide a description of what role that artifact
** plays.
*/
void whatis_cmd(void){
int rid;
const char *zName;
int verboseFlag;
int i;
db_find_and_open_repository(0,0);
verboseFlag = find_option("verbose","v",0)!=0;
/* We should be done with options.. */
verify_all_options();
if( g.argc<3 ) usage("whatis NAME ...");
for(i=2; i<g.argc; i++){
zName = g.argv[i];
if( i>2 ) fossil_print("%.79c\n",'-');
rid = symbolic_name_to_rid(zName, 0);
if( rid<0 ){
Stmt q;
|
| ︙ | ︙ |
Changes to src/path.c.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | /* ** Compute the shortest path from iFrom to iTo ** ** If directOnly is true, then use only the "primary" links from parent to ** child. In other words, ignore merges. ** | | | 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | /* ** Compute the shortest path from iFrom to iTo ** ** If directOnly is true, then use only the "primary" links from parent to ** child. In other words, ignore merges. ** ** Return a pointer to the beginning of the path (the iFrom node). ** Elements of the path can be traversed by following the PathNode.u.pTo ** pointer chain. ** ** Return NULL if no path is found. */ PathNode *path_shortest( int iFrom, /* Path starts here */ |
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
path_reset();
path.pStart = path_new_node(iFrom, 0, 0);
if( iTo==iFrom ){
path.pEnd = path.pStart;
return path.pStart;
}
if( oneWayOnly && directOnly ){
| | | | | | 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 |
path_reset();
path.pStart = path_new_node(iFrom, 0, 0);
if( iTo==iFrom ){
path.pEnd = path.pStart;
return path.pStart;
}
if( oneWayOnly && directOnly ){
db_prepare(&s,
"SELECT cid, 1 FROM plink WHERE pid=:pid AND isprim"
);
}else if( oneWayOnly ){
db_prepare(&s,
"SELECT cid, 1 FROM plink WHERE pid=:pid "
);
}else if( directOnly ){
db_prepare(&s,
"SELECT cid, 1 FROM plink WHERE pid=:pid AND isprim "
"UNION ALL "
"SELECT pid, 0 FROM plink WHERE cid=:pid AND isprim"
);
}else{
db_prepare(&s,
"SELECT cid, 1 FROM plink WHERE pid=:pid "
"UNION ALL "
"SELECT pid, 0 FROM plink WHERE cid=:pid"
);
}
while( path.pCurrent ){
path.nStep++;
|
| ︙ | ︙ | |||
228 229 230 231 232 233 234 |
"SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
" FROM blob, event"
" WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
p->rid, p->rid);
fossil_print("%4d: %5d %s", n, p->rid, z);
fossil_free(z);
if( p->u.pTo ){
| | | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 |
"SELECT substr(uuid,1,12) || ' ' || datetime(mtime)"
" FROM blob, event"
" WHERE blob.rid=%d AND event.objid=%d AND event.type='ci'",
p->rid, p->rid);
fossil_print("%4d: %5d %s", n, p->rid, z);
fossil_free(z);
if( p->u.pTo ){
fossil_print(" is a %s of\n",
p->u.pTo->fromIsParent ? "parent" : "child");
}else{
fossil_print("\n");
}
}
}
|
| ︙ | ︙ | |||
351 352 353 354 355 356 357 | }; /* ** Compute all file name changes that occur going from checkin iFrom ** to checkin iTo. ** ** The number of name changes is written into *pnChng. For each name | | | 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 | }; /* ** Compute all file name changes that occur going from checkin iFrom ** to checkin iTo. ** ** The number of name changes is written into *pnChng. For each name ** change, two integers are allocated for *piChng. The first is the ** filename.fnid for the original name as seen in check-in iFrom and ** the second is for new name as it is used in check-in iTo. ** ** Space to hold *piChng is obtained from fossil_malloc() and should ** be released by the caller. ** ** This routine really has nothing to do with path. It is located |
| ︙ | ︙ | |||
514 515 516 517 518 519 520 |
fossil_free(aChng);
g.argv += 2;
g.argc -= 2;
}
}
/* Query to extract all rename operations */
| | | | | 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
fossil_free(aChng);
g.argv += 2;
g.argc -= 2;
}
}
/* Query to extract all rename operations */
static const char zRenameQuery[] =
@ SELECT
@ datetime(event.mtime),
@ F.name AS old_name,
@ T.name AS new_name,
@ blob.uuid
@ FROM mlink, filename F, filename T, event, blob
@ WHERE coalesce(mlink.pfnid,0)!=0 AND mlink.pfnid!=mlink.fnid
@ AND F.fnid=mlink.pfnid
@ AND T.fnid=mlink.fnid
@ AND event.objid=mlink.mid
@ AND event.type='ci'
@ AND blob.rid=mlink.mid
@ ORDER BY 1 DESC, 2;
;
/*
** WEBPAGE: test-rename-list
**
** Print a list of all file rename operations throughout history.
** This page is intended for for testing purposes only and may change
** or be discontinued without notice.
*/
void test_rename_list_page(void){
Stmt q;
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
style_header("List Of File Name Changes");
@ <h3>NB: Experimental Page</h3>
@ <table border="1" width="100%%">
@ <tr><th>Date & Time</th>
@ <th>Old Name</th>
@ <th>New Name</th>
@ <th>Check-in</th></tr>
db_prepare(&q, "%s", zRenameQuery/*safe-for-%s*/);
while( db_step(&q)==SQLITE_ROW ){
const char *zDate = db_column_text(&q, 0);
const char *zOld = db_column_text(&q, 1);
const char *zNew = db_column_text(&q, 2);
const char *zUuid = db_column_text(&q, 3);
@ <tr>
@ <td>%z(href("%R/timeline?c=%t",zDate))%s(zDate)</a></td>
|
| ︙ | ︙ |
Changes to src/printf.c.
| ︙ | ︙ | |||
42 43 44 45 46 47 48 |
#define etERROR 10 /* Used to indicate no such conversion type */
/* The rest are extensions, not normally found in printf() */
#define etBLOB 11 /* Blob objects. %b */
#define etBLOBSQL 12 /* Blob objects quoted for SQL. %B */
#define etSQLESCAPE 13 /* Strings with '\'' doubled. %q */
#define etSQLESCAPE2 14 /* Strings with '\'' doubled and enclosed in '',
NULL pointers replaced by SQL NULL. %Q */
| > | | | | | | | | | 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
#define etERROR 10 /* Used to indicate no such conversion type */
/* The rest are extensions, not normally found in printf() */
#define etBLOB 11 /* Blob objects. %b */
#define etBLOBSQL 12 /* Blob objects quoted for SQL. %B */
#define etSQLESCAPE 13 /* Strings with '\'' doubled. %q */
#define etSQLESCAPE2 14 /* Strings with '\'' doubled and enclosed in '',
NULL pointers replaced by SQL NULL. %Q */
#define etSQLESCAPE3 15 /* Double '"' characters within an indentifier. %w */
#define etPOINTER 16 /* The %p conversion */
#define etHTMLIZE 17 /* Make text safe for HTML */
#define etHTTPIZE 18 /* Make text safe for HTTP. "/" encoded as %2f */
#define etURLIZE 19 /* Make text safe for HTTP. "/" not encoded */
#define etFOSSILIZE 20 /* The fossil header encoding format. */
#define etPATH 21 /* Path type */
#define etWIKISTR 22 /* Timeline comment text rendered from a char*: %W */
#define etSTRINGID 23 /* String with length limit for a UUID prefix: %S */
#define etROOT 24 /* String value of g.zTop: %R */
/*
** An "etByte" is an 8-bit unsigned value.
*/
typedef unsigned char etByte;
|
| ︙ | ︙ | |||
94 95 96 97 98 99 100 |
{ 's', 0, 4, etSTRING, 0, 0 },
{ 'g', 0, 1, etGENERIC, 30, 0 },
{ 'z', 0, 6, etDYNSTRING, 0, 0 },
{ 'q', 0, 4, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
{ 'b', 0, 2, etBLOB, 0, 0 },
{ 'B', 0, 2, etBLOBSQL, 0, 0 },
| | > | 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 |
{ 's', 0, 4, etSTRING, 0, 0 },
{ 'g', 0, 1, etGENERIC, 30, 0 },
{ 'z', 0, 6, etDYNSTRING, 0, 0 },
{ 'q', 0, 4, etSQLESCAPE, 0, 0 },
{ 'Q', 0, 4, etSQLESCAPE2, 0, 0 },
{ 'b', 0, 2, etBLOB, 0, 0 },
{ 'B', 0, 2, etBLOBSQL, 0, 0 },
{ 'W', 0, 2, etWIKISTR, 0, 0 },
{ 'h', 0, 4, etHTMLIZE, 0, 0 },
{ 'R', 0, 0, etROOT, 0, 0 },
{ 't', 0, 4, etHTTPIZE, 0, 0 }, /* "/" -> "%2F" */
{ 'T', 0, 4, etURLIZE, 0, 0 }, /* "/" unchanged */
{ 'w', 0, 4, etSQLESCAPE3, 0, 0 },
{ 'F', 0, 4, etFOSSILIZE, 0, 0 },
{ 'S', 0, 4, etSTRINGID, 0, 0 },
{ 'c', 0, 0, etCHARX, 0, 0 },
{ 'o', 8, 0, etRADIX, 0, 2 },
{ 'u', 10, 0, etRADIX, 0, 0 },
{ 'x', 16, 0, etRADIX, 16, 1 },
{ 'X', 16, 0, etRADIX, 0, 4 },
|
| ︙ | ︙ | |||
659 660 661 662 663 664 665 |
}
bufpt[j++] = '\'';
length = j;
assert( length==n+cnt+2 );
break;
}
case etSQLESCAPE:
| > | > | | | | | 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
}
bufpt[j++] = '\'';
length = j;
assert( length==n+cnt+2 );
break;
}
case etSQLESCAPE:
case etSQLESCAPE2:
case etSQLESCAPE3: {
int i, j, n, ch, isnull;
int needQuote;
int limit = flag_alternateform ? va_arg(ap,int) : -1;
char q = ((xtype==etSQLESCAPE3)?'"':'\''); /* Quote characters */
char *escarg = va_arg(ap,char*);
isnull = escarg==0;
if( isnull ) escarg = (xtype==etSQLESCAPE2 ? "NULL" : "(NULL)");
if( limit<0 ) limit = strlen(escarg);
for(i=n=0; i<limit; i++){
if( escarg[i]==q ) n++;
}
needQuote = !isnull && xtype==etSQLESCAPE2;
n += i + 1 + needQuote*2;
if( n>etBUFSIZE ){
bufpt = zExtra = fossil_malloc( n );
}else{
bufpt = buf;
}
j = 0;
if( needQuote ) bufpt[j++] = q;
for(i=0; i<limit; i++){
bufpt[j++] = ch = escarg[i];
if( ch==q ) bufpt[j++] = ch;
}
if( needQuote ) bufpt[j++] = q;
bufpt[j] = 0;
length = j;
if( precision>=0 && precision<length ) length = precision;
break;
}
case etHTMLIZE: {
int limit = flag_alternateform ? va_arg(ap,int) : -1;
|
| ︙ | ︙ | |||
864 865 866 867 868 869 870 | fflush(toStdErr ? stderr : stdout); } /* ** Force the standard output cursor to move to the beginning ** of a line, if it is not there already. */ | | | > > > > | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 |
fflush(toStdErr ? stderr : stdout);
}
/*
** Force the standard output cursor to move to the beginning
** of a line, if it is not there already.
*/
int fossil_force_newline(void){
if( g.cgiOutput==0 && stdoutAtBOL==0 ){
fossil_puts("\n", 0);
return 1;
}
return 0;
}
/*
** Indicate that the cursor has moved to the start of a line by means
** other than writing to standard output.
*/
void fossil_new_line_started(void){
|
| ︙ | ︙ |
Changes to src/rebuild.c.
| ︙ | ︙ | |||
79 80 81 82 83 84 85 |
@ cols TEXT, -- A color-key specification
@ sqlcode TEXT -- An SQL SELECT statement for this report
@ );
;
static void rebuild_update_schema(void){
int rc;
| | | | 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
@ cols TEXT, -- A color-key specification
@ sqlcode TEXT -- An SQL SELECT statement for this report
@ );
;
static void rebuild_update_schema(void){
int rc;
db_multi_exec("%s", zSchemaUpdates1 /*safe-for-%s*/);
db_multi_exec("%s", zSchemaUpdates2 /*safe-for-%s*/);
rc = db_exists("SELECT 1 FROM sqlite_master"
" WHERE name='user' AND sql GLOB '* mtime *'");
if( rc==0 ){
db_multi_exec(
"CREATE TEMP TABLE temp_user AS SELECT * FROM user;"
"DROP TABLE user;"
|
| ︙ | ︙ | |||
133 134 135 136 137 138 139 |
rc = db_exists("SELECT 1 FROM sqlite_master"
" WHERE name='reportfmt' AND sql GLOB '* mtime *'");
if( rc==0 ){
db_multi_exec(
"CREATE TEMP TABLE old_fmt AS SELECT * FROM reportfmt;"
"DROP TABLE reportfmt;"
);
| | | 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
rc = db_exists("SELECT 1 FROM sqlite_master"
" WHERE name='reportfmt' AND sql GLOB '* mtime *'");
if( rc==0 ){
db_multi_exec(
"CREATE TEMP TABLE old_fmt AS SELECT * FROM reportfmt;"
"DROP TABLE reportfmt;"
);
db_multi_exec("%s", zSchemaUpdates2/*safe-for-%s*/);
db_multi_exec(
"INSERT OR IGNORE INTO reportfmt(rn,owner,title,cols,sqlcode,mtime)"
" SELECT rn, owner, title, cols, sqlcode, now() FROM old_fmt;"
"INSERT OR IGNORE INTO reportfmt(rn,owner,title,cols,sqlcode,mtime)"
" SELECT rn, owner, title || ' (' || rn || ')', cols, sqlcode, now()"
" FROM old_fmt;"
);
|
| ︙ | ︙ | |||
252 253 254 255 256 257 258 |
}
if( zFNameFormat==0 ){
/* We are doing "fossil rebuild" */
manifest_crosslink(rid, pUse, MC_NONE);
}else{
/* We are doing "fossil deconstruct" */
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
| | > | 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
}
if( zFNameFormat==0 ){
/* We are doing "fossil rebuild" */
manifest_crosslink(rid, pUse, MC_NONE);
}else{
/* We are doing "fossil deconstruct" */
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
char *zFile = mprintf(zFNameFormat /*works-like:"%s:%s"*/,
zUuid, zUuid+prefixLength);
blob_write_to_file(pUse,zFile);
free(zFile);
free(zUuid);
blob_reset(pUse);
}
assert( blob_is_reset(pUse) );
rebuild_step_done(rid);
|
| ︙ | ︙ | |||
353 354 355 356 357 358 359 |
" AND name NOT GLOB 'sqlite_*'"
" AND name NOT GLOB 'fx_*'"
);
if( zTable==0 ) break;
db_multi_exec("DROP TABLE %Q", zTable);
free(zTable);
}
| | | 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
" AND name NOT GLOB 'sqlite_*'"
" AND name NOT GLOB 'fx_*'"
);
if( zTable==0 ) break;
db_multi_exec("DROP TABLE %Q", zTable);
free(zTable);
}
db_multi_exec("%s", zRepositorySchema2/*safe-for-%s*/);
ticket_create_table(0);
shun_artifacts();
db_multi_exec(
"INSERT INTO unclustered"
" SELECT rid FROM blob EXCEPT SELECT rid FROM private"
);
|
| ︙ | ︙ | |||
576 577 578 579 580 581 582 583 584 585 586 587 |
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
if( g.argc!=2 ){
usage("?REPOSITORY-FILENAME?");
}
db_close(1);
db_open_repository(g.zRepositoryName);
}
db_begin_transaction();
ttyOutput = 1;
errCnt = rebuild_db(randomizeFlag, 1, doClustering);
reconstruct_private_table();
db_multi_exec(
| > > > > | | | | 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 |
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
if( g.argc!=2 ){
usage("?REPOSITORY-FILENAME?");
}
db_close(1);
db_open_repository(g.zRepositoryName);
}
/* We should be done with options.. */
verify_all_options();
db_begin_transaction();
ttyOutput = 1;
errCnt = rebuild_db(randomizeFlag, 1, doClustering);
reconstruct_private_table();
db_multi_exec(
"REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());"
"REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());"
"REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());",
CONTENT_SCHEMA, AUX_SCHEMA, get_version()
);
if( errCnt && !forceFlag ){
fossil_print(
"%d errors. Rolling back changes. Use --force to force a commit.\n",
errCnt
);
|
| ︙ | ︙ | |||
791 792 793 794 795 796 797 798 799 800 801 802 803 804 |
int bVerily = find_option("verily",0,0)!=0;
int bForce = find_option("force", "f", 0)!=0;
int privateOnly = find_option("private",0,0)!=0;
int bNeedRebuild = 0;
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
db_close(1);
db_open_repository(g.zRepositoryName);
if( !bForce ){
Blob ans;
char cReply;
prompt_user(
"Scrubbing the repository will permanently delete information.\n"
"Changes cannot be undone. Continue (y/N)? ", &ans);
cReply = blob_str(&ans)[0];
| > > > > | 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 |
int bVerily = find_option("verily",0,0)!=0;
int bForce = find_option("force", "f", 0)!=0;
int privateOnly = find_option("private",0,0)!=0;
int bNeedRebuild = 0;
db_find_and_open_repository(OPEN_ANY_SCHEMA, 2);
db_close(1);
db_open_repository(g.zRepositoryName);
/* We should be done with options.. */
verify_all_options();
if( !bForce ){
Blob ans;
char cReply;
prompt_user(
"Scrubbing the repository will permanently delete information.\n"
"Changes cannot be undone. Continue (y/N)? ", &ans);
cReply = blob_str(&ans)[0];
|
| ︙ | ︙ | |||
913 914 915 916 917 918 919 920 921 922 923 924 925 926 |
}
if( file_isdir(g.argv[3])!=1 ){
fossil_print("\"%s\" is not a directory\n\n", g.argv[3]);
usage("FILENAME DIRECTORY");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
db_open_config(0);
db_begin_transaction();
db_initial_setup(0, 0, 0, 1);
fossil_print("Reading files from directory \"%s\"...\n", g.argv[3]);
recon_read_dir(g.argv[3]);
fossil_print("\nBuilding the Fossil repository...\n");
| > > > > | 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 |
}
if( file_isdir(g.argv[3])!=1 ){
fossil_print("\"%s\" is not a directory\n\n", g.argv[3]);
usage("FILENAME DIRECTORY");
}
db_create_repository(g.argv[2]);
db_open_repository(g.argv[2]);
/* We should be done with options.. */
verify_all_options();
db_open_config(0);
db_begin_transaction();
db_initial_setup(0, 0, 0, 1);
fossil_print("Reading files from directory \"%s\"...\n", g.argv[3]);
recon_read_dir(g.argv[3]);
fossil_print("\nBuilding the Fossil repository...\n");
|
| ︙ | ︙ |
Changes to src/regexp.c.
| ︙ | ︙ | |||
766 767 768 769 770 771 772 |
**
** -i|--ignore-case Ignore case
*/
void re_test_grep(void){
ReCompiled *pRe;
const char *zErr;
int ignoreCase = find_option("ignore-case","i",0)!=0;
| < | 766 767 768 769 770 771 772 773 774 775 776 777 778 779 |
**
** -i|--ignore-case Ignore case
*/
void re_test_grep(void){
ReCompiled *pRe;
const char *zErr;
int ignoreCase = find_option("ignore-case","i",0)!=0;
if( g.argc<3 ){
usage("REGEXP [FILE...]");
}
zErr = re_compile(&pRe, g.argv[2], ignoreCase);
if( zErr ) fossil_fatal("%s", zErr);
if( g.argc==3 ){
grep(pRe, "-", stdin);
|
| ︙ | ︙ |
Changes to src/report.c.
| ︙ | ︙ | |||
434 435 436 437 438 439 440 |
}
}
if( zOwner==0 ) zOwner = g.zLogin;
style_submenu_element("Cancel", "Cancel", "reportlist");
if( rn>0 ){
style_submenu_element("Delete", "Delete", "rptedit?rn=%d&del1=1", rn);
}
| | | 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 |
}
}
if( zOwner==0 ) zOwner = g.zLogin;
style_submenu_element("Cancel", "Cancel", "reportlist");
if( rn>0 ){
style_submenu_element("Delete", "Delete", "rptedit?rn=%d&del1=1", rn);
}
style_header("%s", rn>0 ? "Edit Report Format":"Create New Report Format");
if( zErr ){
@ <blockquote class="reportError">%h(zErr)</blockquote>
}
@ <form action="rptedit" method="post"><div>
@ <input type="hidden" name="rn" value="%d(rn)" />
@ <p>Report Title:<br />
@ <input type="text" name="t" value="%h(zTitle)" size="60" /></p>
|
| ︙ | ︙ | |||
1068 1069 1070 1071 1072 1073 1074 |
if( g.perm.TktFmt ){
style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
}
if( g.perm.NewTkt ){
style_submenu_element("New Ticket", "Create a new ticket",
"%s/tktnew", g.zTop);
}
| | | 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 |
if( g.perm.TktFmt ){
style_submenu_element("SQL", "SQL", "rptsql?rn=%d",rn);
}
if( g.perm.NewTkt ){
style_submenu_element("New Ticket", "Create a new ticket",
"%s/tktnew", g.zTop);
}
style_header("%s", zTitle);
output_color_key(zClrKey, 1,
"border=\"0\" cellpadding=\"3\" cellspacing=\"0\" class=\"report\"");
@ <table border="1" cellpadding="2" cellspacing="0" class="report"
@ id="reportTable">
sState.rn = rn;
sState.nCount = 0;
report_restrict_sql(&zErr1);
|
| ︙ | ︙ | |||
1110 1111 1112 1113 1114 1115 1116 |
/*
** show all reports, which can be used for ticket show.
** Output is written to stdout as tab delimited table
*/
void rpt_list_reports(void){
Stmt q;
| < < | | | | 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 |
/*
** show all reports, which can be used for ticket show.
** Output is written to stdout as tab delimited table
*/
void rpt_list_reports(void){
Stmt q;
fossil_print("Available reports:\n");
fossil_print("%s\t%s\n","report number","report title");
fossil_print("%s\t%s\n",zFullTicketRptRn,zFullTicketRptTitle);
db_prepare(&q,"SELECT rn,title FROM reportfmt ORDER BY rn");
while( db_step(&q)==SQLITE_ROW ){
const char *zRn = db_column_text(&q, 0);
const char *zTitle = db_column_text(&q, 1);
fossil_print("%s\t%s\n",zRn,zTitle);
}
db_finalize(&q);
}
/*
** user defined separator used by ticket show command
*/
|
| ︙ | ︙ | |||
1215 1216 1217 1218 1219 1220 1221 | Stmt q; char *zSql; char *zErr1 = 0; char *zErr2 = 0; int count = 0; int rn; | | | 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
Stmt q;
char *zSql;
char *zErr1 = 0;
char *zErr2 = 0;
int count = 0;
int rn;
if( !zRep || !strcmp(zRep,zFullTicketRptRn) || !strcmp(zRep,zFullTicketRptTitle) ){
zSql = "SELECT * FROM ticket";
}else{
rn = atoi(zRep);
if( rn ){
db_prepare(&q,
"SELECT sqlcode FROM reportfmt WHERE rn=%d", rn);
}else{
|
| ︙ | ︙ |
Changes to src/rss.c.
| ︙ | ︙ | |||
25 26 27 28 29 30 31 | /* ** WEBPAGE: timeline.rss ** URL: /timeline.rss?y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME ** ** Produce an RSS feed of the timeline. ** ** TYPE may be: all, ci (show checkins only), t (show tickets only), | | > > | 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | /* ** WEBPAGE: timeline.rss ** URL: /timeline.rss?y=TYPE&n=LIMIT&tkt=UUID&tag=TAG&wiki=NAME&name=FILENAME ** ** Produce an RSS feed of the timeline. ** ** TYPE may be: all, ci (show checkins only), t (show tickets only), ** w (show wiki only). ** ** LIMIT is the number of items to show. ** ** tkt=UUID filters for only those events for the specified ticket. tag=TAG ** filters for a tag, and wiki=NAME for a wiki page. Only one may be used. ** ** In addition, name=FILENAME filters for a specific file. This may be ** combined with one of the other filters (useful for looking at a specific ** branch). |
| ︙ | ︙ | |||
72 73 74 75 76 77 78 |
blob_zero(&bSQL);
blob_append( &bSQL, zSQL1, -1 );
if( zType[0]!='a' ){
if( zType[0]=='c' && !g.perm.Read ) zType = "x";
if( zType[0]=='w' && !g.perm.RdWiki ) zType = "x";
if( zType[0]=='t' && !g.perm.RdTkt ) zType = "x";
| | | 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
blob_zero(&bSQL);
blob_append( &bSQL, zSQL1, -1 );
if( zType[0]!='a' ){
if( zType[0]=='c' && !g.perm.Read ) zType = "x";
if( zType[0]=='w' && !g.perm.RdWiki ) zType = "x";
if( zType[0]=='t' && !g.perm.RdTkt ) zType = "x";
blob_append_sql(&bSQL, " AND event.type=%Q", zType);
}else{
if( !g.perm.Read ){
if( g.perm.RdTkt && g.perm.RdWiki ){
blob_append(&bSQL, " AND event.type!='ci'", -1);
}else if( g.perm.RdTkt ){
blob_append(&bSQL, " AND event.type=='t'", -1);
|
| ︙ | ︙ | |||
118 119 120 121 122 123 124 |
nTagId = -1;
}
}else{
nTagId = 0;
}
if( nTagId==-1 ){
| | | | | 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 |
nTagId = -1;
}
}else{
nTagId = 0;
}
if( nTagId==-1 ){
blob_append_sql(&bSQL, " AND 0");
}else if( nTagId!=0 ){
blob_append_sql(&bSQL, " AND (EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid))", nTagId);
}
if( zFilename ){
blob_append_sql(&bSQL,
" AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
zFilename, filename_collation()
);
}
blob_append( &bSQL, " ORDER BY event.mtime DESC", -1 );
|
| ︙ | ︙ | |||
156 157 158 159 160 161 162 | @ <channel> @ <title>%h(zProjectName)</title> @ <link>%s(g.zBaseURL)</link> @ <description>%h(zProjectDescr)</description> @ <pubDate>%s(zPubDate)</pubDate> @ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator> free(zPubDate); | | | 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
@ <channel>
@ <title>%h(zProjectName)</title>
@ <link>%s(g.zBaseURL)</link>
@ <description>%h(zProjectDescr)</description>
@ <pubDate>%s(zPubDate)</pubDate>
@ <generator>Fossil version %s(MANIFEST_VERSION) %s(MANIFEST_DATE)</generator>
free(zPubDate);
db_prepare(&q, "%s", blob_sql_text(&bSQL));
blob_reset( &bSQL );
while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){
const char *zId = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 3);
const char *zAuthor = db_column_text(&q, 4);
char *zPrefix = "";
char *zDate;
|
| ︙ | ︙ | |||
210 211 212 213 214 215 216 | ** Usage: %fossil rss ?OPTIONS? ** ** The CLI variant of the /timeline.rss page, this produces an RSS ** feed of the timeline to stdout. Options: ** ** -type|y FLAG ** may be: all (default), ci (show checkins only), t (show tickets only), | | > > > | 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 | ** Usage: %fossil rss ?OPTIONS? ** ** The CLI variant of the /timeline.rss page, this produces an RSS ** feed of the timeline to stdout. Options: ** ** -type|y FLAG ** may be: all (default), ci (show checkins only), t (show tickets only), ** w (show wiki only). ** ** -limit|n LIMIT ** The maximum number of items to show. ** ** -tkt UUID ** Filters for only those events for the specified ticket. ** ** -tag TAG ** filters for a tag ** |
| ︙ | ︙ | |||
266 267 268 269 270 271 272 273 274 275 276 |
}
if(!zBaseURL || !*zBaseURL){
zBaseURL = "URL-PLACEHOLDER";
}
db_find_and_open_repository(0, 0);
blob_zero(&bSQL);
blob_append( &bSQL, zSQL1, -1 );
if( zType[0]!='a' ){
| > > > | | 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 |
}
if(!zBaseURL || !*zBaseURL){
zBaseURL = "URL-PLACEHOLDER";
}
db_find_and_open_repository(0, 0);
/* We should be done with options.. */
verify_all_options();
blob_zero(&bSQL);
blob_append( &bSQL, zSQL1, -1 );
if( zType[0]!='a' ){
blob_append_sql(&bSQL, " AND event.type=%Q", zType);
}
if( zTicketUuid ){
nTagId = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
zTicketUuid);
if ( nTagId==0 ){
nTagId = -1;
|
| ︙ | ︙ | |||
296 297 298 299 300 301 302 |
nTagId = -1;
}
}else{
nTagId = 0;
}
if( nTagId==-1 ){
| | | | | 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 |
nTagId = -1;
}
}else{
nTagId = 0;
}
if( nTagId==-1 ){
blob_append_sql(&bSQL, " AND 0");
}else if( nTagId!=0 ){
blob_append_sql(&bSQL, " AND (EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid))", nTagId);
}
if( zFilename ){
blob_append_sql(&bSQL,
" AND (SELECT mlink.fnid FROM mlink WHERE event.objid=mlink.mid) IN (SELECT fnid FROM filename WHERE name=%Q %s)",
zFilename, filename_collation()
);
}
blob_append( &bSQL, " ORDER BY event.mtime DESC", -1 );
|
| ︙ | ︙ | |||
333 334 335 336 337 338 339 |
fossil_print("<title>%h</title>\n", zProjectName);
fossil_print("<link>%s</link>\n", zBaseURL);
fossil_print("<description>%h</description>\n", zProjectDescr);
fossil_print("<pubDate>%s</pubDate>\n", zPubDate);
fossil_print("<generator>Fossil version %s %s</generator>\n",
MANIFEST_VERSION, MANIFEST_DATE);
free(zPubDate);
| | | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
fossil_print("<title>%h</title>\n", zProjectName);
fossil_print("<link>%s</link>\n", zBaseURL);
fossil_print("<description>%h</description>\n", zProjectDescr);
fossil_print("<pubDate>%s</pubDate>\n", zPubDate);
fossil_print("<generator>Fossil version %s %s</generator>\n",
MANIFEST_VERSION, MANIFEST_DATE);
free(zPubDate);
db_prepare(&q, "%s", blob_sql_text(&bSQL));
blob_reset( &bSQL );
while( db_step(&q)==SQLITE_ROW && nLine<nLimit ){
const char *zId = db_column_text(&q, 1);
const char *zCom = db_column_text(&q, 3);
const char *zAuthor = db_column_text(&q, 4);
char *zPrefix = "";
char *zDate;
|
| ︙ | ︙ |
Changes to src/search.c.
| ︙ | ︙ | |||
189 190 191 192 193 194 195 |
int i;
Blob sql = empty_blob;
Stmt q;
int iBest;
char fAll = NULL != find_option("all", "a", 0); /* If set, do not lop
off the end of the
results. */
| | | 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
int i;
Blob sql = empty_blob;
Stmt q;
int iBest;
char fAll = NULL != find_option("all", "a", 0); /* If set, do not lop
off the end of the
results. */
const char *zLimit = find_option("limit","n",1);
const char *zWidth = find_option("width","W",1);
int nLimit = zLimit ? atoi(zLimit) : -1000; /* Max number of matching
lines/entries to list */
int width;
if( zWidth ){
width = atoi(zWidth);
if( (width!=0) && (width<=20) ){
|
| ︙ | ︙ | |||
229 230 231 232 233 234 235 |
timeline_utc()
);
iBest = db_int(0, "SELECT max(x) FROM srch");
blob_append(&sql,
"SELECT rid, uuid, date, comment, 0, 0 FROM srch "
"WHERE 1 ", -1);
if(!fAll){
| | | | 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
timeline_utc()
);
iBest = db_int(0, "SELECT max(x) FROM srch");
blob_append(&sql,
"SELECT rid, uuid, date, comment, 0, 0 FROM srch "
"WHERE 1 ", -1);
if(!fAll){
blob_append_sql(&sql,"AND x>%d ", iBest/3);
}
blob_append(&sql, "ORDER BY x DESC, date DESC ", -1);
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
print_timeline(&q, nLimit, width, 0);
db_finalize(&q);
}
|
Changes to src/setup.c.
| ︙ | ︙ | |||
17 18 19 20 21 22 23 24 25 26 27 28 29 30 | ** ** Implementation of the Setup page */ #include "config.h" #include <assert.h> #include "setup.h" /* ** The table of web pages supported by this application is generated ** automatically by the "mkindex" program and written into a file ** named "page_index.h". We include that file here to get access ** to the table. */ #include "page_index.h" | > > > > | 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | ** ** Implementation of the Setup page */ #include "config.h" #include <assert.h> #include "setup.h" #if INTERFACE #define ArraySize(x) (sizeof(x)/sizeof(x[0])) #endif /* ** The table of web pages supported by this application is generated ** automatically by the "mkindex" program and written into a file ** named "page_index.h". We include that file here to get access ** to the table. */ #include "page_index.h" |
| ︙ | ︙ | |||
305 306 307 308 309 310 311 |
const char *zOldLogin;
int doWrite;
int uid, i;
int higherUser = 0; /* True if user being edited is SETUP and the */
/* user doing the editing is ADMIN. Disallow editing */
char *inherit[128];
int a[128];
| | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
const char *zOldLogin;
int doWrite;
int uid, i;
int higherUser = 0; /* True if user being edited is SETUP and the */
/* user doing the editing is ADMIN. Disallow editing */
char *inherit[128];
int a[128];
const char *oa[128];
/* Must have ADMIN privileges to access this page
*/
login_check_credentials();
if( !g.perm.Admin ){ login_needed(); return; }
/* Check to see if an ADMIN user is trying to edit a SETUP account.
|
| ︙ | ︙ | |||
373 374 375 376 377 378 379 |
@ <p><a href="setup_uedit?id=%d(uid)">[Bummer]</a></p>
style_footer();
return;
}
login_verify_csrf_secret();
db_multi_exec(
"REPLACE INTO user(uid,login,info,pw,cap,mtime) "
| | | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 |
@ <p><a href="setup_uedit?id=%d(uid)">[Bummer]</a></p>
style_footer();
return;
}
login_verify_csrf_secret();
db_multi_exec(
"REPLACE INTO user(uid,login,info,pw,cap,mtime) "
"VALUES(nullif(%d,0),%Q,%Q,%Q,%Q,now())",
uid, P("login"), P("info"), zPw, zCap
);
if( atoi(PD("all","0"))>0 ){
Blob sql;
char *zErr = 0;
blob_zero(&sql);
if( zOldLogin==0 ){
|
| ︙ | ︙ | |||
439 440 441 442 443 444 445 |
/* figure out inherited permissions */
memset(inherit, 0, sizeof(inherit));
if( fossil_strcmp(zLogin, "developer") ){
char *z1, *z2;
z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='developer'");
while( z1 && *z1 ){
inherit[0x7f & *(z1++)] =
| | | | | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 |
/* figure out inherited permissions */
memset(inherit, 0, sizeof(inherit));
if( fossil_strcmp(zLogin, "developer") ){
char *z1, *z2;
z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='developer'");
while( z1 && *z1 ){
inherit[0x7f & *(z1++)] =
"<span class=\"ueditInheritDeveloper\"><sub>[D]</sub></span>";
}
free(z2);
}
if( fossil_strcmp(zLogin, "reader") ){
char *z1, *z2;
z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='reader'");
while( z1 && *z1 ){
inherit[0x7f & *(z1++)] =
"<span class=\"ueditInheritReader\"><sub>[R]</sub></span>";
}
free(z2);
}
if( fossil_strcmp(zLogin, "anonymous") ){
char *z1, *z2;
z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='anonymous'");
while( z1 && *z1 ){
inherit[0x7f & *(z1++)] =
"<span class=\"ueditInheritAnonymous\"><sub>[A]</sub></span>";
}
free(z2);
}
if( fossil_strcmp(zLogin, "nobody") ){
char *z1, *z2;
z1 = z2 = db_text(0,"SELECT cap FROM user WHERE login='nobody'");
while( z1 && *z1 ){
inherit[0x7f & *(z1++)] =
"<span class=\"ueditInheritNobody\"><sub>[N]</sub></span>";
}
free(z2);
}
/* Begin generating the page
*/
style_submenu_element("Cancel", "Cancel", "setup_ulist");
if( uid ){
style_header("Edit User %h", zLogin);
}else{
style_header("Add A New User");
}
@ <div class="ueditCapBox">
@ <form action="%s(g.zPath)" method="post"><div>
login_insert_csrf_secret();
if( login_is_special(zLogin) ){
@ <input type="hidden" name="login" value="%s(zLogin)">
@ <input type="hidden" name="info" value="">
@ <input type="hidden" name="pw" value="*">
}
@ <script type='text/javascript'>
@ function updateCapabilityString(){
@ /*
@ ** This function updates the "#usetupEditCapability" span content
@ ** with the capabilities selected by the interactive user, based
@ ** upon the state of the capability checkboxes.
@ */
@ try {
@ var inputs = document.getElementsByTagName('input');
@ if( inputs && inputs.length ){
@ var output = document.getElementById('usetupEditCapability');
@ if( output ){
@ var permsIds = [], x = 0;
@ for(var i = 0; i < inputs.length; i++){
@ var e = inputs[i];
@ if( !e.name || !e.type ) continue;
@ if( e.type.toLowerCase()!=='checkbox' ) continue;
@ if( e.name.length===2 && e.name[0]==='a' ){
@ // looks like a capability checkbox
@ if( e.checked ){
@ // grab the second character of the element
@ // name, which is the textual flag for this
@ // capability, and then add it to the result
@ // array.
@ permsIds[x++] = e.name[1];
@ }
@ }
@ }
@ permsIds.sort();
@ output.innerHTML = permsIds.join('');
@ }
@ }
@ } catch (e) {
@ /* ignore errors */
@ }
@ }
@ </script>
@ <table>
@ <tr>
@ <td class="usetupEditLabel">User ID:</td>
if( uid ){
@ <td>%d(uid) <input type="hidden" name="id" value="%d(uid)" /></td>
}else{
@ <td>(new user)<input type="hidden" name="id" value="0" /></td>
|
| ︙ | ︙ | |||
514 515 516 517 518 519 520 |
@ </tr>
@ <tr>
@ <td class="usetupEditLabel">Capabilities:</td>
@ <td>
#define B(x) inherit[x]
@ <table border=0><tr><td valign="top">
if( g.perm.Setup ){
| | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > > > > | | | < | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > | | > > > > > > > | 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 |
@ </tr>
@ <tr>
@ <td class="usetupEditLabel">Capabilities:</td>
@ <td>
#define B(x) inherit[x]
@ <table border=0><tr><td valign="top">
if( g.perm.Setup ){
@ <label><input type="checkbox" name="as"%s(oa['s'])
@ onchange="updateCapabilityString()"/>
@ Setup%s(B('s'))</label><br />
}
@ <label><input type="checkbox" name="aa"%s(oa['a'])
@ onchange="updateCapabilityString()" />
@ Admin%s(B('a'))</label><br />
@ <label><input type="checkbox" name="ad"%s(oa['d'])
@ onchange="updateCapabilityString()" />
@ Delete%s(B('d'))</label><br />
@ <label><input type="checkbox" name="ae"%s(oa['e'])
@ onchange="updateCapabilityString()" />
@ Email%s(B('e'))</label><br />
@ <label><input type="checkbox" name="ap"%s(oa['p'])
@ onchange="updateCapabilityString()" />
@ Password%s(B('p'))</label><br />
@ <label><input type="checkbox" name="ai"%s(oa['i'])
@ onchange="updateCapabilityString()" />
@ Check-In%s(B('i'))</label><br />
@ <label><input type="checkbox" name="ao"%s(oa['o'])
@ onchange="updateCapabilityString()" />
@ Check-Out%s(B('o'))</label><br />
@ <label><input type="checkbox" name="ah"%s(oa['h'])
@ onchange="updateCapabilityString()" />
@ Hyperlinks%s(B('h'))</label><br />
@ <label><input type="checkbox" name="ab"%s(oa['b'])
@ onchange="updateCapabilityString()" />
@ Attachments%s(B('b'))</label><br />
@ </td><td><td width="40"></td><td valign="top">
@ <label><input type="checkbox" name="au"%s(oa['u'])
@ onchange="updateCapabilityString()" />
@ Reader%s(B('u'))</label><br />
@ <label><input type="checkbox" name="av"%s(oa['v'])
@ onchange="updateCapabilityString()" />
@ Developer%s(B('v'))</label><br />
@ <label><input type="checkbox" name="ag"%s(oa['g'])
@ onchange="updateCapabilityString()" />
@ Clone%s(B('g'))</label><br />
@ <label><input type="checkbox" name="aj"%s(oa['j'])
@ onchange="updateCapabilityString()" />
@ Read Wiki%s(B('j'))</label><br />
@ <label><input type="checkbox" name="af"%s(oa['f'])
@ onchange="updateCapabilityString()" />
@ New Wiki%s(B('f'))</label><br />
@ <label><input type="checkbox" name="am"%s(oa['m'])
@ onchange="updateCapabilityString()" />
@ Append Wiki%s(B('m'))</label><br />
@ <label><input type="checkbox" name="ak"%s(oa['k'])
@ onchange="updateCapabilityString()" />
@ Write Wiki%s(B('k'))</label><br />
@ <label><input type="checkbox" name="al"%s(oa['l'])
@ onchange="updateCapabilityString()" />
@ Moderate Wiki%s(B('l'))</label><br />
@ </td><td><td width="40"></td><td valign="top">
@ <label><input type="checkbox" name="ar"%s(oa['r'])
@ onchange="updateCapabilityString()" />
@ Read Ticket%s(B('r'))</label><br />
@ <label><input type="checkbox" name="an"%s(oa['n'])
@ onchange="updateCapabilityString()" />
@ New Tickets%s(B('n'))</label><br />
@ <label><input type="checkbox" name="ac"%s(oa['c'])
@ onchange="updateCapabilityString()" />
@ Append To Ticket%s(B('c'))</label><br />
@ <label><input type="checkbox" name="aw"%s(oa['w'])
@ onchange="updateCapabilityString()" />
@ Write Tickets%s(B('w'))</label><br />
@ <label><input type="checkbox" name="aq"%s(oa['q'])
@ onchange="updateCapabilityString()" />
@ Moderate Tickets%s(B('q'))</label><br />
@ <label><input type="checkbox" name="at"%s(oa['t'])
@ onchange="updateCapabilityString()" />
@ Ticket Report%s(B('t'))</label><br />
@ <label><input type="checkbox" name="ax"%s(oa['x'])
@ onchange="updateCapabilityString()" />
@ Private%s(B('x'))</label><br />
@ <label><input type="checkbox" name="az"%s(oa['z'])
@ onchange="updateCapabilityString()" />
@ Download Zip%s(B('z'))</label>
@ </td></tr>
@ </table>
@ </td>
@ </tr>
@ <tr>
@ <td class="usetupEditLabel">Selected Cap.:</td>
@ <td>
@ <span id="usetupEditCapability">(missing JS?)</span>
@ </td>
@ </tr>
if( !login_is_special(zLogin) ){
@ <tr>
@ <td align="right">Password:</td>
if( zPw[0] ){
/* Obscure the password for all users */
|
| ︙ | ︙ | |||
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
@ <td> </td>
@ <td><input type="submit" name="submit" value="Apply Changes" /></td>
@ </tr>
}
@ </table>
@ </div></form>
@ </div>
@ <h2>Privileges And Capabilities:</h2>
@ <ul>
if( higherUser ){
@ <li><p class="missingPriv">
@ User %h(zLogin) has Setup privileges and you only have Admin privileges
@ so you are not permitted to make changes to %h(zLogin).
@ </p></li>
@
}
@ <li><p>
@ The <span class="capability">Setup</span> user can make arbitrary
@ configuration changes. An <span class="usertype">Admin</span> user
@ can add other users and change user privileges
@ and reset user passwords. Both automatically get all other privileges
@ listed below. Use these two settings with discretion.
@ </p></li>
@
@ <li><p>
| > | | | | | 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 |
@ <td> </td>
@ <td><input type="submit" name="submit" value="Apply Changes" /></td>
@ </tr>
}
@ </table>
@ </div></form>
@ </div>
@ <script type='text/javascript'>updateCapabilityString();</script>
@ <h2>Privileges And Capabilities:</h2>
@ <ul>
if( higherUser ){
@ <li><p class="missingPriv">
@ User %h(zLogin) has Setup privileges and you only have Admin privileges
@ so you are not permitted to make changes to %h(zLogin).
@ </p></li>
@
}
@ <li><p>
@ The <span class="capability">Setup</span> user can make arbitrary
@ configuration changes. An <span class="usertype">Admin</span> user
@ can add other users and change user privileges
@ and reset user passwords. Both automatically get all other privileges
@ listed below. Use these two settings with discretion.
@ </p></li>
@
@ <li><p>
@ The "<span class="ueditInheritNobody"><sub>N</sub></span>" subscript suffix
@ indicates the privileges of <span class="usertype">nobody</span> that
@ are available to all users regardless of whether or not they are logged in.
@ </p></li>
@
@ <li><p>
@ The "<span class="ueditInheritAnonymous"><sub>A</sub></span>" subscript suffix
@ indicates the privileges of <span class="usertype">anonymous</span> that
@ are inherited by all logged-in users.
@ </p></li>
@
@ <li><p>
@ The "<span class="ueditInheritDeveloper"><sub>D</sub></span>" subscript suffix
@ indicates the privileges of <span class="usertype">developer</span> that
@ are inherited by all users with the
@ <span class="capability">Developer</span> privilege.
@ </p></li>
@
@ <li><p>
@ The "<span class="ueditInheritReader"><sub>R</sub></span>" subscript suffix
@ indicates the privileges of <span class="usertype">reader</span> that
@ are inherited by all users with the <span class="capability">Reader</span>
@ privilege.
@ </p></li>
@
@ <li><p>
@ The <span class="capability">Delete</span> privilege give the user the
|
| ︙ | ︙ | |||
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
@ if it does, your server will end up computing diffs and annotations for
@ every historical version of every file and creating ZIPs and tarballs of
@ every historical check-in, which can use a lot of CPU and bandwidth
@ even for relatively small projects.</p>
@
@ <p>Additional parameters that control this behavior:</p>
@ <blockquote>
onoff_attribute("Require mouse movement before enabling hyperlinks",
"auto-hyperlink-mouseover", "ahmo", 0, 0);
@ <br>
entry_attribute("Delay before enabling hyperlinks (milliseconds)", 5,
"auto-hyperlink-delay", "ah-delay", "10", 0);
@ </blockquote>
@ <p>Hyperlinks for user "nobody" are normally enabled as soon as the page
| > > > > | 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 |
@ if it does, your server will end up computing diffs and annotations for
@ every historical version of every file and creating ZIPs and tarballs of
@ every historical check-in, which can use a lot of CPU and bandwidth
@ even for relatively small projects.</p>
@
@ <p>Additional parameters that control this behavior:</p>
@ <blockquote>
onoff_attribute("Enable hyperlinks for humans (as deduced from the UserAgent "
" HTTP header string)",
"auto-hyperlink-ishuman", "ahis", 0, 0);
@ <br>
onoff_attribute("Require mouse movement before enabling hyperlinks",
"auto-hyperlink-mouseover", "ahmo", 0, 0);
@ <br>
entry_attribute("Delay before enabling hyperlinks (milliseconds)", 5,
"auto-hyperlink-delay", "ah-delay", "10", 0);
@ </blockquote>
@ <p>Hyperlinks for user "nobody" are normally enabled as soon as the page
|
| ︙ | ︙ | |||
1085 1086 1087 1088 1089 1090 1091 |
const char *zNewName = PD("newname", "New Login Group");
login_check_credentials();
if( !g.perm.Setup ){
login_needed();
}
file_canonical_name(g.zRepositoryName, &fullName, 0);
| | | 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 |
const char *zNewName = PD("newname", "New Login Group");
login_check_credentials();
if( !g.perm.Setup ){
login_needed();
}
file_canonical_name(g.zRepositoryName, &fullName, 0);
zSelfRepo = fossil_strdup(blob_str(&fullName));
blob_reset(&fullName);
if( P("join")!=0 ){
login_group_join(zRepo, zLogin, zPw, zNewName, &zErrMsg);
}else if( P("leave") ){
login_group_leave(&zErrMsg);
}
style_header("Login Group Configuration");
|
| ︙ | ︙ | |||
1172 1173 1174 1175 1176 1177 1178 |
void setup_timeline(void){
double tmDiff;
char zTmDiff[20];
static const char *const azTimeFormats[] = {
"0", "HH:MM",
"1", "HH:MM:SS",
"2", "YYYY-MM-DD HH:MM",
| | > | 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 |
void setup_timeline(void){
double tmDiff;
char zTmDiff[20];
static const char *const azTimeFormats[] = {
"0", "HH:MM",
"1", "HH:MM:SS",
"2", "YYYY-MM-DD HH:MM",
"3", "YYMMDD HH:MM",
"4", "(off)"
};
login_check_credentials();
if( !g.perm.Setup ){
login_needed();
}
style_header("Timeline Display Preferences");
|
| ︙ | ︙ | |||
1218 1219 1220 1221 1222 1223 1224 |
sqlite3_snprintf(sizeof(zTmDiff), zTmDiff, "%.1f", -tmDiff);
@ %s(zTmDiff) hours behind UTC.</p>
}else{
@ %s(zTmDiff) hours ahead of UTC.</p>
}
@ <hr />
| | | | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
sqlite3_snprintf(sizeof(zTmDiff), zTmDiff, "%.1f", -tmDiff);
@ %s(zTmDiff) hours behind UTC.</p>
}else{
@ %s(zTmDiff) hours ahead of UTC.</p>
}
@ <hr />
multiple_choice_attribute("Per-Item Time Format", "timeline-date-format",
"tdf", "0", ArraySize(azTimeFormats)/2, azTimeFormats);
@ <p>If the "HH:MM" or "HH:MM:SS" format is selected, then the date is shown
@ in a separate box (using CSS class "timelineDate") whenever the date changes.
@ With the "YYYY-MM-DD HH:MM" and "YYMMDD ..." formats, the complete date
@ and time is shown on every timeline entry (using the CSS class "timelineTime").</p>
@ <hr />
onoff_attribute("Show version differences by default",
|
| ︙ | ︙ | |||
1259 1260 1261 1262 1263 1264 1265 |
login_check_credentials();
if( !g.perm.Setup ){
login_needed();
}
(void) aCmdHelp; /* NOTE: Silence compiler warning. */
style_header("Settings");
| > > > | > | 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 |
login_check_credentials();
if( !g.perm.Setup ){
login_needed();
}
(void) aCmdHelp; /* NOTE: Silence compiler warning. */
style_header("Settings");
if(!g.repositoryOpen){
/* Provide read-only access to versioned settings,
but only if no repo file was explicitly provided. */
db_open_local(0);
}
db_begin_transaction();
@ <p>This page provides a simple interface to the "fossil setting" command.
@ See the "fossil help setting" output below for further information on
@ the meaning of each setting.</p><hr />
@ <form action="%s(g.zTop)/setup_settings" method="post"><div>
@ <table border="0"><tr><td valign="top">
login_insert_csrf_secret();
|
| ︙ | ︙ |
Changes to src/shell.c.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 36 37 38 39 40 41 42 | #endif #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "sqlite3.h" #include <ctype.h> #include <stdarg.h> #if !defined(_WIN32) && !defined(WIN32) # include <signal.h> # if !defined(__RTP__) && !defined(_WRS_KERNEL) # include <pwd.h> | > > > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | #endif #include <stdlib.h> #include <string.h> #include <stdio.h> #include <assert.h> #include "sqlite3.h" #if SQLITE_USER_AUTHENTICATION # include "sqlite3userauth.h" #endif #include <ctype.h> #include <stdarg.h> #if !defined(_WIN32) && !defined(WIN32) # include <signal.h> # if !defined(__RTP__) && !defined(_WRS_KERNEL) # include <pwd.h> |
| ︙ | ︙ | |||
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | # define read_history(X) # define write_history(X) # define stifle_history(X) #endif #if defined(_WIN32) || defined(WIN32) # include <io.h> #define isatty(h) _isatty(h) #ifndef access # define access(f,m) _access((f),(m)) #endif #undef popen #define popen _popen #undef pclose | > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | # define read_history(X) # define write_history(X) # define stifle_history(X) #endif #if defined(_WIN32) || defined(WIN32) # include <io.h> # include <fcntl.h> #define isatty(h) _isatty(h) #ifndef access # define access(f,m) _access((f),(m)) #endif #undef popen #define popen _popen #undef pclose |
| ︙ | ︙ | |||
427 428 429 430 431 432 433 |
fflush(stdout);
zResult = local_getline(zPrior, stdin);
#endif
}
return zResult;
}
| > > > > > | | | | | > | < < > | > > < | < > > > > > > > | 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 |
fflush(stdout);
zResult = local_getline(zPrior, stdin);
#endif
}
return zResult;
}
/*
** Shell output mode information from before ".explain on",
** saved so that it can be restored by ".explain off"
*/
typedef struct SavedModeInfo SavedModeInfo;
struct SavedModeInfo {
int valid; /* Is there legit data in here? */
int mode; /* Mode prior to ".explain on" */
int showHeader; /* The ".header" setting prior to ".explain on" */
int colWidth[100]; /* Column widths prior to ".explain on" */
};
/*
** State information about the database connection is contained in an
** instance of the following structure.
*/
typedef struct ShellState ShellState;
struct ShellState {
sqlite3 *db; /* The database */
int echoOn; /* True to echo input commands */
int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
int statsOn; /* True to display memory stats before each finalize */
int outCount; /* Revert to stdout when reaching zero */
int cnt; /* Number of records displayed so far */
FILE *out; /* Write results here */
FILE *traceOut; /* Output for sqlite3_trace() */
int nErr; /* Number of errors seen */
int mode; /* An output mode setting */
int writableSchema; /* True if PRAGMA writable_schema=ON */
int showHeader; /* True to show column names in List or Column mode */
unsigned shellFlgs; /* Various flags */
char *zDestTable; /* Name of destination table when MODE_Insert */
char separator[20]; /* Separator character for MODE_List */
char newline[20]; /* Record separator in MODE_Csv */
int colWidth[100]; /* Requested width of each column when in column mode*/
int actualWidth[100]; /* Actual width of each column */
char nullvalue[20]; /* The text to print when a NULL comes back from
** the database */
SavedModeInfo normalMode;/* Holds the mode just before .explain ON */
char outfile[FILENAME_MAX]; /* Filename for *out */
const char *zDbFilename; /* name of the database file */
char *zFreeOnClose; /* Filename to free when closing */
const char *zVfs; /* Name of VFS to use */
sqlite3_stmt *pStmt; /* Current statement if any. */
FILE *pLog; /* Write log output here */
int *aiIndent; /* Array of indents used in MODE_Explain */
int nIndent; /* Size of array aiIndent[] */
int iIndent; /* Index of current op in aiIndent[] */
};
/*
** These are the allowed shellFlgs values
*/
#define SHFLG_Scratch 0x00001 /* The --scratch option is used */
#define SHFLG_Pagecache 0x00002 /* The --pagecache option is used */
#define SHFLG_Lookaside 0x00004 /* Lookaside memory is used */
/*
** These are the allowed modes.
*/
#define MODE_Line 0 /* One column per line. Blank line between records */
#define MODE_Column 1 /* One record per line in neat columns */
#define MODE_List 2 /* One record per line with a separator */
#define MODE_Semi 3 /* Same as MODE_List but append ";" to each line */
|
| ︙ | ︙ | |||
516 517 518 519 520 521 522 |
return 0x3fffffff & (int)(z2 - z);
}
/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
| | | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 |
return 0x3fffffff & (int)(z2 - z);
}
/*
** A callback for the sqlite3_log() interface.
*/
static void shellLog(void *pArg, int iErrCode, const char *zMsg){
ShellState *p = (ShellState*)pArg;
if( p->pLog==0 ) return;
fprintf(p->pLog, "(%d) %s\n", iErrCode, zMsg);
fflush(p->pLog);
}
/*
** Output the given string as a hex-encoded blob (eg. X'1234' )
|
| ︙ | ︙ | |||
655 656 657 658 659 660 661 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, }; /* ** Output a single term of CSV. Actually, p->separator is used for ** the separator, which may or may not be a comma. p->nullvalue is | | > | | 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
};
/*
** Output a single term of CSV. Actually, p->separator is used for
** the separator, which may or may not be a comma. p->nullvalue is
** the null value. Strings are quoted if necessary. The separator
** is only issued if bSep is true.
*/
static void output_csv(ShellState *p, const char *z, int bSep){
FILE *out = p->out;
if( z==0 ){
fprintf(out,"%s",p->nullvalue);
}else{
int i;
int nSep = strlen30(p->separator);
for(i=0; z[i]; i++){
|
| ︙ | ︙ | |||
706 707 708 709 710 711 712 |
/*
** This is the callback routine that the shell
** invokes for each row of a query result.
*/
static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){
int i;
| | | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 |
/*
** This is the callback routine that the shell
** invokes for each row of a query result.
*/
static int shell_callback(void *pArg, int nArg, char **azArg, char **azCol, int *aiType){
int i;
ShellState *p = (ShellState*)pArg;
switch( p->mode ){
case MODE_Line: {
int w = 5;
if( azArg==0 ) break;
for(i=0; i<nArg; i++){
int len = strlen30(azCol[i] ? azCol[i] : "");
|
| ︙ | ︙ | |||
851 852 853 854 855 856 857 858 859 860 861 |
output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
if(i<nArg-1) fprintf(p->out, "%s", p->separator);
}
fprintf(p->out,"\n");
break;
}
case MODE_Csv: {
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
}
| > > > > | | | | | | > > > > > | 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
output_c_string(p->out, azArg[i] ? azArg[i] : p->nullvalue);
if(i<nArg-1) fprintf(p->out, "%s", p->separator);
}
fprintf(p->out,"\n");
break;
}
case MODE_Csv: {
#if defined(WIN32) || defined(_WIN32)
fflush(p->out);
_setmode(_fileno(p->out), _O_BINARY);
#endif
if( p->cnt++==0 && p->showHeader ){
for(i=0; i<nArg; i++){
output_csv(p, azCol[i] ? azCol[i] : "", i<nArg-1);
}
fprintf(p->out,"%s",p->newline);
}
if( nArg>0 ){
for(i=0; i<nArg; i++){
output_csv(p, azArg[i], i<nArg-1);
}
fprintf(p->out,"%s",p->newline);
}
#if defined(WIN32) || defined(_WIN32)
fflush(p->out);
_setmode(_fileno(p->out), _O_TEXT);
#endif
break;
}
case MODE_Insert: {
p->cnt++;
if( azArg==0 ) break;
fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
for(i=0; i<nArg; i++){
|
| ︙ | ︙ | |||
907 908 909 910 911 912 913 |
*/
static int callback(void *pArg, int nArg, char **azArg, char **azCol){
/* since we don't have type info, call the shell_callback with a NULL value */
return shell_callback(pArg, nArg, azArg, azCol, NULL);
}
/*
| | | | 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 |
*/
static int callback(void *pArg, int nArg, char **azArg, char **azCol){
/* since we don't have type info, call the shell_callback with a NULL value */
return shell_callback(pArg, nArg, azArg, azCol, NULL);
}
/*
** Set the destination table field of the ShellState structure to
** the name of the table given. Escape any quote characters in the
** table name.
*/
static void set_table_name(ShellState *p, const char *zName){
int i, n;
int needQuote;
char *z;
if( p->zDestTable ){
free(p->zDestTable);
p->zDestTable = 0;
|
| ︙ | ︙ | |||
1001 1002 1003 1004 1005 1006 1007 | ** ** If the number of columns is 1 and that column contains text "--" ** then write the semicolon on a separate line. That way, if a ** "--" comment occurs at the end of the statement, the comment ** won't consume the semicolon terminator. */ static int run_table_dump_query( | | | 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 |
**
** If the number of columns is 1 and that column contains text "--"
** then write the semicolon on a separate line. That way, if a
** "--" comment occurs at the end of the statement, the comment
** won't consume the semicolon terminator.
*/
static int run_table_dump_query(
ShellState *p, /* Query context */
const char *zSelect, /* SELECT statement to extract content */
const char *zFirstRow /* Print before first row, if not NULL */
){
sqlite3_stmt *pSelect;
int rc;
int nResult;
int i;
|
| ︙ | ︙ | |||
1064 1065 1066 1067 1068 1069 1070 | } /* ** Display memory stats. */ static int display_stats( sqlite3 *db, /* Database to query */ | | < < > | | | < > < < > | | | < > > | | | | | | | | | > | 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 |
}
/*
** Display memory stats.
*/
static int display_stats(
sqlite3 *db, /* Database to query */
ShellState *pArg, /* Pointer to ShellState */
int bReset /* True to reset the stats */
){
int iCur;
int iHiwtr;
if( pArg && pArg->out ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Memory Used: %d (max %d) bytes\n", iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_COUNT, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Number of Outstanding Allocations: %d (max %d)\n", iCur, iHiwtr);
if( pArg->shellFlgs & SHFLG_Pagecache ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_USED, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Number of Pcache Pages Used: %d (max %d) pages\n", iCur, iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_OVERFLOW, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Number of Pcache Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
if( pArg->shellFlgs & SHFLG_Scratch ){
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_USED, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Number of Scratch Allocations Used: %d (max %d)\n", iCur, iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_OVERFLOW, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Number of Scratch Overflow Bytes: %d (max %d) bytes\n", iCur, iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_MALLOC_SIZE, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Largest Allocation: %d bytes\n", iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PAGECACHE_SIZE, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Largest Pcache Allocation: %d bytes\n", iHiwtr);
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_SCRATCH_SIZE, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Largest Scratch Allocation: %d bytes\n", iHiwtr);
#ifdef YYTRACKMAXSTACKDEPTH
iHiwtr = iCur = -1;
sqlite3_status(SQLITE_STATUS_PARSER_STACK, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Deepest Parser Stack: %d (max %d)\n", iCur, iHiwtr);
#endif
}
if( pArg && pArg->out && db ){
if( pArg->shellFlgs & SHFLG_Lookaside ){
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_USED, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Lookaside Slots Used: %d (max %d)\n", iCur, iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_HIT, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Successful lookaside attempts: %d\n", iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Lookaside failures due to size: %d\n", iHiwtr);
sqlite3_db_status(db, SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Lookaside failures due to OOM: %d\n", iHiwtr);
}
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_USED, &iCur, &iHiwtr, bReset);
fprintf(pArg->out, "Pager Heap Usage: %d bytes\n", iCur); iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_HIT, &iCur, &iHiwtr, 1);
fprintf(pArg->out, "Page cache hits: %d\n", iCur);
iHiwtr = iCur = -1;
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
|
| ︙ | ︙ | |||
1171 1172 1173 1174 1175 1176 1177 |
if( 0==strcmp(zStr, azArray[i]) ) return 1;
}
return 0;
}
/*
** If compiled statement pSql appears to be an EXPLAIN statement, allocate
| | | | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 |
if( 0==strcmp(zStr, azArray[i]) ) return 1;
}
return 0;
}
/*
** If compiled statement pSql appears to be an EXPLAIN statement, allocate
** and populate the ShellState.aiIndent[] array with the number of
** spaces each opcode should be indented before it is output.
**
** The indenting rules are:
**
** * For each "Next", "Prev", "VNext" or "VPrev" instruction, indent
** all opcodes that occur between the p2 jump destination and the opcode
** itself by 2 spaces.
**
** * For each "Goto", if the jump destination is earlier in the program
** and ends on one of:
** Yield SeekGt SeekLt RowSetRead Rewind
** or if the P1 parameter is one instead of zero,
** then indent all opcodes between the earlier instruction
** and "Goto" by 2 spaces.
*/
static void explain_data_prepare(ShellState *p, sqlite3_stmt *pSql){
const char *zSql; /* The text of the SQL statement */
const char *z; /* Used to check if this is an EXPLAIN */
int *abYield = 0; /* True if op is an OP_Yield */
int nAlloc = 0; /* Allocated size of p->aiIndent[], abYield */
int iOp; /* Index of operation in p->aiIndent[] */
const char *azNext[] = { "Next", "Prev", "VPrev", "VNext", "SorterNext",
|
| ︙ | ︙ | |||
1247 1248 1249 1250 1251 1252 1253 | sqlite3_free(abYield); sqlite3_reset(pSql); } /* ** Free the array allocated by explain_data_prepare(). */ | | | | | | | | 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 |
sqlite3_free(abYield);
sqlite3_reset(pSql);
}
/*
** Free the array allocated by explain_data_prepare().
*/
static void explain_data_delete(ShellState *p){
sqlite3_free(p->aiIndent);
p->aiIndent = 0;
p->nIndent = 0;
p->iIndent = 0;
}
/*
** Execute a statement or set of statements. Print
** any result rows/columns depending on the current mode
** set via the supplied callback.
**
** This is very similar to SQLite's built-in sqlite3_exec()
** function except it takes a slightly different callback
** and callback data argument.
*/
static int shell_exec(
sqlite3 *db, /* An open database */
const char *zSql, /* SQL to be evaluated */
int (*xCallback)(void*,int,char**,char**,int*), /* Callback function */
/* (not the same as sqlite3_exec) */
ShellState *pArg, /* Pointer to ShellState */
char **pzErrMsg /* Error msg written here */
){
sqlite3_stmt *pStmt = NULL; /* Statement to execute. */
int rc = SQLITE_OK; /* Return Code */
int rc2;
const char *zLeftover; /* Tail of unprocessed SQL */
if( pzErrMsg ){
|
| ︙ | ︙ | |||
1323 1324 1325 1326 1327 1328 1329 1330 |
fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
}
}
sqlite3_finalize(pExplain);
sqlite3_free(zEQP);
}
/* Output TESTCTRL_EXPLAIN text of requested */
| > | > | 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 |
fprintf(pArg->out,"%s\n", sqlite3_column_text(pExplain, 3));
}
}
sqlite3_finalize(pExplain);
sqlite3_free(zEQP);
}
#if USE_SYSTEM_SQLITE+0==1
/* Output TESTCTRL_EXPLAIN text of requested */
if( pArg && pArg->mode==MODE_Explain && sqlite3_libversion_number()<3008007 ){
const char *zExplain = 0;
sqlite3_test_control(SQLITE_TESTCTRL_EXPLAIN_STMT, pStmt, &zExplain);
if( zExplain && zExplain[0] ){
fprintf(pArg->out, "%s", zExplain);
}
}
#endif
/* If the shell is currently in ".explain" mode, gather the extra
** data required to add indents to the output.*/
if( pArg && pArg->mode==MODE_Explain ){
explain_data_prepare(pArg, pStmt);
}
|
| ︙ | ︙ | |||
1437 1438 1439 1440 1441 1442 1443 |
*/
static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
int rc;
const char *zTable;
const char *zType;
const char *zSql;
const char *zPrepStmt = 0;
| | | 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 |
*/
static int dump_callback(void *pArg, int nArg, char **azArg, char **azCol){
int rc;
const char *zTable;
const char *zType;
const char *zSql;
const char *zPrepStmt = 0;
ShellState *p = (ShellState *)pArg;
UNUSED_PARAMETER(azCol);
if( nArg!=3 ) return 1;
zTable = azArg[0];
zType = azArg[1];
zSql = azArg[2];
|
| ︙ | ︙ | |||
1533 1534 1535 1536 1537 1538 1539 | ** Run zQuery. Use dump_callback() as the callback routine so that ** the contents of the query are output as SQL statements. ** ** If we get a SQLITE_CORRUPT error, rerun the query after appending ** "ORDER BY rowid DESC" to the end. */ static int run_schema_dump_query( | | | 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 |
** Run zQuery. Use dump_callback() as the callback routine so that
** the contents of the query are output as SQL statements.
**
** If we get a SQLITE_CORRUPT error, rerun the query after appending
** "ORDER BY rowid DESC" to the end.
*/
static int run_schema_dump_query(
ShellState *p,
const char *zQuery
){
int rc;
char *zErr = 0;
rc = sqlite3_exec(p->db, zQuery, dump_callback, p, &zErr);
if( rc==SQLITE_CORRUPT ){
char *zQ2;
|
| ︙ | ︙ | |||
1615 1616 1617 1618 1619 1620 1621 | ".quit Exit this program\n" ".read FILENAME Execute SQL in FILENAME\n" ".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n" ".save FILE Write in-memory database into FILE\n" ".schema ?TABLE? Show the CREATE statements\n" " If TABLE specified, only show tables matching\n" " LIKE pattern TABLE.\n" | | > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > | 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 |
".quit Exit this program\n"
".read FILENAME Execute SQL in FILENAME\n"
".restore ?DB? FILE Restore content of DB (default \"main\") from FILE\n"
".save FILE Write in-memory database into FILE\n"
".schema ?TABLE? Show the CREATE statements\n"
" If TABLE specified, only show tables matching\n"
" LIKE pattern TABLE.\n"
".separator STRING ?NL? Change separator used by output mode and .import\n"
" NL is the end-of-line mark for CSV\n"
".shell CMD ARGS... Run CMD ARGS... in a system shell\n"
".show Show the current values for various settings\n"
".stats on|off Turn stats on or off\n"
".system CMD ARGS... Run CMD ARGS... in a system shell\n"
".tables ?TABLE? List names of tables\n"
" If TABLE specified, only list tables matching\n"
" LIKE pattern TABLE.\n"
".timeout MS Try opening locked tables for MS milliseconds\n"
".timer on|off Turn SQL timer on or off\n"
".trace FILE|off Output each SQL statement as it is run\n"
".vfsname ?AUX? Print the name of the VFS stack\n"
".width NUM1 NUM2 ... Set column widths for \"column\" mode\n"
" Negative values right-justify\n"
;
/* Forward reference */
static int process_input(ShellState *p, FILE *in);
/*
** Implementation of the "readfile(X)" SQL function. The entire content
** of the file named X is read and returned as a BLOB. NULL is returned
** if the file does not exist or is unreadable.
*/
static void readfileFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
const char *zName;
FILE *in;
long nIn;
void *pBuf;
zName = (const char*)sqlite3_value_text(argv[0]);
if( zName==0 ) return;
in = fopen(zName, "rb");
if( in==0 ) return;
fseek(in, 0, SEEK_END);
nIn = ftell(in);
rewind(in);
pBuf = sqlite3_malloc( nIn );
if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
}else{
sqlite3_free(pBuf);
}
fclose(in);
}
/*
** Implementation of the "writefile(X,Y)" SQL function. The argument Y
** is written into file X. The number of bytes written is returned. Or
** NULL is returned if something goes wrong, such as being unable to open
** file X for writing.
*/
static void writefileFunc(
sqlite3_context *context,
int argc,
sqlite3_value **argv
){
FILE *out;
const char *z;
sqlite3_int64 rc;
const char *zFile;
zFile = (const char*)sqlite3_value_text(argv[0]);
if( zFile==0 ) return;
out = fopen(zFile, "wb");
if( out==0 ) return;
z = (const char*)sqlite3_value_blob(argv[1]);
if( z==0 ){
rc = 0;
}else{
rc = fwrite(z, 1, sqlite3_value_bytes(argv[1]), out);
}
fclose(out);
sqlite3_result_int64(context, rc);
}
/*
** Make sure the database is open. If it is not, then open it. If
** the database fails to open, print an error message and exit.
*/
static void open_db(ShellState *p, int keepAlive){
if( p->db==0 ){
sqlite3_initialize();
sqlite3_open(p->zDbFilename, &p->db);
db = p->db;
if( db && sqlite3_errcode(db)==SQLITE_OK ){
sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
shellstaticFunc, 0, 0);
}
if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
fprintf(stderr,"Error: unable to open database \"%s\": %s\n",
p->zDbFilename, sqlite3_errmsg(db));
if( keepAlive ) return;
exit(1);
}
#ifndef SQLITE_OMIT_LOAD_EXTENSION
sqlite3_enable_load_extension(p->db, 1);
#endif
sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
readfileFunc, 0, 0);
sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
writefileFunc, 0, 0);
}
}
/*
** Do C-language style dequoting.
**
** \t -> tab
|
| ︙ | ︙ | |||
1815 1816 1817 1818 1819 1820 1821 |
}
/*
** A routine for handling output from sqlite3_trace().
*/
static void sql_trace_callback(void *pArg, const char *z){
FILE *f = (FILE*)pArg;
| | > > > > | 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 |
}
/*
** A routine for handling output from sqlite3_trace().
*/
static void sql_trace_callback(void *pArg, const char *z){
FILE *f = (FILE*)pArg;
if( f ){
int i = (int)strlen(z);
while( i>0 && z[i-1]==';' ){ i--; }
fprintf(f, "%.*s;\n", i, z);
}
}
/*
** A no-op routine that runs with the ".breakpoint" doc-command. This is
** a useful spot to set a debugger breakpoint.
*/
static void test_breakpoint(void){
|
| ︙ | ︙ | |||
1933 1934 1935 1936 1937 1938 1939 | /* ** Try to transfer data for table zTable. If an error is seen while ** moving forward, try to go backwards. The backwards movement won't ** work for WITHOUT ROWID tables. */ static void tryToCloneData( | | | 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 |
/*
** Try to transfer data for table zTable. If an error is seen while
** moving forward, try to go backwards. The backwards movement won't
** work for WITHOUT ROWID tables.
*/
static void tryToCloneData(
ShellState *p,
sqlite3 *newDb,
const char *zTable
){
sqlite3_stmt *pQuery = 0;
sqlite3_stmt *pInsert = 0;
char *zQuery = 0;
char *zInsert = 0;
|
| ︙ | ︙ | |||
2046 2047 2048 2049 2050 2051 2052 | /* ** Try to transfer all rows of the schema that match zWhere. For ** each row, invoke xForEach() on the object defined by that row. ** If an error is encountered while moving forward through the ** sqlite_master table, try again moving backwards. */ static void tryToCloneSchema( | | | | 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 |
/*
** Try to transfer all rows of the schema that match zWhere. For
** each row, invoke xForEach() on the object defined by that row.
** If an error is encountered while moving forward through the
** sqlite_master table, try again moving backwards.
*/
static void tryToCloneSchema(
ShellState *p,
sqlite3 *newDb,
const char *zWhere,
void (*xForEach)(ShellState*,sqlite3*,const char*)
){
sqlite3_stmt *pQuery = 0;
char *zQuery = 0;
int rc;
const unsigned char *zName;
const unsigned char *zSql;
char *zErrMsg = 0;
|
| ︙ | ︙ | |||
2120 2121 2122 2123 2124 2125 2126 | } /* ** Open a new database file named "zNewDb". Try to recover as much information ** as possible out of the main database (which might be corrupt) and write it ** into zNewDb. */ | | | 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 |
}
/*
** Open a new database file named "zNewDb". Try to recover as much information
** as possible out of the main database (which might be corrupt) and write it
** into zNewDb.
*/
static void tryToClone(ShellState *p, const char *zNewDb){
int rc;
sqlite3 *newDb = 0;
if( access(zNewDb,0)==0 ){
fprintf(stderr, "File \"%s\" already exists.\n", zNewDb);
return;
}
rc = sqlite3_open(zNewDb, &newDb);
|
| ︙ | ︙ | |||
2145 2146 2147 2148 2149 2150 2151 | } sqlite3_close(newDb); } /* ** Change the output file back to stdout */ | | | | 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 |
}
sqlite3_close(newDb);
}
/*
** Change the output file back to stdout
*/
static void output_reset(ShellState *p){
if( p->outfile[0]=='|' ){
pclose(p->out);
}else{
output_file_close(p->out);
}
p->outfile[0] = 0;
p->out = stdout;
}
/*
** If an input line begins with "." then invoke this routine to
** process that line.
**
** Return 1 on error, 2 to exit, and 0 otherwise.
*/
static int do_meta_command(char *zLine, ShellState *p){
int i = 1;
int nArg = 0;
int n, c;
int rc = 0;
char *azArg[50];
/* Parse the input line into tokens.
|
| ︙ | ︙ | |||
2279 2280 2281 2282 2283 2284 2285 |
}else{
fprintf(stderr, "Usage: .clone FILENAME\n");
rc = 1;
}
}else
if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){
| | | 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 |
}else{
fprintf(stderr, "Usage: .clone FILENAME\n");
rc = 1;
}
}else
if( c=='d' && n>1 && strncmp(azArg[0], "databases", n)==0 ){
ShellState data;
char *zErrMsg = 0;
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 1;
data.mode = MODE_Column;
data.colWidth[0] = 3;
data.colWidth[1] = 15;
|
| ︙ | ︙ | |||
2377 2378 2379 2380 2381 2382 2383 |
if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
rc = 2;
}else
if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
int val = nArg>=2 ? booleanValue(azArg[1]) : 1;
if(val == 1) {
| | | | | | | | | | | | | | 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 |
if( nArg>1 && (rc = (int)integerValue(azArg[1]))!=0 ) exit(rc);
rc = 2;
}else
if( c=='e' && strncmp(azArg[0], "explain", n)==0 ){
int val = nArg>=2 ? booleanValue(azArg[1]) : 1;
if(val == 1) {
if(!p->normalMode.valid) {
p->normalMode.valid = 1;
p->normalMode.mode = p->mode;
p->normalMode.showHeader = p->showHeader;
memcpy(p->normalMode.colWidth,p->colWidth,sizeof(p->colWidth));
}
/* We could put this code under the !p->explainValid
** condition so that it does not execute if we are already in
** explain mode. However, always executing it allows us an easy
** was to reset to explain mode in case the user previously
** did an .explain followed by a .width, .mode or .header
** command.
*/
p->mode = MODE_Explain;
p->showHeader = 1;
memset(p->colWidth,0,sizeof(p->colWidth));
p->colWidth[0] = 4; /* addr */
p->colWidth[1] = 13; /* opcode */
p->colWidth[2] = 4; /* P1 */
p->colWidth[3] = 4; /* P2 */
p->colWidth[4] = 4; /* P3 */
p->colWidth[5] = 13; /* P4 */
p->colWidth[6] = 2; /* P5 */
p->colWidth[7] = 13; /* Comment */
}else if (p->normalMode.valid) {
p->normalMode.valid = 0;
p->mode = p->normalMode.mode;
p->showHeader = p->normalMode.showHeader;
memcpy(p->colWidth,p->normalMode.colWidth,sizeof(p->colWidth));
}
}else
if( c=='f' && strncmp(azArg[0], "fullschema", n)==0 ){
ShellState data;
char *zErrMsg = 0;
int doStats = 0;
if( nArg!=1 ){
fprintf(stderr, "Usage: .fullschema\n");
rc = 1;
goto meta_command_exit;
}
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 0;
data.mode = MODE_Semi;
rc = sqlite3_exec(p->db,
"SELECT sql FROM"
" (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
" FROM sqlite_master UNION ALL"
" SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
"ORDER BY rowid",
callback, &data, &zErrMsg
);
if( rc==SQLITE_OK ){
sqlite3_stmt *pStmt;
rc = sqlite3_prepare_v2(p->db,
"SELECT rowid FROM sqlite_master"
|
| ︙ | ︙ | |||
2631 2632 2633 2634 2635 2636 2637 |
xCloser(sCsv.in);
sqlite3_free(sCsv.z);
sqlite3_finalize(pStmt);
if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
}else
if( c=='i' && strncmp(azArg[0], "indices", n)==0 ){
| | | 2728 2729 2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 2742 |
xCloser(sCsv.in);
sqlite3_free(sCsv.z);
sqlite3_finalize(pStmt);
if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
}else
if( c=='i' && strncmp(azArg[0], "indices", n)==0 ){
ShellState data;
char *zErrMsg = 0;
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 0;
data.mode = MODE_List;
if( nArg==1 ){
rc = sqlite3_exec(p->db,
|
| ︙ | ︙ | |||
2747 2748 2749 2750 2751 2752 2753 2754 2755 2756 2757 2758 2759 2760 |
p->mode = MODE_Html;
}else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
p->mode = MODE_Tcl;
sqlite3_snprintf(sizeof(p->separator), p->separator, " ");
}else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
p->mode = MODE_Csv;
sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
}else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->separator), p->separator, "\t");
}else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
p->mode = MODE_Insert;
set_table_name(p, nArg>=3 ? azArg[2] : "table");
}else {
| > | 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 |
p->mode = MODE_Html;
}else if( c2=='t' && strncmp(azArg[1],"tcl",n2)==0 ){
p->mode = MODE_Tcl;
sqlite3_snprintf(sizeof(p->separator), p->separator, " ");
}else if( c2=='c' && strncmp(azArg[1],"csv",n2)==0 ){
p->mode = MODE_Csv;
sqlite3_snprintf(sizeof(p->separator), p->separator, ",");
sqlite3_snprintf(sizeof(p->newline), p->newline, "\r\n");
}else if( c2=='t' && strncmp(azArg[1],"tabs",n2)==0 ){
p->mode = MODE_List;
sqlite3_snprintf(sizeof(p->separator), p->separator, "\t");
}else if( c2=='i' && strncmp(azArg[1],"insert",n2)==0 ){
p->mode = MODE_Insert;
set_table_name(p, nArg>=3 ? azArg[2] : "table");
}else {
|
| ︙ | ︙ | |||
2924 2925 2926 2927 2928 2929 2930 |
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
rc = 1;
}
sqlite3_close(pSrc);
}else
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
| | | 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 |
fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
rc = 1;
}
sqlite3_close(pSrc);
}else
if( c=='s' && strncmp(azArg[0], "schema", n)==0 ){
ShellState data;
char *zErrMsg = 0;
open_db(p, 0);
memcpy(&data, p, sizeof(data));
data.showHeader = 0;
data.mode = MODE_Semi;
if( nArg==2 ){
int i;
|
| ︙ | ︙ | |||
2980 2981 2982 2983 2984 2985 2986 |
}
}else if( nArg==1 ){
rc = sqlite3_exec(p->db,
"SELECT sql FROM "
" (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
" FROM sqlite_master UNION ALL"
" SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
| | > > > > > > > > > | 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 |
}
}else if( nArg==1 ){
rc = sqlite3_exec(p->db,
"SELECT sql FROM "
" (SELECT sql sql, type type, tbl_name tbl_name, name name, rowid x"
" FROM sqlite_master UNION ALL"
" SELECT sql, type, tbl_name, name, rowid FROM sqlite_temp_master) "
"WHERE type!='meta' AND sql NOTNULL AND name NOT LIKE 'sqlite_%' "
"ORDER BY rowid",
callback, &data, &zErrMsg
);
}else{
fprintf(stderr, "Usage: .schema ?LIKE-PATTERN?\n");
rc = 1;
goto meta_command_exit;
}
if( zErrMsg ){
fprintf(stderr,"Error: %s\n", zErrMsg);
sqlite3_free(zErrMsg);
rc = 1;
}else if( rc != SQLITE_OK ){
fprintf(stderr,"Error: querying schema information\n");
rc = 1;
}else{
rc = 0;
}
}else
#if defined(SQLITE_DEBUG) && defined(SQLITE_ENABLE_SELECTTRACE)
if( c=='s' && n==11 && strncmp(azArg[0], "selecttrace", n)==0 ){
extern int sqlite3SelectTrace;
sqlite3SelectTrace = nArg>=2 ? booleanValue(azArg[1]) : 0xff;
}else
#endif
#ifdef SQLITE_DEBUG
/* Undocumented commands for internal testing. Subject to change
** without notice. */
if( c=='s' && n>=10 && strncmp(azArg[0], "selftest-", 9)==0 ){
if( strncmp(azArg[0]+9, "boolean", n-9)==0 ){
int i, v;
|
| ︙ | ︙ | |||
3025 3026 3027 3028 3029 3030 3031 |
fprintf(p->out, "%s", zBuf);
}
}
}else
#endif
if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){
| | < < < | > > > > > > | | > | > > | 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141 3142 3143 3144 3145 3146 3147 3148 3149 3150 3151 3152 3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163 3164 3165 3166 3167 3168 3169 3170 3171 3172 3173 3174 3175 3176 3177 3178 3179 3180 3181 3182 3183 3184 3185 3186 3187 3188 3189 3190 3191 3192 3193 3194 3195 3196 3197 3198 |
fprintf(p->out, "%s", zBuf);
}
}
}else
#endif
if( c=='s' && strncmp(azArg[0], "separator", n)==0 ){
if( nArg<2 || nArg>3 ){
fprintf(stderr, "Usage: .separator SEPARATOR ?NEWLINE?\n");
rc = 1;
}
if( nArg>=2 ){
sqlite3_snprintf(sizeof(p->separator), p->separator, azArg[1]);
}
if( nArg>=3 ){
sqlite3_snprintf(sizeof(p->newline), p->newline, azArg[2]);
}
}else
if( c=='s'
&& (strncmp(azArg[0], "shell", n)==0 || strncmp(azArg[0],"system",n)==0)
){
char *zCmd;
int i, x;
if( nArg<2 ){
fprintf(stderr, "Usage: .system COMMAND\n");
rc = 1;
goto meta_command_exit;
}
zCmd = sqlite3_mprintf(strchr(azArg[1],' ')==0?"%s":"\"%s\"", azArg[1]);
for(i=2; i<nArg; i++){
zCmd = sqlite3_mprintf(strchr(azArg[i],' ')==0?"%z %s":"%z \"%s\"",
zCmd, azArg[i]);
}
x = system(zCmd);
sqlite3_free(zCmd);
if( x ) fprintf(stderr, "System command returns %d\n", x);
}else
if( c=='s' && strncmp(azArg[0], "show", n)==0 ){
int i;
if( nArg!=1 ){
fprintf(stderr, "Usage: .show\n");
rc = 1;
goto meta_command_exit;
}
fprintf(p->out,"%9.9s: %s\n","echo", p->echoOn ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","eqp", p->autoEQP ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","explain", p->normalMode.valid ? "on" :"off");
fprintf(p->out,"%9.9s: %s\n","headers", p->showHeader ? "on" : "off");
fprintf(p->out,"%9.9s: %s\n","mode", modeDescr[p->mode]);
fprintf(p->out,"%9.9s: ", "nullvalue");
output_c_string(p->out, p->nullvalue);
fprintf(p->out, "\n");
fprintf(p->out,"%9.9s: %s\n","output",
strlen30(p->outfile) ? p->outfile : "stdout");
fprintf(p->out,"%9.9s: ", "separator");
output_c_string(p->out, p->separator);
fprintf(p->out," ");
output_c_string(p->out, p->newline);
fprintf(p->out, "\n");
fprintf(p->out,"%9.9s: %s\n","stats", p->statsOn ? "on" : "off");
fprintf(p->out,"%9.9s: ","width");
for (i=0;i<(int)ArraySize(p->colWidth) && p->colWidth[i] != 0;i++) {
fprintf(p->out,"%d ",p->colWidth[i]);
}
fprintf(p->out,"\n");
|
| ︙ | ︙ | |||
3332 3333 3334 3335 3336 3337 3338 3339 3340 3341 3342 3343 3344 3345 |
sqlite3_trace(p->db, 0, 0);
}else{
sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
}
#endif
}else
if( c=='v' && strncmp(azArg[0], "version", n)==0 ){
fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
sqlite3_libversion(), sqlite3_sourceid());
}else
if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){
const char *zDbName = nArg==2 ? azArg[1] : "main";
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500 3501 3502 3503 3504 3505 3506 3507 3508 3509 3510 3511 3512 3513 3514 3515 3516 3517 3518 3519 3520 3521 3522 3523 |
sqlite3_trace(p->db, 0, 0);
}else{
sqlite3_trace(p->db, sql_trace_callback, p->traceOut);
}
#endif
}else
#if SQLITE_USER_AUTHENTICATION
if( c=='u' && strncmp(azArg[0], "user", n)==0 ){
if( nArg<2 ){
fprintf(stderr, "Usage: .user SUBCOMMAND ...\n");
rc = 1;
goto meta_command_exit;
}
open_db(p, 0);
if( strcmp(azArg[1],"login")==0 ){
if( nArg!=4 ){
fprintf(stderr, "Usage: .user login USER PASSWORD\n");
rc = 1;
goto meta_command_exit;
}
rc = sqlite3_user_authenticate(p->db, azArg[2], azArg[3],
(int)strlen(azArg[3]));
if( rc ){
fprintf(stderr, "Authentication failed for user %s\n", azArg[2]);
rc = 1;
}
}else if( strcmp(azArg[1],"add")==0 ){
if( nArg!=5 ){
fprintf(stderr, "Usage: .user add USER PASSWORD ISADMIN\n");
rc = 1;
goto meta_command_exit;
}
rc = sqlite3_user_add(p->db, azArg[2],
azArg[3], (int)strlen(azArg[3]),
booleanValue(azArg[4]));
if( rc ){
fprintf(stderr, "User-Add failed: %d\n", rc);
rc = 1;
}
}else if( strcmp(azArg[1],"edit")==0 ){
if( nArg!=5 ){
fprintf(stderr, "Usage: .user edit USER PASSWORD ISADMIN\n");
rc = 1;
goto meta_command_exit;
}
rc = sqlite3_user_change(p->db, azArg[2],
azArg[3], (int)strlen(azArg[3]),
booleanValue(azArg[4]));
if( rc ){
fprintf(stderr, "User-Edit failed: %d\n", rc);
rc = 1;
}
}else if( strcmp(azArg[1],"delete")==0 ){
if( nArg!=3 ){
fprintf(stderr, "Usage: .user delete USER\n");
rc = 1;
goto meta_command_exit;
}
rc = sqlite3_user_delete(p->db, azArg[2]);
if( rc ){
fprintf(stderr, "User-Delete failed: %d\n", rc);
rc = 1;
}
}else{
fprintf(stderr, "Usage: .user login|add|edit|delete ...\n");
rc = 1;
goto meta_command_exit;
}
}else
#endif /* SQLITE_USER_AUTHENTICATION */
if( c=='v' && strncmp(azArg[0], "version", n)==0 ){
fprintf(p->out, "SQLite %s %s\n" /*extra-version-info*/,
sqlite3_libversion(), sqlite3_sourceid());
}else
if( c=='v' && strncmp(azArg[0], "vfsname", n)==0 ){
const char *zDbName = nArg==2 ? azArg[1] : "main";
|
| ︙ | ︙ | |||
3452 3453 3454 3455 3456 3457 3458 | ** is interactive - the user is typing it it. Otherwise, input ** is coming from a file or device. A prompt is issued and history ** is saved only if input is interactive. An interrupt signal will ** cause this routine to exit immediately, unless input is interactive. ** ** Return the number of errors. */ | | | 3630 3631 3632 3633 3634 3635 3636 3637 3638 3639 3640 3641 3642 3643 3644 |
** is interactive - the user is typing it it. Otherwise, input
** is coming from a file or device. A prompt is issued and history
** is saved only if input is interactive. An interrupt signal will
** cause this routine to exit immediately, unless input is interactive.
**
** Return the number of errors.
*/
static int process_input(ShellState *p, FILE *in){
char *zLine = 0; /* A single input line */
char *zSql = 0; /* Accumulated SQL text */
int nLine; /* Length of current line */
int nSql = 0; /* Bytes of zSql[] used */
int nAlloc = 0; /* Allocated zSql[] space */
int nSqlPrior = 0; /* Bytes of zSql[] used by prior line */
char *zErrMsg; /* Error message returned */
|
| ︙ | ︙ | |||
3554 3555 3556 3557 3558 3559 3560 3561 3562 3563 3564 3565 3566 3567 |
if( p->echoOn ) printf("%s\n", zSql);
nSql = 0;
}
}
if( nSql ){
if( !_all_whitespace(zSql) ){
fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
}
free(zSql);
}
free(zLine);
return errCnt>0;
}
| > | 3732 3733 3734 3735 3736 3737 3738 3739 3740 3741 3742 3743 3744 3745 3746 |
if( p->echoOn ) printf("%s\n", zSql);
nSql = 0;
}
}
if( nSql ){
if( !_all_whitespace(zSql) ){
fprintf(stderr, "Error: incomplete SQL: %s\n", zSql);
errCnt++;
}
free(zSql);
}
free(zLine);
return errCnt>0;
}
|
| ︙ | ︙ | |||
3631 3632 3633 3634 3635 3636 3637 | /* ** Read input from the file given by sqliterc_override. Or if that ** parameter is NULL, take input from ~/.sqliterc ** ** Returns the number of errors. */ static int process_sqliterc( | | | 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 3823 3824 |
/*
** Read input from the file given by sqliterc_override. Or if that
** parameter is NULL, take input from ~/.sqliterc
**
** Returns the number of errors.
*/
static int process_sqliterc(
ShellState *p, /* Configuration data */
const char *sqliterc_override /* Name of config file. NULL to use default */
){
char *home_dir = NULL;
const char *sqliterc = sqliterc_override;
char *zBuf = 0;
FILE *in = NULL;
int rc = 0;
|
| ︙ | ︙ | |||
3684 3685 3686 3687 3688 3689 3690 3691 3692 3693 3694 3695 3696 3697 3698 3699 3700 3701 3702 | " -heap SIZE Size of heap for memsys3 or memsys5\n" #endif " -help show this message\n" " -html set output mode to HTML\n" " -interactive force interactive I/O\n" " -line set output mode to 'line'\n" " -list set output mode to 'list'\n" " -mmap N default mmap size set to N\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -nullvalue TEXT set text string for NULL values. Default ''\n" " -separator SEP set output field separator. Default: '|'\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif | > > > > | 3863 3864 3865 3866 3867 3868 3869 3870 3871 3872 3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 | " -heap SIZE Size of heap for memsys3 or memsys5\n" #endif " -help show this message\n" " -html set output mode to HTML\n" " -interactive force interactive I/O\n" " -line set output mode to 'line'\n" " -list set output mode to 'list'\n" " -lookaside SIZE N use N entries of SZ bytes for lookaside memory\n" " -mmap N default mmap size set to N\n" #ifdef SQLITE_ENABLE_MULTIPLEX " -multiplex enable the multiplexor VFS\n" #endif " -newline SEP set newline character(s) for CSV\n" " -nullvalue TEXT set text string for NULL values. Default ''\n" " -pagecache SIZE N use N slots of SZ bytes each for page cache memory\n" " -scratch SIZE N use N slots of SZ bytes each for scratch memory\n" " -separator SEP set output field separator. Default: '|'\n" " -stats print memory stats before each finalize\n" " -version show SQLite version\n" " -vfs NAME use NAME as the default VFS\n" #ifdef SQLITE_ENABLE_VFSTRACE " -vfstrace enable tracing of all VFS calls\n" #endif |
| ︙ | ︙ | |||
3713 3714 3715 3716 3717 3718 3719 | } exit(1); } /* ** Initialize the state information in data */ | | > > > < | 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906 3907 3908 3909 3910 3911 3912 3913 3914 3915 3916 3917 3918 3919 3920 3921 |
}
exit(1);
}
/*
** Initialize the state information in data
*/
static void main_init(ShellState *data) {
memset(data, 0, sizeof(*data));
data->mode = MODE_List;
memcpy(data->separator,"|", 2);
memcpy(data->newline,"\r\n", 3);
data->showHeader = 0;
data->shellFlgs = SHFLG_Lookaside;
sqlite3_config(SQLITE_CONFIG_URI, 1);
sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
}
/*
** Output text to the console in a font that attracts extra attention.
*/
#ifdef _WIN32
static void printBold(const char *zText){
|
| ︙ | ︙ | |||
3760 3761 3762 3763 3764 3765 3766 |
exit(1);
}
return argv[i];
}
int main(int argc, char **argv){
char *zErrMsg = 0;
| | | 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 3956 3957 3958 3959 |
exit(1);
}
return argv[i];
}
int main(int argc, char **argv){
char *zErrMsg = 0;
ShellState data;
const char *zInitFile = 0;
char *zFirstCmd = 0;
int i;
int rc = 0;
int warnInmemoryDb = 0;
#if USE_SYSTEM_SQLITE+0!=1
|
| ︙ | ︙ | |||
3809 3810 3811 3812 3813 3814 3815 3816 3817 3818 3819 3820 3821 3822 |
fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
fprintf(stderr,"Use -help for a list of options.\n");
return 1;
}
if( z[1]=='-' ) z++;
if( strcmp(z,"-separator")==0
|| strcmp(z,"-nullvalue")==0
|| strcmp(z,"-cmd")==0
){
(void)cmdline_option_value(argc, argv, ++i);
}else if( strcmp(z,"-init")==0 ){
zInitFile = cmdline_option_value(argc, argv, ++i);
}else if( strcmp(z,"-batch")==0 ){
/* Need to check for batch mode here to so we can avoid printing
| > | 3994 3995 3996 3997 3998 3999 4000 4001 4002 4003 4004 4005 4006 4007 4008 |
fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
fprintf(stderr,"Use -help for a list of options.\n");
return 1;
}
if( z[1]=='-' ) z++;
if( strcmp(z,"-separator")==0
|| strcmp(z,"-nullvalue")==0
|| strcmp(z,"-newline")==0
|| strcmp(z,"-cmd")==0
){
(void)cmdline_option_value(argc, argv, ++i);
}else if( strcmp(z,"-init")==0 ){
zInitFile = cmdline_option_value(argc, argv, ++i);
}else if( strcmp(z,"-batch")==0 ){
/* Need to check for batch mode here to so we can avoid printing
|
| ︙ | ︙ | |||
3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841 3842 3843 |
sqlite3_int64 szHeap;
zSize = cmdline_option_value(argc, argv, ++i);
szHeap = integerValue(zSize);
if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
#endif
#ifdef SQLITE_ENABLE_VFSTRACE
}else if( strcmp(z,"-vfstrace")==0 ){
extern int vfstrace_register(
const char *zTraceName,
const char *zOldVfsName,
int (*xOut)(const char*,void*),
void *pOutArg,
| > > > > > > > > > > > > > > > > > > > > > > > > > > > | 4016 4017 4018 4019 4020 4021 4022 4023 4024 4025 4026 4027 4028 4029 4030 4031 4032 4033 4034 4035 4036 4037 4038 4039 4040 4041 4042 4043 4044 4045 4046 4047 4048 4049 4050 4051 4052 4053 4054 4055 4056 |
sqlite3_int64 szHeap;
zSize = cmdline_option_value(argc, argv, ++i);
szHeap = integerValue(zSize);
if( szHeap>0x7fff0000 ) szHeap = 0x7fff0000;
sqlite3_config(SQLITE_CONFIG_HEAP, malloc((int)szHeap), (int)szHeap, 64);
#endif
}else if( strcmp(z,"-scratch")==0 ){
int n, sz;
sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( sz>400000 ) sz = 400000;
if( sz<2500 ) sz = 2500;
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( n>10 ) n = 10;
if( n<1 ) n = 1;
sqlite3_config(SQLITE_CONFIG_SCRATCH, malloc(n*sz+1), sz, n);
data.shellFlgs |= SHFLG_Scratch;
}else if( strcmp(z,"-pagecache")==0 ){
int n, sz;
sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( sz>70000 ) sz = 70000;
if( sz<800 ) sz = 800;
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( n<10 ) n = 10;
sqlite3_config(SQLITE_CONFIG_PAGECACHE, malloc(n*sz+1), sz, n);
data.shellFlgs |= SHFLG_Pagecache;
}else if( strcmp(z,"-lookaside")==0 ){
int n, sz;
sz = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( sz<0 ) sz = 0;
n = (int)integerValue(cmdline_option_value(argc,argv,++i));
if( n<0 ) n = 0;
sqlite3_config(SQLITE_CONFIG_LOOKASIDE, sz, n);
if( sz*n==0 ) data.shellFlgs &= ~SHFLG_Lookaside;
#ifdef SQLITE_ENABLE_VFSTRACE
}else if( strcmp(z,"-vfstrace")==0 ){
extern int vfstrace_register(
const char *zTraceName,
const char *zOldVfsName,
int (*xOut)(const char*,void*),
void *pOutArg,
|
| ︙ | ︙ | |||
3918 3919 3920 3921 3922 3923 3924 3925 3926 3927 3928 3929 3930 3931 |
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
memcpy(data.separator,",",2);
}else if( strcmp(z,"-separator")==0 ){
sqlite3_snprintf(sizeof(data.separator), data.separator,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-nullvalue")==0 ){
sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-header")==0 ){
data.showHeader = 1;
}else if( strcmp(z,"-noheader")==0 ){
data.showHeader = 0;
| > > > | 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 |
data.mode = MODE_Column;
}else if( strcmp(z,"-csv")==0 ){
data.mode = MODE_Csv;
memcpy(data.separator,",",2);
}else if( strcmp(z,"-separator")==0 ){
sqlite3_snprintf(sizeof(data.separator), data.separator,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-newline")==0 ){
sqlite3_snprintf(sizeof(data.newline), data.newline,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-nullvalue")==0 ){
sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
"%s",cmdline_option_value(argc,argv,++i));
}else if( strcmp(z,"-header")==0 ){
data.showHeader = 1;
}else if( strcmp(z,"-noheader")==0 ){
data.showHeader = 0;
|
| ︙ | ︙ | |||
3942 3943 3944 3945 3946 3947 3948 3949 3950 3951 3952 3953 3954 3955 |
return 0;
}else if( strcmp(z,"-interactive")==0 ){
stdin_is_interactive = 1;
}else if( strcmp(z,"-batch")==0 ){
stdin_is_interactive = 0;
}else if( strcmp(z,"-heap")==0 ){
i++;
}else if( strcmp(z,"-mmap")==0 ){
i++;
}else if( strcmp(z,"-vfs")==0 ){
i++;
#ifdef SQLITE_ENABLE_VFSTRACE
}else if( strcmp(z,"-vfstrace")==0 ){
i++;
| > > > > > > | 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 |
return 0;
}else if( strcmp(z,"-interactive")==0 ){
stdin_is_interactive = 1;
}else if( strcmp(z,"-batch")==0 ){
stdin_is_interactive = 0;
}else if( strcmp(z,"-heap")==0 ){
i++;
}else if( strcmp(z,"-scratch")==0 ){
i+=2;
}else if( strcmp(z,"-pagecache")==0 ){
i+=2;
}else if( strcmp(z,"-lookaside")==0 ){
i+=2;
}else if( strcmp(z,"-mmap")==0 ){
i++;
}else if( strcmp(z,"-vfs")==0 ){
i++;
#ifdef SQLITE_ENABLE_VFSTRACE
}else if( strcmp(z,"-vfstrace")==0 ){
i++;
|
| ︙ | ︙ |
Changes to src/shun.c.
| ︙ | ︙ | |||
38 39 40 41 42 43 44 |
/*
** WEBPAGE: shun
*/
void shun_page(void){
Stmt q;
int cnt = 0;
const char *zUuid = P("uuid");
| > > > | > | > > > | | > > | > > | | > > > > | | > > > > > > > > > > | | > > > > > | | > > > > > | > | > | | > > > | | > > | | | < < < < < | | | | | | | | | | | > > > > > > > > > > > > > > | | | | | > > > > > > > > > > > > | | | | > > > | > > > > > > > > > | 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 |
/*
** WEBPAGE: shun
*/
void shun_page(void){
Stmt q;
int cnt = 0;
const char *zUuid = P("uuid");
const char *zShun = P("shun");
const char *zAccept = P("accept");
const char *zRcvid = P("rcvid");
int nRcvid = 0;
int numRows = 3;
char *zCanonical = 0;
login_check_credentials();
if( !g.perm.Admin ){
login_needed();
}
if( P("rebuild") ){
db_close(1);
db_open_repository(g.zRepositoryName);
db_begin_transaction();
rebuild_db(0, 0, 0);
db_end_transaction(0);
}
if( zUuid ){
char *p;
int i = 0;
int j = 0;
zCanonical = fossil_malloc(strlen(zUuid)+2);
while( zUuid[i] ){
if( fossil_isspace(zUuid[i]) ){
if( j && zCanonical[j-1] ){
zCanonical[j] = 0;
j++;
}
}else{
zCanonical[j] = zUuid[i];
j++;
}
i++;
}
zCanonical[j+1] = zCanonical[j] = 0;
p = zCanonical;
while( *p ){
int nUuid = strlen(p);
if( nUuid!=UUID_SIZE || !validate16(p, nUuid) ){
@ <p class="generalError">Error: Bad artifact IDs.</p>
fossil_free(zCanonical);
zCanonical = 0;
break;
}else{
canonical16(p, UUID_SIZE);
p += UUID_SIZE+1;
}
}
zUuid = zCanonical;
}
style_header("Shunned Artifacts");
if( zUuid && P("sub") ){
const char *p = zUuid;
int allExist = 1;
login_verify_csrf_secret();
while( *p ){
db_multi_exec("DELETE FROM shun WHERE uuid=%Q", p);
if( !db_exists("SELECT 1 FROM blob WHERE uuid=%Q", p) ){
allExist = 0;
}
p += UUID_SIZE+1;
}
if( allExist ){
@ <p class="noMoreShun">Artifact(s)<br />
for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
@ <a href="%s(g.zTop)/artifact/%s(p)">%s(p)</a><br />
}
@ are no longer being shunned.</p>
}else{
@ <p class="noMoreShun">Artifact(s)<br />
for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
@ %s(p)<br />
}
@ will no longer be shunned. But they may not exist in the repository.
@ It may be necessary to rebuild the repository using the
@ <b>fossil rebuild</b> command-line before the artifact content
@ can pulled in from other repositories.</p>
}
}
if( zUuid && P("add") ){
const char *p = zUuid;
int rid, tagid;
login_verify_csrf_secret();
while( *p ){
db_multi_exec(
"INSERT OR IGNORE INTO shun(uuid,mtime)"
" VALUES(%Q, now())", p);
db_multi_exec("DELETE FROM attachment WHERE src=%Q", p);
rid = db_int(0, "SELECT rid FROM blob WHERE uuid=%Q", p);
if( rid ){
db_multi_exec("DELETE FROM event WHERE objid=%d", rid);
}
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='tkt-%q'", p);
if( tagid ){
db_multi_exec("DELETE FROM ticket WHERE tkt_uuid=%Q", p);
db_multi_exec("DELETE FROM tag WHERE tagid=%d", tagid);
db_multi_exec("DELETE FROM tagxref WHERE tagid=%d", tagid);
}
p += UUID_SIZE+1;
}
@ <p class="shunned">Artifact(s)<br />
for( p = zUuid ; *p ; p += UUID_SIZE+1 ){
@ <a href="%s(g.zTop)/artifact/%s(p)">%s(p)</a><br />
}
@ have been shunned. They will no longer be pushed.
@ They will be removed from the repository the next time the repository
@ is rebuilt using the <b>fossil rebuild</b> command-line</p>
}
if( zRcvid ){
nRcvid = atoi(zRcvid);
numRows = db_int(0, "SELECT min(count(), 10) FROM blob WHERE rcvid=%d",
nRcvid);
}
@ <p>A shunned artifact will not be pushed nor accepted in a pull and the
@ artifact content will be purged from the repository the next time the
@ repository is rebuilt. A list of shunned artifacts can be seen at the
@ bottom of this page.</p>
@
@ <a name="addshun"></a>
@ <p>To shun artifacts, enter their artifact IDs (the 40-character SHA1
@ hash of the artifacts) in the
@ following box and press the "Shun" button. This will cause the artifacts
@ to be removed from the repository and will prevent the artifacts from being
@ readded to the repository by subsequent sync operation.</p>
@
@ <p>Note that you must enter the full 40-character artifact IDs, not
@ an abbreviation or a symbolic tag.</p>
@
@ <p>Warning: Shunning should only be used to remove inappropriate content
@ from the repository. Inappropriate content includes such things as
@ spam added to Wiki, files that violate copyright or patent agreements,
@ or artifacts that by design or accident interfere with the processing
@ of the repository. Do not shun artifacts merely to remove them from
@ sight - set the "hidden" tag on such artifacts instead.</p>
@
@ <blockquote>
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
login_insert_csrf_secret();
@ <textarea class="fullsize-text" cols="50" rows="%d(numRows)" name="uuid">
if( zShun ){
if( strlen(zShun) ){
@ %h(zShun)
}else if( nRcvid ){
db_prepare(&q, "SELECT uuid FROM blob WHERE rcvid=%d", nRcvid);
while( db_step(&q)==SQLITE_ROW ){
@ %s(db_column_text(&q, 0))
}
db_finalize(&q);
}
}
@ </textarea>
@ <input type="submit" name="add" value="Shun" />
@ </div></form>
@ </blockquote>
@
@ <a name="delshun"></a>
@ <p>Enter the UUIDs of previously shunned artifacts to cause them to be
@ accepted again in the repository. The artifacts content is not
@ restored because the content is unknown. The only change is that
@ the formerly shunned artifacts will be accepted on subsequent sync
@ operations.</p>
@
@ <blockquote>
@ <form method="post" action="%s(g.zTop)/%s(g.zPath)"><div>
login_insert_csrf_secret();
@ <textarea class="fullsize-text" cols="50" rows="%d(numRows)" name="uuid">
if( zAccept ){
if( strlen(zAccept) ){
@ %h(zAccept)
}else if( nRcvid ){
db_prepare(&q, "SELECT uuid FROM blob WHERE rcvid=%d", nRcvid);
while( db_step(&q)==SQLITE_ROW ){
@ %s(db_column_text(&q, 0))
}
db_finalize(&q);
}
}
@ </textarea>
@ <input type="submit" name="sub" value="Accept" />
@ </div></form>
@ </blockquote>
@
@ <p>Press the Rebuild button below to rebuild the repository. The
@ content of newly shunned artifacts is not purged until the repository
@ is rebuilt. On larger repositories, the rebuild may take minute or
|
| ︙ | ︙ | |||
179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
}
if( cnt==0 ){
@ <i>no artifacts are shunned on this server</i>
}
db_finalize(&q);
@ </p></blockquote>
style_footer();
}
/*
** Remove from the BLOB table all artifacts that are in the SHUN table.
*/
void shun_artifacts(void){
Stmt q;
| > | 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
}
if( cnt==0 ){
@ <i>no artifacts are shunned on this server</i>
}
db_finalize(&q);
@ </p></blockquote>
style_footer();
fossil_free(zCanonical);
}
/*
** Remove from the BLOB table all artifacts that are in the SHUN table.
*/
void shun_artifacts(void){
Stmt q;
|
| ︙ | ︙ | |||
285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){
login_needed();
}
style_header("Content Source %d", rcvid);
db_prepare(&q,
"SELECT login, datetime(rcvfrom.mtime), rcvfrom.ipaddr"
" FROM rcvfrom LEFT JOIN user USING(uid)"
" WHERE rcvid=%d",
rcvid
);
@ <table cellspacing="15" cellpadding="0" border="0">
| > > > > > > > > > > > > | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
Stmt q;
login_check_credentials();
if( !g.perm.Admin ){
login_needed();
}
style_header("Content Source %d", rcvid);
if( db_exists(
"SELECT 1 FROM blob WHERE rcvid=%d AND"
" NOT EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid)
){
style_submenu_element("Shun All", "Shun All", "shun?shun&rcvid=%d#addshun", rcvid);
}
if( db_exists(
"SELECT 1 FROM blob WHERE rcvid=%d AND"
" EXISTS (SELECT 1 FROM shun WHERE shun.uuid=blob.uuid)", rcvid)
){
style_submenu_element("Unshun All", "Unshun All", "shun?accept&rcvid=%d#delshun", rcvid);
}
db_prepare(&q,
"SELECT login, datetime(rcvfrom.mtime), rcvfrom.ipaddr"
" FROM rcvfrom LEFT JOIN user USING(uid)"
" WHERE rcvid=%d",
rcvid
);
@ <table cellspacing="15" cellpadding="0" border="0">
|
| ︙ | ︙ |
Changes to src/skins.c.
| ︙ | ︙ | |||
768 769 770 771 772 773 774 |
@ }
@ div.mainmenu a, div.mainmenu a:visited {
@ padding: 3px 10px 3px 10px;
@ color: white;
@ text-decoration: none;
@ }
@ div.submenu a, div.submenu a:visited, a.button,
| | | 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 |
@ }
@ div.mainmenu a, div.mainmenu a:visited {
@ padding: 3px 10px 3px 10px;
@ color: white;
@ text-decoration: none;
@ }
@ div.submenu a, div.submenu a:visited, a.button,
@ div.sectionmenu>a.button:link, div.sectionmenu>a.button:visited {
@ padding: 2px 8px;
@ color: #000;
@ font-family: Arial;
@ text-decoration: none;
@ margin:auto;
@ border-radius: 5px;
@ background-color: #e0e0e0;
|
| ︙ | ︙ | |||
872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
@ table.report tr td {
@ padding: 3px 5px;
@ cursor: pointer;
@ }
@
@ textarea {
@ font-size: 1em;
@ }');
@ REPLACE INTO config(name,mtime,value) VALUES('header',now(),'<html>
@ <head>
@ <base href="$baseurl/$current_page" />
@ <title>$<project_name>: $<title></title>
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
@ href="$home/timeline.rss">
| > > > > | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 |
@ table.report tr td {
@ padding: 3px 5px;
@ cursor: pointer;
@ }
@
@ textarea {
@ font-size: 1em;
@ }
@
@ .fullsize-text {
@ font-size: 1.25em;
@ }');
@ REPLACE INTO config(name,mtime,value) VALUES('header',now(),'<html>
@ <head>
@ <base href="$baseurl/$current_page" />
@ <title>$<project_name>: $<title></title>
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
@ href="$home/timeline.rss">
|
| ︙ | ︙ | |||
1386 1387 1388 1389 1390 1391 1392 |
);
}
seen = 0;
for(i=0; i<sizeof(aBuiltinSkin)/sizeof(aBuiltinSkin[0]); i++){
if( fossil_strcmp(aBuiltinSkin[i].zName, z)==0 ){
seen = 1;
zCurrent = aBuiltinSkin[i].zValue;
| | | | 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 |
);
}
seen = 0;
for(i=0; i<sizeof(aBuiltinSkin)/sizeof(aBuiltinSkin[0]); i++){
if( fossil_strcmp(aBuiltinSkin[i].zName, z)==0 ){
seen = 1;
zCurrent = aBuiltinSkin[i].zValue;
db_multi_exec("%s", zCurrent/*safe-for-%s*/);
break;
}
}
if( !seen ){
zName = skinVarName(z,0);
zCurrent = db_get(zName, 0);
db_multi_exec("%s", zCurrent/*safe-for-%s*/);
}
}
style_header("Skins");
if( zErr ){
@ <p><font color="red">%h(zErr)</font></p>
}
|
| ︙ | ︙ |
Changes to src/sqlcmd.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" #include "sqlcmd.h" | > > > > | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | ** This module contains the code that initializes the "sqlite3" command-line ** shell against the repository database. The command-line shell itself ** is a copy of the "shell.c" code from SQLite. This file contains logic ** to initialize the code in shell.c. */ #include "config.h" #include "sqlcmd.h" #if defined(FOSSIL_ENABLE_MINIZ) # define MINIZ_HEADER_FILE_ONLY # include "miniz.c" #else # include <zlib.h> #endif /* ** Implementation of the "content(X)" SQL function. Return the complete ** content of artifact identified by X as a blob. */ static void sqlcmd_content( sqlite3_context *context, |
| ︙ | ︙ | |||
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
*/
void cmd_sqlite3(void){
extern int sqlite3_shell(int, char**);
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
db_close(1);
sqlite3_shutdown();
sqlite3_shell(g.argc-1, g.argv+1);
g.db = 0;
}
/*
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
*pzRepoName = g.zRepositoryName;
}
| > > > > | 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
*/
void cmd_sqlite3(void){
extern int sqlite3_shell(int, char**);
db_find_and_open_repository(OPEN_ANY_SCHEMA, 0);
db_close(1);
sqlite3_shutdown();
sqlite3_shell(g.argc-1, g.argv+1);
sqlite3_cancel_auto_extension((void(*)(void))sqlcmd_autoinit);
g.db = 0;
g.zMainDbType = 0;
g.repositoryOpen = 0;
g.localOpen = 0;
}
/*
** This routine is called by the patched sqlite3 command-line shell in order
** to load the name and database connection for the open Fossil database.
*/
void fossil_open(const char **pzRepoName){
sqlite3_auto_extension((void(*)(void))sqlcmd_autoinit);
*pzRepoName = g.zRepositoryName;
}
|
Changes to src/sqlite3.c.
more than 10,000 changes
Changes to src/sqlite3.h.
| ︙ | ︙ | |||
103 104 105 106 107 108 109 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ | | | | | 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | ** string contains the date and time of the check-in (UTC) and an SHA1 ** hash of the entire source tree. ** ** See also: [sqlite3_libversion()], ** [sqlite3_libversion_number()], [sqlite3_sourceid()], ** [sqlite_version()] and [sqlite_source_id()]. */ #define SQLITE_VERSION "3.8.7.1" #define SQLITE_VERSION_NUMBER 3008007 #define SQLITE_SOURCE_ID "2014-10-29 01:27:43 83afe23e553e802c0947c80d0ffdd120423e7c52" /* ** CAPI3REF: Run-Time Library Version Numbers ** KEYWORDS: sqlite3_version, sqlite3_sourceid ** ** These interfaces provide the same information as the [SQLITE_VERSION], ** [SQLITE_VERSION_NUMBER], and [SQLITE_SOURCE_ID] C preprocessor macros |
| ︙ | ︙ | |||
265 266 267 268 269 270 271 | #endif /* ** CAPI3REF: Closing A Database Connection ** ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors ** for the [sqlite3] object. | | | | | 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | #endif /* ** CAPI3REF: Closing A Database Connection ** ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors ** for the [sqlite3] object. ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if ** the [sqlite3] object is successfully destroyed and all associated ** resources are deallocated. ** ** ^If the database connection is associated with unfinalized prepared ** statements or unfinished sqlite3_backup objects then sqlite3_close() ** will leave the database connection open and return [SQLITE_BUSY]. ** ^If sqlite3_close_v2() is called with unfinalized prepared statements ** and/or unfinished sqlite3_backups, then the database connection becomes ** an unusable "zombie" which will automatically be deallocated when the ** last prepared statement is finalized or the last sqlite3_backup is ** finished. The sqlite3_close_v2() interface is intended for use with ** host languages that are garbage collected, and where the order in which ** destructors are called is arbitrary. ** ** Applications should [sqlite3_finalize | finalize] all [prepared statements], ** [sqlite3_blob_close | close] all [BLOB handles], and ** [sqlite3_backup_finish | finish] all [sqlite3_backup] objects associated ** with the [sqlite3] object prior to attempting to close the object. ^If ** sqlite3_close_v2() is called on a [database connection] that still has ** outstanding [prepared statements], [BLOB handles], and/or ** [sqlite3_backup] objects then it returns [SQLITE_OK] and the deallocation ** of resources is deferred until all [prepared statements], [BLOB handles], ** and [sqlite3_backup] objects are also destroyed. ** ** ^If an [sqlite3] object is destroyed while a transaction is open, ** the transaction is automatically rolled back. ** ** The C parameter to [sqlite3_close(C)] and [sqlite3_close_v2(C)] |
| ︙ | ︙ | |||
382 383 384 385 386 387 388 | int (*callback)(void*,int,char**,char**), /* Callback function */ void *, /* 1st argument to callback */ char **errmsg /* Error msg written here */ ); /* ** CAPI3REF: Result Codes | < | | < | 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
int (*callback)(void*,int,char**,char**), /* Callback function */
void *, /* 1st argument to callback */
char **errmsg /* Error msg written here */
);
/*
** CAPI3REF: Result Codes
** KEYWORDS: {result code definitions}
**
** Many SQLite functions return an integer result code from the set shown
** here in order to indicate success or failure.
**
** New error codes may be added in future versions of SQLite.
**
** See also: [extended result code definitions]
*/
#define SQLITE_OK 0 /* Successful result */
/* beginning-of-error-codes */
#define SQLITE_ERROR 1 /* SQL error or missing database */
#define SQLITE_INTERNAL 2 /* Internal logic error in SQLite */
#define SQLITE_PERM 3 /* Access permission denied */
#define SQLITE_ABORT 4 /* Callback routine requested an abort */
|
| ︙ | ︙ | |||
429 430 431 432 433 434 435 | #define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */ #define SQLITE_ROW 100 /* sqlite3_step() has another row ready */ #define SQLITE_DONE 101 /* sqlite3_step() has finished executing */ /* end-of-error-codes */ /* ** CAPI3REF: Extended Result Codes | < | | | | | | | < < < < < < | 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 |
#define SQLITE_WARNING 28 /* Warnings from sqlite3_log() */
#define SQLITE_ROW 100 /* sqlite3_step() has another row ready */
#define SQLITE_DONE 101 /* sqlite3_step() has finished executing */
/* end-of-error-codes */
/*
** CAPI3REF: Extended Result Codes
** KEYWORDS: {extended result code definitions}
**
** In its default configuration, SQLite API routines return one of 30 integer
** [result codes]. However, experience has shown that many of
** these result codes are too coarse-grained. They do not provide as
** much information about problems as programmers might like. In an effort to
** address this, newer versions of SQLite (version 3.3.8 and later) include
** support for additional result codes that provide more detailed information
** about errors. These [extended result codes] are enabled or disabled
** on a per database connection basis using the
** [sqlite3_extended_result_codes()] API. Or, the extended code for
** the most recent error can be obtained using
** [sqlite3_extended_errcode()].
*/
#define SQLITE_IOERR_READ (SQLITE_IOERR | (1<<8))
#define SQLITE_IOERR_SHORT_READ (SQLITE_IOERR | (2<<8))
#define SQLITE_IOERR_WRITE (SQLITE_IOERR | (3<<8))
#define SQLITE_IOERR_FSYNC (SQLITE_IOERR | (4<<8))
#define SQLITE_IOERR_DIR_FSYNC (SQLITE_IOERR | (5<<8))
#define SQLITE_IOERR_TRUNCATE (SQLITE_IOERR | (6<<8))
|
| ︙ | ︙ | |||
502 503 504 505 506 507 508 509 510 511 512 513 514 515 | #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. | > | 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 | #define SQLITE_CONSTRAINT_TRIGGER (SQLITE_CONSTRAINT | (7<<8)) #define SQLITE_CONSTRAINT_UNIQUE (SQLITE_CONSTRAINT | (8<<8)) #define SQLITE_CONSTRAINT_VTAB (SQLITE_CONSTRAINT | (9<<8)) #define SQLITE_CONSTRAINT_ROWID (SQLITE_CONSTRAINT |(10<<8)) #define SQLITE_NOTICE_RECOVER_WAL (SQLITE_NOTICE | (1<<8)) #define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8)) #define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8)) #define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8)) /* ** CAPI3REF: Flags For File Open Operations ** ** These bit values are intended for use in the ** 3rd parameter to the [sqlite3_open_v2()] interface and ** in the 4th parameter to the [sqlite3_vfs.xOpen] method. |
| ︙ | ︙ | |||
681 682 683 684 685 686 687 | ** integer opcode. The third argument is a generic pointer intended to ** point to a structure that may contain arguments or space in which to ** write return values. Potential uses for xFileControl() might be ** functions to enable blocking locks with timeouts, to change the ** locking strategy (for example to use dot-file locks), to inquire ** about the status of a lock, or to break stale locks. The SQLite ** core reserves all opcodes less than 100 for its own use. | | | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 | ** integer opcode. The third argument is a generic pointer intended to ** point to a structure that may contain arguments or space in which to ** write return values. Potential uses for xFileControl() might be ** functions to enable blocking locks with timeouts, to change the ** locking strategy (for example to use dot-file locks), to inquire ** about the status of a lock, or to break stale locks. The SQLite ** core reserves all opcodes less than 100 for its own use. ** A [file control opcodes | list of opcodes] less than 100 is available. ** Applications that define a custom xFileControl method should use opcodes ** greater than 100 to avoid conflicts. VFS implementations should ** return [SQLITE_NOTFOUND] for file control opcodes that they do not ** recognize. ** ** The xSectorSize() method returns the sector size of the ** device that underlies the file. The sector size is the |
| ︙ | ︙ | |||
754 755 756 757 758 759 760 761 762 763 764 765 766 767 | int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p); /* Methods above are valid for version 3 */ /* Additional methods may be added in future releases */ }; /* ** CAPI3REF: Standard File Control Opcodes ** ** These integer constants are opcodes for the xFileControl method ** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()] ** interface. ** ** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This ** opcode causes the xFileControl method to write the current state of | > | 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 |
int (*xUnfetch)(sqlite3_file*, sqlite3_int64 iOfst, void *p);
/* Methods above are valid for version 3 */
/* Additional methods may be added in future releases */
};
/*
** CAPI3REF: Standard File Control Opcodes
** KEYWORDS: {file control opcodes} {file control opcode}
**
** These integer constants are opcodes for the xFileControl method
** of the [sqlite3_io_methods] object and for the [sqlite3_file_control()]
** interface.
**
** The [SQLITE_FCNTL_LOCKSTATE] opcode is used for debugging. This
** opcode causes the xFileControl method to write the current state of
|
| ︙ | ︙ | |||
2033 2034 2035 2036 2037 2038 2039 | */ SQLITE_API int sqlite3_complete(const char *sql); SQLITE_API int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors ** | | > | > | > > | | | > | | > < < < < < < < < < < < < < < < > | | > | | > > | 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 | */ SQLITE_API int sqlite3_complete(const char *sql); SQLITE_API int sqlite3_complete16(const void *sql); /* ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors ** ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X ** that might be invoked with argument P whenever ** an attempt is made to access a database table associated with ** [database connection] D when another thread ** or process has the table locked. ** The sqlite3_busy_handler() interface is used to implement ** [sqlite3_busy_timeout()] and [PRAGMA busy_timeout]. ** ** ^If the busy callback is NULL, then [SQLITE_BUSY] ** is returned immediately upon encountering the lock. ^If the busy callback ** is not NULL, then the callback might be invoked with two arguments. ** ** ^The first argument to the busy handler is a copy of the void* pointer which ** is the third argument to sqlite3_busy_handler(). ^The second argument to ** the busy handler callback is the number of times that the busy handler has ** been invoked for the same locking event. ^If the ** busy callback returns 0, then no additional attempts are made to ** access the database and [SQLITE_BUSY] is returned ** to the application. ** ^If the callback returns non-zero, then another attempt ** is made to access the database and the cycle repeats. ** ** The presence of a busy handler does not guarantee that it will be invoked ** when there is lock contention. ^If SQLite determines that invoking the busy ** handler could result in a deadlock, it will go ahead and return [SQLITE_BUSY] ** to the application instead of invoking the ** busy handler. ** Consider a scenario where one process is holding a read lock that ** it is trying to promote to a reserved lock and ** a second process is holding a reserved lock that it is trying ** to promote to an exclusive lock. The first process cannot proceed ** because it is blocked by the second and the second process cannot ** proceed because it is blocked by the first. If both processes ** invoke the busy handlers, neither will make any progress. Therefore, ** SQLite returns [SQLITE_BUSY] for the first process, hoping that this ** will induce the first process to release its read lock and allow ** the second process to proceed. ** ** ^The default busy callback is NULL. ** ** ^(There can only be a single busy handler defined for each ** [database connection]. Setting a new busy handler clears any ** previously set handler.)^ ^Note that calling [sqlite3_busy_timeout()] ** or evaluating [PRAGMA busy_timeout=N] will change the ** busy handler and thus clear any previously set busy handler. ** ** The busy callback should not take any actions which modify the ** database connection that invoked the busy handler. In other words, ** the busy handler is not reentrant. Any such actions ** result in undefined behavior. ** ** A busy handler must not close the database connection ** or [prepared statement] that invoked the busy handler. */ SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*); /* ** CAPI3REF: Set A Busy Timeout ** ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps ** for a specified amount of time when a table is locked. ^The handler ** will sleep multiple times until at least "ms" milliseconds of sleeping ** have accumulated. ^After at least "ms" milliseconds of sleeping, ** the handler returns 0 which causes [sqlite3_step()] to return ** [SQLITE_BUSY]. ** ** ^Calling this routine with an argument less than or equal to zero ** turns off all busy handlers. ** ** ^(There can only be a single busy handler for a particular ** [database connection] at any given moment. If another busy handler ** was defined (using [sqlite3_busy_handler()]) prior to calling ** this routine, that other busy handler is cleared.)^ ** ** See also: [PRAGMA busy_timeout] */ SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms); /* ** CAPI3REF: Convenience Routines For Running Queries ** ** This is a legacy interface that is preserved for backwards compatibility. |
| ︙ | ︙ | |||
2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 | ** ** ^The sqlite3_malloc() routine returns a pointer to a block ** of memory at least N bytes in length, where N is the parameter. ** ^If sqlite3_malloc() is unable to obtain sufficient free ** memory, it returns a NULL pointer. ^If the parameter N to ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns ** a NULL pointer. ** ** ^Calling sqlite3_free() with a pointer previously returned ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so ** that it might be reused. ^The sqlite3_free() routine is ** a no-op if is called with a NULL pointer. Passing a NULL pointer ** to sqlite3_free() is harmless. After being freed, memory ** should neither be read nor written. Even reading previously freed ** memory might result in a segmentation fault or other severe error. ** Memory corruption, a segmentation fault, or other severe error ** might result if sqlite3_free() is called with a non-NULL pointer that ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). ** | > > > > | | < | | | | | | | | | > > > > > > > > > > > > > > | > | 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 | ** ** ^The sqlite3_malloc() routine returns a pointer to a block ** of memory at least N bytes in length, where N is the parameter. ** ^If sqlite3_malloc() is unable to obtain sufficient free ** memory, it returns a NULL pointer. ^If the parameter N to ** sqlite3_malloc() is zero or negative then sqlite3_malloc() returns ** a NULL pointer. ** ** ^The sqlite3_malloc64(N) routine works just like ** sqlite3_malloc(N) except that N is an unsigned 64-bit integer instead ** of a signed 32-bit integer. ** ** ^Calling sqlite3_free() with a pointer previously returned ** by sqlite3_malloc() or sqlite3_realloc() releases that memory so ** that it might be reused. ^The sqlite3_free() routine is ** a no-op if is called with a NULL pointer. Passing a NULL pointer ** to sqlite3_free() is harmless. After being freed, memory ** should neither be read nor written. Even reading previously freed ** memory might result in a segmentation fault or other severe error. ** Memory corruption, a segmentation fault, or other severe error ** might result if sqlite3_free() is called with a non-NULL pointer that ** was not obtained from sqlite3_malloc() or sqlite3_realloc(). ** ** ^The sqlite3_realloc(X,N) interface attempts to resize a ** prior memory allocation X to be at least N bytes. ** ^If the X parameter to sqlite3_realloc(X,N) ** is a NULL pointer then its behavior is identical to calling ** sqlite3_malloc(N). ** ^If the N parameter to sqlite3_realloc(X,N) is zero or ** negative then the behavior is exactly the same as calling ** sqlite3_free(X). ** ^sqlite3_realloc(X,N) returns a pointer to a memory allocation ** of at least N bytes in size or NULL if insufficient memory is available. ** ^If M is the size of the prior allocation, then min(N,M) bytes ** of the prior allocation are copied into the beginning of buffer returned ** by sqlite3_realloc(X,N) and the prior allocation is freed. ** ^If sqlite3_realloc(X,N) returns NULL and N is positive, then the ** prior allocation is not freed. ** ** ^The sqlite3_realloc64(X,N) interfaces works the same as ** sqlite3_realloc(X,N) except that N is a 64-bit unsigned integer instead ** of a 32-bit signed integer. ** ** ^If X is a memory allocation previously obtained from sqlite3_malloc(), ** sqlite3_malloc64(), sqlite3_realloc(), or sqlite3_realloc64(), then ** sqlite3_msize(X) returns the size of that memory allocation in bytes. ** ^The value returned by sqlite3_msize(X) might be larger than the number ** of bytes requested when X was allocated. ^If X is a NULL pointer then ** sqlite3_msize(X) returns zero. If X points to something that is not ** the beginning of memory allocation, or if it points to a formerly ** valid memory allocation that has now been freed, then the behavior ** of sqlite3_msize(X) is undefined and possibly harmful. ** ** ^The memory returned by sqlite3_malloc(), sqlite3_realloc(), ** sqlite3_malloc64(), and sqlite3_realloc64() ** is always aligned to at least an 8 byte boundary, or to a ** 4 byte boundary if the [SQLITE_4_BYTE_ALIGNED_MALLOC] compile-time ** option is used. ** ** In SQLite version 3.5.0 and 3.5.1, it was possible to define ** the SQLITE_OMIT_MEMORY_ALLOCATION which would cause the built-in ** implementation of these routines to be omitted. That capability |
| ︙ | ︙ | |||
2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 | ** not yet been released. ** ** The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ SQLITE_API void *sqlite3_malloc(int); SQLITE_API void *sqlite3_realloc(void*, int); SQLITE_API void sqlite3_free(void*); /* ** CAPI3REF: Memory Allocator Statistics ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. | > > > | 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 | ** not yet been released. ** ** The application must not read or write any part of ** a block of memory after it has been released using ** [sqlite3_free()] or [sqlite3_realloc()]. */ SQLITE_API void *sqlite3_malloc(int); SQLITE_API void *sqlite3_malloc64(sqlite3_uint64); SQLITE_API void *sqlite3_realloc(void*, int); SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64); SQLITE_API void sqlite3_free(void*); SQLITE_API sqlite3_uint64 sqlite3_msize(void*); /* ** CAPI3REF: Memory Allocator Statistics ** ** SQLite provides these two interfaces for reporting on the status ** of the [sqlite3_malloc()], [sqlite3_free()], and [sqlite3_realloc()] ** routines, which form the built-in memory allocation subsystem. |
| ︙ | ︙ | |||
2514 2515 2516 2517 2518 2519 2520 | ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. ** | | | | 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 | ** ** The [sqlite3_set_authorizer | authorizer callback function] must ** return either [SQLITE_OK] or one of these two constants in order ** to signal SQLite whether or not the action is permitted. See the ** [sqlite3_set_authorizer | authorizer documentation] for additional ** information. ** ** Note that SQLITE_IGNORE is also used as a [conflict resolution mode] ** returned from the [sqlite3_vtab_on_conflict()] interface. */ #define SQLITE_DENY 1 /* Abort the SQL statement with an error */ #define SQLITE_IGNORE 2 /* Don't allow access, but don't generate an error */ /* ** CAPI3REF: Authorizer Action Codes ** |
| ︙ | ︙ | |||
2656 2657 2658 2659 2660 2661 2662 | ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] ** object.)^ ^(If the database is opened (and/or created) successfully, then ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain ** an English language description of the error following a failure of any ** of the sqlite3_open() routines. ** | | | | | 2665 2666 2667 2668 2669 2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 | ** a NULL will be written into *ppDb instead of a pointer to the [sqlite3] ** object.)^ ^(If the database is opened (and/or created) successfully, then ** [SQLITE_OK] is returned. Otherwise an [error code] is returned.)^ ^The ** [sqlite3_errmsg()] or [sqlite3_errmsg16()] routines can be used to obtain ** an English language description of the error following a failure of any ** of the sqlite3_open() routines. ** ** ^The default encoding will be UTF-8 for databases created using ** sqlite3_open() or sqlite3_open_v2(). ^The default encoding for databases ** created using sqlite3_open16() will be UTF-16 in the native byte order. ** ** Whether or not an error occurs when it is opened, resources ** associated with the [database connection] handle should be released by ** passing it to [sqlite3_close()] when it is no longer required. ** ** The sqlite3_open_v2() interface works like sqlite3_open() ** except that it accepts two additional parameters for additional control |
| ︙ | ︙ | |||
2746 2747 2748 2749 2750 2751 2752 | ** present, is ignored. ** ** ^SQLite uses the path component of the URI as the name of the disk file ** which contains the database. ^If the path begins with a '/' character, ** then it is interpreted as an absolute path. ^If the path does not begin ** with a '/' (meaning that the authority section is omitted from the URI) ** then the path is interpreted as a relative path. | | | > | | 2755 2756 2757 2758 2759 2760 2761 2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 | ** present, is ignored. ** ** ^SQLite uses the path component of the URI as the name of the disk file ** which contains the database. ^If the path begins with a '/' character, ** then it is interpreted as an absolute path. ^If the path does not begin ** with a '/' (meaning that the authority section is omitted from the URI) ** then the path is interpreted as a relative path. ** ^(On windows, the first component of an absolute path ** is a drive specification (e.g. "C:").)^ ** ** [[core URI query parameters]] ** The query component of a URI may contain parameters that are interpreted ** either by SQLite itself, or by a [VFS | custom VFS implementation]. ** SQLite and its built-in [VFSes] interpret the ** following query parameters: ** ** <ul> ** <li> <b>vfs</b>: ^The "vfs" parameter may be used to specify the name of ** a VFS object that provides the operating system interface that should ** be used to access the database file on disk. ^If this option is set to ** an empty string the default VFS object is used. ^Specifying an unknown ** VFS is an error. ^If sqlite3_open_v2() is used and the vfs option is |
| ︙ | ︙ | |||
2787 2788 2789 2790 2791 2792 2793 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in ** a URI filename, its value overrides any behavior requested by setting ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. ** | | < | < | 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 | ** SQLITE_OPEN_SHAREDCACHE bit in the flags argument passed to ** sqlite3_open_v2(). ^Setting the cache parameter to "private" is ** equivalent to setting the SQLITE_OPEN_PRIVATECACHE bit. ** ^If sqlite3_open_v2() is used and the "cache" parameter is present in ** a URI filename, its value overrides any behavior requested by setting ** SQLITE_OPEN_PRIVATECACHE or SQLITE_OPEN_SHAREDCACHE flag. ** ** <li> <b>psow</b>: ^The psow parameter indicates whether or not the ** [powersafe overwrite] property does or does not apply to the ** storage media on which the database file resides. ** ** <li> <b>nolock</b>: ^The nolock parameter is a boolean query parameter ** which if set disables file locking in rollback journal modes. This ** is useful for accessing a database on a filesystem that does not ** support locking. Caution: Database corruption might result if two ** or more processes write to the same database and any one of those ** processes uses nolock=1. |
| ︙ | ︙ | |||
3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 |
**
** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
** <dd>The maximum index number of any [parameter] in an SQL statement.)^
**
** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
** <dd>The maximum depth of recursion for triggers.</dd>)^
** </dl>
*/
#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
#define SQLITE_LIMIT_COLUMN 2
#define SQLITE_LIMIT_EXPR_DEPTH 3
#define SQLITE_LIMIT_COMPOUND_SELECT 4
#define SQLITE_LIMIT_VDBE_OP 5
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
/*
** CAPI3REF: Compiling An SQL Statement
** KEYWORDS: {SQL statement compiler}
**
** To execute an SQL query, it must first be compiled into a byte-code
** program using one of these routines.
| > > > > > | 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125 3126 |
**
** [[SQLITE_LIMIT_VARIABLE_NUMBER]]
** ^(<dt>SQLITE_LIMIT_VARIABLE_NUMBER</dt>
** <dd>The maximum index number of any [parameter] in an SQL statement.)^
**
** [[SQLITE_LIMIT_TRIGGER_DEPTH]] ^(<dt>SQLITE_LIMIT_TRIGGER_DEPTH</dt>
** <dd>The maximum depth of recursion for triggers.</dd>)^
**
** [[SQLITE_LIMIT_WORKER_THREADS]] ^(<dt>SQLITE_LIMIT_WORKER_THREADS</dt>
** <dd>The maximum number of auxiliary worker threads that a single
** [prepared statement] may start.</dd>)^
** </dl>
*/
#define SQLITE_LIMIT_LENGTH 0
#define SQLITE_LIMIT_SQL_LENGTH 1
#define SQLITE_LIMIT_COLUMN 2
#define SQLITE_LIMIT_EXPR_DEPTH 3
#define SQLITE_LIMIT_COMPOUND_SELECT 4
#define SQLITE_LIMIT_VDBE_OP 5
#define SQLITE_LIMIT_FUNCTION_ARG 6
#define SQLITE_LIMIT_ATTACHED 7
#define SQLITE_LIMIT_LIKE_PATTERN_LENGTH 8
#define SQLITE_LIMIT_VARIABLE_NUMBER 9
#define SQLITE_LIMIT_TRIGGER_DEPTH 10
#define SQLITE_LIMIT_WORKER_THREADS 11
/*
** CAPI3REF: Compiling An SQL Statement
** KEYWORDS: {SQL statement compiler}
**
** To execute an SQL query, it must first be compiled into a byte-code
** program using one of these routines.
|
| ︙ | ︙ | |||
3373 3374 3375 3376 3377 3378 3379 | ** number of <u>bytes</u> in the value, not the number of characters.)^ ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() ** is negative, then the length of the string is ** the number of bytes up to the first zero terminator. ** If the fourth parameter to sqlite3_bind_blob() is negative, then ** the behavior is undefined. ** If a non-negative fourth parameter is provided to sqlite3_bind_text() | > | | | | < > > > > > > > > | 3386 3387 3388 3389 3390 3391 3392 3393 3394 3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405 3406 3407 3408 3409 3410 3411 3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 | ** number of <u>bytes</u> in the value, not the number of characters.)^ ** ^If the fourth parameter to sqlite3_bind_text() or sqlite3_bind_text16() ** is negative, then the length of the string is ** the number of bytes up to the first zero terminator. ** If the fourth parameter to sqlite3_bind_blob() is negative, then ** the behavior is undefined. ** If a non-negative fourth parameter is provided to sqlite3_bind_text() ** or sqlite3_bind_text16() or sqlite3_bind_text64() then ** that parameter must be the byte offset ** where the NUL terminator would occur assuming the string were NUL ** terminated. If any NUL characters occur at byte offsets less than ** the value of the fourth parameter then the resulting string value will ** contain embedded NULs. The result of expressions involving strings ** with embedded NULs is undefined. ** ** ^The fifth argument to the BLOB and string binding interfaces ** is a destructor used to dispose of the BLOB or ** string after SQLite has finished with it. ^The destructor is called ** to dispose of the BLOB or string even if the call to bind API fails. ** ^If the fifth argument is ** the special value [SQLITE_STATIC], then SQLite assumes that the ** information is in static, unmanaged space and does not need to be freed. ** ^If the fifth argument has the value [SQLITE_TRANSIENT], then ** SQLite makes its own private copy of the data immediately, before ** the sqlite3_bind_*() routine returns. ** ** ^The sixth argument to sqlite3_bind_text64() must be one of ** [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE] ** to specify the encoding of the text in the third parameter. If ** the sixth argument to sqlite3_bind_text64() is not one of the ** allowed values shown above, or if the text encoding is different ** from the encoding specified by the sixth parameter, then the behavior ** is undefined. ** ** ^The sqlite3_bind_zeroblob() routine binds a BLOB of length N that ** is filled with zeroes. ^A zeroblob uses a fixed amount of memory ** (just an integer to hold its size) while it is being processed. ** Zeroblobs are intended to serve as placeholders for BLOBs whose ** content is later written using ** [sqlite3_blob_open | incremental BLOB I/O] routines. |
| ︙ | ︙ | |||
3412 3413 3414 3415 3416 3417 3418 3419 3420 3421 3422 3423 3424 3425 3426 3427 3428 3429 | ** result is undefined and probably harmful. ** ** ^Bindings are not cleared by the [sqlite3_reset()] routine. ** ^Unbound parameters are interpreted as NULL. ** ** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an ** [error code] if anything goes wrong. ** ^[SQLITE_RANGE] is returned if the parameter ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails. ** ** See also: [sqlite3_bind_parameter_count()], ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()]. */ SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*)); SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double); SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int); SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64); SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int); | > > > > > | > > | 3433 3434 3435 3436 3437 3438 3439 3440 3441 3442 3443 3444 3445 3446 3447 3448 3449 3450 3451 3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 |
** result is undefined and probably harmful.
**
** ^Bindings are not cleared by the [sqlite3_reset()] routine.
** ^Unbound parameters are interpreted as NULL.
**
** ^The sqlite3_bind_* routines return [SQLITE_OK] on success or an
** [error code] if anything goes wrong.
** ^[SQLITE_TOOBIG] might be returned if the size of a string or BLOB
** exceeds limits imposed by [sqlite3_limit]([SQLITE_LIMIT_LENGTH]) or
** [SQLITE_MAX_LENGTH].
** ^[SQLITE_RANGE] is returned if the parameter
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
**
** See also: [sqlite3_bind_parameter_count()],
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
*/
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
void(*)(void*));
SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
/*
** CAPI3REF: Number Of SQL Parameters
**
** ^This routine can be used to find the number of [SQL parameters]
|
| ︙ | ︙ | |||
4173 4174 4175 4176 4177 4178 4179 | ** extract values from the [sqlite3_value] objects. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] ** object results in undefined behavior. ** ** ^These routines work just like the corresponding [column access functions] | | | 4201 4202 4203 4204 4205 4206 4207 4208 4209 4210 4211 4212 4213 4214 4215 | ** extract values from the [sqlite3_value] objects. ** ** These routines work only with [protected sqlite3_value] objects. ** Any attempt to use these routines on an [unprotected sqlite3_value] ** object results in undefined behavior. ** ** ^These routines work just like the corresponding [column access functions] ** except that these routines take a single [protected sqlite3_value] object ** pointer instead of a [sqlite3_stmt*] pointer and an integer column number. ** ** ^The sqlite3_value_text16() interface extracts a UTF-16 string ** in the native byte-order of the host machine. ^The ** sqlite3_value_text16be() and sqlite3_value_text16le() interfaces ** extract UTF-16 strings as big-endian and little-endian respectively. ** |
| ︙ | ︙ | |||
4420 4421 4422 4423 4424 4425 4426 4427 4428 4429 4430 4431 4432 4433 | ** of the application-defined function to be NULL. ** ** ^The sqlite3_result_text(), sqlite3_result_text16(), ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces ** set the return value of the application-defined function to be ** a text string which is represented as UTF-8, UTF-16 native byte order, ** UTF-16 little endian, or UTF-16 big endian, respectively. ** ^SQLite takes the text result from the application from ** the 2nd parameter of the sqlite3_result_text* interfaces. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is negative, then SQLite takes result text from the 2nd parameter ** through the first zero character. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is non-negative, then as many bytes (not characters) of the text | > > > > | 4448 4449 4450 4451 4452 4453 4454 4455 4456 4457 4458 4459 4460 4461 4462 4463 4464 4465 | ** of the application-defined function to be NULL. ** ** ^The sqlite3_result_text(), sqlite3_result_text16(), ** sqlite3_result_text16le(), and sqlite3_result_text16be() interfaces ** set the return value of the application-defined function to be ** a text string which is represented as UTF-8, UTF-16 native byte order, ** UTF-16 little endian, or UTF-16 big endian, respectively. ** ^The sqlite3_result_text64() interface sets the return value of an ** application-defined function to be a text string in an encoding ** specified by the fifth (and last) parameter, which must be one ** of [SQLITE_UTF8], [SQLITE_UTF16], [SQLITE_UTF16BE], or [SQLITE_UTF16LE]. ** ^SQLite takes the text result from the application from ** the 2nd parameter of the sqlite3_result_text* interfaces. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is negative, then SQLite takes result text from the 2nd parameter ** through the first zero character. ** ^If the 3rd parameter to the sqlite3_result_text* interfaces ** is non-negative, then as many bytes (not characters) of the text |
| ︙ | ︙ | |||
4463 4464 4465 4466 4467 4468 4469 4470 4471 4472 4473 4474 4475 4476 4477 4478 4479 4480 4481 4482 4483 4484 4485 4486 | ** kind of [sqlite3_value] object can be used with this interface. ** ** If these routines are called from within the different thread ** than the one containing the application-defined function that received ** the [sqlite3_context] pointer, the results are undefined. */ SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_double(sqlite3_context*, double); SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int); SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int); SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*); SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*); SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int); SQLITE_API void sqlite3_result_int(sqlite3_context*, int); SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64); SQLITE_API void sqlite3_result_null(sqlite3_context*); SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*)); SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*)); SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*); SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n); /* | > > > | 4495 4496 4497 4498 4499 4500 4501 4502 4503 4504 4505 4506 4507 4508 4509 4510 4511 4512 4513 4514 4515 4516 4517 4518 4519 4520 4521 |
** kind of [sqlite3_value] object can be used with this interface.
**
** If these routines are called from within the different thread
** than the one containing the application-defined function that received
** the [sqlite3_context] pointer, the results are undefined.
*/
SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,sqlite3_uint64,void(*)(void*));
SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
SQLITE_API void sqlite3_result_null(sqlite3_context*);
SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
void(*)(void*), unsigned char encoding);
SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
/*
|
| ︙ | ︙ | |||
4701 4702 4703 4704 4705 4706 4707 4708 4709 4710 4711 4712 4713 4714 4715 4716 4717 4718 4719 4720 4721 4722 4723 4724 4725 4726 4727 4728 4729 4730 4731 4732 4733 | ** ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite when using a built-in [sqlite3_vfs | VFS] ** will be placed in that directory.)^ ^If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been called and that this variable remain unchanged ** thereafter. ** ** ^The [temp_store_directory pragma] may modify this variable and cause ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, ** the [temp_store_directory pragma] always assumes that any string ** that this variable points to is held in memory obtained from ** [sqlite3_malloc] and the pragma may attempt to free that memory ** using [sqlite3_free]. ** Hence, if this variable is modified directly, either it should be ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [temp_store_directory pragma] should be avoided. ** ** <b>Note to Windows Runtime users:</b> The temporary directory must be set ** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various ** features that require the use of temporary files may fail. Here is an ** example of how to do this using C++ with the Windows Runtime: ** ** <blockquote><pre> | > > > > > > > > > > > > | 4736 4737 4738 4739 4740 4741 4742 4743 4744 4745 4746 4747 4748 4749 4750 4751 4752 4753 4754 4755 4756 4757 4758 4759 4760 4761 4762 4763 4764 4765 4766 4767 4768 4769 4770 4771 4772 4773 4774 4775 4776 4777 4778 4779 4780 | ** ** ^(If this global variable is made to point to a string which is ** the name of a folder (a.k.a. directory), then all temporary files ** created by SQLite when using a built-in [sqlite3_vfs | VFS] ** will be placed in that directory.)^ ^If this variable ** is a NULL pointer, then SQLite performs a search for an appropriate ** temporary file directory. ** ** Applications are strongly discouraged from using this global variable. ** It is required to set a temporary folder on Windows Runtime (WinRT). ** But for all other platforms, it is highly recommended that applications ** neither read nor write this variable. This global variable is a relic ** that exists for backwards compatibility of legacy applications and should ** be avoided in new projects. ** ** It is not safe to read or modify this variable in more than one ** thread at a time. It is not safe to read or modify this variable ** if a [database connection] is being used at the same time in a separate ** thread. ** It is intended that this variable be set once ** as part of process initialization and before any SQLite interface ** routines have been called and that this variable remain unchanged ** thereafter. ** ** ^The [temp_store_directory pragma] may modify this variable and cause ** it to point to memory obtained from [sqlite3_malloc]. ^Furthermore, ** the [temp_store_directory pragma] always assumes that any string ** that this variable points to is held in memory obtained from ** [sqlite3_malloc] and the pragma may attempt to free that memory ** using [sqlite3_free]. ** Hence, if this variable is modified directly, either it should be ** made NULL or made to point to memory obtained from [sqlite3_malloc] ** or else the use of the [temp_store_directory pragma] should be avoided. ** Except when requested by the [temp_store_directory pragma], SQLite ** does not free the memory that sqlite3_temp_directory points to. If ** the application wants that memory to be freed, it must do ** so itself, taking care to only do so after all [database connection] ** objects have been destroyed. ** ** <b>Note to Windows Runtime users:</b> The temporary directory must be set ** prior to calling [sqlite3_open] or [sqlite3_open_v2]. Otherwise, various ** features that require the use of temporary files may fail. Here is an ** example of how to do this using C++ with the Windows Runtime: ** ** <blockquote><pre> |
| ︙ | ︙ | |||
5854 5855 5856 5857 5858 5859 5860 | ** to sqlite3_mutex_alloc() is one of these integer constants: ** ** <ul> ** <li> SQLITE_MUTEX_FAST ** <li> SQLITE_MUTEX_RECURSIVE ** <li> SQLITE_MUTEX_STATIC_MASTER ** <li> SQLITE_MUTEX_STATIC_MEM | | | > > | 5901 5902 5903 5904 5905 5906 5907 5908 5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 | ** to sqlite3_mutex_alloc() is one of these integer constants: ** ** <ul> ** <li> SQLITE_MUTEX_FAST ** <li> SQLITE_MUTEX_RECURSIVE ** <li> SQLITE_MUTEX_STATIC_MASTER ** <li> SQLITE_MUTEX_STATIC_MEM ** <li> SQLITE_MUTEX_STATIC_OPEN ** <li> SQLITE_MUTEX_STATIC_PRNG ** <li> SQLITE_MUTEX_STATIC_LRU ** <li> SQLITE_MUTEX_STATIC_PMEM ** <li> SQLITE_MUTEX_STATIC_APP1 ** <li> SQLITE_MUTEX_STATIC_APP2 ** </ul>)^ ** ** ^The first two constants (SQLITE_MUTEX_FAST and SQLITE_MUTEX_RECURSIVE) ** cause sqlite3_mutex_alloc() to create ** a new mutex. ^The new mutex is recursive when SQLITE_MUTEX_RECURSIVE ** is used but not necessarily so when SQLITE_MUTEX_FAST is used. ** The mutex implementation does not need to make a distinction |
| ︙ | ︙ | |||
6061 6062 6063 6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 | #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ /* ** CAPI3REF: Retrieve the mutex for a database connection ** ** ^This interface returns a pointer the [sqlite3_mutex] object that ** serializes access to the [database connection] given in the argument ** when the [threading mode] is Serialized. | > > > | 6110 6111 6112 6113 6114 6115 6116 6117 6118 6119 6120 6121 6122 6123 6124 6125 6126 | #define SQLITE_MUTEX_STATIC_MEM 3 /* sqlite3_malloc() */ #define SQLITE_MUTEX_STATIC_MEM2 4 /* NOT USED */ #define SQLITE_MUTEX_STATIC_OPEN 4 /* sqlite3BtreeOpen() */ #define SQLITE_MUTEX_STATIC_PRNG 5 /* sqlite3_random() */ #define SQLITE_MUTEX_STATIC_LRU 6 /* lru page list */ #define SQLITE_MUTEX_STATIC_LRU2 7 /* NOT USED */ #define SQLITE_MUTEX_STATIC_PMEM 7 /* sqlite3PageMalloc() */ #define SQLITE_MUTEX_STATIC_APP1 8 /* For use by application */ #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */ #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */ /* ** CAPI3REF: Retrieve the mutex for a database connection ** ** ^This interface returns a pointer the [sqlite3_mutex] object that ** serializes access to the [database connection] given in the argument ** when the [threading mode] is Serialized. |
| ︙ | ︙ | |||
6152 6153 6154 6155 6156 6157 6158 | #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 | | > > | | 6204 6205 6206 6207 6208 6209 6210 6211 6212 6213 6214 6215 6216 6217 6218 6219 6220 6221 6222 6223 6224 | #define SQLITE_TESTCTRL_ASSERT 12 #define SQLITE_TESTCTRL_ALWAYS 13 #define SQLITE_TESTCTRL_RESERVE 14 #define SQLITE_TESTCTRL_OPTIMIZATIONS 15 #define SQLITE_TESTCTRL_ISKEYWORD 16 #define SQLITE_TESTCTRL_SCRATCHMALLOC 17 #define SQLITE_TESTCTRL_LOCALTIME_FAULT 18 #define SQLITE_TESTCTRL_EXPLAIN_STMT 19 /* NOT USED */ #define SQLITE_TESTCTRL_NEVER_CORRUPT 20 #define SQLITE_TESTCTRL_VDBE_COVERAGE 21 #define SQLITE_TESTCTRL_BYTEORDER 22 #define SQLITE_TESTCTRL_ISINIT 23 #define SQLITE_TESTCTRL_SORTER_MMAP 24 #define SQLITE_TESTCTRL_LAST 24 /* ** CAPI3REF: SQLite Runtime Status ** ** ^This interface is used to retrieve runtime status information ** about the performance of SQLite, and optionally to reset various ** highwater marks. ^The first argument is an integer code for |
| ︙ | ︙ | |||
6347 6348 6349 6350 6351 6352 6353 | ** <dd>This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to all lookaside ** memory already being in use. ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> | | | | | 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 | ** <dd>This parameter returns the number malloc attempts that might have ** been satisfied using lookaside memory but failed due to all lookaside ** memory already being in use. ** Only the high-water value is meaningful; ** the current value is always zero.)^ ** ** [[SQLITE_DBSTATUS_CACHE_USED]] ^(<dt>SQLITE_DBSTATUS_CACHE_USED</dt> ** <dd>This parameter returns the approximate number of bytes of heap ** memory used by all pager caches associated with the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0. ** ** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt> ** <dd>This parameter returns the approximate number of bytes of heap ** memory used to store the schema for all databases associated ** with the connection - main, temp, and any [ATTACH]-ed databases.)^ ** ^The full amount of memory used by the schemas is reported, even if the ** schema memory is shared with other database connections due to ** [shared cache mode] being enabled. ** ^The highwater mark associated with SQLITE_DBSTATUS_SCHEMA_USED is always 0. ** ** [[SQLITE_DBSTATUS_STMT_USED]] ^(<dt>SQLITE_DBSTATUS_STMT_USED</dt> ** <dd>This parameter returns the approximate number of bytes of heap ** and lookaside memory used by all prepared statements associated with ** the database connection.)^ ** ^The highwater mark associated with SQLITE_DBSTATUS_STMT_USED is always 0. ** </dd> ** ** [[SQLITE_DBSTATUS_CACHE_HIT]] ^(<dt>SQLITE_DBSTATUS_CACHE_HIT</dt> ** <dd>This parameter returns the number of pager cache hits that have |
| ︙ | ︙ | |||
7139 7140 7141 7142 7143 7144 7145 7146 7147 7148 7149 7150 7151 7152 7153 7154 7155 7156 7157 7158 7159 7160 7161 7162 7163 7164 7165 7166 7167 7168 7169 | ** ^The callback registered by this function replaces any existing callback ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism ** configured by this function. ** ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface ** from SQL. ** ** ^Every new [database connection] defaults to having the auto-checkpoint ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] ** pages. The use of this interface ** is only necessary if the default setting is found to be suboptimal ** for a particular application. */ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); /* ** CAPI3REF: Checkpoint a database ** ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X ** on [database connection] D to be [checkpointed]. ^If X is NULL or an ** empty string, then a checkpoint is run on all databases of ** connection D. ^If the database connection D is not in ** [WAL | write-ahead log mode] then this interface is a harmless no-op. ** ** ^The [wal_checkpoint pragma] can be used to invoke this interface ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] can be used to cause this interface to be ** run whenever the WAL reaches a certain size threshold. ** ** See also: [sqlite3_wal_checkpoint_v2()] | > > > > > > > | 7193 7194 7195 7196 7197 7198 7199 7200 7201 7202 7203 7204 7205 7206 7207 7208 7209 7210 7211 7212 7213 7214 7215 7216 7217 7218 7219 7220 7221 7222 7223 7224 7225 7226 7227 7228 7229 7230 | ** ^The callback registered by this function replaces any existing callback ** registered using [sqlite3_wal_hook()]. ^Likewise, registering a callback ** using [sqlite3_wal_hook()] disables the automatic checkpoint mechanism ** configured by this function. ** ** ^The [wal_autocheckpoint pragma] can be used to invoke this interface ** from SQL. ** ** ^Checkpoints initiated by this mechanism are ** [sqlite3_wal_checkpoint_v2|PASSIVE]. ** ** ^Every new [database connection] defaults to having the auto-checkpoint ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT] ** pages. The use of this interface ** is only necessary if the default setting is found to be suboptimal ** for a particular application. */ SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N); /* ** CAPI3REF: Checkpoint a database ** ** ^The [sqlite3_wal_checkpoint(D,X)] interface causes database named X ** on [database connection] D to be [checkpointed]. ^If X is NULL or an ** empty string, then a checkpoint is run on all databases of ** connection D. ^If the database connection D is not in ** [WAL | write-ahead log mode] then this interface is a harmless no-op. ** ^The [sqlite3_wal_checkpoint(D,X)] interface initiates a ** [sqlite3_wal_checkpoint_v2|PASSIVE] checkpoint. ** Use the [sqlite3_wal_checkpoint_v2()] interface to get a FULL ** or RESET checkpoint. ** ** ^The [wal_checkpoint pragma] can be used to invoke this interface ** from SQL. ^The [sqlite3_wal_autocheckpoint()] interface and the ** [wal_autocheckpoint pragma] can be used to cause this interface to be ** run whenever the WAL reaches a certain size threshold. ** ** See also: [sqlite3_wal_checkpoint_v2()] |
| ︙ | ︙ | |||
7178 7179 7180 7181 7182 7183 7184 | ** eMode parameter: ** ** <dl> ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd> ** Checkpoint as many frames as possible without waiting for any database ** readers or writers to finish. Sync the db file if all frames in the log ** are checkpointed. This mode is the same as calling | | > | > | > | 7239 7240 7241 7242 7243 7244 7245 7246 7247 7248 7249 7250 7251 7252 7253 7254 7255 7256 7257 7258 7259 7260 7261 7262 7263 7264 7265 7266 7267 | ** eMode parameter: ** ** <dl> ** <dt>SQLITE_CHECKPOINT_PASSIVE<dd> ** Checkpoint as many frames as possible without waiting for any database ** readers or writers to finish. Sync the db file if all frames in the log ** are checkpointed. This mode is the same as calling ** sqlite3_wal_checkpoint(). The [sqlite3_busy_handler|busy-handler callback] ** is never invoked. ** ** <dt>SQLITE_CHECKPOINT_FULL<dd> ** This mode blocks (it invokes the ** [sqlite3_busy_handler|busy-handler callback]) until there is no ** database writer and all readers are reading from the most recent database ** snapshot. It then checkpoints all frames in the log file and syncs the ** database file. This call blocks database writers while it is running, ** but not database readers. ** ** <dt>SQLITE_CHECKPOINT_RESTART<dd> ** This mode works the same way as SQLITE_CHECKPOINT_FULL, except after ** checkpointing the log file it blocks (calls the ** [sqlite3_busy_handler|busy-handler callback]) ** until all readers are reading from the database file only. This ensures ** that the next client to write to the database file restarts the log file ** from the beginning. This call blocks database writers while it is running, ** but not database readers. ** </dl> ** ** If pnLog is not NULL, then *pnLog is set to the total number of frames in |
| ︙ | ︙ | |||
7327 7328 7329 7330 7331 7332 7333 7334 7335 7336 7337 7338 7339 7340 | ** of the SQL statement that triggered the call to the [xUpdate] method of the ** [virtual table]. */ SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *); /* ** CAPI3REF: Conflict resolution modes ** ** These constants are returned by [sqlite3_vtab_on_conflict()] to ** inform a [virtual table] implementation what the [ON CONFLICT] mode ** is for the SQL statement being evaluated. ** ** Note that the [SQLITE_IGNORE] constant is also used as a potential ** return value from the [sqlite3_set_authorizer()] callback and that | > | 7391 7392 7393 7394 7395 7396 7397 7398 7399 7400 7401 7402 7403 7404 7405 |
** of the SQL statement that triggered the call to the [xUpdate] method of the
** [virtual table].
*/
SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
/*
** CAPI3REF: Conflict resolution modes
** KEYWORDS: {conflict resolution mode}
**
** These constants are returned by [sqlite3_vtab_on_conflict()] to
** inform a [virtual table] implementation what the [ON CONFLICT] mode
** is for the SQL statement being evaluated.
**
** Note that the [SQLITE_IGNORE] constant is also used as a potential
** return value from the [sqlite3_set_authorizer()] callback and that
|
| ︙ | ︙ |
Changes to src/stash.c.
| ︙ | ︙ | |||
21 22 23 24 25 26 27 | #include <assert.h> /* ** SQL code to implement the tables needed by the stash. */ static const char zStashInit[] = | | | | 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | #include <assert.h> /* ** SQL code to implement the tables needed by the stash. */ static const char zStashInit[] = @ CREATE TABLE IF NOT EXISTS "%w".stash( @ stashid INTEGER PRIMARY KEY, -- Unique stash identifier @ vid INTEGER, -- The baseline check-out for this stash @ comment TEXT, -- Comment for this stash. Or NULL @ ctime TIMESTAMP -- When the stash was created @ ); @ CREATE TABLE IF NOT EXISTS "%w".stashfile( @ stashid INTEGER REFERENCES stash, -- Stash that contains this file @ rid INTEGER, -- Baseline content in BLOB table or 0. @ isAdded BOOLEAN, -- True if this is an added file @ isRemoved BOOLEAN, -- True if this file is deleted @ isExec BOOLEAN, -- True if file is executable @ isLink BOOLEAN, -- True if file is a symlink @ origname TEXT, -- Original filename |
| ︙ | ︙ | |||
59 60 61 62 63 64 65 |
Stmt q; /* Query against the vfile table */
Stmt ins; /* Insert statement */
zFile = mprintf("%/", zFName);
file_tree_name(zFile, &fname, 1);
zTreename = blob_str(&fname);
blob_zero(&sql);
| | | | | 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 |
Stmt q; /* Query against the vfile table */
Stmt ins; /* Insert statement */
zFile = mprintf("%/", zFName);
file_tree_name(zFile, &fname, 1);
zTreename = blob_str(&fname);
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT deleted, isexe, islink, mrid, pathname, coalesce(origname,pathname)"
" FROM vfile"
" WHERE vid=%d AND (chnged OR deleted OR origname NOT NULL OR mrid==0)",
vid
);
if( fossil_strcmp(zTreename,".")!=0 ){
blob_append_sql(&sql,
" AND (pathname GLOB '%q/*' OR origname GLOB '%q/*'"
" OR pathname=%Q OR origname=%Q)",
zTreename, zTreename, zTreename, zTreename
);
}
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
db_prepare(&ins,
"INSERT INTO stashfile(stashid, rid, isAdded, isRemoved, isExec, isLink,"
"origname, newname, delta)"
"VALUES(%d,:rid,:isadd,:isrm,:isexe,:islink,:orig,:new,:content)",
stashid
);
|
| ︙ | ︙ | |||
479 480 481 482 483 484 485 |
int nCmd;
int stashid = 0;
undo_capture_command_line();
db_must_be_within_tree();
db_open_config(0);
db_begin_transaction();
zDb = db_name("localdb");
| | | 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 |
int nCmd;
int stashid = 0;
undo_capture_command_line();
db_must_be_within_tree();
db_open_config(0);
db_begin_transaction();
zDb = db_name("localdb");
db_multi_exec(zStashInit /*works-like:"%w,%w"*/, zDb, zDb);
if( g.argc<=2 ){
zCmd = "save";
}else{
zCmd = g.argv[2];
}
nCmd = strlen(zCmd);
if( memcmp(zCmd, "save", nCmd)==0 ){
|
| ︙ | ︙ | |||
532 533 534 535 536 537 538 |
if( !verboseFlag ){
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
}
verify_all_options();
db_prepare(&q,
"SELECT stashid, (SELECT uuid FROM blob WHERE rid=vid),"
" comment, datetime(ctime) FROM stash"
| | | | 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
if( !verboseFlag ){
verboseFlag = find_option("detail","l",0)!=0; /* deprecated */
}
verify_all_options();
db_prepare(&q,
"SELECT stashid, (SELECT uuid FROM blob WHERE rid=vid),"
" comment, datetime(ctime) FROM stash"
" ORDER BY ctime"
);
if( verboseFlag ){
db_prepare(&q2, "SELECT isAdded, isRemoved, origname, newname"
" FROM stashfile WHERE stashid=$id");
}
while( db_step(&q)==SQLITE_ROW ){
int stashid = db_column_int(&q, 0);
const char *zCom;
n++;
fossil_print("%5d: [%.14s] on %s\n",
stashid,
db_column_text(&q, 1),
db_column_text(&q, 3)
);
zCom = db_column_text(&q, 2);
if( zCom && zCom[0] ){
fossil_print(" ");
comment_print(zCom, 0, 7, width, g.comFmtFlags);
}
if( verboseFlag ){
db_bind_int(&q2, "$id", stashid);
while( db_step(&q2)==SQLITE_ROW ){
int isAdded = db_column_int(&q2, 0);
int isRemoved = db_column_int(&q2, 1);
const char *zOrig = db_column_text(&q2, 2);
|
| ︙ | ︙ |
Changes to src/stat.c.
| ︙ | ︙ | |||
135 136 137 138 139 140 141 |
@ <tr><th>SQLite Version:</th><td>%.19s(sqlite3_sourceid())
@ [%.10s(&sqlite3_sourceid()[20])] (%s(sqlite3_libversion()))</td></tr>
@ <tr><th>Repository Rebuilt:</th><td>
@ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
@ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
@ <tr><th>Database Stats:</th><td>
zDb = db_name("repository");
| | | | | | | < < | > > > > > | > > > > > > > > > > > | 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 |
@ <tr><th>SQLite Version:</th><td>%.19s(sqlite3_sourceid())
@ [%.10s(&sqlite3_sourceid()[20])] (%s(sqlite3_libversion()))</td></tr>
@ <tr><th>Repository Rebuilt:</th><td>
@ %h(db_get_mtime("rebuilt","%Y-%m-%d %H:%M:%S","Never"))
@ By Fossil %h(db_get("rebuilt","Unknown"))</td></tr>
@ <tr><th>Database Stats:</th><td>
zDb = db_name("repository");
@ %d(db_int(0, "PRAGMA \"%w\".page_count", zDb)) pages,
@ %d(db_int(0, "PRAGMA \"%w\".page_size", zDb)) bytes/page,
@ %d(db_int(0, "PRAGMA \"%w\".freelist_count", zDb)) free pages,
@ %s(db_text(0, "PRAGMA \"%w\".encoding", zDb)),
@ %s(db_text(0, "PRAGMA \"%w\".journal_mode", zDb)) mode
@ </td></tr>
@ </table>
style_footer();
}
/*
** COMMAND: dbstat*
**
** Usage: %fossil dbstat OPTIONS
**
** Shows statistics and global information about the repository.
**
** Options:
**
** --brief|-b Only show essential elements
** --db-check Run a PRAGMA quick_check on the repository database
** --omit-version-info Omit the SQLite and Fossil version information
*/
void dbstat_cmd(void){
i64 t, fsize;
int n, m;
int szMax, szAvg;
const char *zDb;
int brief;
int omitVers; /* Omit Fossil and SQLite version information */
int dbCheck; /* True for the --db-check option */
char zBuf[100];
const int colWidth = -19 /* printf alignment/width for left column */;
const char *p, *z;
brief = find_option("brief", "b",0)!=0;
omitVers = find_option("omit-version-info", 0, 0)!=0;
dbCheck = find_option("db-check",0,0)!=0;
db_find_and_open_repository(0,0);
/* We should be done with options.. */
verify_all_options();
if( (z = db_get("project-name",0))!=0
|| (z = db_get("short-project-name",0))!=0
){
fossil_print("%*s%s\n", colWidth, "project-name:", z);
}
fsize = file_size(g.zRepositoryName);
bigSizeName(sizeof(zBuf), zBuf, fsize);
fossil_print( "%*s%s\n", colWidth, "repository-size:", zBuf );
if( !brief ){
n = db_int(0, "SELECT count(*) FROM blob");
m = db_int(0, "SELECT count(*) FROM delta");
fossil_print("%*s%d (stored as %d full text and %d delta blobs)\n",
|
| ︙ | ︙ | |||
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
" WHERE tagname GLOB 'tkt-*'");
m = db_int(0, "SELECT COUNT(*) FROM event WHERE type='t'");
fossil_print("%*s%d (%d changes)\n", colWidth, "tickets:", n, m);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='e'");
fossil_print("%*s%d\n", colWidth, "events:", n);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='g'");
fossil_print("%*s%d\n", colWidth, "tagchanges:", n);
}
n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
" + 0.99");
fossil_print("%*s%d days or approximately %.2f years.\n",
colWidth, "project-age:", n, n/365.2425);
p = db_get("project-code", 0);
if( p ){
fossil_print("%*s%s\n", colWidth, "project-id:", p);
}
fossil_print("%*s%s\n", colWidth, "server-id:", db_get("server-code", 0));
| > > > > > > > > > | | | | | | | | > | | | | > > > | | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
" WHERE tagname GLOB 'tkt-*'");
m = db_int(0, "SELECT COUNT(*) FROM event WHERE type='t'");
fossil_print("%*s%d (%d changes)\n", colWidth, "tickets:", n, m);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='e'");
fossil_print("%*s%d\n", colWidth, "events:", n);
n = db_int(0, "SELECT COUNT(*) FROM event WHERE type='g'");
fossil_print("%*s%d\n", colWidth, "tagchanges:", n);
z = db_text(0, "SELECT datetime(mtime) || ' - about ' ||"
" CAST(julianday('now') - mtime AS INTEGER)"
" || ' days ago' FROM event "
" ORDER BY mtime DESC LIMIT 1");
fossil_print("%*s%s\n", colWidth, "latest-change:", z);
}
n = db_int(0, "SELECT julianday('now') - (SELECT min(mtime) FROM event)"
" + 0.99");
fossil_print("%*s%d days or approximately %.2f years.\n",
colWidth, "project-age:", n, n/365.2425);
p = db_get("project-code", 0);
if( p ){
fossil_print("%*s%s\n", colWidth, "project-id:", p);
}
#if 0
/* Server-id is not useful information any more */
fossil_print("%*s%s\n", colWidth, "server-id:", db_get("server-code", 0));
#endif
if( !omitVers ){
fossil_print("%*s%s %s [%s] (%s)\n",
colWidth, "fossil-version:",
MANIFEST_DATE, MANIFEST_VERSION, RELEASE_VERSION,
COMPILER_NAME);
fossil_print("%*s%.19s [%.10s] (%s)\n",
colWidth, "sqlite-version:",
sqlite3_sourceid(), &sqlite3_sourceid()[20],
sqlite3_libversion());
}
zDb = db_name("repository");
fossil_print("%*s%d pages, %d bytes/pg, %d free pages, "
"%s, %s mode\n",
colWidth, "database-stats:",
db_int(0, "PRAGMA \"%w\".page_count", zDb),
db_int(0, "PRAGMA \"%w\".page_size", zDb),
db_int(0, "PRAGMA \"%w\".freelist_count", zDb),
db_text(0, "PRAGMA \"%w\".encoding", zDb),
db_text(0, "PRAGMA \"%w\".journal_mode", zDb));
if( dbCheck ){
fossil_print("%*s%s\n", colWidth, "database-check:",
db_text(0, "PRAGMA quick_check(1)"));
}
}
/*
** WEBPAGE: urllist
**
** Show ways in which this repository has been accessed
*/
|
| ︙ | ︙ |
Changes to src/style.c.
| ︙ | ︙ | |||
173 174 175 176 177 178 179 |
@ gebi("a%d(i+1)").href="%s(aHref[i])";
}
}
for(i=0; i<nFormAction; i++){
@ gebi("form%d(i+1)").action="%s(aFormAction[i])";
}
@ }
| | > > > > | | | 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 |
@ gebi("a%d(i+1)").href="%s(aHref[i])";
}
}
for(i=0; i<nFormAction; i++){
@ gebi("form%d(i+1)").action="%s(aFormAction[i])";
}
@ }
if( sqlite3_strglob("*Opera Mini/[1-9]*", P("HTTP_USER_AGENT"))==0 ){
/* Special case for Opera Mini, which executes JS server-side */
@ var isOperaMini = Object.prototype.toString.call(window.operamini)
@ === "[object OperaMini]";
@ if( isOperaMini ){
@ setTimeout("setAllHrefs();",%d(nDelay));
@ }
}else if( db_get_boolean("auto-hyperlink-ishuman",0) && g.isHuman ){
/* Active hyperlinks after a delay */
@ setTimeout("setAllHrefs();",%d(nDelay));
}else if( db_get_boolean("auto-hyperlink-mouseover",0) ){
/* Require mouse movement before starting the teim that will
** activating hyperlinks */
@ document.getElementsByTagName("body")[0].onmousemove=function(){
@ setTimeout("setAllHrefs();",%d(nDelay));
@ this.onmousemove = null;
@ }
}else{
/* Active hyperlinks after a delay */
@ setTimeout("setAllHrefs();",%d(nDelay));
}
@ </script>
}
/*
** Add a new element to the submenu
|
| ︙ | ︙ | |||
386 387 388 389 390 391 392 |
}
@ </div>
}
style_ad_unit();
@ <div class="content">
cgi_destination(CGI_BODY);
| | | 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
}
@ </div>
}
style_ad_unit();
@ <div class="content">
cgi_destination(CGI_BODY);
if( sideboxUsed ){
/* Put the footer at the bottom of the page.
** the additional clear/both is needed to extend the content
** part to the end of an optional sidebox.
*/
@ <div class="endContent"></div>
}
@ </div>
|
| ︙ | ︙ | |||
655 656 657 658 659 660 661 |
/* The following table contains bits of default CSS that must
** be included if they are not found in the application-defined
** CSS.
*/
const struct strctCssDefaults {
| | | | | 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 |
/* The following table contains bits of default CSS that must
** be included if they are not found in the application-defined
** CSS.
*/
const struct strctCssDefaults {
const char *elementClass; /* Name of element needed */
const char *comment; /* Comment text */
const char *value; /* CSS text */
} cssDefaultList[] = {
{ "",
"",
zDefaultCSS
},
{ "div.sidebox",
"The nomenclature sidebox for branches,..",
|
| ︙ | ︙ | |||
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
@ text-align: right;
@ vertical-align: top;
@ white-space: nowrap;
},
{ "span.ueditInheritNobody",
"color for capabilities, inherited by nobody",
@ color: green;
},
{ "span.ueditInheritDeveloper",
"color for capabilities, inherited by developer",
@ color: red;
},
{ "span.ueditInheritReader",
"color for capabilities, inherited by reader",
@ color: black;
},
{ "span.ueditInheritAnonymous",
"color for capabilities, inherited by anonymous",
@ color: blue;
},
{ "span.capability",
"format for capabilities, mentioned on the user edit page",
@ font-weight: bold;
},
{ "span.usertype",
"format for different user types, mentioned on the user edit page",
| > > > > | 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 |
@ text-align: right;
@ vertical-align: top;
@ white-space: nowrap;
},
{ "span.ueditInheritNobody",
"color for capabilities, inherited by nobody",
@ color: green;
@ padding: .2em;
},
{ "span.ueditInheritDeveloper",
"color for capabilities, inherited by developer",
@ color: red;
@ padding: .2em;
},
{ "span.ueditInheritReader",
"color for capabilities, inherited by reader",
@ color: black;
@ padding: .2em;
},
{ "span.ueditInheritAnonymous",
"color for capabilities, inherited by anonymous",
@ color: blue;
@ padding: .2em;
},
{ "span.capability",
"format for capabilities, mentioned on the user edit page",
@ font-weight: bold;
},
{ "span.usertype",
"format for different user types, mentioned on the user edit page",
|
| ︙ | ︙ | |||
1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 |
{ "tr.row0",
"even table row color",
@ /* use default */
},
{ "tr.row1",
"odd table row color",
@ /* Use default */
},
{ "#canvas", "timeline graph node colors",
@ color: black;
@ background-color: white;
},
{ 0,
0,
0
}
};
/*
** Append all of the default CSS to the CGI output.
*/
void cgi_append_default_css(void) {
int i;
| > > > > | | | 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 |
{ "tr.row0",
"even table row color",
@ /* use default */
},
{ "tr.row1",
"odd table row color",
@ /* Use default */
},
{ "#usetupEditCapability",
"format for capabilities string, mentioned on the user edit page",
@ font-weight: bold;
},
{ "#canvas", "timeline graph node colors",
@ color: black;
@ background-color: white;
},
{ 0,
0,
0
}
};
/*
** Append all of the default CSS to the CGI output.
*/
void cgi_append_default_css(void) {
int i;
for( i=0; cssDefaultList[i].elementClass; i++ ){
if( cssDefaultList[i].elementClass[0] ){
cgi_printf("/* %s */\n%s {\n%s\n}\n\n",
cssDefaultList[i].comment,
cssDefaultList[i].elementClass,
cssDefaultList[i].value
);
}else{
cgi_printf("%s",
|
| ︙ | ︙ |
Changes to src/sync.c.
| ︙ | ︙ | |||
184 185 186 187 188 189 190 191 192 193 194 195 196 197 |
**
** See also: clone, push, sync, remote-url
*/
void pull_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PULL;
process_sync_args(&configFlags, &syncFlags);
client_sync(syncFlags, configFlags, 0);
}
/*
** COMMAND: push
**
** Usage: %fossil push ?URL? ?options?
| > > > > | 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
**
** See also: clone, push, sync, remote-url
*/
void pull_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PULL;
process_sync_args(&configFlags, &syncFlags);
/* We should be done with options.. */
verify_all_options();
client_sync(syncFlags, configFlags, 0);
}
/*
** COMMAND: push
**
** Usage: %fossil push ?URL? ?options?
|
| ︙ | ︙ | |||
215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
**
** See also: clone, pull, sync, remote-url
*/
void push_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH;
process_sync_args(&configFlags, &syncFlags);
if( db_get_boolean("dont-push",0) ){
fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
}
client_sync(syncFlags, 0, 0);
}
| > > > > | 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
**
** See also: clone, pull, sync, remote-url
*/
void push_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH;
process_sync_args(&configFlags, &syncFlags);
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ){
fossil_fatal("pushing is prohibited: the 'dont-push' option is set");
}
client_sync(syncFlags, 0, 0);
}
|
| ︙ | ︙ | |||
251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
**
** See also: clone, push, pull, remote-url
*/
void sync_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
process_sync_args(&configFlags, &syncFlags);
if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
client_sync(syncFlags, configFlags, 0);
if( (syncFlags & SYNC_PUSH)==0 ){
fossil_warning("pull only: the 'dont-push' option is set");
}
}
| > > > > | 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
**
** See also: clone, push, pull, remote-url
*/
void sync_cmd(void){
unsigned configFlags = 0;
unsigned syncFlags = SYNC_PUSH|SYNC_PULL;
process_sync_args(&configFlags, &syncFlags);
/* We should be done with options.. */
verify_all_options();
if( db_get_boolean("dont-push",0) ) syncFlags &= ~SYNC_PUSH;
client_sync(syncFlags, configFlags, 0);
if( (syncFlags & SYNC_PUSH)==0 ){
fossil_warning("pull only: the 'dont-push' option is set");
}
}
|
| ︙ | ︙ | |||
278 279 280 281 282 283 284 285 286 287 288 289 290 291 |
** See clone usage for possible URL formats.
**
** See also: clone, push, pull, sync
*/
void remote_url_cmd(void){
char *zUrl;
db_find_and_open_repository(0, 0);
if( g.argc!=2 && g.argc!=3 ){
usage("remote-url ?URL|off?");
}
if( g.argc==3 ){
db_unset("last-sync-url", 0);
db_unset("last-sync-pw", 0);
db_unset("http-auth", 0);
| > > > > | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 |
** See clone usage for possible URL formats.
**
** See also: clone, push, pull, sync
*/
void remote_url_cmd(void){
char *zUrl;
db_find_and_open_repository(0, 0);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=2 && g.argc!=3 ){
usage("remote-url ?URL|off?");
}
if( g.argc==3 ){
db_unset("last-sync-url", 0);
db_unset("last-sync-pw", 0);
db_unset("http-auth", 0);
|
| ︙ | ︙ |
Changes to src/tag.c.
| ︙ | ︙ | |||
48 49 50 51 52 53 54 | pqueuex_init(&queue); pqueuex_insert(&queue, pid, 0.0, 0); /* Query for children of :pid to which to propagate the tag. ** Three returns: (1) rid of the child. (2) timestamp of child. ** (3) True to propagate or false to block. */ | | | 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
pqueuex_init(&queue);
pqueuex_insert(&queue, pid, 0.0, 0);
/* Query for children of :pid to which to propagate the tag.
** Three returns: (1) rid of the child. (2) timestamp of child.
** (3) True to propagate or false to block.
*/
db_prepare(&s,
"SELECT cid, plink.mtime,"
" coalesce(srcid=0 AND tagxref.mtime<:mtime, %d) AS doit"
" FROM plink LEFT JOIN tagxref ON cid=rid AND tagid=%d"
" WHERE pid=:pid AND isprim",
tagType==2, tagid
);
db_bind_double(&s, ":mtime", mtime);
|
| ︙ | ︙ | |||
177 178 179 180 181 182 183 |
db_bind_double(&s, ":mtime", mtime);
rc = db_step(&s);
db_finalize(&s);
if( rc==SQLITE_ROW ){
/* Another entry that is more recent already exists. Do nothing */
return tagid;
}
| | | 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
db_bind_double(&s, ":mtime", mtime);
rc = db_step(&s);
db_finalize(&s);
if( rc==SQLITE_ROW ){
/* Another entry that is more recent already exists. Do nothing */
return tagid;
}
db_prepare(&s,
"REPLACE INTO tagxref(tagid,tagtype,srcId,origid,value,mtime,rid)"
" VALUES(%d,%d,%d,%d,%Q,:mtime,%d)",
tagid, tagtype, srcId, rid, zValue, rid
);
db_bind_double(&s, ":mtime", mtime);
db_step(&s);
db_finalize(&s);
|
| ︙ | ︙ | |||
211 212 213 214 215 216 217 |
db_multi_exec(
"INSERT OR IGNORE INTO private(rid) VALUES(%d);",
rid
);
}
}
if( zCol ){
| | > | 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 |
db_multi_exec(
"INSERT OR IGNORE INTO private(rid) VALUES(%d);",
rid
);
}
}
if( zCol ){
db_multi_exec("UPDATE event SET \"%w\"=%Q WHERE objid=%d",
zCol, zValue, rid);
if( tagid==TAG_COMMENT ){
char *zCopy = mprintf("%s", zValue);
wiki_extract_links(zCopy, rid, 0, mtime, 1, WIKI_INLINE);
free(zCopy);
}
}
if( tagid==TAG_DATE ){
|
| ︙ | ︙ | |||
254 255 256 257 258 259 260 |
usage("TAGNAME ARTIFACT-ID ?VALUE?");
}
zTag = g.argv[2];
switch( zTag[0] ){
case '+': tagtype = 1; break;
case '*': tagtype = 2; break;
case '-': tagtype = 0; break;
| | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
usage("TAGNAME ARTIFACT-ID ?VALUE?");
}
zTag = g.argv[2];
switch( zTag[0] ){
case '+': tagtype = 1; break;
case '*': tagtype = 2; break;
case '-': tagtype = 0; break;
default:
fossil_fatal("tag should begin with '+', '*', or '-'");
return;
}
rid = name_to_rid(g.argv[3]);
if( rid==0 ){
fossil_fatal("no such object: %s", g.argv[3]);
}
|
| ︙ | ︙ | |||
352 353 354 355 356 357 358 | ** ** %fossil tag find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME ** ** List all objects that use TAGNAME. TYPE can be "ci" for ** checkins or "e" for events. The limit option limits the number ** of results to the given value. ** | | | 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 | ** ** %fossil tag find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME ** ** List all objects that use TAGNAME. TYPE can be "ci" for ** checkins or "e" for events. The limit option limits the number ** of results to the given value. ** ** %fossil tag list|ls ?--raw? ?CHECK-IN? ** ** List all tags, or if CHECK-IN is supplied, list ** all tags and their values for CHECK-IN. ** ** The option --raw allows the manipulation of all types of tags ** used for various internal purposes in fossil. It also shows ** "cancel" tags for the "find" and "list" subcommands. You should |
| ︙ | ︙ | |||
376 377 378 379 380 381 382 | ** will be taken as an artifact or baseline ID and fossil will ** probably complain that no such revision was found. However ** ** fossil update tag:decaf ** ** will assume that "decaf" is a tag/branch name. ** | | | | | | 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
** will be taken as an artifact or baseline ID and fossil will
** probably complain that no such revision was found. However
**
** fossil update tag:decaf
**
** will assume that "decaf" is a tag/branch name.
**
** only allow --date-override and --user-override in
** %fossil tag add --date-override 'YYYY-MMM-DD HH:MM:SS' \\
** --user-override user
** in order to import history from other scm systems
*/
void tag_cmd(void){
int n;
int fRaw = find_option("raw","",0)!=0;
int fPropagate = find_option("propagate","",0)!=0;
const char *zPrefix = fRaw ? "" : "sym-";
const char *zFindLimit = find_option("limit","n",1);
const int nFindLimit = zFindLimit ? atoi(zFindLimit) : -2000;
db_find_and_open_repository(0, 0);
if( g.argc<3 ){
goto tag_cmd_usage;
}
n = strlen(g.argv[2]);
if( n==0 ){
|
| ︙ | ︙ | |||
435 436 437 438 439 440 441 |
const char *zType = find_option("type","t",1);
Blob sql = empty_blob;
if( zType==0 || zType[0]==0 ) zType = "*";
if( g.argc!=4 ){
usage("find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME");
}
if( fRaw ){
| | | | | | | | | 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
const char *zType = find_option("type","t",1);
Blob sql = empty_blob;
if( zType==0 || zType[0]==0 ) zType = "*";
if( g.argc!=4 ){
usage("find ?--raw? ?-t|--type TYPE? ?-n|--limit #? TAGNAME");
}
if( fRaw ){
blob_append_sql(&sql,
"SELECT blob.uuid FROM tagxref, blob"
" WHERE tagid=(SELECT tagid FROM tag WHERE tagname=%Q)"
" AND tagxref.tagtype>0"
" AND blob.rid=tagxref.rid",
g.argv[3]
);
if( nFindLimit>0 ){
blob_append_sql(&sql, " LIMIT %d", nFindLimit);
}
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%s\n", db_column_text(&q, 0));
}
db_finalize(&q);
}else{
int tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname='sym-%q'",
g.argv[3]);
if( tagid>0 ){
blob_append_sql(&sql,
"%s"
" AND event.type GLOB '%q'"
" AND blob.rid IN ("
" SELECT rid FROM tagxref"
" WHERE tagtype>0 AND tagid=%d"
")"
" ORDER BY event.mtime DESC",
timeline_query_for_tty(), zType, tagid
);
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
print_timeline(&q, nFindLimit, 79, 0);
db_finalize(&q);
}
}
}else
if(( strncmp(g.argv[2],"list",n)==0 )||( strncmp(g.argv[2],"ls",n)==0 )){
Stmt q;
if( g.argc==3 ){
db_prepare(&q,
"SELECT tagname FROM tag"
" WHERE EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=tag.tagid"
" AND tagtype>0)"
" ORDER BY tagname"
);
while( db_step(&q)==SQLITE_ROW ){
|
| ︙ | ︙ |
Changes to src/tar.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | ** ******************************************************************************* ** ** This file contains code used to generate tarballs. */ #include "config.h" #include <assert.h> | > > > > | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
**
*******************************************************************************
**
** This file contains code used to generate tarballs.
*/
#include "config.h"
#include <assert.h>
#if defined(FOSSIL_ENABLE_MINIZ)
# define MINIZ_HEADER_FILE_ONLY
# include "miniz.c"
#else
# include <zlib.h>
#endif
#include "tar.h"
/*
** State information for the tarball builder.
*/
static struct tarball_t {
unsigned char *aHdr; /* Space for building headers */
|
| ︙ | ︙ | |||
485 486 487 488 489 490 491 |
pManifest = manifest_get(rid, CFTYPE_MANIFEST, 0);
if( pManifest ){
mTime = (pManifest->rDate - 2440587.5)*86400.0;
tar_begin(mTime);
if( db_get_boolean("manifest", 0) ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
| < > > | 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 |
pManifest = manifest_get(rid, CFTYPE_MANIFEST, 0);
if( pManifest ){
mTime = (pManifest->rDate - 2440587.5)*86400.0;
tar_begin(mTime);
if( db_get_boolean("manifest", 0) ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
sha1sum_blob(&mfile, &hash);
sterilize_manifest(&mfile);
tar_add_file(zName, &mfile, 0, mTime);
blob_reset(&mfile);
blob_append(&hash, "\n", 1);
blob_resize(&filename, nPrefix);
blob_append(&filename, "manifest.uuid", -1);
zName = blob_str(&filename);
tar_add_file(zName, &hash, 0, mTime);
blob_reset(&hash);
|
| ︙ | ︙ | |||
524 525 526 527 528 529 530 | blob_reset(&filename); tar_finish(pTar); } /* ** COMMAND: tarball* ** | | > > > > > > > > | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 |
blob_reset(&filename);
tar_finish(pTar);
}
/*
** COMMAND: tarball*
**
** Usage: %fossil tarball VERSION OUTPUTFILE
**
** Generate a compressed tarball for a specified version. If the --name
** option is used, its argument becomes the name of the top-level directory
** in the resulting tarball. If --name is omitted, the top-level directory
** named is derived from the project name, the check-in date and time, and
** the artifact ID of the check-in.
**
** Options:
** --name DIRECTORYNAME The name of the top-level directory in the archive
** -R REPOSITORY Specify a Fossil repository
*/
void tarball_cmd(void){
int rid;
Blob tarball;
const char *zName;
zName = find_option("name", 0, 1);
db_find_and_open_repository(0, 0);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
rid = name_to_typed_rid(g.argv[2], "ci");
if( rid==0 ){
fossil_fatal("Checkin not found: %s", g.argv[2]);
return;
|
| ︙ | ︙ | |||
572 573 574 575 576 577 578 | ** URL: /tarball/RID.tar.gz ** ** Generate a compressed tarball for a checkin. ** Return that tarball as the HTTP reply content. ** ** Optional URL Parameters: ** | | | > > | | 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 |
** URL: /tarball/RID.tar.gz
**
** Generate a compressed tarball for a checkin.
** Return that tarball as the HTTP reply content.
**
** Optional URL Parameters:
**
** - name=NAME[.tar.gz] is base name of the output file. Defaults to
** something project/version-specific. The prefix of the name, up to
** the last '.', are used as the top-most directory name in the tar
** output.
**
** - uuid=the version to tar (may be a tag/branch name).
** Defaults to "trunk".
**
*/
void tarball_page(void){
int rid;
char *zName, *zRid, *zKey;
int nName, nRid;
Blob tarball;
|
| ︙ | ︙ | |||
612 613 614 615 616 617 618 |
}
rid = name_to_typed_rid(nRid?zRid:zName, "ci");
if( rid==0 ){
@ Not found
return;
}
if( nRid==0 && nName>10 ) zName[10] = 0;
| | > > > > > > > > > | 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
}
rid = name_to_typed_rid(nRid?zRid:zName, "ci");
if( rid==0 ){
@ Not found
return;
}
if( nRid==0 && nName>10 ) zName[10] = 0;
zKey = db_text(0, "SELECT '/tarball/'||uuid||'/%q'"
" FROM blob WHERE rid=%d",zName,rid);
if( P("debug")!=0 ){
style_header("Tarball Generator Debug Screen");
@ zName = "%h(zName)"<br>
@ rid = %d(rid)<br>
@ zKey = "%h(zKey)"
style_footer();
return;
}
blob_zero(&tarball);
if( cache_read(&tarball, zKey)==0 ){
tarball_of_checkin(rid, &tarball, zName);
cache_write(&tarball, zKey);
}
free( zName );
free( zRid );
free( zKey );
cgi_set_content(&tarball);
cgi_set_content_type("application/x-compressed");
}
|
Changes to src/th.c.
| ︙ | ︙ | |||
509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 |
case '[': if( nBrace==0 ) nSq++; break;
case ']': if( nBrace==0 ) nSq--; break;
}
iEnd++;
}
if( nBrace>0 || nSq>0 ){
/* Parse error */
return TH_ERROR;
}
}
if( iEnd>nInput ){
/* Parse error */
return TH_ERROR;
}
*pnWord = iEnd;
return TH_OK;
}
/*
| > > | 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
case '[': if( nBrace==0 ) nSq++; break;
case ']': if( nBrace==0 ) nSq--; break;
}
iEnd++;
}
if( nBrace>0 || nSq>0 ){
/* Parse error */
Th_SetResult(interp, "parse error", -1);
return TH_ERROR;
}
}
if( iEnd>nInput ){
/* Parse error */
Th_SetResult(interp, "parse error", -1);
return TH_ERROR;
}
*pnWord = iEnd;
return TH_OK;
}
/*
|
| ︙ | ︙ | |||
1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 |
/*
** These two types are used only by the expression module, where
** the expression module means the Th_Expr() and exprXXX() functions.
*/
typedef struct Operator Operator;
struct Operator {
const char *zOp;
int eOp;
int iPrecedence;
int eArgType;
};
typedef struct Expr Expr;
struct Expr {
Operator *pOp;
| > | 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 |
/*
** These two types are used only by the expression module, where
** the expression module means the Th_Expr() and exprXXX() functions.
*/
typedef struct Operator Operator;
struct Operator {
const char *zOp;
int nOp;
int eOp;
int iPrecedence;
int eArgType;
};
typedef struct Expr Expr;
struct Expr {
Operator *pOp;
|
| ︙ | ︙ | |||
1827 1828 1829 1830 1831 1832 1833 |
*/
#define ARG_INTEGER 1
#define ARG_NUMBER 2
#define ARG_STRING 3
static Operator aOperator[] = {
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 |
*/
#define ARG_INTEGER 1
#define ARG_NUMBER 2
#define ARG_STRING 3
static Operator aOperator[] = {
{"(", 1, OP_OPEN_BRACKET, -1, 0},
{")", 1, OP_CLOSE_BRACKET, -1, 0},
/* Note: all unary operators have (iPrecedence==1) */
{"-", 1, OP_UNARY_MINUS, 1, ARG_NUMBER},
{"+", 1, OP_UNARY_PLUS, 1, ARG_NUMBER},
{"~", 1, OP_BITWISE_NOT, 1, ARG_INTEGER},
{"!", 1, OP_LOGICAL_NOT, 1, ARG_INTEGER},
/* Binary operators. It is important to the parsing in Th_Expr() that
* the two-character symbols ("==") appear before the one-character
* ones ("="). And that the priorities of all binary operators are
* integers between 2 and 12.
*/
{"<<", 2, OP_LEFTSHIFT, 4, ARG_INTEGER},
{">>", 2, OP_RIGHTSHIFT, 4, ARG_INTEGER},
{"<=", 2, OP_LE, 5, ARG_NUMBER},
{">=", 2, OP_GE, 5, ARG_NUMBER},
{"==", 2, OP_EQ, 6, ARG_NUMBER},
{"!=", 2, OP_NE, 6, ARG_NUMBER},
{"eq", 2, OP_SEQ, 7, ARG_STRING},
{"ne", 2, OP_SNE, 7, ARG_STRING},
{"&&", 2, OP_LOGICAL_AND, 11, ARG_INTEGER},
{"||", 2, OP_LOGICAL_OR, 12, ARG_INTEGER},
{"*", 1, OP_MULTIPLY, 2, ARG_NUMBER},
{"/", 1, OP_DIVIDE, 2, ARG_NUMBER},
{"%", 1, OP_MODULUS, 2, ARG_INTEGER},
{"+", 1, OP_ADD, 3, ARG_NUMBER},
{"-", 1, OP_SUBTRACT, 3, ARG_NUMBER},
{"<", 1, OP_LT, 5, ARG_NUMBER},
{">", 1, OP_GT, 5, ARG_NUMBER},
{"&", 1, OP_BITWISE_AND, 8, ARG_INTEGER},
{"^", 1, OP_BITWISE_XOR, 9, ARG_INTEGER},
{"|", 1, OP_BITWISE_OR, 10, ARG_INTEGER},
{0,0,0,0,0}
};
/*
** The first part of the string (zInput,nInput) contains an integer.
** Set *pnVarname to the number of bytes in the numeric string.
*/
static int thNextInteger(
|
| ︙ | ︙ | |||
2119 2120 2121 2122 2123 2124 2125 |
}
}
}
iLeft = 0;
for(jj=nToken-1; jj>=0; jj--){
if( apToken[jj] ){
| | > < < | | 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 |
}
}
}
iLeft = 0;
for(jj=nToken-1; jj>=0; jj--){
if( apToken[jj] ){
if( apToken[jj]->pOp && apToken[jj]->pOp->iPrecedence==1
&& iLeft>0 && ISTERM(iLeft) ){
apToken[jj]->pLeft = apToken[iLeft];
apToken[jj]->pLeft->pParent = apToken[jj];
apToken[iLeft] = 0;
}
iLeft = jj;
}
}
for(i=2; i<=12; i++){
iLeft = -1;
for(jj=0; jj<nToken; jj++){
Expr *pToken = apToken[jj];
if( apToken[jj] ){
if( pToken->pOp && !pToken->pLeft && pToken->pOp->iPrecedence==i ){
int iRight = jj+1;
for(; !apToken[iRight] && iRight<nToken; iRight++);
if( iRight==nToken || iLeft<0 || !ISTERM(iRight) || !ISTERM(iLeft) ){
return TH_ERROR;
}
pToken->pLeft = apToken[iLeft];
apToken[iLeft] = 0;
pToken->pLeft->pParent = pToken;
pToken->pRight = apToken[iRight];
|
| ︙ | ︙ | |||
2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 |
int nExpr, /* Number of bytes at zExpr */
Expr ***papToken, /* OUT: Array of tokens. */
int *pnToken /* OUT: Size of token array */
){
int i;
int rc = TH_OK;
int nToken = 0;
Expr **apToken = 0;
for(i=0; rc==TH_OK && i<nExpr; ){
char c = zExpr[i];
if( th_isspace(c) ){ /* White-space */
i++;
| > | 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 |
int nExpr, /* Number of bytes at zExpr */
Expr ***papToken, /* OUT: Array of tokens. */
int *pnToken /* OUT: Size of token array */
){
int i;
int rc = TH_OK;
int nNest = 0;
int nToken = 0;
Expr **apToken = 0;
for(i=0; rc==TH_OK && i<nExpr; ){
char c = zExpr[i];
if( th_isspace(c) ){ /* White-space */
i++;
|
| ︙ | ︙ | |||
2219 2220 2221 2222 2223 2224 2225 |
pNew->nValue = iEnd+1-i;
}
break;
}
default: {
int j;
| > | | > > > > > > > > > | < | | 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 |
pNew->nValue = iEnd+1-i;
}
break;
}
default: {
int j;
const char *zOp;
for(j=0; (zOp=aOperator[j].zOp); j++){
int nOp = aOperator[j].nOp;
int isMatch = 0;
if( (nExpr-i)>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
isMatch = 1;
}
if( isMatch && aOperator[j].eOp==OP_OPEN_BRACKET ){
nNest++;
}else if( isMatch && aOperator[j].eOp==OP_CLOSE_BRACKET ){
nNest--;
}
if( nToken>0 && aOperator[j].iPrecedence==1 ){
Expr *pPrev = apToken[nToken-1];
if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
continue;
}
}
if( isMatch ){
pNew->pOp = &aOperator[j];
i += nOp;
break;
}
}
}
}
|
| ︙ | ︙ | |||
2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 |
nToken++;
}else{
Th_Free(interp, pNew);
rc = TH_ERROR;
}
}
}
*papToken = apToken;
*pnToken = nToken;
return rc;
}
/*
| > > > > | 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 |
nToken++;
}else{
Th_Free(interp, pNew);
rc = TH_ERROR;
}
}
}
if( nNest!=0 ){
rc = TH_ERROR;
}
*papToken = apToken;
*pnToken = nToken;
return rc;
}
/*
|
| ︙ | ︙ |
Changes to src/th.h.
| ︙ | ︙ | |||
164 165 166 167 168 169 170 | #ifdef FOSSIL_ENABLE_TCL /* ** Interfaces to the full Tcl core library from "th_tcl.c". */ int th_register_tcl(Th_Interp *, void *); int unloadTcl(Th_Interp *, void *); | | | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | #ifdef FOSSIL_ENABLE_TCL /* ** Interfaces to the full Tcl core library from "th_tcl.c". */ int th_register_tcl(Th_Interp *, void *); int unloadTcl(Th_Interp *, void *); int evaluateTclWithEvents(Th_Interp *, void *, const char *, int, int, int); #endif /* ** General purpose hash table from th_lang.c. */ typedef struct Th_Hash Th_Hash; typedef struct Th_HashEntry Th_HashEntry; |
| ︙ | ︙ |
Changes to src/th_main.c.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 | */ #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */ #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */ #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ #define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */ | > > > > | > | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | */ #define TH_INIT_NONE ((u32)0x00000000) /* No flags. */ #define TH_INIT_NEED_CONFIG ((u32)0x00000001) /* Open configuration first? */ #define TH_INIT_FORCE_TCL ((u32)0x00000002) /* Force Tcl to be enabled? */ #define TH_INIT_FORCE_RESET ((u32)0x00000004) /* Force TH1 commands re-added? */ #define TH_INIT_FORCE_SETUP ((u32)0x00000008) /* Force eval of setup script? */ #define TH_INIT_MASK ((u32)0x0000000F) /* All possible init flags. */ /* ** Useful and/or "well-known" combinations of flag values. */ #define TH_INIT_DEFAULT (TH_INIT_NONE) /* Default flags. */ #define TH_INIT_HOOK (TH_INIT_NEED_CONFIG | TH_INIT_FORCE_SETUP) #define TH_INIT_FORBID_MASK (TH_INIT_FORCE_TCL) /* Illegal from a script. */ #endif /* ** Flags set by functions in this file to keep track of integration state ** information. These flags should not be used outside of this file. */ #define TH_STATE_CONFIG ((u32)0x00000010) /* We opened the config. */ |
| ︙ | ︙ | |||
143 144 145 146 147 148 149 | /* ** TH1 command: httpize STRING ** ** Escape all characters of STRING which have special meaning in URI ** components. Return a new string result. */ static int httpizeCmd( | | | | | | 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
/*
** TH1 command: httpize STRING
**
** Escape all characters of STRING which have special meaning in URI
** components. Return a new string result.
*/
static int httpizeCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
char *zOut;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "httpize STRING");
}
zOut = httpize((char*)argv[1], argl[1]);
|
| ︙ | ︙ | |||
170 171 172 173 174 175 176 | /* ** TH1 command: enable_output BOOLEAN ** ** Enable or disable the puts and hputs commands. */ static int enableOutputCmd( | | | | | | > | | 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 |
/*
** TH1 command: enable_output BOOLEAN
**
** Enable or disable the puts and hputs commands.
*/
static int enableOutputCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc;
if( argc<2 || argc>3 ){
return Th_WrongNumArgs(interp, "enable_output [LABEL] BOOLEAN");
}
rc = Th_ToInt(interp, argv[argc-1], argl[argc-1], &enableOutput);
if( g.thTrace ){
Th_Trace("enable_output {%.*s} -> %d<br>\n", argl[1],argv[1],enableOutput);
}
return rc;
}
/*
** Returns a name for a TH1 return code.
*/
const char *Th_ReturnCodeName(int rc, int nullIfOk){
static char zRc[32];
switch( rc ){
case TH_OK: return nullIfOk ? 0 : "TH_OK";
case TH_ERROR: return "TH_ERROR";
case TH_BREAK: return "TH_BREAK";
case TH_RETURN: return "TH_RETURN";
case TH_CONTINUE: return "TH_CONTINUE";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "TH1 return code %d", rc);
}
}
return zRc;
}
/*
** Send text to the appropriate output: Either to the console
|
| ︙ | ︙ | |||
243 244 245 246 247 248 249 | enableOutput = savedEnable; } /* ** TH1 command: puts STRING ** TH1 command: html STRING ** | | | | | | | | | | | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
enableOutput = savedEnable;
}
/*
** TH1 command: puts STRING
** TH1 command: html STRING
**
** Output STRING escaped for HTML (html) or unchanged (puts).
*/
static int putsCmd(
Th_Interp *interp,
void *pConvert,
int argc,
const char **argv,
int *argl
){
if( argc!=2 ){
return Th_WrongNumArgs(interp, "puts STRING");
}
sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
return TH_OK;
}
/*
** TH1 command: wiki STRING
**
** Render the input string as wiki.
*/
static int wikiCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int flags = WIKI_INLINE | WIKI_NOBADLINKS | *(unsigned int*)p;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "wiki STRING");
}
if( enableOutput ){
|
| ︙ | ︙ | |||
291 292 293 294 295 296 297 | /* ** TH1 command: htmlize STRING ** ** Escape all characters of STRING which have special meaning in HTML. ** Return a new string result. */ static int htmlizeCmd( | | | | | | | | | | | | | | 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 |
/*
** TH1 command: htmlize STRING
**
** Escape all characters of STRING which have special meaning in HTML.
** Return a new string result.
*/
static int htmlizeCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
char *zOut;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "htmlize STRING");
}
zOut = htmlize((char*)argv[1], argl[1]);
Th_SetResult(interp, zOut, -1);
free(zOut);
return TH_OK;
}
/*
** TH1 command: date
**
** Return a string which is the current time and date. If the
** -local option is used, the date appears using localtime instead
** of UTC.
*/
static int dateCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
char *zOut;
if( argc>=2 && argl[1]==6 && memcmp(argv[1],"-local",6)==0 ){
zOut = db_text("??", "SELECT datetime('now'%s)", timeline_utc());
}else{
zOut = db_text("??", "SELECT datetime('now')");
}
Th_SetResult(interp, zOut, -1);
free(zOut);
return TH_OK;
}
/*
** TH1 command: hascap STRING...
**
** Return true if the user has all of the capabilities listed in STRING.
*/
static int hascapCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc = 0, i;
if( argc<2 ){
return Th_WrongNumArgs(interp, "hascap STRING ...");
}
for(i=1; i<argc && rc==0; i++){
|
| ︙ | ︙ | |||
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 | /* ** TH1 command: hasfeature STRING ** ** Return true if the fossil binary has the given compile-time feature ** enabled. The set of features includes: ** ** "ssl" = FOSSIL_ENABLE_SSL ** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS ** "tcl" = FOSSIL_ENABLE_TCL ** "useTclStubs" = USE_TCL_STUBS ** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS ** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS ** "json" = FOSSIL_ENABLE_JSON ** "markdown" = FOSSIL_ENABLE_MARKDOWN ** */ static int hasfeatureCmd( | > | | | | > > > > > | 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 |
/*
** TH1 command: hasfeature STRING
**
** Return true if the fossil binary has the given compile-time feature
** enabled. The set of features includes:
**
** "ssl" = FOSSIL_ENABLE_SSL
** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS
** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS
** "tcl" = FOSSIL_ENABLE_TCL
** "useTclStubs" = USE_TCL_STUBS
** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS
** "tclPrivateStubs" = FOSSIL_ENABLE_TCL_PRIVATE_STUBS
** "json" = FOSSIL_ENABLE_JSON
** "markdown" = FOSSIL_ENABLE_MARKDOWN
**
*/
static int hasfeatureCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc = 0;
char const * zArg;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "hasfeature STRING");
}
zArg = (char const*)argv[1];
if(NULL==zArg){
/* placeholder for following ifdefs... */
}
#if defined(FOSSIL_ENABLE_SSL)
else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
rc = 1;
}
#endif
#if defined(FOSSIL_ENABLE_TH1_DOCS)
else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){
rc = 1;
}
#endif
#if defined(FOSSIL_ENABLE_TH1_HOOKS)
else if( 0 == fossil_strnicmp( zArg, "th1Hooks\0", 9 ) ){
rc = 1;
}
#endif
#if defined(FOSSIL_ENABLE_TCL)
|
| ︙ | ︙ | |||
473 474 475 476 477 478 479 | /* ** TH1 command: anycap STRING ** ** Return true if the user has any one of the capabilities listed in STRING. */ static int anycapCmd( | | | | | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 |
/*
** TH1 command: anycap STRING
**
** Return true if the user has any one of the capabilities listed in STRING.
*/
static int anycapCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int rc = 0;
int i;
if( argc!=2 ){
return Th_WrongNumArgs(interp, "anycap STRING");
}
|
| ︙ | ︙ | |||
506 507 508 509 510 511 512 | ** currently selected value. TEXT-LIST is a list of possible ** values for the combobox. NUMLINES is 1 for a true combobox. ** If NUMLINES is greater than one then the display is a listbox ** with the number of lines given. */ static int comboboxCmd( Th_Interp *interp, | | | | | 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 |
** currently selected value. TEXT-LIST is a list of possible
** values for the combobox. NUMLINES is 1 for a true combobox.
** If NUMLINES is greater than one then the display is a listbox
** with the number of lines given.
*/
static int comboboxCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
if( argc!=4 ){
return Th_WrongNumArgs(interp, "combobox NAME TEXT-LIST NUMLINES");
}
if( enableOutput ){
int height;
|
| ︙ | ︙ | |||
537 538 539 540 541 542 543 |
z = mprintf("<select id=\"%s\" name=\"%s\" size=\"%d\">", zH, zH, height);
free(zH);
sendText(z, -1, 0);
free(z);
blob_reset(&name);
for(i=0; i<nElem; i++){
zH = htmlize((char*)azElem[i], aszElem[i]);
| | | 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 |
z = mprintf("<select id=\"%s\" name=\"%s\" size=\"%d\">", zH, zH, height);
free(zH);
sendText(z, -1, 0);
free(z);
blob_reset(&name);
for(i=0; i<nElem; i++){
zH = htmlize((char*)azElem[i], aszElem[i]);
if( zValue && aszElem[i]==nValue
&& memcmp(zValue, azElem[i], nValue)==0 ){
z = mprintf("<option value=\"%s\" selected=\"selected\">%s</option>",
zH, zH);
}else{
z = mprintf("<option value=\"%s\">%s</option>", zH, zH);
}
free(zH);
|
| ︙ | ︙ | |||
562 563 564 565 566 567 568 | ** TH1 command: linecount STRING MAX MIN ** ** Return one more than the number of \n characters in STRING. But ** never return less than MIN or more than MAX. */ static int linecntCmd( Th_Interp *interp, | | | | | 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 |
** TH1 command: linecount STRING MAX MIN
**
** Return one more than the number of \n characters in STRING. But
** never return less than MIN or more than MAX.
*/
static int linecntCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
const char *z;
int size, n, i;
int iMin, iMax;
if( argc!=4 ){
return Th_WrongNumArgs(interp, "linecount STRING MAX MIN");
|
| ︙ | ︙ | |||
598 599 600 601 602 603 604 | ** ** Return the fully qualified file name of the open repository or an empty ** string if one is not currently open. Optionally, it will attempt to open ** the repository if the boolean argument is non-zero. */ static int repositoryCmd( Th_Interp *interp, | | | | | 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 |
**
** Return the fully qualified file name of the open repository or an empty
** string if one is not currently open. Optionally, it will attempt to open
** the repository if the boolean argument is non-zero.
*/
static int repositoryCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "repository ?BOOLEAN?");
}
if( argc==2 ){
int openRepository = 0;
|
| ︙ | ︙ | |||
667 668 669 670 671 672 673 674 675 676 677 678 679 680 |
}
if( g.thTrace ){
Th_Trace("%s", argv[1]);
}
Th_SetResult(interp, 0, 0);
return TH_OK;
}
/*
** TH1 command: getParameter NAME ?DEFAULT?
**
** Return the value of the specified query parameter or the specified default
** value when there is no matching query parameter.
*/
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 |
}
if( g.thTrace ){
Th_Trace("%s", argv[1]);
}
Th_SetResult(interp, 0, 0);
return TH_OK;
}
/*
** TH1 command: globalState NAME ?DEFAULT?
**
** Returns a string containing the value of the specified global state
** variable -OR- the specified default value. Currently, the supported
** items are:
**
** "checkout" = The active local checkout directory, if any.
** "configuration" = The active configuration database file name,
** if any.
** "executable" = The fully qualified executable file name.
** "flags" = The TH1 initialization flags.
** "log" = The error log file name, if any.
** "repository" = The active local repository file name, if
** any.
** "top" = The base path for the active server instance,
** if applicable.
** "user" = The active user name, if any.
** "vfs" = The SQLite VFS in use, if overridden.
**
** Attempts to query for unsupported global state variables will result
** in a script error. Additional global state variables may be exposed
** in the future.
**
** See also: checkout, repository, setting
*/
static int globalStateCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
const char *zDefault = 0;
if( argc!=2 && argc!=3 ){
return Th_WrongNumArgs(interp, "globalState NAME ?DEFAULT?");
}
if( argc==3 ){
zDefault = argv[2];
}
if( fossil_strnicmp(argv[1], "checkout\0", 9)==0 ){
Th_SetResult(interp, g.zLocalRoot ? g.zLocalRoot : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "configuration\0", 14)==0 ){
Th_SetResult(interp, g.zConfigDbName ? g.zConfigDbName : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "executable\0", 11)==0 ){
Th_SetResult(interp, g.nameOfExe ? g.nameOfExe : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "flags\0", 6)==0 ){
Th_SetResultInt(interp, g.th1Flags);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "log\0", 4)==0 ){
Th_SetResult(interp, g.zErrlog ? g.zErrlog : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "repository\0", 11)==0 ){
Th_SetResult(interp, g.zRepositoryName ? g.zRepositoryName : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "top\0", 4)==0 ){
Th_SetResult(interp, g.zTop ? g.zTop : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "user\0", 5)==0 ){
Th_SetResult(interp, g.zLogin ? g.zLogin : zDefault, -1);
return TH_OK;
}else if( fossil_strnicmp(argv[1], "vfs\0", 4)==0 ){
Th_SetResult(interp, g.zVfsName ? g.zVfsName : zDefault, -1);
return TH_OK;
}else{
Th_ErrorMessage(interp, "unsupported global state:", argv[1], argl[1]);
return TH_ERROR;
}
}
/*
** TH1 command: getParameter NAME ?DEFAULT?
**
** Return the value of the specified query parameter or the specified default
** value when there is no matching query parameter.
*/
|
| ︙ | ︙ | |||
710 711 712 713 714 715 716 717 718 719 720 721 722 723 |
){
if( argc!=3 ){
return Th_WrongNumArgs(interp, "setParameter NAME VALUE");
}
cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2]));
return TH_OK;
}
/*
** TH1 command: render STRING
**
** Renders the template and writes the results.
*/
static int renderCmd(
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
){
if( argc!=3 ){
return Th_WrongNumArgs(interp, "setParameter NAME VALUE");
}
cgi_replace_parameter(mprintf("%s", argv[1]), mprintf("%s", argv[2]));
return TH_OK;
}
/*
** TH1 command: reinitialize ?FLAGS?
**
** Reinitializes the TH1 interpreter using the specified flags.
*/
static int reinitializeCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
u32 flags = TH_INIT_DEFAULT;
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "reinitialize ?FLAGS?");
}
if( argc==2 ){
int iFlags;
if( Th_ToInt(interp, argv[1], argl[1], &iFlags) ){
return TH_ERROR;
}else{
flags = (u32)iFlags;
}
}
Th_FossilInit(flags & ~TH_INIT_FORBID_MASK);
Th_SetResult(interp, 0, 0);
return TH_OK;
}
/*
** TH1 command: render STRING
**
** Renders the template and writes the results.
*/
static int renderCmd(
|
| ︙ | ︙ | |||
853 854 855 856 857 858 859 |
#else
struct rusage s;
getrusage(RUSAGE_SELF, &s);
if( piUser ){
*piUser = ((sqlite3_uint64)s.ru_utime.tv_sec)*1000000 + s.ru_utime.tv_usec;
}
if( piKernel ){
| | | | | | | | | | | | | 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 |
#else
struct rusage s;
getrusage(RUSAGE_SELF, &s);
if( piUser ){
*piUser = ((sqlite3_uint64)s.ru_utime.tv_sec)*1000000 + s.ru_utime.tv_usec;
}
if( piKernel ){
*piKernel =
((sqlite3_uint64)s.ru_stime.tv_sec)*1000000 + s.ru_stime.tv_usec;
}
#endif
}
/*
** TH1 command: utime
**
** Return the number of microseconds of CPU time consumed by the current
** process in user space.
*/
static int utimeCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
sqlite3_uint64 x;
char zUTime[50];
getCpuTimes(&x, 0);
sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x);
Th_SetResult(interp, zUTime, -1);
return TH_OK;
}
/*
** TH1 command: stime
**
** Return the number of microseconds of CPU time consumed by the current
** process in system space.
*/
static int stimeCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
sqlite3_uint64 x;
char zUTime[50];
getCpuTimes(0, &x);
sqlite3_snprintf(sizeof(zUTime), zUTime, "%llu", x);
Th_SetResult(interp, zUTime, -1);
return TH_OK;
}
/*
** TH1 command: randhex N
**
** Return N*2 random hexadecimal digits with N<50. If N is omitted,
** use a value of 10.
*/
static int randhexCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
int n;
unsigned char aRand[50];
unsigned char zOut[100];
if( argc!=1 && argc!=2 ){
return Th_WrongNumArgs(interp, "repository ?BOOLEAN?");
|
| ︙ | ︙ | |||
948 949 950 951 952 953 954 | ** ** In SQL, parameters such as $var are filled in using the value of variable ** "var". Result values are stored in variables with the column name prior ** to each invocation of CODE. */ static int queryCmd( Th_Interp *interp, | | | | | 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 |
**
** In SQL, parameters such as $var are filled in using the value of variable
** "var". Result values are stored in variables with the column name prior
** to each invocation of CODE.
*/
static int queryCmd(
Th_Interp *interp,
void *p,
int argc,
const char **argv,
int *argl
){
sqlite3_stmt *pStmt;
int rc;
const char *zSql;
int nSql;
const char *zTail;
|
| ︙ | ︙ | |||
1014 1015 1016 1017 1018 1019 1020 |
if( res==TH_BREAK || res==TH_CONTINUE ) res = TH_OK;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ){
Th_ErrorMessage(interp, "SQL error: ", sqlite3_errmsg(g.db), -1);
return TH_ERROR;
}
| | | 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 |
if( res==TH_BREAK || res==TH_CONTINUE ) res = TH_OK;
}
rc = sqlite3_finalize(pStmt);
if( rc!=SQLITE_OK ){
Th_ErrorMessage(interp, "SQL error: ", sqlite3_errmsg(g.db), -1);
return TH_ERROR;
}
}
return res;
}
/*
** TH1 command: setting name
**
** Gets and returns the value of the specified Fossil setting.
|
| ︙ | ︙ | |||
1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 |
{"artifact", artifactCmd, 0},
{"checkout", checkoutCmd, 0},
{"combobox", comboboxCmd, 0},
{"date", dateCmd, 0},
{"decorate", wikiCmd, (void*)&aFlags[2]},
{"enable_output", enableOutputCmd, 0},
{"getParameter", getParameterCmd, 0},
{"httpize", httpizeCmd, 0},
{"hascap", hascapCmd, 0},
{"hasfeature", hasfeatureCmd, 0},
{"html", putsCmd, (void*)&aFlags[0]},
{"htmlize", htmlizeCmd, 0},
{"http", httpCmd, 0},
{"linecount", linecntCmd, 0},
{"puts", putsCmd, (void*)&aFlags[1]},
{"query", queryCmd, 0},
{"randhex", randhexCmd, 0},
{"regexp", regexpCmd, 0},
{"render", renderCmd, 0},
{"repository", repositoryCmd, 0},
{"setParameter", setParameterCmd, 0},
{"setting", settingCmd, 0},
{"styleHeader", styleHeaderCmd, 0},
{"styleFooter", styleFooterCmd, 0},
{"tclReady", tclReadyCmd, 0},
{"trace", traceCmd, 0},
{"stime", stimeCmd, 0},
{"utime", utimeCmd, 0},
{"wiki", wikiCmd, (void*)&aFlags[0]},
{0, 0, 0}
};
if( needConfig ){
/*
** This function uses several settings which may be defined in the
** repository and/or the global configuration. Since the caller
** passed a non-zero value for the needConfig parameter, make sure
** the necessary database connections are open prior to continuing.
*/
| > > > > > | 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 |
{"artifact", artifactCmd, 0},
{"checkout", checkoutCmd, 0},
{"combobox", comboboxCmd, 0},
{"date", dateCmd, 0},
{"decorate", wikiCmd, (void*)&aFlags[2]},
{"enable_output", enableOutputCmd, 0},
{"getParameter", getParameterCmd, 0},
{"globalState", globalStateCmd, 0},
{"httpize", httpizeCmd, 0},
{"hascap", hascapCmd, 0},
{"hasfeature", hasfeatureCmd, 0},
{"html", putsCmd, (void*)&aFlags[0]},
{"htmlize", htmlizeCmd, 0},
{"http", httpCmd, 0},
{"linecount", linecntCmd, 0},
{"puts", putsCmd, (void*)&aFlags[1]},
{"query", queryCmd, 0},
{"randhex", randhexCmd, 0},
{"regexp", regexpCmd, 0},
{"reinitialize", reinitializeCmd, 0},
{"render", renderCmd, 0},
{"repository", repositoryCmd, 0},
{"setParameter", setParameterCmd, 0},
{"setting", settingCmd, 0},
{"styleHeader", styleHeaderCmd, 0},
{"styleFooter", styleFooterCmd, 0},
{"tclReady", tclReadyCmd, 0},
{"trace", traceCmd, 0},
{"stime", stimeCmd, 0},
{"utime", utimeCmd, 0},
{"wiki", wikiCmd, (void*)&aFlags[0]},
{0, 0, 0}
};
if( g.thTrace ){
Th_Trace("th1-init 0x%x => 0x%x<br />\n", g.th1Flags, flags);
}
if( needConfig ){
/*
** This function uses several settings which may be defined in the
** repository and/or the global configuration. Since the caller
** passed a non-zero value for the needConfig parameter, make sure
** the necessary database connections are open prior to continuing.
*/
|
| ︙ | ︙ | |||
1384 1385 1386 1387 1388 1389 1390 |
Th_Trace("set %h {%h}<br />\n", zName, zValue);
}
Th_SetVar(g.interp, zName, -1, zValue, strlen(zValue));
}
}
/*
| > > > > > > > > > > > > > > > > > | > > > | 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 |
Th_Trace("set %h {%h}<br />\n", zName, zValue);
}
Th_SetVar(g.interp, zName, -1, zValue, strlen(zValue));
}
}
/*
** Appends an element to a TH1 list value. This function is called by the
** transfer subsystem; therefore, it must be very careful to avoid doing
** any unnecessary work. To that end, the TH1 subsystem will not be called
** or initialized if the list pointer is zero (i.e. which will be the case
** when TH1 transfer hooks are disabled).
*/
void Th_AppendToList(
char **pzList,
int *pnList,
const char *zElem,
int nElem
){
if( pzList && zElem ){
Th_FossilInit(TH_INIT_DEFAULT);
Th_ListAppend(g.interp, pzList, pnList, zElem, nElem);
}
}
/*
** Stores a list value in the specified TH1 variable using the specified
** array of strings as the source of the element values.
*/
void Th_StoreList(
const char *zName,
char **pzList,
int nList
){
Th_FossilInit(TH_INIT_DEFAULT);
|
| ︙ | ︙ | |||
1689 1690 1691 1692 1693 1694 1695 | if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1); return rc; } #endif /* ** The z[] input contains text mixed with TH1 scripts. | | | 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 | if( TH_INIT_HOOK & TH_INIT_NEED_CONFIG ) Th_CloseConfig(1); return rc; } #endif /* ** The z[] input contains text mixed with TH1 scripts. ** The TH1 scripts are contained within <th1>...</th1>. ** TH1 variables are $aaa or $<aaa>. The first form of ** variable is literal. The second is run through htmlize ** before being inserted. ** ** This routine processes the template and writes the results ** on either stdout or into CGI. */ |
| ︙ | ︙ |
Changes to src/th_tcl.c.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ** ** This file contains code used to bridge the TH1 and Tcl scripting languages. */ #include "config.h" #ifdef FOSSIL_ENABLE_TCL #include "th.h" #include "tcl.h" /* ** These macros are designed to reduce the redundant code required to marshal ** arguments from TH1 to Tcl. */ | > | 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | ** ** This file contains code used to bridge the TH1 and Tcl scripting languages. */ #include "config.h" #ifdef FOSSIL_ENABLE_TCL #include "sqlite3.h" #include "th.h" #include "tcl.h" /* ** These macros are designed to reduce the redundant code required to marshal ** arguments from TH1 to Tcl. */ |
| ︙ | ︙ | |||
163 164 165 166 167 168 169 | */ #if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS) /* ** HACK: Using some preprocessor magic and a private static variable, redirect ** the Tcl API calls [found within this file] to the function pointers ** that will be contained in our private Tcl stubs table. This takes ** advantage of the fact that the Tcl headers always define the Tcl API | | > | 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | */ #if defined(FOSSIL_ENABLE_TCL_PRIVATE_STUBS) /* ** HACK: Using some preprocessor magic and a private static variable, redirect ** the Tcl API calls [found within this file] to the function pointers ** that will be contained in our private Tcl stubs table. This takes ** advantage of the fact that the Tcl headers always define the Tcl API ** functions in terms of the "tclStubsPtr" variable when the define ** USE_TCL_STUBS is present during compilation. */ #define tclStubsPtr privateTclStubsPtr static const TclStubs *tclStubsPtr = NULL; /* ** Create a Tcl interpreter structure that mirrors just enough fields to get ** it up and running successfully with our private implementation of the Tcl |
| ︙ | ︙ | |||
246 247 248 249 250 251 252 253 254 255 256 257 258 259 | /* ** Creates and initializes a Tcl interpreter for use with the specified TH1 ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied ** by the caller. This must be declared here because quite a few functions in ** this file need to use it before it can be defined. */ static int createTclInterp(Th_Interp *interp, void *pContext); /* ** Returns the Tcl interpreter result as a string with the associated length. ** If the Tcl interpreter or the Tcl result are NULL, the length will be 0. ** If the length pointer is NULL, the length will not be stored. */ static char *getTclResult( | > > > > > > > > > > > > > > > > > > > > > > | 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
/*
** Creates and initializes a Tcl interpreter for use with the specified TH1
** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
** by the caller. This must be declared here because quite a few functions in
** this file need to use it before it can be defined.
*/
static int createTclInterp(Th_Interp *interp, void *pContext);
/*
** Returns a name for a Tcl return code.
*/
static const char *getTclReturnCodeName(
int rc,
int nullIfOk
){
static char zRc[32];
switch( rc ){
case TCL_OK: return nullIfOk ? 0 : "TCL_OK";
case TCL_ERROR: return "TCL_ERROR";
case TCL_BREAK: return "TCL_BREAK";
case TCL_RETURN: return "TCL_RETURN";
case TCL_CONTINUE: return "TCL_CONTINUE";
default: {
sqlite3_snprintf(sizeof(zRc), zRc, "Tcl return code %d", rc);
}
}
return zRc;
}
/*
** Returns the Tcl interpreter result as a string with the associated length.
** If the Tcl interpreter or the Tcl result are NULL, the length will be 0.
** If the length pointer is NULL, the length will not be stored.
*/
static char *getTclResult(
|
| ︙ | ︙ | |||
772 773 774 775 776 777 778 779 780 781 782 783 | /* ** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the ** Tcl script succeeds, start a Tcl event loop until there are no more events ** remaining to process -OR- the script calls [exit]. If the bWait argument ** is zero, only process events that are already in the queue; otherwise, ** process events until the script terminates the Tcl event loop. */ int evaluateTclWithEvents( Th_Interp *interp, void *pContext, const char *zScript, int nScript, | > > | > | > > > > > > > | 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 |
/*
** Evaluate a Tcl script, creating the Tcl interpreter if necessary. If the
** Tcl script succeeds, start a Tcl event loop until there are no more events
** remaining to process -OR- the script calls [exit]. If the bWait argument
** is zero, only process events that are already in the queue; otherwise,
** process events until the script terminates the Tcl event loop.
*/
void fossil_print(const char *zFormat, ...); /* printf.h */
int evaluateTclWithEvents(
Th_Interp *interp,
void *pContext,
const char *zScript,
int nScript,
int bWait,
int bVerbose
){
struct TclContext *tclContext = (struct TclContext *)pContext;
Tcl_Interp *tclInterp;
int rc;
int flags = TCL_ALL_EVENTS;
if( createTclInterp(interp, pContext)!=TH_OK ){
return TH_ERROR;
}
tclInterp = tclContext->interp;
rc = Tcl_EvalEx(tclInterp, zScript, nScript, TCL_EVAL_GLOBAL);
if( rc!=TCL_OK ){
if( bVerbose ){
const char *zResult = getTclResult(tclInterp, 0);
fossil_print("%s: ", getTclReturnCodeName(rc, 0));
fossil_print("%s\n", zResult);
}
return rc;
}
if( !bWait ) flags |= TCL_DONT_WAIT;
while( Tcl_DoOneEvent(flags) ){
/* do nothing */
}
return rc;
}
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
210 211 212 213 214 215 216 | GraphContext *pGraph = 0; int prevWasDivider = 0; /* True if previous output row was <hr> */ int fchngQueryInit = 0; /* True if fchngQuery is initialized */ Stmt fchngQuery; /* Query for file changes on check-ins */ static Stmt qbranch; int pendingEndTr = 0; /* True if a </td></tr> is needed */ int vid = 0; /* Current checkout version */ | | < | > > | 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 |
GraphContext *pGraph = 0;
int prevWasDivider = 0; /* True if previous output row was <hr> */
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
Stmt fchngQuery; /* Query for file changes on check-ins */
static Stmt qbranch;
int pendingEndTr = 0; /* True if a </td></tr> is needed */
int vid = 0; /* Current checkout version */
int dateFormat = 0; /* 0: HH:MM (default) */
char *zDateFmt;
if( fossil_strcmp(g.zIpAddr, "127.0.0.1")==0 && db_open_local(0) ){
vid = db_lget_int("checkout", 0);
}
zPrevDate[0] = 0;
mxWikiLen = db_get_int("timeline-max-comment", 0);
dateFormat = db_get_int("timeline-date-format", 0);
zDateFmt = P("datefmt");
if( zDateFmt ) dateFormat = atoi(zDateFmt);
if( tmFlags & TIMELINE_GRAPH ){
pGraph = graph_init();
/* style is not moved to css, because this is
** a technical div for the timeline graph
*/
@ <div id="canvas" style="position:relative;height:0px;width:0px;"
@ onclick="clickOnGraph(event)"></div>
|
| ︙ | ︙ | |||
252 253 254 255 256 257 258 |
int tagid = db_column_int(pQuery, 9);
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
const char *zBr = 0; /* Branch */
int commentColumn = 3; /* Column containing comment text */
int modPending; /* Pending moderation */
char zTime[20];
| > | > | 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
int tagid = db_column_int(pQuery, 9);
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
const char *zBr = 0; /* Branch */
int commentColumn = 3; /* Column containing comment text */
int modPending; /* Pending moderation */
char zTime[20];
if( zDate==0 ){
zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
}
modPending = moderation_pending(rid);
if( tagid ){
if( modPending ) tagid = -tagid;
if( tagid==prevTagid ){
if( tmFlags & TIMELINE_BRIEF ){
suppressCnt++;
continue;
|
| ︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
if( !prevWasDivider ){
@ <tr><td colspan="3"><hr /></td></tr>
}
prevWasDivider = 1;
continue;
}
prevWasDivider = 0;
if( dateFormat<2 ){
if( fossil_strnicmp(zDate, zPrevDate, 10) ){
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
@ <tr><td>
@ <div class="divider timelineDate">%s(zPrevDate)</div>
@ </td><td></td><td></td></tr>
}
memcpy(zTime, &zDate[11], 5+dateFormat*3);
zTime[5+dateFormat*3] = 0;
| > > > > > > > > > > | < | | 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
if( !prevWasDivider ){
@ <tr><td colspan="3"><hr /></td></tr>
}
prevWasDivider = 1;
continue;
}
prevWasDivider = 0;
/* Date format codes:
** (0) HH:MM
** (1) HH:MM:SS
** (2) YYYY-MM-DD HH:MM
** (3) YYMMDD HH:MM
** (4) (off)
*/
if( dateFormat<2 ){
if( fossil_strnicmp(zDate, zPrevDate, 10) ){
sqlite3_snprintf(sizeof(zPrevDate), zPrevDate, "%.10s", zDate);
@ <tr><td>
@ <div class="divider timelineDate">%s(zPrevDate)</div>
@ </td><td></td><td></td></tr>
}
memcpy(zTime, &zDate[11], 5+dateFormat*3);
zTime[5+dateFormat*3] = 0;
}else if( 2==dateFormat ){
/* YYYY-MM-DD HH:MM */
sqlite3_snprintf(sizeof(zTime), zTime, "%.16s", zDate);
}else if( 3==dateFormat ){
/* YYMMDD HH:MM */
int pos = 0;
zTime[pos++] = zDate[2]; zTime[pos++] = zDate[3]; /* YY */
zTime[pos++] = zDate[5]; zTime[pos++] = zDate[6]; /* MM */
zTime[pos++] = zDate[8]; zTime[pos++] = zDate[9]; /* DD */
zTime[pos++] = ' ';
zTime[pos++] = zDate[11]; zTime[pos++] = zDate[12]; /* HH */
zTime[pos++] = ':';
zTime[pos++] = zDate[14]; zTime[pos++] = zDate[15]; /* MM */
zTime[pos++] = 0;
}else{
zTime[0] = 0;
}
if( rid == vid ){
@ <tr class="timelineCurrent">
}else {
@ <tr>
}
@ <td class="timelineTime">%s(zTime)</td>
|
| ︙ | ︙ | |||
391 392 393 394 395 396 397 |
** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
wiki_convert(&comment, 0, WIKI_INLINE);
}else if( mxWikiLen>0 && blob_size(&comment)>mxWikiLen ){
Blob truncated;
blob_zero(&truncated);
blob_append(&truncated, blob_buffer(&comment), mxWikiLen);
blob_append(&truncated, "...", 3);
| | | | 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 |
** "fossil rebuild" and expect to be rendered as text/x-fossil-wiki */
wiki_convert(&comment, 0, WIKI_INLINE);
}else if( mxWikiLen>0 && blob_size(&comment)>mxWikiLen ){
Blob truncated;
blob_zero(&truncated);
blob_append(&truncated, blob_buffer(&comment), mxWikiLen);
blob_append(&truncated, "...", 3);
@ <span class="timelineComment">%W(blob_str(&truncated))</span>
blob_reset(&truncated);
}else{
@ <span class="timelineComment">%W(blob_str(&comment))</span>
}
blob_reset(&comment);
/* Generate the "user: USERNAME" at the end of the comment, together
** with a hyperlink to another timeline for that user.
*/
if( zTagList && zTagList[0]==0 ) zTagList = 0;
|
| ︙ | ︙ | |||
858 859 860 861 862 863 864 |
@ etype TEXT,
@ taglist TEXT,
@ tagid INTEGER,
@ short TEXT,
@ sortby REAL
@ )
;
| | | 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 |
@ etype TEXT,
@ taglist TEXT,
@ tagid INTEGER,
@ short TEXT,
@ sortby REAL
@ )
;
db_multi_exec("%s", zSql/*safe-for-%s*/);
}
/*
** Return a pointer to a constant string that forms the basis
** for a timeline query for the WWW interface.
*/
const char *timeline_query_for_www(void){
|
| ︙ | ︙ | |||
887 888 889 890 891 892 893 |
@ tagid AS tagid,
@ brief AS brief,
@ event.mtime AS mtime
@ FROM event CROSS JOIN blob
@ WHERE blob.rid=event.objid
;
if( zBase==0 ){
| | | 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 |
@ tagid AS tagid,
@ brief AS brief,
@ event.mtime AS mtime
@ FROM event CROSS JOIN blob
@ WHERE blob.rid=event.objid
;
if( zBase==0 ){
zBase = mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
}
return zBase;
}
/*
** Generate a submenu element with a single parameter change.
*/
|
| ︙ | ︙ | |||
963 964 965 966 967 968 969 |
*/
char *names_of_file(const char *zUuid){
Stmt q;
Blob out;
const char *zSep = "";
db_prepare(&q,
"SELECT DISTINCT filename.name FROM mlink, filename"
| | | 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 |
*/
char *names_of_file(const char *zUuid){
Stmt q;
Blob out;
const char *zSep = "";
db_prepare(&q,
"SELECT DISTINCT filename.name FROM mlink, filename"
" WHERE mlink.fid=(SELECT rid FROM blob WHERE uuid=%Q)"
" AND filename.fnid=mlink.fnid",
zUuid
);
blob_zero(&out);
while( db_step(&q)==SQLITE_ROW ){
const char *zFN = db_column_text(&q, 0);
blob_appendf(&out, "%s%z%h</a>", zSep,
|
| ︙ | ︙ | |||
994 995 996 997 998 999 1000 | ** n=COUNT max number of events in output ** p=UUID artifact and up to COUNT parents and ancestors ** d=UUID artifact and up to COUNT descendants ** dp=UUID The same as d=UUID&p=UUID ** t=TAGID show only check-ins with the given tagid ** r=TAGID show check-ins related to tagid ** u=USER only if belonging to this user | | > > | 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 | ** n=COUNT max number of events in output ** p=UUID artifact and up to COUNT parents and ancestors ** d=UUID artifact and up to COUNT descendants ** dp=UUID The same as d=UUID&p=UUID ** t=TAGID show only check-ins with the given tagid ** r=TAGID show check-ins related to tagid ** u=USER only if belonging to this user ** y=TYPE 'ci', 'w', 't', 'e', or (default) 'all' ** s=TEXT string search (comment and brief) ** ng Suppress the graph if present ** nd Suppress "divider" lines ** v Show details of files changed ** f=UUID Show family (immediate parents and children) of UUID ** from=UUID Path from... ** to=UUID ... to this ** nomerge ... avoid merge links on the path ** shortest ... show only the shortest path ** uf=FUUID Show only checkins that use given file version ** brbg Background color from branch name ** ubg Background color from user ** namechng Show only checkins that filename changes ** ym=YYYY-MM Shown only events for the given year/month. ** datefmt=N Override the date format ** ** p= and d= can appear individually or together. If either p= or d= ** appear, then u=, y=, a=, and b= are ignored. ** ** If a= and b= appear, only a= is used. If neither appear, the most ** recent events are chosen. ** |
| ︙ | ︙ | |||
1035 1036 1037 1038 1039 1040 1041 |
const char *zBefore = P("b"); /* Events before this time */
const char *zCirca = P("c"); /* Events near this time */
const char *zTagName = P("t"); /* Show events with this tag */
const char *zBrName = P("r"); /* Show events related to this tag */
const char *zSearch = P("s"); /* Search string */
const char *zUses = P("uf"); /* Only show checkins hold this file */
const char *zYearMonth = P("ym"); /* Show checkins for the given YYYY-MM */
| | | 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 |
const char *zBefore = P("b"); /* Events before this time */
const char *zCirca = P("c"); /* Events near this time */
const char *zTagName = P("t"); /* Show events with this tag */
const char *zBrName = P("r"); /* Show events related to this tag */
const char *zSearch = P("s"); /* Search string */
const char *zUses = P("uf"); /* Only show checkins hold this file */
const char *zYearMonth = P("ym"); /* Show checkins for the given YYYY-MM */
const char *zYearWeek = P("yw"); /* Show checkins for the given YYYY-WW (week-of-year)*/
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
int renameOnly = P("namechng")!=0; /* Show only checkins that rename files */
int tagid; /* Tag ID */
int tmFlags; /* Timeline flags */
const char *zThisTag = 0; /* Suppress links to this tag */
const char *zThisUser = 0; /* Suppress links to this user */
HQuery url; /* URL for various branch links */
|
| ︙ | ︙ | |||
1126 1127 1128 1129 1130 1131 1132 |
blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1);
blob_append(&sql, timeline_query_for_www(), -1);
if( P("fc")!=0 || P("v")!=0 || P("detail")!=0 ){
tmFlags |= TIMELINE_FCHANGES;
url_add_parameter(&url, "v", 0);
}
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
| > | | | > | 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
blob_append(&sql, "INSERT OR IGNORE INTO timeline ", -1);
blob_append(&sql, timeline_query_for_www(), -1);
if( P("fc")!=0 || P("v")!=0 || P("detail")!=0 ){
tmFlags |= TIMELINE_FCHANGES;
url_add_parameter(&url, "v", 0);
}
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)",
TAG_HIDDEN
);
}
if( !useDividers ) url_add_parameter(&url, "nd", 0);
if( ((from_rid && to_rid) || (me_rid && you_rid)) && g.perm.Read ){
/* If from= and to= are present, display all nodes on a path connecting
** the two */
PathNode *p = 0;
const char *zFrom = 0;
|
| ︙ | ︙ | |||
1151 1152 1153 1154 1155 1156 1157 |
p = path_first();
}
zFrom = P("me");
zTo = P("you");
}
blob_append(&sql, " AND event.objid IN (0", -1);
while( p ){
| | | | | | | 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 |
p = path_first();
}
zFrom = P("me");
zTo = P("you");
}
blob_append(&sql, " AND event.objid IN (0", -1);
while( p ){
blob_append_sql(&sql, ",%d", p->rid);
p = p->u.pTo;
}
blob_append(&sql, ")", -1);
path_reset();
blob_append(&desc, "All nodes on the path from ", -1);
blob_appendf(&desc, "%z[%h]</a>", href("%R/info/%h", zFrom), zFrom);
blob_append(&desc, " to ", -1);
blob_appendf(&desc, "%z[%h]</a>", href("%R/info/%h",zTo), zTo);
tmFlags |= TIMELINE_DISJOINT;
db_multi_exec("%s", blob_sql_text(&sql));
}else if( (p_rid || d_rid) && g.perm.Read ){
/* If p= or d= is present, ignore all other parameters other than n= */
char *zUuid;
int np, nd;
if( p_rid && d_rid ){
if( p_rid!=d_rid ) p_rid = d_rid;
if( P("n")==0 ) nEntry = 10;
}
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY)"
);
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d",
p_rid ? p_rid : d_rid);
blob_append_sql(&sql, " AND event.objid IN ok");
nd = 0;
if( d_rid ){
compute_descendants(d_rid, nEntry+1);
nd = db_int(0, "SELECT count(*)-1 FROM ok");
if( nd>=0 ) db_multi_exec("%s", blob_sql_text(&sql));
if( nd>0 ) blob_appendf(&desc, "%d descendant%s", nd,(1==nd)?"":"s");
if( useDividers ) timeline_add_dividers(0, d_rid);
db_multi_exec("DELETE FROM ok");
}
if( p_rid ){
compute_ancestors(p_rid, nEntry+1, 0);
np = db_int(0, "SELECT count(*)-1 FROM ok");
if( np>0 ){
if( nd>0 ) blob_appendf(&desc, " and ");
blob_appendf(&desc, "%d ancestors", np);
db_multi_exec("%s", blob_sql_text(&sql));
}
if( d_rid==0 && useDividers ) timeline_add_dividers(0, p_rid);
}
blob_appendf(&desc, " of %z[%S]</a>",
href("%R/info/%s", zUuid), zUuid);
if( p_rid ){
url_add_parameter(&url, "p", zUuid);
|
| ︙ | ︙ | |||
1232 1233 1234 1235 1236 1237 1238 |
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;"
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;",
f_rid, f_rid, f_rid
);
| | | | | | | | | | | > | | | > | | | | | | | | | | | | | | | | | | | | | 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 |
db_multi_exec(
"CREATE TEMP TABLE IF NOT EXISTS ok(rid INTEGER PRIMARY KEY);"
"INSERT INTO ok VALUES(%d);"
"INSERT OR IGNORE INTO ok SELECT pid FROM plink WHERE cid=%d;"
"INSERT OR IGNORE INTO ok SELECT cid FROM plink WHERE pid=%d;",
f_rid, f_rid, f_rid
);
blob_append_sql(&sql, " AND event.objid IN ok");
db_multi_exec("%s", blob_sql_text(&sql));
if( useDividers ) timeline_add_dividers(0, f_rid);
blob_appendf(&desc, "Parents and children of check-in ");
zUuid = db_text("", "SELECT uuid FROM blob WHERE rid=%d", f_rid);
blob_appendf(&desc, "%z[%S]</a>", href("%R/info/%s", zUuid), zUuid);
tmFlags |= TIMELINE_DISJOINT;
url_add_parameter(&url, "f", zUuid);
if( tmFlags & TIMELINE_FCHANGES ){
timeline_submenu(&url, "Hide Files", "v", 0, 0);
}else{
timeline_submenu(&url, "Show Files", "v", "", 0);
}
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
timeline_submenu(&url, "Unhide", "unhide", "", 0);
}
}else{
/* Otherwise, a timeline based on a span of time */
int n;
const char *zEType = "timeline item";
char *zDate;
if( zUses ){
blob_append_sql(&sql, " AND event.objid IN usesfile ");
}
if( renameOnly ){
blob_append_sql(&sql, " AND event.objid IN rnfile ");
}
if( zYearMonth ){
blob_append_sql(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
zYearMonth);
}
else if( zYearWeek ){
blob_append_sql(&sql, " AND %Q=strftime('%%Y-%%W',event.mtime) ",
zYearWeek);
}
if( tagid>0 ){
blob_append_sql(&sql,
"AND (EXISTS(SELECT 1 FROM tagxref"
" WHERE tagid=%d AND tagtype>0 AND rid=blob.rid)", tagid);
if( zBrName ){
url_add_parameter(&url, "r", zBrName);
/* The next two blob_appendf() calls add SQL that causes checkins that
** are not part of the branch which are parents or children of the
** branch to be included in the report. This related check-ins are
** useful in helping to visualize what has happened on a quiescent
** branch that is infrequently merged with a much more activate branch.
*/
blob_append_sql(&sql,
" OR EXISTS(SELECT 1 FROM plink CROSS JOIN tagxref ON rid=cid"
" WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
tagid
);
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=cid"
" WHERE tagid=%d AND tagtype>0 AND pid=blob.rid)",
TAG_HIDDEN
);
}
if( P("mionly")==0 ){
blob_append_sql(&sql,
" OR EXISTS(SELECT 1 FROM plink CROSS JOIN tagxref ON rid=pid"
" WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
tagid
);
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
blob_append_sql(&sql,
" AND NOT EXISTS(SELECT 1 FROM plink JOIN tagxref ON rid=pid"
" WHERE tagid=%d AND tagtype>0 AND cid=blob.rid)",
TAG_HIDDEN
);
}
}else{
url_add_parameter(&url, "mionly", "1");
}
}else{
url_add_parameter(&url, "t", zTagName);
}
blob_append_sql(&sql, ")");
}
if( (zType[0]=='w' && !g.perm.RdWiki)
|| (zType[0]=='t' && !g.perm.RdTkt)
|| (zType[0]=='e' && !g.perm.RdWiki)
|| (zType[0]=='c' && !g.perm.Read)
|| (zType[0]=='g' && !g.perm.Read)
){
zType = "all";
}
if( zType[0]=='a' ){
if( !g.perm.Read || !g.perm.RdWiki || !g.perm.RdTkt ){
char cSep = '(';
blob_append_sql(&sql, " AND event.type IN ");
if( g.perm.Read ){
blob_append_sql(&sql, "%c'ci','g'", cSep);
cSep = ',';
}
if( g.perm.RdWiki ){
blob_append_sql(&sql, "%c'w','e'", cSep);
cSep = ',';
}
if( g.perm.RdTkt ){
blob_append_sql(&sql, "%c't'", cSep);
cSep = ',';
}
blob_append_sql(&sql, ")");
}
}else{ /* zType!="all" */
blob_append_sql(&sql, " AND event.type=%Q", zType);
url_add_parameter(&url, "y", zType);
if( zType[0]=='c' ){
zEType = "checkin";
}else if( zType[0]=='w' ){
zEType = "wiki edit";
}else if( zType[0]=='t' ){
zEType = "ticket change";
}else if( zType[0]=='e' ){
zEType = "event";
}else if( zType[0]=='g' ){
zEType = "tag";
}
}
if( zUser ){
blob_append_sql(&sql, " AND (event.user=%Q OR event.euser=%Q)",
zUser, zUser);
url_add_parameter(&url, "u", zUser);
zThisUser = zUser;
}
if( zSearch ){
blob_append_sql(&sql,
" AND (event.comment LIKE '%%%q%%' OR event.brief LIKE '%%%q%%')",
zSearch, zSearch);
url_add_parameter(&url, "s", zSearch);
}
rBefore = symbolic_name_to_mtime(zBefore);
rAfter = symbolic_name_to_mtime(zAfter);
rCirca = symbolic_name_to_mtime(zCirca);
if( rAfter>0.0 ){
if( rBefore>0.0 ){
blob_append_sql(&sql,
" AND event.mtime>=%.17g AND event.mtime<=%.17g"
" ORDER BY event.mtime ASC", rAfter-ONE_SECOND, rBefore+ONE_SECOND);
url_add_parameter(&url, "a", zAfter);
url_add_parameter(&url, "b", zBefore);
nEntry = 1000000;
}else{
blob_append_sql(&sql,
" AND event.mtime>=%.17g ORDER BY event.mtime ASC",
rAfter-ONE_SECOND);
url_add_parameter(&url, "a", zAfter);
}
}else if( rBefore>0.0 ){
blob_append_sql(&sql,
" AND event.mtime<=%.17g ORDER BY event.mtime DESC",
rBefore+ONE_SECOND);
url_add_parameter(&url, "b", zBefore);
}else if( rCirca>0.0 ){
Blob sql2;
blob_init(&sql2, blob_sql_text(&sql), -1);
blob_append_sql(&sql2,
" AND event.mtime<=%f ORDER BY event.mtime DESC LIMIT %d",
rCirca, (nEntry+1)/2
);
db_multi_exec("%s", blob_sql_text(&sql2));
blob_reset(&sql2);
blob_append_sql(&sql,
" AND event.mtime>=%f ORDER BY event.mtime ASC",
rCirca
);
nEntry -= (nEntry+1)/2;
if( useDividers ) timeline_add_dividers(rCirca, 0);
url_add_parameter(&url, "c", zCirca);
}else{
blob_append_sql(&sql, " ORDER BY event.mtime DESC");
}
blob_append_sql(&sql, " LIMIT %d", nEntry);
db_multi_exec("%s", blob_sql_text(&sql));
n = db_int(0, "SELECT count(*) FROM timeline WHERE etype!='div' /*scan*/");
if( zYearMonth ){
blob_appendf(&desc, "%s events for %h", zEType, zYearMonth);
}else if( zYearWeek ){
blob_appendf(&desc, "%s events for year/week %h", zEType, zYearWeek);
}else if( zAfter==0 && zBefore==0 && zCirca==0 ){
|
| ︙ | ︙ | |||
1503 1504 1505 1506 1507 1508 1509 |
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
timeline_submenu(&url, "Unhide", "unhide", "", 0);
}
}
}
}
if( P("showsql") ){
| | | 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 |
if( (tmFlags & TIMELINE_UNHIDE)==0 ){
timeline_submenu(&url, "Unhide", "unhide", "", 0);
}
}
}
}
if( P("showsql") ){
@ <blockquote>%h(blob_sql_text(&sql))</blockquote>
}
blob_zero(&sql);
db_prepare(&q, "SELECT * FROM timeline ORDER BY sortby DESC /*scan*/");
@ <h2>%b(&desc)</h2>
blob_reset(&desc);
www_print_timeline(&q, tmFlags, zThisUser, zThisTag, 0);
db_finalize(&q);
|
| ︙ | ︙ | |||
1600 1601 1602 1603 1604 1605 1606 |
n = strlen(zPrefix);
}
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
n += strlen(zPrefix);
}
zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom);
| | > | 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 |
n = strlen(zPrefix);
}
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
n += strlen(zPrefix);
}
zFree = mprintf("[%S] %s%s", zId, zPrefix, zCom);
/* record another X lines */
nLine += comment_print(zFree, zCom, 9, width, g.comFmtFlags);
fossil_free(zFree);
if(verboseFlag){
if( !fchngQueryInit ){
db_prepare(&fchngQuery,
"SELECT (pid==0) AS isnew,"
" (fid==0) AS isdel,"
|
| ︙ | ︙ | |||
1651 1652 1653 1654 1655 1656 1657 |
}
/*
** Return a pointer to a static string that forms the basis for
** a timeline query for display on a TTY.
*/
const char *timeline_query_for_tty(void){
| < | < | < < | > > | 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 |
}
/*
** Return a pointer to a static string that forms the basis for
** a timeline query for display on a TTY.
*/
const char *timeline_query_for_tty(void){
static const char zBaseSql[] =
@ SELECT
@ blob.rid AS rid,
@ uuid,
@ datetime(event.mtime%s) AS mDateTime,
@ coalesce(ecomment,comment)
@ || ' (user: ' || coalesce(euser,user,'?')
@ || (SELECT case when length(x)>0 then ' tags: ' || x else '' end
@ FROM (SELECT group_concat(substr(tagname,5), ', ') AS x
@ FROM tag, tagxref
@ WHERE tagname GLOB 'sym-*' AND tag.tagid=tagxref.tagid
@ AND tagxref.rid=blob.rid AND tagxref.tagtype>0))
@ || ')' as comment,
@ (SELECT count(*) FROM plink WHERE pid=blob.rid AND isprim)
@ AS primPlinkCount,
@ (SELECT count(*) FROM plink WHERE cid=blob.rid) AS plinkCount,
@ event.mtime AS mtime,
@ tagxref.value AS branch
@ FROM tag CROSS JOIN event CROSS JOIN blob
@ LEFT JOIN tagxref ON tagxref.tagid=tag.tagid
@ AND tagxref.tagtype>0
@ AND tagxref.rid=blob.rid
@ WHERE blob.rid=event.objid
@ AND tag.tagname='branch'
;
return mprintf(zBaseSql /*works-like: "%s"*/, timeline_utc());
}
/*
** Return true if the input string is a date in the ISO 8601 format:
** YYYY-MM-DD.
*/
static int isIsoDate(const char *z){
return strlen(z)==10
&& z[4]=='-'
&& z[7]=='-'
&& fossil_isdigit(z[0])
&& fossil_isdigit(z[5]);
}
/*
** COMMAND: timeline
**
** Usage: %fossil timeline ?WHEN? ?CHECKIN|DATETIME? ?OPTIONS?
**
** Print a summary of activity going backwards in date and time
** specified or from the current date and time if no arguments
** are given. The WHEN argument can be any unique abbreviation
** of one of these keywords:
**
** before
** after
** descendants | children
** ancestors | parents
**
** The BASELINE can be any unique prefix of 4 characters or more.
** The DATETIME should be in the ISO8601 format. For
** examples: "2007-08-18 07:21:21". You can also say "current"
** for the current version or "now" for the current time.
**
** Options:
** -n|--limit N Output the first N entries (default 20 lines).
** N=0 means no limit.
** -p|--path PATH Output items affecting PATH only.
** PATH can be a file or a sub directory.
** --offset P skip P changes
** -t|--type TYPE Output items from the given types only, such as:
** ci = file commits only
** e = events only
** t = tickets only
** w = wiki commits only
** -v|--verbose Output the list of files changed by each commit
|
| ︙ | ︙ | |||
1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 |
char *zDate;
Blob sql;
int objid = 0;
Blob uuid;
int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
int verboseFlag = 0 ;
int iOffset;
verboseFlag = find_option("verbose","v", 0)!=0;
if( !verboseFlag){
verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
}
db_find_and_open_repository(0, 0);
zLimit = find_option("limit","n",1);
zWidth = find_option("width","W",1);
zType = find_option("type","t",1);
| > > > > | > > > > | | | 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 |
char *zDate;
Blob sql;
int objid = 0;
Blob uuid;
int mode = 0 ; /* 0:none 1: before 2:after 3:children 4:parents */
int verboseFlag = 0 ;
int iOffset;
const char *zFilePattern = 0;
Blob treeName;
verboseFlag = find_option("verbose","v", 0)!=0;
if( !verboseFlag){
verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
}
db_find_and_open_repository(0, 0);
zLimit = find_option("limit","n",1);
zWidth = find_option("width","W",1);
zType = find_option("type","t",1);
zFilePattern = find_option("path","p",1);
if( !zLimit ){
zLimit = find_option("count",0,1);
}
if( zLimit ){
n = atoi(zLimit);
}else{
n = -20;
}
if( zWidth ){
width = atoi(zWidth);
if( (width!=0) && (width<=20) ){
fossil_fatal("-W|--width value must be >20 or 0");
}
}else{
width = -1;
}
zOffset = find_option("offset",0,1);
iOffset = zOffset ? atoi(zOffset) : 0;
/* We should be done with options.. */
verify_all_options();
if( g.argc>=4 ){
k = strlen(g.argv[2]);
if( strncmp(g.argv[2],"before",k)==0 ){
mode = 1;
}else if( strncmp(g.argv[2],"after",k)==0 && k>1 ){
mode = 2;
}else if( strncmp(g.argv[2],"descendants",k)==0 ){
mode = 3;
}else if( strncmp(g.argv[2],"children",k)==0 ){
mode = 3;
}else if( strncmp(g.argv[2],"ancestors",k)==0 && k>1 ){
mode = 4;
}else if( strncmp(g.argv[2],"parents",k)==0 ){
mode = 4;
}else if(!zType && !zLimit){
usage("?WHEN? ?CHECKIN|DATETIME? ?-n|--limit #? ?-t|--type TYPE? "
"?-W|--width WIDTH? ?-p|--path PATH");
}
if( '-' != *g.argv[3] ){
zOrigin = g.argv[3];
}else{
zOrigin = "now";
}
}else if( g.argc==3 ){
|
| ︙ | ︙ | |||
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 |
fossil_fatal("cannot compute descendants or ancestors of a date");
}
if( mode==0 ){
if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
}
zDate = mprintf("(SELECT julianday(%Q%s, 'utc'))", zOrigin, zShift);
}
if( mode==0 ) mode = 1;
blob_zero(&sql);
blob_append(&sql, timeline_query_for_tty(), -1);
| > > > > > > > > > > > > > > > | | | | > > > > > > > > > > > > > > > > > > > > | | | | 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 |
fossil_fatal("cannot compute descendants or ancestors of a date");
}
if( mode==0 ){
if( isIsoDate(zOrigin) ) zShift = ",'+1 day'";
}
zDate = mprintf("(SELECT julianday(%Q%s, 'utc'))", zOrigin, zShift);
}
if( zFilePattern ){
if( zType==0 ){
/* When zFilePattern is specified and type is not specified, only show
* file checkins */
zType="ci";
}
file_tree_name(zFilePattern, &treeName, 1);
if( fossil_strcmp(blob_str(&treeName), ".")==0 ){
/* When zTreeName refers to g.zLocalRoot, it's like not specifying
* zFilePattern. */
zFilePattern = 0;
}
}
if( mode==0 ) mode = 1;
blob_zero(&sql);
blob_append(&sql, timeline_query_for_tty(), -1);
blob_append_sql(&sql, " AND event.mtime %s %s",
(mode==1 || mode==4) ? "<=" : ">=",
zDate /*safe-for-%s*/
);
if( mode==3 || mode==4 ){
db_multi_exec("CREATE TEMP TABLE ok(rid INTEGER PRIMARY KEY)");
if( mode==3 ){
compute_descendants(objid, n);
}else{
compute_ancestors(objid, n, 0);
}
blob_append_sql(&sql, "\n AND blob.rid IN ok");
}
if( zType && (zType[0]!='a') ){
blob_append_sql(&sql, "\n AND event.type=%Q ", zType);
}
if( zFilePattern ){
blob_append(&sql,
"\n AND EXISTS(SELECT 1 FROM mlink\n"
" WHERE mlink.mid=event.objid\n"
" AND mlink.fnid IN ", -1);
if( filenames_are_case_sensitive() ){
blob_append_sql(&sql,
"(SELECT fnid FROM filename"
" WHERE name=%Q"
" OR name GLOB '%q/*')",
blob_str(&treeName), blob_str(&treeName));
}else{
blob_append_sql(&sql,
"(SELECT fnid FROM filename"
" WHERE name=%Q COLLATE nocase"
" OR lower(name) GLOB lower('%q/*'))",
blob_str(&treeName), blob_str(&treeName));
}
blob_append(&sql, ")", -1);
}
blob_append_sql(&sql, "\nORDER BY event.mtime DESC");
if( iOffset>0 ){
/* Don't handle LIMIT here, otherwise print_timeline()
* will not determine the end-marker correctly! */
blob_append_sql(&sql, "\n LIMIT -1 OFFSET %d", iOffset);
}
db_prepare(&q, "%s", blob_sql_text(&sql));
blob_reset(&sql);
print_timeline(&q, n, width, verboseFlag);
db_finalize(&q);
}
/*
** Return one of two things:
|
| ︙ | ︙ | |||
1961 1962 1963 1964 1965 1966 1967 | */ static int statsReportType = 0; /* ** Set by stats_report_init_view() to one of the y=XXXX values ** accepted by /timeline?y=XXXX. */ | | | | | 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 |
*/
static int statsReportType = 0;
/*
** Set by stats_report_init_view() to one of the y=XXXX values
** accepted by /timeline?y=XXXX.
*/
static const char *statsReportTimelineYFlag = NULL;
/*
** Creates a TEMP VIEW named v_reports which is a wrapper around the
** EVENT table filtered on event.type. It looks for the request
** parameter 'type' (reminder: we "should" use 'y' for consistency
** with /timeline, but /reports uses 'y' for the year) and expects it
** to contain one of the conventional values from event.type or the
** value "all", which is treated as equivalent to "*". By default (if
** no 'y' is specified), "*" is assumed (that is also the default for
** invalid/unknown filter values). That 'y' filter is the one used for
** the event list. Note that a filter of "*" or "all" is equivalent to
** querying against the full event table. The view, however, adds an
** abstraction level to simplify the implementation code for the
** various /reports pages.
**
** Returns one of: 'c', 'w', 'g', 't', 'e', representing the type of
** filter it applies, or '*' if no filter is applied (i.e. if "all" is
** used).
*/
static int stats_report_init_view(){
const char *zType = PD("type","*"); /* analog to /timeline?y=... */
const char *zRealType = NULL; /* normalized form of zType */
int rc = 0; /* result code */
assert( !statsReportType && "Must not be called more than once." );
switch( (zType && *zType) ? *zType : 0 ){
case 'c':
case 'C':
zRealType = "ci";
rc = *zRealType;
|
| ︙ | ︙ | |||
2036 2037 2038 2039 2040 2041 2042 | /* ** Returns a string suitable (for a given value of suitable) for ** use in a label with the header of the /reports pages, dependent ** on the 'type' flag. See stats_report_init_view(). ** The returned bytes are static. */ | | | 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 |
/*
** Returns a string suitable (for a given value of suitable) for
** use in a label with the header of the /reports pages, dependent
** on the 'type' flag. See stats_report_init_view().
** The returned bytes are static.
*/
static const char *stats_report_label_for_type(){
assert( statsReportType && "Must call stats_report_init_view() first." );
switch( statsReportType ){
case 'c':
return "checkins";
case 'e':
return "events";
case 'w':
|
| ︙ | ︙ | |||
2063 2064 2065 2066 2067 2068 2069 | ** of links for the various type=XXX flags. zCurrentViewName must be ** the name/value of the 'view' parameter which is in effect at the ** time this is called. e.g. if called from the 'byuser' view then ** zCurrentViewName must be "byuser". Any URL parameters which need to ** be added to the generated URLs should be passed in zParam. The ** caller is expected to have already encoded any zParam in the %T or ** %t encoding. */ | | | | | 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 |
** of links for the various type=XXX flags. zCurrentViewName must be
** the name/value of the 'view' parameter which is in effect at the
** time this is called. e.g. if called from the 'byuser' view then
** zCurrentViewName must be "byuser". Any URL parameters which need to
** be added to the generated URLs should be passed in zParam. The
** caller is expected to have already encoded any zParam in the %T or
** %t encoding. */
static void stats_report_event_types_menu(const char *zCurrentViewName,
const char *zParam){
char *zTop;
if(zParam && !*zParam){
zParam = NULL;
}
zTop = mprintf("%s/reports?view=%s%s%s", g.zTop, zCurrentViewName,
zParam ? "&" : "", zParam);
cgi_printf("<div>");
cgi_printf("<span>Types:</span> ");
|
| ︙ | ︙ | |||
2113 2114 2115 2116 2117 2118 2119 | /* ** Helper for stats_report_by_month_year(), which generates a list of ** week numbers. zTimeframe should be either a timeframe in the form YYYY ** or YYYY-MM. */ | | | | | | | | | 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 |
/*
** Helper for stats_report_by_month_year(), which generates a list of
** week numbers. zTimeframe should be either a timeframe in the form YYYY
** or YYYY-MM.
*/
static void stats_report_output_week_links(const char *zTimeframe){
Stmt stWeek = empty_Stmt;
char yearPart[5] = {0,0,0,0,0};
memcpy(yearPart, zTimeframe, 4);
db_prepare(&stWeek,
"SELECT DISTINCT strftime('%%W',mtime) AS wk, "
"count(*) AS n, "
"substr(date(mtime),1,%d) AS ym "
"FROM v_reports "
"WHERE ym=%Q AND mtime < current_timestamp "
"GROUP BY wk ORDER BY wk",
strlen(zTimeframe),
zTimeframe);
while( SQLITE_ROW == db_step(&stWeek) ){
const char *zWeek = db_column_text(&stWeek,0);
const int nCount = db_column_int(&stWeek,1);
cgi_printf("<a href='%s/timeline?"
"yw=%t-%t&n=%d&y=%s'>%s</a>",
g.zTop, yearPart, zWeek,
nCount, statsReportTimelineYFlag, zWeek);
}
db_finalize(&stWeek);
}
/*
** Implements the "byyear" and "bymonth" reports for /reports.
** If includeMonth is true then it generates the "bymonth" report,
** else the "byyear" report. If zUserName is not NULL and not empty
** then the report is restricted to events created by the named user
** account.
*/
static void stats_report_by_month_year(char includeMonth,
char includeWeeks,
const char *zUserName){
Stmt query = empty_Stmt;
int nRowNumber = 0; /* current TR number */
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
Blob sql = empty_blob; /* SQL */
const char *zTimeLabel = includeMonth ? "Year/Month" : "Year";
char zPrevYear[5] = {0}; /* For keeping track of when
we change years while looping */
int nEventsPerYear = 0; /* Total event count for the
current year */
char showYearTotal = 0; /* Flag telling us when to show
the per-year event totals */
Blob header = empty_blob; /* Page header text */
int nMaxEvents = 1; /* for calculating length of graph
bars. */
int iterations = 0; /* number of weeks/months we iterate
over */
stats_report_init_view();
stats_report_event_types_menu( includeMonth ? "bymonth" : "byyear", NULL );
blob_appendf(&header, "Timeline Events (%s) by year%s",
stats_report_label_for_type(),
(includeMonth ? "/month" : ""));
blob_append_sql(&sql,
"SELECT substr(date(mtime),1,%d) AS timeframe, "
"count(*) AS eventCount "
"FROM v_reports ",
includeMonth ? 7 : 4);
if(zUserName&&*zUserName){
blob_append_sql(&sql, " WHERE user=%Q ", zUserName);
blob_appendf(&header," for user %q", zUserName);
}
blob_append(&sql,
" GROUP BY timeframe"
" ORDER BY timeframe DESC",
-1);
db_prepare(&query, "%s", blob_sql_text(&sql));
blob_reset(&sql);
@ <h1>%b(&header)</h1>
@ <table class='statistics-report-table-events' border='0' cellpadding='2'
@ cellspacing='0' id='statsTable'>
@ <thead>
@ <th>%s(zTimeLabel)</th>
@ <th>Events</th>
|
| ︙ | ︙ | |||
2208 2209 2210 2211 2212 2213 2214 |
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
++iterations;
}
db_reset(&query);
while( SQLITE_ROW == db_step(&query) ){
| | | 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 |
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
++iterations;
}
db_reset(&query);
while( SQLITE_ROW == db_step(&query) ){
const char *zTimeframe = db_column_text(&query, 0);
const int nCount = db_column_int(&query, 1);
int nSize = nCount
? (int)(100 * nCount / nMaxEvents)
: 1;
showYearTotal = 0;
if(!nSize) nSize = 1;
if(includeMonth){
|
| ︙ | ︙ | |||
2293 2294 2295 2296 2297 2298 2299 |
@ <tr class='row%d(rowClass)'>
@ <td></td>
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
@</tr>
}
@ </tbody></table>
if(nEventTotal){
| | < | | < < < | | 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 |
@ <tr class='row%d(rowClass)'>
@ <td></td>
@ <td colspan='2'>Yearly total: %d(nEventsPerYear)</td>
@</tr>
}
@ </tbody></table>
if(nEventTotal){
const char *zAvgLabel = includeMonth ? "month" : "year";
int nAvg = iterations ? (nEventTotal/iterations) : 0;
@ <br><div>Total events: %d(nEventTotal)
@ <br>Average per active %s(zAvgLabel): %d(nAvg)
@ </div>
}
if( !includeMonth ){
output_table_sorting_javascript("statsTable","tnx");
}
}
/*
** Implements the "byuser" view for /reports.
*/
static void stats_report_by_user(){
Stmt query = empty_Stmt;
int nRowNumber = 0; /* current TR number */
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
int nMaxEvents = 1; /* max number of events for
all rows. */
stats_report_init_view();
stats_report_event_types_menu("byuser", NULL);
db_prepare(&query,
"SELECT user, "
"COUNT(*) AS eventCount "
"FROM v_reports "
"GROUP BY user ORDER BY eventCount DESC");
@ <h1>Timeline Events
@ (%s(stats_report_label_for_type())) by User</h1>
@ <table class='statistics-report-table-events' border='0'
@ cellpadding='2' cellspacing='0' id='statsTable'>
@ <thead><tr>
@ <th>User</th>
@ <th>Events</th>
@ <th width='90%%'><!-- relative commits graph --></th>
@ </tr></thead><tbody>
while( SQLITE_ROW == db_step(&query) ){
const int nCount = db_column_int(&query, 1);
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
}
db_reset(&query);
while( SQLITE_ROW == db_step(&query) ){
const char *zUser = db_column_text(&query, 0);
const int nCount = db_column_int(&query, 1);
int nSize = nCount
? (int)(100 * nCount / nMaxEvents)
: 0;
if(!nCount) continue /* arguable! Possible? */;
else if(!nSize) nSize = 1;
rowClass = ++nRowNumber % 2;
|
| ︙ | ︙ | |||
2380 2381 2382 2383 2384 2385 2386 |
*/
static void stats_report_day_of_week(){
Stmt query = empty_Stmt;
int nRowNumber = 0; /* current TR number */
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
| < | | | < < < | | 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 |
*/
static void stats_report_day_of_week(){
Stmt query = empty_Stmt;
int nRowNumber = 0; /* current TR number */
int nEventTotal = 0; /* Total event count */
int rowClass = 0; /* counter for alternating
row colors */
int nMaxEvents = 1; /* max number of events for
all rows. */
static const char *const daysOfWeek[] = {
"Monday", "Tuesday", "Wednesday", "Thursday",
"Friday", "Saturday", "Sunday"
};
stats_report_init_view();
stats_report_event_types_menu("byweekday", NULL);
db_prepare(&query,
"SELECT cast(mtime %% 7 AS INTEGER) dow, "
"COUNT(*) AS eventCount "
"FROM v_reports "
"GROUP BY dow ORDER BY dow");
@ <h1>Timeline Events
@ (%s(stats_report_label_for_type())) by Day of the Week</h1>
@ <table class='statistics-report-table-events' border='0'
@ cellpadding='2' cellspacing='0' id='statsTable'>
@ <thead><tr>
@ <th>DoW</th>
@ <th>Day</th>
@ <th>Events</th>
@ <th width='90%%'><!-- relative commits graph --></th>
@ </tr></thead><tbody>
while( SQLITE_ROW == db_step(&query) ){
const int nCount = db_column_int(&query, 1);
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
}
db_reset(&query);
while( SQLITE_ROW == db_step(&query) ){
const int dayNum =db_column_int(&query, 0);
const int nCount = db_column_int(&query, 1);
int nSize = nCount
? (int)(100 * nCount / nMaxEvents)
: 0;
if(!nCount) continue /* arguable! Possible? */;
else if(!nSize) nSize = 1;
rowClass = ++nRowNumber % 2;
|
| ︙ | ︙ | |||
2446 2447 2448 2449 2450 2451 2452 | /* ** Helper for stats_report_by_month_year(), which generates a list of ** week numbers. zTimeframe should be either a timeframe in the form YYYY ** or YYYY-MM. */ | | | | | | | | 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532 2533 2534 2535 2536 2537 2538 2539 2540 2541 2542 |
/*
** Helper for stats_report_by_month_year(), which generates a list of
** week numbers. zTimeframe should be either a timeframe in the form YYYY
** or YYYY-MM.
*/
static void stats_report_year_weeks(const char *zUserName){
const char *zYear = P("y");
int nYear = zYear ? strlen(zYear) : 0;
int i = 0;
Stmt qYears = empty_Stmt;
char *zDefaultYear = NULL;
Blob sql = empty_blob;
int nMaxEvents = 1; /* max number of events for
all rows. */
int iterations = 0; /* # of active time periods. */
stats_report_init_view();
if(4==nYear){
Blob urlParams = empty_blob;
blob_appendf(&urlParams, "y=%T", zYear);
stats_report_event_types_menu("byweek", blob_str(&urlParams));
blob_reset(&urlParams);
}else{
stats_report_event_types_menu("byweek", NULL);
}
blob_append(&sql,
"SELECT DISTINCT substr(date(mtime),1,4) AS y "
"FROM v_reports WHERE 1 ", -1);
if(zUserName&&*zUserName){
blob_append_sql(&sql,"AND user=%Q ", zUserName);
}
blob_append(&sql,"GROUP BY y ORDER BY y", -1);
db_prepare(&qYears, "%s", blob_sql_text(&sql));
blob_reset(&sql);
cgi_printf("Select year: ");
while( SQLITE_ROW == db_step(&qYears) ){
const char *zT = db_column_text(&qYears, 0);
if( i++ ){
cgi_printf(" ");
}
cgi_printf("<a href='?view=byweek&y=%s&type=%c", zT,
(char)statsReportType);
if(zUserName && *zUserName){
cgi_printf("&user=%t",zUserName);
|
| ︙ | ︙ | |||
2502 2503 2504 2505 2506 2507 2508 |
Stmt stWeek = empty_Stmt;
int rowCount = 0;
int total = 0;
Blob header = empty_blob;
blob_appendf(&header, "Timeline events (%s) for the calendar weeks "
"of %h", stats_report_label_for_type(),
zYear);
| | | | | | | | 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563 2564 2565 2566 2567 2568 2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 |
Stmt stWeek = empty_Stmt;
int rowCount = 0;
int total = 0;
Blob header = empty_blob;
blob_appendf(&header, "Timeline events (%s) for the calendar weeks "
"of %h", stats_report_label_for_type(),
zYear);
blob_append_sql(&sql,
"SELECT DISTINCT strftime('%%W',mtime) AS wk, "
"count(*) AS n "
"FROM v_reports "
"WHERE %Q=substr(date(mtime),1,4) "
"AND mtime < current_timestamp ",
zYear);
if(zUserName&&*zUserName){
blob_append_sql(&sql, " AND user=%Q ", zUserName);
blob_appendf(&header," for user %h", zUserName);
}
blob_append_sql(&sql, "GROUP BY wk ORDER BY wk DESC");
cgi_printf("<h1>%h</h1>", blob_str(&header));
blob_reset(&header);
cgi_printf("<table class='statistics-report-table-events' "
"border='0' cellpadding='2' width='100%%' "
"cellspacing='0' id='statsTable'>");
cgi_printf("<thead><tr>"
"<th>Week</th>"
"<th>Events</th>"
"<th width='90%%'><!-- relative commits graph --></th>"
"</tr></thead>"
"<tbody>");
db_prepare(&stWeek, "%s", blob_sql_text(&sql));
blob_reset(&sql);
while( SQLITE_ROW == db_step(&stWeek) ){
const int nCount = db_column_int(&stWeek, 1);
if(nCount>nMaxEvents){
nMaxEvents = nCount;
}
++iterations;
}
db_reset(&stWeek);
while( SQLITE_ROW == db_step(&stWeek) ){
const char *zWeek = db_column_text(&stWeek,0);
const int nCount = db_column_int(&stWeek,1);
int nSize = nCount
? (int)(100 * nCount / nMaxEvents)
: 0;
if(!nSize) nSize = 1;
total += nCount;
cgi_printf("<tr class='row%d'>", ++rowCount % 2 );
|
| ︙ | ︙ | |||
2596 2597 2598 2599 2600 2601 2602 |
** view=byweek:
**
** y=YYYY The year to report (default is the server's
** current year).
*/
void stats_report_page(){
HQuery url; /* URL for various branch links */
| | | 2648 2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661 2662 |
** view=byweek:
**
** y=YYYY The year to report (default is the server's
** current year).
*/
void stats_report_page(){
HQuery url; /* URL for various branch links */
const char *zView = P("view"); /* Which view/report to show. */
const char *zUserName = P("user");
login_check_credentials();
if( !g.perm.Read ){ login_needed(); return; }
if(!zUserName) zUserName = P("u");
url_initialize(&url, "reports");
if(zUserName && *zUserName){
|
| ︙ | ︙ |
Changes to src/tkt.c.
| ︙ | ︙ | |||
201 202 203 204 205 206 207 |
db_multi_exec("INSERT INTO ticket(tkt_uuid, tkt_mtime) "
"VALUES(%Q, 0)", p->zTicketUuid);
tktid = db_last_insert_rowid();
}
blob_zero(&sql1);
blob_zero(&sql2);
blob_zero(&sql3);
| | | | | | | | | | | | > | | > > > > > > > > > > > > > > > > > > > > > > > | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
db_multi_exec("INSERT INTO ticket(tkt_uuid, tkt_mtime) "
"VALUES(%Q, 0)", p->zTicketUuid);
tktid = db_last_insert_rowid();
}
blob_zero(&sql1);
blob_zero(&sql2);
blob_zero(&sql3);
blob_append_sql(&sql1, "UPDATE OR REPLACE ticket SET tkt_mtime=:mtime");
if( haveTicketCTime ){
blob_append_sql(&sql1, ", tkt_ctime=coalesce(tkt_ctime,:mtime)");
}
aUsed = fossil_malloc( nField );
memset(aUsed, 0, nField);
for(i=0; i<p->nField; i++){
const char *zName = p->aField[i].zName;
const char *zBaseName = zName[0]=='+' ? zName+1 : zName;
j = fieldId(zBaseName);
if( j<0 ) continue;
aUsed[j] = 1;
if( aField[j].mUsed & USEDBY_TICKET ){
if( zName[0]=='+' ){
zName++;
blob_append_sql(&sql1,", \"%w\"=coalesce(\"%w\",'') || %Q",
zName, zName, p->aField[i].zValue);
}else{
blob_append_sql(&sql1,", \"%w\"=%Q", zName, p->aField[i].zValue);
}
}
if( aField[j].mUsed & USEDBY_TICKETCHNG ){
blob_append_sql(&sql2, ",\"%w\"", zName);
blob_append_sql(&sql3, ",%Q", p->aField[i].zValue);
}
if( rid>0 ){
wiki_extract_links(p->aField[i].zValue, rid, 1, p->rDate, i==0, 0);
}
}
blob_append_sql(&sql1, " WHERE tkt_id=%d", tktid);
db_prepare(&q, "%s", blob_sql_text(&sql1));
db_bind_double(&q, ":mtime", p->rDate);
db_step(&q);
db_finalize(&q);
blob_reset(&sql1);
if( blob_size(&sql2)>0 || haveTicketChngRid ){
int fromTkt = 0;
if( haveTicketChngRid ){
blob_append(&sql2, ",tkt_rid", -1);
blob_append_sql(&sql3, ",%d", rid);
}
for(i=0; i<nField; i++){
if( aUsed[i]==0
&& (aField[i].mUsed & USEDBY_BOTH)==USEDBY_BOTH
){
const char *z = aField[i].zName;
if( z[0]=='+' ) z++;
fromTkt = 1;
blob_append_sql(&sql2, ",\"%w\"", z);
blob_append_sql(&sql3, ",\"%w\"", z);
}
}
if( fromTkt ){
db_prepare(&q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%s)"
"SELECT %d,:mtime%s FROM ticket WHERE tkt_id=%d",
blob_sql_text(&sql2), tktid,
blob_sql_text(&sql3), tktid);
}else{
db_prepare(&q, "INSERT INTO ticketchng(tkt_id,tkt_mtime%s)"
"VALUES(%d,:mtime%s)",
blob_sql_text(&sql2), tktid, blob_sql_text(&sql3));
}
db_bind_double(&q, ":mtime", p->rDate);
db_step(&q);
db_finalize(&q);
}
blob_reset(&sql2);
blob_reset(&sql3);
fossil_free(aUsed);
return tktid;
}
/*
** Returns non-zero if moderation is required for ticket changes and ticket
** attachments.
*/
int ticket_need_moderation(
int localUser /* Are we being called for a local interactive user? */
){
/*
** If the FOSSIL_FORCE_TICKET_MODERATION variable is set, *ALL* changes for
** tickets will be required to go through moderation (even those performed
** by the local interactive user via the command line). This can be useful
** for local (or remote) testing of the moderation subsystem and its impact
** on the contents and status of tickets.
*/
if( fossil_getenv("FOSSIL_FORCE_TICKET_MODERATION")!=0 ){
return 1;
}
if( localUser ){
return 0;
}
return g.perm.ModTkt==0 && db_get_boolean("modreq-tkt",0)==1;
}
/*
** Rebuild an entire entry in the TICKET table
*/
void ticket_rebuild_entry(const char *zTktUuid){
char *zTag = mprintf("tkt-%s", zTktUuid);
int tagid = tag_findid(zTag, 1);
|
| ︙ | ︙ | |||
320 321 322 323 324 325 326 | zConfig = ticket_common_code(); Th_Eval(g.interp, 0, zConfig, -1); } /* ** Create the TH1 interpreter and load the "change" code. */ | | > | | 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 |
zConfig = ticket_common_code();
Th_Eval(g.interp, 0, zConfig, -1);
}
/*
** Create the TH1 interpreter and load the "change" code.
*/
int ticket_change(const char *zUuid){
const char *zConfig;
Th_FossilInit(TH_INIT_DEFAULT);
Th_Store("uuid", zUuid);
zConfig = ticket_change_code();
return Th_Eval(g.interp, 0, zConfig, -1);
}
/*
** Recreate the TICKET and TICKETCHNG tables.
*/
void ticket_create_table(int separateConnection){
const char *zSql;
db_multi_exec(
"DROP TABLE IF EXISTS ticket;"
"DROP TABLE IF EXISTS ticketchng;"
);
zSql = ticket_table_schema();
if( separateConnection ){
db_end_transaction(0);
db_init_database(g.zRepositoryName, zSql, 0);
}else{
db_multi_exec("%s", zSql/*safe-for-%s*/);
}
}
/*
** Repopulate the TICKET and TICKETCHNG tables from scratch using all
** available ticket artifacts.
*/
|
| ︙ | ︙ | |||
525 526 527 528 529 530 531 |
int rid = content_put_ex(pTicket, 0, 0, 0, needMod);
if( rid==0 ){
fossil_fatal("trouble committing ticket: %s", g.zErrMsg);
}
if( needMod ){
moderation_table_create();
db_multi_exec(
| | | 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 |
int rid = content_put_ex(pTicket, 0, 0, 0, needMod);
if( rid==0 ){
fossil_fatal("trouble committing ticket: %s", g.zErrMsg);
}
if( needMod ){
moderation_table_create();
db_multi_exec(
"INSERT INTO modreq(objid, tktid) VALUES(%d,%Q)",
rid, zTktId
);
}else{
db_multi_exec("INSERT OR IGNORE INTO unsent VALUES(%d);", rid);
db_multi_exec("INSERT OR IGNORE INTO unclustered VALUES(%d);", rid);
}
manifest_crosslink_begin();
|
| ︙ | ︙ | |||
564 565 566 567 568 569 570 571 572 573 574 575 576 577 |
int *argl
){
char *zDate;
const char *zUuid;
int i;
int nJ = 0;
Blob tktchng, cksum;
login_verify_csrf_secret();
if( !captcha_is_correct() ){
@ <p class="generalError">Error: Incorrect security code.</p>
return TH_OK;
}
zUuid = (const char *)pUuid;
| > | 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 |
int *argl
){
char *zDate;
const char *zUuid;
int i;
int nJ = 0;
Blob tktchng, cksum;
int needMod;
login_verify_csrf_secret();
if( !captcha_is_correct() ){
@ <p class="generalError">Error: Incorrect security code.</p>
return TH_OK;
}
zUuid = (const char *)pUuid;
|
| ︙ | ︙ | |||
619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 |
blob_appendf(&tktchng, "U %F\n", login_name());
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
if( nJ==0 ){
blob_reset(&tktchng);
return TH_OK;
}
if( g.zPath[0]=='d' ){
/* If called from /debug_tktnew or /debug_tktedit... */
@ <font color="blue">
@ <p>Ticket artifact that would have been submitted:</p>
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
@ <hr /></font>
return TH_OK;
}else{
if( g.thTrace ){
Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
"}<br />\n",
blob_str(&tktchng));
}
| > > > | < | | 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 |
blob_appendf(&tktchng, "U %F\n", login_name());
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
if( nJ==0 ){
blob_reset(&tktchng);
return TH_OK;
}
needMod = ticket_need_moderation(0);
if( g.zPath[0]=='d' ){
const char *zNeedMod = needMod ? "required" : "skipped";
/* If called from /debug_tktnew or /debug_tktedit... */
@ <font color="blue">
@ <p>Ticket artifact that would have been submitted:</p>
@ <blockquote><pre>%h(blob_str(&tktchng))</pre></blockquote>
@ <blockquote><pre>Moderation would be %h(zNeedMod).</pre></blockquote>
@ <hr /></font>
return TH_OK;
}else{
if( g.thTrace ){
Th_Trace("submit_ticket {\n<blockquote><pre>\n%h\n</pre></blockquote>\n"
"}<br />\n",
blob_str(&tktchng));
}
ticket_put(&tktchng, zUuid, needMod);
}
return ticket_change(zUuid);
}
/*
** WEBPAGE: tktnew
** WEBPAGE: debug_tktnew
**
|
| ︙ | ︙ | |||
826 827 828 829 830 831 832 |
style_submenu_element("Status", "Status",
"%s/info/%s", g.zTop, zUuid);
if( zType[0]=='c' ){
zTitle = mprintf("Check-Ins Associated With Ticket %h", zUuid);
}else{
zTitle = mprintf("Timeline Of Ticket %h", zUuid);
}
| | < | 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 |
style_submenu_element("Status", "Status",
"%s/info/%s", g.zTop, zUuid);
if( zType[0]=='c' ){
zTitle = mprintf("Check-Ins Associated With Ticket %h", zUuid);
}else{
zTitle = mprintf("Timeline Of Ticket %h", zUuid);
}
style_header("%z", zTitle);
sqlite3_snprintf(6, zGlobPattern, "%s", zUuid);
canonical16(zGlobPattern, strlen(zGlobPattern));
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid);
if( tagid==0 ){
@ No such ticket: %h(zUuid)
style_footer();
|
| ︙ | ︙ | |||
860 861 862 863 864 865 866 |
" AND '%s' GLOB (target||'*')"
" UNION SELECT attachid FROM attachment"
" WHERE target=%Q) "
"ORDER BY mtime DESC",
timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
);
}
| | < | 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 |
" AND '%s' GLOB (target||'*')"
" UNION SELECT attachid FROM attachment"
" WHERE target=%Q) "
"ORDER BY mtime DESC",
timeline_query_for_www(), tagid, zFullUuid, zFullUuid, zFullUuid
);
}
db_prepare(&q, "%z", zSQL/*safe-for-%s*/);
www_print_timeline(&q, TIMELINE_ARTID|TIMELINE_DISJOINT|TIMELINE_GRAPH,
0, 0, 0);
db_finalize(&q);
style_footer();
}
/*
|
| ︙ | ︙ | |||
898 899 900 901 902 903 904 |
if( P("plaintext")!=0 ){
style_submenu_element("Formatted", "Formatted",
"%R/tkthistory/%s", zUuid);
}else{
style_submenu_element("Plaintext", "Plaintext",
"%R/tkthistory/%s?plaintext", zUuid);
}
| | < | 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 |
if( P("plaintext")!=0 ){
style_submenu_element("Formatted", "Formatted",
"%R/tkthistory/%s", zUuid);
}else{
style_submenu_element("Plaintext", "Plaintext",
"%R/tkthistory/%s?plaintext", zUuid);
}
style_header("%z", zTitle);
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",zUuid);
if( tagid==0 ){
@ No such ticket: %h(zUuid)
style_footer();
return;
}
|
| ︙ | ︙ | |||
1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 | ** page in the gui is used. This has no effect in JSON mode. ** ** Instead of the report title its possible to use the report ** number. Using the special report number 0 list all columns, ** defined in the ticket table. ** ** %fossil ticket list fields ** ** list all fields, defined for ticket in the fossil repository ** ** %fossil ticket list reports ** ** list all ticket reports, defined in the fossil repository ** ** %fossil ticket set TICKETUUID (FIELD VALUE)+ ?-q|--quote? ** %fossil ticket change TICKETUUID (FIELD VALUE)+ ?-q|--quote? ** ** change ticket identified by TICKETUUID and set the value of | > > | 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 | ** page in the gui is used. This has no effect in JSON mode. ** ** Instead of the report title its possible to use the report ** number. Using the special report number 0 list all columns, ** defined in the ticket table. ** ** %fossil ticket list fields ** %fossil ticket ls fields ** ** list all fields, defined for ticket in the fossil repository ** ** %fossil ticket list reports ** %fossil ticket ls reports ** ** list all ticket reports, defined in the fossil repository ** ** %fossil ticket set TICKETUUID (FIELD VALUE)+ ?-q|--quote? ** %fossil ticket change TICKETUUID (FIELD VALUE)+ ?-q|--quote? ** ** change ticket identified by TICKETUUID and set the value of |
| ︙ | ︙ | |||
1121 1122 1123 1124 1125 1126 1127 |
usage("add|change|list|set|show|history");
}
n = strlen(g.argv[2]);
if( n==1 && g.argv[2][0]=='s' ){
/* set/show cannot be distinguished, so show the usage */
usage("add|change|list|set|show|history");
}
| | | 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 |
usage("add|change|list|set|show|history");
}
n = strlen(g.argv[2]);
if( n==1 && g.argv[2][0]=='s' ){
/* set/show cannot be distinguished, so show the usage */
usage("add|change|list|set|show|history");
}
if(( strncmp(g.argv[2],"list",n)==0 ) || ( strncmp(g.argv[2],"ls",n)==0 )){
if( g.argc==3 ){
usage("list fields|reports");
}else{
n = strlen(g.argv[3]);
if( !strncmp(g.argv[3],"fields",n) ){
/* simply show all field names */
int i;
|
| ︙ | ︙ | |||
1182 1183 1184 1185 1186 1187 1188 |
}else{
eCmd = set;
}
if( g.argc==3 ){
usage("set|change|history TICKETUUID");
}
zTktUuid = db_text(0,
| | | 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 |
}else{
eCmd = set;
}
if( g.argc==3 ){
usage("set|change|history TICKETUUID");
}
zTktUuid = db_text(0,
"SELECT tkt_uuid FROM ticket WHERE tkt_uuid GLOB '%q*'", g.argv[3]
);
if( !zTktUuid ){
fossil_fatal("unknown ticket: '%s'!",g.argv[3]);
}
i=4;
}else if( strncmp(g.argv[2],"add",n)==0 ){
eCmd = add;
|
| ︙ | ︙ | |||
1205 1206 1207 1208 1209 1210 1211 |
}
/* we just handle history separately here, does not get out */
if( eCmd==history ){
Stmt q;
int tagid;
| | | 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 |
}
/* we just handle history separately here, does not get out */
if( eCmd==history ){
Stmt q;
int tagid;
if( i != g.argc ){
fossil_fatal("no other parameters expected to %s!",g.argv[2]);
}
tagid = db_int(0, "SELECT tagid FROM tag WHERE tagname GLOB 'tkt-%q*'",
zTktUuid);
if( tagid==0 ){
fossil_fatal("no such ticket %h", zTktUuid);
}
|
| ︙ | ︙ | |||
1261 1262 1263 1264 1265 1266 1267 |
fossil_print(" Append to ");
z++;
}else{
fossil_print(" Change ");
}
fossil_print("%h: ",z);
if( blob_size(&val)>50 || contains_newline(&val)) {
| | | | 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 |
fossil_print(" Append to ");
z++;
}else{
fossil_print(" Change ");
}
fossil_print("%h: ",z);
if( blob_size(&val)>50 || contains_newline(&val)) {
fossil_print("\n ");
comment_print(blob_str(&val),0,4,-1,g.comFmtFlags);
}else{
fossil_print("%s\n",blob_str(&val));
}
blob_reset(&val);
}
}
manifest_destroy(pTicket);
|
| ︙ | ︙ | |||
1297 1298 1299 1300 1301 1302 1303 |
}
zFValue = g.argv[i++];
if( tktEncoding == tktFossilize ){
zFValue=mprintf("%s",zFValue);
defossilize(zFValue);
}
append = (zFName[0] == '+');
| | | | | | | | | 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 |
}
zFValue = g.argv[i++];
if( tktEncoding == tktFossilize ){
zFValue=mprintf("%s",zFValue);
defossilize(zFValue);
}
append = (zFName[0] == '+');
if( append ){
zFName++;
}
j = fieldId(zFName);
if( j == -1 ){
fossil_fatal("unknown field name '%s'!",zFName);
}else{
if( append ){
aField[j].zAppend = zFValue;
}else{
aField[j].zValue = zFValue;
}
}
}
/* now add the needed artifacts to the repository */
blob_zero(&tktchng);
/* add the time to the ticket manifest */
blob_appendf(&tktchng, "D %s\n", zDate);
/* append defined elements */
for(i=0; i<nField; i++){
char *zValue = 0;
char *zPfx;
if( aField[i].zAppend && aField[i].zAppend[0] ){
zPfx = " +";
zValue = aField[i].zAppend;
}else if( aField[i].zValue && aField[i].zValue[0] ){
zPfx = " ";
zValue = aField[i].zValue;
}else{
continue;
}
if( memcmp(aField[i].zName, "private_", 8)==0 ){
zValue = db_conceal(zValue, strlen(zValue));
blob_appendf(&tktchng, "J%s%s %s\n", zPfx, aField[i].zName, zValue);
}else{
blob_appendf(&tktchng, "J%s%s %#F\n", zPfx,
aField[i].zName, strlen(zValue), zValue);
}
}
blob_appendf(&tktchng, "K %s\n", zTktUuid);
blob_appendf(&tktchng, "U %F\n", zUser);
md5sum_blob(&tktchng, &cksum);
blob_appendf(&tktchng, "Z %b\n", &cksum);
if( ticket_put(&tktchng, zTktUuid, ticket_need_moderation(1)) ){
fossil_fatal("%s\n", g.zErrMsg);
}else{
fossil_print("ticket %s succeeded for %s\n",
(eCmd==set?"set":"add"),zTktUuid);
}
}
}
}
|
Changes to src/tktsetup.c.
| ︙ | ︙ | |||
433 434 435 436 437 438 439 | ); } static const char zDefaultView[] = @ <table cellpadding="5"> @ <tr><td class="tktDspLabel">Ticket UUID:</td> @ <th1> | > | | | > > > > | > > > > | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
);
}
static const char zDefaultView[] =
@ <table cellpadding="5">
@ <tr><td class="tktDspLabel">Ticket UUID:</td>
@ <th1>
@ if {[info exists tkt_uuid]} {
@ if {[hascap s]} {
@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid "
@ html "($tkt_id)</td></tr>\n"
@ } else {
@ html "<td class='tktDspValue' colspan='3'>$tkt_uuid</td></tr>\n"
@ }
@ } else {
@ if {[hascap s]} {
@ html "<td class='tktDspValue' colspan='3'>Deleted "
@ html "(0)</td></tr>\n"
@ } else {
@ html "<td class='tktDspValue' colspan='3'>Deleted</td></tr>\n"
@ }
@ }
@ </th1>
@ <tr><td class="tktDspLabel">Title:</td>
@ <td class="tktDspValue" colspan="3">
@ $<title>
@ </td></tr>
@ <tr><td class="tktDspLabel">Status:</td><td class="tktDspValue">
|
| ︙ | ︙ | |||
463 464 465 466 467 468 469 | @ <tr><td class="tktDspLabel">Subsystem:</td><td class="tktDspValue"> @ $<subsystem> @ </td> @ <td class="tktDspLabel">Resolution:</td><td class="tktDspValue"> @ $<resolution> @ </td></tr> @ <tr><td class="tktDspLabel">Last Modified:</td><td class="tktDspValue"> | > > | > > | > | | | | | | | | > | | 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 |
@ <tr><td class="tktDspLabel">Subsystem:</td><td class="tktDspValue">
@ $<subsystem>
@ </td>
@ <td class="tktDspLabel">Resolution:</td><td class="tktDspValue">
@ $<resolution>
@ </td></tr>
@ <tr><td class="tktDspLabel">Last Modified:</td><td class="tktDspValue">
@ <th1>
@ if {[info exists tkt_datetime]} {
@ html $tkt_datetime
@ }
@ </th1>
@ </td>
@ <th1>enable_output [hascap e]</th1>
@ <td class="tktDspLabel">Contact:</td><td class="tktDspValue">
@ $<private_contact>
@ </td>
@ <th1>enable_output 1</th1>
@ </tr>
@ <tr><td class="tktDspLabel">Version Found In:</td>
@ <td colspan="3" valign="top" class="tktDspValue">
@ $<foundin>
@ </td></tr>
@
@ <th1>
@ if {[info exists comment]} {
@ if {[string length $comment]>10} {
@ html {
@ <tr><td class="tktDspLabel">Description:</td></tr>
@ <tr><td colspan="5" class="tktDspValue">
@ }
@ if {[info exists plaintext]} {
@ set r [randhex]
@ wiki "<verbatim-$r links>\n$comment\n</verbatim-$r>"
@ } else {
@ wiki $comment
@ }
@ }
@ }
@ set seenRow 0
@ set alwaysPlaintext [info exists plaintext]
@ query {SELECT datetime(tkt_mtime) AS xdate, login AS xlogin,
@ mimetype as xmimetype, icomment AS xcomment,
@ username AS xusername
|
| ︙ | ︙ |
Changes to src/translate.c.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 | ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** | | | | | | 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 | ** ** Author contact information: ** drh@hwaci.com ** http://www.hwaci.com/drh/ ** ******************************************************************************* ** ** SYNOPSIS: ** ** Input lines that begin with the "@" character are translated into ** either cgi_printf() statements or string literals and the ** translated code is written on standard output. ** ** The problem this program is attempt to solve is as follows: When ** writing CGI programs in C, we typically want to output a lot of HTML ** text to standard output. In pure C code, this involves doing a ** printf() with a big string containing all that text. But we have ** to insert special codes (ex: \n and \") for many common characters, ** which interferes with the readability of the HTML. ** ** This tool allows us to put raw HTML, without the special codes, in ** the middle of a C program. This program then translates the text ** into standard C by inserting all necessary backslashes and other ** punctuation. ** ** Enhancement #1: ** ** If the last non-whitespace character prior to the first "@" of a ** @-block is "=" or "," then the @-block is a string literal initializer ** rather than text that is to be output via cgi_printf(). Render it ** as such. ** ** Enhancement #2: ** ** Comments of the form: "/* @-comment: CC" cause CC to become a ** comment character for the @-substitution. Typical values for CC are ** "--" (for SQL text) or "#" (for TCL script) or "//" (for C++ code). ** Lines of subsequent @-blocks that begin with CC are omitted from the ** output. ** */ #include <stdio.h> #include <ctype.h> #include <stdlib.h> #include <string.h> /* |
| ︙ | ︙ | |||
120 121 122 123 124 125 126 |
i++;
if( isspace(zLine[i]) ){ i++; }
indent = i - 2;
if( indent<0 ) indent = 0;
omitline = 0;
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
| | | | 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 |
i++;
if( isspace(zLine[i]) ){ i++; }
indent = i - 2;
if( indent<0 ) indent = 0;
omitline = 0;
for(j=0; zLine[i] && zLine[i]!='\r' && zLine[i]!='\n'; i++){
if( zLine[i]==c1 && (c2==' ' || zLine[i+1]==c2) ){
omitline = 1; break;
}
if( zLine[i]=='"' || zLine[i]=='\\' ){ zOut[j++] = '\\'; }
zOut[j++] = zLine[i];
}
while( j>0 && isspace(zOut[j-1]) ){ j--; }
zOut[j] = 0;
if( j<=0 && omitline ){
fprintf(out,"\n");
}else{
fprintf(out,"%*s\"%s\\n\"\n",indent, "", zOut);
}
}else{
/* Otherwise (if the last non-whitespace was not '=') then generate
** a cgi_printf() statement whose format is the text following the '@'.
** Substrings of the form "%C(...)" (where C is any sequence of
** characters other than \000 and '(') will put "%C" in the
** format and add the "(...)" as an argument to the cgi_printf call.
*/
int indent;
int nC;
char c;
i++;
|
| ︙ | ︙ | |||
172 173 174 175 176 177 178 |
zOut[j] = 0;
if( !inPrint ){
fprintf(out,"%*scgi_printf(\"%s\\n\"",indent-2,"", zOut);
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s\\n\"",indent+5, "", zOut);
}
| | | 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
zOut[j] = 0;
if( !inPrint ){
fprintf(out,"%*scgi_printf(\"%s\\n\"",indent-2,"", zOut);
inPrint = 1;
}else{
fprintf(out,"\n%*s\"%s\\n\"",indent+5, "", zOut);
}
}
}
}
int main(int argc, char **argv){
if( argc==2 ){
char *arg;
FILE *in = fopen(argv[1], "r");
|
| ︙ | ︙ |
Changes to src/undo.c.
| ︙ | ︙ | |||
141 142 143 144 145 146 147 |
"CREATE TEMP TABLE undo_vmerge_2 AS SELECT * FROM vmerge;"
"DELETE FROM vmerge;"
"INSERT INTO vmerge SELECT * FROM undo_vmerge;"
"DELETE FROM undo_vmerge;"
"INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
"DROP TABLE undo_vmerge_2;"
);
| | > | 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
"CREATE TEMP TABLE undo_vmerge_2 AS SELECT * FROM vmerge;"
"DELETE FROM vmerge;"
"INSERT INTO vmerge SELECT * FROM undo_vmerge;"
"DELETE FROM undo_vmerge;"
"INSERT INTO undo_vmerge SELECT * FROM undo_vmerge_2;"
"DROP TABLE undo_vmerge_2;"
);
if(db_exists("SELECT 1 FROM \"%w\".sqlite_master"
" WHERE name='undo_stash'", zDb) ){
if( redoFlag ){
db_multi_exec(
"DELETE FROM stash WHERE stashid IN (SELECT stashid FROM undo_stash);"
"DELETE FROM stashfile"
" WHERE stashid NOT IN (SELECT stashid FROM stash);"
);
}else{
|
| ︙ | ︙ | |||
172 173 174 175 176 177 178 |
static const char zSql[] =
@ DROP TABLE IF EXISTS undo;
@ DROP TABLE IF EXISTS undo_vfile;
@ DROP TABLE IF EXISTS undo_vmerge;
@ DROP TABLE IF EXISTS undo_stash;
@ DROP TABLE IF EXISTS undo_stashfile;
;
| | | 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
static const char zSql[] =
@ DROP TABLE IF EXISTS undo;
@ DROP TABLE IF EXISTS undo_vfile;
@ DROP TABLE IF EXISTS undo_vmerge;
@ DROP TABLE IF EXISTS undo_stash;
@ DROP TABLE IF EXISTS undo_stashfile;
;
db_multi_exec(zSql /*works-like:""*/);
db_lset_int("undo_available", 0);
db_lset_int("undo_checkout", 0);
}
/*
** The following variable stores the original command-line of the
** command that is a candidate to be undone.
|
| ︙ | ︙ | |||
217 218 219 220 221 222 223 |
/*
** Begin capturing a snapshot that can be undone.
*/
void undo_begin(void){
int cid;
const char *zDb = db_name("localdb");
static const char zSql[] =
| | | | | | 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 |
/*
** Begin capturing a snapshot that can be undone.
*/
void undo_begin(void){
int cid;
const char *zDb = db_name("localdb");
static const char zSql[] =
@ CREATE TABLE "%w".undo(
@ pathname TEXT UNIQUE, -- Name of the file
@ redoflag BOOLEAN, -- 0 for undoable. 1 for redoable
@ existsflag BOOLEAN, -- True if the file exists
@ isExe BOOLEAN, -- True if the file is executable
@ isLink BOOLEAN, -- True if the file is symlink
@ content BLOB -- Saved content
@ );
@ CREATE TABLE "%w".undo_vfile AS SELECT * FROM vfile;
@ CREATE TABLE "%w".undo_vmerge AS SELECT * FROM vmerge;
;
if( undoDisable ) return;
undo_reset();
db_multi_exec(zSql/*works-like:"%w,%w,%w"*/, zDb, zDb, zDb);
cid = db_lget_int("checkout", 0);
db_lset_int("undo_checkout", cid);
db_lset_int("undo_available", 1);
db_lset("undo_cmdline", undoCmd);
undoActive = 1;
}
|
| ︙ | ︙ | |||
299 300 301 302 303 304 305 |
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
db_multi_exec(
| | | | 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
/*
** Make the current state of stashid undoable.
*/
void undo_save_stash(int stashid){
const char *zDb = db_name("localdb");
db_multi_exec(
"CREATE TABLE IF NOT EXISTS \"%w\".undo_stash"
" AS SELECT * FROM stash WHERE 0;"
"INSERT INTO undo_stash"
" SELECT * FROM stash WHERE stashid=%d;",
zDb, stashid
);
db_multi_exec(
"CREATE TABLE IF NOT EXISTS \"%w\".undo_stashfile"
" AS SELECT * FROM stashfile WHERE 0;"
"INSERT INTO undo_stashfile"
" SELECT * FROM stashfile WHERE stashid=%d;",
zDb, stashid
);
}
|
| ︙ | ︙ |
Changes to src/unicode.c.
| ︙ | ︙ | |||
206 207 208 209 210 211 212 |
iLo = iTest+1;
}else{
iHi = iTest-1;
}
}
assert( key>=aDia[iRes] );
return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
| < > | 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
iLo = iTest+1;
}else{
iHi = iTest-1;
}
}
assert( key>=aDia[iRes] );
return ((c > (aDia[iRes]>>3) + (aDia[iRes]&0x07)) ? c : (int)aChar[iRes]);
}
/*
** Return true if the argument interpreted as a unicode codepoint
** is a diacritical modifier character.
*/
int unicode_is_diacritic(int c){
|
| ︙ | ︙ |
Changes to src/update.c.
| ︙ | ︙ | |||
60 61 62 63 64 65 66 | } /* ** COMMAND: update ** ** Usage: %fossil update ?OPTIONS? ?VERSION? ?FILES...? ** | | | | | | | | > | | | | > > > > > | | | | | | 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 | } /* ** COMMAND: update ** ** Usage: %fossil update ?OPTIONS? ?VERSION? ?FILES...? ** ** Change the version of the current checkout to VERSION. Any ** uncommitted changes are retained and applied to the new checkout. ** ** The VERSION argument can be a specific version or tag or branch ** name. If the VERSION argument is omitted, then the leaf of the ** subtree that begins at the current version is used, if there is ** only a single leaf. VERSION can also be "current" to select the ** leaf of the current version or "latest" to select the most recent ** check-in. ** ** If one or more FILES are listed after the VERSION then only the ** named files are candidates to be updated, and any updates to them ** will be treated as edits to the current version. Using a directory ** name for one of the FILES arguments is the same as using every ** subdirectory and file beneath that directory. ** ** If FILES is omitted, all files in the current checkout are subject ** to being updated and the version of the current checkout is changed ** to VERSION. Any uncommitted changes are retained and applied to the ** new checkout. ** ** The -n or --dry-run option causes this command to do a "dry run". ** It prints out what would have happened but does not actually make ** any changes to the current checkout or the repository. ** ** The -v or --verbose option prints status information about ** unchanged files in addition to those file that actually do change. ** ** Options: ** --case-sensitive <BOOL> override case-sensitive setting ** --debug print debug information on stdout ** --latest acceptable in place of VERSION, update to latest version ** --force-missing force update if missing content after sync ** -n|--dry-run If given, display instead of run actions |
| ︙ | ︙ | |||
136 137 138 139 140 141 142 |
if( !dryRunFlag ){
dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */
}
verboseFlag = find_option("verbose","v",0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
debugFlag = find_option("debug",0,0)!=0;
setmtimeFlag = find_option("setmtime",0,0)!=0;
| | > > > | 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 |
if( !dryRunFlag ){
dryRunFlag = find_option("nochange",0,0)!=0; /* deprecated */
}
verboseFlag = find_option("verbose","v",0)!=0;
forceMissingFlag = find_option("force-missing",0,0)!=0;
debugFlag = find_option("debug",0,0)!=0;
setmtimeFlag = find_option("setmtime",0,0)!=0;
/* We should be done with options.. */
verify_all_options();
db_must_be_within_tree();
vid = db_lget_int("checkout", 0);
user_select();
if( !dryRunFlag && !internalUpdate ){
if( autosync_loop(SYNC_PULL + SYNC_VERBOSE*verboseFlag,
db_get_int("autosync-tries", 1)) ){
fossil_fatal("Cannot proceed with update");
|
| ︙ | ︙ | |||
259 260 261 262 263 264 265 |
" FROM vfile WHERE vid=%d",
vid
);
/* Compute file name changes on V->T. Record name changes in files that
** have changed locally.
*/
| > | | | | | | | | | | | > | 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 |
" FROM vfile WHERE vid=%d",
vid
);
/* Compute file name changes on V->T. Record name changes in files that
** have changed locally.
*/
if( vid ){
find_filename_changes(vid, tid, 1, &nChng, &aChng, debugFlag ? "V->T": 0);
if( nChng ){
for(i=0; i<nChng; i++){
db_multi_exec(
"UPDATE fv"
" SET fnt=(SELECT name FROM filename WHERE fnid=%d)"
" WHERE fn=(SELECT name FROM filename WHERE fnid=%d) AND chnged",
aChng[i*2+1], aChng[i*2]
);
}
fossil_free(aChng);
}
}
/* Add files found in the target version T but missing from the current
** version V.
*/
db_multi_exec(
"INSERT OR IGNORE INTO fv(fn,fnt,idv,idt,ridv,ridt,isexe,chnged)"
|
| ︙ | ︙ | |||
344 345 346 347 348 349 350 |
blob_zero(&sql);
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
zSep = "";
for(i=3; i<g.argc; i++){
file_tree_name(g.argv[i], &treename, 1);
if( file_wd_isdir(g.argv[i])==1 ){
if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
| | > | > | | 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 |
blob_zero(&sql);
blob_append(&sql, "DELETE FROM fv WHERE ", -1);
zSep = "";
for(i=3; i<g.argc; i++){
file_tree_name(g.argv[i], &treename, 1);
if( file_wd_isdir(g.argv[i])==1 ){
if( blob_size(&treename) != 1 || blob_str(&treename)[0] != '.' ){
blob_append_sql(&sql, "%sfn NOT GLOB '%q/*' ",
zSep /*safe-for-%s*/, blob_str(&treename));
}else{
blob_reset(&sql);
break;
}
}else{
blob_append_sql(&sql, "%sfn<>%Q ",
zSep /*safe-for-%s*/, blob_str(&treename));
}
zSep = "AND ";
blob_reset(&treename);
}
db_multi_exec("%s", blob_sql_text(&sql));
blob_reset(&sql);
}
/*
** Alter the content of the checkout so that it conforms with the
** target
*/
|
| ︙ | ︙ |
Changes to src/url.c.
| ︙ | ︙ | |||
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 |
zFile = mprintf("%s", zUrl);
}else if( file_isdir(zUrl)==1 ){
zFile = mprintf("%s/FOSSIL", zUrl);
if( file_isfile(zFile) ){
pUrlData->isFile = 1;
}else{
free(zFile);
fossil_fatal("unknown repository: %s", zUrl);
}
}else{
fossil_fatal("unknown repository: %s", zUrl);
}
if( urlFlags ) pUrlData->flags = urlFlags;
if( pUrlData->isFile ){
Blob cfile;
dehttpize(zFile);
file_canonical_name(zFile, &cfile, 0);
free(zFile);
pUrlData->protocol = "file";
pUrlData->path = "";
pUrlData->name = mprintf("%b", &cfile);
pUrlData->canonical = mprintf("file://%T", pUrlData->name);
blob_reset(&cfile);
}else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){
url_prompt_for_password_local(pUrlData);
| > > | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 |
zFile = mprintf("%s", zUrl);
}else if( file_isdir(zUrl)==1 ){
zFile = mprintf("%s/FOSSIL", zUrl);
if( file_isfile(zFile) ){
pUrlData->isFile = 1;
}else{
free(zFile);
zFile = 0;
fossil_fatal("unknown repository: %s", zUrl);
}
}else{
fossil_fatal("unknown repository: %s", zUrl);
}
if( urlFlags ) pUrlData->flags = urlFlags;
if( pUrlData->isFile ){
Blob cfile;
dehttpize(zFile);
file_canonical_name(zFile, &cfile, 0);
free(zFile);
zFile = 0;
pUrlData->protocol = "file";
pUrlData->path = "";
pUrlData->name = mprintf("%b", &cfile);
pUrlData->canonical = mprintf("file://%T", pUrlData->name);
blob_reset(&cfile);
}else if( pUrlData->user!=0 && pUrlData->passwd==0 && (urlFlags & URL_PROMPT_PW) ){
url_prompt_for_password_local(pUrlData);
|
| ︙ | ︙ |
Changes to src/user.c.
| ︙ | ︙ | |||
195 196 197 198 199 200 201 202 203 204 205 206 207 208 | ** ** %fossil user default ?USERNAME? ** ** Query or set the default user. The default user is the ** user for command-line interaction. ** ** %fossil user list ** ** List all users known to the repository ** ** %fossil user new ?USERNAME? ?CONTACT-INFO? ?PASSWORD? ** ** Create a new user in the repository. Users can never be ** deleted. They can be denied all access but they must continue | > | 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 | ** ** %fossil user default ?USERNAME? ** ** Query or set the default user. The default user is the ** user for command-line interaction. ** ** %fossil user list ** %fossil user ls ** ** List all users known to the repository ** ** %fossil user new ?USERNAME? ?CONTACT-INFO? ?PASSWORD? ** ** Create a new user in the repository. Users can never be ** deleted. They can be denied all access but they must continue |
| ︙ | ︙ | |||
259 260 261 262 263 264 265 |
}
if( g.localOpen ){
db_lset("default-user", g.argv[3]);
}else{
db_set("default-user", g.argv[3], 0);
}
}
| | | 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
}
if( g.localOpen ){
db_lset("default-user", g.argv[3]);
}else{
db_set("default-user", g.argv[3], 0);
}
}
}else if(( n>=2 && strncmp(g.argv[2],"list",n)==0 ) || ( n>=2 && strncmp(g.argv[2],"ls",n)==0 )){
Stmt q;
db_prepare(&q, "SELECT login, info FROM user ORDER BY login");
while( db_step(&q)==SQLITE_ROW ){
fossil_print("%-12s %s\n", db_column_text(&q, 0), db_column_text(&q, 1));
}
db_finalize(&q);
}else if( n>=2 && strncmp(g.argv[2],"password",2)==0 ){
|
| ︙ | ︙ | |||
448 449 450 451 452 453 454 |
"(SELECT rowid FROM accesslog ORDER BY rowid DESC"
" LIMIT -1 OFFSET 200)");
cgi_redirectf("%s/access_log?y=%d&n=%d", g.zTop, y, n);
return;
}
style_header("Access Log");
blob_zero(&sql);
| | | | | 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 |
"(SELECT rowid FROM accesslog ORDER BY rowid DESC"
" LIMIT -1 OFFSET 200)");
cgi_redirectf("%s/access_log?y=%d&n=%d", g.zTop, y, n);
return;
}
style_header("Access Log");
blob_zero(&sql);
blob_append_sql(&sql,
"SELECT uname, ipaddr, datetime(mtime%s), success"
" FROM accesslog", timeline_utc()
);
if( y==1 ){
blob_append(&sql, " WHERE success", -1);
}else if( y==2 ){
blob_append(&sql, " WHERE NOT success", -1);
}
blob_append_sql(&sql," ORDER BY rowid DESC LIMIT %d OFFSET %d", n+1, skip);
if( skip ){
style_submenu_element("Newer", "Newer entries",
"%s/access_log?o=%d&n=%d&y=%d", g.zTop, skip>=n ? skip-n : 0,
n, y);
}
rc = db_prepare_ignore_error(&q, "%s", blob_sql_text(&sql));
@ <center><table border="1" cellpadding="5">
@ <tr><th width="33%%">Date</th><th width="34%%">User</th>
@ <th width="33%%">IP Address</th></tr>
while( rc==SQLITE_OK && db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
const char *zIP = db_column_text(&q, 1);
const char *zDate = db_column_text(&q, 2);
|
| ︙ | ︙ |
Changes to src/utf8.c.
| ︙ | ︙ | |||
125 126 127 128 129 130 131 |
}
WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0);
pUtf = qUtf = zUtf;
while( *pUtf ) {
if( *pUtf == (char)0xef ){
wchar_t c = ((pUtf[1]&0x3f)<<6)|(pUtf[2]&0x3f);
/* Only really convert it when the resulting char is in range. */
| | | 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
}
WideCharToMultiByte(CP_UTF8, 0, zFilename, -1, zUtf, nByte, 0, 0);
pUtf = qUtf = zUtf;
while( *pUtf ) {
if( *pUtf == (char)0xef ){
wchar_t c = ((pUtf[1]&0x3f)<<6)|(pUtf[2]&0x3f);
/* Only really convert it when the resulting char is in range. */
if( c && ((c < ' ') || wcschr(L"\"*:<>?|", c)) ){
*qUtf++ = c; pUtf+=3; continue;
}
}
*qUtf++ = *pUtf++;
}
*qUtf = 0;
return zUtf;
|
| ︙ | ︙ | |||
239 240 241 242 243 244 245 |
/*
** In the remainder of the path, translate invalid characters to
** characters in the Unicode private use area. This is what makes
** Win32 fossil.exe work well in a Cygwin environment even when a
** filename contains characters which are invalid for Win32.
*/
while( *wUnicode != '\0' ){
| | | 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
/*
** In the remainder of the path, translate invalid characters to
** characters in the Unicode private use area. This is what makes
** Win32 fossil.exe work well in a Cygwin environment even when a
** filename contains characters which are invalid for Win32.
*/
while( *wUnicode != '\0' ){
if( (*wUnicode < ' ') || wcschr(L"\"*:<>?|", *wUnicode) ){
*wUnicode |= 0xF000;
}else if( *wUnicode == '/' ){
*wUnicode = '\\';
}
++wUnicode;
}
return zUnicode;
|
| ︙ | ︙ |
Changes to src/util.c.
| ︙ | ︙ | |||
76 77 78 79 80 81 82 83 84 85 86 87 88 89 | rc = _wsystem(zUnicode); fossil_unicode_free(zUnicode); free(zNewCmd); #else /* On unix, evaluate the command directly. */ if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd); rc = system(zOrigCmd); #endif return rc; } /* ** Like strcmp() except that it accepts NULL pointers. NULL sorts before | > > > > > > > > > | 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | rc = _wsystem(zUnicode); fossil_unicode_free(zUnicode); free(zNewCmd); #else /* On unix, evaluate the command directly. */ if( g.fSystemTrace ) fprintf(stderr, "SYSTEM: %s\n", zOrigCmd); /* Unix systems should never shell-out while processing an HTTP request, ** either via CGI, SCGI, or direct HTTP. The following assert verifies ** this. And the following assert proves that Fossil is not vulnerable ** to the ShellShock or BashDoor bug. */ assert( g.cgiOutput==0 ); /* The regular system() call works to get a shell on unix */ rc = system(zOrigCmd); #endif return rc; } /* ** Like strcmp() except that it accepts NULL pointers. NULL sorts before |
| ︙ | ︙ | |||
293 294 295 296 297 298 299 |
** Returns true (non-0) if the given timer ID (as returned from
** fossil_timer_start() is currently active.
*/
int fossil_timer_is_active( int timerId ){
if(timerId<1 || timerId>FOSSIL_TIMER_COUNT){
return 0;
}else{
| | | 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
** Returns true (non-0) if the given timer ID (as returned from
** fossil_timer_start() is currently active.
*/
int fossil_timer_is_active( int timerId ){
if(timerId<1 || timerId>FOSSIL_TIMER_COUNT){
return 0;
}else{
const int rc = fossilTimerList[timerId-1].id;
assert(!rc || (rc == timerId));
return fossilTimerList[timerId-1].id;
}
}
/*
** Return TRUE if fd is a valid open file descriptor. This only
|
| ︙ | ︙ | |||
315 316 317 318 319 320 321 | #endif } /* ** Returns TRUE if zSym is exactly UUID_SIZE bytes long and contains ** only lower-case ASCII hexadecimal values. */ | | | 324 325 326 327 328 329 330 331 332 333 334 335 |
#endif
}
/*
** Returns TRUE if zSym is exactly UUID_SIZE bytes long and contains
** only lower-case ASCII hexadecimal values.
*/
int fossil_is_uuid(const char *zSym){
return zSym
&& (UUID_SIZE==strlen(zSym))
&& validate16(zSym, UUID_SIZE);
}
|
Changes to src/vfile.c.
| ︙ | ︙ | |||
395 396 397 398 399 400 401 |
"baseline",
"merge",
"original",
"output",
};
int i, j, n;
| | | | 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 |
"baseline",
"merge",
"original",
"output",
};
int i, j, n;
if( sqlite3_strglob("ci-comment-????????????.txt", zName)==0 ) return 1;
for(; zName[0]!=0; zName++){
if( zName[0]=='/' && sqlite3_strglob("/ci-comment-????????????.txt", zName)==0 ){
return 1;
}
if( zName[0]!='-' ) continue;
for(i=0; i<sizeof(azTemp)/sizeof(azTemp[0]); i++){
n = (int)strlen(azTemp[i]);
if( memcmp(azTemp[i], zName+1, n) ) continue;
if( zName[n+1]==0 ) return 1;
|
| ︙ | ︙ |
Changes to src/wiki.c.
| ︙ | ︙ | |||
154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
}else{
@ <pre>
@ %h(blob_str(pWiki))
@ </pre>
}
}
/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
| > > > > > > > > > > > > > > > > > > > > > > | 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 |
}else{
@ <pre>
@ %h(blob_str(pWiki))
@ </pre>
}
}
/*
** Returns non-zero if moderation is required for wiki changes and wiki
** attachments.
*/
int wiki_need_moderation(
int localUser /* Are we being called for a local interactive user? */
){
/*
** If the FOSSIL_FORCE_WIKI_MODERATION variable is set, *ALL* changes for
** wiki pages will be required to go through moderation (even those performed
** by the local interactive user via the command line). This can be useful
** for local (or remote) testing of the moderation subsystem and its impact
** on the contents and status of wiki pages.
*/
if( fossil_getenv("FOSSIL_FORCE_WIKI_MODERATION")!=0 ){
return 1;
}
if( localUser ){
return 0;
}
return g.perm.ModWiki==0 && db_get_boolean("modreq-wiki",0)==1;
}
/*
** WEBPAGE: wiki
** URL: /wiki?name=PAGENAME
*/
void wiki_page(void){
char *zTag;
|
| ︙ | ︙ | |||
268 269 270 271 272 273 274 |
}
if( g.perm.Hyperlink ){
style_submenu_element("History", "History", "%s/whistory?name=%T",
g.zTop, zPageName);
}
}
style_set_current_page("%T?name=%T", g.zPath, zPageName);
| | | | | 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
}
if( g.perm.Hyperlink ){
style_submenu_element("History", "History", "%s/whistory?name=%T",
g.zTop, zPageName);
}
}
style_set_current_page("%T?name=%T", g.zPath, zPageName);
style_header("%s", zPageName);
blob_init(&wiki, zBody, -1);
wiki_render_by_mimetype(&wiki, zMimetype);
blob_reset(&wiki);
attachment_list(zPageName, "<hr /><h2>Attachments:</h2><ul>");
manifest_destroy(pWiki);
style_footer();
}
/*
** Write a wiki artifact into the repository
*/
static void wiki_put(Blob *pWiki, int parent, int needMod){
int nrid;
if( !needMod ){
nrid = content_put_ex(pWiki, 0, 0, 0, 0);
if( parent) content_deltify(parent, nrid, 0);
}else{
nrid = content_put_ex(pWiki, 0, 0, 0, 1);
moderation_table_create();
db_multi_exec("INSERT INTO modreq(objid) VALUES(%d)", nrid);
}
|
| ︙ | ︙ | |||
425 426 427 428 429 430 431 |
if( !login_is_nobody() ){
blob_appendf(&wiki, "U %F\n", login_name());
}
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 |
if( !login_is_nobody() ){
blob_appendf(&wiki, "U %F\n", login_name());
}
blob_appendf(&wiki, "W %d\n%s\n", strlen(zBody), zBody);
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
wiki_put(&wiki, 0, wiki_need_moderation(0));
}
db_end_transaction(0);
cgi_redirectf("wiki?name=%T", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%T", zPageName);
return;
|
| ︙ | ︙ | |||
625 626 627 628 629 630 631 |
Blob cksum;
Blob body;
Blob wiki;
Manifest *pWiki = 0;
blob_zero(&body);
if( isSandbox ){
| | | 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 |
Blob cksum;
Blob body;
Blob wiki;
Manifest *pWiki = 0;
blob_zero(&body);
if( isSandbox ){
blob_append(&body, db_get("sandbox",""), -1);
appendRemark(&body, zMimetype);
db_set("sandbox", blob_str(&body), 0);
}else{
login_verify_csrf_secret();
pWiki = manifest_get(rid, CFTYPE_WIKI, 0);
if( pWiki ){
blob_append(&body, pWiki->zWiki, -1);
|
| ︙ | ︙ | |||
656 657 658 659 660 661 662 |
blob_appendf(&wiki, "U %F\n", login_name());
}
appendRemark(&body, zMimetype);
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
| | | 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 |
blob_appendf(&wiki, "U %F\n", login_name());
}
appendRemark(&body, zMimetype);
blob_appendf(&wiki, "W %d\n%s\n", blob_size(&body), blob_str(&body));
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
wiki_put(&wiki, rid, wiki_need_moderation(0));
db_end_transaction(0);
}
cgi_redirectf("wiki?name=%T", zPageName);
}
if( P("cancel")!=0 ){
cgi_redirectf("wiki?name=%T", zPageName);
return;
|
| ︙ | ︙ | |||
722 723 724 725 726 727 728 |
** WEBPAGE: whistory
** URL: /whistory?name=PAGENAME
**
** Show the complete change history for a single wiki page.
*/
void whistory_page(void){
Stmt q;
| < < | < < | < < < | < < | 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
** WEBPAGE: whistory
** URL: /whistory?name=PAGENAME
**
** Show the complete change history for a single wiki page.
*/
void whistory_page(void){
Stmt q;
const char *zPageName;
login_check_credentials();
if( !g.perm.Hyperlink ){ login_needed(); return; }
zPageName = PD("name","");
style_header("History Of %s", zPageName);
db_prepare(&q, "%s AND event.objid IN "
" (SELECT rid FROM tagxref WHERE tagid="
"(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
" UNION SELECT attachid FROM attachment"
" WHERE target=%Q)"
"ORDER BY mtime DESC",
timeline_query_for_www(), zPageName, zPageName);
zWikiPageName = zPageName;
www_print_timeline(&q, TIMELINE_ARTID, 0, 0, wiki_history_extra);
db_finalize(&q);
style_footer();
}
/*
** WEBPAGE: wdiff
** URL: /whistory?name=PAGENAME&a=RID1&b=RID2
**
** Show the difference between two wiki pages.
*/
void wdiff_page(void){
int rid1, rid2;
const char *zPageName;
Manifest *pW1, *pW2 = 0;
Blob w1, w2, d;
u64 diffFlags;
login_check_credentials();
rid1 = atoi(PD("a","0"));
if( !g.perm.Hyperlink ){ login_needed(); return; }
if( rid1==0 ) fossil_redirect_home();
rid2 = atoi(PD("b","0"));
zPageName = PD("name","");
style_header("Changes To %s", zPageName);
if( rid2==0 ){
rid2 = db_int(0,
"SELECT objid FROM event JOIN tagxref ON objid=rid AND tagxref.tagid="
"(SELECT tagid FROM tag WHERE tagname='wiki-%q')"
" WHERE event.mtime<(SELECT mtime FROM event WHERE objid=%d)"
" ORDER BY event.mtime DESC LIMIT 1",
|
| ︙ | ︙ | |||
858 859 860 861 862 863 864 |
** WEBPAGE: wfind
**
** URL: /wfind?title=TITLE
** List all wiki pages whose titles contain the search text
*/
void wfind_page(void){
Stmt q;
| | | 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 |
** WEBPAGE: wfind
**
** URL: /wfind?title=TITLE
** List all wiki pages whose titles contain the search text
*/
void wfind_page(void){
Stmt q;
const char *zTitle;
login_check_credentials();
if( !g.perm.RdWiki ){ login_needed(); return; }
zTitle = PD("title","*");
style_header("Wiki Pages Found");
@ <ul>
db_prepare(&q,
"SELECT substr(tagname, 6, 1000) FROM tag WHERE tagname like 'wiki-%%%q%%'"
|
| ︙ | ︙ | |||
958 959 960 961 962 963 964 | ** ** The content of the new page is given by the blob pContent. ** ** zMimeType specifies the N-card for the wiki page. If it is 0, ** empty, or "text/x-fossil-wiki" (the default format) then it is ** ignored. */ | | | | | 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 |
**
** The content of the new page is given by the blob pContent.
**
** zMimeType specifies the N-card for the wiki page. If it is 0,
** empty, or "text/x-fossil-wiki" (the default format) then it is
** ignored.
*/
int wiki_cmd_commit(const char *zPageName, int isNew, Blob *pContent,
const char *zMimeType, int localUser){
Blob wiki; /* Wiki page content */
Blob cksum; /* wiki checksum */
int rid; /* artifact ID of parent page */
char *zDate; /* timestamp */
char *zUuid; /* uuid for rid */
rid = db_int(0,
"SELECT x.rid FROM tag t, tagxref x"
" WHERE x.tagid=t.tagid AND t.tagname='wiki-%q'"
" ORDER BY x.mtime DESC LIMIT 1",
zPageName
);
if( rid==0 && !isNew ){
|
| ︙ | ︙ | |||
1009 1010 1011 1012 1013 1014 1015 |
}
blob_appendf( &wiki, "W %d\n%s\n", blob_size(pContent),
blob_str(pContent) );
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
db_begin_transaction();
| | | 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 |
}
blob_appendf( &wiki, "W %d\n%s\n", blob_size(pContent),
blob_str(pContent) );
md5sum_blob(&wiki, &cksum);
blob_appendf(&wiki, "Z %b\n", &cksum);
blob_reset(&cksum);
db_begin_transaction();
wiki_put(&wiki, 0, wiki_need_moderation(localUser));
db_end_transaction(0);
return 1;
}
/*
** COMMAND: wiki*
**
|
| ︙ | ︙ | |||
1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 |
**
** %fossil wiki create PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
**
** Create a new wiki page with initial content taken from
** FILE or from standard input.
**
** %fossil wiki list
**
** Lists all wiki entries, one per line, ordered
** case-insensitively by name.
**
*/
void wiki_cmd(void){
int n;
db_find_and_open_repository(0, 0);
if( g.argc<3 ){
goto wiki_cmd_usage;
}
n = strlen(g.argv[2]);
if( n==0 ){
goto wiki_cmd_usage;
}
if( strncmp(g.argv[2],"export",n)==0 ){
| > | | | 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 |
**
** %fossil wiki create PAGENAME ?FILE? [-mimetype TEXT-FORMAT]
**
** Create a new wiki page with initial content taken from
** FILE or from standard input.
**
** %fossil wiki list
** %fossil wiki ls
**
** Lists all wiki entries, one per line, ordered
** case-insensitively by name.
**
*/
void wiki_cmd(void){
int n;
db_find_and_open_repository(0, 0);
if( g.argc<3 ){
goto wiki_cmd_usage;
}
n = strlen(g.argv[2]);
if( n==0 ){
goto wiki_cmd_usage;
}
if( strncmp(g.argv[2],"export",n)==0 ){
const char *zPageName; /* Name of the wiki page to export */
const char *zFile; /* Name of the output file (0=stdout) */
int rid; /* Artifact ID of the wiki page */
int i; /* Loop counter */
char *zBody = 0; /* Wiki page content */
Blob body; /* Wiki page content */
Manifest *pWiki = 0; /* Parsed wiki page content */
if( (g.argc!=4) && (g.argc!=5) ){
usage("export PAGENAME ?FILE?");
|
| ︙ | ︙ | |||
1089 1090 1091 1092 1093 1094 1095 |
blob_append(&body, "\n", 1);
blob_write_to_file(&body, zFile);
blob_reset(&body);
manifest_destroy(pWiki);
return;
}else if( strncmp(g.argv[2],"commit",n)==0
|| strncmp(g.argv[2],"create",n)==0 ){
| | | | 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 |
blob_append(&body, "\n", 1);
blob_write_to_file(&body, zFile);
blob_reset(&body);
manifest_destroy(pWiki);
return;
}else if( strncmp(g.argv[2],"commit",n)==0
|| strncmp(g.argv[2],"create",n)==0 ){
const char *zPageName; /* page name */
Blob content; /* Input content */
int rid;
Manifest *pWiki = 0; /* Parsed wiki page content */
const char *zMimeType = find_option("mimetype", "M", 1);
if( g.argc!=4 && g.argc!=5 ){
usage("commit|create PAGENAME ?FILE? [-mimetype TEXT-FORMAT]");
}
zPageName = g.argv[3];
if( g.argc==4 ){
blob_read_from_channel(&content, stdin, -1);
}else{
|
| ︙ | ︙ | |||
1116 1117 1118 1119 1120 1121 1122 |
);
if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0
&& (pWiki->zMimetype && *pWiki->zMimetype)){
zMimeType = pWiki->zMimetype;
}
}
if( g.argv[2][1]=='r' ){
| | | | | 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 |
);
if(rid>0 && (pWiki = manifest_get(rid, CFTYPE_WIKI, 0))!=0
&& (pWiki->zMimetype && *pWiki->zMimetype)){
zMimeType = pWiki->zMimetype;
}
}
if( g.argv[2][1]=='r' ){
wiki_cmd_commit(zPageName, 1, &content, zMimeType, 1);
fossil_print("Created new wiki page %s.\n", zPageName);
}else{
wiki_cmd_commit(zPageName, 0, &content, zMimeType, 1);
fossil_print("Updated wiki page %s.\n", zPageName);
}
manifest_destroy(pWiki);
blob_reset(&content);
}else if( strncmp(g.argv[2],"delete",n)==0 ){
if( g.argc!=5 ){
usage("delete PAGENAME");
}
fossil_fatal("delete not yet implemented.");
}else if(( strncmp(g.argv[2],"list",n)==0 ) || ( strncmp(g.argv[2],"ls",n)==0 )){
Stmt q;
db_prepare(&q,
"SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
" ORDER BY lower(tagname) /*sort*/"
);
while( db_step(&q)==SQLITE_ROW ){
const char *zName = db_column_text(&q, 0);
|
| ︙ | ︙ |
Changes to src/wikiformat.c.
| ︙ | ︙ | |||
1044 1045 1046 1047 1048 1049 1050 |
/*
** Begin a new paragraph if that something that is needed.
*/
static void startAutoParagraph(Renderer *p){
if( p->wantAutoParagraph==0 ) return;
if( p->state & WIKI_LINKSONLY ) return;
if( p->wikiList==MARKUP_OL || p->wikiList==MARKUP_UL ) return;
| | | 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 |
/*
** Begin a new paragraph if that something that is needed.
*/
static void startAutoParagraph(Renderer *p){
if( p->wantAutoParagraph==0 ) return;
if( p->state & WIKI_LINKSONLY ) return;
if( p->wikiList==MARKUP_OL || p->wikiList==MARKUP_UL ) return;
blob_append(p->pOut, "<p>", -1);
p->wantAutoParagraph = 0;
p->inAutoParagraph = 1;
}
/*
** End a paragraph if we are in one.
*/
|
| ︙ | ︙ | |||
1119 1120 1121 1122 1123 1124 1125 |
memcpy(zUpper, zLower, n+1);
zUpper[n-1]++;
if( once ){
const char *zClosedExpr = db_get("ticket-closed-expr", "status='Closed'");
db_static_prepare(&q,
"SELECT %s FROM ticket "
" WHERE tkt_uuid>=:lwr AND tkt_uuid<:upr",
| | | 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 |
memcpy(zUpper, zLower, n+1);
zUpper[n-1]++;
if( once ){
const char *zClosedExpr = db_get("ticket-closed-expr", "status='Closed'");
db_static_prepare(&q,
"SELECT %s FROM ticket "
" WHERE tkt_uuid>=:lwr AND tkt_uuid<:upr",
zClosedExpr /*safe-for-%s*/
);
once = 0;
}
db_bind_text(&q, ":lwr", zLower);
db_bind_text(&q, ":upr", zUpper);
if( db_step(&q)==SQLITE_ROW ){
rc = 1;
|
| ︙ | ︙ | |||
1241 1242 1243 1244 1245 1246 1247 |
zTerm = "]";
}
}
}else if( !in_this_repo(zTarget) ){
if( (p->state & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){
zTerm = "";
}else{
| | | 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 |
zTerm = "]";
}
}
}else if( !in_this_repo(zTarget) ){
if( (p->state & (WIKI_LINKSONLY|WIKI_NOBADLINKS))!=0 ){
zTerm = "";
}else{
blob_appendf(p->pOut, "<span class=\"brokenlink\">[");
zTerm = "]</span>";
}
}else if( g.perm.Hyperlink ){
blob_appendf(p->pOut, "%z[",href("%R/info/%s", zTarget));
zTerm = "]</a>";
}
}else if( strlen(zTarget)>=10 && fossil_isdigit(zTarget[0]) && zTarget[4]=='-'
|
| ︙ | ︙ | |||
1326 1327 1328 1329 1330 1331 1332 |
blob_append(p->pOut, " ", -1);
}else{
if( p->wikiList ){
popStackToTag(p, p->wikiList);
p->wikiList = 0;
}
endAutoParagraph(p);
| | | 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 |
blob_append(p->pOut, " ", -1);
}else{
if( p->wikiList ){
popStackToTag(p, p->wikiList);
p->wikiList = 0;
}
endAutoParagraph(p);
blob_append(p->pOut, "\n\n", 1);
p->wantAutoParagraph = 1;
}
p->state |= AT_PARAGRAPH|AT_NEWLINE;
break;
}
case TOKEN_NEWLINE: {
blob_append(p->pOut, "\n", 1);
|
| ︙ | ︙ |
Changes to src/winhttp.c.
| ︙ | ︙ | |||
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
** HTTP request.
*/
typedef struct HttpRequest HttpRequest;
struct HttpRequest {
int id; /* ID counter */
SOCKET s; /* Socket on which to receive data */
SOCKADDR_IN addr; /* Address from which data is coming */
const char *zOptions; /* --notfound and/or --localauth options */
};
/*
** Prefix for a temporary file.
*/
static char *zTempPrefix;
| > | 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
** HTTP request.
*/
typedef struct HttpRequest HttpRequest;
struct HttpRequest {
int id; /* ID counter */
SOCKET s; /* Socket on which to receive data */
SOCKADDR_IN addr; /* Address from which data is coming */
int flags; /* Flags passed to win32_http_server() */
const char *zOptions; /* --notfound and/or --localauth options */
};
/*
** Prefix for a temporary file.
*/
static char *zTempPrefix;
|
| ︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
return atoi(&zHdr[17]);
}
}
zHdr++;
}
return 0;
}
/*
** Process a single incoming HTTP request.
*/
static void win32_http_request(void *pAppData){
HttpRequest *p = (HttpRequest*)pAppData;
FILE *in = 0, *out = 0;
| > > > > > > > > > > > | 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 |
return atoi(&zHdr[17]);
}
}
zHdr++;
}
return 0;
}
/*
** Issue a fatal error.
*/
static NORETURN void winhttp_fatal(
const char *zOp,
const char *zService,
const char *zErr
){
fossil_fatal("unable to %s service '%s': %s", zOp, zService, zErr);
}
/*
** Process a single incoming HTTP request.
*/
static void win32_http_request(void *pAppData){
HttpRequest *p = (HttpRequest*)pAppData;
FILE *in = 0, *out = 0;
|
| ︙ | ︙ | |||
109 110 111 112 113 114 115 |
}else{
break;
}
wanted -= got;
}
fclose(out);
out = 0;
| > > > > > > > | | > > > > | | > | 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 |
}else{
break;
}
wanted -= got;
}
fclose(out);
out = 0;
/*
** The repository name is only needed if there was no open checkout. This
** is designed to allow the open checkout for the interactive user to work
** with the local Fossil server started via the "ui" command.
*/
if( (p->flags & HTTP_SERVER_HAD_CHECKOUT)==0 ){
assert( g.zRepositoryName && g.zRepositoryName[0] );
sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s\n%s",
get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
g.zRepositoryName
);
}else{
sqlite3_snprintf(sizeof(zCmd), zCmd, "%s%s\n%s\n%s",
get_utf8_bom(0), zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr)
);
}
out = fossil_fopen(zCmdFName, "wb");
if( out==0 ) goto end_request;
fwrite(zCmd, 1, strlen(zCmd), out);
fclose(out);
sqlite3_snprintf(sizeof(zCmd), zCmd, "\"%s\" http -args \"%s\" --nossl%s",
g.nameOfExe, zCmdFName, p->zOptions
|
| ︙ | ︙ | |||
178 179 180 181 182 183 184 185 |
got = recv(p->s, zHdr, wanted<sizeof(zHdr) ? wanted : sizeof(zHdr), 0);
if( got<=0 ) break;
fwrite(zHdr, 1, got, out);
wanted += got;
}
fclose(out);
out = 0;
sqlite3_snprintf(sizeof(zCmd), zCmd,
| > | | | | 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
got = recv(p->s, zHdr, wanted<sizeof(zHdr) ? wanted : sizeof(zHdr), 0);
if( got<=0 ) break;
fwrite(zHdr, 1, got, out);
wanted += got;
}
fclose(out);
out = 0;
assert( g.zRepositoryName && g.zRepositoryName[0] );
sqlite3_snprintf(sizeof(zCmd), zCmd,
"\"%s\" http \"%s\" \"%s\" %s \"%s\" --scgi --nossl%s",
g.nameOfExe, zRequestFName, zReplyFName, inet_ntoa(p->addr.sin_addr),
g.zRepositoryName, p->zOptions
);
fossil_system(zCmd);
in = fossil_fopen(zReplyFName, "rb");
if( in ){
while( (got = fread(zHdr, 1, sizeof(zHdr), in))>0 ){
send(p->s, zHdr, got, 0);
}
|
| ︙ | ︙ | |||
281 282 283 284 285 286 287 |
fossil_fatal("unable to get path to the temporary directory.");
}
zTempPrefix = mprintf("%sfossil_server_P%d_",
fossil_unicode_to_utf8(zTmpPath), iPort);
fossil_print("Listening for %s requests on TCP port %d\n",
(flags&HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
if( zBrowser ){
| | | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
fossil_fatal("unable to get path to the temporary directory.");
}
zTempPrefix = mprintf("%sfossil_server_P%d_",
fossil_unicode_to_utf8(zTmpPath), iPort);
fossil_print("Listening for %s requests on TCP port %d\n",
(flags&HTTP_SERVER_SCGI)!=0?"SCGI":"HTTP", iPort);
if( zBrowser ){
zBrowser = mprintf(zBrowser /*works-like:"%d"*/, iPort);
fossil_print("Launch webbrowser: %s\n", zBrowser);
fossil_system(zBrowser);
}
fossil_print("Type Ctrl-C to stop the HTTP server\n");
/* Set the service status to running and pass the listener socket to the
** service handling procedures. */
win32_http_service_running(s);
|
| ︙ | ︙ | |||
316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
}else if( zStopper && file_size(zStopper)>=0 ){
break;
}
p = fossil_malloc( sizeof(*p) );
p->id = ++idCnt;
p->s = client;
p->addr = client_addr;
p->zOptions = blob_str(&options);
if( flags & HTTP_SERVER_SCGI ){
_beginthread(win32_scgi_request, 0, (void*)p);
}else{
_beginthread(win32_http_request, 0, (void*)p);
}
}
| > | 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 |
}else if( zStopper && file_size(zStopper)>=0 ){
break;
}
p = fossil_malloc( sizeof(*p) );
p->id = ++idCnt;
p->s = client;
p->addr = client_addr;
p->flags = flags;
p->zOptions = blob_str(&options);
if( flags & HTTP_SERVER_SCGI ){
_beginthread(win32_scgi_request, 0, (void*)p);
}else{
_beginthread(win32_http_request, 0, (void*)p);
}
}
|
| ︙ | ︙ | |||
662 663 664 665 666 667 668 |
n = strlen(zMethod);
if( strncmp(zMethod, "create", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_DESCRIPTIONW
svcDescr = {L"Fossil - Distributed Software Configuration Management"};
| < | > > > > > | | | 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 |
n = strlen(zMethod);
if( strncmp(zMethod, "create", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_DESCRIPTIONW
svcDescr = {L"Fossil - Distributed Software Configuration Management"};
DWORD dwStartType = SERVICE_DEMAND_START;
const char *zDisplay = find_option("display", "D", 1);
const char *zStart = find_option("start", "S", 1);
const char *zUsername = find_option("username", "U", 1);
const char *zPassword = find_option("password", "W", 1);
const char *zPort = find_option("port", "P", 1);
const char *zNotFound = find_option("notfound", 0, 1);
const char *zFileGlob = find_option("files", 0, 1);
const char *zLocalAuth = find_option("localauth", 0, 0);
const char *zRepository = find_repository_option();
int useSCGI = find_option("scgi", 0, 0)!=0;
Blob binPath;
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
fossil_fatal("too many arguments for create method.");
}
/* Process service creation specific options. */
if( !zDisplay ){
zDisplay = zSvcName;
}
/* Per MSDN, the password parameter cannot be NULL. Must use empty
** string instead (i.e. in the call to CreateServiceW). */
if( !zPassword ){
zPassword = "";
}
if( zStart ){
if( strncmp(zStart, "auto", strlen(zStart))==0 ){
dwStartType = SERVICE_AUTO_START;
}else if( strncmp(zStart, "manual", strlen(zStart))==0 ){
dwStartType = SERVICE_DEMAND_START;
}else{
winhttp_fatal("create", zSvcName,
"specify 'auto' or 'manual' for the '-S|--start' option");
}
}
/* Process options for Fossil running as server. */
if( zPort && (atoi(zPort)<=0) ){
winhttp_fatal("create", zSvcName,
"port number must be in the range 1 - 65535.");
}
if( !zRepository ){
db_must_be_within_tree();
}else if( file_isdir(zRepository)==1 ){
g.zRepositoryName = mprintf("%s", zRepository);
file_simplify_name(g.zRepositoryName, -1, 0);
|
| ︙ | ︙ | |||
721 722 723 724 725 726 727 |
if( useSCGI ) blob_appendf(&binPath, " --scgi");
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
if( zFileGlob ) blob_appendf(&binPath, " --files-urlenc %T", zFileGlob);
if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
/* Create the service. */
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
| | | | < | | | | | < | 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 |
if( useSCGI ) blob_appendf(&binPath, " --scgi");
if( zNotFound ) blob_appendf(&binPath, " --notfound \"%s\"", zNotFound);
if( zFileGlob ) blob_appendf(&binPath, " --files-urlenc %T", zFileGlob);
if( zLocalAuth ) blob_append(&binPath, " --localauth", -1);
blob_appendf(&binPath, " \"%s\"", g.zRepositoryName);
/* Create the service. */
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( !hScm ) winhttp_fatal("create", zSvcName, win32_get_last_errmsg());
hSvc = CreateServiceW(
hScm, /* Handle to the SCM */
fossil_utf8_to_unicode(zSvcName), /* Name of the service */
fossil_utf8_to_unicode(zDisplay), /* Display name */
SERVICE_ALL_ACCESS, /* Desired access */
SERVICE_WIN32_OWN_PROCESS, /* Service type */
dwStartType, /* Start type */
SERVICE_ERROR_NORMAL, /* Error control */
fossil_utf8_to_unicode(blob_str(&binPath)), /* Binary path */
NULL, /* Load ordering group */
NULL, /* Tag value */
NULL, /* Service dependencies */
zUsername ? fossil_utf8_to_unicode(zUsername) : 0, /* Account */
fossil_utf8_to_unicode(zPassword) /* Account password */
);
if( !hSvc ) winhttp_fatal("create", zSvcName, win32_get_last_errmsg());
/* Set the service description. */
ChangeServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION, &svcDescr);
fossil_print("Service '%s' successfully created.\n", zSvcName);
CloseServiceHandle(hSvc);
CloseServiceHandle(hScm);
}else
if( strncmp(zMethod, "delete", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_STATUS sstat;
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
fossil_fatal("too many arguments for delete method.");
}
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( !hScm ) winhttp_fatal("delete", zSvcName, win32_get_last_errmsg());
hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName),
SERVICE_ALL_ACCESS);
if( !hSvc ) winhttp_fatal("delete", zSvcName, win32_get_last_errmsg());
QueryServiceStatus(hSvc, &sstat);
if( sstat.dwCurrentState!=SERVICE_STOPPED ){
fossil_print("Stopping service '%s'", zSvcName);
if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
if( !ControlService(hSvc, SERVICE_CONTROL_STOP, &sstat) ){
winhttp_fatal("delete", zSvcName, win32_get_last_errmsg());
}
}
while( sstat.dwCurrentState!=SERVICE_STOPPED ){
Sleep(100);
fossil_print(".");
QueryServiceStatus(hSvc, &sstat);
}
fossil_print("\nService '%s' stopped.\n", zSvcName);
}
if( !DeleteService(hSvc) ){
if( GetLastError()==ERROR_SERVICE_MARKED_FOR_DELETE ){
fossil_warning("Service '%s' already marked for delete.\n", zSvcName);
}else{
winhttp_fatal("delete", zSvcName, win32_get_last_errmsg());
}
}else{
fossil_print("Service '%s' successfully deleted.\n", zSvcName);
}
CloseServiceHandle(hSvc);
CloseServiceHandle(hScm);
}else
if( strncmp(zMethod, "show", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_STATUS sstat;
LPQUERY_SERVICE_CONFIGW pSvcConfig;
LPSERVICE_DESCRIPTIONW pSvcDescr;
BOOL bStatus;
DWORD nRequired;
static const char *const zSvcTypes[] = {
"Driver service",
"File system driver service",
"Service runs in its own process",
"Service shares a process with other services",
"Service can interact with the desktop"
};
|
| ︙ | ︙ | |||
823 824 825 826 827 828 829 |
};
const char *zSvcState = "";
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
| | | | | | | | | | 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 |
};
const char *zSvcState = "";
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
fossil_fatal("too many arguments for show method.");
}
hScm = OpenSCManagerW(NULL, NULL, GENERIC_READ);
if( !hScm ) winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName), GENERIC_READ);
if( !hSvc ) winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
/* Get the service configuration */
bStatus = QueryServiceConfigW(hSvc, NULL, 0, &nRequired);
if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
}
pSvcConfig = fossil_malloc(nRequired);
bStatus = QueryServiceConfigW(hSvc, pSvcConfig, nRequired, &nRequired);
if( !bStatus ) winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
/* Translate the service type */
switch( pSvcConfig->dwServiceType ){
case SERVICE_KERNEL_DRIVER: zSvcType = zSvcTypes[0]; break;
case SERVICE_FILE_SYSTEM_DRIVER: zSvcType = zSvcTypes[1]; break;
case SERVICE_WIN32_OWN_PROCESS: zSvcType = zSvcTypes[2]; break;
case SERVICE_WIN32_SHARE_PROCESS: zSvcType = zSvcTypes[3]; break;
case SERVICE_INTERACTIVE_PROCESS: zSvcType = zSvcTypes[4]; break;
}
/* Translate the service start type */
switch( pSvcConfig->dwStartType ){
case SERVICE_BOOT_START: zSvcStartType = zSvcStartTypes[0]; break;
case SERVICE_SYSTEM_START: zSvcStartType = zSvcStartTypes[1]; break;
case SERVICE_AUTO_START: zSvcStartType = zSvcStartTypes[2]; break;
case SERVICE_DEMAND_START: zSvcStartType = zSvcStartTypes[3]; break;
case SERVICE_DISABLED: zSvcStartType = zSvcStartTypes[4]; break;
}
/* Get the service description. */
bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
NULL, 0, &nRequired);
if( !bStatus && GetLastError()!=ERROR_INSUFFICIENT_BUFFER ){
winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
}
pSvcDescr = fossil_malloc(nRequired);
bStatus = QueryServiceConfig2W(hSvc, SERVICE_CONFIG_DESCRIPTION,
(LPBYTE)pSvcDescr, nRequired, &nRequired);
if( !bStatus ) winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
/* Retrieves the current status of the specified service. */
bStatus = QueryServiceStatus(hSvc, &sstat);
if( !bStatus ) winhttp_fatal("show", zSvcName, win32_get_last_errmsg());
/* Translate the current state. */
switch( sstat.dwCurrentState ){
case SERVICE_STOPPED: zSvcState = zSvcStates[0]; break;
case SERVICE_START_PENDING: zSvcState = zSvcStates[1]; break;
case SERVICE_STOP_PENDING: zSvcState = zSvcStates[2]; break;
case SERVICE_RUNNING: zSvcState = zSvcStates[3]; break;
case SERVICE_CONTINUE_PENDING: zSvcState = zSvcStates[4]; break;
|
| ︙ | ︙ | |||
899 900 901 902 903 904 905 |
CloseServiceHandle(hSvc);
CloseServiceHandle(hScm);
}else
if( strncmp(zMethod, "start", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_STATUS sstat;
| < | | | | < | | | | | 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 |
CloseServiceHandle(hSvc);
CloseServiceHandle(hScm);
}else
if( strncmp(zMethod, "start", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_STATUS sstat;
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
fossil_fatal("too many arguments for start method.");
}
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( !hScm ) winhttp_fatal("start", zSvcName, win32_get_last_errmsg());
hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName),
SERVICE_ALL_ACCESS);
if( !hSvc ) winhttp_fatal("start", zSvcName, win32_get_last_errmsg());
QueryServiceStatus(hSvc, &sstat);
if( sstat.dwCurrentState!=SERVICE_RUNNING ){
fossil_print("Starting service '%s'", zSvcName);
if( sstat.dwCurrentState!=SERVICE_START_PENDING ){
if( !StartServiceW(hSvc, 0, NULL) ){
winhttp_fatal("start", zSvcName, win32_get_last_errmsg());
}
}
while( sstat.dwCurrentState!=SERVICE_RUNNING ){
Sleep(100);
fossil_print(".");
QueryServiceStatus(hSvc, &sstat);
}
fossil_print("\nService '%s' started.\n", zSvcName);
}else{
fossil_print("Service '%s' is already started.\n", zSvcName);
}
CloseServiceHandle(hSvc);
CloseServiceHandle(hScm);
}else
if( strncmp(zMethod, "stop", n)==0 ){
SC_HANDLE hScm;
SC_HANDLE hSvc;
SERVICE_STATUS sstat;
verify_all_options();
if( g.argc==4 ){
zSvcName = g.argv[3];
}else if( g.argc>4 ){
fossil_fatal("too many arguments for stop method.");
}
hScm = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if( !hScm ) winhttp_fatal("stop", zSvcName, win32_get_last_errmsg());
hSvc = OpenServiceW(hScm, fossil_utf8_to_unicode(zSvcName),
SERVICE_ALL_ACCESS);
if( !hSvc ) winhttp_fatal("stop", zSvcName, win32_get_last_errmsg());
QueryServiceStatus(hSvc, &sstat);
if( sstat.dwCurrentState!=SERVICE_STOPPED ){
fossil_print("Stopping service '%s'", zSvcName);
if( sstat.dwCurrentState!=SERVICE_STOP_PENDING ){
if( !ControlService(hSvc, SERVICE_CONTROL_STOP, &sstat) ){
winhttp_fatal("stop", zSvcName, win32_get_last_errmsg());
}
}
while( sstat.dwCurrentState!=SERVICE_STOPPED ){
Sleep(100);
fossil_print(".");
QueryServiceStatus(hSvc, &sstat);
}
|
| ︙ | ︙ |
Changes to src/wysiwyg.c.
| ︙ | ︙ | |||
249 250 251 252 253 254 255 |
@ if(oDoc.style.whiteSpace=="pre-wrap"){setDocMode(0);}
@ document.getElementById("wysiwygValue").value=oDoc.innerHTML;
@ }
@
@ /* Run the editing command if in WYSIWYG mode */
@ function formatDoc(sCmd, sValue) {
@ if (isWysiwyg()){
| > > > > | > > > > > > > > | 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
@ if(oDoc.style.whiteSpace=="pre-wrap"){setDocMode(0);}
@ document.getElementById("wysiwygValue").value=oDoc.innerHTML;
@ }
@
@ /* Run the editing command if in WYSIWYG mode */
@ function formatDoc(sCmd, sValue) {
@ if (isWysiwyg()){
@ try {
@ // First, try the W3C draft standard way, which has
@ // been working on all non-IE browsers for a while.
@ // It is also supported by IE11 and higher.
@ document.execCommand("styleWithCSS", false, false);
@ } catch (e) {
@ try {
@ // For IE9 or IE10, this should work.
@ document.execCommand("useCSS", 0, true);
@ } catch (e) {
@ // Ok, that apparently did not work, do nothing.
@ }
@ }
@ document.execCommand(sCmd, false, sValue);
@ oDoc.focus();
@ }
@ }
@
@ /* Change the editing mode. Convert to markup if the argument
@ ** is true and wysiwyg if the argument is false. */
|
| ︙ | ︙ |
Changes to src/xfer.c.
| ︙ | ︙ | |||
111 112 113 114 115 116 117 | ** ** If any error occurs, write a message into pErr which has already ** be initialized to an empty string. ** ** Any artifact successfully received by this routine is considered to ** be public and is therefore removed from the "private" table. */ | | > > > > > | 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
**
** If any error occurs, write a message into pErr which has already
** be initialized to an empty string.
**
** Any artifact successfully received by this routine is considered to
** be public and is therefore removed from the "private" table.
*/
static void xfer_accept_file(
Xfer *pXfer,
int cloneFlag,
char **pzUuidList,
int *pnUuidList
){
int n;
int rid;
int srcid = 0;
Blob content, hash;
int isPriv;
isPriv = pXfer->nextIsPrivate;
|
| ︙ | ︙ | |||
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 |
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
0, isPriv);
remote_has(rid);
blob_reset(&content);
return;
}
if( pXfer->nToken==4 ){
Blob src, next;
srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv);
if( content_get(srcid, &src)==0 ){
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
0, isPriv);
pXfer->nDanglingFile++;
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
if( !isPriv ) content_make_public(rid);
blob_reset(&src);
blob_reset(&content);
return;
}
pXfer->nDeltaRcvd++;
blob_delta_apply(&src, &content, &next);
blob_reset(&src);
blob_reset(&content);
content = next;
}else{
pXfer->nFileRcvd++;
}
sha1sum_blob(&content, &hash);
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
blob_appendf(&pXfer->err, "content does not match sha1 hash");
}
rid = content_put_ex(&content, blob_str(&hash), 0, 0, isPriv);
blob_reset(&hash);
if( rid==0 ){
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
blob_reset(&content);
}else{
if( !isPriv ) content_make_public(rid);
| > > > > > | | 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 |
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
0, isPriv);
Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
blob_size(&pXfer->aToken[1]));
remote_has(rid);
blob_reset(&content);
return;
}
if( pXfer->nToken==4 ){
Blob src, next;
srcid = rid_from_uuid(&pXfer->aToken[2], 1, isPriv);
if( content_get(srcid, &src)==0 ){
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
0, isPriv);
Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
blob_size(&pXfer->aToken[1]));
pXfer->nDanglingFile++;
db_multi_exec("DELETE FROM phantom WHERE rid=%d", rid);
if( !isPriv ) content_make_public(rid);
blob_reset(&src);
blob_reset(&content);
return;
}
pXfer->nDeltaRcvd++;
blob_delta_apply(&src, &content, &next);
blob_reset(&src);
blob_reset(&content);
content = next;
}else{
pXfer->nFileRcvd++;
}
sha1sum_blob(&content, &hash);
if( !blob_eq_str(&pXfer->aToken[1], blob_str(&hash), -1) ){
blob_appendf(&pXfer->err, "content does not match sha1 hash");
}
rid = content_put_ex(&content, blob_str(&hash), 0, 0, isPriv);
Th_AppendToList(pzUuidList, pnUuidList, blob_str(&hash), blob_size(&hash));
blob_reset(&hash);
if( rid==0 ){
blob_appendf(&pXfer->err, "%s", g.zErrMsg);
blob_reset(&content);
}else{
if( !isPriv ) content_make_public(rid);
manifest_crosslink(rid, &content, MC_NO_ERRORS);
}
assert( blob_is_reset(&content) );
remote_has(rid);
}
/*
** The aToken[0..nToken-1] blob array is a parse of a "cfile" line
|
| ︙ | ︙ | |||
218 219 220 221 222 223 224 | ** ** If any error occurs, write a message into pErr which has already ** be initialized to an empty string. ** ** Any artifact successfully received by this routine is considered to ** be public and is therefore removed from the "private" table. */ | | > > > > | 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
**
** If any error occurs, write a message into pErr which has already
** be initialized to an empty string.
**
** Any artifact successfully received by this routine is considered to
** be public and is therefore removed from the "private" table.
*/
static void xfer_accept_compressed_file(
Xfer *pXfer,
char **pzUuidList,
int *pnUuidList
){
int szC; /* CSIZE */
int szU; /* USIZE */
int rid;
int srcid = 0;
Blob content;
int isPriv;
|
| ︙ | ︙ | |||
259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
szC, isPriv);
remote_has(rid);
blob_reset(&content);
}
/*
** Try to send a file as a delta against its parent.
** If successful, return the number of bytes in the delta.
| > > | 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
pXfer->nDeltaRcvd++;
}else{
srcid = 0;
pXfer->nFileRcvd++;
}
rid = content_put_ex(&content, blob_str(&pXfer->aToken[1]), srcid,
szC, isPriv);
Th_AppendToList(pzUuidList, pnUuidList, blob_str(&pXfer->aToken[1]),
blob_size(&pXfer->aToken[1]));
remote_has(rid);
blob_reset(&content);
}
/*
** Try to send a file as a delta against its parent.
** If successful, return the number of bytes in the delta.
|
| ︙ | ︙ | |||
293 294 295 296 297 298 299 |
};
int i;
Blob src, delta;
int size = 0;
int srcId = 0;
for(i=0; srcId==0 && i<count(azQuery); i++){
| | | 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 |
};
int i;
Blob src, delta;
int size = 0;
int srcId = 0;
for(i=0; srcId==0 && i<count(azQuery); i++){
srcId = db_int(0, azQuery[i] /*works-like:"%d"*/, rid);
}
if( srcId>0
&& (pXfer->syncPrivate || !content_is_private(srcId))
&& content_get(srcId, &src)
){
char *zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", srcId);
blob_delta_create(&src, pContent, &delta);
|
| ︙ | ︙ | |||
404 405 406 407 408 409 410 |
if( uuid_is_shunned(blob_str(pUuid)) ){
blob_reset(&uuid);
return;
}
if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) ||
pXfer->mxSend<=blob_size(pXfer->pOut) ){
const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n";
| | | 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 |
if( uuid_is_shunned(blob_str(pUuid)) ){
blob_reset(&uuid);
return;
}
if( (pXfer->maxTime != -1 && time(NULL) >= pXfer->maxTime) ||
pXfer->mxSend<=blob_size(pXfer->pOut) ){
const char *zFormat = isPriv ? "igot %b 1\n" : "igot %b\n";
blob_appendf(pXfer->pOut, zFormat /*works-like:"%b"*/, pUuid);
pXfer->nIGotSent++;
blob_reset(&uuid);
return;
}
if( nativeDelta ){
size = send_delta_native(pXfer, rid, isPriv, pUuid);
if( size ){
|
| ︙ | ︙ | |||
436 437 438 439 440 441 442 |
}
blob_reset(&content);
}
remote_has(rid);
blob_reset(&uuid);
#if 0
if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){
| | | 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
}
blob_reset(&content);
}
remote_has(rid);
blob_reset(&uuid);
#if 0
if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){
blob_append(pXfer->pOut, "\n", 1);
}
#endif
}
/*
** Send the file identified by rid as a compressed artifact. Basically,
** send the content exactly as it appears in the BLOB table using
|
| ︙ | ︙ | |||
496 497 498 499 500 501 502 |
pXfer->nDeltaSent++;
}else{
pXfer->nFileSent++;
}
blob_appendf(pXfer->pOut, "%d %d\n", szU, szC);
blob_append(pXfer->pOut, zContent, szC);
if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){
| | | 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
pXfer->nDeltaSent++;
}else{
pXfer->nFileSent++;
}
blob_appendf(pXfer->pOut, "%d %d\n", szU, szC);
blob_append(pXfer->pOut, zContent, szC);
if( blob_buffer(pXfer->pOut)[blob_size(pXfer->pOut)-1]!='\n' ){
blob_append(pXfer->pOut, "\n", 1);
}
if( !isPrivate && srcIsPrivate ){
blob_reset(&fullContent);
}
}
db_reset(&q1);
}
|
| ︙ | ︙ | |||
693 694 695 696 697 698 699 |
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
rid = content_put(&cluster);
blob_reset(&cluster);
nUncl -= nRow;
nRow = 0;
| | | > | | 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 |
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
rid = content_put(&cluster);
blob_reset(&cluster);
nUncl -= nRow;
nRow = 0;
blob_append_sql(&deleteWhere, ",%d", rid);
}
}
db_finalize(&q);
db_multi_exec(
"DELETE FROM unclustered WHERE rid NOT IN (0 %s)"
" AND NOT EXISTS(SELECT 1 FROM phantom WHERE rid=unclustered.rid)",
blob_sql_text(&deleteWhere)
);
blob_reset(&deleteWhere);
if( nRow>0 ){
md5sum_blob(&cluster, &cksum);
blob_appendf(&cluster, "Z %b\n", &cksum);
blob_reset(&cksum);
content_put(&cluster);
|
| ︙ | ︙ | |||
850 851 852 853 854 855 856 |
const char *xfer_ticket_code(void){
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
| | > > > > | | | < < < < < < | | 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 |
const char *xfer_ticket_code(void){
return db_get("xfer-ticket-script", 0);
}
/*
** Run the specified TH1 script, if any, and returns 1 on error.
*/
int xfer_run_script(
const char *zScript,
const char *zUuidOrList,
int bIsList
){
int rc = TH_OK;
if( !zScript ) return rc;
Th_FossilInit(TH_INIT_DEFAULT);
Th_Store(bIsList ? "uuids" : "uuid", zUuidOrList ? zUuidOrList : "");
rc = Th_Eval(g.interp, 0, zScript, -1);
if( rc!=TH_OK ){
fossil_error(1, "%s", Th_GetResult(g.interp, 0));
}
return rc;
}
/*
** Runs the pre-transfer TH1 script, if any, and returns its return code.
** This script may be run multiple times. If the script performs actions
** that cannot be redone, it should use an internal [if] guard similar to
** the following:
**
** if {![info exists common_done]} {
** # ... code here
** set common_done 1
** }
*/
int xfer_run_common_script(void){
return xfer_run_script(xfer_common_code(), 0, 0);
}
/*
** If this variable is set, disable login checks. Used for debugging
** only.
*/
static int disableLogin = 0;
|
| ︙ | ︙ | |||
914 915 916 917 918 919 920 921 922 923 924 925 926 927 |
int deltaFlag = 0;
int isClone = 0;
int nGimme = 0;
int size;
int recvConfig = 0;
char *zNow;
int rc;
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
fossil_redirect_home();
}
g.zLogin = "anonymous";
login_set_anon_nobody_capabilities();
login_check_credentials();
| > > > > > | 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 |
int deltaFlag = 0;
int isClone = 0;
int nGimme = 0;
int size;
int recvConfig = 0;
char *zNow;
int rc;
const char *zScript = 0;
char *zUuidList = 0;
int nUuidList = 0;
char **pzUuidList = 0;
int *pnUuidList = 0;
if( fossil_strcmp(PD("REQUEST_METHOD","POST"),"POST") ){
fossil_redirect_home();
}
g.zLogin = "anonymous";
login_set_anon_nobody_capabilities();
login_check_credentials();
|
| ︙ | ︙ | |||
948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 |
);
manifest_crosslink_begin();
rc = xfer_run_common_script();
if( rc==TH_ERROR ){
cgi_reset_content();
@ error common\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
while( blob_line(xfer.pIn, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
if( blob_size(&xfer.line)==0 ) continue;
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
/* file UUID SIZE \n CONTENT
** file UUID DELTASRC SIZE \n CONTENT
**
** Accept a file from the client.
*/
if( blob_eq(&xfer.aToken[0], "file") ){
if( !isPush ){
cgi_reset_content();
@ error not\sauthorized\sto\swrite
nErr++;
break;
}
| > > > > > | | | 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 |
);
manifest_crosslink_begin();
rc = xfer_run_common_script();
if( rc==TH_ERROR ){
cgi_reset_content();
@ error common\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
zScript = xfer_push_code();
if( zScript ){ /* NOTE: Are TH1 transfer hooks enabled? */
pzUuidList = &zUuidList;
pnUuidList = &nUuidList;
}
while( blob_line(xfer.pIn, &xfer.line) ){
if( blob_buffer(&xfer.line)[0]=='#' ) continue;
if( blob_size(&xfer.line)==0 ) continue;
xfer.nToken = blob_tokenize(&xfer.line, xfer.aToken, count(xfer.aToken));
/* file UUID SIZE \n CONTENT
** file UUID DELTASRC SIZE \n CONTENT
**
** Accept a file from the client.
*/
if( blob_eq(&xfer.aToken[0], "file") ){
if( !isPush ){
cgi_reset_content();
@ error not\sauthorized\sto\swrite
nErr++;
break;
}
xfer_accept_file(&xfer, 0, pzUuidList, pnUuidList);
if( blob_size(&xfer.err) ){
cgi_reset_content();
@ error %T(blob_str(&xfer.err))
nErr++;
break;
}
}else
/* cfile UUID USIZE CSIZE \n CONTENT
** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
**
** Accept a file from the client.
*/
if( blob_eq(&xfer.aToken[0], "cfile") ){
if( !isPush ){
cgi_reset_content();
@ error not\sauthorized\sto\swrite
nErr++;
break;
}
xfer_accept_compressed_file(&xfer, pzUuidList, pnUuidList);
if( blob_size(&xfer.err) ){
cgi_reset_content();
@ error %T(blob_str(&xfer.err))
nErr++;
break;
}
}else
|
| ︙ | ︙ | |||
1272 1273 1274 1275 1276 1277 1278 |
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
if( rc==TH_OK ){
| | > > > | 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 |
@ error bad\scommand:\s%F(blob_str(&xfer.line))
}
blobarray_reset(xfer.aToken, xfer.nToken);
blob_reset(&xfer.line);
}
if( isPush ){
if( rc==TH_OK ){
rc = xfer_run_script(zScript, zUuidList, 1);
if( rc==TH_ERROR ){
cgi_reset_content();
@ error push\sscript\sfailed:\s%F(g.zErrMsg)
nErr++;
}
}
request_phantoms(&xfer, 500);
}
if( zUuidList ){
Th_Free(g.interp, zUuidList);
}
if( isClone && nGimme==0 ){
/* The initial "clone" message from client to server contains no
** "gimme" cards. On that initial message, send the client an "igot"
** card for every artifact currently in the repository. This will
** cause the client to create phantoms for all artifacts, which will
** in turn make sure that the entire repository is sent efficiently
** and expeditiously.
|
| ︙ | ︙ | |||
1466 1467 1468 1469 1470 1471 1472 |
if( syncFlags & SYNC_PUSH ){
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
nCardSent++;
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
}
if( syncFlags & SYNC_VERBOSE ){
| > | | 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 |
if( syncFlags & SYNC_PUSH ){
blob_appendf(&send, "push %s %s\n", zSCode, zPCode);
nCardSent++;
if( (syncFlags & SYNC_PULL)==0 ) zOpType = "Push";
if( (syncFlags & SYNC_RESYNC)!=0 ) xfer.resync = 0x7fffffff;
}
if( syncFlags & SYNC_VERBOSE ){
fossil_print(zLabelFormat /*works-like:"%s%s%s%s%d"*/,
"", "Bytes", "Cards", "Artifacts", "Deltas");
}
while( go ){
int newPhantom = 0;
char *zRandomness;
db_begin_transaction();
db_record_repository_filename(0);
|
| ︙ | ︙ | |||
1563 1564 1565 1566 1567 1568 1569 |
nErr++;
go = 2;
break;
}
/* Output current stats */
if( syncFlags & SYNC_VERBOSE ){
| | > | | 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 |
nErr++;
go = 2;
break;
}
/* Output current stats */
if( syncFlags & SYNC_VERBOSE ){
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Sent:",
blob_size(&send), nCardSent+xfer.nGimmeSent+xfer.nIGotSent,
xfer.nFileSent, xfer.nDeltaSent);
}else{
nRoundtrip++;
nArtifactSent += xfer.nFileSent + xfer.nDeltaSent;
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
nRoundtrip, nArtifactSent, nArtifactRcvd);
}
nCardSent = 0;
nCardRcvd = 0;
xfer.nFileSent = 0;
xfer.nDeltaSent = 0;
xfer.nGimmeSent = 0;
xfer.nIGotSent = 0;
|
| ︙ | ︙ | |||
1634 1635 1636 1637 1638 1639 1640 |
/* file UUID SIZE \n CONTENT
** file UUID DELTASRC SIZE \n CONTENT
**
** Receive a file transmitted from the server.
*/
if( blob_eq(&xfer.aToken[0],"file") ){
| | | | 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 |
/* file UUID SIZE \n CONTENT
** file UUID DELTASRC SIZE \n CONTENT
**
** Receive a file transmitted from the server.
*/
if( blob_eq(&xfer.aToken[0],"file") ){
xfer_accept_file(&xfer, (syncFlags & SYNC_CLONE)!=0, 0, 0);
nArtifactRcvd++;
}else
/* cfile UUID USIZE CSIZE \n CONTENT
** cfile UUID DELTASRC USIZE CSIZE \n CONTENT
**
** Receive a compressed file transmitted from the server.
*/
if( blob_eq(&xfer.aToken[0],"cfile") ){
xfer_accept_compressed_file(&xfer, 0, 0);
nArtifactRcvd++;
}else
/* gimme UUID
**
** Server is requesting a file. If the file is a manifest, assume
** that the server will also want to know all of the content files
|
| ︙ | ︙ | |||
1784 1785 1786 1787 1788 1789 1790 |
**
** If the "login failed" message is seen, clear the sync password prior
** to the next cycle.
*/
if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
char *zMsg = blob_terminate(&xfer.aToken[1]);
defossilize(zMsg);
| | | 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 |
**
** If the "login failed" message is seen, clear the sync password prior
** to the next cycle.
*/
if( blob_eq(&xfer.aToken[0],"message") && xfer.nToken==2 ){
char *zMsg = blob_terminate(&xfer.aToken[1]);
defossilize(zMsg);
if( (syncFlags & SYNC_PUSH) && zMsg && sqlite3_strglob("pull only *", zMsg)==0 ){
syncFlags &= ~SYNC_PUSH;
zMsg = 0;
}
if( zMsg && zMsg[0] ){
fossil_force_newline();
fossil_print("Server says: %s\n", zMsg);
}
|
| ︙ | ︙ | |||
1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 |
go = 1;
if( g.cgiOutput==0 ){
g.url.flags |= URL_PROMPT_PW;
g.url.flags &= ~URL_PROMPTED;
url_prompt_for_password();
url_remember();
}
}
}else{
blob_appendf(&xfer.err, "server says: %s\n", zMsg);
nErr++;
}
break;
}
| > > | 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 |
go = 1;
if( g.cgiOutput==0 ){
g.url.flags |= URL_PROMPT_PW;
g.url.flags &= ~URL_PROMPTED;
url_prompt_for_password();
url_remember();
}
}else{
nErr++;
}
}else{
blob_appendf(&xfer.err, "server says: %s\n", zMsg);
nErr++;
}
break;
}
|
| ︙ | ︙ | |||
1868 1869 1870 1871 1872 1873 1874 |
if( (configRcvMask & (CONFIGSET_USER|CONFIGSET_TKT))!=0
&& (configRcvMask & CONFIGSET_OLDFORMAT)!=0
){
configure_finalize_receive();
}
origConfigRcvMask = 0;
if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
| | > | | 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 |
if( (configRcvMask & (CONFIGSET_USER|CONFIGSET_TKT))!=0
&& (configRcvMask & CONFIGSET_OLDFORMAT)!=0
){
configure_finalize_receive();
}
origConfigRcvMask = 0;
if( nCardRcvd>0 && (syncFlags & SYNC_VERBOSE) ){
fossil_print(zValueFormat /*works-like:"%s%d%d%d%d"*/, "Received:",
blob_size(&recv), nCardRcvd,
xfer.nFileRcvd, xfer.nDeltaRcvd + xfer.nDanglingFile);
}else{
fossil_print(zBriefFormat /*works-like:"%d%d%d"*/,
nRoundtrip, nArtifactSent, nArtifactRcvd);
}
blob_reset(&recv);
nCycle++;
/* If we received one or more files on the previous exchange but
** there are still phantoms, then go another round.
*/
|
| ︙ | ︙ |
Changes to src/zip.c.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | ** ******************************************************************************* ** ** This file contains code used to generate ZIP archives. */ #include "config.h" #include <assert.h> | > > > > | > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
**
*******************************************************************************
**
** This file contains code used to generate ZIP archives.
*/
#include "config.h"
#include <assert.h>
#if defined(FOSSIL_ENABLE_MINIZ)
# define MINIZ_HEADER_FILE_ONLY
# include "miniz.c"
#else
# include <zlib.h>
#endif
#include "zip.h"
/*
** Write a 16- or 32-bit integer as little-endian into the given buffer.
*/
static void put16(char *z, int v){
z[0] = v & 0xff;
|
| ︙ | ︙ | |||
343 344 345 346 347 348 349 |
if( pManifest ){
char *zName;
zip_set_timedate(pManifest->rDate);
if( db_get_boolean("manifest", 0) ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
zip_add_folders(zName);
| < > > | 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
if( pManifest ){
char *zName;
zip_set_timedate(pManifest->rDate);
if( db_get_boolean("manifest", 0) ){
blob_append(&filename, "manifest", -1);
zName = blob_str(&filename);
zip_add_folders(zName);
sha1sum_blob(&mfile, &hash);
sterilize_manifest(&mfile);
zip_add_file(zName, &mfile, 0);
blob_reset(&mfile);
blob_append(&hash, "\n", 1);
blob_resize(&filename, nPrefix);
blob_append(&filename, "manifest.uuid", -1);
zName = blob_str(&filename);
zip_add_file(zName, &hash, 0);
blob_reset(&hash);
|
| ︙ | ︙ | |||
391 392 393 394 395 396 397 398 399 400 401 402 403 404 |
*/
void baseline_zip_cmd(void){
int rid;
Blob zip;
const char *zName;
zName = find_option("name", 0, 1);
db_find_and_open_repository(0, 0);
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
rid = name_to_typed_rid(g.argv[2],"ci");
if( zName==0 ){
zName = db_text("default-name",
"SELECT replace(%Q,' ','_') "
| > > > > | 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 |
*/
void baseline_zip_cmd(void){
int rid;
Blob zip;
const char *zName;
zName = find_option("name", 0, 1);
db_find_and_open_repository(0, 0);
/* We should be done with options.. */
verify_all_options();
if( g.argc!=4 ){
usage("VERSION OUTPUTFILE");
}
rid = name_to_typed_rid(g.argv[2],"ci");
if( zName==0 ){
zName = db_text("default-name",
"SELECT replace(%Q,' ','_') "
|
| ︙ | ︙ | |||
419 420 421 422 423 424 425 | ** URL: /zip/RID.zip ** ** Generate a ZIP archive for the baseline. ** Return that ZIP archive as the HTTP reply content. ** ** Optional URL Parameters: ** | | | > > | > > > > > > > | | | | > | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
** URL: /zip/RID.zip
**
** Generate a ZIP archive for the baseline.
** Return that ZIP archive as the HTTP reply content.
**
** Optional URL Parameters:
**
** - name=NAME[.zip] is the name of the output file. Defaults to
** something project/version-specific. The base part of the
** name, up to the last dot, is used as the top-most directory
** name in the output file.
**
** - uuid=the version to zip (may be a tag/branch name).
** Defaults to "trunk".
**
*/
void baseline_zip_page(void){
int rid;
char *zName, *zRid;
int nName, nRid;
Blob zip;
char *zKey;
login_check_credentials();
if( !g.perm.Zip ){ login_needed(); return; }
load_control();
zName = mprintf("%s", PD("name",""));
nName = strlen(zName);
zRid = mprintf("%s", PD("uuid","trunk"));
nRid = strlen(zRid);
if( nName>4 && fossil_strcmp(&zName[nName-4], ".zip")==0 ){
/* Special case: Remove the ".zip" suffix. */
nName -= 4;
zName[nName] = 0;
}else{
/* If the file suffix is not ".zip" then just remove the
** suffix up to and including the last "." */
for(nName=strlen(zName)-1; nName>5; nName--){
if( zName[nName]=='.' ){
zName[nName] = 0;
break;
}
}
}
rid = name_to_typed_rid(nRid?zRid:zName,"ci");
if( rid==0 ){
@ Not found
return;
}
|
| ︙ | ︙ |
Changes to test/comment.test.
| ︙ | ︙ | |||
24 25 26 27 28 29 30 |
###############################################################################
fossil test-comment-format --decode "" ""
test comment-2 {$RESULT eq "\n(1 lines output)"}
###############################################################################
| | | | | | | | | | | | | | | | | | | | | | > > > > > | | < < < < < | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
###############################################################################
fossil test-comment-format --decode "" ""
test comment-2 {$RESULT eq "\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 26 " " "this is a short comment."
test comment-3 {$RESULT eq " this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --decode " " "this is a short comment."
test comment-4 {$RESULT eq " this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 26 "*PREFIX* " "this is a short comment."
test comment-5 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --decode "*PREFIX* " "this is a short comment."
test comment-6 {$RESULT eq "*PREFIX* this is a short c\n omment.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 "" "this\\sis\\sa\\sshort\\scomment."
test comment-7 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --decode "" "this\\sis\\sa\\sshort\\scomment."
test comment-8 {$RESULT eq "this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly."
test comment-9 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --decode --trimspace "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*"
test comment-10 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test is\n working correctly. more text here describing the issue.\n another line here....................................................\n ..............................*\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 78 "HH:MM:SS " "....................................................................................*"
test comment-11 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 78 "HH:MM:SS " ".....................................................................*" 78
test comment-12 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 "*TEST* " "this\tis a test."
test comment-13 {$RESULT eq "*TEST* this\tis a te\n st.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................."
test comment-14 {$RESULT eq "*TEST* this is a test.......................................\n .....................................................\n ...........................\n(3 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................."
test comment-15 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 "*TEST* " "this is a test......................................................................................................................."
test comment-16 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --wordbreak "*TEST* " "this is a test......................................................................................................................."
test comment-17 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-18 {$RESULT eq "*TEST* one two three four five six seven eight nine ten elev\n en twelve\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-19 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-20 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-21 {$RESULT eq "*TEST* one two three four five\n six seven eight nine ten\n eleven twelve\n(3 lines output)"}
###############################################################################
fossil test-comment-format --legacy "" ""
test comment-22 {$RESULT eq "\n(1 lines output)"}
###############################################################################
fossil test-comment-format --legacy --decode "" ""
test comment-23 {$RESULT eq "\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --legacy " " "this is a short comment."
test comment-24 {$RESULT eq " this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --legacy --decode " " "this is a short comment."
test comment-25 {$RESULT eq " this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 25 --legacy "*PREFIX* " "this is a short comment."
test comment-26 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 25 --legacy --decode "*PREFIX* " "this is a short comment."
test comment-27 {$RESULT eq "*PREFIX* this is a short\n comment.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --legacy "" "this\\sis\\sa\\sshort\\scomment."
test comment-28 {$RESULT eq "this\\sis\\sa\\sshort\\scommen\nt.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --legacy --decode "" "this\\sis\\sa\\sshort\\scomment."
test comment-29 {$RESULT eq "this is a short comment.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly."
test comment-30 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly.\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --legacy --decode "HH:MM:SS " "this is a long comment that should span multiple lines if the test is working correctly. more text here describing the issue.\\nanother line here..................................................................................*"
test comment-31 {$RESULT eq "HH:MM:SS this is a long comment that should span multiple lines if the test\n is working correctly. more text here describing the issue. another\n line\n here.................................................................\n .................*\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --legacy "HH:MM:SS " "....................................................................................*"
test comment-32 {$RESULT eq "HH:MM:SS .....................................................................\n ...............*\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 78 --legacy "HH:MM:SS " ".....................................................................*"
test comment-33 {$RESULT eq "HH:MM:SS .....................................................................\n *\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 26 --legacy "*TEST* " "this\tis a test."
test comment-34 {$RESULT eq "*TEST* this is a test.\n(1 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................."
test comment-35 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................."
test comment-36 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy "*TEST* " "this is a test......................................................................................................................."
test comment-37 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "this is a test......................................................................................................................."
test comment-38 {$RESULT eq "*TEST* this is a\n test.................................................\n .....................................................\n .................\n(4 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-39 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-40 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-41 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
###############################################################################
fossil test-comment-format --width 60 --legacy --wordbreak "*TEST* " "one two three four five six seven eight nine ten eleven twelve"
test comment-42 {$RESULT eq "*TEST* one two three four five six seven eight nine ten\n eleven twelve\n(2 lines output)"}
###############################################################################
set orig "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\\nxxxxxxx."
fossil test-comment-format --width 73 --decode --origbreak "" $orig
test comment-43 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 73 --decode --origbreak "" $orig $orig
test comment-44 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 73 --decode --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig
test comment-45 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \nxxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(6 lines output)"}
###############################################################################
fossil test-comment-format --width 82 --indent 9 --decode --origbreak " " $orig
test comment-46 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 82 --indent 9 --decode --origbreak " " $orig $orig
test comment-47 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 82 --indent 9 --decode --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
test comment-48 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig
test comment-49 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimspace --origbreak "" $orig $orig
test comment-50 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimspace --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig
test comment-51 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \nxxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(6 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig
test comment-52 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak " " $orig $orig
test comment-53 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimspace --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
test comment-54 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimcrlf --origbreak "" $orig
test comment-55 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimcrlf --origbreak "" $orig $orig
test comment-56 {$RESULT eq "xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 72 --decode --trimcrlf --origbreak "" "00:00:00 \[0000000000\] *CURRENT* $orig" $orig
test comment-57 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \nxxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\nxxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\nxxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\nxxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\nxxxxxxx.\n(6 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak " " $orig
test comment-58 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak " " $orig $orig
test comment-59 {$RESULT eq " xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(5 lines output)"}
###############################################################################
fossil test-comment-format --width 81 --indent 9 --decode --trimcrlf --origbreak "00:00:00 " "\[0000000000\] *CURRENT* $orig" $orig
test comment-60 {$RESULT eq "00:00:00 \[0000000000\] *CURRENT* \n xxxx xx xxxxxxx xxxx xxxxxx xxxxxxx, xxxxxxx, x xxxx xxxxxx xx xxxx xxxx\n xxxxxxx xxxxx xxxx xxxx xx xxxxxxx xxxxxxx (xxxxxx xxxxxxxxx x xxxxx).\n xxx'x xxx xxx xx xxxxx xxxx xxx xxx --xxxxxxxxxxx xxxxxx xx xx xxxx. x\n xxxxx x xxxxxx xxxx xxxx xxxx xxxx xxxx x xxxxx xx xxx x xxxxxxxx\n xxxxxxx.\n(6 lines output)"}
|
Added test/merge6.test.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 |
#
# Copyright (c) 2014 D. Richard Hipp
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the Simplified BSD License (also
# known as the "2-Clause License" or "FreeBSD License".)
#
# This program is distributed in the hope that it will be useful,
# but without any warranty; without even the implied warranty of
# merchantability or fitness for a particular purpose.
#
# Author contact information:
# drh@hwaci.com
# http://www.hwaci.com/drh/
#
############################################################################
#
# Tests of the "merge" command
#
####################################################################
# TEST 1: Handle multiple merges each with one or more ADDED files #
####################################################################
repo_init
fossil ls
test merge_multi-0 {[string map [list \r\n \n] [string trim $RESULT]] eq {}}
write_file f1 "f1 line"
fossil add f1
fossil commit -m "base file"
fossil ls
test merge_multi-1 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1}}
fossil update trunk
write_file f2 "f2 line"
fossil add f2
fossil commit -m "branch for file f2" -b branch_for_f2
fossil ls
test merge_multi-2 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1
f2}}
fossil update trunk
write_file f3 "f3 line"
write_file f4 "f4 line"
fossil add f3
fossil add f4
fossil commit -m "branch for files f3 and f4" -b branch_for_f3_f4
fossil ls
test merge_multi-3 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1
f3
f4}}
fossil update trunk
fossil merge branch_for_f2
fossil merge branch_for_f3_f4
fossil commit -m "new trunk files f2, f3, and f4 via merge"
fossil ls
test merge_multi-4 {[string map [list \r\n \n] [string trim $RESULT]] eq {f1
f2
f3
f4}}
|
Changes to test/release-checklist.wiki.
| ︙ | ︙ | |||
15 16 17 18 19 20 21 | [./graph-test-1.wiki] document and verify that all graphs are rendered correctly. <li><p> Click on each of the links in in the [./diff-test-1.wiki] document and verify that all diffs are rendered correctly. | < > > > > > | 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | [./graph-test-1.wiki] document and verify that all graphs are rendered correctly. <li><p> Click on each of the links in in the [./diff-test-1.wiki] document and verify that all diffs are rendered correctly. <li><p> Click on the following link to verify that it works: [./test-page%2b%2b.wiki | ./test-page++.wiki] (NB: Many web servers automatically block or rewrite URLs that contain "+" characters, even when those "+" characters are encoded as "%2B". On such web servers, the URL above will not work. This test is only guaranteed to work when running "fossil ui".) <li><p> Verify correct name-change tracking behavior (no net changes) for: <blockquote><b> fossil test-name-changes --debug b120bc8b262ac 374920b20944b </b></blockquote> |
| ︙ | ︙ |
Changes to test/th1.test.
| ︙ | ︙ | |||
478 479 480 481 482 483 484 485 486 487 488 489 490 491 |
###############################################################################
fossil test-th-eval "expr 0+0b"
test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}}
###############################################################################
fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
test th1-checkout-1 {[string length $RESULT] > 0}
###############################################################################
fossil test-th-eval "checkout"; # NOTE: Assumes running "in tree".
test th1-checkout-2 {[string length $RESULT] > 0}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 |
###############################################################################
fossil test-th-eval "expr 0+0b"
test th1-expr-35 {$RESULT eq {TH_ERROR: expected number, got: "0b"}}
###############################################################################
fossil test-th-eval "expr (-1)+1"
test th1-expr-36 {$RESULT eq {0}}
###############################################################################
fossil test-th-eval "expr (((-1)))"
test th1-expr-37 {$RESULT eq {-1}}
###############################################################################
fossil test-th-eval "expr (((1)))"
test th1-expr-38 {$RESULT eq {1}}
###############################################################################
fossil test-th-eval "expr (((1))"
test th1-expr-39 {$RESULT eq {TH_ERROR: syntax error in expression: "(((1))"}}
###############################################################################
fossil test-th-eval "expr ((1)))"
test th1-expr-40 {$RESULT eq {TH_ERROR: syntax error in expression: "((1)))"}}
###############################################################################
fossil test-th-eval "expr (((1)*2)*2)"
test th1-expr-41 {$RESULT eq {4}}
###############################################################################
fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
test th1-checkout-1 {[string length $RESULT] > 0}
###############################################################################
fossil test-th-eval "checkout"; # NOTE: Assumes running "in tree".
test th1-checkout-2 {[string length $RESULT] > 0}
|
| ︙ | ︙ | |||
521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
###############################################################################
fossil test-th-eval --th-trace "trace {}"
if {$th1Hooks} {
test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
------------------- END TRACE LOG -------------------}}
} else {
test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-setup {} => TH_OK<br />
------------------- END TRACE LOG -------------------}}
}
###############################################################################
fossil test-th-eval "trace {this is a trace message.}"
test th1-trace-3 {$RESULT eq {}}
###############################################################################
fossil test-th-eval --th-trace "trace {this is a trace message.}"
if {$th1Hooks} {
test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
this is a trace message.
------------------- END TRACE LOG -------------------}}
} else {
test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-setup {} => TH_OK<br />
this is a trace message.
------------------- END TRACE LOG -------------------}}
}
###############################################################################
| > > > > | 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 |
###############################################################################
fossil test-th-eval --th-trace "trace {}"
if {$th1Hooks} {
test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-init 0x0 => 0x0<br />
------------------- END TRACE LOG -------------------}}
} else {
test th1-trace-2 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-init 0x0 => 0x0<br />
th1-setup {} => TH_OK<br />
------------------- END TRACE LOG -------------------}}
}
###############################################################################
fossil test-th-eval "trace {this is a trace message.}"
test th1-trace-3 {$RESULT eq {}}
###############################################################################
fossil test-th-eval --th-trace "trace {this is a trace message.}"
if {$th1Hooks} {
test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-init 0x0 => 0x0<br />
this is a trace message.
------------------- END TRACE LOG -------------------}}
} else {
test th1-trace-4 {[string map [list \r\n \n] [string trim $RESULT]] eq \
{------------------ BEGIN TRACE LOG ------------------
th1-init 0x0 => 0x0<br />
th1-setup {} => TH_OK<br />
this is a trace message.
------------------- END TRACE LOG -------------------}}
}
###############################################################################
|
| ︙ | ︙ | |||
674 675 676 677 678 679 680 |
fossil test-th-eval "artifact 0000000000 test/th1.test"
test th1-artifact-8 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact 0000000000 test/th1.test"
test th1-artifact-9 {$RESULT eq {TH_ERROR: artifact not found}}
| > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 |
fossil test-th-eval "artifact 0000000000 test/th1.test"
test th1-artifact-8 {$RESULT eq {TH_ERROR: repository unavailable}}
###############################################################################
fossil test-th-eval --th-open-config "artifact 0000000000 test/th1.test"
test th1-artifact-9 {$RESULT eq {TH_ERROR: artifact not found}}
###############################################################################
fossil test-th-eval "globalState checkout"
test th1-globalState-1 {[string length $RESULT] > 0}
###############################################################################
fossil test-th-eval "globalState checkout"
test th1-globalState-2 {$RESULT eq [fossil test-th-eval checkout]}
###############################################################################
fossil test-th-eval "globalState configuration"
test th1-globalState-3 {[string length $RESULT] == 0}
###############################################################################
fossil test-th-eval --th-open-config "globalState configuration"
test th1-globalState-4 {[string length $RESULT] > 0}
###############################################################################
fossil test-th-eval "globalState executable"
test th1-globalState-5 {[file rootname [file tail $RESULT]] eq "fossil"}
###############################################################################
fossil test-th-eval "globalState log"
test th1-globalState-6 {[string length $RESULT] == 0}
###############################################################################
fossil test-th-eval --errorlog foserrors.log "globalState log"
test th1-globalState-7 {$RESULT eq "foserrors.log"}
###############################################################################
fossil test-th-eval "globalState repository"
test th1-globalState-8 {[string length $RESULT] > 0}
###############################################################################
fossil test-th-eval "globalState repository"
test th1-globalState-9 {$RESULT eq [fossil test-th-eval repository]}
###############################################################################
fossil test-th-eval "globalState top"
test th1-globalState-10 {[string length $RESULT] == 0}
###############################################################################
fossil test-th-eval "globalState user"
test th1-globalState-11 {[string length $RESULT] == 0}
###############################################################################
fossil test-th-eval --user fossil-th1-test "globalState user"
test th1-globalState-12 {$RESULT eq "fossil-th1-test"}
###############################################################################
fossil test-th-eval "globalState vfs"
test th1-globalState-13 {[string length $RESULT] == 0}
###############################################################################
fossil test-th-eval "globalState vfs"
test th1-globalState-14 {[string length $RESULT] == 0}
###############################################################################
if {$tcl_platform(platform) eq "windows"} then {
set altVfs win32-longpath
} else {
set altVfs unix-dotfile
}
###############################################################################
fossil test-th-eval --vfs $altVfs "globalState vfs"
test th1-globalState-15 {$RESULT eq $altVfs}
###############################################################################
fossil test-th-eval "globalState flags"
test th1-globalState-16 {$RESULT eq "0"}
###############################################################################
fossil test-th-eval "reinitialize; globalState configuration"
test th1-reinitialize-1 {$RESULT eq ""}
###############################################################################
fossil test-th-eval "reinitialize 1; globalState configuration"
test th1-reinitialize-2 {$RESULT ne ""}
|
Changes to win/Makefile.PellesCGMake.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 | # zlib sources 1.2.5 # Windows XP SP 2 # and # PellesC 6.00.4 # gmake 3.80 # zlib sources 1.2.5 # Windows 7 Home Premium | | | | 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | # zlib sources 1.2.5 # Windows XP SP 2 # and # PellesC 6.00.4 # gmake 3.80 # zlib sources 1.2.5 # Windows 7 Home Premium # # PellesCDir=c:\Programme\PellesC # Select between 32/64 bit code, default is 32 bit #TARGETVERSION=64 ifeq ($(TARGETVERSION),64) # 64 bit version |
| ︙ | ︙ | |||
73 74 75 76 77 78 79 | # define commands for building the windows resource files RESOURCE=fossil.res RC=$(PellesCDir)\bin\porc.exe RCFLAGS=$(INCLUDE) -D__POCC__=1 -D_M_X$(TARGETVERSION) # define the special utilities files, needed to generate # the automatically generated source files | | | | | | 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 | # define commands for building the windows resource files RESOURCE=fossil.res RC=$(PellesCDir)\bin\porc.exe RCFLAGS=$(INCLUDE) -D__POCC__=1 -D_M_X$(TARGETVERSION) # define the special utilities files, needed to generate # the automatically generated source files UTILS=translate.exe mkindex.exe makeheaders.exe mkbuiltin.exe UTILS_OBJ=$(UTILS:.exe=.obj) UTILS_SRC=$(foreach uf,$(UTILS),$(SRCDIR)$(uf:.exe=.c)) # define the SQLite files, which need special flags on compile SQLITESRC=sqlite3.c ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf)) SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj)) SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_WIN32_NO_ANSI # define the SQLite shell files, which need special flags on compile SQLITESHELLSRC=shell.c ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf)) SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj)) SQLITESHELLDEFINES=-Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen # define the th scripting files, which need special flags on compile THSRC=th.c th_lang.c |
| ︙ | ︙ | |||
112 113 114 115 116 117 118 | TRANSLATEDOBJ=$(TRANSLATEDSRC:.c=.obj) # main target file is the application APPLICATION=fossil.exe # define the standard make target .PHONY: default | | | 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | TRANSLATEDOBJ=$(TRANSLATEDSRC:.c=.obj) # main target file is the application APPLICATION=fossil.exe # define the standard make target .PHONY: default default: page_index.h builtin_data.h headers $(APPLICATION) # symbolic target to generate the source generate utils .PHONY: utils utils: $(UTILS) # link utils $(UTILS) version.exe: %.exe: %.obj |
| ︙ | ︙ | |||
137 138 139 140 141 142 143 144 145 146 | # generate the translated c-source files $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe translate.exe $< >$@ # generate the index source, containing all web references,.. page_index.h: $(TRANSLATEDSRC) mkindex.exe mkindex.exe $(TRANSLATEDSRC) >$@ # extracting version info from manifest VERSION.h: version.exe ..\manifest.uuid ..\manifest ..\VERSION | > > > | | | 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 | # generate the translated c-source files $(TRANSLATEDSRC): %_.c: $(SRCDIR)%.c translate.exe translate.exe $< >$@ # generate the index source, containing all web references,.. page_index.h: $(TRANSLATEDSRC) mkindex.exe mkindex.exe $(TRANSLATEDSRC) >$@ builtin_data.h: $(EXTRA_FILES) mkbuiltin.exe mkbuiltin.exe $(EXTRA_FILES) >$@ # extracting version info from manifest VERSION.h: version.exe ..\manifest.uuid ..\manifest ..\VERSION version.exe ..\manifest.uuid ..\manifest ..\VERSION >$@ # generate the simplified headers headers: makeheaders.exe page_index.h builtin_data.h VERSION.h ../src/sqlite3.h ../src/th.h VERSION.h makeheaders.exe $(foreach ts,$(TRANSLATEDSRC),$(ts):$(ts:_.c=.h)) ../src/sqlite3.h ../src/th.h VERSION.h echo Done >$@ # compile C sources with relevant options $(TRANSLATEDOBJ): %_.obj: %_.c %.h $(CC) $(CCFLAGS) $(INCLUDE) "$<" -Fo"$@" |
| ︙ | ︙ |
Changes to win/Makefile.dmc.
| ︙ | ︙ | |||
22 23 24 25 26 27 28 | SSL = CFLAGS = -o BCC = $(DMDIR)\bin\dmc $(CFLAGS) TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 | | | | | | > | > > > | > > > | | > > > | | 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 | SSL = CFLAGS = -o BCC = $(DMDIR)\bin\dmc $(CFLAGS) TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL) LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c skins_.c sqlcmd_.c stash_.c stat_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O RC=$(DMDIR)\bin\rcc RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__ APPNAME = $(OBJDIR)\fossil$(E) all: $(APPNAME) $(APPNAME) : translate$E mkindex$E codecheck1$E headers $(OBJ) $(OBJDIR)\link cd $(OBJDIR) codecheck1$E $(SRC) $(DMDIR)\bin\link @link $(OBJDIR)\fossil.res: $B\win\fossil.rc $(RC) $(RCFLAGS) -o$@ $** $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res +echo add allrepo attach bag bisect blob branch browse builtin cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf rebuild regexp report rss schema search setup sha1 shun skins sqlcmd stash stat style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@ +echo fossil >> $@ +echo fossil >> $@ +echo $(LIBS) >> $@ +echo. >> $@ +echo fossil >> $@ translate$E: $(SRCDIR)\translate.c $(BCC) -o$@ $** makeheaders$E: $(SRCDIR)\makeheaders.c $(BCC) -o$@ $** mkindex$E: $(SRCDIR)\mkindex.c $(BCC) -o$@ $** mkbuiltin$E: $(SRCDIR)\mkbuiltin.c $(BCC) -o$@ $** mkversion$E: $(SRCDIR)\mkversion.c $(BCC) -o$@ $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) -o$@ $** $(OBJDIR)\shell$O : $(SRCDIR)\shell.c $(TCC) -o$@ -c $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) $** $(OBJDIR)\sqlite3$O : $(SRCDIR)\sqlite3.c $(TCC) -o$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $** $(OBJDIR)\th$O : $(SRCDIR)\th.c $(TCC) -o$@ -c $** $(OBJDIR)\th_lang$O : $(SRCDIR)\th_lang.c $(TCC) -o$@ -c $** $(OBJDIR)\cson_amalgamation.h : $(SRCDIR)\cson_amalgamation.h cp $@ $@ VERSION.h : mkversion$E $B\manifest.uuid $B\manifest $B\VERSION +$** > $@ page_index.h: mkindex$E $(SRC) +$** > $@ builtin_data.h: mkbuiltin$E $(EXTRA_FILES) +$** > $@ clean: -del $(OBJDIR)\*.obj -del *.obj *_.c *.h *.map realclean: -del $(APPNAME) translate$E mkindex$E makeheaders$E mkversion$E codecheck1$E mkbuiltin$E $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h |
| ︙ | ︙ | |||
158 159 160 161 162 163 164 165 166 167 168 169 170 171 | +translate$E $** > $@ $(OBJDIR)\browse$O : browse_.c browse.h $(TCC) -o$@ -c browse_.c browse_.c : $(SRCDIR)\browse.c +translate$E $** > $@ $(OBJDIR)\cache$O : cache_.c cache.h $(TCC) -o$@ -c cache_.c cache_.c : $(SRCDIR)\cache.c +translate$E $** > $@ | > > > > > > | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 | +translate$E $** > $@ $(OBJDIR)\browse$O : browse_.c browse.h $(TCC) -o$@ -c browse_.c browse_.c : $(SRCDIR)\browse.c +translate$E $** > $@ $(OBJDIR)\builtin$O : builtin_.c builtin.h $(TCC) -o$@ -c builtin_.c builtin_.c : $(SRCDIR)\builtin.c +translate$E $** > $@ $(OBJDIR)\cache$O : cache_.c cache.h $(TCC) -o$@ -c cache_.c cache_.c : $(SRCDIR)\cache.c +translate$E $** > $@ |
| ︙ | ︙ | |||
777 778 779 780 781 782 783 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ | | | | 793 794 795 796 797 798 799 800 801 802 | $(OBJDIR)\zip$O : zip_.c zip.h $(TCC) -o$@ -c zip_.c zip_.c : $(SRCDIR)\zip.c +translate$E $** > $@ headers: makeheaders$E page_index.h builtin_data.h VERSION.h +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h @copy /Y nul: headers |
Changes to win/Makefile.mingw.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #### Enable JSON (http://www.json.org) support using "cson" # # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # # FOSSIL_ENABLE_SSL = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 | #### Enable JSON (http://www.json.org) support using "cson" # # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # # FOSSIL_ENABLE_SSL = 1 #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 #### Enable TH1 scripts in embedded documentation files # # FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 #### Use 'system' SQLite # # USE_SYSTEM_SQLITE = 1 #### Use the miniz compression library # # FOSSIL_ENABLE_MINIZ = 1 #### Use the Tcl source directory instead of the install directory? # This is useful when Tcl has been compiled statically with MinGW. # FOSSIL_TCL_SOURCE = 1 #### Check if the workaround for the MinGW command line handling needs to # be enabled by default. # ifndef MINGW_IS_32BIT_ONLY ifeq (,$(findstring w64-mingw32,$(PREFIX))) MINGW_IS_32BIT_ONLY = 1 endif endif #### The directories where the zlib include and library files are located. # ZINCDIR = $(SRCDIR)/../compat/zlib ZLIBDIR = $(SRCDIR)/../compat/zlib ifndef X64 ifneq (,$(findstring x86_64-w64-mingw32,$(PREFIX))) X64 = 1 endif endif ifndef X64 SSLCONFIG = mingw ZLIBCONFIG = LOC="-DASMV -DASMINF" OBJA="inffas86.o match.o" LIBTARGETS = $(ZLIBDIR)/inffas86.o $(ZLIBDIR)/match.o else SSLCONFIG = mingw64 ZLIBCONFIG = LIBTARGETS = endif ifndef FOSSIL_ENABLE_MINIZ SSLCONFIG += --with-zlib-lib=$(PWD)/$(ZLIBDIR) --with-zlib-include=$(PWD)/$(ZLIBDIR) zlib endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLINCDIR = $(SRCDIR)/../compat/openssl-1.0.1j/include OPENSSLLIBDIR = $(SRCDIR)/../compat/openssl-1.0.1j #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If # this points to the Tcl source code directory, this directory must # have "generic" and "win" sub-directories. The recommended usage |
| ︙ | ︙ | |||
136 137 138 139 140 141 142 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | > > > > > > | > > > > > > > > > > > > > > > > | 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 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)gcc -Os -Wall #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ TCC += -L$(ZLIBDIR) -I$(ZINCDIR) endif #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g endif #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) ifndef FOSSIL_ENABLE_MINIZ RCC += -I$(ZINCDIR) endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -L$(OPENSSLLIBDIR) -I$(OPENSSLINCDIR) RCC += -I$(OPENSSLINCDIR) endif # With Tcl support ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_TCL_SOURCE TCC += -L$(TCLSRCDIR)/win -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win RCC += -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win else TCC += -L$(TCLLIBDIR) -I$(TCLINCDIR) RCC += -I$(TCLINCDIR) endif endif # With miniz (i.e. instead of zlib) ifdef FOSSIL_ENABLE_MINIZ TCC += -DFOSSIL_ENABLE_MINIZ=1 RCC += -DFOSSIL_ENABLE_MINIZ=1 endif # With MinGW command line handling workaround ifdef MINGW_IS_32BIT_ONLY TCC += -DBROKEN_MINGW_CMDLINE=1 RCC += -DBROKEN_MINGW_CMDLINE=1 endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif # With TH1 embedded docs support ifdef FOSSIL_ENABLE_TH1_DOCS TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 endif |
| ︙ | ︙ | |||
214 215 216 217 218 219 220 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static | | > > > | > | > | > > > > > > | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static #### MinGW: If available, use the Unicode capable runtime startup code. # ifndef MINGW_IS_32BIT_ONLY LIB += -municode endif #### SQLite: If enabled, use the system SQLite library. # ifdef USE_SYSTEM_SQLITE LIB += -lsqlite3 endif #### OpenSSL: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_SSL LIB += -lssl -lcrypto -lgdi32 endif #### Tcl: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_TCL LIB += $(LIBTCL) endif #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library. There are no # other mandatory dependencies. # LIB += -lmingwex #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ LIB += -lz endif #### These libraries MUST appear in the same order as they do for Tcl # or linking with it will not work (exact reason unknown). # ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_ENABLE_TCL_STUBS LIB += -lkernel32 -lws2_32 |
| ︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ | > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/builtin.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ |
| ︙ | ︙ | |||
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ | > > > > | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c EXTRA_FILES = \ $(SRCDIR)/diff.tcl TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/builtin_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ |
| ︙ | ︙ | |||
509 510 511 512 513 514 515 516 517 518 519 520 521 522 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ | > | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/builtin.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ |
| ︙ | ︙ | |||
613 614 615 616 617 618 619 | $(OBJDIR)/winfile.o \ $(OBJDIR)/winhttp.o \ $(OBJDIR)/wysiwyg.o \ $(OBJDIR)/xfer.o \ $(OBJDIR)/xfersetup.o \ $(OBJDIR)/zip.o | | > | | | | > > > | | | | > > > > > | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | $(OBJDIR)/winfile.o \ $(OBJDIR)/winhttp.o \ $(OBJDIR)/wysiwyg.o \ $(OBJDIR)/xfer.o \ $(OBJDIR)/xfersetup.o \ $(OBJDIR)/zip.o APPNAME = fossil.exe APPTARGETS = #### If the USE_WINDOWS variable exists, it is assumed that we are building # inside of a Windows-style shell; otherwise, it is assumed that we are # building inside of a Unix-style shell. Note that the "move" command is # broken when attempting to use it from the Windows shell via MinGW make # because the SHELL variable is only used for certain commands that are # recognized internally by make. # ifdef USE_WINDOWS TRANSLATE = $(subst /,\,$(OBJDIR)/translate.exe) MAKEHEADERS = $(subst /,\,$(OBJDIR)/makeheaders.exe) MKINDEX = $(subst /,\,$(OBJDIR)/mkindex.exe) MKBUILTIN = $(subst /,\,$(OBJDIR)/mkbuiltin.exe) MKVERSION = $(subst /,\,$(OBJDIR)/mkversion.exe) CODECHECK1 = $(subst /,\,$(OBJDIR)/codecheck1.exe) CAT = type CP = copy GREP = find MV = copy RM = del /Q MKDIR = -mkdir RMDIR = rmdir /S /Q else TRANSLATE = $(OBJDIR)/translate.exe MAKEHEADERS = $(OBJDIR)/makeheaders.exe MKINDEX = $(OBJDIR)/mkindex.exe MKBUILTIN = $(OBJDIR)/mkbuiltin.exe MKVERSION = $(OBJDIR)/mkversion.exe CODECHECK1 = $(OBJDIR)/codecheck1.exe CAT = cat CP = cp GREP = grep MV = mv RM = rm -f MKDIR = -mkdir -p RMDIR = rm -rf endif all: $(OBJDIR) $(APPNAME) $(OBJDIR)/fossil.o: $(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h ifdef USE_WINDOWS $(CAT) $(subst /,\,$(SRCDIR)\miniz.c) | $(GREP) "define MZ_VERSION" > $(subst /,\,$(OBJDIR)\minizver.h) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR)) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR)) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR)) else $(CAT) $(SRCDIR)/miniz.c | $(GREP) "define MZ_VERSION" > $(OBJDIR)/minizver.h $(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR) $(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR) $(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR) endif $(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o install: $(OBJDIR) $(APPNAME) |
| ︙ | ︙ | |||
676 677 678 679 680 681 682 | $(OBJDIR): ifdef USE_WINDOWS $(MKDIR) $(subst /,\,$(OBJDIR)) else $(MKDIR) $(OBJDIR) endif | | | | | | | > > > | | > > > | | | > > > > > > > > > | > > > > > > > | > > > > > > > > > > > | | > > > > > > | > | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | $(OBJDIR): ifdef USE_WINDOWS $(MKDIR) $(subst /,\,$(OBJDIR)) else $(MKDIR) $(OBJDIR) endif $(TRANSLATE): $(SRCDIR)/translate.c $(BCC) -o $@ $(SRCDIR)/translate.c $(MAKEHEADERS): $(SRCDIR)/makeheaders.c $(BCC) -o $@ $(SRCDIR)/makeheaders.c $(MKINDEX): $(SRCDIR)/mkindex.c $(BCC) -o $@ $(SRCDIR)/mkindex.c $(MKBUILTIN): $(SRCDIR)/mkbuiltin.c $(BCC) -o $@ $(SRCDIR)/mkbuiltin.c $(MKVERSION): $(SRCDIR)/mkversion.c $(BCC) -o $@ $(SRCDIR)/mkversion.c $(CODECHECK1): $(SRCDIR)/codecheck1.c $(BCC) -o $@ $(SRCDIR)/codecheck1.c # WARNING. DANGER. Running the test suite modifies the repository the # build is done from, i.e. the checkout belongs to. Do not sync/push # the repository after running the tests. test: $(OBJDIR) $(APPNAME) $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(MKVERSION) $(MKVERSION) $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$@ # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set # to 1. If it is set to 1, then there is no need to build or link # the sqlite3.o object. Instead, the system SQLite will be linked # using -lsqlite3. SQLITE3_OBJ.1 = SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o SQLITE3_OBJ. = $(SQLITE3_OBJ.0) # The FOSSIL_ENABLE_MINIZ variable may be undefined, set to 0, or # set to 1. If it is set to 1, the miniz library included in the # source tree should be used; otherwise, it should not. MINIZ_OBJ.0 = MINIZ_OBJ.1 = $(OBJDIR)/miniz.o MINIZ_OBJ. = $(MINIZ_OBJ.0) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \ $(OBJDIR)/shell.o \ $(OBJDIR)/th.o \ $(OBJDIR)/th_lang.o \ $(OBJDIR)/th_tcl.o \ $(OBJDIR)/cson_amalgamation.o zlib: $(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) $(ZLIBCONFIG) -f win32/Makefile.gcc libz.a clean-zlib: $(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) -f win32/Makefile.gcc clean $(ZLIBDIR)/inffas86.o: $(TCC) -c -o $@ -DASMINF -I$(ZLIBDIR) -O3 $(ZLIBDIR)/contrib/inflate86/inffas86.c $(ZLIBDIR)/match.o: $(TCC) -c -o $@ -DASMV $(ZLIBDIR)/contrib/asm686/match.S ifndef FOSSIL_ENABLE_MINIZ LIBTARGETS += zlib endif openssl: $(LIBTARGETS) cd $(OPENSSLLIBDIR);./Configure --cross-compile-prefix=$(PREFIX) $(SSLCONFIG) $(MAKE) -C $(OPENSSLLIBDIR) build_libs clean-openssl: $(MAKE) -C $(OPENSSLLIBDIR) clean tcl: cd $(TCLSRCDIR)/win;./configure $(MAKE) -C $(TCLSRCDIR)/win $(TCLTARGET) clean-tcl: $(MAKE) -C $(TCLSRCDIR)/win distclean APPTARGETS += $(LIBTARGETS) ifdef FOSSIL_BUILD_SSL APPTARGETS += openssl endif $(APPNAME): $(OBJDIR)/headers $(CODECHECK1) $(OBJ) $(EXTRAOBJ) $(OBJDIR)/fossil.o $(APPTARGETS) $(CODECHECK1) $(TRANS_SRC) $(TCC) -o $@ $(OBJ) $(EXTRAOBJ) $(LIB) $(OBJDIR)/fossil.o # This rule prevents make from using its default rules to try build # an executable named "manifest" out of the file named "manifest.c" # $(SRCDIR)/../manifest: # noop |
| ︙ | ︙ | |||
751 752 753 754 755 756 757 | setup: $(OBJDIR) $(APPNAME) $(MAKENSIS) ./setup/fossil.nsi innosetup: $(OBJDIR) $(APPNAME) $(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION) | | > > > | > | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | setup: $(OBJDIR) $(APPNAME) $(MAKENSIS) ./setup/fossil.nsi innosetup: $(OBJDIR) $(APPNAME) $(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION) $(OBJDIR)/page_index.h: $(TRANS_SRC) $(MKINDEX) $(MKINDEX) $(TRANS_SRC) >$@ $(OBJDIR)/builtin_data.h: $(MKBUILTIN) $(EXTRA_FILES) $(MKBUILTIN) $(EXTRA_FILES) >$@ $(OBJDIR)/headers: $(OBJDIR)/page_index.h $(OBJDIR)/builtin_data.h $(MAKEHEADERS) $(OBJDIR)/VERSION.h $(MAKEHEADERS) $(OBJDIR)/add_.c:$(OBJDIR)/add.h \ $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h \ $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h \ $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h \ $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h \ $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h \ $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h \ $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h \ $(OBJDIR)/builtin_.c:$(OBJDIR)/builtin.h \ $(OBJDIR)/cache_.c:$(OBJDIR)/cache.h \ $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h \ $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h \ $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h \ $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h \ $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h \ $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h \ |
| ︙ | ︙ | |||
875 876 877 878 879 880 881 | $(OBJDIR)/VERSION.h echo Done >$(OBJDIR)/headers $(OBJDIR)/headers: Makefile Makefile: | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > > > > > | | | | | | > > > | 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 |
$(OBJDIR)/VERSION.h
echo Done >$(OBJDIR)/headers
$(OBJDIR)/headers: Makefile
Makefile:
$(OBJDIR)/add_.c: $(SRCDIR)/add.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/add.c >$@
$(OBJDIR)/add.o: $(OBJDIR)/add_.c $(OBJDIR)/add.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/add.o -c $(OBJDIR)/add_.c
$(OBJDIR)/add.h: $(OBJDIR)/headers
$(OBJDIR)/allrepo_.c: $(SRCDIR)/allrepo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/allrepo.c >$@
$(OBJDIR)/allrepo.o: $(OBJDIR)/allrepo_.c $(OBJDIR)/allrepo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/allrepo.o -c $(OBJDIR)/allrepo_.c
$(OBJDIR)/allrepo.h: $(OBJDIR)/headers
$(OBJDIR)/attach_.c: $(SRCDIR)/attach.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/attach.c >$@
$(OBJDIR)/attach.o: $(OBJDIR)/attach_.c $(OBJDIR)/attach.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/attach.o -c $(OBJDIR)/attach_.c
$(OBJDIR)/attach.h: $(OBJDIR)/headers
$(OBJDIR)/bag_.c: $(SRCDIR)/bag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/bag.c >$@
$(OBJDIR)/bag.o: $(OBJDIR)/bag_.c $(OBJDIR)/bag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bag.o -c $(OBJDIR)/bag_.c
$(OBJDIR)/bag.h: $(OBJDIR)/headers
$(OBJDIR)/bisect_.c: $(SRCDIR)/bisect.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/bisect.c >$@
$(OBJDIR)/bisect.o: $(OBJDIR)/bisect_.c $(OBJDIR)/bisect.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bisect.o -c $(OBJDIR)/bisect_.c
$(OBJDIR)/bisect.h: $(OBJDIR)/headers
$(OBJDIR)/blob_.c: $(SRCDIR)/blob.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/blob.c >$@
$(OBJDIR)/blob.o: $(OBJDIR)/blob_.c $(OBJDIR)/blob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/blob.o -c $(OBJDIR)/blob_.c
$(OBJDIR)/blob.h: $(OBJDIR)/headers
$(OBJDIR)/branch_.c: $(SRCDIR)/branch.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/branch.c >$@
$(OBJDIR)/branch.o: $(OBJDIR)/branch_.c $(OBJDIR)/branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/branch.o -c $(OBJDIR)/branch_.c
$(OBJDIR)/branch.h: $(OBJDIR)/headers
$(OBJDIR)/browse_.c: $(SRCDIR)/browse.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/browse.c >$@
$(OBJDIR)/browse.o: $(OBJDIR)/browse_.c $(OBJDIR)/browse.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/browse.o -c $(OBJDIR)/browse_.c
$(OBJDIR)/browse.h: $(OBJDIR)/headers
$(OBJDIR)/builtin_.c: $(SRCDIR)/builtin.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/builtin.c >$@
$(OBJDIR)/builtin.o: $(OBJDIR)/builtin_.c $(OBJDIR)/builtin.h $(OBJDIR)/builtin_data.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/builtin.o -c $(OBJDIR)/builtin_.c
$(OBJDIR)/builtin.h: $(OBJDIR)/headers
$(OBJDIR)/cache_.c: $(SRCDIR)/cache.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/cache.c >$@
$(OBJDIR)/cache.o: $(OBJDIR)/cache_.c $(OBJDIR)/cache.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cache.o -c $(OBJDIR)/cache_.c
$(OBJDIR)/cache.h: $(OBJDIR)/headers
$(OBJDIR)/captcha_.c: $(SRCDIR)/captcha.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/captcha.c >$@
$(OBJDIR)/captcha.o: $(OBJDIR)/captcha_.c $(OBJDIR)/captcha.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/captcha.o -c $(OBJDIR)/captcha_.c
$(OBJDIR)/captcha.h: $(OBJDIR)/headers
$(OBJDIR)/cgi_.c: $(SRCDIR)/cgi.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/cgi.c >$@
$(OBJDIR)/cgi.o: $(OBJDIR)/cgi_.c $(OBJDIR)/cgi.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cgi.o -c $(OBJDIR)/cgi_.c
$(OBJDIR)/cgi.h: $(OBJDIR)/headers
$(OBJDIR)/checkin_.c: $(SRCDIR)/checkin.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/checkin.c >$@
$(OBJDIR)/checkin.o: $(OBJDIR)/checkin_.c $(OBJDIR)/checkin.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkin.o -c $(OBJDIR)/checkin_.c
$(OBJDIR)/checkin.h: $(OBJDIR)/headers
$(OBJDIR)/checkout_.c: $(SRCDIR)/checkout.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/checkout.c >$@
$(OBJDIR)/checkout.o: $(OBJDIR)/checkout_.c $(OBJDIR)/checkout.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkout.o -c $(OBJDIR)/checkout_.c
$(OBJDIR)/checkout.h: $(OBJDIR)/headers
$(OBJDIR)/clearsign_.c: $(SRCDIR)/clearsign.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/clearsign.c >$@
$(OBJDIR)/clearsign.o: $(OBJDIR)/clearsign_.c $(OBJDIR)/clearsign.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clearsign.o -c $(OBJDIR)/clearsign_.c
$(OBJDIR)/clearsign.h: $(OBJDIR)/headers
$(OBJDIR)/clone_.c: $(SRCDIR)/clone.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/clone.c >$@
$(OBJDIR)/clone.o: $(OBJDIR)/clone_.c $(OBJDIR)/clone.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clone.o -c $(OBJDIR)/clone_.c
$(OBJDIR)/clone.h: $(OBJDIR)/headers
$(OBJDIR)/comformat_.c: $(SRCDIR)/comformat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/comformat.c >$@
$(OBJDIR)/comformat.o: $(OBJDIR)/comformat_.c $(OBJDIR)/comformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/comformat.o -c $(OBJDIR)/comformat_.c
$(OBJDIR)/comformat.h: $(OBJDIR)/headers
$(OBJDIR)/configure_.c: $(SRCDIR)/configure.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/configure.c >$@
$(OBJDIR)/configure.o: $(OBJDIR)/configure_.c $(OBJDIR)/configure.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/configure.o -c $(OBJDIR)/configure_.c
$(OBJDIR)/configure.h: $(OBJDIR)/headers
$(OBJDIR)/content_.c: $(SRCDIR)/content.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/content.c >$@
$(OBJDIR)/content.o: $(OBJDIR)/content_.c $(OBJDIR)/content.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/content.o -c $(OBJDIR)/content_.c
$(OBJDIR)/content.h: $(OBJDIR)/headers
$(OBJDIR)/db_.c: $(SRCDIR)/db.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/db.c >$@
$(OBJDIR)/db.o: $(OBJDIR)/db_.c $(OBJDIR)/db.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/db.o -c $(OBJDIR)/db_.c
$(OBJDIR)/db.h: $(OBJDIR)/headers
$(OBJDIR)/delta_.c: $(SRCDIR)/delta.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/delta.c >$@
$(OBJDIR)/delta.o: $(OBJDIR)/delta_.c $(OBJDIR)/delta.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/delta.o -c $(OBJDIR)/delta_.c
$(OBJDIR)/delta.h: $(OBJDIR)/headers
$(OBJDIR)/deltacmd_.c: $(SRCDIR)/deltacmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/deltacmd.c >$@
$(OBJDIR)/deltacmd.o: $(OBJDIR)/deltacmd_.c $(OBJDIR)/deltacmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/deltacmd.o -c $(OBJDIR)/deltacmd_.c
$(OBJDIR)/deltacmd.h: $(OBJDIR)/headers
$(OBJDIR)/descendants_.c: $(SRCDIR)/descendants.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/descendants.c >$@
$(OBJDIR)/descendants.o: $(OBJDIR)/descendants_.c $(OBJDIR)/descendants.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/descendants.o -c $(OBJDIR)/descendants_.c
$(OBJDIR)/descendants.h: $(OBJDIR)/headers
$(OBJDIR)/diff_.c: $(SRCDIR)/diff.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/diff.c >$@
$(OBJDIR)/diff.o: $(OBJDIR)/diff_.c $(OBJDIR)/diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diff.o -c $(OBJDIR)/diff_.c
$(OBJDIR)/diff.h: $(OBJDIR)/headers
$(OBJDIR)/diffcmd_.c: $(SRCDIR)/diffcmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/diffcmd.c >$@
$(OBJDIR)/diffcmd.o: $(OBJDIR)/diffcmd_.c $(OBJDIR)/diffcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diffcmd.o -c $(OBJDIR)/diffcmd_.c
$(OBJDIR)/diffcmd.h: $(OBJDIR)/headers
$(OBJDIR)/doc_.c: $(SRCDIR)/doc.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/doc.c >$@
$(OBJDIR)/doc.o: $(OBJDIR)/doc_.c $(OBJDIR)/doc.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/doc.o -c $(OBJDIR)/doc_.c
$(OBJDIR)/doc.h: $(OBJDIR)/headers
$(OBJDIR)/encode_.c: $(SRCDIR)/encode.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/encode.c >$@
$(OBJDIR)/encode.o: $(OBJDIR)/encode_.c $(OBJDIR)/encode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/encode.o -c $(OBJDIR)/encode_.c
$(OBJDIR)/encode.h: $(OBJDIR)/headers
$(OBJDIR)/event_.c: $(SRCDIR)/event.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/event.c >$@
$(OBJDIR)/event.o: $(OBJDIR)/event_.c $(OBJDIR)/event.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/event.o -c $(OBJDIR)/event_.c
$(OBJDIR)/event.h: $(OBJDIR)/headers
$(OBJDIR)/export_.c: $(SRCDIR)/export.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/export.c >$@
$(OBJDIR)/export.o: $(OBJDIR)/export_.c $(OBJDIR)/export.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/export.o -c $(OBJDIR)/export_.c
$(OBJDIR)/export.h: $(OBJDIR)/headers
$(OBJDIR)/file_.c: $(SRCDIR)/file.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/file.c >$@
$(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c
$(OBJDIR)/file.h: $(OBJDIR)/headers
$(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/finfo.c >$@
$(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c
$(OBJDIR)/finfo.h: $(OBJDIR)/headers
$(OBJDIR)/fusefs_.c: $(SRCDIR)/fusefs.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/fusefs.c >$@
$(OBJDIR)/fusefs.o: $(OBJDIR)/fusefs_.c $(OBJDIR)/fusefs.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/fusefs.o -c $(OBJDIR)/fusefs_.c
$(OBJDIR)/fusefs.h: $(OBJDIR)/headers
$(OBJDIR)/glob_.c: $(SRCDIR)/glob.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/glob.c >$@
$(OBJDIR)/glob.o: $(OBJDIR)/glob_.c $(OBJDIR)/glob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/glob.o -c $(OBJDIR)/glob_.c
$(OBJDIR)/glob.h: $(OBJDIR)/headers
$(OBJDIR)/graph_.c: $(SRCDIR)/graph.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/graph.c >$@
$(OBJDIR)/graph.o: $(OBJDIR)/graph_.c $(OBJDIR)/graph.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/graph.o -c $(OBJDIR)/graph_.c
$(OBJDIR)/graph.h: $(OBJDIR)/headers
$(OBJDIR)/gzip_.c: $(SRCDIR)/gzip.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/gzip.c >$@
$(OBJDIR)/gzip.o: $(OBJDIR)/gzip_.c $(OBJDIR)/gzip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/gzip.o -c $(OBJDIR)/gzip_.c
$(OBJDIR)/gzip.h: $(OBJDIR)/headers
$(OBJDIR)/http_.c: $(SRCDIR)/http.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http.c >$@
$(OBJDIR)/http.o: $(OBJDIR)/http_.c $(OBJDIR)/http.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http.o -c $(OBJDIR)/http_.c
$(OBJDIR)/http.h: $(OBJDIR)/headers
$(OBJDIR)/http_socket_.c: $(SRCDIR)/http_socket.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_socket.c >$@
$(OBJDIR)/http_socket.o: $(OBJDIR)/http_socket_.c $(OBJDIR)/http_socket.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_socket.o -c $(OBJDIR)/http_socket_.c
$(OBJDIR)/http_socket.h: $(OBJDIR)/headers
$(OBJDIR)/http_ssl_.c: $(SRCDIR)/http_ssl.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_ssl.c >$@
$(OBJDIR)/http_ssl.o: $(OBJDIR)/http_ssl_.c $(OBJDIR)/http_ssl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_ssl.o -c $(OBJDIR)/http_ssl_.c
$(OBJDIR)/http_ssl.h: $(OBJDIR)/headers
$(OBJDIR)/http_transport_.c: $(SRCDIR)/http_transport.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_transport.c >$@
$(OBJDIR)/http_transport.o: $(OBJDIR)/http_transport_.c $(OBJDIR)/http_transport.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_transport.o -c $(OBJDIR)/http_transport_.c
$(OBJDIR)/http_transport.h: $(OBJDIR)/headers
$(OBJDIR)/import_.c: $(SRCDIR)/import.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/import.c >$@
$(OBJDIR)/import.o: $(OBJDIR)/import_.c $(OBJDIR)/import.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/import.o -c $(OBJDIR)/import_.c
$(OBJDIR)/import.h: $(OBJDIR)/headers
$(OBJDIR)/info_.c: $(SRCDIR)/info.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/info.c >$@
$(OBJDIR)/info.o: $(OBJDIR)/info_.c $(OBJDIR)/info.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/info.o -c $(OBJDIR)/info_.c
$(OBJDIR)/info.h: $(OBJDIR)/headers
$(OBJDIR)/json_.c: $(SRCDIR)/json.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json.c >$@
$(OBJDIR)/json.o: $(OBJDIR)/json_.c $(OBJDIR)/json.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json.o -c $(OBJDIR)/json_.c
$(OBJDIR)/json.h: $(OBJDIR)/headers
$(OBJDIR)/json_artifact_.c: $(SRCDIR)/json_artifact.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_artifact.c >$@
$(OBJDIR)/json_artifact.o: $(OBJDIR)/json_artifact_.c $(OBJDIR)/json_artifact.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_artifact.o -c $(OBJDIR)/json_artifact_.c
$(OBJDIR)/json_artifact.h: $(OBJDIR)/headers
$(OBJDIR)/json_branch_.c: $(SRCDIR)/json_branch.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_branch.c >$@
$(OBJDIR)/json_branch.o: $(OBJDIR)/json_branch_.c $(OBJDIR)/json_branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_branch.o -c $(OBJDIR)/json_branch_.c
$(OBJDIR)/json_branch.h: $(OBJDIR)/headers
$(OBJDIR)/json_config_.c: $(SRCDIR)/json_config.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_config.c >$@
$(OBJDIR)/json_config.o: $(OBJDIR)/json_config_.c $(OBJDIR)/json_config.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_config.o -c $(OBJDIR)/json_config_.c
$(OBJDIR)/json_config.h: $(OBJDIR)/headers
$(OBJDIR)/json_diff_.c: $(SRCDIR)/json_diff.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_diff.c >$@
$(OBJDIR)/json_diff.o: $(OBJDIR)/json_diff_.c $(OBJDIR)/json_diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_diff.o -c $(OBJDIR)/json_diff_.c
$(OBJDIR)/json_diff.h: $(OBJDIR)/headers
$(OBJDIR)/json_dir_.c: $(SRCDIR)/json_dir.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_dir.c >$@
$(OBJDIR)/json_dir.o: $(OBJDIR)/json_dir_.c $(OBJDIR)/json_dir.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_dir.o -c $(OBJDIR)/json_dir_.c
$(OBJDIR)/json_dir.h: $(OBJDIR)/headers
$(OBJDIR)/json_finfo_.c: $(SRCDIR)/json_finfo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_finfo.c >$@
$(OBJDIR)/json_finfo.o: $(OBJDIR)/json_finfo_.c $(OBJDIR)/json_finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_finfo.o -c $(OBJDIR)/json_finfo_.c
$(OBJDIR)/json_finfo.h: $(OBJDIR)/headers
$(OBJDIR)/json_login_.c: $(SRCDIR)/json_login.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_login.c >$@
$(OBJDIR)/json_login.o: $(OBJDIR)/json_login_.c $(OBJDIR)/json_login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_login.o -c $(OBJDIR)/json_login_.c
$(OBJDIR)/json_login.h: $(OBJDIR)/headers
$(OBJDIR)/json_query_.c: $(SRCDIR)/json_query.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_query.c >$@
$(OBJDIR)/json_query.o: $(OBJDIR)/json_query_.c $(OBJDIR)/json_query.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_query.o -c $(OBJDIR)/json_query_.c
$(OBJDIR)/json_query.h: $(OBJDIR)/headers
$(OBJDIR)/json_report_.c: $(SRCDIR)/json_report.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_report.c >$@
$(OBJDIR)/json_report.o: $(OBJDIR)/json_report_.c $(OBJDIR)/json_report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_report.o -c $(OBJDIR)/json_report_.c
$(OBJDIR)/json_report.h: $(OBJDIR)/headers
$(OBJDIR)/json_status_.c: $(SRCDIR)/json_status.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_status.c >$@
$(OBJDIR)/json_status.o: $(OBJDIR)/json_status_.c $(OBJDIR)/json_status.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_status.o -c $(OBJDIR)/json_status_.c
$(OBJDIR)/json_status.h: $(OBJDIR)/headers
$(OBJDIR)/json_tag_.c: $(SRCDIR)/json_tag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_tag.c >$@
$(OBJDIR)/json_tag.o: $(OBJDIR)/json_tag_.c $(OBJDIR)/json_tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_tag.o -c $(OBJDIR)/json_tag_.c
$(OBJDIR)/json_tag.h: $(OBJDIR)/headers
$(OBJDIR)/json_timeline_.c: $(SRCDIR)/json_timeline.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_timeline.c >$@
$(OBJDIR)/json_timeline.o: $(OBJDIR)/json_timeline_.c $(OBJDIR)/json_timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_timeline.o -c $(OBJDIR)/json_timeline_.c
$(OBJDIR)/json_timeline.h: $(OBJDIR)/headers
$(OBJDIR)/json_user_.c: $(SRCDIR)/json_user.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_user.c >$@
$(OBJDIR)/json_user.o: $(OBJDIR)/json_user_.c $(OBJDIR)/json_user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_user.o -c $(OBJDIR)/json_user_.c
$(OBJDIR)/json_user.h: $(OBJDIR)/headers
$(OBJDIR)/json_wiki_.c: $(SRCDIR)/json_wiki.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_wiki.c >$@
$(OBJDIR)/json_wiki.o: $(OBJDIR)/json_wiki_.c $(OBJDIR)/json_wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_wiki.o -c $(OBJDIR)/json_wiki_.c
$(OBJDIR)/json_wiki.h: $(OBJDIR)/headers
$(OBJDIR)/leaf_.c: $(SRCDIR)/leaf.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/leaf.c >$@
$(OBJDIR)/leaf.o: $(OBJDIR)/leaf_.c $(OBJDIR)/leaf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/leaf.o -c $(OBJDIR)/leaf_.c
$(OBJDIR)/leaf.h: $(OBJDIR)/headers
$(OBJDIR)/loadctrl_.c: $(SRCDIR)/loadctrl.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/loadctrl.c >$@
$(OBJDIR)/loadctrl.o: $(OBJDIR)/loadctrl_.c $(OBJDIR)/loadctrl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/loadctrl.o -c $(OBJDIR)/loadctrl_.c
$(OBJDIR)/loadctrl.h: $(OBJDIR)/headers
$(OBJDIR)/login_.c: $(SRCDIR)/login.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/login.c >$@
$(OBJDIR)/login.o: $(OBJDIR)/login_.c $(OBJDIR)/login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/login.o -c $(OBJDIR)/login_.c
$(OBJDIR)/login.h: $(OBJDIR)/headers
$(OBJDIR)/lookslike_.c: $(SRCDIR)/lookslike.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/lookslike.c >$@
$(OBJDIR)/lookslike.o: $(OBJDIR)/lookslike_.c $(OBJDIR)/lookslike.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/lookslike.o -c $(OBJDIR)/lookslike_.c
$(OBJDIR)/lookslike.h: $(OBJDIR)/headers
$(OBJDIR)/main_.c: $(SRCDIR)/main.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/main.c >$@
$(OBJDIR)/main.o: $(OBJDIR)/main_.c $(OBJDIR)/main.h $(OBJDIR)/page_index.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/main.o -c $(OBJDIR)/main_.c
$(OBJDIR)/main.h: $(OBJDIR)/headers
$(OBJDIR)/manifest_.c: $(SRCDIR)/manifest.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/manifest.c >$@
$(OBJDIR)/manifest.o: $(OBJDIR)/manifest_.c $(OBJDIR)/manifest.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/manifest.o -c $(OBJDIR)/manifest_.c
$(OBJDIR)/manifest.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_.c: $(SRCDIR)/markdown.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/markdown.c >$@
$(OBJDIR)/markdown.o: $(OBJDIR)/markdown_.c $(OBJDIR)/markdown.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown.o -c $(OBJDIR)/markdown_.c
$(OBJDIR)/markdown.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_html_.c: $(SRCDIR)/markdown_html.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/markdown_html.c >$@
$(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
$(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
$(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/md5.c >$@
$(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/md5.o -c $(OBJDIR)/md5_.c
$(OBJDIR)/md5.h: $(OBJDIR)/headers
$(OBJDIR)/merge_.c: $(SRCDIR)/merge.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/merge.c >$@
$(OBJDIR)/merge.o: $(OBJDIR)/merge_.c $(OBJDIR)/merge.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge.o -c $(OBJDIR)/merge_.c
$(OBJDIR)/merge.h: $(OBJDIR)/headers
$(OBJDIR)/merge3_.c: $(SRCDIR)/merge3.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/merge3.c >$@
$(OBJDIR)/merge3.o: $(OBJDIR)/merge3_.c $(OBJDIR)/merge3.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge3.o -c $(OBJDIR)/merge3_.c
$(OBJDIR)/merge3.h: $(OBJDIR)/headers
$(OBJDIR)/moderate_.c: $(SRCDIR)/moderate.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/moderate.c >$@
$(OBJDIR)/moderate.o: $(OBJDIR)/moderate_.c $(OBJDIR)/moderate.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/moderate.o -c $(OBJDIR)/moderate_.c
$(OBJDIR)/moderate.h: $(OBJDIR)/headers
$(OBJDIR)/name_.c: $(SRCDIR)/name.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/name.c >$@
$(OBJDIR)/name.o: $(OBJDIR)/name_.c $(OBJDIR)/name.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/name.o -c $(OBJDIR)/name_.c
$(OBJDIR)/name.h: $(OBJDIR)/headers
$(OBJDIR)/path_.c: $(SRCDIR)/path.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/path.c >$@
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
$(OBJDIR)/path.h: $(OBJDIR)/headers
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/pivot.c >$@
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pivot.o -c $(OBJDIR)/pivot_.c
$(OBJDIR)/pivot.h: $(OBJDIR)/headers
$(OBJDIR)/popen_.c: $(SRCDIR)/popen.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/popen.c >$@
$(OBJDIR)/popen.o: $(OBJDIR)/popen_.c $(OBJDIR)/popen.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/popen.o -c $(OBJDIR)/popen_.c
$(OBJDIR)/popen.h: $(OBJDIR)/headers
$(OBJDIR)/pqueue_.c: $(SRCDIR)/pqueue.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/pqueue.c >$@
$(OBJDIR)/pqueue.o: $(OBJDIR)/pqueue_.c $(OBJDIR)/pqueue.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pqueue.o -c $(OBJDIR)/pqueue_.c
$(OBJDIR)/pqueue.h: $(OBJDIR)/headers
$(OBJDIR)/printf_.c: $(SRCDIR)/printf.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/printf.c >$@
$(OBJDIR)/printf.o: $(OBJDIR)/printf_.c $(OBJDIR)/printf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/printf.o -c $(OBJDIR)/printf_.c
$(OBJDIR)/printf.h: $(OBJDIR)/headers
$(OBJDIR)/rebuild_.c: $(SRCDIR)/rebuild.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/rebuild.c >$@
$(OBJDIR)/rebuild.o: $(OBJDIR)/rebuild_.c $(OBJDIR)/rebuild.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rebuild.o -c $(OBJDIR)/rebuild_.c
$(OBJDIR)/rebuild.h: $(OBJDIR)/headers
$(OBJDIR)/regexp_.c: $(SRCDIR)/regexp.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/regexp.c >$@
$(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
$(OBJDIR)/regexp.h: $(OBJDIR)/headers
$(OBJDIR)/report_.c: $(SRCDIR)/report.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/report.c >$@
$(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/report.o -c $(OBJDIR)/report_.c
$(OBJDIR)/report.h: $(OBJDIR)/headers
$(OBJDIR)/rss_.c: $(SRCDIR)/rss.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/rss.c >$@
$(OBJDIR)/rss.o: $(OBJDIR)/rss_.c $(OBJDIR)/rss.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rss.o -c $(OBJDIR)/rss_.c
$(OBJDIR)/rss.h: $(OBJDIR)/headers
$(OBJDIR)/schema_.c: $(SRCDIR)/schema.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/schema.c >$@
$(OBJDIR)/schema.o: $(OBJDIR)/schema_.c $(OBJDIR)/schema.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/schema.o -c $(OBJDIR)/schema_.c
$(OBJDIR)/schema.h: $(OBJDIR)/headers
$(OBJDIR)/search_.c: $(SRCDIR)/search.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/search.c >$@
$(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c
$(OBJDIR)/search.h: $(OBJDIR)/headers
$(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/setup.c >$@
$(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c
$(OBJDIR)/setup.h: $(OBJDIR)/headers
$(OBJDIR)/sha1_.c: $(SRCDIR)/sha1.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sha1.c >$@
$(OBJDIR)/sha1.o: $(OBJDIR)/sha1_.c $(OBJDIR)/sha1.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sha1.o -c $(OBJDIR)/sha1_.c
$(OBJDIR)/sha1.h: $(OBJDIR)/headers
$(OBJDIR)/shun_.c: $(SRCDIR)/shun.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/shun.c >$@
$(OBJDIR)/shun.o: $(OBJDIR)/shun_.c $(OBJDIR)/shun.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/shun.o -c $(OBJDIR)/shun_.c
$(OBJDIR)/shun.h: $(OBJDIR)/headers
$(OBJDIR)/skins_.c: $(SRCDIR)/skins.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/skins.c >$@
$(OBJDIR)/skins.o: $(OBJDIR)/skins_.c $(OBJDIR)/skins.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/skins.o -c $(OBJDIR)/skins_.c
$(OBJDIR)/skins.h: $(OBJDIR)/headers
$(OBJDIR)/sqlcmd_.c: $(SRCDIR)/sqlcmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sqlcmd.c >$@
$(OBJDIR)/sqlcmd.o: $(OBJDIR)/sqlcmd_.c $(OBJDIR)/sqlcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sqlcmd.o -c $(OBJDIR)/sqlcmd_.c
$(OBJDIR)/sqlcmd.h: $(OBJDIR)/headers
$(OBJDIR)/stash_.c: $(SRCDIR)/stash.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/stash.c >$@
$(OBJDIR)/stash.o: $(OBJDIR)/stash_.c $(OBJDIR)/stash.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stash.o -c $(OBJDIR)/stash_.c
$(OBJDIR)/stash.h: $(OBJDIR)/headers
$(OBJDIR)/stat_.c: $(SRCDIR)/stat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/stat.c >$@
$(OBJDIR)/stat.o: $(OBJDIR)/stat_.c $(OBJDIR)/stat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stat.o -c $(OBJDIR)/stat_.c
$(OBJDIR)/stat.h: $(OBJDIR)/headers
$(OBJDIR)/style_.c: $(SRCDIR)/style.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/style.c >$@
$(OBJDIR)/style.o: $(OBJDIR)/style_.c $(OBJDIR)/style.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/style.o -c $(OBJDIR)/style_.c
$(OBJDIR)/style.h: $(OBJDIR)/headers
$(OBJDIR)/sync_.c: $(SRCDIR)/sync.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sync.c >$@
$(OBJDIR)/sync.o: $(OBJDIR)/sync_.c $(OBJDIR)/sync.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sync.o -c $(OBJDIR)/sync_.c
$(OBJDIR)/sync.h: $(OBJDIR)/headers
$(OBJDIR)/tag_.c: $(SRCDIR)/tag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tag.c >$@
$(OBJDIR)/tag.o: $(OBJDIR)/tag_.c $(OBJDIR)/tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tag.o -c $(OBJDIR)/tag_.c
$(OBJDIR)/tag.h: $(OBJDIR)/headers
$(OBJDIR)/tar_.c: $(SRCDIR)/tar.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tar.c >$@
$(OBJDIR)/tar.o: $(OBJDIR)/tar_.c $(OBJDIR)/tar.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tar.o -c $(OBJDIR)/tar_.c
$(OBJDIR)/tar.h: $(OBJDIR)/headers
$(OBJDIR)/th_main_.c: $(SRCDIR)/th_main.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/th_main.c >$@
$(OBJDIR)/th_main.o: $(OBJDIR)/th_main_.c $(OBJDIR)/th_main.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/th_main.o -c $(OBJDIR)/th_main_.c
$(OBJDIR)/th_main.h: $(OBJDIR)/headers
$(OBJDIR)/timeline_.c: $(SRCDIR)/timeline.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/timeline.c >$@
$(OBJDIR)/timeline.o: $(OBJDIR)/timeline_.c $(OBJDIR)/timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/timeline.o -c $(OBJDIR)/timeline_.c
$(OBJDIR)/timeline.h: $(OBJDIR)/headers
$(OBJDIR)/tkt_.c: $(SRCDIR)/tkt.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tkt.c >$@
$(OBJDIR)/tkt.o: $(OBJDIR)/tkt_.c $(OBJDIR)/tkt.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tkt.o -c $(OBJDIR)/tkt_.c
$(OBJDIR)/tkt.h: $(OBJDIR)/headers
$(OBJDIR)/tktsetup_.c: $(SRCDIR)/tktsetup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tktsetup.c >$@
$(OBJDIR)/tktsetup.o: $(OBJDIR)/tktsetup_.c $(OBJDIR)/tktsetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tktsetup.o -c $(OBJDIR)/tktsetup_.c
$(OBJDIR)/tktsetup.h: $(OBJDIR)/headers
$(OBJDIR)/undo_.c: $(SRCDIR)/undo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/undo.c >$@
$(OBJDIR)/undo.o: $(OBJDIR)/undo_.c $(OBJDIR)/undo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/undo.o -c $(OBJDIR)/undo_.c
$(OBJDIR)/undo.h: $(OBJDIR)/headers
$(OBJDIR)/unicode_.c: $(SRCDIR)/unicode.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/unicode.c >$@
$(OBJDIR)/unicode.o: $(OBJDIR)/unicode_.c $(OBJDIR)/unicode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/unicode.o -c $(OBJDIR)/unicode_.c
$(OBJDIR)/unicode.h: $(OBJDIR)/headers
$(OBJDIR)/update_.c: $(SRCDIR)/update.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/update.c >$@
$(OBJDIR)/update.o: $(OBJDIR)/update_.c $(OBJDIR)/update.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/update.o -c $(OBJDIR)/update_.c
$(OBJDIR)/update.h: $(OBJDIR)/headers
$(OBJDIR)/url_.c: $(SRCDIR)/url.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/url.c >$@
$(OBJDIR)/url.o: $(OBJDIR)/url_.c $(OBJDIR)/url.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/url.o -c $(OBJDIR)/url_.c
$(OBJDIR)/url.h: $(OBJDIR)/headers
$(OBJDIR)/user_.c: $(SRCDIR)/user.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/user.c >$@
$(OBJDIR)/user.o: $(OBJDIR)/user_.c $(OBJDIR)/user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/user.o -c $(OBJDIR)/user_.c
$(OBJDIR)/user.h: $(OBJDIR)/headers
$(OBJDIR)/utf8_.c: $(SRCDIR)/utf8.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/utf8.c >$@
$(OBJDIR)/utf8.o: $(OBJDIR)/utf8_.c $(OBJDIR)/utf8.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/utf8.o -c $(OBJDIR)/utf8_.c
$(OBJDIR)/utf8.h: $(OBJDIR)/headers
$(OBJDIR)/util_.c: $(SRCDIR)/util.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/util.c >$@
$(OBJDIR)/util.o: $(OBJDIR)/util_.c $(OBJDIR)/util.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/util.o -c $(OBJDIR)/util_.c
$(OBJDIR)/util.h: $(OBJDIR)/headers
$(OBJDIR)/verify_.c: $(SRCDIR)/verify.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/verify.c >$@
$(OBJDIR)/verify.o: $(OBJDIR)/verify_.c $(OBJDIR)/verify.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/verify.o -c $(OBJDIR)/verify_.c
$(OBJDIR)/verify.h: $(OBJDIR)/headers
$(OBJDIR)/vfile_.c: $(SRCDIR)/vfile.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/vfile.c >$@
$(OBJDIR)/vfile.o: $(OBJDIR)/vfile_.c $(OBJDIR)/vfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/vfile.o -c $(OBJDIR)/vfile_.c
$(OBJDIR)/vfile.h: $(OBJDIR)/headers
$(OBJDIR)/wiki_.c: $(SRCDIR)/wiki.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wiki.c >$@
$(OBJDIR)/wiki.o: $(OBJDIR)/wiki_.c $(OBJDIR)/wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wiki.o -c $(OBJDIR)/wiki_.c
$(OBJDIR)/wiki.h: $(OBJDIR)/headers
$(OBJDIR)/wikiformat_.c: $(SRCDIR)/wikiformat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wikiformat.c >$@
$(OBJDIR)/wikiformat.o: $(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
$(OBJDIR)/wikiformat.h: $(OBJDIR)/headers
$(OBJDIR)/winfile_.c: $(SRCDIR)/winfile.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/winfile.c >$@
$(OBJDIR)/winfile.o: $(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
$(OBJDIR)/winfile.h: $(OBJDIR)/headers
$(OBJDIR)/winhttp_.c: $(SRCDIR)/winhttp.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/winhttp.c >$@
$(OBJDIR)/winhttp.o: $(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
$(OBJDIR)/winhttp.h: $(OBJDIR)/headers
$(OBJDIR)/wysiwyg_.c: $(SRCDIR)/wysiwyg.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wysiwyg.c >$@
$(OBJDIR)/wysiwyg.o: $(OBJDIR)/wysiwyg_.c $(OBJDIR)/wysiwyg.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wysiwyg.o -c $(OBJDIR)/wysiwyg_.c
$(OBJDIR)/wysiwyg.h: $(OBJDIR)/headers
$(OBJDIR)/xfer_.c: $(SRCDIR)/xfer.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/xfer.c >$@
$(OBJDIR)/xfer.o: $(OBJDIR)/xfer_.c $(OBJDIR)/xfer.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfer.o -c $(OBJDIR)/xfer_.c
$(OBJDIR)/xfer.h: $(OBJDIR)/headers
$(OBJDIR)/xfersetup_.c: $(SRCDIR)/xfersetup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/xfersetup.c >$@
$(OBJDIR)/xfersetup.o: $(OBJDIR)/xfersetup_.c $(OBJDIR)/xfersetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfersetup.o -c $(OBJDIR)/xfersetup_.c
$(OBJDIR)/xfersetup.h: $(OBJDIR)/headers
$(OBJDIR)/zip_.c: $(SRCDIR)/zip.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/zip.c >$@
$(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
$(OBJDIR)/zip.h: $(OBJDIR)/headers
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_WIN32_NO_ANSI \
-D_HAVE__MINGW_H \
-DSQLITE_USE_MALLOC_H \
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
-DSQLITE_SHELL_DBNAME_PROC=fossil_open \
-Daccess=file_access \
-Dsystem=fossil_system \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
MINIZ_OPTIONS = -DMINIZ_NO_STDIO \
-DMINIZ_NO_TIME \
-DMINIZ_NO_ARCHIVE_APIS
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c $(SRCDIR)/../win/Makefile.mingw
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw
$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $@
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -c $(SRCDIR)/th.c -o $@
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -c $(SRCDIR)/th_lang.c -o $@
$(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
$(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
$(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
$(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
|
Changes to win/Makefile.mingw.mistachkin.
| ︙ | ︙ | |||
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | #### Enable JSON (http://www.json.org) support using "cson" # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # FOSSIL_ENABLE_SSL = 1 #### Enable hooks for commands and web pages via TH1 # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 | > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > | | | 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 | #### Enable JSON (http://www.json.org) support using "cson" # FOSSIL_ENABLE_JSON = 1 #### Enable HTTPS support via OpenSSL (links to libssl and libcrypto) # FOSSIL_ENABLE_SSL = 1 #### Automatically build OpenSSL when building Fossil (causes rebuild # issues when building incrementally). # # FOSSIL_BUILD_SSL = 1 #### Enable TH1 scripts in embedded documentation files # # FOSSIL_ENABLE_TH1_DOCS = 1 #### Enable hooks for commands and web pages via TH1 # FOSSIL_ENABLE_TH1_HOOKS = 1 #### Enable scripting support via Tcl/Tk # FOSSIL_ENABLE_TCL = 1 #### Load Tcl using the stubs library mechanism # FOSSIL_ENABLE_TCL_STUBS = 1 #### Load Tcl using the private stubs mechanism # FOSSIL_ENABLE_TCL_PRIVATE_STUBS = 1 #### Use 'system' SQLite # # USE_SYSTEM_SQLITE = 1 #### Use the miniz compression library # # FOSSIL_ENABLE_MINIZ = 1 #### Use the Tcl source directory instead of the install directory? # This is useful when Tcl has been compiled statically with MinGW. # FOSSIL_TCL_SOURCE = 1 #### Check if the workaround for the MinGW command line handling needs to # be enabled by default. # ifndef MINGW_IS_32BIT_ONLY ifeq (,$(findstring w64-mingw32,$(PREFIX))) MINGW_IS_32BIT_ONLY = 1 endif endif #### The directories where the zlib include and library files are located. # ZINCDIR = $(SRCDIR)/../compat/zlib ZLIBDIR = $(SRCDIR)/../compat/zlib ifndef X64 ifneq (,$(findstring x86_64-w64-mingw32,$(PREFIX))) X64 = 1 endif endif ifndef X64 SSLCONFIG = mingw ZLIBCONFIG = LOC="-DASMV -DASMINF" OBJA="inffas86.o match.o" LIBTARGETS = $(ZLIBDIR)/inffas86.o $(ZLIBDIR)/match.o else SSLCONFIG = mingw64 ZLIBCONFIG = LIBTARGETS = endif ifndef FOSSIL_ENABLE_MINIZ SSLCONFIG += --with-zlib-lib=$(PWD)/$(ZLIBDIR) --with-zlib-include=$(PWD)/$(ZLIBDIR) zlib endif #### The directories where the OpenSSL include and library files are located. # The recommended usage here is to use the Sysinternals junction tool # to create a hard link between an "openssl-1.x" sub-directory of the # Fossil source code directory and the target OpenSSL source directory. # OPENSSLINCDIR = $(SRCDIR)/../compat/openssl-1.0.1j/include OPENSSLLIBDIR = $(SRCDIR)/../compat/openssl-1.0.1j #### Either the directory where the Tcl library is installed or the Tcl # source code directory resides (depending on the value of the macro # FOSSIL_TCL_SOURCE). If this points to the Tcl install directory, # this directory must have "include" and "lib" sub-directories. If # this points to the Tcl source code directory, this directory must # have "generic" and "win" sub-directories. The recommended usage |
| ︙ | ︙ | |||
136 137 138 139 140 141 142 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # | | > > > > > > | > > > > > > > > > > > > > > > > | 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 | #### C Compile and options for use in building executables that # will run on the target platform. This is usually the same # as BCC, unless you are cross-compiling. This C compiler builds # the finished binary for fossil. The BCC compiler above is used # for building intermediate code-generator tools. # TCC = $(PREFIX)gcc -Os -Wall #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ TCC += -L$(ZLIBDIR) -I$(ZINCDIR) endif #### Add the necessary command line options to build with debugging # symbols, if enabled. # ifdef FOSSIL_ENABLE_SYMBOLS TCC += -g endif #### Compile resources for use in building executables that will run # on the target platform. # RCC = $(PREFIX)windres -I$(SRCDIR) ifndef FOSSIL_ENABLE_MINIZ RCC += -I$(ZINCDIR) endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -L$(OPENSSLLIBDIR) -I$(OPENSSLINCDIR) RCC += -I$(OPENSSLINCDIR) endif # With Tcl support ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_TCL_SOURCE TCC += -L$(TCLSRCDIR)/win -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win RCC += -I$(TCLSRCDIR)/generic -I$(TCLSRCDIR)/win else TCC += -L$(TCLLIBDIR) -I$(TCLINCDIR) RCC += -I$(TCLINCDIR) endif endif # With miniz (i.e. instead of zlib) ifdef FOSSIL_ENABLE_MINIZ TCC += -DFOSSIL_ENABLE_MINIZ=1 RCC += -DFOSSIL_ENABLE_MINIZ=1 endif # With MinGW command line handling workaround ifdef MINGW_IS_32BIT_ONLY TCC += -DBROKEN_MINGW_CMDLINE=1 RCC += -DBROKEN_MINGW_CMDLINE=1 endif # With HTTPS support ifdef FOSSIL_ENABLE_SSL TCC += -DFOSSIL_ENABLE_SSL=1 RCC += -DFOSSIL_ENABLE_SSL=1 endif # With TH1 embedded docs support ifdef FOSSIL_ENABLE_TH1_DOCS TCC += -DFOSSIL_ENABLE_TH1_DOCS=1 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1 endif # With TH1 hook support ifdef FOSSIL_ENABLE_TH1_HOOKS TCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 RCC += -DFOSSIL_ENABLE_TH1_HOOKS=1 endif |
| ︙ | ︙ | |||
214 215 216 217 218 219 220 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static | | > > > | > | > | > > > > > > | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 | endif #### We add the -static option here so that we can build a static # executable that will run in a chroot jail. # LIB = -static #### MinGW: If available, use the Unicode capable runtime startup code. # ifndef MINGW_IS_32BIT_ONLY LIB += -municode endif #### SQLite: If enabled, use the system SQLite library. # ifdef USE_SYSTEM_SQLITE LIB += -lsqlite3 endif #### OpenSSL: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_SSL LIB += -lssl -lcrypto -lgdi32 endif #### Tcl: Add the necessary libraries required, if enabled. # ifdef FOSSIL_ENABLE_TCL LIB += $(LIBTCL) endif #### Extra arguments for linking the finished binary. Fossil needs # to link against the Z-Lib compression library. There are no # other mandatory dependencies. # LIB += -lmingwex #### When not using the miniz compression library, zlib is required. # ifndef FOSSIL_ENABLE_MINIZ LIB += -lz endif #### These libraries MUST appear in the same order as they do for Tcl # or linking with it will not work (exact reason unknown). # ifdef FOSSIL_ENABLE_TCL ifdef FOSSIL_ENABLE_TCL_STUBS LIB += -lkernel32 -lws2_32 |
| ︙ | ︙ | |||
283 284 285 286 287 288 289 290 291 292 293 294 295 296 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ | > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | $(SRCDIR)/allrepo.c \ $(SRCDIR)/attach.c \ $(SRCDIR)/bag.c \ $(SRCDIR)/bisect.c \ $(SRCDIR)/blob.c \ $(SRCDIR)/branch.c \ $(SRCDIR)/browse.c \ $(SRCDIR)/builtin.c \ $(SRCDIR)/cache.c \ $(SRCDIR)/captcha.c \ $(SRCDIR)/cgi.c \ $(SRCDIR)/checkin.c \ $(SRCDIR)/checkout.c \ $(SRCDIR)/clearsign.c \ $(SRCDIR)/clone.c \ |
| ︙ | ︙ | |||
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ | > > > > | 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 | $(SRCDIR)/winfile.c \ $(SRCDIR)/winhttp.c \ $(SRCDIR)/wysiwyg.c \ $(SRCDIR)/xfer.c \ $(SRCDIR)/xfersetup.c \ $(SRCDIR)/zip.c EXTRA_FILES = \ $(SRCDIR)/diff.tcl TRANS_SRC = \ $(OBJDIR)/add_.c \ $(OBJDIR)/allrepo_.c \ $(OBJDIR)/attach_.c \ $(OBJDIR)/bag_.c \ $(OBJDIR)/bisect_.c \ $(OBJDIR)/blob_.c \ $(OBJDIR)/branch_.c \ $(OBJDIR)/browse_.c \ $(OBJDIR)/builtin_.c \ $(OBJDIR)/cache_.c \ $(OBJDIR)/captcha_.c \ $(OBJDIR)/cgi_.c \ $(OBJDIR)/checkin_.c \ $(OBJDIR)/checkout_.c \ $(OBJDIR)/clearsign_.c \ $(OBJDIR)/clone_.c \ |
| ︙ | ︙ | |||
509 510 511 512 513 514 515 516 517 518 519 520 521 522 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ | > | 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 | $(OBJDIR)/allrepo.o \ $(OBJDIR)/attach.o \ $(OBJDIR)/bag.o \ $(OBJDIR)/bisect.o \ $(OBJDIR)/blob.o \ $(OBJDIR)/branch.o \ $(OBJDIR)/browse.o \ $(OBJDIR)/builtin.o \ $(OBJDIR)/cache.o \ $(OBJDIR)/captcha.o \ $(OBJDIR)/cgi.o \ $(OBJDIR)/checkin.o \ $(OBJDIR)/checkout.o \ $(OBJDIR)/clearsign.o \ $(OBJDIR)/clone.o \ |
| ︙ | ︙ | |||
613 614 615 616 617 618 619 | $(OBJDIR)/winfile.o \ $(OBJDIR)/winhttp.o \ $(OBJDIR)/wysiwyg.o \ $(OBJDIR)/xfer.o \ $(OBJDIR)/xfersetup.o \ $(OBJDIR)/zip.o | | > | | | | > > > | | | | > > > > > | 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 | $(OBJDIR)/winfile.o \ $(OBJDIR)/winhttp.o \ $(OBJDIR)/wysiwyg.o \ $(OBJDIR)/xfer.o \ $(OBJDIR)/xfersetup.o \ $(OBJDIR)/zip.o APPNAME = fossil.exe APPTARGETS = #### If the USE_WINDOWS variable exists, it is assumed that we are building # inside of a Windows-style shell; otherwise, it is assumed that we are # building inside of a Unix-style shell. Note that the "move" command is # broken when attempting to use it from the Windows shell via MinGW make # because the SHELL variable is only used for certain commands that are # recognized internally by make. # ifdef USE_WINDOWS TRANSLATE = $(subst /,\,$(OBJDIR)/translate.exe) MAKEHEADERS = $(subst /,\,$(OBJDIR)/makeheaders.exe) MKINDEX = $(subst /,\,$(OBJDIR)/mkindex.exe) MKBUILTIN = $(subst /,\,$(OBJDIR)/mkbuiltin.exe) MKVERSION = $(subst /,\,$(OBJDIR)/mkversion.exe) CODECHECK1 = $(subst /,\,$(OBJDIR)/codecheck1.exe) CAT = type CP = copy GREP = find MV = copy RM = del /Q MKDIR = -mkdir RMDIR = rmdir /S /Q else TRANSLATE = $(OBJDIR)/translate.exe MAKEHEADERS = $(OBJDIR)/makeheaders.exe MKINDEX = $(OBJDIR)/mkindex.exe MKBUILTIN = $(OBJDIR)/mkbuiltin.exe MKVERSION = $(OBJDIR)/mkversion.exe CODECHECK1 = $(OBJDIR)/codecheck1.exe CAT = cat CP = cp GREP = grep MV = mv RM = rm -f MKDIR = -mkdir -p RMDIR = rm -rf endif all: $(OBJDIR) $(APPNAME) $(OBJDIR)/fossil.o: $(SRCDIR)/../win/fossil.rc $(OBJDIR)/VERSION.h ifdef USE_WINDOWS $(CAT) $(subst /,\,$(SRCDIR)\miniz.c) | $(GREP) "define MZ_VERSION" > $(subst /,\,$(OBJDIR)\minizver.h) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.rc) $(subst /,\,$(OBJDIR)) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.ico) $(subst /,\,$(OBJDIR)) $(CP) $(subst /,\,$(SRCDIR)\..\win\fossil.exe.manifest) $(subst /,\,$(OBJDIR)) else $(CAT) $(SRCDIR)/miniz.c | $(GREP) "define MZ_VERSION" > $(OBJDIR)/minizver.h $(CP) $(SRCDIR)/../win/fossil.rc $(OBJDIR) $(CP) $(SRCDIR)/../win/fossil.ico $(OBJDIR) $(CP) $(SRCDIR)/../win/fossil.exe.manifest $(OBJDIR) endif $(RCC) $(OBJDIR)/fossil.rc -o $(OBJDIR)/fossil.o install: $(OBJDIR) $(APPNAME) |
| ︙ | ︙ | |||
676 677 678 679 680 681 682 | $(OBJDIR): ifdef USE_WINDOWS $(MKDIR) $(subst /,\,$(OBJDIR)) else $(MKDIR) $(OBJDIR) endif | | | | | | | > > > | | > > > | | | > > > > > > > > > | > > > > > > > | > > > > > > > > > > > | | > > > > > > | > | | 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | $(OBJDIR): ifdef USE_WINDOWS $(MKDIR) $(subst /,\,$(OBJDIR)) else $(MKDIR) $(OBJDIR) endif $(TRANSLATE): $(SRCDIR)/translate.c $(BCC) -o $@ $(SRCDIR)/translate.c $(MAKEHEADERS): $(SRCDIR)/makeheaders.c $(BCC) -o $@ $(SRCDIR)/makeheaders.c $(MKINDEX): $(SRCDIR)/mkindex.c $(BCC) -o $@ $(SRCDIR)/mkindex.c $(MKBUILTIN): $(SRCDIR)/mkbuiltin.c $(BCC) -o $@ $(SRCDIR)/mkbuiltin.c $(MKVERSION): $(SRCDIR)/mkversion.c $(BCC) -o $@ $(SRCDIR)/mkversion.c $(CODECHECK1): $(SRCDIR)/codecheck1.c $(BCC) -o $@ $(SRCDIR)/codecheck1.c # WARNING. DANGER. Running the test suite modifies the repository the # build is done from, i.e. the checkout belongs to. Do not sync/push # the repository after running the tests. test: $(OBJDIR) $(APPNAME) $(TCLSH) $(SRCDIR)/../test/tester.tcl $(APPNAME) $(OBJDIR)/VERSION.h: $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(MKVERSION) $(MKVERSION) $(SRCDIR)/../manifest.uuid $(SRCDIR)/../manifest $(SRCDIR)/../VERSION >$@ # The USE_SYSTEM_SQLITE variable may be undefined, set to 0, or set # to 1. If it is set to 1, then there is no need to build or link # the sqlite3.o object. Instead, the system SQLite will be linked # using -lsqlite3. SQLITE3_OBJ.1 = SQLITE3_OBJ.0 = $(OBJDIR)/sqlite3.o SQLITE3_OBJ. = $(SQLITE3_OBJ.0) # The FOSSIL_ENABLE_MINIZ variable may be undefined, set to 0, or # set to 1. If it is set to 1, the miniz library included in the # source tree should be used; otherwise, it should not. MINIZ_OBJ.0 = MINIZ_OBJ.1 = $(OBJDIR)/miniz.o MINIZ_OBJ. = $(MINIZ_OBJ.0) EXTRAOBJ = \ $(SQLITE3_OBJ.$(USE_SYSTEM_SQLITE)) \ $(MINIZ_OBJ.$(FOSSIL_ENABLE_MINIZ)) \ $(OBJDIR)/shell.o \ $(OBJDIR)/th.o \ $(OBJDIR)/th_lang.o \ $(OBJDIR)/th_tcl.o \ $(OBJDIR)/cson_amalgamation.o zlib: $(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) $(ZLIBCONFIG) -f win32/Makefile.gcc libz.a clean-zlib: $(MAKE) -C $(ZLIBDIR) PREFIX=$(PREFIX) -f win32/Makefile.gcc clean $(ZLIBDIR)/inffas86.o: $(TCC) -c -o $@ -DASMINF -I$(ZLIBDIR) -O3 $(ZLIBDIR)/contrib/inflate86/inffas86.c $(ZLIBDIR)/match.o: $(TCC) -c -o $@ -DASMV $(ZLIBDIR)/contrib/asm686/match.S ifndef FOSSIL_ENABLE_MINIZ LIBTARGETS += zlib endif openssl: $(LIBTARGETS) cd $(OPENSSLLIBDIR);./Configure --cross-compile-prefix=$(PREFIX) $(SSLCONFIG) $(MAKE) -C $(OPENSSLLIBDIR) build_libs clean-openssl: $(MAKE) -C $(OPENSSLLIBDIR) clean tcl: cd $(TCLSRCDIR)/win;./configure $(MAKE) -C $(TCLSRCDIR)/win $(TCLTARGET) clean-tcl: $(MAKE) -C $(TCLSRCDIR)/win distclean APPTARGETS += $(LIBTARGETS) ifdef FOSSIL_BUILD_SSL APPTARGETS += openssl endif $(APPNAME): $(OBJDIR)/headers $(CODECHECK1) $(OBJ) $(EXTRAOBJ) $(OBJDIR)/fossil.o $(APPTARGETS) $(CODECHECK1) $(TRANS_SRC) $(TCC) -o $@ $(OBJ) $(EXTRAOBJ) $(LIB) $(OBJDIR)/fossil.o # This rule prevents make from using its default rules to try build # an executable named "manifest" out of the file named "manifest.c" # $(SRCDIR)/../manifest: # noop |
| ︙ | ︙ | |||
751 752 753 754 755 756 757 | setup: $(OBJDIR) $(APPNAME) $(MAKENSIS) ./setup/fossil.nsi innosetup: $(OBJDIR) $(APPNAME) $(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION) | | > > > | > | 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 | setup: $(OBJDIR) $(APPNAME) $(MAKENSIS) ./setup/fossil.nsi innosetup: $(OBJDIR) $(APPNAME) $(INNOSETUP) ./setup/fossil.iss -DAppVersion=$(shell $(CAT) ./VERSION) $(OBJDIR)/page_index.h: $(TRANS_SRC) $(MKINDEX) $(MKINDEX) $(TRANS_SRC) >$@ $(OBJDIR)/builtin_data.h: $(MKBUILTIN) $(EXTRA_FILES) $(MKBUILTIN) $(EXTRA_FILES) >$@ $(OBJDIR)/headers: $(OBJDIR)/page_index.h $(OBJDIR)/builtin_data.h $(MAKEHEADERS) $(OBJDIR)/VERSION.h $(MAKEHEADERS) $(OBJDIR)/add_.c:$(OBJDIR)/add.h \ $(OBJDIR)/allrepo_.c:$(OBJDIR)/allrepo.h \ $(OBJDIR)/attach_.c:$(OBJDIR)/attach.h \ $(OBJDIR)/bag_.c:$(OBJDIR)/bag.h \ $(OBJDIR)/bisect_.c:$(OBJDIR)/bisect.h \ $(OBJDIR)/blob_.c:$(OBJDIR)/blob.h \ $(OBJDIR)/branch_.c:$(OBJDIR)/branch.h \ $(OBJDIR)/browse_.c:$(OBJDIR)/browse.h \ $(OBJDIR)/builtin_.c:$(OBJDIR)/builtin.h \ $(OBJDIR)/cache_.c:$(OBJDIR)/cache.h \ $(OBJDIR)/captcha_.c:$(OBJDIR)/captcha.h \ $(OBJDIR)/cgi_.c:$(OBJDIR)/cgi.h \ $(OBJDIR)/checkin_.c:$(OBJDIR)/checkin.h \ $(OBJDIR)/checkout_.c:$(OBJDIR)/checkout.h \ $(OBJDIR)/clearsign_.c:$(OBJDIR)/clearsign.h \ $(OBJDIR)/clone_.c:$(OBJDIR)/clone.h \ |
| ︙ | ︙ | |||
875 876 877 878 879 880 881 | $(OBJDIR)/VERSION.h echo Done >$(OBJDIR)/headers $(OBJDIR)/headers: Makefile Makefile: | | | | | | | | | | | | | | | | | | | | | | | | | > > > > > > > > | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | > | > > > > > | | | | | | > > > | 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 |
$(OBJDIR)/VERSION.h
echo Done >$(OBJDIR)/headers
$(OBJDIR)/headers: Makefile
Makefile:
$(OBJDIR)/add_.c: $(SRCDIR)/add.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/add.c >$@
$(OBJDIR)/add.o: $(OBJDIR)/add_.c $(OBJDIR)/add.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/add.o -c $(OBJDIR)/add_.c
$(OBJDIR)/add.h: $(OBJDIR)/headers
$(OBJDIR)/allrepo_.c: $(SRCDIR)/allrepo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/allrepo.c >$@
$(OBJDIR)/allrepo.o: $(OBJDIR)/allrepo_.c $(OBJDIR)/allrepo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/allrepo.o -c $(OBJDIR)/allrepo_.c
$(OBJDIR)/allrepo.h: $(OBJDIR)/headers
$(OBJDIR)/attach_.c: $(SRCDIR)/attach.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/attach.c >$@
$(OBJDIR)/attach.o: $(OBJDIR)/attach_.c $(OBJDIR)/attach.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/attach.o -c $(OBJDIR)/attach_.c
$(OBJDIR)/attach.h: $(OBJDIR)/headers
$(OBJDIR)/bag_.c: $(SRCDIR)/bag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/bag.c >$@
$(OBJDIR)/bag.o: $(OBJDIR)/bag_.c $(OBJDIR)/bag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bag.o -c $(OBJDIR)/bag_.c
$(OBJDIR)/bag.h: $(OBJDIR)/headers
$(OBJDIR)/bisect_.c: $(SRCDIR)/bisect.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/bisect.c >$@
$(OBJDIR)/bisect.o: $(OBJDIR)/bisect_.c $(OBJDIR)/bisect.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/bisect.o -c $(OBJDIR)/bisect_.c
$(OBJDIR)/bisect.h: $(OBJDIR)/headers
$(OBJDIR)/blob_.c: $(SRCDIR)/blob.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/blob.c >$@
$(OBJDIR)/blob.o: $(OBJDIR)/blob_.c $(OBJDIR)/blob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/blob.o -c $(OBJDIR)/blob_.c
$(OBJDIR)/blob.h: $(OBJDIR)/headers
$(OBJDIR)/branch_.c: $(SRCDIR)/branch.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/branch.c >$@
$(OBJDIR)/branch.o: $(OBJDIR)/branch_.c $(OBJDIR)/branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/branch.o -c $(OBJDIR)/branch_.c
$(OBJDIR)/branch.h: $(OBJDIR)/headers
$(OBJDIR)/browse_.c: $(SRCDIR)/browse.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/browse.c >$@
$(OBJDIR)/browse.o: $(OBJDIR)/browse_.c $(OBJDIR)/browse.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/browse.o -c $(OBJDIR)/browse_.c
$(OBJDIR)/browse.h: $(OBJDIR)/headers
$(OBJDIR)/builtin_.c: $(SRCDIR)/builtin.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/builtin.c >$@
$(OBJDIR)/builtin.o: $(OBJDIR)/builtin_.c $(OBJDIR)/builtin.h $(OBJDIR)/builtin_data.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/builtin.o -c $(OBJDIR)/builtin_.c
$(OBJDIR)/builtin.h: $(OBJDIR)/headers
$(OBJDIR)/cache_.c: $(SRCDIR)/cache.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/cache.c >$@
$(OBJDIR)/cache.o: $(OBJDIR)/cache_.c $(OBJDIR)/cache.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cache.o -c $(OBJDIR)/cache_.c
$(OBJDIR)/cache.h: $(OBJDIR)/headers
$(OBJDIR)/captcha_.c: $(SRCDIR)/captcha.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/captcha.c >$@
$(OBJDIR)/captcha.o: $(OBJDIR)/captcha_.c $(OBJDIR)/captcha.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/captcha.o -c $(OBJDIR)/captcha_.c
$(OBJDIR)/captcha.h: $(OBJDIR)/headers
$(OBJDIR)/cgi_.c: $(SRCDIR)/cgi.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/cgi.c >$@
$(OBJDIR)/cgi.o: $(OBJDIR)/cgi_.c $(OBJDIR)/cgi.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/cgi.o -c $(OBJDIR)/cgi_.c
$(OBJDIR)/cgi.h: $(OBJDIR)/headers
$(OBJDIR)/checkin_.c: $(SRCDIR)/checkin.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/checkin.c >$@
$(OBJDIR)/checkin.o: $(OBJDIR)/checkin_.c $(OBJDIR)/checkin.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkin.o -c $(OBJDIR)/checkin_.c
$(OBJDIR)/checkin.h: $(OBJDIR)/headers
$(OBJDIR)/checkout_.c: $(SRCDIR)/checkout.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/checkout.c >$@
$(OBJDIR)/checkout.o: $(OBJDIR)/checkout_.c $(OBJDIR)/checkout.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/checkout.o -c $(OBJDIR)/checkout_.c
$(OBJDIR)/checkout.h: $(OBJDIR)/headers
$(OBJDIR)/clearsign_.c: $(SRCDIR)/clearsign.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/clearsign.c >$@
$(OBJDIR)/clearsign.o: $(OBJDIR)/clearsign_.c $(OBJDIR)/clearsign.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clearsign.o -c $(OBJDIR)/clearsign_.c
$(OBJDIR)/clearsign.h: $(OBJDIR)/headers
$(OBJDIR)/clone_.c: $(SRCDIR)/clone.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/clone.c >$@
$(OBJDIR)/clone.o: $(OBJDIR)/clone_.c $(OBJDIR)/clone.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/clone.o -c $(OBJDIR)/clone_.c
$(OBJDIR)/clone.h: $(OBJDIR)/headers
$(OBJDIR)/comformat_.c: $(SRCDIR)/comformat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/comformat.c >$@
$(OBJDIR)/comformat.o: $(OBJDIR)/comformat_.c $(OBJDIR)/comformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/comformat.o -c $(OBJDIR)/comformat_.c
$(OBJDIR)/comformat.h: $(OBJDIR)/headers
$(OBJDIR)/configure_.c: $(SRCDIR)/configure.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/configure.c >$@
$(OBJDIR)/configure.o: $(OBJDIR)/configure_.c $(OBJDIR)/configure.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/configure.o -c $(OBJDIR)/configure_.c
$(OBJDIR)/configure.h: $(OBJDIR)/headers
$(OBJDIR)/content_.c: $(SRCDIR)/content.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/content.c >$@
$(OBJDIR)/content.o: $(OBJDIR)/content_.c $(OBJDIR)/content.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/content.o -c $(OBJDIR)/content_.c
$(OBJDIR)/content.h: $(OBJDIR)/headers
$(OBJDIR)/db_.c: $(SRCDIR)/db.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/db.c >$@
$(OBJDIR)/db.o: $(OBJDIR)/db_.c $(OBJDIR)/db.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/db.o -c $(OBJDIR)/db_.c
$(OBJDIR)/db.h: $(OBJDIR)/headers
$(OBJDIR)/delta_.c: $(SRCDIR)/delta.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/delta.c >$@
$(OBJDIR)/delta.o: $(OBJDIR)/delta_.c $(OBJDIR)/delta.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/delta.o -c $(OBJDIR)/delta_.c
$(OBJDIR)/delta.h: $(OBJDIR)/headers
$(OBJDIR)/deltacmd_.c: $(SRCDIR)/deltacmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/deltacmd.c >$@
$(OBJDIR)/deltacmd.o: $(OBJDIR)/deltacmd_.c $(OBJDIR)/deltacmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/deltacmd.o -c $(OBJDIR)/deltacmd_.c
$(OBJDIR)/deltacmd.h: $(OBJDIR)/headers
$(OBJDIR)/descendants_.c: $(SRCDIR)/descendants.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/descendants.c >$@
$(OBJDIR)/descendants.o: $(OBJDIR)/descendants_.c $(OBJDIR)/descendants.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/descendants.o -c $(OBJDIR)/descendants_.c
$(OBJDIR)/descendants.h: $(OBJDIR)/headers
$(OBJDIR)/diff_.c: $(SRCDIR)/diff.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/diff.c >$@
$(OBJDIR)/diff.o: $(OBJDIR)/diff_.c $(OBJDIR)/diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diff.o -c $(OBJDIR)/diff_.c
$(OBJDIR)/diff.h: $(OBJDIR)/headers
$(OBJDIR)/diffcmd_.c: $(SRCDIR)/diffcmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/diffcmd.c >$@
$(OBJDIR)/diffcmd.o: $(OBJDIR)/diffcmd_.c $(OBJDIR)/diffcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/diffcmd.o -c $(OBJDIR)/diffcmd_.c
$(OBJDIR)/diffcmd.h: $(OBJDIR)/headers
$(OBJDIR)/doc_.c: $(SRCDIR)/doc.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/doc.c >$@
$(OBJDIR)/doc.o: $(OBJDIR)/doc_.c $(OBJDIR)/doc.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/doc.o -c $(OBJDIR)/doc_.c
$(OBJDIR)/doc.h: $(OBJDIR)/headers
$(OBJDIR)/encode_.c: $(SRCDIR)/encode.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/encode.c >$@
$(OBJDIR)/encode.o: $(OBJDIR)/encode_.c $(OBJDIR)/encode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/encode.o -c $(OBJDIR)/encode_.c
$(OBJDIR)/encode.h: $(OBJDIR)/headers
$(OBJDIR)/event_.c: $(SRCDIR)/event.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/event.c >$@
$(OBJDIR)/event.o: $(OBJDIR)/event_.c $(OBJDIR)/event.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/event.o -c $(OBJDIR)/event_.c
$(OBJDIR)/event.h: $(OBJDIR)/headers
$(OBJDIR)/export_.c: $(SRCDIR)/export.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/export.c >$@
$(OBJDIR)/export.o: $(OBJDIR)/export_.c $(OBJDIR)/export.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/export.o -c $(OBJDIR)/export_.c
$(OBJDIR)/export.h: $(OBJDIR)/headers
$(OBJDIR)/file_.c: $(SRCDIR)/file.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/file.c >$@
$(OBJDIR)/file.o: $(OBJDIR)/file_.c $(OBJDIR)/file.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/file.o -c $(OBJDIR)/file_.c
$(OBJDIR)/file.h: $(OBJDIR)/headers
$(OBJDIR)/finfo_.c: $(SRCDIR)/finfo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/finfo.c >$@
$(OBJDIR)/finfo.o: $(OBJDIR)/finfo_.c $(OBJDIR)/finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/finfo.o -c $(OBJDIR)/finfo_.c
$(OBJDIR)/finfo.h: $(OBJDIR)/headers
$(OBJDIR)/fusefs_.c: $(SRCDIR)/fusefs.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/fusefs.c >$@
$(OBJDIR)/fusefs.o: $(OBJDIR)/fusefs_.c $(OBJDIR)/fusefs.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/fusefs.o -c $(OBJDIR)/fusefs_.c
$(OBJDIR)/fusefs.h: $(OBJDIR)/headers
$(OBJDIR)/glob_.c: $(SRCDIR)/glob.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/glob.c >$@
$(OBJDIR)/glob.o: $(OBJDIR)/glob_.c $(OBJDIR)/glob.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/glob.o -c $(OBJDIR)/glob_.c
$(OBJDIR)/glob.h: $(OBJDIR)/headers
$(OBJDIR)/graph_.c: $(SRCDIR)/graph.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/graph.c >$@
$(OBJDIR)/graph.o: $(OBJDIR)/graph_.c $(OBJDIR)/graph.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/graph.o -c $(OBJDIR)/graph_.c
$(OBJDIR)/graph.h: $(OBJDIR)/headers
$(OBJDIR)/gzip_.c: $(SRCDIR)/gzip.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/gzip.c >$@
$(OBJDIR)/gzip.o: $(OBJDIR)/gzip_.c $(OBJDIR)/gzip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/gzip.o -c $(OBJDIR)/gzip_.c
$(OBJDIR)/gzip.h: $(OBJDIR)/headers
$(OBJDIR)/http_.c: $(SRCDIR)/http.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http.c >$@
$(OBJDIR)/http.o: $(OBJDIR)/http_.c $(OBJDIR)/http.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http.o -c $(OBJDIR)/http_.c
$(OBJDIR)/http.h: $(OBJDIR)/headers
$(OBJDIR)/http_socket_.c: $(SRCDIR)/http_socket.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_socket.c >$@
$(OBJDIR)/http_socket.o: $(OBJDIR)/http_socket_.c $(OBJDIR)/http_socket.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_socket.o -c $(OBJDIR)/http_socket_.c
$(OBJDIR)/http_socket.h: $(OBJDIR)/headers
$(OBJDIR)/http_ssl_.c: $(SRCDIR)/http_ssl.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_ssl.c >$@
$(OBJDIR)/http_ssl.o: $(OBJDIR)/http_ssl_.c $(OBJDIR)/http_ssl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_ssl.o -c $(OBJDIR)/http_ssl_.c
$(OBJDIR)/http_ssl.h: $(OBJDIR)/headers
$(OBJDIR)/http_transport_.c: $(SRCDIR)/http_transport.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/http_transport.c >$@
$(OBJDIR)/http_transport.o: $(OBJDIR)/http_transport_.c $(OBJDIR)/http_transport.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/http_transport.o -c $(OBJDIR)/http_transport_.c
$(OBJDIR)/http_transport.h: $(OBJDIR)/headers
$(OBJDIR)/import_.c: $(SRCDIR)/import.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/import.c >$@
$(OBJDIR)/import.o: $(OBJDIR)/import_.c $(OBJDIR)/import.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/import.o -c $(OBJDIR)/import_.c
$(OBJDIR)/import.h: $(OBJDIR)/headers
$(OBJDIR)/info_.c: $(SRCDIR)/info.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/info.c >$@
$(OBJDIR)/info.o: $(OBJDIR)/info_.c $(OBJDIR)/info.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/info.o -c $(OBJDIR)/info_.c
$(OBJDIR)/info.h: $(OBJDIR)/headers
$(OBJDIR)/json_.c: $(SRCDIR)/json.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json.c >$@
$(OBJDIR)/json.o: $(OBJDIR)/json_.c $(OBJDIR)/json.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json.o -c $(OBJDIR)/json_.c
$(OBJDIR)/json.h: $(OBJDIR)/headers
$(OBJDIR)/json_artifact_.c: $(SRCDIR)/json_artifact.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_artifact.c >$@
$(OBJDIR)/json_artifact.o: $(OBJDIR)/json_artifact_.c $(OBJDIR)/json_artifact.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_artifact.o -c $(OBJDIR)/json_artifact_.c
$(OBJDIR)/json_artifact.h: $(OBJDIR)/headers
$(OBJDIR)/json_branch_.c: $(SRCDIR)/json_branch.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_branch.c >$@
$(OBJDIR)/json_branch.o: $(OBJDIR)/json_branch_.c $(OBJDIR)/json_branch.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_branch.o -c $(OBJDIR)/json_branch_.c
$(OBJDIR)/json_branch.h: $(OBJDIR)/headers
$(OBJDIR)/json_config_.c: $(SRCDIR)/json_config.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_config.c >$@
$(OBJDIR)/json_config.o: $(OBJDIR)/json_config_.c $(OBJDIR)/json_config.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_config.o -c $(OBJDIR)/json_config_.c
$(OBJDIR)/json_config.h: $(OBJDIR)/headers
$(OBJDIR)/json_diff_.c: $(SRCDIR)/json_diff.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_diff.c >$@
$(OBJDIR)/json_diff.o: $(OBJDIR)/json_diff_.c $(OBJDIR)/json_diff.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_diff.o -c $(OBJDIR)/json_diff_.c
$(OBJDIR)/json_diff.h: $(OBJDIR)/headers
$(OBJDIR)/json_dir_.c: $(SRCDIR)/json_dir.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_dir.c >$@
$(OBJDIR)/json_dir.o: $(OBJDIR)/json_dir_.c $(OBJDIR)/json_dir.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_dir.o -c $(OBJDIR)/json_dir_.c
$(OBJDIR)/json_dir.h: $(OBJDIR)/headers
$(OBJDIR)/json_finfo_.c: $(SRCDIR)/json_finfo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_finfo.c >$@
$(OBJDIR)/json_finfo.o: $(OBJDIR)/json_finfo_.c $(OBJDIR)/json_finfo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_finfo.o -c $(OBJDIR)/json_finfo_.c
$(OBJDIR)/json_finfo.h: $(OBJDIR)/headers
$(OBJDIR)/json_login_.c: $(SRCDIR)/json_login.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_login.c >$@
$(OBJDIR)/json_login.o: $(OBJDIR)/json_login_.c $(OBJDIR)/json_login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_login.o -c $(OBJDIR)/json_login_.c
$(OBJDIR)/json_login.h: $(OBJDIR)/headers
$(OBJDIR)/json_query_.c: $(SRCDIR)/json_query.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_query.c >$@
$(OBJDIR)/json_query.o: $(OBJDIR)/json_query_.c $(OBJDIR)/json_query.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_query.o -c $(OBJDIR)/json_query_.c
$(OBJDIR)/json_query.h: $(OBJDIR)/headers
$(OBJDIR)/json_report_.c: $(SRCDIR)/json_report.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_report.c >$@
$(OBJDIR)/json_report.o: $(OBJDIR)/json_report_.c $(OBJDIR)/json_report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_report.o -c $(OBJDIR)/json_report_.c
$(OBJDIR)/json_report.h: $(OBJDIR)/headers
$(OBJDIR)/json_status_.c: $(SRCDIR)/json_status.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_status.c >$@
$(OBJDIR)/json_status.o: $(OBJDIR)/json_status_.c $(OBJDIR)/json_status.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_status.o -c $(OBJDIR)/json_status_.c
$(OBJDIR)/json_status.h: $(OBJDIR)/headers
$(OBJDIR)/json_tag_.c: $(SRCDIR)/json_tag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_tag.c >$@
$(OBJDIR)/json_tag.o: $(OBJDIR)/json_tag_.c $(OBJDIR)/json_tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_tag.o -c $(OBJDIR)/json_tag_.c
$(OBJDIR)/json_tag.h: $(OBJDIR)/headers
$(OBJDIR)/json_timeline_.c: $(SRCDIR)/json_timeline.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_timeline.c >$@
$(OBJDIR)/json_timeline.o: $(OBJDIR)/json_timeline_.c $(OBJDIR)/json_timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_timeline.o -c $(OBJDIR)/json_timeline_.c
$(OBJDIR)/json_timeline.h: $(OBJDIR)/headers
$(OBJDIR)/json_user_.c: $(SRCDIR)/json_user.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_user.c >$@
$(OBJDIR)/json_user.o: $(OBJDIR)/json_user_.c $(OBJDIR)/json_user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_user.o -c $(OBJDIR)/json_user_.c
$(OBJDIR)/json_user.h: $(OBJDIR)/headers
$(OBJDIR)/json_wiki_.c: $(SRCDIR)/json_wiki.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/json_wiki.c >$@
$(OBJDIR)/json_wiki.o: $(OBJDIR)/json_wiki_.c $(OBJDIR)/json_wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/json_wiki.o -c $(OBJDIR)/json_wiki_.c
$(OBJDIR)/json_wiki.h: $(OBJDIR)/headers
$(OBJDIR)/leaf_.c: $(SRCDIR)/leaf.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/leaf.c >$@
$(OBJDIR)/leaf.o: $(OBJDIR)/leaf_.c $(OBJDIR)/leaf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/leaf.o -c $(OBJDIR)/leaf_.c
$(OBJDIR)/leaf.h: $(OBJDIR)/headers
$(OBJDIR)/loadctrl_.c: $(SRCDIR)/loadctrl.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/loadctrl.c >$@
$(OBJDIR)/loadctrl.o: $(OBJDIR)/loadctrl_.c $(OBJDIR)/loadctrl.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/loadctrl.o -c $(OBJDIR)/loadctrl_.c
$(OBJDIR)/loadctrl.h: $(OBJDIR)/headers
$(OBJDIR)/login_.c: $(SRCDIR)/login.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/login.c >$@
$(OBJDIR)/login.o: $(OBJDIR)/login_.c $(OBJDIR)/login.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/login.o -c $(OBJDIR)/login_.c
$(OBJDIR)/login.h: $(OBJDIR)/headers
$(OBJDIR)/lookslike_.c: $(SRCDIR)/lookslike.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/lookslike.c >$@
$(OBJDIR)/lookslike.o: $(OBJDIR)/lookslike_.c $(OBJDIR)/lookslike.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/lookslike.o -c $(OBJDIR)/lookslike_.c
$(OBJDIR)/lookslike.h: $(OBJDIR)/headers
$(OBJDIR)/main_.c: $(SRCDIR)/main.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/main.c >$@
$(OBJDIR)/main.o: $(OBJDIR)/main_.c $(OBJDIR)/main.h $(OBJDIR)/page_index.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/main.o -c $(OBJDIR)/main_.c
$(OBJDIR)/main.h: $(OBJDIR)/headers
$(OBJDIR)/manifest_.c: $(SRCDIR)/manifest.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/manifest.c >$@
$(OBJDIR)/manifest.o: $(OBJDIR)/manifest_.c $(OBJDIR)/manifest.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/manifest.o -c $(OBJDIR)/manifest_.c
$(OBJDIR)/manifest.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_.c: $(SRCDIR)/markdown.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/markdown.c >$@
$(OBJDIR)/markdown.o: $(OBJDIR)/markdown_.c $(OBJDIR)/markdown.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown.o -c $(OBJDIR)/markdown_.c
$(OBJDIR)/markdown.h: $(OBJDIR)/headers
$(OBJDIR)/markdown_html_.c: $(SRCDIR)/markdown_html.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/markdown_html.c >$@
$(OBJDIR)/markdown_html.o: $(OBJDIR)/markdown_html_.c $(OBJDIR)/markdown_html.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/markdown_html.o -c $(OBJDIR)/markdown_html_.c
$(OBJDIR)/markdown_html.h: $(OBJDIR)/headers
$(OBJDIR)/md5_.c: $(SRCDIR)/md5.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/md5.c >$@
$(OBJDIR)/md5.o: $(OBJDIR)/md5_.c $(OBJDIR)/md5.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/md5.o -c $(OBJDIR)/md5_.c
$(OBJDIR)/md5.h: $(OBJDIR)/headers
$(OBJDIR)/merge_.c: $(SRCDIR)/merge.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/merge.c >$@
$(OBJDIR)/merge.o: $(OBJDIR)/merge_.c $(OBJDIR)/merge.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge.o -c $(OBJDIR)/merge_.c
$(OBJDIR)/merge.h: $(OBJDIR)/headers
$(OBJDIR)/merge3_.c: $(SRCDIR)/merge3.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/merge3.c >$@
$(OBJDIR)/merge3.o: $(OBJDIR)/merge3_.c $(OBJDIR)/merge3.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/merge3.o -c $(OBJDIR)/merge3_.c
$(OBJDIR)/merge3.h: $(OBJDIR)/headers
$(OBJDIR)/moderate_.c: $(SRCDIR)/moderate.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/moderate.c >$@
$(OBJDIR)/moderate.o: $(OBJDIR)/moderate_.c $(OBJDIR)/moderate.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/moderate.o -c $(OBJDIR)/moderate_.c
$(OBJDIR)/moderate.h: $(OBJDIR)/headers
$(OBJDIR)/name_.c: $(SRCDIR)/name.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/name.c >$@
$(OBJDIR)/name.o: $(OBJDIR)/name_.c $(OBJDIR)/name.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/name.o -c $(OBJDIR)/name_.c
$(OBJDIR)/name.h: $(OBJDIR)/headers
$(OBJDIR)/path_.c: $(SRCDIR)/path.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/path.c >$@
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
$(OBJDIR)/path.h: $(OBJDIR)/headers
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/pivot.c >$@
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pivot.o -c $(OBJDIR)/pivot_.c
$(OBJDIR)/pivot.h: $(OBJDIR)/headers
$(OBJDIR)/popen_.c: $(SRCDIR)/popen.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/popen.c >$@
$(OBJDIR)/popen.o: $(OBJDIR)/popen_.c $(OBJDIR)/popen.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/popen.o -c $(OBJDIR)/popen_.c
$(OBJDIR)/popen.h: $(OBJDIR)/headers
$(OBJDIR)/pqueue_.c: $(SRCDIR)/pqueue.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/pqueue.c >$@
$(OBJDIR)/pqueue.o: $(OBJDIR)/pqueue_.c $(OBJDIR)/pqueue.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/pqueue.o -c $(OBJDIR)/pqueue_.c
$(OBJDIR)/pqueue.h: $(OBJDIR)/headers
$(OBJDIR)/printf_.c: $(SRCDIR)/printf.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/printf.c >$@
$(OBJDIR)/printf.o: $(OBJDIR)/printf_.c $(OBJDIR)/printf.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/printf.o -c $(OBJDIR)/printf_.c
$(OBJDIR)/printf.h: $(OBJDIR)/headers
$(OBJDIR)/rebuild_.c: $(SRCDIR)/rebuild.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/rebuild.c >$@
$(OBJDIR)/rebuild.o: $(OBJDIR)/rebuild_.c $(OBJDIR)/rebuild.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rebuild.o -c $(OBJDIR)/rebuild_.c
$(OBJDIR)/rebuild.h: $(OBJDIR)/headers
$(OBJDIR)/regexp_.c: $(SRCDIR)/regexp.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/regexp.c >$@
$(OBJDIR)/regexp.o: $(OBJDIR)/regexp_.c $(OBJDIR)/regexp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/regexp.o -c $(OBJDIR)/regexp_.c
$(OBJDIR)/regexp.h: $(OBJDIR)/headers
$(OBJDIR)/report_.c: $(SRCDIR)/report.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/report.c >$@
$(OBJDIR)/report.o: $(OBJDIR)/report_.c $(OBJDIR)/report.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/report.o -c $(OBJDIR)/report_.c
$(OBJDIR)/report.h: $(OBJDIR)/headers
$(OBJDIR)/rss_.c: $(SRCDIR)/rss.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/rss.c >$@
$(OBJDIR)/rss.o: $(OBJDIR)/rss_.c $(OBJDIR)/rss.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/rss.o -c $(OBJDIR)/rss_.c
$(OBJDIR)/rss.h: $(OBJDIR)/headers
$(OBJDIR)/schema_.c: $(SRCDIR)/schema.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/schema.c >$@
$(OBJDIR)/schema.o: $(OBJDIR)/schema_.c $(OBJDIR)/schema.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/schema.o -c $(OBJDIR)/schema_.c
$(OBJDIR)/schema.h: $(OBJDIR)/headers
$(OBJDIR)/search_.c: $(SRCDIR)/search.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/search.c >$@
$(OBJDIR)/search.o: $(OBJDIR)/search_.c $(OBJDIR)/search.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/search.o -c $(OBJDIR)/search_.c
$(OBJDIR)/search.h: $(OBJDIR)/headers
$(OBJDIR)/setup_.c: $(SRCDIR)/setup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/setup.c >$@
$(OBJDIR)/setup.o: $(OBJDIR)/setup_.c $(OBJDIR)/setup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/setup.o -c $(OBJDIR)/setup_.c
$(OBJDIR)/setup.h: $(OBJDIR)/headers
$(OBJDIR)/sha1_.c: $(SRCDIR)/sha1.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sha1.c >$@
$(OBJDIR)/sha1.o: $(OBJDIR)/sha1_.c $(OBJDIR)/sha1.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sha1.o -c $(OBJDIR)/sha1_.c
$(OBJDIR)/sha1.h: $(OBJDIR)/headers
$(OBJDIR)/shun_.c: $(SRCDIR)/shun.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/shun.c >$@
$(OBJDIR)/shun.o: $(OBJDIR)/shun_.c $(OBJDIR)/shun.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/shun.o -c $(OBJDIR)/shun_.c
$(OBJDIR)/shun.h: $(OBJDIR)/headers
$(OBJDIR)/skins_.c: $(SRCDIR)/skins.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/skins.c >$@
$(OBJDIR)/skins.o: $(OBJDIR)/skins_.c $(OBJDIR)/skins.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/skins.o -c $(OBJDIR)/skins_.c
$(OBJDIR)/skins.h: $(OBJDIR)/headers
$(OBJDIR)/sqlcmd_.c: $(SRCDIR)/sqlcmd.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sqlcmd.c >$@
$(OBJDIR)/sqlcmd.o: $(OBJDIR)/sqlcmd_.c $(OBJDIR)/sqlcmd.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sqlcmd.o -c $(OBJDIR)/sqlcmd_.c
$(OBJDIR)/sqlcmd.h: $(OBJDIR)/headers
$(OBJDIR)/stash_.c: $(SRCDIR)/stash.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/stash.c >$@
$(OBJDIR)/stash.o: $(OBJDIR)/stash_.c $(OBJDIR)/stash.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stash.o -c $(OBJDIR)/stash_.c
$(OBJDIR)/stash.h: $(OBJDIR)/headers
$(OBJDIR)/stat_.c: $(SRCDIR)/stat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/stat.c >$@
$(OBJDIR)/stat.o: $(OBJDIR)/stat_.c $(OBJDIR)/stat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/stat.o -c $(OBJDIR)/stat_.c
$(OBJDIR)/stat.h: $(OBJDIR)/headers
$(OBJDIR)/style_.c: $(SRCDIR)/style.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/style.c >$@
$(OBJDIR)/style.o: $(OBJDIR)/style_.c $(OBJDIR)/style.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/style.o -c $(OBJDIR)/style_.c
$(OBJDIR)/style.h: $(OBJDIR)/headers
$(OBJDIR)/sync_.c: $(SRCDIR)/sync.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/sync.c >$@
$(OBJDIR)/sync.o: $(OBJDIR)/sync_.c $(OBJDIR)/sync.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/sync.o -c $(OBJDIR)/sync_.c
$(OBJDIR)/sync.h: $(OBJDIR)/headers
$(OBJDIR)/tag_.c: $(SRCDIR)/tag.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tag.c >$@
$(OBJDIR)/tag.o: $(OBJDIR)/tag_.c $(OBJDIR)/tag.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tag.o -c $(OBJDIR)/tag_.c
$(OBJDIR)/tag.h: $(OBJDIR)/headers
$(OBJDIR)/tar_.c: $(SRCDIR)/tar.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tar.c >$@
$(OBJDIR)/tar.o: $(OBJDIR)/tar_.c $(OBJDIR)/tar.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tar.o -c $(OBJDIR)/tar_.c
$(OBJDIR)/tar.h: $(OBJDIR)/headers
$(OBJDIR)/th_main_.c: $(SRCDIR)/th_main.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/th_main.c >$@
$(OBJDIR)/th_main.o: $(OBJDIR)/th_main_.c $(OBJDIR)/th_main.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/th_main.o -c $(OBJDIR)/th_main_.c
$(OBJDIR)/th_main.h: $(OBJDIR)/headers
$(OBJDIR)/timeline_.c: $(SRCDIR)/timeline.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/timeline.c >$@
$(OBJDIR)/timeline.o: $(OBJDIR)/timeline_.c $(OBJDIR)/timeline.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/timeline.o -c $(OBJDIR)/timeline_.c
$(OBJDIR)/timeline.h: $(OBJDIR)/headers
$(OBJDIR)/tkt_.c: $(SRCDIR)/tkt.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tkt.c >$@
$(OBJDIR)/tkt.o: $(OBJDIR)/tkt_.c $(OBJDIR)/tkt.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tkt.o -c $(OBJDIR)/tkt_.c
$(OBJDIR)/tkt.h: $(OBJDIR)/headers
$(OBJDIR)/tktsetup_.c: $(SRCDIR)/tktsetup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/tktsetup.c >$@
$(OBJDIR)/tktsetup.o: $(OBJDIR)/tktsetup_.c $(OBJDIR)/tktsetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/tktsetup.o -c $(OBJDIR)/tktsetup_.c
$(OBJDIR)/tktsetup.h: $(OBJDIR)/headers
$(OBJDIR)/undo_.c: $(SRCDIR)/undo.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/undo.c >$@
$(OBJDIR)/undo.o: $(OBJDIR)/undo_.c $(OBJDIR)/undo.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/undo.o -c $(OBJDIR)/undo_.c
$(OBJDIR)/undo.h: $(OBJDIR)/headers
$(OBJDIR)/unicode_.c: $(SRCDIR)/unicode.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/unicode.c >$@
$(OBJDIR)/unicode.o: $(OBJDIR)/unicode_.c $(OBJDIR)/unicode.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/unicode.o -c $(OBJDIR)/unicode_.c
$(OBJDIR)/unicode.h: $(OBJDIR)/headers
$(OBJDIR)/update_.c: $(SRCDIR)/update.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/update.c >$@
$(OBJDIR)/update.o: $(OBJDIR)/update_.c $(OBJDIR)/update.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/update.o -c $(OBJDIR)/update_.c
$(OBJDIR)/update.h: $(OBJDIR)/headers
$(OBJDIR)/url_.c: $(SRCDIR)/url.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/url.c >$@
$(OBJDIR)/url.o: $(OBJDIR)/url_.c $(OBJDIR)/url.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/url.o -c $(OBJDIR)/url_.c
$(OBJDIR)/url.h: $(OBJDIR)/headers
$(OBJDIR)/user_.c: $(SRCDIR)/user.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/user.c >$@
$(OBJDIR)/user.o: $(OBJDIR)/user_.c $(OBJDIR)/user.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/user.o -c $(OBJDIR)/user_.c
$(OBJDIR)/user.h: $(OBJDIR)/headers
$(OBJDIR)/utf8_.c: $(SRCDIR)/utf8.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/utf8.c >$@
$(OBJDIR)/utf8.o: $(OBJDIR)/utf8_.c $(OBJDIR)/utf8.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/utf8.o -c $(OBJDIR)/utf8_.c
$(OBJDIR)/utf8.h: $(OBJDIR)/headers
$(OBJDIR)/util_.c: $(SRCDIR)/util.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/util.c >$@
$(OBJDIR)/util.o: $(OBJDIR)/util_.c $(OBJDIR)/util.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/util.o -c $(OBJDIR)/util_.c
$(OBJDIR)/util.h: $(OBJDIR)/headers
$(OBJDIR)/verify_.c: $(SRCDIR)/verify.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/verify.c >$@
$(OBJDIR)/verify.o: $(OBJDIR)/verify_.c $(OBJDIR)/verify.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/verify.o -c $(OBJDIR)/verify_.c
$(OBJDIR)/verify.h: $(OBJDIR)/headers
$(OBJDIR)/vfile_.c: $(SRCDIR)/vfile.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/vfile.c >$@
$(OBJDIR)/vfile.o: $(OBJDIR)/vfile_.c $(OBJDIR)/vfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/vfile.o -c $(OBJDIR)/vfile_.c
$(OBJDIR)/vfile.h: $(OBJDIR)/headers
$(OBJDIR)/wiki_.c: $(SRCDIR)/wiki.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wiki.c >$@
$(OBJDIR)/wiki.o: $(OBJDIR)/wiki_.c $(OBJDIR)/wiki.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wiki.o -c $(OBJDIR)/wiki_.c
$(OBJDIR)/wiki.h: $(OBJDIR)/headers
$(OBJDIR)/wikiformat_.c: $(SRCDIR)/wikiformat.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wikiformat.c >$@
$(OBJDIR)/wikiformat.o: $(OBJDIR)/wikiformat_.c $(OBJDIR)/wikiformat.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wikiformat.o -c $(OBJDIR)/wikiformat_.c
$(OBJDIR)/wikiformat.h: $(OBJDIR)/headers
$(OBJDIR)/winfile_.c: $(SRCDIR)/winfile.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/winfile.c >$@
$(OBJDIR)/winfile.o: $(OBJDIR)/winfile_.c $(OBJDIR)/winfile.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winfile.o -c $(OBJDIR)/winfile_.c
$(OBJDIR)/winfile.h: $(OBJDIR)/headers
$(OBJDIR)/winhttp_.c: $(SRCDIR)/winhttp.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/winhttp.c >$@
$(OBJDIR)/winhttp.o: $(OBJDIR)/winhttp_.c $(OBJDIR)/winhttp.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/winhttp.o -c $(OBJDIR)/winhttp_.c
$(OBJDIR)/winhttp.h: $(OBJDIR)/headers
$(OBJDIR)/wysiwyg_.c: $(SRCDIR)/wysiwyg.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/wysiwyg.c >$@
$(OBJDIR)/wysiwyg.o: $(OBJDIR)/wysiwyg_.c $(OBJDIR)/wysiwyg.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/wysiwyg.o -c $(OBJDIR)/wysiwyg_.c
$(OBJDIR)/wysiwyg.h: $(OBJDIR)/headers
$(OBJDIR)/xfer_.c: $(SRCDIR)/xfer.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/xfer.c >$@
$(OBJDIR)/xfer.o: $(OBJDIR)/xfer_.c $(OBJDIR)/xfer.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfer.o -c $(OBJDIR)/xfer_.c
$(OBJDIR)/xfer.h: $(OBJDIR)/headers
$(OBJDIR)/xfersetup_.c: $(SRCDIR)/xfersetup.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/xfersetup.c >$@
$(OBJDIR)/xfersetup.o: $(OBJDIR)/xfersetup_.c $(OBJDIR)/xfersetup.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/xfersetup.o -c $(OBJDIR)/xfersetup_.c
$(OBJDIR)/xfersetup.h: $(OBJDIR)/headers
$(OBJDIR)/zip_.c: $(SRCDIR)/zip.c $(TRANSLATE)
$(TRANSLATE) $(SRCDIR)/zip.c >$@
$(OBJDIR)/zip.o: $(OBJDIR)/zip_.c $(OBJDIR)/zip.h $(SRCDIR)/config.h
$(XTCC) -o $(OBJDIR)/zip.o -c $(OBJDIR)/zip_.c
$(OBJDIR)/zip.h: $(OBJDIR)/headers
SQLITE_OPTIONS = -DNDEBUG=1 \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DSQLITE_ENABLE_LOCKING_STYLE=0 \
-DSQLITE_THREADSAFE=0 \
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
-DSQLITE_OMIT_DEPRECATED \
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
-DSQLITE_WIN32_NO_ANSI \
-D_HAVE__MINGW_H \
-DSQLITE_USE_MALLOC_H \
-DSQLITE_USE_MSIZE
SHELL_OPTIONS = -Dmain=sqlite3_shell \
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
-DSQLITE_SHELL_DBNAME_PROC=fossil_open \
-Daccess=file_access \
-Dsystem=fossil_system \
-Dgetenv=fossil_getenv \
-Dfopen=fossil_fopen
MINIZ_OPTIONS = -DMINIZ_NO_STDIO \
-DMINIZ_NO_TIME \
-DMINIZ_NO_ARCHIVE_APIS
$(OBJDIR)/sqlite3.o: $(SRCDIR)/sqlite3.c $(SRCDIR)/../win/Makefile.mingw.mistachkin
$(XTCC) $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) -c $(SRCDIR)/sqlite3.c -o $@
$(OBJDIR)/cson_amalgamation.o: $(SRCDIR)/cson_amalgamation.c
$(XTCC) -c $(SRCDIR)/cson_amalgamation.c -o $@
$(OBJDIR)/json.o $(OBJDIR)/json_artifact.o $(OBJDIR)/json_branch.o $(OBJDIR)/json_config.o $(OBJDIR)/json_diff.o $(OBJDIR)/json_dir.o $(OBJDIR)/jsos_finfo.o $(OBJDIR)/json_login.o $(OBJDIR)/json_query.o $(OBJDIR)/json_report.o $(OBJDIR)/json_status.o $(OBJDIR)/json_tag.o $(OBJDIR)/json_timeline.o $(OBJDIR)/json_user.o $(OBJDIR)/json_wiki.o : $(SRCDIR)/json_detail.h
$(OBJDIR)/shell.o: $(SRCDIR)/shell.c $(SRCDIR)/sqlite3.h $(SRCDIR)/../win/Makefile.mingw.mistachkin
$(XTCC) $(SHELL_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)/shell.c -o $@
$(OBJDIR)/th.o: $(SRCDIR)/th.c
$(XTCC) -c $(SRCDIR)/th.c -o $@
$(OBJDIR)/th_lang.o: $(SRCDIR)/th_lang.c
$(XTCC) -c $(SRCDIR)/th_lang.c -o $@
$(OBJDIR)/th_tcl.o: $(SRCDIR)/th_tcl.c
$(XTCC) -c $(SRCDIR)/th_tcl.c -o $@
$(OBJDIR)/miniz.o: $(SRCDIR)/miniz.c
$(XTCC) $(MINIZ_OPTIONS) -c $(SRCDIR)/miniz.c -o $@
|
Changes to win/Makefile.msc.
1 2 3 4 5 6 7 8 9 | # ############################################################################## # WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl") ############################################################################## # # This file is automatically generated. Instead of editing this # file, edit "makemake.tcl" then run "tclsh makemake.tcl" # to regenerate this file. # | > > > > > > > > | | | | | | | > > > > > > > > > > > > > > > > > > | > | > > > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > | | > > > > > > > > > > > > > > > > | | > > > > > > | 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 |
#
##############################################################################
# WARNING: DO NOT EDIT, AUTOMATICALLY GENERATED FILE (SEE "src/makemake.tcl")
##############################################################################
#
# This Makefile will only function correctly if used from a sub-directory
# that is a direct child of the top-level directory for this project.
#
!if !exist("..\.fossil-settings")
!error "Please change the current directory to the one containing this file."
!endif
#
# This file is automatically generated. Instead of editing this
# file, edit "makemake.tcl" then run "tclsh makemake.tcl"
# to regenerate this file.
#
B = ..
SRCDIR = $B\src
OBJDIR = .
OX = .
O = .obj
E = .exe
P = .pdb
# Perl is only necessary if OpenSSL support is enabled and it must
# be built from source code. The PERLDIR variable should point to
# the directory containing the main Perl binary (i.e. "perl.exe").
PERLDIR = C:\Perl\bin
PERL = perl.exe
# Uncomment to enable debug symbols
# DEBUG = 1
# Uncomment to support Windows XP with Visual Studio 201x
# FOSSIL_ENABLE_WINXP = 1
# Uncomment to enable JSON API
# FOSSIL_ENABLE_JSON = 1
# Uncomment to enable miniz usage
# FOSSIL_ENABLE_MINIZ = 1
# Uncomment to enable SSL support
# FOSSIL_ENABLE_SSL = 1
# Uncomment to build SSL libraries
# FOSSIL_BUILD_SSL = 1
# Uncomment to enable TH1 scripts in embedded documentation files
# FOSSIL_ENABLE_TH1_DOCS = 1
# Uncomment to enable TH1 hooks
# FOSSIL_ENABLE_TH1_HOOKS = 1
# Uncomment to enable Tcl support
# FOSSIL_ENABLE_TCL = 1
!ifdef FOSSIL_ENABLE_SSL
SSLDIR = $(B)\compat\openssl-1.0.1j
SSLINCDIR = $(SSLDIR)\inc32
SSLLIBDIR = $(SSLDIR)\out32
SSLLFLAGS = /nologo /opt:ref /debug
SSLLIB = ssleay32.lib libeay32.lib user32.lib gdi32.lib
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
!message Using 'x64' platform for OpenSSL...
SSLCONFIG = VC-WIN64A no-asm
SSLSETUP = ms\do_win64a.bat
SSLNMAKE = ms\nt.mak all
!elseif "$(PLATFORM)"=="ia64"
!message Using 'ia64' platform for OpenSSL...
SSLCONFIG = VC-WIN64I no-asm
SSLSETUP = ms\do_win64i.bat
SSLNMAKE = ms\nt.mak all
!else
!message Assuming 'x86' platform for OpenSSL...
SSLCONFIG = VC-WIN32 no-asm
SSLSETUP = ms\do_ms.bat
SSLNMAKE = ms\nt.mak all
!endif
!endif
!ifdef FOSSIL_ENABLE_TCL
TCLDIR = $(B)\compat\tcl-8.6
TCLSRCDIR = $(TCLDIR)
TCLINCDIR = $(TCLSRCDIR)\generic
!endif
# zlib options
ZINCDIR = $(B)\compat\zlib
ZLIBDIR = $(B)\compat\zlib
ZLIB = zlib.lib
INCL = /I. /I$(SRCDIR) /I$B\win\include
!ifndef FOSSIL_ENABLE_MINIZ
INCL = $(INCL) /I$(ZINCDIR)
!endif
!ifdef FOSSIL_ENABLE_SSL
INCL = $(INCL) /I$(SSLINCDIR)
!endif
!ifdef FOSSIL_ENABLE_TCL
INCL = $(INCL) /I$(TCLINCDIR)
!endif
CFLAGS = /nologo
LDFLAGS = /NODEFAULTLIB:msvcrt /MANIFEST:NO
!ifdef FOSSIL_ENABLE_WINXP
XPCFLAGS = $(XPCFLAGS) /D_USING_V110_SDK71_=1
CFLAGS = $(CFLAGS) $(XPCFLAGS)
!if "$(PLATFORM)"=="amd64" || "$(PLATFORM)"=="x64"
XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.02
!else
XPLDFLAGS = $(XPLDFLAGS) /SUBSYSTEM:CONSOLE,5.01
!endif
LDFLAGS = $(LDFLAGS) $(XPLDFLAGS)
!endif
!ifdef DEBUG
CFLAGS = $(CFLAGS) /Zi /MTd /Od
LDFLAGS = $(LDFLAGS) /DEBUG
!else
CFLAGS = $(CFLAGS) /MT /O2
!endif
BCC = $(CC) $(CFLAGS)
TCC = $(CC) /c $(CFLAGS) $(MSCDEF) $(INCL)
RCC = rc /D_WIN32 /D_MSC_VER $(MSCDEF) $(INCL)
LIBS = ws2_32.lib advapi32.lib
LIBDIR =
!ifndef FOSSIL_ENABLE_MINIZ
LIBS = $(LIBS) $(ZLIB)
LIBDIR = $(LIBDIR) /LIBPATH:$(ZLIBDIR)
!endif
!ifdef FOSSIL_ENABLE_MINIZ
TCC = $(TCC) /DFOSSIL_ENABLE_MINIZ=1
RCC = $(RCC) /DFOSSIL_ENABLE_MINIZ=1
!endif
!ifdef FOSSIL_ENABLE_JSON
TCC = $(TCC) /DFOSSIL_ENABLE_JSON=1
RCC = $(RCC) /DFOSSIL_ENABLE_JSON=1
!endif
!ifdef FOSSIL_ENABLE_SSL
TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
LIBS = $(LIBS) $(SSLLIB)
LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
!endif
!ifdef FOSSIL_ENABLE_TH1_DOCS
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
!endif
!ifdef FOSSIL_ENABLE_TH1_HOOKS
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_HOOKS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_HOOKS=1
!endif
!ifdef FOSSIL_ENABLE_TCL
TCC = $(TCC) /DFOSSIL_ENABLE_TCL=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL=1
TCC = $(TCC) /DFOSSIL_ENABLE_TCL_STUBS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL_STUBS=1
TCC = $(TCC) /DFOSSIL_ENABLE_TCL_PRIVATE_STUBS=1
RCC = $(RCC) /DFOSSIL_ENABLE_TCL_PRIVATE_STUBS=1
TCC = $(TCC) /DUSE_TCL_STUBS=1
RCC = $(RCC) /DUSE_TCL_STUBS=1
!endif
SQLITE_OPTIONS = /DNDEBUG=1 \
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
/DSQLITE_ENABLE_LOCKING_STYLE=0 \
/DSQLITE_THREADSAFE=0 \
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
/DSQLITE_OMIT_DEPRECATED \
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
/DSQLITE_WIN32_NO_ANSI
SHELL_OPTIONS = /Dmain=sqlite3_shell \
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
/DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
/DSQLITE_SHELL_DBNAME_PROC=fossil_open \
/Daccess=file_access \
/Dsystem=fossil_system \
/Dgetenv=fossil_getenv \
/Dfopen=fossil_fopen
MINIZ_OPTIONS = /DMINIZ_NO_STDIO \
/DMINIZ_NO_TIME \
/DMINIZ_NO_ARCHIVE_APIS
SRC = add_.c \
allrepo_.c \
attach_.c \
bag_.c \
bisect_.c \
blob_.c \
branch_.c \
browse_.c \
builtin_.c \
cache_.c \
captcha_.c \
cgi_.c \
checkin_.c \
checkout_.c \
clearsign_.c \
clone_.c \
|
| ︙ | ︙ | |||
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 |
winfile_.c \
winhttp_.c \
wysiwyg_.c \
xfer_.c \
xfersetup_.c \
zip_.c
OBJ = $(OX)\add$O \
$(OX)\allrepo$O \
$(OX)\attach$O \
$(OX)\bag$O \
$(OX)\bisect$O \
$(OX)\blob$O \
$(OX)\branch$O \
$(OX)\browse$O \
$(OX)\cache$O \
$(OX)\captcha$O \
$(OX)\cgi$O \
$(OX)\checkin$O \
$(OX)\checkout$O \
$(OX)\clearsign$O \
$(OX)\clone$O \
| > > > | 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
winfile_.c \
winhttp_.c \
wysiwyg_.c \
xfer_.c \
xfersetup_.c \
zip_.c
EXTRA_FILES = $(SRCDIR)\diff.tcl
OBJ = $(OX)\add$O \
$(OX)\allrepo$O \
$(OX)\attach$O \
$(OX)\bag$O \
$(OX)\bisect$O \
$(OX)\blob$O \
$(OX)\branch$O \
$(OX)\browse$O \
$(OX)\builtin$O \
$(OX)\cache$O \
$(OX)\captcha$O \
$(OX)\cgi$O \
$(OX)\checkin$O \
$(OX)\checkout$O \
$(OX)\clearsign$O \
$(OX)\clone$O \
|
| ︙ | ︙ | |||
342 343 344 345 346 347 348 349 350 351 |
$(OX)\wikiformat$O \
$(OX)\winfile$O \
$(OX)\winhttp$O \
$(OX)\wysiwyg$O \
$(OX)\xfer$O \
$(OX)\xfersetup$O \
$(OX)\zip$O \
$(OX)\fossil.res
| > > > | | > > > > | > > > > > > > > > > > > > > > | > > > > > > > > > > > | > > | 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
$(OX)\wikiformat$O \
$(OX)\winfile$O \
$(OX)\winhttp$O \
$(OX)\wysiwyg$O \
$(OX)\xfer$O \
$(OX)\xfersetup$O \
$(OX)\zip$O \
!ifdef FOSSIL_ENABLE_MINIZ
$(OX)\miniz$O \
!endif
$(OX)\fossil.res
APPNAME = $(OX)\fossil$(E)
PDBNAME = $(OX)\fossil$(P)
APPTARGETS =
all: $(OX) $(APPNAME)
zlib:
@echo Building zlib from "$(ZLIBDIR)"...
!ifdef FOSSIL_ENABLE_WINXP
@pushd "$(ZLIBDIR)" && $(MAKE) /f win32\Makefile.msc $(ZLIB) "CC=cl $(XPCFLAGS)" "LD=link $(XPLDFLAGS)" && popd
!else
@pushd "$(ZLIBDIR)" && $(MAKE) /f win32\Makefile.msc $(ZLIB) && popd
!endif
!ifdef FOSSIL_ENABLE_SSL
openssl:
@echo Building OpenSSL from "$(SSLDIR)"...
!if "$(PERLDIR)" != ""
@set PATH=$(PERLDIR);$(PATH)
!endif
@pushd "$(SSLDIR)" && $(PERL) Configure $(SSLCONFIG) && popd
@pushd "$(SSLDIR)" && call $(SSLSETUP) && popd
!ifdef FOSSIL_ENABLE_WINXP
@pushd "$(SSLDIR)" && $(MAKE) /f $(SSLNMAKE) "CC=cl $(XPCFLAGS)" "LFLAGS=$(SSLLFLAGS) $(XPLDFLAGS)" && popd
!else
@pushd "$(SSLDIR)" && $(MAKE) /f $(SSLNMAKE) && popd
!endif
!endif
!ifndef FOSSIL_ENABLE_MINIZ
APPTARGETS = $(APPTARGETS) zlib
!endif
!ifdef FOSSIL_ENABLE_SSL
!ifdef FOSSIL_BUILD_SSL
APPTARGETS = $(APPTARGETS) openssl
!endif
!endif
$(APPNAME) : $(APPTARGETS) translate$E mkindex$E codecheck1$E headers $(OBJ) $(OX)\linkopts
cd $(OX)
codecheck1$E $(SRC)
link $(LDFLAGS) /OUT:$@ $(LIBDIR) Wsetargv.obj fossil.res @linkopts
$(OX)\linkopts: $B\win\Makefile.msc
echo $(OX)\add.obj > $@
echo $(OX)\allrepo.obj >> $@
echo $(OX)\attach.obj >> $@
echo $(OX)\bag.obj >> $@
echo $(OX)\bisect.obj >> $@
echo $(OX)\blob.obj >> $@
echo $(OX)\branch.obj >> $@
echo $(OX)\browse.obj >> $@
echo $(OX)\builtin.obj >> $@
echo $(OX)\cache.obj >> $@
echo $(OX)\captcha.obj >> $@
echo $(OX)\cgi.obj >> $@
echo $(OX)\checkin.obj >> $@
echo $(OX)\checkout.obj >> $@
echo $(OX)\clearsign.obj >> $@
echo $(OX)\clone.obj >> $@
|
| ︙ | ︙ | |||
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 | echo $(OX)\wikiformat.obj >> $@ echo $(OX)\winfile.obj >> $@ echo $(OX)\winhttp.obj >> $@ echo $(OX)\wysiwyg.obj >> $@ echo $(OX)\xfer.obj >> $@ echo $(OX)\xfersetup.obj >> $@ echo $(OX)\zip.obj >> $@ echo $(LIBS) >> $@ $(OX): @-mkdir $@ translate$E: $(SRCDIR)\translate.c $(BCC) $** makeheaders$E: $(SRCDIR)\makeheaders.c $(BCC) $** mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** | > > > > > > | > > > > > > | > > > | 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | echo $(OX)\wikiformat.obj >> $@ echo $(OX)\winfile.obj >> $@ echo $(OX)\winhttp.obj >> $@ echo $(OX)\wysiwyg.obj >> $@ echo $(OX)\xfer.obj >> $@ echo $(OX)\xfersetup.obj >> $@ echo $(OX)\zip.obj >> $@ !ifdef FOSSIL_ENABLE_MINIZ echo $(OX)\miniz.obj >> $@ !endif echo $(LIBS) >> $@ $(OX): @-mkdir $@ translate$E: $(SRCDIR)\translate.c $(BCC) $** makeheaders$E: $(SRCDIR)\makeheaders.c $(BCC) $** mkindex$E: $(SRCDIR)\mkindex.c $(BCC) $** mkbuiltin$E: $(SRCDIR)\mkbuiltin.c $(BCC) $** mkversion$E: $(SRCDIR)\mkversion.c $(BCC) $** codecheck1$E: $(SRCDIR)\codecheck1.c $(BCC) $** $(OX)\shell$O : $(SRCDIR)\shell.c $B\win\Makefile.msc $(TCC) /Fo$@ $(SHELL_OPTIONS) $(SQLITE_OPTIONS) $(SHELL_CFLAGS) -c $(SRCDIR)\shell.c $(OX)\sqlite3$O : $(SRCDIR)\sqlite3.c $B\win\Makefile.msc $(TCC) /Fo$@ -c $(SQLITE_OPTIONS) $(SQLITE_CFLAGS) $(SRCDIR)\sqlite3.c $(OX)\th$O : $(SRCDIR)\th.c $(TCC) /Fo$@ -c $** $(OX)\th_lang$O : $(SRCDIR)\th_lang.c $(TCC) /Fo$@ -c $** $(OX)\th_tcl$O : $(SRCDIR)\th_tcl.c $(TCC) /Fo$@ -c $** $(OX)\miniz$O : $(SRCDIR)\miniz.c $(TCC) /Fo$@ -c $(MINIZ_OPTIONS) $(SRCDIR)\miniz.c VERSION.h : mkversion$E $B\manifest.uuid $B\manifest $B\VERSION $** > $@ $(OX)\cson_amalgamation$O : $(SRCDIR)\cson_amalgamation.c $(TCC) /Fo$@ /c $** page_index.h: mkindex$E $(SRC) $** > $@ builtin_data.h: mkbuiltin$E $(EXTRA_FILES) $** > $@ clean: -del $(OX)\*.obj -del *.obj -del *_.c -del *.h |
| ︙ | ︙ | |||
539 540 541 542 543 544 545 546 547 548 549 550 551 552 | -del translate$P -del mkindex$E -del mkindex$P -del makeheaders$E -del makeheaders$P -del mkversion$E -del mkversion$P $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h | > > > > | 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 | -del translate$P -del mkindex$E -del mkindex$P -del makeheaders$E -del makeheaders$P -del mkversion$E -del mkversion$P -del codecheck1$E -del codecheck1$P -del mkbuiltin$E -del mkbuiltin$P $(OBJDIR)\json$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_artifact$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_branch$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_config$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_diff$O : $(SRCDIR)\json_detail.h $(OBJDIR)\json_dir$O : $(SRCDIR)\json_detail.h |
| ︙ | ︙ | |||
603 604 605 606 607 608 609 610 611 612 613 614 615 616 | translate$E $** > $@ $(OX)\browse$O : browse_.c browse.h $(TCC) /Fo$@ -c browse_.c browse_.c : $(SRCDIR)\browse.c translate$E $** > $@ $(OX)\cache$O : cache_.c cache.h $(TCC) /Fo$@ -c cache_.c cache_.c : $(SRCDIR)\cache.c translate$E $** > $@ | > > > > > > | 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 | translate$E $** > $@ $(OX)\browse$O : browse_.c browse.h $(TCC) /Fo$@ -c browse_.c browse_.c : $(SRCDIR)\browse.c translate$E $** > $@ $(OX)\builtin$O : builtin_.c builtin.h $(TCC) /Fo$@ -c builtin_.c builtin_.c : $(SRCDIR)\builtin.c translate$E $** > $@ $(OX)\cache$O : cache_.c cache.h $(TCC) /Fo$@ -c cache_.c cache_.c : $(SRCDIR)\cache.c translate$E $** > $@ |
| ︙ | ︙ | |||
1225 1226 1227 1228 1229 1230 1231 | zip_.c : $(SRCDIR)\zip.c translate$E $** > $@ fossil.res : $B\win\fossil.rc $(RCC) /fo $@ $** | | > | 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 | zip_.c : $(SRCDIR)\zip.c translate$E $** > $@ fossil.res : $B\win\fossil.rc $(RCC) /fo $@ $** headers: makeheaders$E page_index.h builtin_data.h VERSION.h makeheaders$E add_.c:add.h \ allrepo_.c:allrepo.h \ attach_.c:attach.h \ bag_.c:bag.h \ bisect_.c:bisect.h \ blob_.c:blob.h \ branch_.c:branch.h \ browse_.c:browse.h \ builtin_.c:builtin.h \ cache_.c:cache.h \ captcha_.c:captcha.h \ cgi_.c:cgi.h \ checkin_.c:checkin.h \ checkout_.c:checkout.h \ clearsign_.c:clearsign.h \ clone_.c:clone.h \ |
| ︙ | ︙ |
Changes to win/buildmsvc.bat.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 | SETLOCAL REM SET __ECHO=ECHO REM SET __ECHO2=ECHO IF NOT DEFINED _AECHO (SET _AECHO=REM) IF NOT DEFINED _CECHO (SET _CECHO=REM) IF NOT DEFINED _VECHO (SET _VECHO=REM) REM REM Visual Studio ???? REM IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" ( %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... GOTO skip_detectVisualStudio | > > > > > > > > > > > > > > > > > > > > > > > | 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 | SETLOCAL REM SET __ECHO=ECHO REM SET __ECHO2=ECHO IF NOT DEFINED _AECHO (SET _AECHO=REM) IF NOT DEFINED _CECHO (SET _CECHO=REM) IF NOT DEFINED _VECHO (SET _VECHO=REM) REM REM NOTE: Setup local environment variables that point to the root directory REM of the Fossil source checkout and to the directory containing this REM build tool. REM SET ROOT=%~dp0\.. SET ROOT=%ROOT:\\=\% %_VECHO% Root = '%ROOT%' SET TOOLS=%~dp0 SET TOOLS=%TOOLS:~0,-1% %_VECHO% Tools = '%TOOLS%' REM REM Visual C++ ???? REM IF DEFINED VCINSTALLDIR IF EXIST "%VCINSTALLDIR%" ( %_AECHO% Build environment appears to be setup. GOTO skip_setupVisualStudio ) REM REM Visual Studio ???? REM IF DEFINED VSVARS32 IF EXIST "%VSVARS32%" ( %_AECHO% Build environment batch file manually overridden to "%VSVARS32%"... GOTO skip_detectVisualStudio |
| ︙ | ︙ | |||
119 120 121 122 123 124 125 | REM selected Visual Studio common tools path. This is not strictly REM necessary; however, it makes reading the output easier. REM SET VSVARS32=%VSVARS32:\\=\% %_VECHO% VsVars32 = '%VSVARS32%' | < < < < < < < < < < < < < < > > > > > > > > | 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 | REM selected Visual Studio common tools path. This is not strictly REM necessary; however, it makes reading the output easier. REM SET VSVARS32=%VSVARS32:\\=\% %_VECHO% VsVars32 = '%VSVARS32%' REM REM NOTE: After this point, a clean ERRORLEVEL is required; therefore, make REM sure it is reset now. REM CALL :fn_ResetErrorLevel REM REM NOTE: Attempt to call the selected batch file to setup the environment REM variables for building with MSVC. REM %__ECHO3% CALL "%VSVARS32%" IF ERRORLEVEL 1 ( ECHO Visual Studio build environment batch file "%VSVARS32%" failed. GOTO errors ) REM REM NOTE: After this point, the environment should already be setup for REM building with MSVC. REM :skip_setupVisualStudio %_VECHO% VcInstallDir = '%VCINSTALLDIR%' REM REM NOTE: Attempt to create the build output directory, if necessary. REM IF NOT EXIST "%ROOT%\msvcbld" ( %__ECHO% MKDIR "%ROOT%\msvcbld" IF ERRORLEVEL 1 ( |
| ︙ | ︙ | |||
173 174 175 176 177 178 179 180 181 182 183 | %__ECHO2% PUSHD "%ROOT%\msvcbld" IF ERRORLEVEL 1 ( ECHO Could not change to directory "%ROOT%\msvcbld". GOTO errors ) REM REM NOTE: Attempt to execute NMAKE for the Fossil MSVC makefile, passing REM anything extra from our command line along (e.g. extra options). REM | > > > > > > > > > > > > > > > | > > > > > > > > > > > > > > > > > > > > > > > > > | 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 259 260 261 262 263 264 |
%__ECHO2% PUSHD "%ROOT%\msvcbld"
IF ERRORLEVEL 1 (
ECHO Could not change to directory "%ROOT%\msvcbld".
GOTO errors
)
REM
REM NOTE: If requested, setup the build environment to refer to the Windows
REM SDK v7.1A, which is required if the binaries are being built with
REM Visual Studio 201x and need to work on Windows XP.
REM
IF DEFINED USE_V110SDK71A (
%_AECHO% Forcing use of the Windows SDK v7.1A...
CALL :fn_UseV110Sdk71A
)
%_VECHO% Path = '%PATH%'
%_VECHO% Include = '%INCLUDE%'
%_VECHO% Lib = '%LIB%'
%_VECHO% NmakeArgs = '%NMAKE_ARGS%'
REM
REM NOTE: Attempt to execute NMAKE for the Fossil MSVC makefile, passing
REM anything extra from our command line along (e.g. extra options).
REM
%__ECHO% nmake /f "%TOOLS%\Makefile.msc" %NMAKE_ARGS% %*
IF ERRORLEVEL 1 (
GOTO errors
)
REM
REM NOTE: Attempt to restore the previously saved directory.
REM
%__ECHO2% POPD
IF ERRORLEVEL 1 (
ECHO Could not restore directory.
GOTO errors
)
GOTO no_errors
:fn_UseV110Sdk71A
IF "%PROCESSOR_ARCHITECTURE%" == "x86" GOTO set_v110Sdk71A_x86
SET PFILES_SDK71A=%ProgramFiles(x86)%
GOTO set_v110Sdk71A_done
:set_v110Sdk71A_x86
SET PFILES_SDK71A=%ProgramFiles%
:set_v110Sdk71A_done
SET PATH=%PFILES_SDK71A%\Microsoft SDKs\Windows\7.1A\Bin;%PATH%
SET INCLUDE=%PFILES_SDK71A%\Microsoft SDKs\Windows\7.1A\Include;%INCLUDE%
IF "%PLATFORM%" == "x64" (
SET LIB=%PFILES_SDK71A%\Microsoft SDKs\Windows\7.1A\Lib\x64;%LIB%
) ELSE (
SET LIB=%PFILES_SDK71A%\Microsoft SDKs\Windows\7.1A\Lib;%LIB%
)
CALL :fn_UnsetVariable PFILES_SDK71A
SET NMAKE_ARGS=%NMAKE_ARGS% FOSSIL_ENABLE_WINXP=1
GOTO :EOF
:fn_UnsetVariable
IF NOT "%1" == "" (
SET %1=
CALL :fn_ResetErrorLevel
)
GOTO :EOF
:fn_ResetErrorLevel
VERIFY > NUL
GOTO :EOF
:fn_SetErrorLevel
VERIFY MAYBE 2> NUL
|
| ︙ | ︙ |
Changes to win/fossil.exe.manifest.
| ︙ | ︙ | |||
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
| > > | 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
<!-- Windows 8.1 -->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!-- Windows 8 -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!-- Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!-- Windows Vista -->
|
| ︙ | ︙ |
Changes to win/fossil.rc.
| ︙ | ︙ | |||
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | # define VS_FF_NONE 0x00000000L #endif /* !defined(VS_FF_NONE) */ #include "VERSION.h" #define _RC_COMPILE_ #include "config.h" #include "sqlite3.h" #include "zlib.h" #if defined(FOSSIL_ENABLE_SSL) #include "openssl/opensslv.h" #endif /* defined(FOSSIL_ENABLE_SSL) */ #if defined(FOSSIL_ENABLE_TCL) #include "tcl.h" | > > > > > > > > > > | 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 | # define VS_FF_NONE 0x00000000L #endif /* !defined(VS_FF_NONE) */ #include "VERSION.h" #define _RC_COMPILE_ #include "config.h" #include "sqlite3.h" #if defined(FOSSIL_ENABLE_MINIZ) #if defined(__MINGW32__) #include "minizver.h" #else #define MINIZ_HEADER_FILE_ONLY #include "miniz.c" #endif /* defined(__MINGW32__) */ #else #include "zlib.h" #endif /* defined(FOSSIL_ENABLE_MINIZ) */ #if defined(FOSSIL_ENABLE_SSL) #include "openssl/opensslv.h" #endif /* defined(FOSSIL_ENABLE_SSL) */ #if defined(FOSSIL_ENABLE_TCL) #include "tcl.h" |
| ︙ | ︙ | |||
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
VALUE "ProductVersion", "Fossil " RELEASE_VERSION " " MANIFEST_VERSION " " MANIFEST_DATE " UTC\0"
VALUE "FileVersion", "Fossil " RELEASE_VERSION " " MANIFEST_VERSION " " MANIFEST_DATE " UTC\0"
VALUE "InternalName", "fossil\0"
VALUE "LegalCopyright", "Copyright © " MANIFEST_YEAR " by D. Richard Hipp. All rights reserved.\0"
VALUE "OriginalFilename", "fossil.exe\0"
VALUE "CompilerName", COMPILER_NAME "\0"
VALUE "SQLiteVersion", "SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\0"
VALUE "ZlibVersion", "zlib " ZLIB_VERSION "\0"
#if defined(BROKEN_MINGW_CMDLINE)
VALUE "CommandLineIsUnicode", "No\0"
#else
VALUE "CommandLineIsUnicode", "Yes\0"
#endif /* defined(BROKEN_MINGW_CMDLINE) */
#if defined(FOSSIL_ENABLE_SSL)
VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
#endif /* defined(FOSSIL_ENABLE_SSL) */
#if defined(FOSSIL_ENABLE_TH1_HOOKS)
VALUE "Th1Hooks", "Yes\0"
#else
VALUE "Th1Hooks", "No\0"
| > > > > > > > > > | | 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 |
VALUE "ProductVersion", "Fossil " RELEASE_VERSION " " MANIFEST_VERSION " " MANIFEST_DATE " UTC\0"
VALUE "FileVersion", "Fossil " RELEASE_VERSION " " MANIFEST_VERSION " " MANIFEST_DATE " UTC\0"
VALUE "InternalName", "fossil\0"
VALUE "LegalCopyright", "Copyright © " MANIFEST_YEAR " by D. Richard Hipp. All rights reserved.\0"
VALUE "OriginalFilename", "fossil.exe\0"
VALUE "CompilerName", COMPILER_NAME "\0"
VALUE "SQLiteVersion", "SQLite " SQLITE_VERSION " " SQLITE_SOURCE_ID "\0"
#if defined(FOSSIL_ENABLE_MINIZ)
VALUE "MinizVersion", "miniz " MZ_VERSION "\0"
#else
VALUE "ZlibVersion", "zlib " ZLIB_VERSION "\0"
#endif /* defined(FOSSIL_ENABLE_MINIZ) */
#if defined(BROKEN_MINGW_CMDLINE)
VALUE "CommandLineIsUnicode", "No\0"
#else
VALUE "CommandLineIsUnicode", "Yes\0"
#endif /* defined(BROKEN_MINGW_CMDLINE) */
#if defined(FOSSIL_ENABLE_SSL)
VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
#endif /* defined(FOSSIL_ENABLE_SSL) */
#if defined(FOSSIL_ENABLE_TH1_DOCS)
VALUE "Th1Docs", "Yes\0"
#else
VALUE "Th1Docs", "No\0"
#endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */
#if defined(FOSSIL_ENABLE_TH1_HOOKS)
VALUE "Th1Hooks", "Yes\0"
#else
VALUE "Th1Hooks", "No\0"
#endif /* defined(FOSSIL_ENABLE_TH1_HOOKS) */
#if defined(FOSSIL_ENABLE_TCL)
VALUE "TclEnabled", "Yes, Tcl " TCL_PATCH_LEVEL "\0"
#if defined(USE_TCL_STUBS)
VALUE "UseTclStubsEnabled", "Yes\0"
#else
VALUE "UseTclStubsEnabled", "No\0"
#endif /* defined(USE_TCL_STUBS) */
|
| ︙ | ︙ | |||
140 141 142 143 144 145 146 | /* * This embedded manifest is needed for Windows 8.1. */ #ifndef RT_MANIFEST #define RT_MANIFEST 24 | | | | 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | /* * This embedded manifest is needed for Windows 8.1. */ #ifndef RT_MANIFEST #define RT_MANIFEST 24 #endif /* RT_MANIFEST */ #ifndef CREATEPROCESS_MANIFEST_RESOURCE_ID #define CREATEPROCESS_MANIFEST_RESOURCE_ID 1 #endif /* CREATEPROCESS_MANIFEST_RESOURCE_ID */ CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "fossil.exe.manifest" |
Changes to win/include/dirent.h.
| ︙ | ︙ | |||
18 19 20 21 22 23 24 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < | < < < | < < < < < < < < < < < < < < < < < < < > > > > > | | | 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 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. * IN NO EVENT SHALL TONI RONKKO BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * * $Id: dirent.h,v 1.20 2014/03/19 17:52:23 tronkko Exp $ */ #ifndef DIRENT_H #define DIRENT_H /* * Define architecture flags so we don't need to include windows.h. * Avoiding windows.h makes it simpler to use windows sockets in conjunction * with dirent.h. */ #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_IX86) # define _X86_ #endif #if !defined(_68K_) && !defined(_MPPC_) && !defined(_X86_) && !defined(_IA64_) && !defined(_AMD64_) && defined(_M_AMD64) #define _AMD64_ #endif #include <stdio.h> #include <stdarg.h> #include <windef.h> #include <winbase.h> |
| ︙ | ︙ | |||
211 212 213 214 215 216 217 | #define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR) #define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK) /* Return the exact length of d_namlen without zero terminator */ #define _D_EXACT_NAMLEN(p) ((p)->d_namlen) /* Return number of bytes needed to store d_namlen */ | | | | 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 |
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
/* Return the exact length of d_namlen without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
/* Return number of bytes needed to store d_namlen */
#define _D_ALLOC_NAMLEN(p) (PATH_MAX)
#ifdef __cplusplus
extern "C" {
#endif
/* Wide-character version */
struct _wdirent {
long d_ino; /* Always zero */
unsigned short d_reclen; /* Structure size */
size_t d_namlen; /* Length of name without \0 */
int d_type; /* File type */
wchar_t d_name[PATH_MAX]; /* File name */
};
typedef struct _wdirent _wdirent;
struct _WDIR {
struct _wdirent ent; /* Current directory entry */
WIN32_FIND_DATAW data; /* Private file data */
int cached; /* True if data is valid */
|
| ︙ | ︙ | |||
259 260 261 262 263 264 265 |
/* Multi-byte character versions */
struct dirent {
long d_ino; /* Always zero */
unsigned short d_reclen; /* Structure size */
size_t d_namlen; /* Length of name without \0 */
int d_type; /* File type */
| | | 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
/* Multi-byte character versions */
struct dirent {
long d_ino; /* Always zero */
unsigned short d_reclen; /* Structure size */
size_t d_namlen; /* Length of name without \0 */
int d_type; /* File type */
char d_name[PATH_MAX]; /* File name */
};
typedef struct dirent dirent;
struct DIR {
struct dirent ent;
struct _WDIR *wdirp;
};
|
| ︙ | ︙ | |||
421 422 423 424 425 426 427 |
/*
* Copy file name as wide-character string. If the file name is too
* long to fit in to the destination buffer, then truncate file name
* to PATH_MAX characters and zero-terminate the buffer.
*/
n = 0;
| | | 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 |
/*
* Copy file name as wide-character string. If the file name is too
* long to fit in to the destination buffer, then truncate file name
* to PATH_MAX characters and zero-terminate the buffer.
*/
n = 0;
while (n + 1 < PATH_MAX && datap->cFileName[n] != 0) {
entp->d_name[n] = datap->cFileName[n];
n++;
}
dirp->ent.d_name[n] = 0;
/* Length of file name excluding zero terminator */
entp->d_namlen = n;
|
| ︙ | ︙ | |||
590 591 592 593 594 595 596 |
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate memory for DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp) {
| | | < | 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 |
dirent_set_errno (ENOENT);
return NULL;
}
/* Allocate memory for DIR structure */
dirp = (DIR*) malloc (sizeof (struct DIR));
if (dirp) {
wchar_t wname[PATH_MAX];
size_t n;
/* Convert directory name to wide-character string */
error = dirent_mbstowcs_s (&n, wname, PATH_MAX, dirname, PATH_MAX);
if (!error) {
/* Open directory stream using wide-character name */
dirp->wdirp = _wopendir (wname);
if (dirp->wdirp) {
/* Directory stream opened */
error = 0;
|
| ︙ | ︙ | |||
660 661 662 663 664 665 666 |
datap = dirent_next (dirp->wdirp);
if (datap) {
size_t n;
int error;
/* Attempt to convert file name to multi-byte string */
error = dirent_wcstombs_s(
| | | | < | 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 |
datap = dirent_next (dirp->wdirp);
if (datap) {
size_t n;
int error;
/* Attempt to convert file name to multi-byte string */
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX);
/*
* If the file name cannot be represented by a multi-byte string,
* then attempt to use old 8+3 file name. This allows traditional
* Unix-code to access some file names despite of unicode
* characters, although file names may seem unfamiliar to the user.
*
* Be ware that the code below cannot come up with a short file
* name unless the file system provides one. At least
* VirtualBox shared folders fail to do this.
*/
if (error && datap->cAlternateFileName[0] != '\0') {
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX,
datap->cAlternateFileName, PATH_MAX);
}
if (!error) {
DWORD attr;
/* Initialize directory entry for return */
entp = &dirp->ent;
|
| ︙ | ︙ | |||
785 786 787 788 789 790 791 |
error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
| | | | | > > > | 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 |
error = mbstowcs_s (pReturnValue, wcstr, sizeInWords, mbstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to wide-character string (or count characters) */
n = mbstowcs (wcstr, mbstr, sizeInWords);
if (!wcstr || n < count) {
/* Zero-terminate output buffer */
if (wcstr && sizeInWords) {
if (n >= sizeInWords) {
n = sizeInWords - 1;
}
wcstr[n] = 0;
}
/* Length of resuting multi-byte string WITH zero terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
|
| ︙ | ︙ | |||
819 820 821 822 823 824 825 |
}
/* Convert wide-character string to multi-byte string */
static int
dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
| | | | | | > > > | 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 |
}
/* Convert wide-character string to multi-byte string */
static int
dirent_wcstombs_s(
size_t *pReturnValue,
char *mbstr,
size_t sizeInBytes, /* max size of mbstr */
const wchar_t *wcstr,
size_t count)
{
int error;
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 or later */
error = wcstombs_s (pReturnValue, mbstr, sizeInBytes, wcstr, count);
#else
/* Older Visual Studio or non-Microsoft compiler */
size_t n;
/* Convert to multi-byte string (or count the number of bytes needed) */
n = wcstombs (mbstr, wcstr, sizeInBytes);
if (!mbstr || n < count) {
/* Zero-terminate output buffer */
if (mbstr && sizeInBytes) {
if (n >= sizeInBytes) {
n = sizeInBytes - 1;
}
mbstr[n] = '\0';
}
/* Lenght of resulting multi-bytes string WITH zero-terminator */
if (pReturnValue) {
*pReturnValue = n + 1;
}
|
| ︙ | ︙ | |||
869 870 871 872 873 874 875 |
}
/* Set errno variable */
static void
dirent_set_errno(
int error)
{
| | | 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 |
}
/* Set errno variable */
static void
dirent_set_errno(
int error)
{
#if defined(_MSC_VER) && _MSC_VER >= 1400
/* Microsoft Visual Studio 2005 and later */
_set_errno (error);
#else
/* Non-Microsoft compiler or older Microsoft compiler */
|
| ︙ | ︙ |
Changes to www/build.wiki.
| ︙ | ︙ | |||
110 111 112 113 114 115 116 | <li><p><i>MinGW/MinGW-w64</i> → Use the mingw makefile: "<b>make -f win/Makefile.mingw</b>". On a Windows box you will need either Cygwin or Msys as build environment. On Cygwin, Linux or Darwin you may want to make minor edits to win/Makefile.mingw to configure the cross-compile environment. | | | | | > > > > > > > > > > > > > > | 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 |
<li><p><i>MinGW/MinGW-w64</i> → Use the mingw makefile:
"<b>make -f win/Makefile.mingw</b>". On a Windows box you will
need either Cygwin or Msys as build environment. On Cygwin, Linux
or Darwin you may want to make minor edits to win/Makefile.mingw
to configure the cross-compile environment.
<li><p><i>MSVC</i> → Use the MSVC makefile. First
change to the "win/" subdirectory ("<b>cd win</b>") then run
"<b>nmake /f Makefile.msc</b>".<br><br>Alternatively, the batch
file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to
detect and use the latest installed version of MSVC.<br><br>To enable
the optional <a href="https://www.openssl.org/">OpenSSL</a> support,
first <a href="https://www.openssl.org/source/">download the official
source code for OpenSSL</a> and extract it to an appropriately named
"<b>openssl-X.Y.ZA</b>" subdirectory within the local
[/tree?ci=trunk&name=compat | compat] directory (e.g.
"<b>compat/openssl-1.0.1j</b>"), then make sure that some recent
<a href="http://www.perl.org/">Perl</a> binaries are installed locally,
and finally run one of the following commands:
<blockquote><pre>
nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
</pre></blockquote>
<blockquote><pre>
buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
</pre></blockquote>
<li><p><i>Cygwin</i> → The same as other unix-like systems. It is
recommended to configure using: "<b>configure --disable-internal-sqlite</b>",
making sure you have the "libsqlite3-devel" , "zlib-devel" and
"openssl-devel" packages installed first.
</ol>
</ol>
|
| ︙ | ︙ |
Changes to www/changes.wiki.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
<title>Change Log</title>
<h2>Changes For Version 1.30 (as yet unreleased)</h2>
* Add setting to control the number of times autosync will be tried before
returning an error.
* Add the [/help/fusefs|fossil fusefs DIRECTORY] command that mounts a
Fuse Filesystem at the given DIRECTORY and populates it with read-only
copies of all historical check-ins. This only works on systems that
support FuseFS.
* Support customization of commands and webpages, including the ability to
add new ones, via the "TH1 hooks" feature. Disabled by default. Enabled
via a compile-time option.
* Add the <nowiki>[checkout], [render], [styleHeader], [styleFooter],
| > > > | | > > | 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 |
<title>Change Log</title>
<h2>Changes For Version 1.30 (as yet unreleased)</h2>
* Add setting to control the number of times autosync will be tried before
returning an error.
* Add the [/help/fusefs|fossil fusefs DIRECTORY] command that mounts a
Fuse Filesystem at the given DIRECTORY and populates it with read-only
copies of all historical check-ins. This only works on systems that
support FuseFS.
* Added a compile-time option (--with-miniz) to build using miniz instead
of zlib. Disabled by default.
* Several fixes to the TH1 expression parser.
* Support customization of commands and webpages, including the ability to
add new ones, via the "TH1 hooks" feature. Disabled by default. Enabled
via a compile-time option.
* Add the <nowiki>[checkout], [render], [styleHeader], [styleFooter],
[trace], [getParameter], [setParameter], [artifact], and
[globalState]</nowiki> commands to TH1, primarily for use by TH1 hooks.
* Bring in the latest version of autosetup from upstream.
* When committing a (non-binary) file which contains bytes forming an
invalid UTF-8 stream, fossil now adds the possibility to convert it
to a valid UTF-8 stream ('c') if you like.
* Let [/help?cmd=new|fossil new] no longer create an initial empty commit
by default. The first commit after checking out an empty repository will
become the initial commit. (NOT PLANNED FOR 1.30, BUT DONE TO EXPOSE
[/help?cmd=new|fossil new --empty] TO MORE FIELD TESTING BEFORE
MAKING ANY DECISION ON IT!)
* Added a line-number toggle option to the [/help?cmd=/info|/info]
and [/help?cmd=/artifact|/artifact] pages.
<h2>Changes For Version 1.29 (2014-06-12)</h2>
* Add the ability to display content, diffs and annotations for UTF16
text files in the web interface.
* Add the "SaveAs..." and "Invert" buttons
to the graphical diff display that results
from using the --tk option with the [/help/diff | fossil diff] command.
|
| ︙ | ︙ | |||
437 438 439 440 441 442 443 |
* Add an Admin/Access setting to change the number of octets of the
IP address that are saved in login cookies - allowing this setting
to be changed to zero
* Promote the "test-md5sum" command to "md5sum".
* Added the "whatis" command.
* Stop showing the server-code in status outputs - it is no longer used
for anything.
| | | | 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 |
* Add an Admin/Access setting to change the number of octets of the
IP address that are saved in login cookies - allowing this setting
to be changed to zero
* Promote the "test-md5sum" command to "md5sum".
* Added the "whatis" command.
* Stop showing the server-code in status outputs - it is no longer used
for anything.
* Added a compile-time option (--with-tcl) to build in full Tcl scripting
support via integration with TH1.
* Merged the JSON branch into trunk. Disabled by default. Enabled
by a compile-time option. Probably it will be enabled by default
in some future release.
* Update to use SQLite version 3.7.9 plus the alignment fix for Sparc.
align
<h2>Changes For Version 1.20 (2011-10-21)</h2>
|
| ︙ | ︙ |
Changes to www/fileformat.wiki.
| ︙ | ︙ | |||
26 27 28 29 30 31 32 | The local state is not versioned and is not synchronized with the global state. The local state is not composed of artifacts and is not intended to be enduring. This document is concerned with global state only. Local state is only mentioned here in order to distinguish it from global state. Each artifact in the repository is named by its SHA1 hash. | | | | 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 | The local state is not versioned and is not synchronized with the global state. The local state is not composed of artifacts and is not intended to be enduring. This document is concerned with global state only. Local state is only mentioned here in order to distinguish it from global state. Each artifact in the repository is named by its SHA1 hash. No prefixes or meta information is added to an artifact before its hash is computed. The name of an artifact in the repository is exactly the same SHA1 hash that is computed by sha1sum on the file as it exists in your source tree.</p> Some artifacts have a particular format which gives them special meaning to fossil. Fossil recognizes: <ul> |
| ︙ | ︙ | |||
236 237 238 239 240 241 242 | A sample manifest from Fossil itself can be seen [/artifact/28987096ac | here]. <a name="cluster"></a> <h2>2.0 Clusters</h2> | | | 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 | A sample manifest from Fossil itself can be seen [/artifact/28987096ac | here]. <a name="cluster"></a> <h2>2.0 Clusters</h2> A cluster is an artifact that declares the existence of other artifacts. Clusters are used during repository synchronization to help reduce network traffic. As such, clusters are an optimization and may be removed from a repository without loss or damage to the underlying project code. Clusters follow a syntax that is very similar to manifests. A Cluster is a line-oriented text file. Newline characters |
| ︙ | ︙ |
Changes to www/makefile.wiki.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 | These two files are imports like the SQLite source files, and so are not preprocessed. The VERSION.h header file is generated from other information sources using a small program called: 9. mkversion.c The src/ subdirectory also contains documentation about the makeheaders preprocessor program: | > > > > > > > | | | | 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 | These two files are imports like the SQLite source files, and so are not preprocessed. The VERSION.h header file is generated from other information sources using a small program called: 9. mkversion.c The builtin_data.h header file contains the definitions of C-language byte-array constants that contain various resources such as scripts and images. The builtin_data.h header file is generate from the original resource files using a small program called: 10 mkbuiltin.c The src/ subdirectory also contains documentation about the makeheaders preprocessor program: 11. [../src/makeheaders.html | makeheaders.html] Click on the link to read this documentation. In addition there is a [http://www.tcl.tk/ | Tcl] script used to build the various makefiles: 12. makemake.tcl Running this Tcl script will automatically regenerate all makefiles. In order to add a new source file to the Fossil implementation, simply edit makemake.tcl to add the new filename, then rerun the script, and all of the makefiles for all targets will be rebuild. Finally, there is one of the makefiles generated by makemake.tcl: 13. main.mk The main.mk makefile is invoked from the Makefile in the top-level directory. The main.mk is generated by makemake.tcl and should not be hand edited. Other makefiles generated by makemake.tcl are in other subdirectories (currently all in the win/ subdirectory). All the other files in the src/ subdirectory (79 files at the time of |
| ︙ | ︙ | |||
103 104 105 106 107 108 109 | updated by Fossil itself. See the [/help/setting | fossil set manifest] command for additional information.) The VERSION.h header file is generated by a C program: src/mkversion.c. To run the VERSION.h generator, first compile the src/mkversion.c source file into a command-line program (named "mkversion.exe") | | > > > > > > > > > > > > > > | 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 | updated by Fossil itself. See the [/help/setting | fossil set manifest] command for additional information.) The VERSION.h header file is generated by a C program: src/mkversion.c. To run the VERSION.h generator, first compile the src/mkversion.c source file into a command-line program (named "mkversion.exe") then run: <blockquote><pre> mkversion.exe manifest.uuid manifest VERSION >VERSION.h </pre></blockquote> The pathnames in the above command might need to be adjusted to get the directories right. The point is that the manifest.uuid, manifest, and VERSION files in the root of the source tree are the three arguments and the generated VERSION.h file appears on standard output. The builtin_data.h header file is generated by a C program: src/mkbuiltin.c. The builtin_data.h file contains C-langauge byte-array definitions for the content of resource files used by Fossil. To generate the builtin_data.h file, first compile the mkbuiltin.c program, then run: <blockquote><pre> mkbuiltin.exe diff.tcl <i>OtherFiles...</i> >builtin_data.h </pre></blockquote> At the time of this writing, the "diff.tcl" script (a Tcl/Tk script used to generate implement --tk option on the diff command) is the only resource file processed using mkbuiltin.exe. However, new resources will likely be added using this facility in future versions of Fossil. <a name="preprocessing"></a> <h1>4.0 Preprocessing</h1> There are three preprocessors for the Fossil sources. The mkindex and translate preprocessors can be run in any order. The makeheaders preprocessor must be run after translate. |
| ︙ | ︙ |
Changes to www/pop.wiki.
| ︙ | ︙ | |||
29 30 31 32 33 34 35 | collection of artifacts. Each artifact is named by its SHA1 hash encoded in lowercase hexadecimal. In many contexts, the name can be abbreviated to a unique prefix. A five- or six-character prefix usually suffices to uniquely identify a file.</p></li> <li><p>Because artifacts are named by their SHA1 hash, all artifacts | | | 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | collection of artifacts. Each artifact is named by its SHA1 hash encoded in lowercase hexadecimal. In many contexts, the name can be abbreviated to a unique prefix. A five- or six-character prefix usually suffices to uniquely identify a file.</p></li> <li><p>Because artifacts are named by their SHA1 hash, all artifacts are immutable. Any change to the content of an artifact also changes the hash that forms the artifacts name, thus creating a new artifact. Both the old original version of the artifact and the new change are preserved under different names.</p></li> <li><p>It is theoretically possible for two artifacts with different content to share the same hash. But finding two such artifacts is so incredibly difficult and unlikely that we |
| ︙ | ︙ |
Changes to www/quotes.wiki.
| ︙ | ︙ | |||
55 56 57 58 59 60 61 62 63 64 65 66 67 | <li>Klingon Code Warriors embrace Git; we enjoy arbitrary conflicts. Git is not for the weak and feeble. TODAY IS A GOOD DAY TO CODE. <blockquote> <i>teastain at [http://www.reddit.com/r/programming/comments/xpitj/10_things_i_hate_about_git/c5oj4fk] </blockquote> </ol> <h2>On The Usability Of Fossil:</h2> <ol> | > > > > > > > > > > > > > | > > > > > > > > > > | | 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 | <li>Klingon Code Warriors embrace Git; we enjoy arbitrary conflicts. Git is not for the weak and feeble. TODAY IS A GOOD DAY TO CODE. <blockquote> <i>teastain at [http://www.reddit.com/r/programming/comments/xpitj/10_things_i_hate_about_git/c5oj4fk] </blockquote> <li>[G]it is <i>designed</i> to forget things. <blockquote> <i>[http://www.cs.cmu.edu/~davide/howto/git_lose.html] </blockquote> <li>[I]n nearly 31 years of using a computer i have, in total, lost more data to git (while following the instructions!!!) than any other single piece of software. <blockquote> <i>Stephen Beal on the [http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg17181.html|Fossil mailing list] 2014-09-01.</i> </blockquote> </ol> <h2>On The Usability Of Fossil:</h2> <ol> <li value=9> Fossil mesmerizes me with simplicity especially after I struggled to get a bug-tracking system to work with mercurial. <blockquote> <i>rawjeev at [http://stackoverflow.com/questions/156322/what-do-people-think-of-the-fossil-dvcs]</i> </blockquote> <li>Fossil is the best thing to happen to my development workflow this year, as I am pretty sure that using Git has resulted in the premature death of too many of my brain cells. I'm glad to be able to replace Git in every place that I possibly can with Fossil. <blockquote> <i>Joe Prostko at [http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg16716.html] </blockquote> <li>Fossil is awesome!!! I have never seen an app like that before, such simplicity and flexibility!!! <blockquote> <i>zengr at [http://stackoverflow.com/questions/138621/best-version-control-for-lone-developer]</i> </blockquote> </ol> <h2>On Git Versus Fossil</h2> <ol> <li value=12> Just want to say thanks for fossil making my life easier.... Also <nowiki>[for]</nowiki> not having a misanthropic command line interface. <blockquote> <i>Joshua Paine at [http://www.mail-archive.com/fossil-users@lists.fossil-scm.org/msg02736.html]</i> </blockquote> |
| ︙ | ︙ |
Changes to www/sync.wiki.
| ︙ | ︙ | |||
157 158 159 160 161 162 163 | checks out, then the client is granted all privileges of the specified user.</p> <p>Privileges are cumulative. There can be multiple successful login cards. The session privileges are the bit-wise OR of the privileges of each individual login.</p> | | | | > > > > > > | | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | checks out, then the client is granted all privileges of the specified user.</p> <p>Privileges are cumulative. There can be multiple successful login cards. The session privileges are the bit-wise OR of the privileges of each individual login.</p> <h3>3.3 File and Compressed File Cards</h3> <p>Artifacts are transferred using either "file" cards, or "cfile" cards. (The name "file" card comes from the fact that most artifacts correspond to files, and "cfile" is just a compressed file.) </p> <h4>3.3.1 File Cards</h4> <p>For sync protocols, artifacts are transferred using "file" cards. File cards come in two different formats depending on whether the artifact is sent directly or as a delta from some other artifact.</p> <blockquote> <b>file</b> <i>artifact-id size</i> <b>\n</b> <i>content</i><br> <b>file</b> <i>artifact-id delta-artifact-id size</i> <b>\n</b> <i>content</i> </blockquote> <p>File cards are different from all other cards in that they followed by in-line "payload" data. The content of the artifact or the artifact delta consists of the first <i>size</i> bytes of the x-fossil content that immediately follow the newline that terminates the file card. Only file and cfile cards have this characteristic. </p> <p>The first argument of a file card is the ID of the artifact that is being transferred. The artifact ID is the lower-case hexadecimal representation of the SHA1 hash of the artifact. The last argument of the file card is the number of bytes of payload that immediately follow the file card. If the file card has only two arguments, that means the payload is the complete content of the artifact. If the file card has three arguments, then the payload is a delta and second argument is the ID of another artifact that is the source of the delta.</p> <p>File cards are sent in both directions: client to server and server to client. A delta might be sent before the source of the delta, so both client and server should remember deltas and be able to apply them when their source arrives.</p> <h4>3.3.2 Compressed File Cards</h4> <p>A client that sends a clone protocol version "3" or greater will receive artifacts as "cfile" cards while cloning. This card was introduced to improve the speed of the transfer of content by sending the compressed artifact directly from the server database to the client.</p> <p>Compressed File cards are similar to File cards, sharing the same in-line "payload" data characteristics and also the same treatment of direct content or delta content. It comes in two different formats depending on whether the artifact is sent directly or as a delta from some other artifact.</p> <blockquote> <b>cfile</b> <i>artifact-id usize csize</i> <b>\n</b> <i>content</i><br> <b>cfile</b> <i>artifact-id delta-artifact-id usize csize</i> <b>\n</b> <i>content</i><br> </blockquote> <p>The first argument of the cfile card is the ID of the artifact that is being transferred. The artifact ID is the lower-case hexadecimal representation of the SHA1 hash of the artifact. The second argument of the cfile card is the original size in bytes of the artifact. The last argument of the cfile card is the number of compressed bytes of payload that immediately follow the cfile card. If the cfile card has only three arguments, that means the payload is the complete content of the artifact. If the cfile card has four arguments, then the payload is a delta and the second argument is the ID of another artifact that is the source of the delta and the third argument is the original size of the delta artifact.</p> <p>Unlike file cards, cfile cards are only sent in one direction during a clone from server to client for clone protocol version "3" or greater.</p> <h3>3.4 Push and Pull Cards</h3> <p>Among the first cards in a client-to-server message are the push and pull cards. The push card tells the server that the client is pushing content. The pull card tells the server that the client wants to pull content. In the event of a sync, both cards are sent. The format is as follows:</p> |
| ︙ | ︙ | |||
230 231 232 233 234 235 236 | two-argument format.</p> <blockquote> <b>clone</b><br> <b>clone</b> <i>protocol-version sequence-number</i> </blockquote> | | | > > > > > > > | | | 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 | two-argument format.</p> <blockquote> <b>clone</b><br> <b>clone</b> <i>protocol-version sequence-number</i> </blockquote> <h4>3.5.1 Protocol 3</h4> <p>The latest clients send a two-argument clone message with a protocol version of "3". (Future versions of Fossil might use larger protocol version numbers.) Version "3" of the protocol enhanced version "2" by introducing the "cfile" card which is intended to speed up clone operations. Instead of sending "file" cards, the server will send "cfile" cards</p> <h4>3.5.2 Protocol 2</h4> <p>The sequence-number sent is the number of artifacts received so far. For the first clone message, the sequence number is 0. The server will respond by sending file cards for some number of artifacts up to the maximum message size. <p>The server will also send a single "clone_seqno" card to the client so that the client can know where the server left off. <blockquote> <b>clone_seqno</b> <i>sequence-number</i> </blockquote> <p>The clone message in subsequent HTTP requests for the same clone operation will use the sequence-number from the clone_seqno of the previous reply.</p> <p>In response to an initial clone message, the server also sends the client a push message so that the client can discover the projectcode for this project.</p> <h4>3.5.3 Legacy Protocol</h4> <p>Older clients send a clone card with no argument. The server responds to a blank clone card by sending an "igot" card for every artifact in the repository. The client will then issue "gimme" cards to pull down all the content it needs. <p>The legacy protocol works well for smaller repositories (50MB with 50,000 |
| ︙ | ︙ | |||
445 446 447 448 449 450 451 | <h3>3.13 Unknown Cards</h3> <p>If either the client or the server sees a card that is not described above, then it generates an error and aborts.</p> <h2>4.0 Phantoms And Clusters</h2> | | | | | 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 |
<h3>3.13 Unknown Cards</h3>
<p>If either the client or the server sees a card that is not
described above, then it generates an error and aborts.</p>
<h2>4.0 Phantoms And Clusters</h2>
<p>When a repository knows that an artifact exists and knows the ID of
that artifact, but it does not know the artifact content, then it stores that
artifact as a "phantom". A repository will typically create a phantom when
it receives an igot card for an artifact that it does not hold or when it
receives a file card that references a delta source that it does not
hold. When a server is generating its reply or when a client is
generating a new request, it will usually send gimme cards for every
phantom that it holds.</p>
<p>A cluster is a special artifact that tells of the existence of other
artifacts. Any artifact in the repository that follows the syntactic rules
of a cluster is considered a cluster.</p>
<p>A cluster is line oriented. Each line of a cluster
is a card. The cards are separated by the newline ("\n") character.
Each card consists of a single character card type, a space, and a
single argument. No extra whitespace and no trailing or leading
whitespace is allowed. All cards in the cluster must occur in
strict lexicographical order.</p>
<p>A cluster consists of one or more "M" cards followed by a single
"Z" card. Each M card holds an argument which is an artifact ID for an
artifact in the repository. The Z card has a single argument which is the
lower-case hexadecimal representation of the MD5 checksum of all
preceding M cards up to and included the newline character that
occurred just before the Z that starts the Z card.</p>
<p>Any artifact that does not match the specifications of a cluster
exactly is not a cluster. There must be no extra whitespace in
|
| ︙ | ︙ |