home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / lan / pdclkset / pdclkset.asm
Assembly Source File  |  1990-09-14  |  10KB  |  201 lines

  1.  
  2. ;*************************************************************************
  3. ;**                                                                     **
  4. ;**                     PDCLKSET                                        **
  5. ;**                                                                     **
  6. ;**                                                                     **
  7. ;**             Copyright (C) 1990 Jan.Engvald @ LDC.lu.se        **
  8. ;**                                                                     **
  9. ;** This program is free software; you can redistribute it and/or modify**
  10. ;** it under the terms of the GNU General Public License as published by**
  11. ;** the Free Software Foundation, version 1.                **
  12. ;**                                    **
  13. ;** This program is distributed in the hope that it will be useful,    **
  14. ;** but WITHOUT ANY WARRANTY; without even the implied warranty of    **
  15. ;** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    **
  16. ;** GNU General Public License for more details.            **
  17. ;**                                    **
  18. ;** You should have received a copy of the GNU General Public License    **
  19. ;** along with this program; if not, write to the Free Software        **
  20. ;** Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.        **
  21. ;**                                                                     **
  22. ;*************************************************************************
  23. ;**                                                                     **
  24. ;** PDCLKSET sets the time and date of the PC clock using a TIME server.**
  25. ;** To do so, the following information is required:            **
  26. ;**                                     **
  27. ;** - This clients unique IP number.                    **
  28. ;** - The IP number of a time server.                    **
  29. ;** - The time offset from UTC (GMT) at this place.            **
  30. ;** - If daylight saving (summer) time is used, which algorithm to use.    **
  31. ;**                                     **
  32. ;** All the above info can be supplied as arguments to PDCLKSET. If any    **
  33. ;** of the first three are missing, it will send a BOOTP request to try    **
  34. ;** to find the missing info. Except for client IP number, arguments to    **
  35. ;** PDCLKSET overrides BOOTP info.                    **
  36. ;**                                     **
  37. ;** BOOTP can not supply which dst algorithm to use; also, time offset    **
  38. ;** can't always be trusted. So, in practice, time offset and dst algo-    **
  39. ;** rithm (if applicable) are required arguments.            **
  40. ;**                                     **
  41. ;** If PDCLKSET finds more than one time server (sum of arguments and    **
  42. ;** BOOTP fields) and the first one does not answer, it will try the    **
  43. ;** second server.                            **
  44. ;**                                     **
  45. ;** It is very hard to get accurate info on all the dst algorithms used    **
  46. ;** all over the world, so the one you choose, you should test out. Use    **
  47. ;** the alter argument to add or subtract time and days, and check that    **
  48. ;** the dst switch occurs correctly. When using the alter argument, the    **
  49. ;** date and time is displayed as usual, but the PC clock is not set.    **
  50. ;** If you find any errors, mail me the correct info to my mail address    **
  51. ;** below. If you want to, you can customize your own dst algorithm, see**
  52. ;** detailed info below.                        **
  53. ;**                                     **
  54. ;** PDCLKSET talks to the network card via a packet driver. If you have    **
  55. ;** more than one packet driver, it will use the first one (lowest     **
  56. ;** packet interrupt number) unless you use the pktintno argument.    **
  57. ;** In AUTOEXEC.BAT you should first load the packet driver, then call    **
  58. ;** PDCLKSET. It is very small (6 kbyte) and executes fast, so you will    **
  59. ;** not notice any delay. PDCLKSET is not a TSR and does not require any**
  60. ;** CONFIG.SYS files, so no memory is wasted.                **
  61. ;** Note: If you always log into a Novell server after a boot, you     **
  62. ;** don't need this program, the PC clock will be set from the server.    **
  63. ;**                                     **
  64. ;** Call syntax:                            **
  65. ;**                                     **
  66. ;**   (time is [- | +]{<hours>h | <minutes>m | <seconds>[s]})        **
  67. ;**                                    **
  68. ;** pdclkset b[ootp]       or                        **
  69. ;**                                    **
  70. ;** pdclkset [i[pnr]=n.n.n.n]  [t[imserver]=n.n.n.n[,n.n.n.n]]        **
  71. ;**                                     **
  72. ;**          [o[ffset]=time]                        **
  73. ;**                                     **
  74. ;**          [d[aylightsave]=PACP | USA | CUB | CHIL | BRZ | GBR |    **
  75. ;**                          W_EU | M_EU | E_EU | LIBY | EGY | TURK |    **
  76. ;**                          ISR | IRAN | PRC | ROK | AUS | NSW | NZE |    **
  77. ;**                          FrTime,FrWeekDay,FrDayOfYear,        **
  78. ;**                          ToTime,ToWday,ToDayOfYr,AddTime]        **
  79. ;**                                     **
  80. ;**          [a[lter]=days,time]  [p[ktintno]=decimalnr]        **
  81. ;**                                     **
  82. ;**                                     **
  83. ;** Examples:                                **
  84. ;**                                     **
  85. ;** pdclkset offs= -60m dst=M_EU (my IP nr and timeserver(s) from BOOTP)**
  86. ;**                                     **
  87. ;** pdclkset o=5h  d=USA  ip=123.45.6.7  ts=123.45.6.8  (BOOTP not used)**
  88. ;**                                     **
  89. ;*************************************************************************
  90. ;**                                     **
  91. ;** Acknowledgments:                            **
  92. ;**                                     **
  93. ;** The checksum routine used is a modified NCSA Telnet version.    **
  94. ;** The dst algorithm was modelled after PCIP SETCLOCK (thanks Drew!),    **
  95. ;** but enhanced to use parameters from a table.            **
  96. ;** The dst algorithm table was derived from a comp.sources.unix 1989    **
  97. ;** posting by ado@ncifcrf.gov of localtime.c and related routines    **
  98. ;** and tables (very useful data, thanks!).                **
  99. ;** The packet driver interface routines were copied from the Clarkson    **
  100. ;** packet driver distribution.                        **
  101. ;** The small UDP/IP library was written by me, and can probably be    **
  102. ;** used in other small assembler applications.                **
  103. ;*                                      *
  104. ;* Jan Engvald, Lund University Computing Center             *
  105. ;* ____________________________________________________________________     *
  106. ;*   Address: Box 783               E-mail: xjeldc@ldc.lu.se         *
  107. ;*            S-220 07 LUND    Earn/Bitnet: xjeldc@seldc52         *
  108. ;*            SWEDEN          (Span/Hepnet: Sweden::Gemini::xjeldc)     *
  109. ;*    Office: Soelvegatan 18        VAXPSI: psi%24020031020720::xjeldc     *
  110. ;* Telephone: +46 46 107458         (X.400: C=se; A=TeDe; P=Sunet; O=lu; *
  111. ;*   Telefax: +46 46 138225                 OU=ldc; S=Engvald; G=Jan)     *
  112. ;*     Telex: 33533 LUNIVER S                         *
  113. ;*                                      *
  114. ;*************************************************************************
  115.  
  116. ;************************************************************************
  117. ;*        Compile time constants                                  *
  118. ;************************************************************************
  119.  
  120. DEBUG        equ    0
  121. IDSTRING    equ    'PDCLKSET ver 0.85beta'
  122.  
  123. HR        equ    60*60            ; seconds in an hour
  124.  
  125. SUN        equ    0            ; Sunday
  126. SAT        equ    6            ; Saturday
  127. DAT        equ    0ffh            ; Specific date follows
  128.  
  129. JANLW        equ    31                ; Jan last week
  130. FEB2W        equ    31+2*7                ; Feb 2nd week
  131. MAR1W        equ    31+28+1*7            ; Mar 1st week
  132. MAR2W        equ    31+28+2*7            ; Mar 2nd week
  133. MAR3W        equ    31+28+3*7            ; Mar 2rd week
  134. MARLW        equ    31+28+31            ; Mar last week
  135. APR01        equ    31+28+31+1            ; Apr 1
  136. APR1W        equ    31+28+31+1*7            ; Apr 1st week
  137. APR2W        equ    31+28+31+2*7            ; Apr 2nd week
  138. APR12        equ    31+28+31+12            ; Apr 12
  139. APR3W        equ    31+28+31+3*7            ; Apr 3rd week
  140. APRNL        equ    31+28+31+30-7            ; Apr next last week
  141. APRLW        equ    31+28+31+30            ; Apr last week
  142. MAY01        equ    31+28+31+30+1            ; May 1
  143. MAY1W        equ    31+28+31+30+1*7            ; May 1st week
  144. MAY2W        equ    31+28+31+30+2*7            ; May 2nd week
  145. AUG4W        equ    31+28+31+30+31+30+31+4*7    ; Aug 4th week
  146. SEP1W        equ    31+28+31+30+31+30+31+31+1*7    ; Sep 1st week
  147. SEP12        equ    31+28+31+30+31+30+31+31+12    ; Sep 12
  148. SEP2W        equ    31+28+31+30+31+30+31+31+2*7    ; Sep 2nd week
  149. SEP3W        equ    31+28+31+30+31+30+31+31+3*7    ; Sep 3rd week
  150. SEPLW        equ    31+28+31+30+31+30+31+31+30    ; Sep last week
  151. SEP30        equ    31+28+31+30+31+30+31+31+30    ; Sep 30
  152. OCT01        equ    31+28+31+30+31+30+31+31+30+1    ; Oct 1
  153. OCT1W        equ    31+28+31+30+31+30+31+31+30+1*7    ; Oct 1st week
  154. OCT2W        equ    31+28+31+30+31+30+31+31+30+2*7    ; Oct 2nd week
  155. OCT3W        equ    31+28+31+30+31+30+31+31+30+3*7    ; Oct 3rd week
  156. OCT24        equ    31+28+31+30+31+30+31+31+30+24    ; Oct 18 - 24
  157. OCT4W        equ    31+28+31+30+31+30+31+31+30+4*7    ; Oct 4th week
  158. OCT29        equ    31+28+31+30+31+30+31+31+30+29    ; Oct 23 - 29
  159. OCTLW        equ    31+28+31+30+31+30+31+31+30+31        ; Oct last week
  160. NOV13        equ    31+28+31+30+31+30+31+31+30+31+13    ; Nov 5 - 13
  161. DEC01        equ    31+28+31+30+31+30+31+31+30+31+30+1    ; Dec 1
  162. DEC2W        equ    31+28+31+30+31+30+31+31+30+31+30+2*7    ; Dec 2nd week
  163.  
  164. AlgE        struc
  165. AlgName        db    "EUR "            ; Name of dst algorithm
  166. AlgFromTime    dw    2*HR            ; local standard time dst start
  167. AlgFromWeekDay    dw    SUN            ; weekday dst start
  168. AlgFromWeek    dw    MARLW            ; last day-of-year dst start
  169. AlgUntilTime    dw    2*HR            ; local standard time dst end
  170. AlgUntilWeekDay    dw    SUN            ; weekday dst end
  171. AlgUntilWeek    dw    SEPLW            ; last day-of-year dst end
  172. AlgAddAmount    dw    1*HR            ; dst advance amount
  173. AlgEntryLen    =    $-AlgName
  174. AlgE        ends
  175.  
  176. AlgData        struc
  177. APac AlgE <"PACP", 2*HR,SUN,OCTLW, 1*HR,SUN,NOV13, HR>    ; Pacific presidential
  178. AUSA AlgE <"USA ", 2*HR,SUN,APR1W, 1*HR,SUN,OCTLW, HR>    ; USA Canada Mexico
  179. ACub AlgE <"CUB ", 0*HR,SUN,MAY2W,-1*HR,SUN,OCT2W, HR>    ; Cuba
  180. AChl AlgE <"CHIL", 0*HR,SUN,OCT2W,-1*HR,SUN,MAR2W, HR>    ; Chile
  181. ABrz AlgE <"BRZ ", 2*HR,SAT,OCT4W, 1*HR,SAT,FEB2W, HR>    ; Brazil
  182. AGBR AlgE <"GBR ", 1*HR,SUN,MARLW, 1*HR,SUN,OCT29, HR>    ; United Kingdom
  183. AWEu AlgE <"W_EU", 1*HR,SUN,MARLW, 1*HR,SUN,SEPLW, HR>    ; West Europe
  184. AMEu AlgE <"M_EU", 2*HR,SUN,MARLW, 2*HR,SUN,SEPLW, HR>    ; Central Europe + SU
  185. AEEu AlgE <"E_EU", 3*HR,SUN,MARLW, 3*HR,SUN,SEPLW, HR>    ; East Europe
  186. ALby AlgE <"LIBY", 2*HR,DAT,APR01, 1*HR,DAT,SEP30, HR>    ; Libya
  187. AEgy AlgE <"EGY ", 2*HR,DAT,MAY01, 1*HR,DAT,OCT01, HR>    ; Egypt
  188. ATur AlgE <"TURK", 1*HR,SUN,MARLW, 0*HR,SUN,SEPLW, HR>    ; Turkey
  189. AIsr AlgE <"ISR ", 2*HR,SUN,APR3W, 1*HR,SAT,AUG4W, HR>    ; Israel
  190. AIra AlgE <"IRAN", 2*HR,SUN,MARLW, 1*HR,SUN,SEP3W, HR>    ; Iran
  191. APRC AlgE <"PRC ", 2*HR,SUN,APR2W, 2*HR,SUN,SEP2W, HR>    ; People Rep of China
  192. AROK AlgE <"ROK ", 2*HR,SUN,MAY2W, 2*HR,SUN,OCT2W, HR>    ; Rep of Korea
  193. AAus AlgE <"AUS ", 2*HR,SUN,OCT24, 2*HR,SUN,MAR3W, HR>    ; South Australia
  194. ANSW AlgE <"NSW ", 2*HR,SUN,OCTLW, 2*HR,SUN,MAR3W, HR>    ; New South Wales
  195. ANZe AlgE <"NZE ", 2*HR,SUN,OCTLW, 2*HR,SUN,MAR1W, HR>    ; New Zealand
  196. AlgData        ends
  197.  
  198. ;************************************************************************
  199.  
  200.  
  201.