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.

88 lines
2.2 KiB

  1. /*****************************************************************************
  2. * This is a poor list. Insert only of a (node *).data with no ordering.
  3. * To create the list (and insert 1 item), call insertList(NULL, blah, blah...)
  4. */
  5. #include "pch.h"
  6. #include "lib3.h"
  7. #include "list.h"
  8. AssertData;
  9. AssertError;
  10. void killList(node *thisList)
  11. {
  12. node *currRoot=thisList,*last;
  13. while(currRoot) {
  14. last = currRoot;
  15. currRoot = currRoot->next;
  16. FreeCopyParams(last->lpCP);
  17. GlobalFree(last);
  18. }
  19. }
  20. /*
  21. insert a node. Small bug: if mem alloc fails for CopyParams, the list will
  22. have 1 extra fluff node at the end.
  23. */
  24. node *
  25. insertList(
  26. node **thisList,
  27. LPCOPYPARAMS aNode,
  28. LPSHADOWINFO lpSI,
  29. LPWIN32_FIND_DATA lpFind32Local,
  30. LPWIN32_FIND_DATA lpFind32Remote,
  31. int iShadowStatus,
  32. int iFileStatus,
  33. unsigned int uAction)
  34. {
  35. node *startItem = *thisList;
  36. node *currItem = startItem;
  37. if(startItem) {
  38. while(currItem->next)
  39. currItem = currItem->next;
  40. if(!(currItem->next = (node *) GlobalAlloc(GPTR,sizeof(node))))
  41. return NULL;
  42. currItem = currItem->next;
  43. } else {
  44. if(!(startItem = (node *) GlobalAlloc(GPTR,sizeof(node))))
  45. return NULL;
  46. currItem = startItem;
  47. *thisList = currItem;
  48. }
  49. if(!(currItem->lpCP = LpAllocCopyParams())) {
  50. GlobalFree(currItem);
  51. return 0;
  52. }
  53. currItem->lpCP->hShare = aNode->hShare;
  54. currItem->lpCP->hDir = aNode->hDir;
  55. currItem->lpCP->hShadow = aNode->hShadow;
  56. lstrcpy(currItem->lpCP->lpLocalPath, aNode->lpLocalPath);
  57. lstrcpy(currItem->lpCP->lpSharePath, aNode->lpSharePath);
  58. lstrcpy(currItem->lpCP->lpRemotePath, aNode->lpRemotePath);
  59. currItem->iShadowStatus = iShadowStatus;
  60. currItem->iFileStatus = iFileStatus;
  61. currItem->uAction = uAction;
  62. memcpy(&(currItem->sSI), lpSI, sizeof(SHADOWINFO));
  63. currItem->sSI.lpFind32 = NULL;
  64. memcpy(&(currItem->sFind32Local), lpFind32Local, sizeof(WIN32_FIND_DATA));
  65. if (lpFind32Remote)
  66. {
  67. Assert(sizeof(currItem->sFind32Remote) == sizeof(*lpFind32Remote));
  68. currItem->sFind32Remote = *lpFind32Remote;
  69. }
  70. else
  71. {
  72. memset(&(currItem->sFind32Remote), 0, sizeof(currItem->sFind32Remote));
  73. }
  74. currItem->next = (node *) NULL;
  75. return startItem;
  76. }