Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
2.5 KiB

  1. /***
  2. *fscanf.c - read formatted data from stream
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines fscanf() - reads formatted data from stream
  8. *
  9. *Revision History:
  10. * 09-02-83 RN initial version
  11. * 04-13-87 JCR added const to declaration
  12. * 06-24-87 JCR (1) Made declaration conform to ANSI prototype and use
  13. * the va_ macros; (2) removed SS_NE_DS conditionals.
  14. * 11-06-87 JCR Multi-thread support
  15. * 12-11-87 JCR Added "_LOAD_DS" to declaration
  16. * 05-31-88 PHG Merged DLL and normal versions
  17. * 02-15-90 GJF Fixed copyright and indents
  18. * 03-19-90 GJF Replaced _LOAD_DS with _CALLTYPE2 and added #include
  19. * <cruntime.h>.
  20. * 03-26-90 GJF Added #include <internal.h>.
  21. * 07-23-90 SBM Replaced <assertm.h> by <assert.h>
  22. * 10-02-90 GJF New-style function declarator.
  23. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  24. * 09-06-94 CFW Replace MTHREAD with _MT.
  25. * 02-06-94 CFW assert -> _ASSERTE.
  26. * 03-07-95 GJF _[un]lock_str macros now take FILE * arg.
  27. * 03-02-98 GJF Exception-safe locking.
  28. *
  29. *******************************************************************************/
  30. #include <cruntime.h>
  31. #include <stdio.h>
  32. #include <dbgint.h>
  33. #include <stdarg.h>
  34. #include <file2.h>
  35. #include <internal.h>
  36. #include <mtdll.h>
  37. /***
  38. *int fscanf(stream, format, ...) - read formatted data from stream
  39. *
  40. *Purpose:
  41. * Reads formatted data from stream into arguments. _input does the real
  42. * work here.
  43. *
  44. *Entry:
  45. * FILE *stream - stream to read data from
  46. * char *format - format string
  47. * followed by list of pointers to storage for the data read. The number
  48. * and type are controlled by the format string.
  49. *
  50. *Exit:
  51. * returns number of fields read and assigned
  52. *
  53. *Exceptions:
  54. *
  55. *******************************************************************************/
  56. int __cdecl fscanf (
  57. FILE *stream,
  58. const char *format,
  59. ...
  60. )
  61. /*
  62. * 'F'ile (stream) 'SCAN', 'F'ormatted
  63. */
  64. {
  65. int retval;
  66. va_list arglist;
  67. va_start(arglist, format);
  68. _ASSERTE(stream != NULL);
  69. _ASSERTE(format != NULL);
  70. #ifdef _MT
  71. _lock_str(stream);
  72. __try {
  73. #endif
  74. retval = (_input(stream,format,arglist));
  75. #ifdef _MT
  76. }
  77. __finally {
  78. _unlock_str(stream);
  79. }
  80. #endif
  81. return(retval);
  82. }