Leaked source code of windows server 2003
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.

85 lines
2.0 KiB

  1. /***
  2. *wscanf.c - read formatted data from stdin
  3. *
  4. * Copyright (c) 1985-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * defines wscanf() - reads formatted data from stdin
  8. *
  9. *Revision History:
  10. * 05-16-92 KRS Created from scanf.c.
  11. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  12. * 02-07-94 CFW POSIXify.
  13. * 09-06-94 CFW Replace MTHREAD with _MT.
  14. * 02-06-94 CFW assert -> _ASSERTE.
  15. * 03-07-95 GJF Use _[un]lock_str2 instead of _[un]lock_str. Also,
  16. * removed useless local and macro.
  17. * 03-02-98 GJF Exception-safe locking.
  18. *
  19. *******************************************************************************/
  20. #ifndef _POSIX_
  21. #include <cruntime.h>
  22. #include <stdio.h>
  23. #include <wchar.h>
  24. #include <dbgint.h>
  25. #include <stdarg.h>
  26. #include <file2.h>
  27. #include <internal.h>
  28. #include <mtdll.h>
  29. /***
  30. *int wscanf(format, ...) - read formatted data from stdin
  31. *
  32. *Purpose:
  33. * Reads formatted data from stdin into arguments. _input does the real
  34. * work here.
  35. *
  36. *Entry:
  37. * char *format - format string
  38. * followed by list of pointers to storage for the data read. The number
  39. * and type are controlled by the format string.
  40. *
  41. *Exit:
  42. * returns number of fields read and assigned
  43. *
  44. *Exceptions:
  45. *
  46. *******************************************************************************/
  47. int __cdecl wscanf (
  48. const wchar_t *format,
  49. ...
  50. )
  51. /*
  52. * stdin 'W'char_t 'SCAN', 'F'ormatted
  53. */
  54. {
  55. int retval;
  56. va_list arglist;
  57. // UNDONE: make va_start work with wchar_t format string
  58. va_start(arglist, format);
  59. _ASSERTE(format != NULL);
  60. #ifdef _MT
  61. _lock_str2(0, stdin);
  62. __try {
  63. #endif
  64. retval = (_winput(stdin,format,arglist));
  65. #ifdef _MT
  66. }
  67. __finally {
  68. _unlock_str2(0, stdin);
  69. }
  70. #endif
  71. return(retval);
  72. }
  73. #endif /* _POSIX_ */