Unnamed Fossil Project

Check-in [922d82ae97]
Login

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:922d82ae97eb6292ae6e741e0a871900f308b7e1
User & Date: alexey@sudachen.name 2012-04-04 10:37:52
Context
2012-04-28
19:50
'httpd/httpx/sar' check-in: cc61bb1107 user: alexey@sudachen.name tags: trunk
2012-04-04
10:37
'updated' check-in: 922d82ae97 user: alexey@sudachen.name tags: trunk
2012-03-25
21:39
updated check-in: c84f04fc57 user: alexey@sudachen.name tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to asio.hc.

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
...
208
209
210
211
212
213
214




























215
216
217
218
219
220
221
...
224
225
226
227
228
229
230
231
232
233
234


235
236
237
238
239
240
241
...
245
246
247
248
249
250
251














252
253
254
255
256
257
258
...
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
...
425
426
427
428
429
430
431


432
433
434
435
436
437
438
  typedef int socket_t;
#endif

enum  
  {
    ASIO_COMPLETED    = 0x00000001,
    ASIO_CLOSED       = 0x00000002,
    ASIO_SYNCHRONOUS = 0x00200000,
    ASIO_TIMER        = 0x00100000,
    ASIO_FAILED       = 0x8e000000,
    ASIO_INTERRAPTED  = 0x8f000000,
    ASIO_PENGING      = 0,
    ASIO_CONTINUE     = 0,
    ASIO_INTERRUPT    = 1,
  
    ASIO_ST_SEND      = 1,
    ASIO_ST_RECV      = 2,
    ASIO_ST_NOTIFY    = 3,
................................................................................
    ASIO_ST_ACCEPT    = 4,
    
    ASIO_MAP_BASE     = 101,
  };
  
#define ASIO_SUCCEEDED(State) (!((State)&0xff000000))

typedef int (*asio_recv_callback_t)(void *obj,int status,int count);
typedef int (*asio_send_callback_t)(void *obj,int status);
typedef int (*asio_accept_callback_t)(void *obj,int status,socket_t fd,struct sockaddr *addr);
typedef int (*asio_notify_callback_t)(void *obj,int status);
typedef void (*asio_any_callback_t)(void *obj,int status,...);

typedef struct _YOYO_ASIO_STATE
  {
    socket_t fd;
    longptr_t accum;
    int fdsno,count,mincount;
    struct sockaddr addr;
    void *obj, *dta;
    asio_any_callback_t cbk;
    int (*perform)(struct _YOYO_ASIO_STATE *st);
    struct _YOYO_ASIO_STATE *next;
  } YOYO_ASIO_STATE;

#ifdef _YOYO_ASIO_BUILTIN
static int Asio_St_Count = 0;
static YOYO_ASIO_STATE *Asio_St_Map[ASIO_MAP_BASE] = {0};
static YOYO_ASIO_STATE *Asio_St_Pool = 0;

static int Asio_Is_Init = 0;
#endif
  ;
  
YOYO_ASIO_STATE **Asio_Map_Fd(socket_t fd)
#ifdef _YOYO_ASIO_BUILTIN
  {
................................................................................
      return Asio_Status_Repeat_Or_Die();
    st->accum += e;
    return (int)st->accum >= st->mincount ? ASIO_COMPLETED : ASIO_PENGING;  
  }
#endif
  ;
  




























void Asio_Perform_Interrupt()
#ifdef _YOYO_ASIO_BUILTIN
  {
    int i;
    for ( i = 0; i < ASIO_MAP_BASE; ++i )
      {
        YOYO_ASIO_STATE **pst = &Asio_St_Map[i];
................................................................................
            __Auto_Release
              {
                YOYO_ASIO_STATE st = **pst;
                void *obj = __Pool_Ptr(st.obj,Yo_Unrefe);
                Asio_Release_State(pst);
                
                if ( st.cbk ) 
                  st.cbk(obj,ASIO_INTERRAPTED,st.accum,&st.addr);
              }
          }
      }


  }
#endif
  ;
  
void Asio_At_Exit(void)
#ifdef _YOYO_ASIO_BUILTIN
  {
................................................................................
        YOYO_ASIO_STATE * st = Asio_St_Pool;
        Asio_St_Pool = st->next;
        free(st);
      }
  }
#endif
  ;














  
YOYO_ASIO_STATE *Asio_Alloc_State(socket_t fd, int tag)
#ifdef _YOYO_ASIO_BUILTIN
  {
    YOYO_ASIO_STATE *st;
    YOYO_ASIO_STATE **pst = Asio_Map_Fd(fd);
    
................................................................................
              {
                pst = Asio_Map_Fd(fd);
                if ( *pst )
                  {
                    YOYO_ASIO_STATE st = **pst;
                    __Pool_Ptr(st.obj,Yo_Unrefe);
                    Asio_Release_State(pst);
                    if ( st.cbk ) st.cbk(st.obj,status,st.accum,&st.addr);
                  }
              } 
          }
      } 
  }
#endif
  ;
................................................................................
      }
    
    i = select(Yo_MIN(FD_SETSIZE,Asio_St_Count),&fds[0],&fds[1],&fds[2],&timeout);

    if ( i < 0 )
      __Raise_Format(YOYO_ERROR_IO,(__yoTa("ASIO select failed: %s",0),Format_Network_Error()));



    for ( i = 2; i >= 0; --i )
      for ( j = 0; j < (int)fds[i].fd_count; ++j )
        {
          Asio_Complete(fds[i].fd_array[j],i==2?ASIO_FAILED:0);
          if ( maxms && ( maxms < (System_Millis() - start) ) )
            goto l;
        }







|


|







 







|

|

|




|












>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|



>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







 







>
>







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
...
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
...
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
...
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
...
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
...
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
  typedef int socket_t;
#endif

enum  
  {
    ASIO_COMPLETED    = 0x00000001,
    ASIO_CLOSED       = 0x00000002,
    ASIO_SYNCHRONOUS  = 0x00200000,
    ASIO_TIMER        = 0x00100000,
    ASIO_FAILED       = 0x8e000000,
    ASIO_INTERRUPTED  = 0x8f000000,
    ASIO_PENGING      = 0,
    ASIO_CONTINUE     = 0,
    ASIO_INTERRUPT    = 1,
  
    ASIO_ST_SEND      = 1,
    ASIO_ST_RECV      = 2,
    ASIO_ST_NOTIFY    = 3,
................................................................................
    ASIO_ST_ACCEPT    = 4,
    
    ASIO_MAP_BASE     = 101,
  };
  
#define ASIO_SUCCEEDED(State) (!((State)&0xff000000))

typedef int (*asio_recv_callback_t)(void *obj,int status, int count);
typedef int (*asio_send_callback_t)(void *obj,int status);
typedef int (*asio_accept_callback_t)(void *obj,int status, int _, longptr_t fd, struct sockaddr *addr);
typedef int (*asio_notify_callback_t)(void *obj,int status);
typedef void (*asio_any_callback_t)(void *obj, int status, int count, longptr_t fd, void *info);

typedef struct _YOYO_ASIO_STATE
  {
    socket_t fd;
    uquad_t accum;
    int fdsno,count,mincount;
    struct sockaddr addr;
    void *obj, *dta;
    asio_any_callback_t cbk;
    int (*perform)(struct _YOYO_ASIO_STATE *st);
    struct _YOYO_ASIO_STATE *next;
  } YOYO_ASIO_STATE;

#ifdef _YOYO_ASIO_BUILTIN
static int Asio_St_Count = 0;
static YOYO_ASIO_STATE *Asio_St_Map[ASIO_MAP_BASE] = {0};
static YOYO_ASIO_STATE *Asio_St_Pool = 0;
static YOYO_ASIO_STATE *Asio_St_Alert = 0;
static int Asio_Is_Init = 0;
#endif
  ;
  
YOYO_ASIO_STATE **Asio_Map_Fd(socket_t fd)
#ifdef _YOYO_ASIO_BUILTIN
  {
................................................................................
      return Asio_Status_Repeat_Or_Die();
    st->accum += e;
    return (int)st->accum >= st->mincount ? ASIO_COMPLETED : ASIO_PENGING;  
  }
#endif
  ;
  
void Asio_Perform_Alert(int status)
#ifdef _YOYO_ASIO_BUILTIN
  {
    YOYO_ASIO_STATE *lst = Asio_St_Alert;
    quad_t curms = Get_System_Millis();
    Asio_St_Alert = 0;
    
    while ( lst )
      {
        YOYO_ASIO_STATE *st = lst;
        lst = lst->next;
        if ( st->accum > curms && status == ASIO_TIMER )
          {
            st->next = Asio_St_Alert;
            Asio_St_Alert = st; 
          }
        else __Auto_Release 
          {
            YOYO_ASIO_STATE xst = *st;
            __Pool_Ptr(xst.obj,Yo_Unrefe);
            Asio_Release_State(&st);
            if ( xst.cbk ) xst.cbk(xst.obj,status,0,0,0);
          }
      }
  }
#endif
  ;
    
void Asio_Perform_Interrupt()
#ifdef _YOYO_ASIO_BUILTIN
  {
    int i;
    for ( i = 0; i < ASIO_MAP_BASE; ++i )
      {
        YOYO_ASIO_STATE **pst = &Asio_St_Map[i];
................................................................................
            __Auto_Release
              {
                YOYO_ASIO_STATE st = **pst;
                void *obj = __Pool_Ptr(st.obj,Yo_Unrefe);
                Asio_Release_State(pst);
                
                if ( st.cbk ) 
                  st.cbk(obj,ASIO_INTERRUPTED,0,0,0);
              }
          }
      }
      
    Asio_Perform_Alert(ASIO_INTERRUPTED);
  }
#endif
  ;
  
void Asio_At_Exit(void)
#ifdef _YOYO_ASIO_BUILTIN
  {
................................................................................
        YOYO_ASIO_STATE * st = Asio_St_Pool;
        Asio_St_Pool = st->next;
        free(st);
      }
  }
#endif
  ;

void Asio_Alert(int timeout, void *obj, void (*callback)(void *obj, int status))
#ifdef _YOYO_ASIO_BUILTIN
  {
    YOYO_ASIO_STATE *st = Asio_Pool_Get_State();
    st->obj = __Refe(obj);
    st->cbk = (asio_any_callback_t)callback;
    st->next = Asio_St_Alert;
    st->accum = Get_System_Millis() + timeout;
    Asio_St_Alert = st;
    ++Asio_St_Count;
  }
#endif
  ;  
  
YOYO_ASIO_STATE *Asio_Alloc_State(socket_t fd, int tag)
#ifdef _YOYO_ASIO_BUILTIN
  {
    YOYO_ASIO_STATE *st;
    YOYO_ASIO_STATE **pst = Asio_Map_Fd(fd);
    
................................................................................
              {
                pst = Asio_Map_Fd(fd);
                if ( *pst )
                  {
                    YOYO_ASIO_STATE st = **pst;
                    __Pool_Ptr(st.obj,Yo_Unrefe);
                    Asio_Release_State(pst);
                    if ( st.cbk ) st.cbk(st.obj,status,st.accum,st.accum,&st.addr);
                  }
              } 
          }
      } 
  }
#endif
  ;
................................................................................
      }
    
    i = select(Yo_MIN(FD_SETSIZE,Asio_St_Count),&fds[0],&fds[1],&fds[2],&timeout);

    if ( i < 0 )
      __Raise_Format(YOYO_ERROR_IO,(__yoTa("ASIO select failed: %s",0),Format_Network_Error()));

    Asio_Perform_Alert(ASIO_TIMER);
    
    for ( i = 2; i >= 0; --i )
      for ( j = 0; j < (int)fds[i].fd_count; ++j )
        {
          Asio_Complete(fds[i].fd_array[j],i==2?ASIO_FAILED:0);
          if ( maxms && ( maxms < (System_Millis() - start) ) )
            goto l;
        }

Changes to buffer.hc.

428
429
430
431
432
433
434













435
436
437
438
439
440
441
    if ( count )
      Buffer_Resize(bf,count);
    return bf;
  }
#endif
  ;
  













void *Buffer_Zero(int count)
#ifdef _YOYO_BUFFER_BUILTIN
  {
    YOYO_BUFFER *bf = Buffer_Init(count);
    if ( bf->count ) 
      memset(bf->at,0,bf->count);
    return bf;







>
>
>
>
>
>
>
>
>
>
>
>
>







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
    if ( count )
      Buffer_Resize(bf,count);
    return bf;
  }
#endif
  ;
  
void *Buffer_Acquire(char *S)
#ifdef _YOYO_BUFFER_BUILTIN
  {
    YOYO_BUFFER *bf = Yo_Object_Dtor(sizeof(YOYO_BUFFER),Buffer_Destruct);
    int L = strlen(S);
    bf->at = S;
    bf->count = L;
    bf->capacity = L;
    return bf;
  }
#endif
  ;

void *Buffer_Zero(int count)
#ifdef _YOYO_BUFFER_BUILTIN
  {
    YOYO_BUFFER *bf = Buffer_Init(count);
    if ( bf->count ) 
      memset(bf->at,0,bf->count);
    return bf;

Changes to file.hc.

1312
1313
1314
1315
1316
1317
1318











1319
1320
1321
1322
1323
1324
1325
....
1649
1650
1651
1652
1653
1654
1655







1656
1657
1658
1659
1660
1661
1662
....
1664
1665
1666
1667
1668
1669
1670

1671
1672
1673
1674
1675
1676
1677
....
1708
1709
1710
1711
1712
1713
1714

1715
1716
1717
1718
1719
1720
1721
    return f;
  }
#endif
  ;

#define Cfile_Acquire(Name,Fd) Cfile_Object(Fd,Name,0)
#define Cfile_Share(Name,Fd)   Cfile_Object(Fd,Name,1)












int Oj_Write_BOM(void *f,int bom)
#ifdef _YOYO_FILE_BUILTIN
  {
    switch( bom )
      {
        case YOYO_BOM_DOESNT_PRESENT:
................................................................................
quad_t Buffer_File_Tell(YOYO_BUFFER_FILE *f)
#ifdef _YOYO_FILE_BUILTIN
  {
    return f->offs;
  }
#endif
  ;








void *Buffer_As_File(YOYO_BUFFER *bf)
#ifdef _YOYO_FILE_BUILTIN
  {
    static YOYO_FUNCTABLE funcs[] = 
      { {0},
        {Oj_Destruct_OjMID,    YOYO_BUFFER_FILE_Destruct},
................................................................................
        {Oj_Read_OjMID,        Buffer_File_Read},
        {Oj_Write_OjMID,       Buffer_File_Write},
        {Oj_Available_OjMID,   Buffer_File_Available},
        {Oj_Eof_OjMID,         Buffer_File_Eof},
        {Oj_Length_OjMID,      Buffer_File_Length},
        {Oj_Seek_OjMID,        Buffer_File_Seek},
        {Oj_Tell_OjMID,        Buffer_File_Tell},

        {0}
      };
    YOYO_BUFFER_FILE *file = __Object(sizeof(YOYO_BUFFER_FILE),funcs);
    file->bf = __Refe(bf);
    return file;
  }
#endif
................................................................................
        {Oj_Read_OjMID,        Buffer_File_Read},
        {Oj_Write_OjMID,       Memory_File_Write},
        {Oj_Available_OjMID,   Buffer_File_Available},
        {Oj_Eof_OjMID,         Buffer_File_Eof},
        {Oj_Length_OjMID,      Buffer_File_Length},
        {Oj_Seek_OjMID,        Buffer_File_Seek},
        {Oj_Tell_OjMID,        Buffer_File_Tell},

        {0}
      };
      
    YOYO_BUFFER_FILE *file = __Object(sizeof(YOYO_BUFFER_FILE),funcs);
    file->bf = __Zero_Malloc_Npl(sizeof(YOYO_BUFFER));
    file->bf->at = mem;
    file->bf->count = mem_len;







>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>







 







>







 







>







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
....
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
....
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
....
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
    return f;
  }
#endif
  ;

#define Cfile_Acquire(Name,Fd) Cfile_Object(Fd,Name,0)
#define Cfile_Share(Name,Fd)   Cfile_Object(Fd,Name,1)

void *Cfile_Temp()
#ifdef _YOYO_FILE_BUILTIN
  {
    FILE *f = tmpfile();
    if ( !f )
      File_Check_Error("open file",0,"tmpfile",1);
    return Cfile_Object(f,"tmpfile",0);
  }
#endif
  ;

int Oj_Write_BOM(void *f,int bom)
#ifdef _YOYO_FILE_BUILTIN
  {
    switch( bom )
      {
        case YOYO_BOM_DOESNT_PRESENT:
................................................................................
quad_t Buffer_File_Tell(YOYO_BUFFER_FILE *f)
#ifdef _YOYO_FILE_BUILTIN
  {
    return f->offs;
  }
#endif
  ;

void Buffer_File_Flush()
#ifdef _YOYO_FILE_BUILTIN
  {
  }
#endif
  ;

void *Buffer_As_File(YOYO_BUFFER *bf)
#ifdef _YOYO_FILE_BUILTIN
  {
    static YOYO_FUNCTABLE funcs[] = 
      { {0},
        {Oj_Destruct_OjMID,    YOYO_BUFFER_FILE_Destruct},
................................................................................
        {Oj_Read_OjMID,        Buffer_File_Read},
        {Oj_Write_OjMID,       Buffer_File_Write},
        {Oj_Available_OjMID,   Buffer_File_Available},
        {Oj_Eof_OjMID,         Buffer_File_Eof},
        {Oj_Length_OjMID,      Buffer_File_Length},
        {Oj_Seek_OjMID,        Buffer_File_Seek},
        {Oj_Tell_OjMID,        Buffer_File_Tell},
        {Oj_Flush_OjMID,       Buffer_File_Flush},
        {0}
      };
    YOYO_BUFFER_FILE *file = __Object(sizeof(YOYO_BUFFER_FILE),funcs);
    file->bf = __Refe(bf);
    return file;
  }
#endif
................................................................................
        {Oj_Read_OjMID,        Buffer_File_Read},
        {Oj_Write_OjMID,       Memory_File_Write},
        {Oj_Available_OjMID,   Buffer_File_Available},
        {Oj_Eof_OjMID,         Buffer_File_Eof},
        {Oj_Length_OjMID,      Buffer_File_Length},
        {Oj_Seek_OjMID,        Buffer_File_Seek},
        {Oj_Tell_OjMID,        Buffer_File_Tell},
        {Oj_Flush_OjMID,       Buffer_File_Flush},
        {0}
      };
      
    YOYO_BUFFER_FILE *file = __Object(sizeof(YOYO_BUFFER_FILE),funcs);
    file->bf = __Zero_Malloc_Npl(sizeof(YOYO_BUFFER));
    file->bf->at = mem;
    file->bf->count = mem_len;

Changes to string.hc.

120
121
122
123
124
125
126










127
128
129
130
131
132
133
  ;

int Str_Length(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    return S ? strlen(S) : 0;
  }










#endif
  ;

char Str_Last(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    int L = S ? strlen(S) : 0;







>
>
>
>
>
>
>
>
>
>







120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
  ;

int Str_Length(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    return S ? strlen(S) : 0;
  }
#endif
  ;

int Str_Is_Empty(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    if ( !S ) return 1;
    while ( *S && Isspace(*S) ) ++S;
    return !*S;
  }
#endif
  ;

char Str_Last(char *S)
#ifdef _YOYO_STRING_BUILTIN
  {
    int L = S ? strlen(S) : 0;

Changes to tcpip.hc.

415
416
417
418
419
420
421
422
423





424
425
426
427
428
429
430
431

432
433
434
435
436
437
438
  {
    YOYO_TCPSOK_ACCEPT *acbk = __Object_Dtor(sizeof(YOYO_TCPSOK_ACCEPT),YOYO_TCPSOK_ACCEPT_Destruct);
    acbk->callback = callback;
    acbk->obj = __Refe(obj);
    return acbk;
  }

int Cbk_Tcp_Asio_Accept(void *obj, int status, socket_t skt, struct sockaddr *_addr)
  {





    struct sockaddr_in *addr = ((struct sockaddr_in*)_addr);
    YOYO_TCPSOK *sok = Tcp_Socket( (status&ASIO_SYNCHRONOUS)?0:TCPSOK_ASYNC );
    sok->ip = addr->sin_addr.s_addr;
    sok->port = addr->sin_port;
    sok->skt = skt;
    if ( sok->async )
      Tcp_Set_Async(sok->skt);
    return ((YOYO_TCPSOK_ACCEPT*)obj)->callback(((YOYO_TCPSOK_ACCEPT*)obj)->obj,status,sok);

  }
#endif

int Tcp_Asio_Accept(YOYO_TCPSOK *sok, void *obj, tcp_accept_callback_t callback)
#ifdef _YOYO_TCPIP_BUILTIN
  {
    return Asio_Accept(sok->skt,Tcp_Accept_Callback(obj,callback),Cbk_Tcp_Asio_Accept);







|

>
>
>
>
>
|
|
|
|
|
|
|
|
>







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
  {
    YOYO_TCPSOK_ACCEPT *acbk = __Object_Dtor(sizeof(YOYO_TCPSOK_ACCEPT),YOYO_TCPSOK_ACCEPT_Destruct);
    acbk->callback = callback;
    acbk->obj = __Refe(obj);
    return acbk;
  }

int Cbk_Tcp_Asio_Accept(void *obj, int status, int _, longptr_t _skt, struct sockaddr *_addr)
  {
    socket_t skt = (socket_t)_skt;
    if ( status == ASIO_TIMER || !ASIO_SUCCEEDED(status) )
      return ((YOYO_TCPSOK_ACCEPT*)obj)->callback(((YOYO_TCPSOK_ACCEPT*)obj)->obj,status,0);
    else
      {
        struct sockaddr_in *addr = ((struct sockaddr_in*)_addr);
        YOYO_TCPSOK *sok = Tcp_Socket( (status&ASIO_SYNCHRONOUS)?0:TCPSOK_ASYNC );
        sok->ip = addr->sin_addr.s_addr;
        sok->port = addr->sin_port;
        sok->skt = skt;
        if ( sok->async )
          Tcp_Set_Async(sok->skt);
        return ((YOYO_TCPSOK_ACCEPT*)obj)->callback(((YOYO_TCPSOK_ACCEPT*)obj)->obj,status,sok);
      }
  }
#endif

int Tcp_Asio_Accept(YOYO_TCPSOK *sok, void *obj, tcp_accept_callback_t callback)
#ifdef _YOYO_TCPIP_BUILTIN
  {
    return Asio_Accept(sok->skt,Tcp_Accept_Callback(obj,callback),Cbk_Tcp_Asio_Accept);

Changes to yoyo.hc.

108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330

331
332
333
334
335
336
337
...
367
368
369
370
371
372
373

374
375
376
377
378
379
380
...
433
434
435
436
437
438
439









440
441
442
443
444
445
446
....
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
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <locale.h>

#if defined _WIN32 || defined _MSC_VER || defined __MINGW32_VERSION
# define __windoze
# if !defined __i386 && !defined __x86_64
#  ifdef _M_IX86
#   define __i386
#  elif defined _M_AMD64
#   define __x86_64
#  else
................................................................................
  };

enum _YOYO_ERRORS
  {
    YOYO_FATAL_ERROR_GROUP          = 0x70000000,
    YOYO_USER_ERROR_GROUP           = 0x00010000,
    YOYO_IO_ERROR_GROUP             = 0x00020000,
    YOYO_TCPIP_ERROR_GROUP          = 0x00040000,
    YOYO_RUNTIME_ERROR_GROUP        = 0x00080000,
    YOYO_SELFCHECK_ERROR_GROUP      = 0x00100000,
    YOYO_ENCODING_ERROR_GROUP       = 0x00200000,
    YOYO_ILLFORMED_ERROR_GROUP      = 0x00400000,
    YOYO_RANGE_ERROR_GROUP          = 0x00800000,
    YOYO_CORRUPTED_ERROR_GROUP      = 0x01000000,
    YOYO_STORAGE_ERROR_GROUP        = 0x02000000,


    YOYO_XXXX_ERROR_GROUP           = 0x7fff0000,
    YO_RERAISE_CURRENT_ERROR        = 0x7fff7fff,

    YOYO_TRACED_ERROR_GROUP     = YOYO_FATAL_ERROR_GROUP
                                |YOYO_RANGE_ERROR_GROUP
                                |YOYO_SELFCHECK_ERROR_GROUP,
................................................................................
    YOYO_ERROR_TO_BIG           = YOYO_STORAGE_ERROR_GROUP|(YOYO_ERROR_BASE+26),
    YOYO_ERROR_ZERODIVIDE       = YOYO_FATAL_ERROR_GROUP|(YOYO_ERROR_BASE+27),
    YOYO_ERROR_LIMIT_REACHED    = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+28),
    YOYO_ERROR_UNSUPPORTED      = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+29),
    YOYO_ERROR_IO_EOF           = YOYO_IO_ERROR_GROUP|(YOYO_ERROR_BASE+30),
    YOYO_ERROR_DNS              = YOYO_IO_ERROR_GROUP|(YOYO_ERROR_BASE+31),
    YOYO_ERROR_SUBSYSTEM_INIT   = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+32),

  };

#define YOYO_ERROR_IS_USER_ERROR(err) !(err&YOYO_XXXX_ERROR_GROUP)

enum _YOYO_FLAGS
  {
    YO_RAISE_ERROR            = 0x70000000,
................................................................................
void Yo_Xchg_Unlock_Proc(int volatile *p) _YOYO_CORE_BUILTIN_CODE({Yo_Atomic_CmpXchg(p,0,1);});

# define __Mtx_Sync(Mtx) \
              __Interlock_Opt(((void)0),Mtx, \
                  Yo_Wait_Mtx_Lock,Yo_Mtx_Unlock,Yo_Mtx_Unlock_Proc)

#endif










#define REQUIRE(Expr) \
  if (Expr); else Yo_Fatal(YOYO_ERROR_REQUIRE_FAILED,__Yo_Expr__(Expr),__Yo_FILE__,__LINE__)
#define PANICA(msg) Yo_Fatal(YOYO_FATAL_ERROR,msg,__Yo_FILE__,__LINE__)

#ifdef _STRICT
# define STRICT_REQUIRE(Expr) REQUIRE(Expr)
................................................................................
    if ( code & YOYO_FATAL_ERROR_GROUP )
      abort();
    Yo_Unwind_Scope(0,-1,0);
    exit(code);
  }
#endif
  ;



















#define __Pool(Ptr)                     Yo_Pool_Ptr(Ptr,0)
#define __Pool_Ptr(Ptr,Free)            Yo_Pool_Ptr(Ptr,Free)
#define __Release(Pooled)               Yo_Release(Pooled)
#define __Retain(Pooled)                Yo_Retain(Pooled)
#define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
#define __Refe(Ptr)                     Yo_Refe(Ptr)
#define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
#define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
#define __Raise_User_Error(Msg_)        Yo_Raise(YOYO_ERROR_USER,Msg_,__Yo_FILE__,__LINE__)
#define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)
#define __Raise_Occured()               Yo_Raise_Occured()

#define __Fatal(Ctx)                    Yo_Fatal(YOYO_FATAL_ERROR,Ctx,__Yo_FILE__,__LINE__)
#define __Fatal_Format(x)               Yo_Fatal(YOYO_FATAL_ERROR,Yo_Format_Npl x,__Yo_FILE__,__LINE__)
#define __Format                        Yo_Format
#define __Format_Npl                    Yo_Format_Npl
#define __Format_Error()                Yo_Error_Format()




#define __Malloc(Size)                  Yo_Malloc(Size)
#define __Malloc_Npl(Size)              Yo_Malloc_Npl(Size)
#define __Zero_Malloc(Size)             __Pool(Yo_Zero_Malloc_Npl(Size))
#define __Zero_Malloc_Npl(Size)         Yo_Zero_Malloc_Npl(Size)
#define __Memcopy(Ptr,Size)             Yo_Memcopy(Ptr,Size)
#define __Memcopy_Npl(Ptr,Size)         Yo_Memcopy_Npl(Ptr,Size)







|







 







|







>







 







>







 







>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>












>





>
>
>







108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
...
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
...
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
....
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
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <locale.h>

#if defined WIN32 || defined _WIN32 || defined _MSC_VER || defined __MINGW32_VERSION
# define __windoze
# if !defined __i386 && !defined __x86_64
#  ifdef _M_IX86
#   define __i386
#  elif defined _M_AMD64
#   define __x86_64
#  else
................................................................................
  };

enum _YOYO_ERRORS
  {
    YOYO_FATAL_ERROR_GROUP          = 0x70000000,
    YOYO_USER_ERROR_GROUP           = 0x00010000,
    YOYO_IO_ERROR_GROUP             = 0x00020000,
    //YOYO_TCPIP_ERROR_GROUP          = 0x00040000,
    YOYO_RUNTIME_ERROR_GROUP        = 0x00080000,
    YOYO_SELFCHECK_ERROR_GROUP      = 0x00100000,
    YOYO_ENCODING_ERROR_GROUP       = 0x00200000,
    YOYO_ILLFORMED_ERROR_GROUP      = 0x00400000,
    YOYO_RANGE_ERROR_GROUP          = 0x00800000,
    YOYO_CORRUPTED_ERROR_GROUP      = 0x01000000,
    YOYO_STORAGE_ERROR_GROUP        = 0x02000000,
    //YOYO_SYSTEM_ERROR_GROUP         = 0x04000000,

    YOYO_XXXX_ERROR_GROUP           = 0x7fff0000,
    YO_RERAISE_CURRENT_ERROR        = 0x7fff7fff,

    YOYO_TRACED_ERROR_GROUP     = YOYO_FATAL_ERROR_GROUP
                                |YOYO_RANGE_ERROR_GROUP
                                |YOYO_SELFCHECK_ERROR_GROUP,
................................................................................
    YOYO_ERROR_TO_BIG           = YOYO_STORAGE_ERROR_GROUP|(YOYO_ERROR_BASE+26),
    YOYO_ERROR_ZERODIVIDE       = YOYO_FATAL_ERROR_GROUP|(YOYO_ERROR_BASE+27),
    YOYO_ERROR_LIMIT_REACHED    = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+28),
    YOYO_ERROR_UNSUPPORTED      = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+29),
    YOYO_ERROR_IO_EOF           = YOYO_IO_ERROR_GROUP|(YOYO_ERROR_BASE+30),
    YOYO_ERROR_DNS              = YOYO_IO_ERROR_GROUP|(YOYO_ERROR_BASE+31),
    YOYO_ERROR_SUBSYSTEM_INIT   = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+32),
    YOYO_ERROR_SYSTEM           = YOYO_RUNTIME_ERROR_GROUP|(YOYO_ERROR_BASE+33),
  };

#define YOYO_ERROR_IS_USER_ERROR(err) !(err&YOYO_XXXX_ERROR_GROUP)

enum _YOYO_FLAGS
  {
    YO_RAISE_ERROR            = 0x70000000,
................................................................................
void Yo_Xchg_Unlock_Proc(int volatile *p) _YOYO_CORE_BUILTIN_CODE({Yo_Atomic_CmpXchg(p,0,1);});

# define __Mtx_Sync(Mtx) \
              __Interlock_Opt(((void)0),Mtx, \
                  Yo_Wait_Mtx_Lock,Yo_Mtx_Unlock,Yo_Mtx_Unlock_Proc)

#endif

#if defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__>=6) )
  #define __Static_Assert(expr,S) _Static_assert(expr,#S)
#elif !defined _MSC_VER || _MSC_VER < 1600 || defined __ICL
  #define __Static_Assert(expr,S) \
    extern char YOYO_LOCAL_ID(__##S##__)[(expr)?1:-1]
#else
  #define __Static_Assert(expr,S) static_assert(expr,#S)
#endif

#define REQUIRE(Expr) \
  if (Expr); else Yo_Fatal(YOYO_ERROR_REQUIRE_FAILED,__Yo_Expr__(Expr),__Yo_FILE__,__LINE__)
#define PANICA(msg) Yo_Fatal(YOYO_FATAL_ERROR,msg,__Yo_FILE__,__LINE__)

#ifdef _STRICT
# define STRICT_REQUIRE(Expr) REQUIRE(Expr)
................................................................................
    if ( code & YOYO_FATAL_ERROR_GROUP )
      abort();
    Yo_Unwind_Scope(0,-1,0);
    exit(code);
  }
#endif
  ;

char *Yo_Format_System_Error()
#ifdef _YOYO_CORE_BUILTIN
  {
  #ifdef __windoze
    int err = GetLastError();
    char *msg = Yo_Malloc(1024);
    FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS |
                  FORMAT_MESSAGE_MAX_WIDTH_MASK, NULL, err,
                  MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                  (LPSTR)msg, 1024,0);
    return msg;  
  #else
    return strerror(errno);
  #endif
  }
#endif
  ;

#define __Pool(Ptr)                     Yo_Pool_Ptr(Ptr,0)
#define __Pool_Ptr(Ptr,Free)            Yo_Pool_Ptr(Ptr,Free)
#define __Release(Pooled)               Yo_Release(Pooled)
#define __Retain(Pooled)                Yo_Retain(Pooled)
#define __Purge(TholdPtr)               Yo_Pool_Purge(TholdPtr,YOYO_DEFAULT_PURGE_CAP)
#define __Refe(Ptr)                     Yo_Refe(Ptr)
#define __Unrefe(Ptr)                   Yo_Unrefe(Ptr)
#define __Raise(Err,Msg)                Yo_Raise(Err,Msg,__Yo_FILE__,__LINE__)
#define __Raise_User_Error(Msg_)        Yo_Raise(YOYO_ERROR_USER,Msg_,__Yo_FILE__,__LINE__)
#define __Raise_Format(Err,Fmt)         Yo_Raise(Err,(Yo_Format Fmt),__Yo_FILE__,__LINE__)
#define __Raise_Occured()               Yo_Raise_Occured()
#define __Raise_System_Error()          Yo_Raise(YOYO_ERROR_SYSTEM,Yo_Format_System_Error(),__Yo_FILE__,__LINE__)
#define __Fatal(Ctx)                    Yo_Fatal(YOYO_FATAL_ERROR,Ctx,__Yo_FILE__,__LINE__)
#define __Fatal_Format(x)               Yo_Fatal(YOYO_FATAL_ERROR,Yo_Format_Npl x,__Yo_FILE__,__LINE__)
#define __Format                        Yo_Format
#define __Format_Npl                    Yo_Format_Npl
#define __Format_Error()                Yo_Error_Format()
#define __Format_Btrace()               Yo_Btrace()
#define __Format_Error_Btrace()         Yo_Error_Format_Btrace()
#define __Format_System_Error()         Yo_Format_System_Error()

#define __Malloc(Size)                  Yo_Malloc(Size)
#define __Malloc_Npl(Size)              Yo_Malloc_Npl(Size)
#define __Zero_Malloc(Size)             __Pool(Yo_Zero_Malloc_Npl(Size))
#define __Zero_Malloc_Npl(Size)         Yo_Zero_Malloc_Npl(Size)
#define __Memcopy(Ptr,Size)             Yo_Memcopy(Ptr,Size)
#define __Memcopy_Npl(Ptr,Size)         Yo_Memcopy_Npl(Ptr,Size)