home *** CD-ROM | disk | FTP | other *** search
/ Beijing Paradise BBS Backup / PARADISE.ISO / software / BBSDOORW / RA-CDK03.ZIP / RACDK.DOC < prev    next >
Encoding:
Text File  |  1996-04-29  |  16.0 KB  |  391 lines

  1. Developer Manual
  2.  
  3.  
  4.  
  5.     RemoteAccess 'C' Developer Toolkit
  6.  
  7.     'C' Development code & examples for
  8.     programming RemoteAccess based BBS's
  9.  
  10.  
  11.     
  12.  
  13.  
  14.  
  15.      (c) Copyright 1996, Envy Technologies.
  16.  
  17.  
  18. Contents
  19. =========
  20.  
  21. Part 1    Introduction
  22.     Introduction to RACDK
  23.     Licence agreement
  24.     Revision history
  25.     Requirements
  26.     Setting up RACDK
  27.  
  28. Part 2    Using RACDK
  29.     Structures
  30.     Functions
  31.     Pascal string handling
  32.     General tips    
  33.     Examples
  34.  
  35. Appendix
  36.     Frequently asked questions
  37.     File summary
  38.     Contacting Envy Technologies
  39.     Future enhancements
  40.     Other sources
  41.     Credits & acknowledgements
  42.  
  43.  
  44. Introduction
  45. ============
  46.  
  47. Introduction to RACDK
  48. ---------------------
  49. The RemoteAccess 'C' Developer Kit (or RACDK), is a set of files to assist
  50. with developing applications for use with the popular bulletin-board package,
  51. RemoteAccess.
  52.  
  53. Currently included are the RemoteAccess structures converted to 'C' from
  54. Pascal, routines for converting Pascal strings to and from C strings,
  55. multitasking timeslicing, CRC calculations and a few examples to get you
  56. started.
  57.  
  58.  
  59. Licence agreement
  60. -----------------
  61. The RACDK package consists of all files contained within the distribution
  62. archive except for any parts described in Exclusions at the end of this
  63. section.  Before running RACDK, you must read and agree to the following
  64. conditions. If you do not or can not agree to and accept the following
  65. conditions, you are prohibited from using this package.
  66.  
  67. o    RACDK is copyrighted Damien Guard/Envy Technologies and may only be used
  68.     in accordance with the conditions set forth in this license agreement.
  69. o    RACDK is distributed as a FREEWARE package for this release.  This means 
  70.     that the software may be freely distributed and used but Envy Technologies
  71.      retains all copyrights on this package.  This licensing agreement does
  72.      not apply to any future releases which may be packaged with an
  73.      alternative licensing agreement.
  74. o    Permission is granted to any individual or institution to use, copy, or
  75.      redistribute RACDK free of charge as long as the distribution package is
  76.      not modified, nor sold for profit.
  77. o    RACDK may be used free of charge in private, shareware and commercial
  78.      packages but only as part of an executable binary in a compiled state.
  79.      No files contained in this package can be included as part of your
  80.      application in their native uncompiled state (.H etc).
  81. o    RACDK may not be licenced nor sub-licenced to any third party without
  82.      written permission of Envy Technologies.
  83. o    This licence agreement may not be modified nor supplemented without
  84.      written permission of Envy Technologies.
  85. o    Neither Damien Guard, nor Envy Technologies are obligated to provide new
  86.     versions or support for existing versions of RACDK even if a previous
  87.      version of this package is unusable.
  88. o    Although care has been taken to write and test a package that does what
  89.      this document states, the package is provided as is, without warranty or
  90.      guarantee of any kind, either expressed or implied, as to the quality or
  91.      performance of this package, except that RACDK will occupy disk space.
  92. o    Neither the author of RACDK, Damien Guard, nor the publisher, Envy 
  93.     Technologies are responsible for any (direct or indirect) damage or costs,
  94.      including, but not limited to, lost savings, lost profits and loss of
  95.      data, which may result from the use or the inability to use RACDK.
  96. o    The RACDK package may not be distributed in a modified form with the 
  97.     exception of other archive formats.  This applies to adverts which may
  98.      not be included as either a file, nor as a modification to an existing
  99.      .DIZ informational file.
  100. o    Any BBS/distribution adverts of any kind may only be included in the
  101.      archive banner.
  102. o    RACDK may be included on shareware CD's and floppy disks providing that
  103.      any charge levied is for the compilation and not expressly for RACDK.
  104. o    If you use this program, you will constitute your agreement to this
  105.      disclaimer/license.
  106. o    All rights reserved worldwide.
  107.  
  108. In simple terms: It's free, but it is *ours*.  Please also include a small
  109. credit somewhere in your programs documentation saying something like
  110. "RemoteAccess 'C' Developer Toolkit from Envy Technologies utilised in the
  111. development of this product".
  112.  
  113. Exclusions
  114. The following parts of RACDK are neither copyright Envy Technologies nor
  115. covered by this licence agreement.
  116.  
  117.     Pascal <> C string conversion macros
  118.     Taken from the 'C' Snippets collection - Public Domain.
  119.     
  120.  
  121. Revision history
  122. ----------------
  123. v0.00            Original release of converted structs for RA 2.02.
  124.                     Pascal <> C string conversion macros included.
  125. v0.01            Brand new conversion of RA 2.50 gamma structs.
  126.                     * Untested release*
  127. v0.02            Fixed compilation problems.
  128.                     Added enumeration types as per the Pascal structs.
  129.                     Added Pascal <> C string copy macros.
  130.                     Code tidied up & commented.
  131. v0.03            Added new Write format documentation.
  132.                     Added struct and enum prefixes to allow compilation
  133.                          without a normal 'C' compiler (ie. non C++).
  134.                     New function library RACDK.H contains:
  135.                          CRC-32 calculation routine
  136.                          Multitasking timeslice
  137.                     Added examples:
  138.                          Using a CRC
  139.                          Reading RA files
  140.  
  141. Requirements
  142. ------------
  143. To use RACDK you require:
  144.  
  145. o    A 'C' language compiler.  RACDK has only been tested with Borland C++
  146.      v4.52
  147. o    A copy of RemoteAccess 2.01, 2.02 or 2.50 Shareware, Hobby or
  148.      Professional configured & working is recommended.
  149. o    Experience with 'C' programming.
  150.  
  151. Note: The 'C' source files contained within this package have been developed
  152. using Borland C++ v4.52 only.  Other compilers may interpret this code in such
  153. a way that it no longer functions correctly (Common problems include different
  154. compilers ideas about longs, ints etc).
  155.  
  156. Setting up RA-Monitor
  157. ---------------------
  158. To setup RACDK simply unpack the files to a directory.  You may want to put
  159. the .H files into your 'C' compilers include directory, or add the RACDK path
  160. to your compiler's list of include directories.
  161.  
  162.  
  163. Using RACDK
  164. ===========
  165.  
  166. Structures
  167. ----------
  168. The RA250C.H file included with the package is the core of the RACDK.  It
  169. defines, in 'C', the structure of the RemoteAccess data & control files so
  170. that you may read and write information to work with the RemoteAccess software.
  171. This file is based on information in the Pascal structures file included with
  172. all releases of RemoteAccess.
  173.  
  174. There are many files described in the structures document, a listing of them
  175. appears in the following section Overview of files.  A simple example of
  176. accessing a RemoteAccess file in 'C' using the RACDK can be found in the
  177. included FILEDEMO.C file.
  178.  
  179.  
  180. Functions
  181. ---------
  182. The RACDK.H file contains functions which you may find of some use while
  183. developing applications to work with RemoteAccess.  You may either include
  184. this file in your project with #include or manually copy and paste the
  185. routines into your own code.  The functions are detailed below however
  186. additional detailed information can be found at the start of RACDK.H.
  187.  
  188. CRC32 - Calculate 32-bit CRC
  189. Prototype:    unsigned long CRC32(unsigned char *pBuffer,unsigned int iBufLen)
  190. Input:        *pBuffer    Pointer to area of memory to calculate CRC from
  191.                iBufLen   Length of pBuffer (number of bytes to process)
  192. Output:        32-bit CRC code for memory block
  193. Description:    This routine generates a 32-bit CRC code from a block of data.
  194.                You can pass this routine a block of text such as a password
  195.                and it will generate the same CRC code as RemoteAccess does
  196.                when changing a password.  This is also used to encode user
  197.                names for fast lookup as well as in the JAM message base and
  198.                on Z-Modem transfer packets.
  199. Example:       USERrec.PasswordCRC = CRC32(myPass,strlen(myPass));
  200.                This would store the password contained in the string myPass in
  201.                a USER.BBS record ready to be written back to USERS.BBS itself.
  202. Note:        This routine uses 'C' string types, to use it on Pascal types,
  203.                see the section titled 'Pascal string handling' later in this
  204.                document.
  205.  
  206. TimeSlice - Release timeslice to multitasking OS
  207. Prototype:    void TimeSlice(void)
  208. Input:        None
  209. Output:        None
  210. Description:    This routine will attempt to detect DESQview, OS/2 or Windows
  211.                multitasking operating systems and will release a timeslice to
  212.                each of them when called.  If none are found this routine will
  213.                release timeslices using the generic method of executing
  214.                assembler NUL instructions.
  215. Example:       while(!kbhit()) TimeSlice();
  216.                This would wait for a key to be pressed but will take minimal
  217.                CPU usage while waiting.
  218. Note:        This function will compile only in compilers which support
  219.                inline assembler.
  220.                This function will run only in DOS applications with Intel
  221.                80x86 support.
  222.  
  223.  
  224. Pascal string handling
  225. ----------------------
  226. Pascal handles strings differently to 'C'.  In 'C' a string consists of a
  227. sequence of characters with the null character (00h) telling 'C' when the
  228. string finishes.  This has the advantage of allowing unlimited length strings
  229. at the expensive of not being able to tell how long the string is until you
  230. have read every character in it (this is what the strlen() function does).
  231.  
  232. Pascal strings are stored differently.  Instead of being null-terminated the
  233. first actual byte contains the length of the string, followed by the string
  234. itself.  For example:-
  235.  
  236. 'C'        unsigned char sUserName[61];
  237.         strcpy(sFileName,"Guard");
  238.         In memory (hex):    477561726400
  239.  
  240. Pascal    sUserName: String[5];
  241.         sUserName := 'Guard';
  242.         In memory(hex):    054775617264
  243.  
  244. It is important to note that as Pascal stores this length that you do not read
  245. more characters than specified as often Pascal will overwrite only part of a
  246. string.  For example if a Pascal field contained the string 'This is a test'
  247. and then later contained the string 'What' if you went and uses the entire
  248. contents of the field instead of the first 4 characters specified you would
  249. possibly get 'What is a test'.
  250.  
  251. To help relieve this problem the RACDK contains four macros for managing
  252. Pascal <> 'C ' string conversions.  These are implemented as macros for
  253. optimum speed but you are free to convert them to functions (but do not
  254. redistribute these functions with the RACDK).
  255.  
  256. The macros are as follows:
  257.  
  258.     Pas2C        Convert Pascal string to 'C' format
  259.                     Example:  Pas2C(CONFIGrec.SysopName);
  260.                               printf("Sysop is %s\n",CONFIGrec.SysopName);
  261.     C2Pas        Convert 'C' string to Pascal format
  262.                     Example:  C2Pas(CONFIGrec.SysopName);
  263.                               fwrite...
  264.      cpyPas2C       Copy a Pascal string into a 'C' string
  265.                     Example:  cpyPas2C(CONFIGrec.SysopName,sSysopName);
  266.                               printf("Sysop is %s\n",sSysopName);
  267.      cpyC2Pas       Copy a 'C' string to a Pascal string
  268.                     Example:  cpyC2Pas(sSysopName,CONFIGrec.SysopName);
  269.                               fwrite...
  270.  
  271. General tips
  272. ------------
  273.  
  274. Files
  275. ·    Always open the files in shared mode.
  276. ·    Open a file, read it's contents and close ASAP to prevent RA from being
  277.      locked-out.
  278. ·    Some files have multiple records.  What this means is that the same
  279.      information is stored multiple times.  For example, the CONFIGrecord
  280.      found in CONFIG.RA is only stored once - the CONFIGrecord described all
  281.      the fields contained within this file and matches it exactly.  However,
  282.      the FILESrecord found in FILES.RA is stored many many times, one for each
  283.      file area.  You can choose which area you read using the 'C' function
  284.      fseek before reading.  fseek is based on moving the files current
  285.      position by a number of bytes so to get to a specific record you
  286.      calculate the position as (recordnumber-1)*sizeof(record).
  287.  
  288. Interface
  289. ·    Making your program appear to the sysops using an RA style interface is a
  290.      great way to make them feel immediately at home.  If your application
  291.      does uses this interface then you should include something like
  292.      'Original interface design by Joaquim Homrighausen' in the documentation.
  293. ·    Always release timeslices when posssible, especially when waiting for a
  294.      key-press.
  295.  
  296.  
  297. Appendix
  298. ========
  299.  
  300. Frequently asked questions
  301. --------------------------
  302. Q:    The configuration files are reading in garbage, why?
  303. A:    Ensure you are loading the correct file properly.  If you are sure you are
  304.      loading it correctly then you MUST make sure that your compiler has the
  305.      option for ENUM as character and not ENUM as integer which is the default
  306.      on some 'C' compilers including Borland C++.
  307.  
  308.  
  309. File summary
  310. ------------
  311. This package consists of the following 9 files:
  312.  
  313. Main files
  314.     RACDK.WRI        Windows Write format documentation
  315.     RACDK.DOC        Plain DOS text format documentation
  316.     RA250C.H        RemoteAccess 2.50 'C' file structures
  317.     RACDK.H        RACDK function library
  318.  
  319. Examples
  320.      TEST-CRC.C     Show how to generate an RA CRC value
  321.      FILEDEMO.C     Show how to access RA files & information
  322.  
  323. Administration
  324.      FILE_ID.DIZ    Archive description
  325.      DESCRIPT.ION   4-DOS extended file descriptions
  326.     WHATS.NEW        Information on changes since v0.2
  327.  
  328.  
  329. Contacting Envy Technologies
  330. ----------------------------
  331. There are several ways of contacting Envy Technologies.  They are:
  332.  
  333.      FidoNet:         2:255/78 or 2:255/119 (Damien Guard)
  334.      RANet:           73:7440/78 (Damien Guard)
  335.      BBS (UK):        (01481) 727140/727141    (28k8)
  336.      BBS (Internat.): +44-1481-727140/727141   (28k8)
  337.      Internet:        envy@guernsey.net
  338.  
  339. To recieve the latest versions of Envy Technologies releases:
  340.  
  341.     FidoNet:    FREQ from 2:255/78 or 2:255/119
  342.                RACDK     for latest version of RACDK
  343.             ENVY        for list of releases to dates + future release info
  344.     BBS:        Log onto our BBS (numbers listed above) as user GUEST.
  345.             Go into the file menu, select group [Ice] Distribution then
  346.             file area Envy Technologies.
  347.     Internet WWW:    http://www.guernsey.net/~envy
  348.  
  349.  
  350. Future enhancements
  351. -------------------
  352. Expect some more example programs and a greatly expanded function library
  353. (Note sending, checking user online etc) maybe even complete little
  354. applications to show various functions.  If you want to see a product that
  355. has used RACDK, our own FREEWARE RA-Monitor tool uses this package (shows
  356. status of all nodes, send notes, log off users) can be FREQ'ed from our
  357. FidoNet address as RAMON or retrieved from our WWW site on the Internet.  As
  358. of writing the latest version is 1.00.
  359.  
  360.  
  361. Other sources
  362. -------------
  363. There are many other archives which you may find useful when developing
  364. applications for RemoteAccess in 'C', a couple of the most useful ones are
  365. listed here and should be available from any good BBS (and are available on
  366. our BBS once your account has been validated):
  367.  
  368. Messages
  369. JAM-API    Set of 'C' and Pascal routines for manipulating the JAM message
  370.         base including reading/writing messages.  Also includes HMB2JAM
  371.         message base converter with source code which is useful if you want
  372.         to know how to read Hudson message bases.
  373.  
  374. Doors
  375. OpenDoors    OpenDoors v6 is an excellent library for 'C'/'C++' which lets you
  376.           write a BBS door almost as easily as writing a normal DOS 'C'
  377.           program.
  378.  
  379.  
  380. Credits & acknowledgements
  381. --------------------------
  382. Thanks to Steve Streeting for information on pointers (again ;-) and to those
  383. RACDK users who have given good feedback!
  384.  
  385. Development tools:    Borland C++ v4.52
  386. Documentation:        Windows Write
  387.  
  388. Thank-you for using RACDK,
  389.  
  390. [)amien
  391. Damien Guard - Envy Technologies - Monday 29th April, 1996.