home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / iniser04.zip / server.zip / iniserve.INF (.txt) < prev    next >
OS/2 Help File  |  1999-11-11  |  29KB  |  905 lines

  1.  
  2. ΓòÉΓòÉΓòÉ 1. Introduction ΓòÉΓòÉΓòÉ
  3.  
  4. INIServe is a server application that allows a remote client to edit INI file 
  5. entries on the machine on which INIServe is running.  It is distributed as 
  6. freeware. This documentation is for version 0.4. 
  7.  
  8. Disclaimer of Warranty 
  9.  
  10.       This Product is provided "as-is", without warranty of any kind, either 
  11.       expressed or implied, including, but not limited to, the implied 
  12.       warranties of merchantability and fitness for a particular purpose.  The 
  13.       entire risk as to the quality and performance of the Product is with you. 
  14.       Should the Product prove defective, the full cost of repair, servicing, 
  15.       or correction lies with you. 
  16.  
  17.  The author of INIServe is Peter Moylan, peter@ee.newcastle.edu.au. 
  18.  
  19.  The latest version of INIServe is normally kept at 
  20.  ftp://eepjm.newcastle.edu.au/software 
  21.  Information about other software on this site may be found at 
  22.  http://eepjm.newcastle.edu.au/os2/software.html. 
  23.  
  24.  I keep a mailing list of people who receive e-mail notification of new 
  25.  versions of my software.  If you want to be put on this list, let me know by 
  26.  e-mail to peter@ee.newcastle.edu.au. The mailing list is not used for any 
  27.  other purposes, and the addresses will not be passed on to anyone else. 
  28.  
  29.  
  30. ΓòÉΓòÉΓòÉ 2. What is it for? ΓòÉΓòÉΓòÉ
  31.  
  32. One of the most common ways for an OS/2 program to store its configuration data 
  33. is in an INI file. This means that you can, in many cases, alter the program 
  34. options by editing the program's INI file. There are, in fact, several INI 
  35. editors available to let you do just that. 
  36.  
  37. Normally you wouldn't work directly with the INI file, because developers 
  38. generally consider INI data to be internal detail that's not properly 
  39. documented for the end user. Most typically these data are manipulated either 
  40. via "setup" options in the program itself, or by a configuration utility 
  41. supplied by the program's author. It is sufficient that the author of the 
  42. software knows what's in the INI file. 
  43.  
  44. There is one situation where it can be difficult to change a program's 
  45. configuration options, and that is where the manager is trying to look after 
  46. the software across a network. A way around the problem is to use a 
  47. client-server approach to INI editing, and that's where INIServe comes in. 
  48. INIServe, which runs on the machine where the INI file is located, provides the 
  49. server end of the connection. All that is needed is a client to run at the 
  50. other end. 
  51.  
  52. When you received the INIServe package, you probably also received a 
  53. demonstration client that is a remote INI file editor. This is intended only as 
  54. a demonstration. The long-term aim is that application-specific clients be 
  55. written, preferably by the authors of the software that owns the INI file. 
  56.  
  57. The protocol for the commands accepted by INIServe has been deliberately kept 
  58. simple, so that it is easy to write client software. Any existing "setup" 
  59. software that manipulates INI files via operating system API calls should be 
  60. able to be modified, with relatively little effort, to instead use INIServe 
  61. commands to read and write INI data. 
  62.  
  63.  
  64. ΓòÉΓòÉΓòÉ 3. The contents of an INI file ΓòÉΓòÉΓòÉ
  65.  
  66. An INI file is a place where a program can store just about any data that it 
  67. likes. Typically it is used to store information that the program needs to 
  68. retain from one invocation to the next: screen location, fonts, 
  69. user-configurable options, and the like. You wouldn't want to use it to store a 
  70. huge database - that could be inefficient - but an INI file is the ideal place 
  71. to store those little bits of information that aren't big enough to deserve a 
  72. file of their own. 
  73.  
  74. Internally, the file is a binary file, and I don't plan to tell you about the 
  75. precise internal structure. (In fact I've never looked this up, although I 
  76. believe it's documented somewhere on Hobbes.) The important thing is that OS/2 
  77. provides API calls that let a programmer read and write INI file entries. 
  78.  
  79. Conceptually, each entry is a triple (application,key,value), where the 
  80. application and key are character strings that are usually human-readable. You 
  81. can think of this as a two-level hierarchy. The INI file holds data for a 
  82. number of different applications; each application can have a number of keys; 
  83. and associated with each key there is a value, which is the thing the program 
  84. actually wants to read. 
  85.  
  86. Historically, there was probably an intention to have all programs save their 
  87. INI data in one huge "user INI file", and in that case the "application" part 
  88. of the triple would have identified the program owning that part of the data. 
  89. These days we've learnt that concentrating all the important data in a single 
  90. central registry is bad design - it leaves the system vulnerable to damage by a 
  91. single misbehaving program - so there's more of a tendency to use a separate 
  92. INI file for each program. This being the case, it would be logical to rename 
  93. the "application" to something like "section label", since it doesn't identify 
  94. an application in many cases; but we continue to call it the "application" in 
  95. order to be consistent with the existing documentation. 
  96.  
  97. The "value" part of the entry can be anything at all, depending on the needs of 
  98. the programmer who is using the INI file. It can be something as simple as a 
  99. one-byte binary value; it could also be a character string, with or without a 
  100. null terminating byte; or it could be a complex record whose internal structure 
  101. is known only to the programmer. 
  102.  
  103. The meaning of INI file data is usually not documented, because programmers 
  104. tend to see it as internal implementation detail. Before modifying anything in 
  105. an INI file, make sure that you understand what the modification will do. 
  106.  
  107.  
  108. ΓòÉΓòÉΓòÉ 4. A functional overview of the INIServe commands ΓòÉΓòÉΓòÉ
  109.  
  110. The INIServe protocol is intentionally very simple. Every command is a single 
  111. letter, followed (without any spaces) by a parameter if necessary. Some 
  112. commands have no parameters, so the single letter is the entire command. Some 
  113. other commands have a single character string as a parameter. The parameter for 
  114. the W command is a string of bytes, where each byte is expressed as a two-digit 
  115. hexadecimal number. The most complicated case is the O command, which has two 
  116. numeric parameters separated by a comma. 
  117.  
  118. The command must be terminated by an ASCII carriage return followed by an ASCII 
  119. line feed. 
  120.  
  121. The server sends back a response to each command. There are two kinds of 
  122. response. 
  123.  
  124.      If the command failed or was rejected, the response starts with the '-' 
  125.       character, and this might be followed by a plain-text error message. 
  126.  
  127.      If the command was successful, the first character of the response is the 
  128.       '+' character, and then the data follows if this is the sort of command 
  129.       that returns data. Most commands don't return anything except the '+' or 
  130.       '-'; the exceptions are: 
  131.  
  132.         -  The S and T commands produce a numeric reply, and this comes as a 
  133.            hexadecimal number immediately after the '+'. 
  134.  
  135.         -  The V command produces a byte string as the reply, and this is in 
  136.            the form of a long hexadecimal number, immediately after the '+', 
  137.            where each two hexadecimal characters represent one byte. 
  138.  
  139.         -  The L command is a special case, producing a multi-line reply. This 
  140.            is the only case where the reply is more than one line long. 
  141.  
  142.  Every response line is terminated with a carriage return and line feed. 
  143.  
  144.  The following pages describe the steps you would go through in a single 
  145.  INIServe session. For more precise details, refer to the alphabetical list of 
  146.  commands later in this manual. 
  147.  
  148.      Logging in 
  149.      Choosing a file to edit 
  150.      Finding out what applications and keys are present 
  151.      Checking the size of an entry 
  152.      Reading a value 
  153.      Adding or modifying an entry 
  154.      Deleting an entry 
  155.      Logging out 
  156.  
  157.  
  158. ΓòÉΓòÉΓòÉ 4.1. Logging in ΓòÉΓòÉΓòÉ
  159.  
  160. To start a session, the client must connect to the destination machine using 
  161. the TCP port on which INIServe is listening. The default port number is 8000, 
  162. but this can be changed by altering an entry in INIServe.INI. 
  163.  
  164. The server replies with a confirmation line; that is, a line starting with the 
  165. '+' character. 
  166.  
  167. The client should then give a password with the 'P' command, for example 
  168.  
  169.        Psecret
  170.  
  171. If the password is correct, the server replies with another confirmation line, 
  172. and the client is then able to issue other commands. The default password is 
  173. the empty string, but this can be changed by changing the password in 
  174. INIServe.INI. 
  175.  
  176.  
  177. ΓòÉΓòÉΓòÉ 4.2. Choosing a file to edit ΓòÉΓòÉΓòÉ
  178.  
  179. Three commands are useful here. The L command gives a listing of the current 
  180. directory. The C command is a "change directory" command. Finally, the F 
  181. command specifies a file name; this should be the name of an INI file, of 
  182. course. 
  183.  
  184. The parameter for the C and F commands can be either an absolute path, or a 
  185. path relative to the current directory. Initially the "current directory" is a 
  186. pseudo-directory containing the names of all accessible drives. 
  187.  
  188. The information returned by the L command does not indicate whether any given 
  189. entry is a directory or a non-directory file. An easy way to check this is to 
  190. issue a C command to change to that entry. If the name is the name of a file 
  191. rather than of a directory, then the C command will result in a '-' failure 
  192. indication; and then you can, if desired, issue an F command with the same 
  193. parameter. 
  194.  
  195. If you know the full filename, including drive and directory, for the file to 
  196. be worked on, then you can of course give it directly in the F command. In this 
  197. case the L and C commands are unnecessary. 
  198.  
  199.  
  200. ΓòÉΓòÉΓòÉ 4.3. Finding out what applications and keys are present ΓòÉΓòÉΓòÉ
  201.  
  202. The A command is for specifying an application, and the K command is for 
  203. specifying a key. After you've given these two commands, you are ready to read 
  204. the existing value, or write a new value. But what if you don't know what 
  205. applications and/or keys exist in the INI file? 
  206.  
  207. If you specify an empty string as the application - that is, if you use the A 
  208. command with no parameter - and then use the V command, the value returned is a 
  209. hexadecimal string that should be interpreted as follows: 
  210.  
  211.    1. Each two hexadecimal characters represents one byte, with the obvious 
  212.       encoding, so the hexadecimal string can be turned into a byte string. 
  213.    2. Considering the byte values as ASCII character codes, the result can 
  214.       further be interpreted as a character string. 
  215.    3. The character string is in fact a sequence of substrings, where each 
  216.       substring is terminated by a zero byte. (The last substring is terminated 
  217.       with two zero bytes, one to end the substring and the other to mark the 
  218.       end of the sequence.) Each of those substrings will turn out to be the 
  219.       name of one application. 
  220.  
  221.  In summary, specifying the empty string as the application will give you a 
  222.  result, when you read the value, which is a list of all applications in that 
  223.  INI file. 
  224.  
  225.  Likewise, you can get a list of all keys, for a given application, by 
  226.  specifying a real application but setting the key to the empty string with the 
  227.  K command. 
  228.  
  229.  
  230. ΓòÉΓòÉΓòÉ 4.4. Checking the size of an entry ΓòÉΓòÉΓòÉ
  231.  
  232. The S command asks how many bytes there are in a particular INI file entry. Use 
  233. the A and K commands to set the application and key, and then give the S 
  234. command (with no parameters). The reply is a + sign followed by a hexadecimal 
  235. number. 
  236.  
  237. Depending on how the client software is designed, there might be some 
  238. situations where an entry is too big to be read or written in one piece. The O 
  239. command tells the server that you want to pick up the data in limited-size 
  240. chunks. It has two parameters, an offset and a limit. The offset says how far 
  241. from the beginning of an item we should start. (For example, if the offset is 
  242. 10 when you issue a V command, then the V command skips the first 10 bytes of 
  243. the current entry.) The second parameter, the limit, specifies a maximum number 
  244. of bytes that can be returned by the V command. 
  245.  
  246. Initially, and also after you give an O command with no parameters, the offset 
  247. is zero and the limit is the largest possible 32-bit number. In effect, there 
  248. is initially no offset or limit. 
  249.  
  250. The T command is like the S command, except that it takes the offset and limit 
  251. into account, and tells you the number of bytes that would actually be returned 
  252. as a response to the V command. 
  253.  
  254.  
  255. ΓòÉΓòÉΓòÉ 4.5. Reading a value ΓòÉΓòÉΓòÉ
  256.  
  257. To read an INI file entry, you use the A and K commands to specify the 
  258. application and key, and then you give the V command to get the value. The 
  259. response to the V command is a + sign followed by a long string of hexadecimal 
  260. digits. Each pair of hexadecimal digits gives the value of one byte. 
  261.  
  262. As noted in the previous subsection, the behaviour of the V command is affected 
  263. by the offset and limit specified by the most recent O command. In particular, 
  264. the V command will never return more bytes than specified by the limit, even if 
  265. there are more bytes than that in the INI file entry. To get the missing part, 
  266. if any, you have to give a new O command with a larger offset. 
  267.  
  268.  
  269. ΓòÉΓòÉΓòÉ 4.6. Adding or modifying an entry ΓòÉΓòÉΓòÉ
  270.  
  271. The W command is for writing data. First you give the A and K commands to 
  272. specify the application and key, then you give the W command. The letter W 
  273. should be followed by an even number of hexadecimal digits. Each pair of digits 
  274. gives the value of one byte. 
  275.  
  276. If the application/key pair already exists in the INI file, the new value 
  277. overwrites the existing entry. Otherwise, a new entry is created. 
  278.  
  279. If the O command has not been issued, then the length of the new entry is 
  280. exactly as long as the number of bytes specified in the W command. (Even if the 
  281. old entry was longer.) However, the offset and limit given by an O command 
  282. modify the action of the W command. What happens is that the new value overlays 
  283. the old value. (If there wasn't any old value, and you have a nonzero offset, 
  284. then you can end up with random rubbish.) The first "offset" bytes of the old 
  285. value remain unchanged; then you have the new values supplied with the W 
  286. command; and then, possibly, you have more bytes of the old value. 
  287.  
  288. Whether the "tail" is retained depends on the size of the new data relative to 
  289. the current limit. If the number of bytes supplied with the W command is 
  290. greater than or equal to the limit, then the server assumes that this is not 
  291. the final section of the data, i.e. it keeps the old data, if any, that stretch 
  292. more than (offset+N) bytes from the beginning of the value, where N is the 
  293. number of bytes supplied with the W command. If, on the other hand, the number 
  294. of bytes supplied with the W command is smaller than the limit, then the value 
  295. is truncated at that point. 
  296.  
  297.  
  298. ΓòÉΓòÉΓòÉ 4.7. Deleting an entry ΓòÉΓòÉΓòÉ
  299.  
  300. The D command tells the server to delete the INI file entry corresponding to 
  301. the current application and key, as set by the most recent A and K commands. 
  302.  
  303. If the K command specified an empty string, then all entries, for all keys 
  304. associated with the current application, are deleted. 
  305.  
  306. If the A command specified an empty string, then the D command is illegal. 
  307.  
  308.  
  309. ΓòÉΓòÉΓòÉ 4.8. Logging out ΓòÉΓòÉΓòÉ
  310.  
  311. When the client has finished working on the INI file(s), it should send the Q 
  312. command to terminate the current session. 
  313.  
  314.  
  315. ΓòÉΓòÉΓòÉ 5. Alphabetic list of commands ΓòÉΓòÉΓòÉ
  316.  
  317.     A<string>                  set application 
  318.  
  319.     C<string>                  change directory 
  320.  
  321.     D                          delete the current entry 
  322.  
  323.     F<string>                  select file to edit 
  324.  
  325.     K<string>                  set key 
  326.  
  327.     L                          list current directory 
  328.  
  329.     M<string>                  make directory 
  330.  
  331.     O<val>,<val>               set offset and limit (for V and W commands) 
  332.  
  333.     P<string>                  password 
  334.  
  335.     Q                          quit 
  336.  
  337.     S                          return size of current item 
  338.  
  339.     T                          return truncated size of current item 
  340.  
  341.     V                          return value of current item 
  342.  
  343.     W<hexdata>                 store new value for current item 
  344.  
  345.  The parameters, if any, for the commands come immediately after the command 
  346.  letter, with no intervening space. The possible parameter types are as 
  347.  follows. 
  348.  
  349.  <string> 
  350.            A character string specifying a file name, a password, etc. 
  351.  
  352.  <val> 
  353.            A number, expressed in hexadecimal. 
  354.  
  355.  <hexdata> 
  356.            A byte sequence of arbitrary length, where each byte is specified by 
  357.            exactly two hexadecimal digits. 
  358.  
  359.  The command must be terminated by a carriage return and line feed. 
  360.  
  361.  
  362. ΓòÉΓòÉΓòÉ <hidden> <string> ΓòÉΓòÉΓòÉ
  363.  
  364.  A <string> is a sequence of characters in human-readable form. It should not 
  365. include the null character (the character with code 0). It is legal to have an 
  366. empty string, i.e. a string of zero length. 
  367.  
  368.  
  369. ΓòÉΓòÉΓòÉ <hidden> <val> ΓòÉΓòÉΓòÉ
  370.  
  371.  A <val> is a single unsigned 32-bit integer expressed in hexadecimal. The 
  372. value must be in the range 0 to FFFFFFFF. 
  373.  
  374.  
  375. ΓòÉΓòÉΓòÉ <hidden> <hexdata> ΓòÉΓòÉΓòÉ
  376.  
  377.  This is a byte sequence of arbitrary length, where each byte is specified by 
  378. exactly two hexadecimal digits. 
  379.  
  380.  
  381. ΓòÉΓòÉΓòÉ 5.1. The A command: set Application ΓòÉΓòÉΓòÉ
  382.  
  383. Form 
  384.  
  385.    A<string> 
  386.  
  387. Reply 
  388.  
  389.     +      if the command was successful 
  390.     -      if the command failed 
  391.  
  392.  Example 
  393.  
  394.     AProg1 
  395.  
  396.  Discussion 
  397.  
  398.  To read or write an INI file entry, you must first specify an application and 
  399.  key. The usual way to do this is to send an A command, then a K command, and 
  400.  then the command to read or write the value. 
  401.  
  402.  The application name specified in this command remains in force until the next 
  403.  A command. 
  404.  
  405.  
  406. ΓòÉΓòÉΓòÉ 5.2. The C command: Change directory ΓòÉΓòÉΓòÉ
  407.  
  408. Form 
  409.  
  410.    C<string> 
  411.  
  412. Reply 
  413.  
  414.     +      if the command was successful 
  415.     -      if the command failed 
  416.  
  417.  Example 
  418.  
  419.     C.. 
  420.  
  421.  Discussion 
  422.  
  423.  The letter C is followed by a directory name, and this can either be a 
  424.  complete path (e.g. D:\uvw\xyz) or a name relative to the current directory 
  425.  (e.g. xyz or ..). You can use this command - multiple times, if desired - to 
  426.  walk through the directory tree on the target machine until you reach the 
  427.  directory containing the INI file that you want to work on. 
  428.  
  429.  Before the first C command, the "current directory" is a hypothetical 
  430.  top-level directory containing all the drives on the system.  Normally, then, 
  431.  your first C command would be something like "CE:" to select a drive. 
  432.  
  433.  Hint: after obtaining a file listing with the L command, you usually can't 
  434.  tell whether any given entry is a subdirectory or an ordinary file. One way to 
  435.  tell is to use a C command and see whether there is a failure response. 
  436.  
  437.  The "current directory" set by this command remains in force until the next C 
  438.  command, if any. If a C command fails, the current directory is unchanged. 
  439.  
  440.  
  441. ΓòÉΓòÉΓòÉ 5.3. The D command: Delete the current entry ΓòÉΓòÉΓòÉ
  442.  
  443. Form 
  444.  
  445.    D 
  446.  
  447. Reply 
  448.  
  449.     +      if the command was successful 
  450.     -      if the command failed 
  451.  
  452.  Example 
  453.  
  454.     D 
  455.  
  456.  Discussion 
  457.  
  458.  The D command has no parameters. It causes the current INI file entry, as 
  459.  specified by the most recent A and K commands, to be deleted. 
  460.  
  461.  If the current key is the empty string, then all keys and values for the 
  462.  current entry are deleted. 
  463.  
  464.  If the current application is the empty string, the command will fail. 
  465.  
  466.  
  467. ΓòÉΓòÉΓòÉ 5.4. The F command: select File to edit ΓòÉΓòÉΓòÉ
  468.  
  469. Form 
  470.  
  471.    F<string> 
  472.  
  473. Reply 
  474.  
  475.     +      if the command was successful 
  476.     -      if the command failed 
  477.  
  478.  Example 
  479.  
  480.     Fweasel.INI 
  481.  
  482.  Discussion 
  483.  
  484.  This is in effect the "open file" operation that the client must do before 
  485.  reading or writing INI file entries. The file name after the F can either be a 
  486.  complete path string, or a name relative to the directory that was most 
  487.  recently set by the C command. 
  488.  
  489.  Physically, this does not open the file. It simply sets the name of the file 
  490.  to be worked on. For safety, the server opens and re-closes the file for every 
  491.  operation on the file; this is mildly inefficient, but it ensures that the INI 
  492.  file remains in a well-defined state even if the INIServe session is aborted 
  493.  because of something like a communications failure. 
  494.  
  495.  The "current file" set by this command remains in force until the next F 
  496.  command, if any. 
  497.  
  498.  
  499. ΓòÉΓòÉΓòÉ 5.5. The K command: set Key ΓòÉΓòÉΓòÉ
  500.  
  501. Form 
  502.  
  503.    K<string> 
  504.  
  505. Reply 
  506.  
  507.     +      if the command was successful 
  508.     -      if the command failed 
  509.  
  510.  Example 
  511.  
  512.     KPassword 
  513.  
  514.  Discussion 
  515.  
  516.  To read or write an INI file entry, you must first specify an application and 
  517.  key. The usual way to do this is to send an A command, then a K command, and 
  518.  then the command to read or write the value. 
  519.  
  520.  The key name specified in this command remains in force until the next K 
  521.  command. 
  522.  
  523.  
  524. ΓòÉΓòÉΓòÉ 5.6. The L command: List current directory ΓòÉΓòÉΓòÉ
  525.  
  526. Form 
  527.  
  528.    L 
  529.  
  530. (Note that this command has no parameters.) 
  531.  
  532. Reply 
  533.  
  534. This command produces a multi-line reply, where each line is terminated by a 
  535. carriage return and line feed. 
  536.  
  537. The first line contains the single character '+'. 
  538.  
  539. Each of the following lines, except for the last, lists one file name. That is, 
  540. the current directory is listed with one line per entry. Only the names are 
  541. given, not other details such as date and file size. 
  542.  
  543. The final line is empty, i.e. it contains nothing except the terminating 
  544. carriage return and line feed. This is to mark the end of the reply. 
  545.  
  546. Example 
  547.  
  548.    L 
  549.  
  550. If the current directory contained two files called "file1" and "mydata", then 
  551. the response from the server would be 
  552.  
  553.       +<CR><LF>
  554.       file1<CR><LF>
  555.       mydata<CR><LF>
  556.       <CR><LF>
  557.  
  558. Discussion 
  559.  
  560. Note that, at least in the current version, there is no failure response: the 
  561. command always succeeds. In the case of an error like selecting a nonexistent 
  562. directory, the L command simply returns an empty directory listing. 
  563.  
  564.  
  565. ΓòÉΓòÉΓòÉ 5.7. The M command: Make directory ΓòÉΓòÉΓòÉ
  566.  
  567. Form 
  568.  
  569.    M<string> 
  570.  
  571. Reply 
  572.  
  573.     +      if the command was successful 
  574.     -      if the command failed 
  575.  
  576.  Example 
  577.  
  578.     Msubdir 
  579.  
  580.  Discussion 
  581.  
  582.  The letter M is followed by a directory name, and this can either be a 
  583.  complete path (e.g. D:\uvw\xyz) or a name relative to the current directory 
  584.  (e.g. xyz). You can use this command to create a new directory on the target 
  585.  machine. (If the directory already exists, the command fails and the directory 
  586.  is left unchanged.) 
  587.  
  588.  
  589. ΓòÉΓòÉΓòÉ 5.8. The O command: set Offset and limit ΓòÉΓòÉΓòÉ
  590.  
  591. Form 
  592.  
  593.    O<val>,<val> 
  594.  
  595. Reply 
  596.  
  597.     +      if the command was successful 
  598.     -      if the command failed 
  599.  
  600.  Example 
  601.  
  602.     OF8,40 
  603.  
  604.  This sets the offset to F8 hexadecimal (248 decimal) and the limit to 40 
  605.  hexadecimal (64 decimal). 
  606.  
  607.  Discussion 
  608.  
  609.  If you deal only with INI file entries that are short, you will never need the 
  610.  O command. It is there to handle the possibility of entries that are too large 
  611.  to fit in a client's data buffer, so that you have to work with substrings of 
  612.  the data. 
  613.  
  614.  The offset and limit defined by the O command affect future V and W commands 
  615.  that read and write data. The offset says how many bytes are ahead of the 
  616.  chunk of data being dealt with by V and W. The limit is an upper bound on how 
  617.  many bytes will be read by a V command. The initial defaults are an offset of 
  618.  zero, and a limit which is the largest possible 32-bit number. 
  619.  
  620.  Suppose, for example, that you have to deal with an INI file entry that is 
  621.  1024 bytes long, but that buffer size restrictions mean that you can't deal 
  622.  with more than 128 bytes at a time. In this case you would set the offset to 0 
  623.  and the limit to 128, and process the first 128 bytes of the data. Then you 
  624.  would set the offset to 128 (leaving the limit at 128) to process the next 128 
  625.  bytes. Next, you would set the offset to 256 (still with the limit set at 
  626.  128), and so on. 
  627.  
  628.  If an O command is received and only one numeric parameter is supplied, then 
  629.  the other one reverts to its default value: a zero offset, or a very large 
  630.  limit, depending on which parameter is missing. 
  631.  
  632.  The offset and limit specified in this command remain in force until the next 
  633.  O command. 
  634.  
  635.  
  636. ΓòÉΓòÉΓòÉ 5.9. The P command: supply a Password ΓòÉΓòÉΓòÉ
  637.  
  638. Form 
  639.  
  640.    P<string> 
  641.  
  642. Reply 
  643.  
  644.     +      if the password was accepted 
  645.     -      if the password was rejected 
  646.  
  647.  Example 
  648.  
  649.     Psecret 
  650.  
  651.  Discussion 
  652.  
  653.  The P command should be the first command sent by the client. Until the client 
  654.  has supplied a valid password, no commands except P and Q will be accepted. 
  655.  
  656.  When the server is first installed, the initial password is the empty string, 
  657.  so the correct way to log in is with a P followed directly by a carriage 
  658.  return and line feed. You should of course change this as soon as possible. 
  659.  Malicious clients could use INIServe to read or even alter important system 
  660.  settings. The way to stop this is to use a password that nobody knows except 
  661.  you. 
  662.  
  663.  The password can be up to 32 characters long, and it is case-sensitive. It can 
  664.  contain any character except the null character. 
  665.  
  666.  
  667. ΓòÉΓòÉΓòÉ 5.10. The Q command: Quit ΓòÉΓòÉΓòÉ
  668.  
  669. Form 
  670.  
  671.    Q 
  672.  
  673. (Note that this command has no parameters.) 
  674.  
  675. Reply 
  676.  
  677. The reply will always be the single character '+' (followed, of course, by a 
  678. carriage return and line feed) to indicate successful completion. The server 
  679. will never reject this command, unless of course it is so badly corrupted by 
  680. transmission errors that the server does not see the Q. 
  681.  
  682. Example 
  683.  
  684.    Q 
  685.  
  686. Discussion 
  687.  
  688. This is the "log out" command, and it should be the last command issued by a 
  689. client. 
  690.  
  691.  
  692. ΓòÉΓòÉΓòÉ 5.11. The S command: return Size of current item ΓòÉΓòÉΓòÉ
  693.  
  694. Form 
  695.  
  696.    S 
  697.  
  698. (Note that this command has no parameters.) 
  699.  
  700. Reply 
  701.  
  702. If the size of the current item cannot be determined (usually because the INI 
  703. file doesn't exist) then the reply is the failure code '-'. Otherwise, the 
  704. reply is the single character '+' followed by a hexadecimal number. This number 
  705. is the length, in bytes, of the INI data specified by the current application 
  706. and key, i.e. specified by the most recent A and K commands. 
  707.  
  708. Example 
  709.  
  710.    S 
  711.  
  712. The reply to this would be something like "+2E" (without the quote marks, and 
  713. terminated by a carriage return and line feed). Note that the answer is always 
  714. given in hexadecimal. 
  715.  
  716. Discussion 
  717.  
  718. The size reported by this command is always the full size of the item. The 
  719. answer is not affected by any previous O command. (If you want an answer that 
  720. does depend on the O command parameters, use the T command.) 
  721.  
  722. If the current application or the current key is the empty string, then 
  723. strictly speaking there should be no value to return. In fact the V command 
  724. does return an answer in this case - see the description of special cases for 
  725. the V command - and the S command reports how many bytes would be returned. 
  726.  
  727.  
  728. ΓòÉΓòÉΓòÉ 5.12. The T command: return Truncated size of current item ΓòÉΓòÉΓòÉ
  729.  
  730. Form 
  731.  
  732.    T 
  733.  
  734. (Note that this command has no parameters.) 
  735.  
  736. Reply 
  737.  
  738. If the size of the current item cannot be determined (usually because the INI 
  739. file doesn't exist) then the reply is the failure code '-'. Otherwise, the 
  740. reply is the single character '+' followed by a hexadecimal number. This number 
  741. is the length, in bytes, of the data that would be returned by the V command. 
  742.  
  743. Example 
  744.  
  745.    T 
  746.  
  747. The reply to this would be something like "+20" (without the quote marks, and 
  748. terminated by a carriage return and line feed). Note that the answer is always 
  749. given in hexadecimal. 
  750.  
  751. Discussion 
  752.  
  753. This command is almost exactly the same as the S command. The difference is 
  754. that the S command is not affected by any previous O command, while the answer 
  755. returned for the T command is modified by the offset and limit set by the most 
  756. recent O command. The result of the T command tells you how many data bytes 
  757. will be returned by the next V command (always assuming, of course, that you 
  758. don't issue a new A or K command before the V). The S command, on the other 
  759. hand, tells you how many bytes would have been returned if you hadn't used an O 
  760. command to limit the size of the transfer. 
  761.  
  762.  
  763. ΓòÉΓòÉΓòÉ 5.13. The V command: return Value of current item ΓòÉΓòÉΓòÉ
  764.  
  765. Form 
  766.  
  767.    V 
  768.  
  769. Reply 
  770.  
  771. If the current item cannot be determined (usually because the INI file doesn't 
  772. exist) then the reply is the failure code '-'. Otherwise, the reply is the 
  773. single character '+' followed by N bytes of data, where each byte is specified 
  774. as a two-digit hexadecimal number. The total number of characters in the reply 
  775. is 2N+3; 2N characters for the N bytes of data, one more for the '+', and two 
  776. for the carriage return and line feed that terminate the line. 
  777.  
  778. For the value of N, see the discussion below. 
  779.  
  780. Example 
  781.  
  782.    V 
  783.  
  784. If the current item is a four-byte value, then the reply would be something 
  785. like 
  786.  
  787.     +00014F37<cr><lf> 
  788.  
  789. Discussion 
  790.  
  791. If the O command has not been issued, so that the offset is 0 and the limit is 
  792. very large, the result is precisely the current item, however many bytes that 
  793. might be. If the O command has been issued, then the value returned is the 
  794. value of the current item, truncated as follows. 
  795.  
  796.      First, the initial "offset" bytes of the value are removed. 
  797.  
  798.      If the string resulting from the first operation still has more than 
  799.       "limit" bytes, then the result is truncated so that only "limit" bytes 
  800.       are returned. Otherwise, all bytes, apart from the initial ones removed 
  801.       in the first step, are returned. 
  802.  
  803.  Special cases 
  804.  
  805.      If the current application name, as set by the A command, is the empty 
  806.       string, then what is returned is a list of all application names in this 
  807.       INI file. The result is still encoded in hexadecimal, with two 
  808.       hexadecimal digits per character, but after decoding this you will have a 
  809.       sequence of null-terminated character strings, where each character 
  810.       string is the name of one application. The end of the list is marked by 
  811.       an extra zero byte. 
  812.  
  813.      If the current application name is a valid application name, but the 
  814.       current key name, as set by the K command, is the empty string, then what 
  815.       is returned is a list of all key names for this application. The result 
  816.       is still encoded in hexadecimal, with two hexadecimal digits per 
  817.       character, but after decoding this you will have a sequence of 
  818.       null-terminated character strings, where each character string is the 
  819.       name of one key. The end of the list is marked by an extra zero byte. 
  820.  
  821.  You can use this information to deduce the set of all application/key pairs in 
  822.  the INI file. 
  823.  
  824.  
  825. ΓòÉΓòÉΓòÉ 5.14. The W command: Write new value for current item ΓòÉΓòÉΓòÉ
  826.  
  827. Form 
  828.  
  829.    W<hexdata> 
  830.  
  831. Reply 
  832.  
  833.     +      if the command was successful 
  834.     -      if the command failed 
  835.  
  836.  Example 
  837.  
  838.     W74657374696E6700 
  839.  
  840.  This would set the value of the current item to the null-terminated character 
  841.  string "testing". 
  842.  
  843.  Discussion 
  844.  
  845.  If the O command has not been issued, so that the current offset is 0 and the 
  846.  current limit is very large, then the byte string specified as the <hexdata> 
  847.  is stored as the value of the INI file entry for the current application and 
  848.  key (as set by the most recent A and K commands). This either creates a new 
  849.  entry or overwrites an existing entry, depending on whether an old value 
  850.  already existed for that application and key. The new entry does not have to 
  851.  have the same size as the old entry. 
  852.  
  853.  If an offset and limit have been set by the O command, then the new data 
  854.  supplied by the W command are overlaid over the original data. The first 
  855.  "offset" bytes remain as before, then the next N bytes (where N is the number 
  856.  of bytes supplied by the W command) are modified, and subsequent bytes if any 
  857.  remain unchanged. 
  858.  
  859.  Note that N, the number of bytes supplied by the W command, is not constrained 
  860.  by the current limit. The value of the limit is, however, used in deciding 
  861.  whether to shorten an existing entry. If N is greater than or equal to the 
  862.  limit, then later bytes are left unmodified, as described above. If N is 
  863.  strictly less than the current limit, then we assume that this is the last 
  864.  "chunk" of this value to be stored, and the value is truncated at that point. 
  865.  In this case the modified entry ends up being exactly (offset+N) bytes long. 
  866.  
  867.  If N and offset are both zero, the value stored is a byte string of zero 
  868.  length. This is legal, and it is not equivalent to deleting the current entry. 
  869.  
  870.  
  871. ΓòÉΓòÉΓòÉ 6. Installation ΓòÉΓòÉΓòÉ
  872.  
  873. Installation 
  874.  
  875. See also De-installation 
  876.  
  877. You should have received this package in the form of a zip file. To install it, 
  878. simply unzip the file into a directory of your choice. (Presumably you've 
  879. already done this.)  The server is now ready to run. 
  880.  
  881. The server itself is the program called INIServe.exe.  You can run it either by 
  882. double-clicking on the desktop icon, or by entering the command "iniserve" in a 
  883. command-line session.  If you want the server to be running all the time, then 
  884. you should probably create a shadow or program object to go into the startup 
  885. folder. 
  886.  
  887. The server can be run detached, if desired. In theory it can also be run from 
  888. inetd, but I've never tested that option. 
  889.  
  890. As supplied, the server uses an empty password and listens on port 8000. To 
  891. change these parameters, make the obvious changes to the file INIServe.INI. You 
  892. can use another INI file editor to do this, but it is also legal to use 
  893. INIServe to modify its own INI file. 
  894.  
  895. The file source.zip is optional.  If you're not interested in the source code, 
  896. you can delete it. 
  897.  
  898.  
  899. ΓòÉΓòÉΓòÉ 7. De-installation ΓòÉΓòÉΓòÉ
  900.  
  901. De-installation 
  902.  
  903. INIServe does not tamper with CONFIG.SYS or with other system files. If you 
  904. decide that you don't want to keep it, simply delete the directory into which 
  905. you installed it.