00001
00005
#include <stdio.h>
00006
#include <stdarg.h>
00007
#include <string.h>
00008
00009
#include "copyrigh.h"
00010
#include "wattcp.h"
00011
#include "misc.h"
00012
#include "pctcp.h"
00013
00014
#if defined(__WATCOMC__) && (__WATCOMC__ >= 1250)
00015
#define OPENWATCOM_15
00016
#endif
00017
00018
00019
00020
00021
00022
#if defined(WIN32) && !defined(__MINGW32__) && !defined(OPENWATCOM_15)
00023
static int vsscanf (
const char *buf,
const char *fmt, va_list arglist)
00024 {
00025 ARGSUSED (buf);
00026 ARGSUSED (fmt);
00027 ARGSUSED (arglist);
00028
return (0);
00029 }
00030
#elif defined(__DJGPP__) && (DJGPP_MINOR < 2)
00031
static int vsscanf (
const char *buf,
const char *fmt, va_list arglist)
00032 {
00033 FILE *fil = stdin;
00034 fil->_ptr = (
char*) buf;
00035
return _doscan (fil, fmt, arglist);
00036 }
00037
#elif defined(_MSC_VER) || defined(__DMC__)
00038
static int vsscanf (
const char *buf,
const char *fmt, va_list arglist)
00039 {
00040
extern _input (FILE*,
const char*, va_list);
00041 FILE *fil = stdin;
00042 fil->_ptr = (
char*) buf;
00043
return _input (fil, fmt, arglist);
00044 }
00045
#endif
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
int MS_CDECL sock_scanf (
sock_type *s,
const char *fmt, ...)
00057 {
00058
char buf [tcp_MaxBufSize];
00059
int fields = 0;
00060
int status, len;
00061
00062
while ((status =
sock_dataready(s)) == 0)
00063 {
00064
if (status == -1)
00065
return (-1);
00066
00067 len = sock_gets (s, (
BYTE*)buf,
sizeof(buf));
00068
if (len > 0)
00069 {
00070 va_list args;
00071 va_start (args, fmt);
00072 fields = vsscanf (buf, fmt, args);
00073 va_end (args);
00074
break;
00075 }
00076 }
00077
return (fields);
00078 }
00079