home *** CD-ROM | disk | FTP | other *** search
/ PC Media 4 / PC MEDIA CD04.iso / share / prog / res104 / res.doc < prev    next >
Encoding:
Text File  |  1994-08-30  |  23.3 KB  |  515 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.                        RES version 1.04 Documentation
  7.                                30 August 1994
  8.  
  9.                         RES software and manual are
  10.                Copyright (c) 1993-1994 by Matthew Hildebrand.
  11.                             All rights reserved.
  12.  
  13.  
  14.  
  15.  
  16. Topics covered in this document:
  17. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  18.  
  19.      INTRODUCTION
  20.      TERMS OF USAGE AND DISTRIBUTION
  21.      WHY REGISTER?
  22.      PACKING LIST
  23.      USING RES.EXE, THE RESOURCE MANAGER
  24.      USING RES IN A PROGRAM
  25.      THE RES FUNCTION LIBRARY
  26.      ADDITIONAL FEATURES IN THE REGISTERED VERSION
  27.      CONTACTING THE AUTHOR
  28.      OBTAINING THE NEWEST VERSION OF RES
  29.      TROUBLESHOOTING
  30.      LEGAL STUFF
  31.  
  32.  
  33.  
  34.  
  35. INTRODUCTION
  36. ▀▀▀▀▀▀▀▀▀▀▀▀
  37.  
  38.      RES is a package designed to allow C++ developers to use resource
  39.      files in their programs.  A resource file is a file which contains
  40.      several or many files, each of which is easily accessible by a program
  41.      through a resource manager interface.  The advantages of storing data
  42.      files this way are that, in a typical program, the files may be
  43.      accessed more quickly and less disk space will be wasted.  Using
  44.      resource files also makes programs look more professional.
  45.  
  46.      The RES package includes the RES.EXE resource manager program, which
  47.      allows adding, extracting, deleting, and listing of files in
  48.      resources.  The RES package also includes all the source code
  49.      necessary to access data stored in resources from within your own
  50.      programs.
  51.  
  52.  
  53.  
  54. TERMS OF USAGE AND DISTRIBUTION
  55. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  56.  
  57.      RES is not free; it is distributed on a "try before you buy" basis.
  58.      Permission is granted to use RES, for evaluation purposes only, for a
  59.      trial period of up to 30 days.  In order to use RES after the trial
  60.      period, you MUST REGISTER; registration entitles you to free upgrades,
  61.      technical support, royalty-free distribution rights for all software
  62.      written using RES, and a copy of the registered version of RES, which
  63.      includes complete source code.  Failure to register constitutes theft
  64.      and is punishable by law.
  65.  
  66.      By registering a copy of RES, you signify that you have read and
  67.      understood the terms of usage and distribution explained in this
  68.      document, and that you agree to be bound by these terms; you also
  69.      signify that you agree to release the Author (Matthew Hildebrand) from
  70.      all liability associated with the use of RES.
  71.  
  72.      In order to register a copy of RES, send $15 US funds or $20 Canadian
  73.      funds to Matthew Hildebrand at the address listed in the CONTACTING
  74.      THE AUTHOR section of this document.  Payment by money order, cheque,
  75.      or cash is acceptable; currency must be US or Canadian funds.  Users
  76.      outside the USA and Canada, please ensure that cheques are drawn on a
  77.      US or Canadian bank, and that money orders are international if
  78.      necessary.  Also, please send a filled out copy of ORDER.FRM with
  79.      your payment.  Thank you in advance for registering RES; your support
  80.      is what makes its continued growth possible.
  81.  
  82.      Upon receipt of your registration, I will mail you a copy of the
  83.      registered version of RES, which includes complete source code; this
  84.      registered copy of RES may not be distributed in any way.  Once I have
  85.      mailed you a copy of the registered version, you will be considered a
  86.      registered user.  If you are interested in receiving notifications of
  87.      new versions as they are released, or copies of the new versions
  88.      themselves, refer to paragraph two of the OBTAINING THE NEWEST VERSION
  89.      OF RES section.
  90.  
  91.      The privileges granted by purchasing RES may be retracted if the
  92.      copyright notice in RESOURCE.CPP (copyright[]) is modified or removed,
  93.      if any or all of the registered version of RES is distributed in any
  94.      way, or if any or all of RES's source code is distributed as part of a
  95.      software package.
  96.  
  97.      The shareware version of RES may be distributed freely as long as the
  98.      distributed package is complete and its contents are not modified in
  99.      any way, and the distributed package is not sold for profit.
  100.  
  101.  
  102.  
  103. WHY REGISTER?
  104. ▀▀▀▀▀▀▀▀▀▀▀▀▀
  105.  
  106.      You will receive complete source code for the library.  The source
  107.      includes a complete file manipulation class, which would be useful in
  108.      many programs.
  109.  
  110.      Programs built with RES will be able to create resources, as well as
  111.      open existing ones.
  112.  
  113.      You will be legally entitled to use RES in as many programs as you
  114.      want, without royalties.
  115.  
  116.      You will be entitled to free upgrades, technical support, and eternal
  117.      happiness.
  118.  
  119.      You will have the satisfaction of supporting a good product.
  120.  
  121.  
  122.  
  123. PACKING LIST
  124. ▀▀▀▀▀▀▀▀▀▀▀▀
  125.  
  126.      The current version of RES consists of the following files:
  127.  
  128.      \RES\               <DIR>
  129.          RES.DOC                   RES documentation.
  130.          RES.EXE                   RES resource manager.
  131.          REVISION.HST              Revision history.
  132.          CATALOG.TXT               Catalog of my software packages.
  133.          ORDER.FRM                 Order form (shareware version only).
  134.          README.NOW                Important information.
  135.          FILE_ID.DIZ               Archive description file used by some
  136.                                      bulletin board systems (shareware
  137.                                      version only).
  138.      \RES\SOURCE\        <DIR>
  139.          ERROR.H                   Error reporter header.
  140.          FILE.H                    File class header.
  141.          PORTABLE.H                Portability header.
  142.          RESOURCE.H                Resource class header.
  143.            (The licensed version contains complete source code.)
  144.      \RES\LIB\           <DIR>
  145.          BCL.BAT                   Borland C++ large model batch file.
  146.          BCL.MAK                   Borland C++ large model makefile.
  147.          BCH.BAT                   Borland C++ huge model batch file.
  148.          BCH.MAK                   Borland C++ huge model makefile.
  149.          GNU.BAT                   GNU C++ batch file.
  150.          GNU.MAK                   GNU C++ makefile.
  151.          GENERAL.BAT               General batch file.
  152.          GENERAL.MAK               General makefile; edit to suit other
  153.                                      compilers.
  154.          BCL.LIB                   Borland C++ large model library.
  155.          BCH.LIB                   Borland C++ huge model library.
  156.          GNU.A                     GNU C++ library.
  157.  
  158.  
  159.  
  160. USING RES.EXE, THE RESOURCE MANAGER
  161. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  162.  
  163.      RES includes a simple resource file manager, RES.EXE.  This program
  164.      can add, delete, extract, and list files in resource files.  RES.EXE
  165.      has a simple, case-insensitive command-line syntax:
  166.  
  167.               RES <command> <resource_name> [<file_names>...]
  168.  
  169.      <command> must be 'A' (add), 'D' (delete), 'E' (extract), or 'L'
  170.      (list).  <resource_name> is the filename of the resource; the .RES
  171.      extension is assumed if none is present.  If there is an error in the
  172.      command line, a brief help screen is displayed.  Some examples follow:
  173.  
  174.           res a foo graphics\*.*
  175.           res D bar *.obj
  176.           res a foobar.res tom.* dick?.pcx d:\someprog\miscdata\harry*.*
  177.           res l foo *.txt
  178.           res e bar.res *.cpp *.c *.h
  179.  
  180.      Resource files created with RES.EXE may be accessed using a simple
  181.      interface.  How to use RES in a program is detailed in the next two
  182.      sections.
  183.  
  184.      
  185.  
  186. USING RES IN A PROGRAM
  187. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  188.  
  189.      IN ORDER TO USE RES WITH BORLAND COMPILERS, YOU **MUST** DISABLE THE
  190.      "FAR VIRTUAL TABLES" OPTION (-Vf- FROM THE COMMAND LINE) AND THE
  191.      "UNSIGNED CHARACTERS" OPTION (-k- FROM THE COMMAND LINE).  IF YOU DO
  192.      NOT, YOU WILL GET LINKER ERRORS.
  193.  
  194.      Before using RES for the first time, you should locate the library
  195.      suitable for use with your compiler; libraries may be found in the LIB
  196.      directory.  Following is a list of libraries and the compilers with
  197.      which to use them:
  198.  
  199.           BCL.LIB        Borland C++ large model.
  200.           BCH.LIB        Borland C++ huge model.
  201.           GNU.A          GNU C++.
  202.  
  203.      RES has only been compiled for Borland C++ and GNU C++, simply because
  204.      these are the only C++ compilers I own.
  205.  
  206.      Now, to use the RES resource management function library, all you must
  207.      do is ensure that (a) you #include the RESOURCE.H file (in the SOURCE
  208.      directory) in any module which uses these functions, and that (b) you
  209.      link the appropriate library during the linking stage.
  210.  
  211.      IF YOU ARE USING A BORLAND COMPILER, BE SURE TO ONLY LINK OBJECT FILES
  212.      WHICH WERE COMPILED WITH THE "FAR VIRTUAL TABLES" AND "UNSIGNED
  213.      CHARACTERS" OPTIONS DISABLED.  ATTEMPTS TO LINK MODULES COMPILED WITH
  214.      EITHER OF THESE OPTIONS ENABLED WILL RESULT IN LINKER ERRORS.  IN
  215.      ORDER TO DISABLE THESE OPTIONS, USE THE -Vf- AND -k- COMMAND LINE
  216.      PARAMETERS, OR USE THE IDE'S OPTIONS->COMPILER MENU.
  217.  
  218.  
  219.  
  220. THE RES FUNCTION LIBRARY
  221. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  222.  
  223.      A description of each of the resource management functions,
  224.      implemented through the Resource class, follows:
  225.  
  226.  
  227.          Function:  Resource::open
  228.           Purpose:  Open a resource.
  229.            Syntax:  int Resource::open(char *filename);
  230.        Parameters:  The resource 'filename' will be opened.
  231.           Remarks:  The shareware version of RES does not allow this
  232.                     function to create new resources; it can only open
  233.                     existing resources created by RES.EXE.
  234.           Returns:  Returns 0 on error.
  235.          See also:  None.
  236.  
  237.          Function:  Resource::add
  238.           Purpose:  Add a file to the resource.
  239.            Syntax:  int Resource::add(char *filename);
  240.        Parameters:  The file 'filename' will be added.
  241.           Remarks:  - For speed considerations, the file will not actually
  242.                       be added to the resource file until Resource::pack()
  243.                       is called; this may be done either explicitly or
  244.                       automatically by the Resource class destructor.  A
  245.                       record of the addition will be made, but since the
  246.                       file is not actually added, it is important to ensure
  247.                       that, until Resource::pack() is called, the stated
  248.                       file is not deleted and that no attempt is made to
  249.                       access it through the resource.
  250.                     - If the file already exists in the resource, it will
  251.                       be overwritten.
  252.           Returns:  Returns 0 on error.
  253.          See also:  None.
  254.  
  255.          Function:  Resource::del
  256.           Purpose:  Delete a file from the resource.
  257.            Syntax:  int Resource::del(char *filename);
  258.        Parameters:  The file 'filename' will be deleted from the resource.
  259.           Remarks:  For speed considerations, the file will not actually be
  260.                     deleted from the resource file until Resource::pack() is
  261.                     called; this may be done either explicitly or
  262.                     automatically by the Resource class destructor.
  263.           Returns:  Returns 0 on error.
  264.          See also:  None.
  265.  
  266.          Function:  Resource::extract
  267.           Purpose:  Extract a file from the resource.
  268.            Syntax:  int Resource::extract(char *filename, char
  269.                     *outputPath=NULL);
  270.        Parameters:  The file 'filename' will be extracted into the current
  271.                     directory if 'outputPath' has its default value of
  272.                     NULL; if it has a different value, the string it points
  273.                     to will be prepended to the name of the file, and the
  274.                     resulting string will be used as the name of the output
  275.                     file.  For example, if 'outputPath' points to "D:\",
  276.                     then FILENAME.EXT will be extracted to D:\FILENAME.EXT.
  277.                     Note that the trailing backslash in the path is
  278.                     necessary.
  279.           Remarks:  If the file exists, it will be overwritten.
  280.           Returns:  Returns 0 on error.
  281.          See also:  None.
  282.  
  283.          Function:  Resource::load
  284.           Purpose:  Load some or all of a file from the resource.
  285.            Syntax:  void _far *Resource::load(char *file, void _far
  286.                     *buf=NULL, biguint numBytes=0, bigint startOff=-1);
  287.        Parameters:  Based on other parameters, some or all of 'file' will
  288.                     be loaded.  'startOff' determines the offset into the
  289.                     file of the first byte to load.  As with the standard
  290.                     FILE*s, the current offset into each file is
  291.                     maintained; the default value of -1 will cause the use
  292.                     of the current offset, or an offset may be explicitly
  293.                     stated.  'numBytes' determines how much data will be
  294.                     loaded; the default of 0 will cause the loading of all
  295.                     data from 'startOff' to end-of-file, or a value may be
  296.                     explicitly stated.  'buf' determines the address into
  297.                     which the data will be loaded; the default value of
  298.                     NULL will cause a block of memory of the correct size
  299.                     to be allocated (remember to free it later), or an
  300.                     address may be explicitly stated.
  301.           Remarks:  - This function can be confusing; see the examples
  302.                       below.
  303.                     - If this function is instructed to allocate a new
  304.                       buffer, and the allocation fails, then the program
  305.                       will exit.  Licensed users may change this behaviour.
  306.           Returns:  Returns NULL on error, or the address of the loaded
  307.                     data on success.
  308.          See also:  None.
  309.          Examples:  // Load all of FOOBAR.DAT into a new buffer
  310.                     addr = res.load("foobar.dat");
  311.                     // Load all of FOOBAR.DAT into an old buffer
  312.                     res.load("foobar.dat", addr);
  313.                     // Load the first kb of FOOBAR.DAT into an old buffer
  314.                     res.load("foobar.dat", addr, 1024);
  315.                     // Load the second kb of FOOBAR.DAT into a new buffer
  316.                     addr = res.load("foobar.dat", NULL, 1024, 1024);
  317.  
  318.          Function:  Resource::pack
  319.           Purpose:  Update a resource file, implementing any deletions and
  320.                     additions.
  321.            Syntax:  int Resource::pack(void);
  322.        Parameters:  N/A
  323.           Remarks:  This function has no effect if there have been no
  324.                     additions and/or deletions to/from the resource.
  325.           Returns:  Returns 0 on error.
  326.          See also:  None.
  327.  
  328.          Function:  Resource::rewind
  329.           Purpose:  Reset a file's current offset to beginning-of-file.
  330.            Syntax:  int Resource::rewind(char *filename);
  331.        Parameters:  The file 'filename' will be rewound.
  332.           Remarks:  None.
  333.           Returns:  Returns 0 on error (ie. if the file does not exist in
  334.                     the resource).
  335.          See also:  Resource::seek()
  336.  
  337.          Function:  Resource::seek
  338.           Purpose:  Reset a file's current offset to a specified value,
  339.                     fseek()-style.
  340.            Syntax:  int Resource::seek(char *filename, bigint offset, int
  341.                     whence);
  342.        Parameters:  The current offset of 'filename' will be changed.
  343.                     'whence' determines the point from which the offset
  344.                     will be reckoned; use SEEK_SET (0) for file beginning,
  345.                     SEEK_CUR (1) for current position, or SEEK_END (2) for
  346.                     end-of-file.  The pointer will be moved to a position
  347.                     which is 'offset' bytes from the location given by
  348.                     'whence'; 'offset' may be negative.
  349.           Remarks:  This function is used in the same way as fseek().
  350.           Returns:  Returns 0 on error.
  351.          See also:  Resource::rewind()
  352.  
  353.          Function:  Resource::fileSize
  354.           Purpose:  Return the size of a file in the resource.
  355.            Syntax:  biguint Resource::fileSize(char *filename);
  356.        Parameters:  The size of 'filename' will be returned.
  357.           Remarks:  None.
  358.           Returns:  Returns 0 on error, or the size of the file on success.
  359.          See also:  None.
  360.  
  361.          Function:  Resource::exists
  362.           Purpose:  Return a flag indicating whether or not the resource
  363.                     exists on disk, or whether it is newly created and
  364.                     Resource::pack() has not yet been called to write it to
  365.                     disk.
  366.            Syntax:  int Resource::exists(void);
  367.        Parameters:  None.
  368.           Remarks:  None.
  369.           Returns:  Returns 0 if the resource does not exist on disk, or
  370.                     non-zero if it does.
  371.          See also:  None.
  372.  
  373.          Function:  Resource::status
  374.           Purpose:  Returns an indication of how many errors have occurred
  375.                     in accessing the resource.
  376.            Syntax:  int Resource::status(void);
  377.        Parameters:  None.
  378.           Remarks:  None.
  379.           Returns:  Returns the number of errors which have occurred in
  380.                     accessing the resource since the last call to this
  381.                     function or the opening of the resource, whichever is
  382.                     most recent.
  383.          See also:  None.
  384.  
  385.  
  386.  
  387. ADDITIONAL FEATURES IN THE REGISTERED VERSION
  388. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  389.  
  390.      In addition to technical support and usage rights, registered users
  391.      may use the registered version of RES.  Not only does the registered
  392.      version of RES include complete source code for the RES library, it
  393.      also includes a feature not available in the shareware verion:
  394.  
  395.      Programs built with RES will be allowed to create resources, as well
  396.      as opening existing resources created with RES.EXE.  In order to allow
  397.      creation of resources, comment out the definition of NO_CREATE on line
  398.      16 of RESOURCE.CPP, then recompile the library using the appropriate
  399.      batch file in the LIB directory; uncommenting the line and recompiling
  400.      will once again cause RES to not create resources.
  401.  
  402.  
  403.  
  404. CONTACTING THE AUTHOR
  405. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  406.  
  407.      I would appreciate hearing any questions, comments, bug reports, or
  408.      suggestions for improvement.  If you have any, feel free to contact
  409.      me; I can be reached via any of the methods below.  When reporting
  410.      bugs, please be sure to mention the version of RES to which you are
  411.      referring.
  412.  
  413.           Snail mail:      Matthew Hildebrand
  414.                            4 College St.
  415.                            St. Catharines, ON
  416.                            Canada
  417.                            L2R 2W7
  418.  
  419.           Fidonet mail:    1:247/128.2
  420.                Please do not post personal messages to me in any of the
  421.                Fidonet echos, such as C_ECHO or C_PLUSPLUS; such messages
  422.                are off-topic and liable to annoy the moderator and other
  423.                echo participants.  Use netmail instead.  If I find any such
  424.                personal messages in Fidonet programming echos, I reply by
  425.                netmail only.  If the matter being discussed would be of
  426.                interest to other echo participants, I will reply in that
  427.                echo.
  428.  
  429.           Internet mail:   Matthew.Hildebrand@p2.f128.n247.z1.fidonet.org
  430.                Internet-Fidonet mail routing sometimes goes awry; if you
  431.                don't get a reply from me after a reasonable amount of time,
  432.                send the message again.  If you still don't receive a reply,
  433.                either persist until you do or contact me via a different
  434.                method.
  435.  
  436.           BBS:             (905)-935-6628
  437.                I am not the sysop of idiot savant BBS, but I will receive
  438.                messages left there for me.  The BBS runs a 14400 bps
  439.                V.32bis modem.
  440.  
  441.           Telephone:       (905)-687-8736
  442.                Please keep in mind the time zone difference, if any, when
  443.                calling; I'm in Eastern Standard Time.
  444.  
  445.  
  446.  
  447. OBTAINING THE NEWEST VERSION OF RES
  448. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  449.  
  450.      The most recent distributed copy of RES is available via first-call
  451.      download from (905)-935-6628 (14400 bps V.32bis), or via file request
  452.      from Fidonet node 1:247/128 (14400 bps V.32bis) using the magic file
  453.      name "RES"; unlisted nodes and points are welcome.  RES is also
  454.      distributed through the Fidonet file echo PDNCEE.
  455.  
  456.      If, after you have registered, you are interested in receiving new
  457.      versions of RES as they are released, an easy method is now available.
  458.      For $3 per mailing (to cover the disk, envelope, and postage), I will
  459.      mail copies of new versions as they are released, on either a 3.5" or
  460.      a 5.25" disk.  The $3 per mailing may be included with the initial
  461.      registration fee, with instructions to mail newer versions as they are
  462.      released, or mailed later with a request for a copy of the newest
  463.      version.  Please ensure that the $3 is paid in either US or Canadian
  464.      funds; payment by cash, money order (use an international money order
  465.      if necessary), or cheque drawn on a US or Canadian bank is acceptable.
  466.  
  467.      Alternatively, it is possible to receive notifications of updates but
  468.      not the updates themselves.  For $1 per mailing (to cover the envelope
  469.      and postage), I will mail notifications of new versions when they are
  470.      released.  The $1 per mailing may be included with the initial
  471.      registration fee, with instructions to mail notifications as new
  472.      versions are released, or mailed later with similar instructions.
  473.      Again, please ensure that the $1 is paid in either US or Canadian
  474.      funds; payment by cash, money order (use an international money order
  475.      if necessary), or cheque drawn on a US or Canadian bank is acceptable.
  476.  
  477.  
  478.  
  479. TROUBLESHOOTING
  480. ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
  481.  
  482.      Q.   My Borland linker is giving me error messages.  What's happening?
  483.  
  484.      A.   IN ORDER TO USE RES WITH BORLAND COMPILERS, YOU **MUST** DISABLE
  485.           THE "FAR VIRTUAL TABLES" OPTION (-Vf- FROM THE COMMAND LINE) AND
  486.           THE "UNSIGNED CHARACTERS" OPTION (-k- FROM THE COMMAND LINE.  IF
  487.           YOU DO NOT, YOU WILL GET LINKER ERRORS COMPLAINING THAT CERTAIN
  488.           CLASS MEMBER FUNCTIONS CANNOT BE FOUND.
  489.  
  490.  
  491.  
  492. LEGAL STUFF
  493. ▀▀▀▀▀▀▀▀▀▀▀
  494.  
  495.      RES and its documentation are Copyright (c) 1994 by Matthew
  496.      Hildebrand.
  497.  
  498.      All software and documentation associated with RES is provided "as
  499.      is":  ie., it is provided without warranty of any kind, not even an
  500.      implied warranty of merchantability or fitness for any purpose.  The
  501.      Author (Matthew Hildebrand) disclaims all warranties, both express and
  502.      implied, including but not limited to warranties regarding RES's
  503.      merchantability or fitness for any particular purpose.
  504.  
  505.      The author may not be held liable for any damage or misfortune related
  506.      to the use of this software.  Any usage of any or all of RES is done
  507.      entirely at the user's risk.
  508.  
  509.      All registered trademarks in this document belong to their respective
  510.      owners.
  511.  
  512.  
  513.  
  514. End of document.
  515.