home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 35 Internet / 35-Internet.zip / upc12b12.zip / waiting.cmd < prev   
OS/2 REXX Batch file  |  1993-04-04  |  5KB  |  120 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.6 1993/04/04 05:01:49 ahd Exp $
  33.  *
  34.  *       $Log: WAITING.CMD $
  35. *     Revision 1.6  1993/04/04  05:01:49  ahd
  36. *     Use common getuupc.cmd for variable retrieval
  37. *
  38. *     Revision 1.5  1993/01/23  19:15:47  ahd
  39. *     Load required subroutine packages before using them
  40. *
  41. *     Revision 1.4  1993/01/01  16:47:07  ahd
  42. *     Ignore totally blank arguments
  43. *
  44. *     Revision 1.3  1993/01/01  16:44:04  ahd
  45. *     Correct seven digit date bug
  46. *
  47.  * Revision 1.2  1992/11/28  23:08:07  ahd
  48.  * Tweak order of procedures, add comments
  49.  *
  50.  */
  51.  
  52. '@echo off'
  53. signal on novalue
  54. Call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
  55. Call 'SysLoadFuncs'
  56. parse upper arg who;
  57. if words(who) = 0 then
  58.    who = '*';
  59. maildir = getuupc("maildir" );
  60. mailext = getuupc("mailext" );
  61.  
  62. return = SysFileTree(maildir || '\' || who || '.' || mailext, 'data.','F')
  63. if return = 2 then
  64.    say 'Not enough memory';
  65. if data.0 = 0 then
  66. do;
  67.    if who = '*' then
  68.       say 'No mail waiting in' maildir;
  69.    else
  70.       say 'No mail waiting for' who;
  71. end;
  72. else  do i = 1 to data.0
  73.    parse value space(data.i) with mmddyy hhmmss bytes attr fname;
  74.    if bytes > 0 then
  75.    do
  76.       if length(mmddyy) == 7 then
  77.          mmddyy = '0' || mmddyy
  78.       parse value filespec( "name", fname ) with id'.';
  79.       if mmddyy = date('U') then
  80.          when = hhmmss
  81.       else
  82.          when = substr(mmddyy,1,5) hhmmss;
  83.       items = CountItems( space(fname) );
  84.       say 'Mail waiting for' id 'since' when '(' || items 'items,' ,
  85.                bytes 'bytes).'
  86.    end
  87. end i /* do */
  88. exit;
  89.  
  90. /*--------------------------------------------------------------------*/
  91. /*    C o u n t I t e m s                                             */
  92. /*                                                                    */
  93. /*    Determine number of items in a mailbox                          */
  94. /*--------------------------------------------------------------------*/
  95.  
  96. CountItems:procedure
  97. parse arg mailbox
  98. sep = copies('01'x,19)
  99. xrc = SysFileSearch( sep ,mailbox,'data.');
  100. if xrc <> 0 then
  101. do;
  102.    say 'Internal error' xrc || ':' ,
  103.          mailbox 'has no UUPC/extended message breaks'
  104.    return 0;
  105. end;
  106. else
  107.    return data.0;
  108.  
  109. /*--------------------------------------------------------------------*/
  110. /*    n o v a l u e                                                   */
  111. /*                                                                    */
  112. /*    Trap for uninitialized variables                                */
  113. /*--------------------------------------------------------------------*/
  114.  
  115. novalue:
  116. trace n
  117. signal off novalue;           /* Avoid nasty recursion         */
  118. say 'Uninitialized variable in line' sigl || ':';
  119. say sourceline( sigl );
  120.