Windows NT 4.0 source code leak
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.

64 lines
2.1 KiB

4 years ago
  1. /************************************************************************/
  2. /* */
  3. /* RCPP - Resource Compiler Pre-Processor for NT system */
  4. /* */
  5. /* RCPPTIL.C - Utility routines for RCPP */
  6. /* */
  7. /* 27-Nov-90 w-BrianM Update for NT from PM SDK RCPP */
  8. /* */
  9. /************************************************************************/
  10. #include "rc.h"
  11. extern void error(int);
  12. extern CHAR Msg_Text[];
  13. extern PCHAR Msg_Temp;
  14. /************************************************************************
  15. * PSTRDUP - Create a duplicate of string s and return a pointer to it.
  16. ************************************************************************/
  17. WCHAR *pstrdup(WCHAR *s)
  18. {
  19. return(wcscpy((WCHAR *)MyAlloc((wcslen(s) + 1) * sizeof(WCHAR)), s));
  20. }
  21. /************************************************************************
  22. ** pstrndup : copies n bytes from the string to a newly allocated
  23. ** near memory location.
  24. ************************************************************************/
  25. WCHAR * pstrndup(WCHAR *s, int n)
  26. {
  27. WCHAR *r;
  28. WCHAR *res;
  29. r = res = MyAlloc((n+1) * sizeof(WCHAR));
  30. if (res == NULL) {
  31. strcpy (Msg_Text, GET_MSG (1002));
  32. error(1002);
  33. return NULL;
  34. }
  35. try {
  36. for (; n--; r++, s++) {
  37. *r = *s;
  38. }
  39. } except(EXCEPTION_EXECUTE_HANDLER) {
  40. n++;
  41. while (n--) {
  42. *r++ = L'\0';
  43. }
  44. }
  45. *r = L'\0';
  46. return(res);
  47. }
  48. /************************************************************************
  49. ** strappend : appends src to the dst,
  50. ** returns a ptr in dst to the null terminator.
  51. ************************************************************************/
  52. WCHAR * strappend(register WCHAR *dst, register WCHAR *src)
  53. {
  54. while ((*dst++ = *src++) != 0);
  55. return(--dst);
  56. }