| | @@ -1,28 +1,28 @@ |
| 1 | 1 | #include "config.h" |
| 2 | 2 | |
| 3 | 3 | /* |
| 4 | | -** TH_USE_SQLITE, if defined, enables the "query" family of functions. |
| 4 | +** TH_ENABLE_SQLITE, if defined, enables the "query" family of functions. |
| 5 | 5 | ** They provide SELECT-only access to the repository db. |
| 6 | 6 | */ |
| 7 | | -#define TH_USE_SQLITE |
| 7 | +#define TH_ENABLE_SQLITE |
| 8 | 8 | |
| 9 | 9 | /* |
| 10 | | -** TH_USE_OUTBUF, if defined, enables the "ob" family of functions. |
| 10 | +** TH_ENABLE_OUTBUF, if defined, enables the "ob" family of functions. |
| 11 | 11 | ** They are functionally similar to PHP's ob_start(), ob_end(), etc. |
| 12 | 12 | ** family of functions, providing output capturing/buffering. |
| 13 | 13 | */ |
| 14 | | -#define TH_USE_OUTBUF |
| 14 | +#define TH_ENABLE_OUTBUF |
| 15 | 15 | |
| 16 | 16 | /* |
| 17 | | -** TH_USE_ARGV, if defined, enables the "argv" family of functions. |
| 17 | +** TH_ENABLE_ARGV, if defined, enables the "argv" family of functions. |
| 18 | 18 | ** They provide access to CLI arguments as well as GET/POST arguments. |
| 19 | 19 | ** They do not provide access to POST data submitted in JSON mode. |
| 20 | 20 | */ |
| 21 | | -#define TH_USE_ARGV |
| 21 | +#define TH_ENABLE_ARGV |
| 22 | 22 | |
| 23 | | -#ifdef TH_USE_OUTBUF |
| 23 | +#ifdef TH_ENABLE_OUTBUF |
| 24 | 24 | #ifndef INTERFACE |
| 25 | 25 | #include "blob.h" |
| 26 | 26 | #endif |
| 27 | 27 | #endif |
| 28 | 28 | |
| | @@ -200,11 +200,11 @@ |
| 200 | 200 | |
| 201 | 201 | /* |
| 202 | 202 | ** Interfaces to register the language extensions. |
| 203 | 203 | */ |
| 204 | 204 | int th_register_language(Th_Interp *interp); /* th_lang.c */ |
| 205 | | -int th_register_sqlite(Th_Interp *interp); /* th_main.c */ |
| 205 | +int th_register_query(Th_Interp *interp); /* th_main.c */ |
| 206 | 206 | int th_register_argv(Th_Interp *interp); /* th_main.c */ |
| 207 | 207 | int th_register_vfs(Th_Interp *interp); /* th_vfs.c */ |
| 208 | 208 | int th_register_testvfs(Th_Interp *interp); /* th_testvfs.c */ |
| 209 | 209 | int th_register_tcl(Th_Interp *interp, void *pContext); /* th_tcl.c */ |
| 210 | 210 | int th_register_ob(Th_Interp * interp); /* th.c */ |
| | @@ -313,30 +313,21 @@ |
| 313 | 313 | ** Returns TH_OK on success, "something else" on error. |
| 314 | 314 | */ |
| 315 | 315 | int Th_register_commands( Th_Interp * interp, Th_Command_Reg const * pList ); |
| 316 | 316 | |
| 317 | 317 | |
| 318 | | -#ifdef TH_USE_OUTBUF |
| 318 | +#ifdef TH_ENABLE_OUTBUF |
| 319 | 319 | /* |
| 320 | 320 | ** Manager of a stack of Blob objects for output buffering. |
| 321 | +** See Th_ob_manager(). |
| 321 | 322 | */ |
| 322 | | -struct Th_Ob_Man { |
| 323 | | - Blob ** aBuf; /* Stack of Blobs */ |
| 324 | | - int nBuf; /* Number of blobs */ |
| 325 | | - int cursor; /* Current level (-1=not active) */ |
| 326 | | - Th_Interp * interp; /* The associated interpreter */ |
| 327 | | - Th_Vtab_Output * aOutput |
| 328 | | - /* Stack of output routines corresponding |
| 329 | | - to the current buffering level. |
| 330 | | - Has nBuf entries. |
| 331 | | - */; |
| 332 | | -}; |
| 333 | | - |
| 334 | 323 | typedef struct Th_Ob_Man Th_Ob_Man; |
| 335 | 324 | |
| 336 | 325 | /* |
| 337 | | -** Returns the ob manager for the given interpreter. |
| 326 | +** Returns the ob manager for the given interpreter. The manager gets |
| 327 | +** installed by the th_register_ob(). In Fossil ob support is |
| 328 | +** installed automatically if it is available at built time. |
| 338 | 329 | */ |
| 339 | 330 | Th_Ob_Man * Th_ob_manager(Th_Interp *ignored); |
| 340 | 331 | |
| 341 | 332 | /* |
| 342 | 333 | ** Returns the top-most Blob in pMan's stack, or NULL |
| | @@ -352,15 +343,22 @@ |
| 352 | 343 | */ |
| 353 | 344 | int Th_ob_push( Th_Ob_Man * pMan, Blob ** pOut ); |
| 354 | 345 | |
| 355 | 346 | /* |
| 356 | 347 | ** Pops the top-most output buffer off the stack and returns |
| 357 | | -** it. Returns NULL if there is no current buffer. When the last |
| 358 | | -** buffer is popped, pMan's internals are cleaned up. |
| 348 | +** it. Returns NULL if there is no current buffer. When the last |
| 349 | +** buffer is popped, pMan's internals are cleaned up (but pMan is not |
| 350 | +** freed). |
| 359 | 351 | ** |
| 360 | | -** The caller owns the returned object and must eventually call |
| 361 | | -** blob_reset() on it and Th_Free() it. |
| 352 | +** The caller owns the returned object and must eventually clean it up |
| 353 | +** by first passing it to blob_reset() and then Th_Free() it. |
| 362 | 354 | */ |
| 363 | 355 | Blob * Th_ob_pop( Th_Ob_Man * pMan ); |
| 356 | +/* |
| 357 | +** Convenience form of Th_ob_pop() which pops and frees the |
| 358 | +** top-most buffer. Returns 0 on success, non-0 if there is no |
| 359 | +** stack to pop. |
| 360 | +*/ |
| 361 | +int Th_ob_pop_free( Th_Ob_Man * pMan ); |
| 364 | 362 | |
| 365 | 363 | #endif |
| 366 | | -/* TH_USE_OUTBUF */ |
| 364 | +/* TH_ENABLE_OUTBUF */ |
| 367 | 365 | |