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.

88 lines
1.3 KiB

  1. /*++
  2. Copyright (c) 1991 Microsoft Corporation
  3. Module Name:
  4. dllext.c
  5. Abstract:
  6. Client implementation of C Language Extensions (Chapter 8 of 1003.1)
  7. Author:
  8. Ellen Aycock-Wright (ellena) 15-Oct-1991
  9. Revision History:
  10. --*/
  11. #include <stdio.h>
  12. #include <fcntl.h>
  13. #include "psxdll.h"
  14. extern FILE *_getstream(void);
  15. int
  16. __cdecl
  17. fileno(FILE *stream)
  18. {
  19. return(stream->_file);
  20. }
  21. #if 0
  22. FILE *
  23. fdopen(int fildes, const char *type)
  24. {
  25. FILE *stream;
  26. int mode;
  27. int streamflag = 0;
  28. //
  29. // XXX.mjb: we need fcntl to check modes and validity of fildes
  30. //
  31. if (NULL == (stream = _getstream())) {
  32. return NULL;
  33. }
  34. switch (*type) {
  35. case 'r':
  36. mode = O_RDONLY;
  37. streamflag |= _IOREAD;
  38. break;
  39. case 'w':
  40. mode = O_WRONLY;
  41. streamflag |= _IOWRT;
  42. break;
  43. case 'a':
  44. mode = O_WRONLY | O_APPEND;
  45. streamflag |= _IOWRT;
  46. // XXX.mjb: should be _IOWRT | _IOAPPEND;
  47. break;
  48. default:
  49. errno = EINVAL;
  50. return NULL;
  51. }
  52. switch (*++type) {
  53. case '\0':
  54. break;
  55. case '+':
  56. mode |= O_RDWR;
  57. mode &= ~(O_RDONLY | O_WRONLY);
  58. streamflag |= _IOWRT;
  59. streamflag &= (_IOREAD | _IOWRT);
  60. break;
  61. default:
  62. errno = EINVAL;
  63. return NULL;
  64. }
  65. stream->_flag = streamflag;
  66. stream->_cnt = 0;
  67. stream->_base = stream->_ptr = NULL;
  68. stream->_file = fildes;
  69. return stream;
  70. }
  71. #endif