home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 24 / CD_ASCQ_24_0995.iso / vrac / semaf003.zip / SEMAFORE.DOC < prev    next >
Text File  |  1995-07-01  |  15KB  |  327 lines

  1.  
  2.                           Semaphore Utility, Revision 3
  3.  
  4.                                   Written by :
  5.                 Marco Miltenburg, 2:512/64@fidonet, marco@klpd.nl
  6.  
  7.  
  8.  
  9.     ────────────────────────────────────────────────────────────────────────
  10.     In no event shall  Marco Miltenburg be liable to you  or anyone else for
  11.     any  special, incidental, consequential, indirect or similar damages due
  12.     to the use  of this program even if one of our support-sites has advised
  13.     you to use the program  in a special way. The program is  provided as it
  14.     is, and you use  it at your  own risk. All brands  and product names  in
  15.     this  documentation are  trademarks or  registered  trademarks of  their
  16.     respective holders.
  17.     ────────────────────────────────────────────────────────────────────────
  18.  
  19.  
  20.     WHAT IS IT ?
  21.     ════════════────────────────────────────────────────────────────────────
  22.     If you don't know what semaphore files are, you probably don't need this
  23.     little utility. It's  written to make  writing batchfiles for  MultiLine
  24.     BBS systems somewhat easier.
  25.  
  26.     SEMAFORE is a little utility that can create, delete and touch semaphore
  27.     files. In  addition it can  also wait (configurable maximum  time) for a
  28.     semaphore file  to exist or to clear. Last  but not least, it can report
  29.     through an errorlevel if the specified semaphore file exists or not.
  30.  
  31.     Creation,  updating  and  deleting  of  the  semaphore   files  is  done
  32.     according to the guidelines provided  by Joaquim Homrighausen (in his FD
  33.     2.20 Developers  Package), author  of the  well  known FrontDoor  mailer
  34.     which  makes extensive  use  of semaphore  files.  This assures  maximum
  35.     compatible with a variety of mailers, BBS systems, operating systems and
  36.     NOS.
  37.  
  38.     SEMAFORE  is multitasker aware. This means  that when it's waiting for a
  39.     semaphore file to clear or to appear, it will return time-slices back to
  40.     the operating system or multitasker. Currently supported systems are :
  41.  
  42.       Windows/Std 3.x and higher
  43.       Windows/386 2.x and higher
  44.       OS/2 2.x and OS/2 Warp
  45.       DESQview and DESQview/X
  46.  
  47.  
  48.     USAGE
  49.     ═════───────────────────────────────────────────────────────────────────
  50.     Usage of SEMAFORE is very easy. If  started without any command, it will
  51.     display the following help screen :
  52.  
  53.      SEMAFORE, Rev. 3   Multi-Line BBS Semaphore Utility   Freeware!
  54.      Copyright (C) 1994-1995, Marco A.J. Miltenburg. All rights reserved.
  55.  
  56.      Usage :
  57.  
  58.        SEMAFORE <action>[<action>] <filename> [<waittime>]|[<waittime>s]
  59.  
  60.      Action  :  +  Create or touch semaphore.
  61.                 -  Delete semaphore.
  62.                 *  Create when not exist, return errorlevel 1 when created.
  63.                 !  Wait until semaphore exist.
  64.                 ?  Wait until semaphore is cleared (removed).
  65.                 &  If semaphore exists, return errorlevel 1.
  66.                 %  If semaphore doesn't exist, return errorlevel 1.
  67.  
  68.      Filename:  Full path and filename of semaphore file.
  69.  
  70.      Waittime:  Maximum time to wait (optional for use with ! and ?).
  71.                 If the time has expired, exit with errorlevel 1. If followed
  72.                 by an 's' the time is in seconds, otherwise minutes.
  73.  
  74.     SEMAFORE requires at least two options. The first is one or more actions
  75.     and a semaphore  filename. The third waittime option  is always optional
  76.     and assumed zero if not given.
  77.  
  78.  
  79.     ─  Creating Semaphores
  80.     ──────────────────────
  81.     Creating  a semaphore file  can be done  with the  following command (an
  82.     example) :
  83.  
  84.       SEMAFORE + S:\SEMA\FD\FDFREEZE.ALL
  85.  
  86.     This  will create  the semaphore  S:\SEMA\FD\FREEZE.ALL.  If it  already
  87.     exists, it will only touch the date/time of the semaphore.
  88.  
  89.  
  90.     ─  Deleting Semaphores
  91.     ──────────────────────
  92.     Deleting  a semaphore file  can be done  with the  following command (an
  93.     example) :
  94.  
  95.       SEMAFORE - S:\SEMA\FD\FDFREEZE.ALL
  96.  
  97.     This  will delete the  semaphore S:\SEMA\FD\FDFREEZE.ALL. If  it doesn't
  98.     exist,  SEMAFORE will simply ignore  the command and return immediately.
  99.     No error message  or whatsoever is displayed.  When deleting semaphores,
  100.     you can also use wildcards to match multiple semaphores, e.g. :
  101.  
  102.       SEMAFORE - S:\SEMA\FD\FDFREEZE.*
  103.  
  104.     This will delete all FDFREEZE semaphore files.
  105.  
  106.  
  107.     ─  Create Semaphore Only When It Doesn't Exist Yet
  108.     ──────────────────────────────────────────────────
  109.     The * option  is an extended version  of the + option.  This option will
  110.     create the specified semaphore file only when it doesn't exist yet. When
  111.     it's created,  it will exit  with errorlevel 1, otherwise  errorlevel 0.
  112.     This is useful  when you  want to check  for a semaphore  file and  only
  113.     create it when it doesn't exist already  (no touch). The following is an
  114.     example on how to use this option :
  115.  
  116.       SEMAFORE * S:\SEMA\TOSSMAIL
  117.       If Errorlevel 1 Goto TossMail
  118.  
  119.     This will create S:\SEMA\TOSSMAIL only when the TOSSMAIL semaphore isn't
  120.     present already. When it's created, the batchfile will continue at label
  121.     'TossMail'.  This makes sure that mail is only tossed when the semaphore
  122.     is created by  the current task, preventing multiple  tasks from tossing
  123.     mail at the same time.
  124.  
  125.  
  126.     ─  Wait Until Semaphore Exists
  127.     ──────────────────────────────
  128.     In  addition  to  these basic  semaphore  operations,  SEMAFORE supports
  129.     checking if  the  specified  semaphore  exists. If  it  doesn't  exists,
  130.     SEMAFORE will wait till it exists. To narrow the change of  lockups, you
  131.     can specify  a maximum time to wait.  If the specified semaphore doesn't
  132.     appear in the  given time, SEMAFORE will display a warning and will exit
  133.     with errorlevel 1. You can use this errorlevel in your batchfile to take
  134.     care of this  situation. The following is an example on  how to use this
  135.     option :
  136.  
  137.       SEMAFORE + S:\SEMA\FD\FDFREEZE.ALL
  138.       SEMAFORE ! S:\SEMA\FD\FDFROZEN.2
  139.       SEMAFORE ! S:\SEMA\FD\FDFROZEN.3
  140.       SEMAFORE ! S:\SEMA\FD\FDFROZEN.4
  141.  
  142.     This fragment of a batchfile could be executed by line #1 of a MultiLine
  143.     system  causing all  FrontDoor's on  the other 3  lines to  freeze until
  144.     FDFREEZE.ALL is removed again (with SEMAFORE - S:\SEMA\FD\FDFREEZE.ALL).
  145.  
  146.     If you want to wait for a maximum of 2 hours for the semaphore FDALIVE.1
  147.     to appear, you could use the following command :
  148.  
  149.       SEMAFORE ! S:\SEMA\FD\FDALIVE.1 120
  150.       If Errorlevel 1 Echo Serious trouble on line #1 !!!
  151.  
  152.     The  maximum wait time  is normally  expressed in  minutes. If  you need
  153.     shorter times or  times other than in minutes, add an 's' directly after
  154.     the time to specify the waittime in seconds. E.g. :
  155.  
  156.       SEMAFORE ! S:\SEMA\FD\FDALIVE.1 100s
  157.       If Errorlevel 1 Echo No respons within 100 seconds from line #1 !!!
  158.  
  159.     If this time expires, this example will display a warning message to the
  160.     standard output device.
  161.  
  162.  
  163.     ─  Wait Until Semaphore Is Cleared
  164.     ──────────────────────────────────
  165.     If you want to wait for  a specified semaphore to be cleared  (removed),
  166.     you can use the following command :
  167.  
  168.       SEMAFORE ? S:\SEMA\HOLDLINE.1
  169.  
  170.     SEMAFORE will wait till the  semaphore HOLDLINE.1 is removed (by another
  171.     line or anything else).  To wait a maximum of 15 minutes,  you can add '
  172.     15' to the above commandline, like :
  173.  
  174.       SEMAFORE ? S:\SEMA\HOLDLINE.1 15
  175.       If Errorlevel 1 Echo He, I'm already waiting for 15 minutes!
  176.  
  177.     If the semaphore  isn't cleared after 15 minutes, this example will echo
  178.     a  message to  the  standard  output device.  This  option also  accepts
  179.     wildcards in the semaphore filename to monitor multiple semaphore  files
  180.     at the same time. E.g. :
  181.  
  182.       SEMAFORE ? S:\SEMA\LINEUP.* 500s
  183.       If Errorlevel 1 Echo There are still lines running after 500 seconds!
  184.  
  185.  
  186.     ─  Return Errorlevel
  187.     ────────────────────
  188.     Last but  not least SEMAFORE can  check if the  specified semaphore file
  189.     exist  or not. If  it does,  it will  report an errorlevel  of 1.  If it
  190.     doesn't exist, it will return with errorlevel 0. Example :
  191.  
  192.       SEMAFORE & S:\SEMA\FD\FDALIVE.1
  193.       If Errorlevel 1 SEMAFORE + S:\SEMA\FD\FDXIT1.10
  194.  
  195.     The above piece  of batchfile will force  FrontDoor Task 1 to  exit like
  196.     the user pressed ALT-Q  on the keyboard. However, the semaphore  is only
  197.     created when Task 1 is up and running.
  198.  
  199.     The inverse of this option is the % command. This will force SEMAFORE to
  200.     exit with errorlevel 1 when the semaphore does NOT exist, e.g. :
  201.  
  202.       SEMAFORE % S:\SEMA\FD\FDALIVE.1
  203.       If Errorlevel 1 Echo FrontDoor Task 1 is not running
  204.  
  205.     Both & and % also accept wildcards in the semaphore filename.
  206.  
  207.  
  208.     ─  Multiple Actions
  209.     ───────────────────
  210.     SEMAFORE can  handle multiple actions on  the semaphore file  at once in
  211.     the same run. It will handle them  in the same order you present them on
  212.     the commandline. A good example for it's use is :
  213.  
  214.       SEMAFORE &- S:\SEMA\NEWMAIL.ALL
  215.  
  216.     This means  that SEMAFORE  will check if  the NEWMAIL.ALL  semafore does
  217.     exist. If  it does,  it will  exit with  errorlevel 1  but it  will also
  218.     remove the semaphore  to be sure it  won't be processed twice.  This can
  219.     ofcourse also be utilized as :
  220.  
  221.       SEMAFORE %+ S:\SEMA\SCANNOW.ALL
  222.  
  223.     which does the opposite. The following command is ofcourse nonsense :
  224.  
  225.       SEMAFORE +- S:\SEMA\WHATEVER.ALL
  226.  
  227.     but completly valid for SEMAFORE. In fact it will do exactly what it has
  228.     been told and will create and remove the semaphore  file in one run. You
  229.     may specify an unlimited number of actions, e.g. :
  230.  
  231.       SEMAFORE -!- S:\SEMA\NOTIFY.1
  232.  
  233.     which  might  be  usefull. It  will  always  wait for  a  fresh NOTIFY.1
  234.     semaphore. If it already exists when SEMAFORE is started, it will remove
  235.     it and wait for it to show up.
  236.  
  237.     Another possiblity that comes to mind is :
  238.  
  239.       SEMAFORE +?- S:\SEMA\SYNCH.NOW 2
  240.  
  241.     which will create SYNCH.NOW. After that  it will wait for 2 minutes  for
  242.     SYNCH.NOW to  clear so it knows in which state the other line is. If the
  243.     semaphore is not  cleared within 2 minutes,  it will be also  be removed
  244.     but no errorlevel will be reported.
  245.  
  246.     As you  can see,  you can  ease your  batchfile a  lot with  this little
  247.     utility. Of course it can also  be done with standard DOS commands,  but
  248.     this normally requires  more lines and continuous  execution and reading
  249.     of  the batchfile by COMMAND.COM when waiting  for a semaphore to appear
  250.     or clear  for example. SEMAFORE  will only  check once every  second and
  251.     will  return timeslices  to  the above  mentioned multitaskers/operating
  252.     systems. This speeds up processing in other tasks.
  253.  
  254.  
  255.     FDOPT
  256.     ═════───────────────────────────────────────────────────────────────────
  257.     SEMAFORE supports the FDOPT environment  variable. It will recognize the
  258.     following options :
  259.  
  260.     FORCEINT28     By default, SEMAFORE  uses the DPMI mechanism  to release
  261.                    timeslices under OS/2  and Windows (FDOPT=FORCEDPMI).  By
  262.                    using this option, SEMAFORE will  issue INT 28 calls when
  263.                    returning   timeslices    when   running    under   these
  264.                    multitaskers / operating systems.
  265.  
  266.     FORCECOMMIT    This will  force SEMAFORE  to use  the commit  call. This
  267.                    will update the directory entry of  the semaphore on disk
  268.                    every time is has been changed.
  269.  
  270.     NOCOMMIT       By  default SEMAFORE will use  the normal commit call. If
  271.                    this   option  is   specified,  SEMAFORE   will  use   an
  272.                    alternative way to commit changes.
  273.  
  274.     NOMULD         Prevents SEMAFORE  from auto-detecting the  multitasker /
  275.                    operating  system.  No timeslices  will be  returned when
  276.                    SEMAFORE is waiting.
  277.  
  278.  
  279.     In contradiction  to FrontDoor, these  options can only  be set  via the
  280.     FDOPT environment variable, NOT on  the commandline. All unknown options
  281.     in the FDOPT environment variable are ignored.
  282.  
  283.  
  284.     FINAL NOTE
  285.     ══════════──────────────────────────────────────────────────────────────
  286.     Almost  all of  the above  examples show  FrontDoor semaphore  files. Of
  287.     course SEMAFORE can be used with other packages as well, but I just like
  288.     FrontDoor, so I took that as  an example. I've tested SEMAFORE on  2 BBS
  289.     systems  (6  lines totally)  of  which  I'm sysop.  It  didn't  show any
  290.     compatibility problems with RemoteAccess 2.0x/SW/PRO, FrontDoor 2.20c.mL
  291.     (and higher), Novell Netware 3.11  to 4.1, Lantastic/AI 5.0, All version
  292.     higher then  3.30 of MS-DOS, DESQview 2.62, Windows 3.10 and Windows for
  293.     Workgroups 3.11. It works for me, so it should work for you.
  294.  
  295.     SEMAFORE has been  written by Marco Miltenburg  (2:512/64@fidonet) using
  296.     Borland Pascal  7.0 for  DOS.  I have  written it  because there  wasn't
  297.     anything else  on the  market with  the features  I wanted  it to  have.
  298.     SEMAFORE is freeware. You don't have to  register it, nor do you have to
  299.     pay me for using it. However, I like getting money on my bankaccount, so
  300.     if you need to get rid of some, please mail me :-). I  also like to here
  301.     from  people that  are using it  with or  without success. Feel  free to
  302.     contact me at the following system :
  303.  
  304.       Public Board MultiLine
  305.       Location: Driebergen, The Netherlands
  306.       Line #1 : +31-3438-14125 - USRobotics DS/HST V.Everything with V.34+
  307.       Line #2 : +31-3438-33602 - USRobotics DS/HST V32Bis, HST
  308.       FidoNet : 2:512/64 (Line #1)
  309.                 2:512/364 (Line #2)
  310.  
  311.  
  312.     CREDITS
  313.     ═══════─────────────────────────────────────────────────────────────────
  314.     Thanks to numerous people who  contacted me with suggestions and reports
  315.     how  the use  SEMAFORE. Also  thanks to  Joaquim Homrighausen  and Bruce
  316.     Bodger for hatching this utility in SDSFRONT.
  317.  
  318.     DESQview         Copyright QuarterDeck Office Systems.
  319.     FrontDoor        Copyright Joaquim Homrighausen, Absolute Solutions.
  320.     Lantastic        Copyright Artisoft, Inc.
  321.     MS-DOS           Copyright Microsoft Corporation.
  322.     Novell Netware   Copyright Novell Inc.
  323.     OS/2             Copyright IBM Corporation.
  324.     RemoteAccess     Copyright Andrew Milner, Wantree Development.
  325.     Borland Pascal   Copyright Borland International, Inc.
  326.     Windows          Copyright Microsoft Corporation.
  327.