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.

120 lines
4.6 KiB

  1. #include <faxutil.h>
  2. //*********************************************************************************
  3. //* Personal Profile Functions
  4. //*********************************************************************************
  5. //*********************************************************************************
  6. //* Name: CopyPersonalProfile()
  7. //* Author: Ronen Barenboim
  8. //* Date:
  9. //*********************************************************************************
  10. //* DESCRIPTION:
  11. //* Creates a new copy of a FAX_PERSONAL_PROFILEW structure.
  12. //* It duplicates all the strings.
  13. //*
  14. //* PARAMETERS:
  15. //* [IN] PFAX_PERSONAL_PROFILE lpDstProfile
  16. //* A pointer to destination personal profile structure.
  17. //*
  18. //* [OUT] LPCFAX_PERSONAL_PROFILE lpcSrcProfile.
  19. //* A pointer to the source personal profile to copy.
  20. //*
  21. //* RETURN VALUE:
  22. //* TRUE
  23. //* If the operation succeeded.
  24. //* FALSE
  25. //* If the operation failed.
  26. //*********************************************************************************
  27. BOOL CopyPersonalProfile(
  28. PFAX_PERSONAL_PROFILE lpDstProfile,
  29. LPCFAX_PERSONAL_PROFILE lpcSrcProfile
  30. )
  31. {
  32. STRING_PAIR pairs[] =
  33. {
  34. { lpcSrcProfile->lptstrName, &lpDstProfile->lptstrName},
  35. { lpcSrcProfile->lptstrFaxNumber, &lpDstProfile->lptstrFaxNumber},
  36. { lpcSrcProfile->lptstrCompany, &lpDstProfile->lptstrCompany},
  37. { lpcSrcProfile->lptstrStreetAddress, &lpDstProfile->lptstrStreetAddress},
  38. { lpcSrcProfile->lptstrCity, &lpDstProfile->lptstrCity},
  39. { lpcSrcProfile->lptstrState, &lpDstProfile->lptstrState},
  40. { lpcSrcProfile->lptstrZip, &lpDstProfile->lptstrZip},
  41. { lpcSrcProfile->lptstrCountry, &lpDstProfile->lptstrCountry},
  42. { lpcSrcProfile->lptstrTitle, &lpDstProfile->lptstrTitle},
  43. { lpcSrcProfile->lptstrDepartment, &lpDstProfile->lptstrDepartment},
  44. { lpcSrcProfile->lptstrOfficeLocation, &lpDstProfile->lptstrOfficeLocation},
  45. { lpcSrcProfile->lptstrHomePhone, &lpDstProfile->lptstrHomePhone},
  46. { lpcSrcProfile->lptstrOfficePhone, &lpDstProfile->lptstrOfficePhone},
  47. { lpcSrcProfile->lptstrEmail, &lpDstProfile->lptstrEmail},
  48. { lpcSrcProfile->lptstrBillingCode, &lpDstProfile->lptstrBillingCode},
  49. { lpcSrcProfile->lptstrTSID, &lpDstProfile->lptstrTSID}
  50. };
  51. int nRes;
  52. DEBUG_FUNCTION_NAME(TEXT("CopyPersonalProfile"));
  53. Assert(lpDstProfile);
  54. Assert(lpcSrcProfile);
  55. nRes=MultiStringDup(pairs, sizeof(pairs)/sizeof(STRING_PAIR));
  56. if (nRes!=0) {
  57. // MultiStringDup takes care of freeing the memory for the pairs for which the copy succeeded
  58. DebugPrintEx(DEBUG_ERR,TEXT("Failed to copy string with index %d"),nRes-1);
  59. return FALSE;
  60. }
  61. lpDstProfile->dwSizeOfStruct=lpcSrcProfile->dwSizeOfStruct;
  62. return TRUE;
  63. }
  64. //*********************************************************************************
  65. //* Name: FreePersonalProfile()
  66. //* Author: Ronen Barenboim
  67. //* Date:
  68. //*********************************************************************************
  69. //* DESCRIPTION:
  70. //* Frees the contents of a FAX_PERSONAL_PROFILEW structure.
  71. //* Deallocates the strucutre itself if required.
  72. //* PARAMETERS:
  73. //* [IN] PFAX_PERSONAL_PROFILE lpProfile
  74. //* The structure whose content is to be freed.
  75. //*
  76. //* [IN] BOOL bDestroy
  77. //* If this parameter is TRUE the function will
  78. //* deallocate the structure itself.
  79. //*
  80. //* RETURN VALUE:
  81. //* VOID
  82. //*********************************************************************************
  83. void FreePersonalProfile (
  84. PFAX_PERSONAL_PROFILE lpProfile,
  85. BOOL bDestroy
  86. )
  87. {
  88. DEBUG_FUNCTION_NAME(TEXT("FreePersonalProfile"));
  89. Assert(lpProfile);
  90. MemFree(lpProfile->lptstrName);
  91. MemFree(lpProfile->lptstrFaxNumber);
  92. MemFree(lpProfile->lptstrCompany);
  93. MemFree(lpProfile->lptstrStreetAddress);
  94. MemFree(lpProfile->lptstrCity);
  95. MemFree(lpProfile->lptstrState);
  96. MemFree(lpProfile->lptstrZip);
  97. MemFree(lpProfile->lptstrCountry);
  98. MemFree(lpProfile->lptstrTitle);
  99. MemFree(lpProfile->lptstrDepartment);
  100. MemFree(lpProfile->lptstrOfficeLocation);
  101. MemFree(lpProfile->lptstrHomePhone);
  102. MemFree(lpProfile->lptstrOfficePhone);
  103. MemFree(lpProfile->lptstrEmail);
  104. MemFree(lpProfile->lptstrBillingCode);
  105. MemFree(lpProfile->lptstrTSID);
  106. if (bDestroy) {
  107. MemFree(lpProfile);
  108. }
  109. }