summaryrefslogtreecommitdiffstats
path: root/private/crt32/stdio/swscanf.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/stdio/swscanf.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/stdio/swscanf.c')
-rw-r--r--private/crt32/stdio/swscanf.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/private/crt32/stdio/swscanf.c b/private/crt32/stdio/swscanf.c
new file mode 100644
index 000000000..65d99a69e
--- /dev/null
+++ b/private/crt32/stdio/swscanf.c
@@ -0,0 +1,81 @@
+/***
+*swscanf.c - read formatted data from wide-character string
+*
+* Copyright (c) 1991-1992, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines _swscanf() - reads formatted data from wide-character string
+*
+*Revision History:
+* 11-21-91 ETC Created from sscanf.c
+# 05-16-92 KRS Revised for new ISO spec. format is wchar_t * now.
+* 02-18-93 SRW Make FILE a local and remove lock usage.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <stdio.h>
+#include <wchar.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+#include <internal.h>
+#include <os2dll.h>
+
+/***
+*int swscanf(string, format, ...) - read formatted data from wide-char string
+*
+*Purpose:
+* Same as sscanf (described below) from reads from a wide-char string.
+*
+* Reads formatted data from string into arguments. _winput does the real
+* work here. Sets up a FILE so file i/o operations can be used, makes
+* string look like a huge buffer to it, but _filbuf will refuse to refill
+* it if it is exhausted.
+*
+* Allocate the 'fake' _iob[] entryit statically instead of on
+* the stack so that other routines can assume that _iob[] entries are in
+* are in DGROUP and, thus, are near.
+*
+* Multi-thread: (1) Since there is no stream, this routine must never try
+* to get the stream lock (i.e., there is no stream lock either). (2)
+* Also, since there is only one staticly allocated 'fake' iob, we must
+* lock/unlock to prevent collisions.
+*
+*Entry:
+* wchar_t *string - wide-character string to read data from
+* wchar_t *format - format string
+* followed by list of pointers to storage for the data read. The number
+* and type are controlled by the format string.
+*
+*Exit:
+* returns number of fields read and assigned
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CALLTYPE2 swscanf (
+ REG2 const wchar_t *string,
+ const wchar_t *format,
+ ...
+ )
+{
+ va_list arglist;
+ FILE str;
+ REG1 FILE *infile = &str;
+ REG2 int retval;
+
+ va_start(arglist, format);
+
+ assert(string != NULL);
+ assert(format != NULL);
+
+ infile->_flag = _IOREAD|_IOSTRG|_IOMYBUF;
+ infile->_ptr = infile->_base = (char *) string;
+ infile->_cnt = wcslen(string)*sizeof(wchar_t);
+
+ retval = (_winput(infile,format,arglist));
+
+ return(retval);
+}