Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | updated. |
---|---|
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
5efd8359852eee20d19e2eabf5d097bb |
User & Date: | monster 2012-08-07 05:12:04.924 |
Context
2012-08-09
| ||
01:06 | mySQL backend for XDDB check-in: 64eb4d0d7d user: monster tags: trunk | |
2012-08-07
| ||
05:12 | updated. check-in: 5efd835985 user: monster tags: trunk | |
2012-08-03
| ||
06:54 | xtmpl added check-in: 5cba536d25 user: monster tags: trunk | |
Changes
Changes to buffer.hc.
︙ | ︙ | |||
82 83 84 85 86 87 88 | #ifdef _YO_BUFFER_BUILTIN { if ( capacity < 0 ) __Raise(YO_ERROR_OUT_OF_RANGE,0); if ( !bf ) bf = Buffer_Init(0); | | > > | 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | #ifdef _YO_BUFFER_BUILTIN { if ( capacity < 0 ) __Raise(YO_ERROR_OUT_OF_RANGE,0); if ( !bf ) bf = Buffer_Init(0); if ( bf->capacity < capacity || !bf->at ) { bf->at = __Realloc_Npl(bf->at,capacity+1); bf->capacity = capacity; STRICT_REQUIRE(bf->count <= bf->capacity ); bf->at[bf->count] = 0; } return bf; } #endif ; |
︙ | ︙ | |||
261 262 263 264 265 266 267 | E = p + len; while ( p != E ) { do { | | | > > > | 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 | E = p + len; while ( p != E ) { do { if ( *p < 30 || *p == '\\' || *p == brk || *p == '"' || *p == '\'' ) break; ++p; } while ( p != E ); if ( q != p ) Buffer_Append(bf,q,p-q); if ( p != E ) { if ( *p == '\n' ) Buffer_Append(bf,"\\n",2); else if ( *p == '\t' ) Buffer_Append(bf,"\\t",2); else if ( *p == '\r' ) Buffer_Append(bf,"\\r",2); else if ( *p == '\\' ) Buffer_Append(bf,"\\\\",2); else if ( *p == brk ) { Buffer_Fill_Append(bf,'\\',1); Buffer_Fill_Append(bf,brk,1); } else if ( *p == '"' ) Buffer_Append(bf,"\\\"",2); else if ( *p == '\'' ) Buffer_Append(bf,"\\'",2); else if ( *p < 30 ) { Buffer_Append(bf,"\\x",2); Buffer_Hex_Append(bf,p,1); } ++p; |
︙ | ︙ |
Changes to dicto.hc.
︙ | ︙ | |||
50 51 52 53 54 55 56 57 58 59 60 61 62 63 | #define _YO_DICTO_BUILTIN #endif #include "yoyo.hc" #include "crc.hc" #include "buffer.hc" #include "array.hc" typedef struct _YO_DICTO_REC { struct _YO_DICTO_REC *next; void *ptr; byte_t hashcode; char key[1]; | > | 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #define _YO_DICTO_BUILTIN #endif #include "yoyo.hc" #include "crc.hc" #include "buffer.hc" #include "array.hc" #include "string.hc" typedef struct _YO_DICTO_REC { struct _YO_DICTO_REC *next; void *ptr; byte_t hashcode; char key[1]; |
︙ | ︙ | |||
382 383 384 385 386 387 388 | dicto_apply_filter_t filter = _filter; if ( o && o->table ) for ( i = 0; i < o->width; ++i ) { nrec = o->table[i]; while ( nrec ) { | | | 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | dicto_apply_filter_t filter = _filter; if ( o && o->table ) for ( i = 0; i < o->width; ++i ) { nrec = o->table[i]; while ( nrec ) { __Auto_Release filter(nrec->key,nrec->ptr,state); nrec = nrec->next; } } } #endif ; |
︙ | ︙ | |||
460 461 462 463 464 465 466 | Buffer_Append(bf,", ",2); else j = 1; if ( pretty ) Buffer_Fill_Append(bf,' ',2); Buffer_Append(bf,nrec->key,-1); Buffer_Append(bf,": ",2); | | > > > > > > > > > > > | 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 | Buffer_Append(bf,", ",2); else j = 1; if ( pretty ) Buffer_Fill_Append(bf,' ',2); Buffer_Append(bf,nrec->key,-1); Buffer_Append(bf,": ",2); __Auto_Release print(bf,nrec->ptr); nrec = nrec->next; } } if ( j && pretty ) Buffer_Fill_Append(bf,'\n',1); Buffer_Fill_Append(bf,'}',1); if ( !_bf ) return Buffer_Take_Data(bf); else return bf->at+start; } #endif ; YO_DICTO *Dicto_Set_Str(YO_DICTO *dicto, char *key, void *val) #ifdef _YO_DICTO_BUILTIN { if ( !dicto ) dicto = Dicto_Ptrs(); Dicto_Put(dicto,key,Str_Copy_Npl(val,-1)); return dicto; } #endif ; #endif /* C_once_38B1FFE7_1462_42EB_BABE_AA8E0BE62203 */ |
Changes to file.hc.
︙ | ︙ | |||
1063 1064 1065 1066 1067 1068 1069 | if ( Raise_If_Cfile_Is_Not_Opened(f) ) { YO_BUFFER *L; quad_t len = Cfile_Available(f); if ( len > INT_MAX ) Yo_Raise(YO_ERROR_IO, "file to big to be read in one pass",__Yo_FILE__,__LINE__); | | | 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 | if ( Raise_If_Cfile_Is_Not_Opened(f) ) { YO_BUFFER *L; quad_t len = Cfile_Available(f); if ( len > INT_MAX ) Yo_Raise(YO_ERROR_IO, "file to big to be read in one pass",__Yo_FILE__,__LINE__); L = Buffer_Reserve(0,len); while ( len ) /* windoze text mode reads less then available, so we need to read carefully*/ { Buffer_Grow_Reserve(L,L->count+(int)len); L->count += Cfile_Read(f,L->at+L->count,(int)len,0); L->at[L->count] = 0; len = Cfile_Available(f); |
︙ | ︙ |
Added linebuf.hc.
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | /* Copyright © 2010-2011, Alexéy Sudachén, alexey@sudachen.name, Chile In USA, UK, Japan and other countries allowing software patents: This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. 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. See the GNU General Public License for more details. http://www.gnu.org/licenses/ Otherwise: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 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 OR COPYRIGHT HOLDERS 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. Except as contained in this notice, the name of a copyright holder shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization of the copyright holder. */ #ifndef C_once_FAC5C358_605A_4663_A129_F9C093097A9C #define C_once_FAC5C358_605A_4663_A129_F9C093097A9C #include "yoyo.hc" #include "string.hc" #include "buffer.hc" #ifdef _LIBYOYO #define _YO_DEFPARS_BUILTIN #endif typedef struct _YO_LINEBUF { void *file; char *file_name; void *fast_file_obj; int (*fast_file_read)(void *obj, void *bf, int count, int mincount); char *at; byte_t *tail; int tail_len; int cur_line; int next_line; int eof; YO_BUFFER *line; } YO_LINEBUF; void YO_LINEBUF_Destruct(YO_LINEBUF *lb) { __Unrefe(lb->line); __Unrefe(lb->file); free(lb->file_name); } YO_LINEBUF *Linebuf_Init(void *file, char *file_name) { YO_LINEBUF *lb = __Object_Dtor(sizeof(YO_LINEBUF),YO_LINEBUF_Destruct); lb->file = __Refe(file); lb->file_name = Str_Copy_Npl(file_name,-1); lb->line = __Refe(Buffer_Init(0)); lb->fast_file_obj = lb->file; lb->fast_file_read = Yo_Find_Method_Of(&lb->fast_file_obj,Oj_Read_OjMID,YO_RAISE_ERROR); return lb; } int Linebuf_Nextline(YO_LINEBUF *lb) { int i,j; byte_t *tail; tail = lb->line->at; if ( lb->tail_len ) { memmove(lb->line->at,lb->tail,lb->tail_len); Buffer_Resize(lb->line,lb->tail_len); } lb->cur_line = lb->next_line; lb->tail = 0; lb->tail_len = 0; i = 0; for (;;) { for ( ; tail[i] ; ++i ) if ( tail[i] == '\n' ) { tail[i] = 0; lb->tail = tail +i; lb->tail_len = lb->line->count - i; ++lb->next_line; break; } else if ( tail[i] == '\r' && i+1 < lb->line->count && tail[i+1] == '\n') { tail[i] = 0; lb->tail = tail + i + 1; lb->tail_len = lb->line->count - (i+1); ++lb->next_line; break; } if ( !lb->tail ) { Buffer_Reserve(lb->line,i+256); j = lb->fast_file_read(lb->fast_file_obj,lb->line->at+i,256,0); if ( j ) Buffer_Resize(lb->line,i+j); else break; } else break; } lb->at = lb->line->at; lb->eof = !lb->at[0] && lb->next_line == lb->cur_line; return !lb->eof; } int Linebuf_ExtendLine(YO_LINEBUF *lb) { return 0; } int Linebuf_Eof(YO_LINEBUF *lb) { return lb->eof; } int Linebuf_Lineno(YO_LINEBUF *lb) { return lb->cur_line; } #endif /* C_once_FAC5C358_605A_4663_A129_F9C093097A9C */ |
Changes to string.hc.
︙ | ︙ | |||
1769 1770 1771 1772 1773 1774 1775 1776 1777 | } return __Pool(R); } #endif ; #endif /* C_once_0ED387CD_668B_44C3_9D91_A6336A2F5F48 */ | > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 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 | } return __Pool(R); } #endif ; char *Str_Quote(char *S) #ifdef _YO_STRING_BUILTIN { int S_len = S? strlen(S):0; int R_count = 0; int R_capacity = S_len+1; char *R = 0; if ( S ) for ( ; *S; ++S ) { if ( 0 ) ; else if ( *(signed char*)S < 30 || *S == '"' || *S == '\'' ||*S == '\\' ) { char b[5] = {0,}; Str_Hex_Byte(*S,'\\',b); R_count += __Elm_Append_Npl(&R,R_count,b,4,1,&R_capacity); } else R_count += __Elm_Append_Npl(&R,R_count,S,1,1,&R_capacity); } return __Pool(R); } #endif ; #endif /* C_once_0ED387CD_668B_44C3_9D91_A6336A2F5F48 */ |
Changes to webcfg.hc.
︙ | ︙ | |||
58 59 60 61 62 63 64 | { char *foo; if ( !host ) host = Webhost_Init(); foo = cfg?Xnode_Value_Get_Str(&cfg->root,"doc_root",0):0; if ( !foo ) foo = Current_Directory(); | | | 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | { char *foo; if ( !host ) host = Webhost_Init(); foo = cfg?Xnode_Value_Get_Str(&cfg->root,"doc_root",0):0; if ( !foo ) foo = Current_Directory(); Webhost_Add_Doc_Root(host,foo); foo = cfg?Xnode_Value_Get_Str(&cfg->root,"exec_root",0):0; Webhost_Set_Exec_Root(host,foo); return host; } #endif |
︙ | ︙ |
Changes to webhost.hc.
︙ | ︙ | |||
84 85 86 87 88 89 90 | __Destruct(svc); } #endif ; typedef struct _YO_WEBHOST { | < > | | 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 | __Destruct(svc); } #endif ; typedef struct _YO_WEBHOST { char *exec_root; YO_ARRAY *doc_roots; YO_ARRAY *indexes; YO_ARRAY *services; int disable_index: 1; } YO_WEBHOST; void YO_WEBHOST_Destruct(YO_WEBHOST *host) #ifdef _YO_WEBHOST_BUILTIN { __Unrefe(host->indexes); __Unrefe(host->doc_roots); free(host->exec_root); __Destruct(host); } #endif ; typedef struct _YO_WEBHOST_CGIST |
︙ | ︙ | |||
136 137 138 139 140 141 142 143 144 145 146 147 | ; YO_WEBHOST *Webhost_Init() #ifdef _YO_WEBHOST_BUILTIN { YO_WEBHOST *host = __Object_Dtor(sizeof(YO_WEBHOST),YO_WEBHOST_Destruct); host->indexes = __Refe(Array_Pchars()); return host; } #endif ; | > | | | | 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 | ; YO_WEBHOST *Webhost_Init() #ifdef _YO_WEBHOST_BUILTIN { YO_WEBHOST *host = __Object_Dtor(sizeof(YO_WEBHOST),YO_WEBHOST_Destruct); host->indexes = __Refe(Array_Pchars()); host->doc_roots = __Refe(Array_Pchars()); return host; } #endif ; YO_WEBHOST *Webhost_Add_Doc_Root(YO_WEBHOST *host, char *doc_root) #ifdef _YO_WEBHOST_BUILTIN { if ( doc_root ) Array_Push(host->doc_roots,Str_Copy_Npl(doc_root,-1)); return host; } #endif ; YO_WEBHOST *Webhost_Set_Exec_Root(YO_WEBHOST *host, char *exec_root) #ifdef _YO_WEBHOST_BUILTIN |
︙ | ︙ | |||
320 321 322 323 324 325 326 | } return fpath; } #endif ; | | | | 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 | } return fpath; } #endif ; char *Webhost_Find_Handler(YO_WEBHOST *host, char *doc_root, char *query, char **script, char **pathinfo,YO_WEBHOST_SERVICE **h) #ifdef _YO_WEBHOST_BUILTIN { char *fpath = 0; if ( !host->services ) return 0; __Auto_Ptr(fpath) { int i, L; YO_ARRAY *extL = Array_Init(); YO_ARRAY *patL = Str_Split(query,"/"); YO_BUFFER *bf = Buffer_Acquire(Path_Normilize_Npl(doc_root)); for ( i = 0; i < host->services->count; ++i ) { YO_WEBHOST_SERVICE *svc = host->services->at[i]; if ( svc->ext ) Array_Push(extL,svc->ext); } |
︙ | ︙ | |||
364 365 366 367 368 369 370 | } return fpath; } #endif ; | | | 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | } return fpath; } #endif ; YO_ARRAY *Webhost_Setup_Environment(char *doc_root, YO_HTTPD_REQUEST *rqst, char *path, char *script, char *pathinfo, YO_URL *url) #ifdef _YO_WEBHOST_BUILTIN { YO_ARRAY *env; __Auto_Ptr(env) { char *method = 0; env = Array_Pchars(); |
︙ | ︙ | |||
404 405 406 407 408 409 410 | case HTTPD_PUT_METHOD: method = "PUT"; break; } Array_Push(env,Str_Concat_Npl("REQUEST_METHOD=",method)); Array_Push(env,Str_Concat_Npl("REMOTE_ADDR=",rqst->remote_addr)); Array_Push(env,Str_Concat_Npl("REMOTE_HOST=",rqst->remote_addr)); Array_Push(env,Str_Concat_Npl("REQUEST_URI=",url->uri)); | > | | 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 | case HTTPD_PUT_METHOD: method = "PUT"; break; } Array_Push(env,Str_Concat_Npl("REQUEST_METHOD=",method)); Array_Push(env,Str_Concat_Npl("REMOTE_ADDR=",rqst->remote_addr)); Array_Push(env,Str_Concat_Npl("REMOTE_HOST=",rqst->remote_addr)); Array_Push(env,Str_Concat_Npl("REQUEST_URI=",url->uri)); if ( doc_root ) Array_Push(env,Str_Concat_Npl("DOCUMENT_ROOT=",doc_root)); Array_Push(env,Str_Concat_Npl("HTTP_REFERRER=",Dicto_Get(rqst->qhdr,"REFERRER",""))); if ( Dicto_Has(rqst->qhdr,"COOKIE") ) Array_Push(env,Str_Concat_Npl("HTTP_COOKIE=",Dicto_Get(rqst->qhdr,"COOKIE",""))); //("HTTP_USER_AGENT"); //("HTTP_ACCEPT_LANGUAGE"); //("SERVER_NAME"); |
︙ | ︙ | |||
445 446 447 448 449 450 451 | } } return 0; } #endif ; | | > > | | 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 | } } return 0; } #endif ; void Webhost_Execute_Service(YO_WEBHOST_CGIST *st, char *doc_root) #ifdef _YO_WEBHOST_BUILTIN { YO_ARRAY *env; if ( !doc_root ) doc_root = st->host->doc_roots->count?st->host->doc_roots->at[0]:0; env = Webhost_Setup_Environment(doc_root,st->rqst,st->path,st->script,st->pathinfo,st->url); st->rqst->outstrm_type = Mime_String_Of_Npl(YO_MIME_HTML); st->rqst->outstrm = __Refe(Cfile_Temp()); st->cgi = __Refe(Cgi_Init_2(st->rqst->instrm,st->rqst->outstrm,(char**)env->at)); Tasque_Alert(0,st->svc->callback,st); } #endif ; |
︙ | ︙ | |||
598 599 600 601 602 603 604 605 | __Auto_Release { char *curdir = Current_Directory(); __Try_Except { YO_ARRAY *env; Change_Directory(Path_Dirname(st->path)); | > | | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 | __Auto_Release { char *curdir = Current_Directory(); __Try_Except { YO_ARRAY *env; char *doc_root = st->host->doc_roots->count?st->host->doc_roots->at[0]:0; Change_Directory(Path_Dirname(st->path)); env = Webhost_Setup_Environment(doc_root,st->rqst,st->path,st->script,st->pathinfo,st->url); st->pipex = __Refe(Pipex_Exec(Path_Basename(st->path),0,PIPEX_TMPFILE,PIPEX_NONE,(char**)env->at)); if ( st->rqst->instrm ) { int c = Oj_Copy_File(st->rqst->instrm,st->pipex->fin); Oj_Flush(st->pipex->fin); |
︙ | ︙ | |||
668 669 670 671 672 673 674 | for ( i = 0; i < L; ++i ) if ( b[i] < 30 || b[i] > 127 ) b[i] = '.'; if ( rqst->instrm_length > MAX_L ) memcpy(b+MAX_L-3,">>>",3); Log_Info("[%p] POSTDTA %s",rqst,b); } if ( host->services ) { | | | > > > > > | > > | > > | | > > > > | | > | 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 | for ( i = 0; i < L; ++i ) if ( b[i] < 30 || b[i] > 127 ) b[i] = '.'; if ( rqst->instrm_length > MAX_L ) memcpy(b+MAX_L-3,">>>",3); Log_Info("[%p] POSTDTA %s",rqst,b); } if ( host->services ) { YO_WEBHOST_SERVICE *svc = 0; svc = Webhost_Find_Service(host->services,url->query,&script,&pathinfo); if ( svc ) { YO_WEBHOST_CGIST *st = Webhost_CGI_State(host, rqst, __Retain(path), script, pathinfo, url); st->svc = __Refe(svc); Webhost_Execute_Service(st,host->doc_roots->at[0]); return 0; } } #ifdef __windoze if ( host->exec_root ) { path = Webhost_Find_Executable(host,url->query,&script,&pathinfo); if ( path ) return Webhost_Execute_CGI(Webhost_CGI_State(host, rqst, __Retain(path), script, pathinfo, url)); } #endif if ( host->services ) { char *doc_root = 0; char *path = 0; YO_WEBHOST_SERVICE *svc = 0; for ( i = 0; i < host->doc_roots->count; ++i ) { doc_root = host->doc_roots->at[i]; path = Webhost_Find_Handler(host,doc_root,url->query,&script,&pathinfo,&svc); if ( path ) break; } if ( svc ) { YO_WEBHOST_CGIST *st = Webhost_CGI_State(host, rqst, __Retain(path), script, pathinfo, url); st->svc = __Refe(svc); Webhost_Execute_Service(st,doc_root); return 0; } } for ( i = 0; i < host->doc_roots->count; ++i ) { path = Path_Join(host->doc_roots->at[i],url->query); path = Path_Normposix(path); if ( File_Get_Stats(path,&stats,1)->f.exists ) break; else path = 0; } if ( path ) { if ( stats.f.is_directory ) { for ( i = 0; i < host->indexes->count; ++i ) { char *path1 = Path_Join(path,host->indexes->at[i]); if ( File_Get_Stats(path1,&stats,1)->f.exists ) |
︙ | ︙ |
Changes to xdata.hc.
︙ | ︙ | |||
846 847 848 849 850 851 852 | #endif ; YO_XNODE *Xnode_Next_If(YO_XNODE *node, char *tag_name) #ifdef _YO_XDATA_BUILTIN { ushort_t tag; | | | | 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 | #endif ; YO_XNODE *Xnode_Next_If(YO_XNODE *node, char *tag_name) #ifdef _YO_XDATA_BUILTIN { ushort_t tag; YO_XNODE *n = node; if ( !node ) return 0; //n = Xnode_Refacc(node); STRICT_REQUIRE( n ); STRICT_REQUIRE( tag_name ); STRICT_REQUIRE( (n->opt&XVALUE_OPT_IS_VALUE) == 0 ); tag = (ushort_t)(longptr_t)Xdata_Resolve_Name(n->xdata,tag_name,0); |
︙ | ︙ |
Added xddbmsql.hc.
Added xddbsql3.hc.
Changes to xdef.hc.
︙ | ︙ | |||
410 411 412 413 414 415 416 417 418 419 420 421 422 423 | void Def_Parse_In_Node( YO_XDEF_STATE *st, YO_XNODE *n ) #ifdef _YO_XDEF_BUILTIN { Def_Parse_Skip_Spaces(st); for ( ; *st->text && *st->text != '}' ; Def_Parse_Skip_Spaces(st) ) { int go_deeper = 0; YO_XNODE *nn = 0; __Auto_Release { YO_XDEF_VALUE value = {0}; char *name; | > | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 | void Def_Parse_In_Node( YO_XDEF_STATE *st, YO_XNODE *n ) #ifdef _YO_XDEF_BUILTIN { Def_Parse_Skip_Spaces(st); for ( ; *st->text && *st->text != '}' ; Def_Parse_Skip_Spaces(st) ) { int set_if_not_set = 0; int go_deeper = 0; YO_XNODE *nn = 0; __Auto_Release { YO_XDEF_VALUE value = {0}; char *name; |
︙ | ︙ | |||
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 | if ( *st->text != ')' ) __Raise(YO_ERROR_ILLFORMED,__Format("expected ')' at line %d",st->lineno)); ++st->text; Def_Parse_Skip_Spaces(st); } if ( *st->text == '=' ) { ++st->text; Def_Parse_Skip_Spaces(st); Def_Parse_Get_Value(st,&value); Def_Parse_Skip_Spaces(st); } if ( *st->text == '<' && st->text[1] == '=' ) { YO_XDATA *xd = 0; YO_XNODE *sn = 0; char *include_file; char *subnode = 0; st->text += 2; Def_Parse_Skip_Spaces(st); include_file = Def_Parse_Get_Literal(st); Def_Parse_Skip_Spaces(st); subnode = strchr(include_file,':'); if ( subnode ) *subnode++ = 0; if ( st->dirname ) include_file = Path_Join(st->dirname,include_file); | > > > > > > > > > > > > > > | | | | | | > | 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 | if ( *st->text != ')' ) __Raise(YO_ERROR_ILLFORMED,__Format("expected ')' at line %d",st->lineno)); ++st->text; Def_Parse_Skip_Spaces(st); } if ( *st->text == '?' && st->text[1] == '=' ) { set_if_not_set = 1; ++st->text; } if ( *st->text == '=' ) { ++st->text; Def_Parse_Skip_Spaces(st); Def_Parse_Get_Value(st,&value); Def_Parse_Skip_Spaces(st); } if ( *st->text == '<' && st->text[1] == '=' ) { YO_XDATA *xd = 0; YO_XNODE *sn = 0; char *include_file; char *subnode = 0; int skip_if_dsnt_exists = 0; st->text += 2; Def_Parse_Skip_Spaces(st); include_file = Def_Parse_Get_Literal(st); Def_Parse_Skip_Spaces(st); if ( *include_file == '?' ) { ++include_file; skip_if_dsnt_exists = 1; } subnode = strchr(include_file,':'); if ( subnode ) *subnode++ = 0; if ( st->dirname ) include_file = Path_Join(st->dirname,include_file); if ( !skip_if_dsnt_exists || File_Exists(include_file) ) { xd = Def_Parse_File(include_file); sn = subnode?Xnode_Query_Node(&xd->root,subnode):&xd->root; if ( sn ) { nn = Xnode_Append_Refnode(n,name,sn); name = 0; } } } if ( nodename ) { if ( !nn ) nn = Xnode_Append(n,name); |
︙ | ︙ | |||
484 485 486 487 488 489 490 | nn = Xnode_Append(n,name); if ( value.type ) Def_Parse_In_Node_Set_Value(nn,"$",&value); } else if ( value.type ) { if ( name || !nn ) | > > | > | 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | nn = Xnode_Append(n,name); if ( value.type ) Def_Parse_In_Node_Set_Value(nn,"$",&value); } else if ( value.type ) { if ( name || !nn ) { if ( !set_if_not_set || !Xnode_Value(n,name,0) ) Def_Parse_In_Node_Set_Value(n,name,&value); } else Def_Parse_In_Node_Set_Value(nn,"$",&value); } } if ( go_deeper ) |
︙ | ︙ |
Changes to xtmpl.hc.
︙ | ︙ | |||
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | return source - S_source; } return 0; } #endif ; int Xtmpl_Dump_Template(YO_XNODE *n, char *source) #ifdef _YO_XTMPL_BUILTIN { char *S_source = source; for ( ; *source && *source != '}'; ) ++source; | > > > > > > > > > > > > > > > > > > > > | 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 | return source - S_source; } return 0; } #endif ; int Xtmpl_Quote_Template(YO_XNODE *n, char *source) #ifdef _YO_XTMPL_BUILTIN { char *S_source = source; for ( ; *source && *source != '}'; ) ++source; if ( *source == '}' ) { YO_XNODE *ext = Xnode_Append(n,"quote"); YO_XVALUE *val = Xnode_Value(ext,"$",1); Xvalue_Set_Str(val,S_source,source-S_source); ++source; return source - S_source; } return 0; } #endif ; int Xtmpl_Dump_Template(YO_XNODE *n, char *source) #ifdef _YO_XTMPL_BUILTIN { char *S_source = source; for ( ; *source && *source != '}'; ) ++source; |
︙ | ︙ | |||
225 226 227 228 229 230 231 | YO_XNODE *ext = Xnode_Append(n,tag); char *expr = Str_Trim_Copy_L(S_source,source-S_source); if ( expr && *expr ) { YO_XVALUE *val = Xnode_Value(ext,"$",1); Xvalue_Set_Or_Put_Str(val,expr); } | > | | 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | YO_XNODE *ext = Xnode_Append(n,tag); char *expr = Str_Trim_Copy_L(S_source,source-S_source); if ( expr && *expr ) { YO_XVALUE *val = Xnode_Value(ext,"$",1); Xvalue_Set_Or_Put_Str(val,expr); } ++source; source += Xtmpl_Macro_Template(ext,source,close_tag); return source - S_source; } return 0; } #endif ; |
︙ | ︙ | |||
289 290 291 292 293 294 295 296 297 298 299 300 301 302 | static char t_set[] = "set{"; static char t_repeat[] = "repeat{"; static char t_at[] = "at{"; static char t_at1[] = "at1{"; static char t_inc[] = "inc{"; static char t_dec[] = "dec{"; static char t_expand[] = "{"; static char t_comment[] = "/*"; char *S_source = source; char *Q; int close_len = close_tag?strlen(close_tag):0; for ( Q = source; *source; ) { | > | 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 | static char t_set[] = "set{"; static char t_repeat[] = "repeat{"; static char t_at[] = "at{"; static char t_at1[] = "at1{"; static char t_inc[] = "inc{"; static char t_dec[] = "dec{"; static char t_expand[] = "{"; static char t_quote[] = "quote{"; static char t_comment[] = "/*"; char *S_source = source; char *Q; int close_len = close_tag?strlen(close_tag):0; for ( Q = source; *source; ) { |
︙ | ︙ | |||
327 328 329 330 331 332 333 334 335 336 337 338 339 340 | Q = source; } else if ( !strncmp(source+1,t_expand,sizeof(t_expand)-1) ) { source += sizeof(t_expand); source += Xtmpl_Expand_Template(n,source); Q = source; } else if ( !strncmp(source+1,t_liftup,sizeof(t_liftup)-1) ) { source += sizeof(t_liftup); source += Xtmpl_Liftup_Template(n,source); Q = source; } | > > > > > > | 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | Q = source; } else if ( !strncmp(source+1,t_expand,sizeof(t_expand)-1) ) { source += sizeof(t_expand); source += Xtmpl_Expand_Template(n,source); Q = source; } else if ( !strncmp(source+1,t_quote,sizeof(t_quote)-1) ) { source += sizeof(t_quote); source += Xtmpl_Quote_Template(n,source); Q = source; } else if ( !strncmp(source+1,t_liftup,sizeof(t_liftup)-1) ) { source += sizeof(t_liftup); source += Xtmpl_Liftup_Template(n,source); Q = source; } |
︙ | ︙ | |||
1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 | char S[3]; sprintf(S,"%d",i); Dicto_Put(ctx->global,S,__Refe(m)); Xvalue_Set_Str(&m->value,L->at[i],strlen(L->at[i])); } Xtmpl_Query_Str_Bf(ctx,L->at[0],bf); } else if ( Xnode_Tag_Is(n,"def") ) { Xtmpl_Def_Macro(ctx,n); } else if ( Xnode_Tag_Is(n,"set") ) { Xtmpl_Set_Value(ctx,n); | > > > > > > > | 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 | char S[3]; sprintf(S,"%d",i); Dicto_Put(ctx->global,S,__Refe(m)); Xvalue_Set_Str(&m->value,L->at[i],strlen(L->at[i])); } Xtmpl_Query_Str_Bf(ctx,L->at[0],bf); } else if ( Xnode_Tag_Is(n,"quote") ) { int i; char *query = Xnode_Value_Get_Str(n,"$",0); YO_XVALUE *m = Xtmpl_Query_Value(ctx,query); if ( m ) Buffer_Quote_Append(bf,Xvalue_Get_Str(m,""),-1,0); } else if ( Xnode_Tag_Is(n,"def") ) { Xtmpl_Def_Macro(ctx,n); } else if ( Xnode_Tag_Is(n,"set") ) { Xtmpl_Set_Value(ctx,n); |
︙ | ︙ | |||
1140 1141 1142 1143 1144 1145 1146 | Xtmpl_Handle_Node_Out(bf,n,&ctx); n = Xnode_Next(n); } } #endif ; | > > > > > > > > > > > | > > | 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 | Xtmpl_Handle_Node_Out(bf,n,&ctx); n = Xnode_Next(n); } } #endif ; #ifdef _YO_XTMPL_BUILTIN void Xtmpl_Glob_Set(char *key, char *val, YO_DICTO *glob) { YO_XNODE *t; YO_BUFFER *bf = Buffer_Init(0); YO_XTMPL_VALUE *m = YO_XTMPL_VALUE_Init(); Dicto_Put(glob,key,__Refe(m)); Xvalue_Set_Str(&m->value,val,-1); } #endif void Xtmpl_Step_Down(YO_BUFFER *bf, YO_XNODE *tmpl, YO_XDATA *model, YO_DICTO *glob) #ifdef _YO_XTMPL_BUILTIN { YO_DICTO *global = Dicto_Refs(); YO_XTMPL_UP upstep_q[32] = { {tmpl, 0}, }; YO_XNODE *down; YO_XTMPL_UP *upstep = upstep_q; Dicto_Apply(glob,Xtmpl_Glob_Set,global); for ( down = Xnode_Down_If(tmpl,"extends"); down; ) { Xtmpl_Step_Down_Global_Set(upstep->tmpl,down,global,model); upstep[1].up = upstep; ++upstep; upstep->tmpl = down; |
︙ | ︙ | |||
1172 1173 1174 1175 1176 1177 1178 | ctx.tmpl = tmpl; Xtmpl_Step_Up(bf,upstep,"content",&ctx); } } #endif ; | | | | 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 | ctx.tmpl = tmpl; Xtmpl_Step_Up(bf,upstep,"content",&ctx); } } #endif ; char *Xtmpl_Produce_Out(YO_BUFFER *bf, YO_XDATA *tmpl, YO_XDATA *model, YO_DICTO *glob) #ifdef _YO_XTMPL_BUILTIN { YO_BUFFER *xbf = bf; if ( !xbf ) xbf = Buffer_Init(0); Buffer_Append(bf,"\n",1); Xtmpl_Step_Down(bf,&tmpl->root,model,glob); return bf?xbf->at:Buffer_Take_Data(xbf); } #endif ; #ifdef _YO_XTMPL_BUILTIN |
︙ | ︙ | |||
1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 | Dicto_Put(dt,S,__Refe(doc)); /* doc can be NULL */ } return doc; } #endif YO_XDATA *Xtmpl_Autoload(char *root, char *name, char **langlist /*zero terminated langiages list*/) #ifdef _YO_XTMPL_BUILTIN { YO_XDATA *doc = 0; __Auto_Release /* document is retaining by template cache */ { if (langlist) for ( ; !doc && *langlist; ++langlist ) | > > > > > > > > > > > > | 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 | Dicto_Put(dt,S,__Refe(doc)); /* doc can be NULL */ } return doc; } #endif void Xtmpl_Drop_Cache() #ifdef _YO_XTMPL_BUILTIN { if ( Xtmpl_Cache_Dicto ) { __Unrefe(Xtmpl_Cache_Dicto); Xtmpl_Cache_Dicto = __Refe(Dicto_Refs()); } } #endif ; YO_XDATA *Xtmpl_Autoload(char *root, char *name, char **langlist /*zero terminated langiages list*/) #ifdef _YO_XTMPL_BUILTIN { YO_XDATA *doc = 0; __Auto_Release /* document is retaining by template cache */ { if (langlist) for ( ; !doc && *langlist; ++langlist ) |
︙ | ︙ |