home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / UUPC11X3.ZIP / WAITING.CMD < prev   
OS/2 REXX Batch file  |  1992-11-28  |  5KB  |  137 lines

  1. /*--------------------------------------------------------------------*/
  2. /*          Program:    waiting.cmd          9 Nov 1992               */
  3. /*          Author:     Andrew H. Derbyshire                          */
  4. /*          Address:    Kendra Electronic Wonderworks                 */
  5. /*                      P.O. Box 132                                  */
  6. /*                      Arlington, MA 02174                           */
  7. /*          Internet:   help@kew.com                                  */
  8. /*          Language:   OS/2 2.0 REXX                                 */
  9. /*          Function:   Report mail waiting for users                 */
  10. /*        Parameters:   None                                          */
  11. /*       Environment:   Assumes OS/2 Environment variable             */
  12. /*                      UUPCSYSRC has been set to name of UUPC/       */
  13. /*                      extended system configuration file, and       */
  14. /*                      TEMP variable been set if not defined         */
  15. /*                      in UUPC/extended.                             */
  16. /*--------------------------------------------------------------------*/
  17.  
  18. /*--------------------------------------------------------------------*/
  19. /*       Copyright 1990-1992 By Kendra Electronic Wonderworks;        */
  20. /*       may be distributed freely if original documentation and      */
  21. /*       source are included, and credit is given to the authors.     */
  22. /*       For additional instructions, see README.PRN in UUPC/         */
  23. /*       extended documentation archive.                              */
  24. /*--------------------------------------------------------------------*/
  25.  
  26. /*--------------------------------------------------------------------*/
  27. /*       Based on original DOS version by various people, and         */
  28. /*       MAILCHEK.CMD, by Evan Champion <evanc@uuisis.isis.org>       */
  29. /*--------------------------------------------------------------------*/
  30.  
  31. /*
  32.  *       $Id: WAITING.CMD 1.2 1992/11/28 23:08:07 ahd Exp $
  33.  *
  34.  *       $Log: WAITING.CMD $
  35. :: Revision 1.2  1992/11/28  23:08:07  ahd
  36. :: Tweak order of procedures, add comments
  37. ::
  38.  */
  39. '@echo off'
  40. signal on novalue
  41. parse upper arg who;
  42. if who == '' then
  43.    who = '*';
  44. maildir = getuupc("maildir" );
  45. mailext = getuupc("mailext" );
  46.  
  47. return = SysFileTree(maildir || '\' || who || '.' || mailext, 'data.','F')
  48. if return = 2 then
  49.    say 'Not enough memory';
  50. if data.0 = 0 then
  51. do;
  52.    if who = '*' then
  53.       say 'No mail waiting in' maildir;
  54.    else
  55.       say 'No mail waiting for' who;
  56. end;
  57. else  do i = 1 to data.0
  58.    parse var data.i mmddyy hhmmss bytes attr fname;
  59.  
  60.    if bytes > 0 then
  61.    do
  62.       parse value filespec( "name", fname ) with id'.';
  63.       if mmddyy = date('U') then
  64.          when = hhmmss
  65.       else
  66.          when = substr(mmddyy,1,5) hhmmss;
  67.  
  68.       items = CountItems( space(fname) );
  69.       say 'Mail waiting for' id 'since' when '(' || items 'items,' ,
  70.                bytes 'bytes).'
  71.    end
  72. end i /* do */
  73. exit;
  74.  
  75. /*--------------------------------------------------------------------*/
  76. /*    C o u n t I t e m s                                             */
  77. /*                                                                    */
  78. /*    Determine number of items in a mailbox                          */
  79. /*--------------------------------------------------------------------*/
  80.  
  81. CountItems:procedure
  82. parse arg mailbox
  83. sep = copies('01'x,19)
  84. xrc = SysFileSearch( sep ,mailbox,'data.');
  85. if xrc <> 0 then
  86. do;
  87.    say 'Internal error' xrc || ':' ,
  88.          mailbox 'has no UUPC/extended message breaks'
  89.    return 0;
  90. end;
  91. else
  92.    return data.0;
  93.  
  94. /*--------------------------------------------------------------------*/
  95. /*       g e t u u p c                                                */
  96. /*                                                                    */
  97. /*       Get UUPC/extended configuration variable                     */
  98. /*--------------------------------------------------------------------*/
  99.  
  100. getuupc:procedure;
  101. trace n
  102. parse upper arg keyword,answer;
  103.  
  104. uupcrc = value('UUPCSYSRC',,'OS2ENVIRONMENT');
  105. if  uupcrc == '' then
  106. do;
  107.    'UUPCSYSRC not set, cannot continue'
  108.    exit 44;
  109. end;
  110.  
  111. xrc = SysFileSearch( keyword || '=',uupcrc,'data.');
  112. if xrc \= 0 then
  113. do;
  114.    say 'SysFileSearch error' xrc 'searching' uupcrc 'for' keyword;
  115.    exit xrc;
  116. end;
  117.  
  118. do count = 1 to data.0
  119.    parse var data.count newkey'='string;
  120.  
  121.    if translate(newkey) = keyword then
  122.       answer = string;
  123. end;
  124. return translate(answer,'\','/');
  125.  
  126. /*--------------------------------------------------------------------*/
  127. /*    n o v a l u e                                                   */
  128. /*                                                                    */
  129. /*    Trap for uninitialized variables                                */
  130. /*--------------------------------------------------------------------*/
  131.  
  132. novalue:
  133. trace n
  134. signal off novalue;           /* Avoid nasty recursion         */
  135. say 'Uninitialized variable in line' sigl || ':';
  136. say sourceline( sigl );
  137.