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.

73 lines
2.3 KiB

  1. /*
  2. ** Copyright 1995-2095, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. */
  17. #include <GL/gls.h>
  18. #include <stdlib.h>
  19. #if __GLS_PLATFORM_WIN32
  20. #include <fcntl.h>
  21. #include <io.h>
  22. #define __MAIN_LINKAGE __cdecl
  23. #else /* !__GLS_PLATFORM_WIN32 */
  24. #define __MAIN_LINKAGE
  25. #endif /* __GLS_PLATFORM_WIN32 */
  26. static void configStdio(void) {
  27. setbuf(stdout, GLS_NONE);
  28. #if __GLS_PLATFORM_WIN32
  29. _setmode(_fileno(stdout), _O_BINARY);
  30. _setmode(_fileno(stderr), _O_BINARY);
  31. #endif /* __GLS_PLATFORM_WIN32 */
  32. }
  33. GLint __MAIN_LINKAGE main(const GLsizei inArgc, const GLubyte *inArgv[]) {
  34. GLubyte *array;
  35. size_t count;
  36. GLSenum streamType;
  37. configStdio();
  38. if (inArgc != 2) {
  39. fprintf(stderr, "usage: %s <streamName>\n", inArgv[0]);
  40. exit(EXIT_FAILURE);
  41. }
  42. glsContext(glsGenContext());
  43. streamType = glsGetStreamType(inArgv[1]);
  44. if (!streamType) {
  45. fprintf(stderr, "%s: invalid stream %s\n", inArgv[0], inArgv[1]);
  46. exit(EXIT_FAILURE);
  47. }
  48. count = glsGetStreamSize(inArgv[1]);
  49. if (!count) {
  50. fprintf(
  51. stderr,
  52. "%s: could not determine size of stream %s\n",
  53. inArgv[0],
  54. inArgv[1]
  55. );
  56. exit(EXIT_FAILURE);
  57. }
  58. array = (GLubyte *)malloc(count);
  59. if (!array) {
  60. fprintf(stderr, "%s: malloc(%u) failed\n", inArgv[0], count);
  61. exit(EXIT_FAILURE);
  62. }
  63. fread(array, 1, count, fopen((const char *)inArgv[1], "rb"));
  64. glsBeginCapture(glsCSTR(""), GLS_TEXT, GLS_NONE);
  65. glsCallArray(streamType, count, array);
  66. glsEndCapture();
  67. return EXIT_SUCCESS;
  68. }