summaryrefslogtreecommitdiffstats
path: root/private/crt32/stdio/sscanf.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/sscanf.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/sscanf.c')
-rw-r--r--private/crt32/stdio/sscanf.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/private/crt32/stdio/sscanf.c b/private/crt32/stdio/sscanf.c
new file mode 100644
index 000000000..218a0246c
--- /dev/null
+++ b/private/crt32/stdio/sscanf.c
@@ -0,0 +1,95 @@
+/***
+*sscanf.c - read formatted data from string
+*
+* Copyright (c) 1985-1991, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* defines scanf() - reads formatted data from string
+*
+*Revision History:
+* 09-02-83 RN initial version
+* 04-13-87 JCR added const to declaration
+* 06-24-87 JCR (1) Made declaration conform to ANSI prototype and use
+* the va_ macros; (2) removed SS_NE_DS conditionals.
+* 12-11-87 JCR Added "_LOAD_DS" to declaration
+* 06-13-88 JCR Fake _iob entry is now static so that other routines can
+* assume _iob entries are in DGROUP.
+* 06-06-89 JCR 386 mthread support -- threads share one locked iob.
+* 08-18-89 GJF Clean up, now specific to OS/2 2.0 (i.e., 386 flat
+* model). Also fixed indents.
+* 02-16-90 GJF Fixed copyright
+* 03-19-90 GJF Made calling type _CALLTYPE2, added #include
+* <cruntime.h> and removed #include <register.h>.
+* 03-26-90 GJF Added #include <string.h>.
+* 07-23-90 SBM Replaced <assertm.h> by <assert.h>
+* 10-03-90 GJF New-style function declarator.
+* 02-18-93 SRW Make FILE a local and remove lock usage.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <stdio.h>
+#include <assert.h>
+#include <stdarg.h>
+#include <string.h>
+#include <internal.h>
+#include <os2dll.h>
+
+/***
+*int sscanf(string, format, ...) - read formatted data from string
+*
+*Purpose:
+* Reads formatted data from string into arguments. _input 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:
+* char *string - string to read data from
+* char *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 sscanf (
+ REG2 const char *string,
+ const char *format,
+ ...
+ )
+/*
+ * 'S'tring 'SCAN', 'F'ormatted
+ */
+{
+ 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 = strlen(string);
+
+ retval = (_input(infile,format,arglist));
+
+ return(retval);
+}