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.

98 lines
2.3 KiB

  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* GETMSG.C - Replaces NMSGHDR.ASM and MSGS.ASM */
  6. /* */
  7. /* 28-Nov-90 w-BrianM Created to remove need for MKMSG.EXE */
  8. /* */
  9. /************************************************************************/
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <stdarg.h>
  13. #include <string.h>
  14. #include "rcpptype.h"
  15. #include "rcppdecl.h"
  16. #include "getmsg.h"
  17. /************************************************************************/
  18. /* GET_MSG - Given a message number, get the correct format string */
  19. /************************************************************************/
  20. char * GET_MSG (int msgnumber)
  21. {
  22. int imsg = 0;
  23. int inum;
  24. while ((inum = MSG_TABLE[imsg].usmsgnum) != LASTMSG) {
  25. if (inum == msgnumber) {
  26. return (MSG_TABLE[imsg].pmsg);
  27. }
  28. imsg ++;
  29. }
  30. return ("");
  31. }
  32. /************************************************************************/
  33. /* SET_MSG - Given a format string, format it and store it in first parm*/
  34. /************************************************************************/
  35. void __cdecl SET_MSG (char *exp, char *fmt, ...)
  36. {
  37. va_list arg;
  38. char * arg_pchar;
  39. int arg_int;
  40. long arg_long;
  41. char arg_char;
  42. int base;
  43. int longflag;
  44. va_start (arg, fmt);
  45. while (*fmt) {
  46. if (*fmt == '%') {
  47. longflag = FALSE;
  48. top:
  49. switch (*(fmt+1)) {
  50. case 'l' :
  51. longflag = TRUE;
  52. fmt++;
  53. goto top;
  54. case 'F' :
  55. fmt++;
  56. goto top;
  57. case 's' :
  58. arg_pchar = va_arg(arg, char *);
  59. strcpy(exp, arg_pchar);
  60. exp += strlen(arg_pchar);
  61. fmt += 2;
  62. break;
  63. case 'd' :
  64. case 'x' :
  65. base = *(fmt+1) == 'd' ? 10 : 16;
  66. if (longflag) {
  67. arg_long = va_arg (arg, long);
  68. exp += zltoa(arg_long, exp, base);
  69. }
  70. else {
  71. arg_int = va_arg (arg, int);
  72. exp += zltoa((long)arg_int, exp, base);
  73. }
  74. fmt += 2;
  75. break;
  76. case 'c' :
  77. arg_char = va_arg (arg, char);
  78. *exp++ = arg_char;
  79. fmt += 2;
  80. break;
  81. default :
  82. *exp++ = *fmt++;
  83. }
  84. }
  85. else {
  86. *exp++ = *fmt++;
  87. }
  88. }
  89. *exp = 0;
  90. va_end (arg);
  91. }