58 |
/* ------------------------------------------------------------- Definitions */ |
/* ------------------------------------------------------------- Definitions */ |
59 |
|
|
60 |
#define TYPE_LOCAL 0 |
#define TYPE_LOCAL 0 |
61 |
#define TYPE_ACCEPT 1 |
#define TYPE_ACCEPT 1 |
62 |
#define RBUFFER_SIZE 1024 |
#define RBUFFER_SIZE 1024 |
63 |
|
|
64 |
struct Socket_T { |
struct Socket_T { |
312 |
} |
} |
313 |
|
|
314 |
|
|
315 |
/* -------------------------------------------------------------- Properties */ |
/* ------------------------------------------------------------ Properties */ |
316 |
|
|
317 |
|
|
318 |
/** |
/** |
413 |
} |
} |
414 |
|
|
415 |
|
|
416 |
/* ------------------------------------------------------------------ Public */ |
/* ---------------------------------------------------------------- Public */ |
417 |
|
|
418 |
|
|
419 |
/** |
/** |
489 |
* @param S A Socket_T object |
* @param S A Socket_T object |
490 |
* @return The byte read, or -1 if the end of the stream has been reached |
* @return The byte read, or -1 if the end of the stream has been reached |
491 |
*/ |
*/ |
492 |
int Socket_readByte(Socket_T S) { |
int socket_read_byte(Socket_T S) { |
493 |
|
|
494 |
ASSERT(S); |
ASSERT(S); |
495 |
|
|
513 |
int socket_read(Socket_T S, void *b, int size) { |
int socket_read(Socket_T S, void *b, int size) { |
514 |
|
|
515 |
int c; |
int c; |
516 |
unsigned char *p= (unsigned char*)b; |
unsigned char *p= b; |
517 |
|
|
518 |
ASSERT(S); |
ASSERT(S); |
519 |
|
|
520 |
while((size-- > 0) && ((c= Socket_readByte(S)) >= 0)) { |
while((size-- > 0) && ((c= socket_read_byte(S)) >= 0)) { |
521 |
*p++= c; |
*p++= c; |
522 |
} |
} |
523 |
|
|
543 |
|
|
544 |
ASSERT(S); |
ASSERT(S); |
545 |
|
|
546 |
while(--size && ((*s= Socket_readByte(S)) > 0)) { |
while(--size && ((*s= socket_read_byte(S)) > 0)) { |
547 |
if(*s++ == 10) |
if(*s++ == 10) |
548 |
break; |
break; |
549 |
} |
} |
572 |
} |
} |
573 |
|
|
574 |
|
|
575 |
/* ----------------------------------------------------------------- Private */ |
/* --------------------------------------------------------------- Private */ |
576 |
|
|
577 |
|
|
578 |
/* |
/* |