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.

163 lines
3.8 KiB

  1. # __________________________________________________________________________________
  2. #
  3. # Purpose:
  4. # PERL Script to emulate SLM's 'enlist' command
  5. #
  6. # Parameters:
  7. # See Usage below
  8. #
  9. # Output:
  10. # Perforce output or the appropriate error message or usage statement
  11. #
  12. # __________________________________________________________________________________
  13. #
  14. # Load common SLM wrapper subroutine module
  15. #
  16. use SlmSubs;
  17. #
  18. # Parse command line arguments
  19. #
  20. SlmSubs::ParseArgs(@ARGV);
  21. #
  22. # Call usage and exit if ParseArgs has set the Usage or InvalidFlag flags
  23. #
  24. if ($Usage or $InvalidFlag)
  25. {
  26. print $ErrorMessage;
  27. &Usage;
  28. exit 1;
  29. }
  30. #
  31. # Initialize Strings
  32. #
  33. $UserName = "";
  34. #
  35. # Set @CurrentClientList equal to $SourceControlClient client output
  36. #
  37. open(USERS, "$SourceControlClient users @OriginalFileList|");
  38. @UsersOutput = <USERS>;
  39. close (USERS);
  40. foreach $UserLine (@UsersOutput)
  41. {
  42. $UserLine =~ /^(.*) <.*/;
  43. $UserName = $1;
  44. push @UsersList, $UserName;
  45. $UsersExistenceHash{lc($UserName)}++;
  46. }
  47. #
  48. # Set @CurrentClientList equal to $SourceControlClient client output
  49. #
  50. open(CLIENTS, "$SourceControlClient clients |");
  51. @ClientsOutput = <CLIENTS>;
  52. close (CLIENTS);
  53. foreach $ClientLine (@ClientsOutput)
  54. {
  55. $ClientLine =~ /^Client (\S+) .*/;
  56. $ClientName = $1;
  57. push @ClientsList, $ClientName;
  58. }
  59. foreach $ClientName (@ClientsList)
  60. {
  61. my @OwnerClientList;
  62. #
  63. # Set @CurrentClientList equal to $SourceControlClient client output
  64. #
  65. open(CLIENT, "$SourceControlClient -c $ClientName client -o |");
  66. @ClientOutput = <CLIENT>;
  67. close (CLIENT);
  68. foreach $ClientLine (@ClientOutput)
  69. {
  70. if ($ClientLine =~ /^Owner:(\s*)(.*)\n/)
  71. {
  72. $Owner = $2;
  73. }
  74. if ($ClientLine =~ /^Access:(\s*)(.*)\n/)
  75. {
  76. $LastAccessed = $2;
  77. }
  78. }
  79. if ($UsersHash{lc($Owner)} == ())
  80. {
  81. @OwnerClientList = ();
  82. }
  83. else
  84. {
  85. $ArrayRef = $UsersHash{lc($Owner)};
  86. @OwnerClientList = @$ArrayRef;
  87. }
  88. if ($Verbose)
  89. {
  90. push @OwnerClientList, "$ClientName\t\tLast Accessed\t$LastAccessed";
  91. }
  92. else
  93. {
  94. push @OwnerClientList, $ClientName;
  95. }
  96. $UsersHash{lc($Owner)} = \@OwnerClientList;
  97. if ($UsersExistenceHash{lc($Owner)} == NULL)
  98. {
  99. push @UsersList, $Owner;
  100. $UsersExistenceHash{lc($Owner)}++;
  101. }
  102. }
  103. @UsersList = sort @UsersList;
  104. foreach $UserLine (@UsersList)
  105. {
  106. print "$UserLine:\n";
  107. if ($UsersHash{lc($UserLine)} == ())
  108. {
  109. print "\tNo clients...\n";
  110. }
  111. $ClientArrayRef = $UsersHash{lc($UserLine)};
  112. @UserClientList = @$ClientArrayRef;
  113. foreach $ClientLine (@UserClientList)
  114. {
  115. print "\t$ClientLine\n";
  116. }
  117. }
  118. sub Usage
  119. # __________________________________________________________________________________
  120. #
  121. # Prints out a usage statement for this script. In this case usurped from SLM's
  122. # 'enlist' usage statement
  123. #
  124. # Parameters:
  125. # None
  126. #
  127. # Output:
  128. # The usage statement
  129. #
  130. # __________________________________________________________________________________
  131. {
  132. print q/enlist - enlists a directory in a project
  133. Usage: enlist [-?fh] [-s Server:Port] -p [branch]\/projname
  134. Arguments:
  135. -h prints out this message.
  136. -p use this flag to specify the name of the project to enlist in. The
  137. project name can be preceeded by a branch name. The default branch
  138. is the main branch.
  139. -s use this flag to specify the network location of the project in which
  140. to enlist, using the format: -s Server:Port "Server" is the network
  141. server name and "Port" is the Perforce Server's TCP\/IP port number.
  142. /;
  143. }