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: |
ace7839bf1369a29cfa9dcffca1a7a2d |
User & Date: | monster 2012-07-24 17:26:00.760 |
Context
2012-07-24
| ||
17:27 | updated check-in: d07351188b user: monster tags: trunk | |
17:26 | updated check-in: ace7839bf1 user: monster tags: trunk | |
17:23 | updated check-in: fb3d7efd70 user: monster tags: trunk | |
Changes
Added stdf.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 | /* (C)2010-2011, Alexéy Sudáchen, alexey@sudachen.name 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_B16E23B4_712C_4444_9C55_D12A063F3395 #define C_once_B16E23B4_712C_4444_9C55_D12A063F3395 #ifdef _LIBYOYO #define _YO_STDF_BUILTIN #endif #include "yoyo.hc" #include "file.hc" enum { YO_STDF_PUMP_BUFFER = 1*KILOBYTE, YO_STDF_PUMP_BUFFER_W = YO_STDF_PUMP_BUFFER-1, }; int Stdf_Read_In(FILE *stdf,char *buf, int L) #ifdef _YO_STDF_BUILTIN { int i; for ( i = 0; i < L; ) { int q = fread(buf+i,1,L-i,stdf); if ( q ) i += q; else if ( feof(stdf) ) break; else { int err = ferror(stdf); if ( err == EAGAIN ) continue; __Raise_Format(YO_ERROR_IO,(__yoTa("failed to read: %s",0),strerror(err))); } } buf[i] = 0; return i; } #endif ; #define Stdf_Pump(stdf,buf) Stdf_Read_In(stdf,buf,YO_STDF_PUMP_BUFFER_W) char *Stdf_Pump_Part(FILE *stdf, char *buf, char *S, int *L) #ifdef _YO_STDF_BUILTIN { int l = *L; if ( !S ) S = buf+l; l -= ( S-buf); if ( l ) memmove(buf,S,l); l += Stdf_Read_In(stdf,buf+l,YO_STDF_PUMP_BUFFER_W-l); *L = l; STRICT_REQUIRE(l <= YO_STDF_PUMP_BUFFER_W); buf[l] = 0; return buf; } #endif ; #define Stdout_Put(S) if (!S); else fputs(S,stdout) #define Stdin_Pump(B) Stdf_Pump(stdin,B) #define Stdin_Pump_Part(B,S,L) Stdf_Pump_Part(stdin,B,S,L) /* returns -1 if error and read bytes count on success */ typedef int Unknown_Write_Proc(void *buf, longptr_t f, int count, int *err); int Stdf_Write(void *buf, longptr_t f, int count, int *err) #ifdef _YO_STDF_BUILTIN { int q = fwrite(buf,1,count,(FILE*)f); if ( !q ) { *err = ferror((FILE*)f); q = -1; } return q; } #endif ; int Fdf_Write(void *buf, longptr_t f, int count, int *err) #ifdef _YO_STDF_BUILTIN { int q = write((int)f,buf,count); if ( q < 0 ) q = errno; return q; } #endif ; int Bf_Write(void *buf, longptr_t f, int count, int *err) #ifdef _YO_STDF_BUILTIN { Buffer_Append((YO_BUFFER*)f,buf,count); return count; } #endif ; int Cf_Write(void *buf, longptr_t f, int count, int *err) #ifdef _YO_STDF_BUILTIN { return Stdf_Write(buf,(longptr_t)((YO_CFILE*)f)->fd,count,err); } #endif ; int Unknown_Write(longptr_t f, void *bf, int count, Unknown_Write_Proc xwrite) #ifdef _YO_STDF_BUILTIN { int i; for ( i = 0; i < count; ) { int err = 0; int r = xwrite((char*)bf+i,f,count-i,&err); if ( r > 0 ) i += r; else if ( err != EAGAIN ) __Raise_Format(YO_ERROR_IO,(__yoTa("failed to write: %s",0),strerror(err))); } return i; } #endif ; #endif /* C_once_B16E23B4_712C_4444_9C55_D12A063F3395 */ |
Added tesuite.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 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 | /* 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_22EC0578_5C71_4FE1_9C29_1EE80DFD34A5 #define C_once_22EC0578_5C71_4FE1_9C29_1EE80DFD34A5 #include "yoyo.hc" #include "datetime.hc" #include "newdes96.hc" #include "string.hc" #ifdef _LIBYOYO # define _YO_TESUITE_BUILTIN #endif #ifdef _YO_TESUITE_BUILTIN int Tesuite_Case_Log = -1; quad_t Tesuite_Id = 0; quad_t Tesuite_Case_Id = 0; quad_t Tesuite_Subcase_Id = 0; char Tesuite_Sid[15] = {0}; char Tesuite_Case_Sid[15] = {0}; char Tesuite_Subcase_Sid[15] = {0}; YO_NEWDES96 Tesuite_Nds96 = {0}; #endif quad_t Tesuite_Case_Cid() { quad_t val = Get_System_Useconds(); val = (val << 16) | (getpid()&0x0ffff); return val; } void Tesuite_Case_Value(quad_t val, quad_t *case_id, char case_sid[15]) #ifdef _YO_TESUITE_BUILTIN { *case_id = val; memset(case_sid,0,sizeof(case_sid)); NEWDES96_Encrypt8(&Tesuite_Nds96,&val); Str_Xbit_Encode(&val,8*8,5,Str_5bit_Encoding_Table_Upper,case_sid); } #endif ; void Tesuite_Init() #ifdef _YO_TESUITE_BUILTIN { static char key[15] = "\xCC\xF8\x06\x43\xD3\x49\x4B\xB9\x89\xD7\xC8\x1E\x6A\xE4\x36"; char *suite_file_path; char *suite_case; __Auto_Release { int flags = O_APPEND|O_CREAT|O_WRONLY; NEWDES96_Init_Static(&Tesuite_Nds96, key, 15); suite_file_path = getenv("TESUITE_FILE_PATH"); if ( !suite_file_path ) { flags |= O_TRUNC; suite_file_path = Path_Join( Path_Join(Prog_Directory(),".tesuite"), Str_Concat(Path_Basename(Prog_Fullname()),".txt"));; } Create_Required_Dirs(suite_file_path); Tesuite_Case_Log = open(suite_file_path,flags,0640); if ( Tesuite_Case_Log < 0 ) __Raise_Format(YO_FATAL_ERROR,("failed to open .tesuite log",strerror(errno))); putenv(__Format("TESUITE_FILE_PATH=%s",suite_file_path)); suite_case = getenv("TESUITE_CASE"); if ( suite_case ) { quad_t q = *(quad_t*)Str_Hex_Decode(suite_case,0); Tesuite_Case_Value(q,&Tesuite_Id,Tesuite_Sid); } else { Tesuite_Id = 0; } } } #endif ; void Tesuite_Info(char *text) #ifdef _YO_TESUITE_BUILTIN { char format[4096]; int L = snprintf(format,sizeof(format),"\n[%s] INFO %s",Tesuite_Subcase_Sid,text); write(Tesuite_Case_Log,format,L); } #endif ; void Tesuite_Case(char *text) #ifdef _YO_TESUITE_BUILTIN { quad_t cid; char format[4096]; int L; Sleep(1); cid = Tesuite_Case_Cid(); Tesuite_Case_Value(cid,&Tesuite_Subcase_Id,Tesuite_Subcase_Sid); L = snprintf(format,sizeof(format),"\n[%s] SUBCASE [%s] %s",Tesuite_Subcase_Sid,Tesuite_Case_Sid,text); write(Tesuite_Case_Log,format,L); } #endif ; void Tesuite_Case_Successed() #ifdef _YO_TESUITE_BUILTIN { char format[128]; int L = snprintf(format,sizeof(format),"\n[%s] OK",Tesuite_Subcase_Sid); write(Tesuite_Case_Log,format,L); } #endif ; void Tesuite_Case_Fail(char *text) #ifdef _YO_TESUITE_BUILTIN { char format[4096]; int L = snprintf(format,sizeof(format),"\n[%s] FAIL %s",Tesuite_Subcase_Sid,text); write(Tesuite_Case_Log,format,L); } #endif ; void Tesuite_Case_Open() #ifdef _YO_TESUITE_BUILTIN { char format[128]; int L; quad_t cid = Tesuite_Case_Cid(); Tesuite_Case_Value(cid,&Tesuite_Subcase_Id,Tesuite_Subcase_Sid); if ( !Tesuite_Id ) { Tesuite_Case_Value(cid,&Tesuite_Case_Id,Tesuite_Case_Sid); L = snprintf(format,sizeof(format),"\n[%s] OPEN",Tesuite_Case_Sid); write(Tesuite_Case_Log,format,L); putenv(__Format("TESUITE_CASE=%s",Str_Hex_Encode(&cid,8))); } else { Tesuite_Case_Id = Tesuite_Id; memcpy(Tesuite_Case_Sid,Tesuite_Sid,sizeof(Tesuite_Sid)); } } #endif ; void Tesuite_Case_Close() #ifdef _YO_TESUITE_BUILTIN { if ( !Tesuite_Id ) { char format[128]; int L = snprintf(format,sizeof(format),"\n[%s] CLOSE",Tesuite_Case_Sid); write(Tesuite_Case_Log,format,L); } Tesuite_Case_Value(0,&Tesuite_Case_Id,Tesuite_Case_Sid); Tesuite_Case_Value(0,&Tesuite_Subcase_Id,Tesuite_Subcase_Sid); } #endif ; void Tesuite_Exception_Occured() #ifdef _YO_TESUITE_BUILTIN { Tesuite_Case_Fail(__Format_Error()); Tesuite_Case_Close(); } #endif ; #define Tesuite_Perform(expr) \ __Auto_Release __Try_Except {\ Tesuite_Case_Open();\ expr;\ Tesuite_Case_Close();\ }__Except{ Tesuite_Exception_Occured(); } #endif /* C_once_22EC0578_5C71_4FE1_9C29_1EE80DFD34A5 */ |