home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / utility / fn32_13.zip / FN32.DOC < prev    next >
Text File  |  1993-02-10  |  17KB  |  447 lines

  1.  
  2.  
  3.  
  4.                              F N 3 2 - 3
  5.  
  6.                    PCDOS 32 character filename utilites.
  7.                             Run Time Files
  8.  
  9.                              Version 1.32
  10.  
  11.                           February 10, 1993
  12.  
  13.  
  14.                             Norman D. Culver
  15.                          1323 S.E. 17th Street
  16.                                Box 662
  17.                         Ft. Lauderdale, FL 33316
  18.                          Fax: (305) 760-7584
  19.                          Compuserve 70672,1257
  20.  
  21.         Copyright (C) 1992,1993 Norman D. Culver  All rights reserved.
  22.  
  23.  
  24.  
  25.                            CONTENTS
  26.  
  27.  
  28.          1.0 INTRODUCTION
  29.              1.1 WHAT IS FN32
  30.  
  31.          2.0 COPYRIGHT
  32.              2.1 LICENSE
  33.              2.2 WARRANTY
  34.              2.3 REGISTRATION
  35.  
  36.          3.0 USING FN32-3
  37.              3.1 RUNNING THE TSR
  38.              3.2 UTILIZING THE .OBJ FILES
  39.              3.3 SAMPLE PROGRAMS
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.      1.0 INTRODUCTION
  49.  
  50.      1.1 WHAT IS FN32 ?
  51.  
  52.      FN32 is a TSR, 3 object modules and 2 include files which support
  53.      32 character filenames under PCDOS. The TSR intercepts INT21h calls
  54.      and performs filename substitution by managing dictionary files in
  55.      each directory which contains longnames. The operation of
  56.      the TSR 'fn32.exe' is transparent to the user. The object modules
  57.      are substitutes for 'setargv.obj' and the 'stat' and 'fstat'
  58.      library routines. They also contain longname versions of 'opendir',
  59.      'readdir' etc.
  60.      
  61.      Several of the GNU file utilities have been modified and are
  62.      in the package GNUDOS.ZIP. They are needed because many of the
  63.      standard PCDOS utilities truncate filenames to 8.3 internally.
  64.      The standard PCDOS stat info and filename globbing is inadequate
  65.      for a program written for unix so these utilities have been compiled 
  66.      with the substitute obj files mentioned above.
  67.  
  68.      Therefore, you get to use tar and unix or macintosh style names 
  69.      without the usual PCDOS name mangling.
  70.  
  71.      Also, conversion of many more unix programs for PCDOS is now a feasible
  72.      and rather simple project.
  73.  
  74.  
  75.  
  76.      2.0 COPYRIGHT
  77.  
  78.      The program fn32.exe, the object modules fn32argv.obj, xstat.obj
  79.      and xfstat.obj and the include files 'fn32argv.h' and 'xstat.h',
  80.      hereinafter known as the 'Run Time Files' are:
  81.  
  82.      Copyright (c) 1992,1993 by Norman D. Culver with all rights reserved. 
  83.  
  84.      The readable source code for the Run Time Files is also
  85.      Copyright (c) 1992,1993 by Norman D. Culver with all rights reserved. 
  86.  
  87.      If you find FN32-3 to be a useful addition to your
  88.      software library, you are requested to become a registered
  89.      user by completing the registration form and returning it
  90.      along with a $ 25 license fee.  The license fee is required
  91.      if FN32-3 is used in a commercial environment, it is also
  92.      a requirement for obtaining a copy of the source code.
  93.  
  94.      2.1 LICENSE
  95.  
  96.      You are granted a limited license to use and examine
  97.      FN32-3 on a trial basis to determine if FN32-3 is suitable for
  98.      your needs. If you find FN32-3 useful and use it on a regular
  99.      basis, you are requested to complete and return the registration
  100.      form along with the license fee.
  101.  
  102.      Once you have registered, you are granted a license to
  103.      obtain the source code for your own personal use. You may
  104.      also embed the object files 'fn32argv.obj', 'xstat.obj'
  105.      and 'xfstat.obj' in programs written by you and distributed
  106.      for any purpose whatsoever.
  107.  
  108.      You may not distribute the Run Time Files and especially
  109.      the program fn32.exe except under the terms of this license.
  110.  
  111.      Original or modified versions of the FN32-3 source code files
  112.      are for your own personal use and may not be distributed in any form.
  113.  
  114.      You are encouraged to make copies of FN32-3 Run Time Files 
  115.      for the trial use of other individuals, subject to the following
  116.      restrictions:
  117.  
  118.           All FN32-3 Run Time Files must be copied in
  119.           unmodified form, including the documentation,
  120.           registration and executable images.
  121.  
  122.           You may not include any files other than the GNU
  123.           file utilities and FN32-3 sample programs with the copy.
  124.  
  125.      FN32-3 Run Time Files may be included on electronic bulletin board
  126.      systems for downloading by users of the bulletin board provided
  127.      the above restrictions are met.
  128.  
  129.  
  130.      2.2 WARRANTY
  131.  
  132.      FN32-3 AND ALL ACCOMPANYING MATERIALS ARE PROVIDED "AS IS"
  133.      WITHOUT WARRANTY OF ANY KIND.  THE ENTIRE RISK OF USING
  134.      FN32-3 IS ASSUMED BY YOU.
  135.  
  136.      Norman D. Culver makes no warranty of any kind, express or
  137.      implied, including but not limited to any warranties of
  138.      merchantability and fitness for a particular purpose.
  139.  
  140.      IN NO EVENT WILL NORMAN D. CULVER BE LIABLE FOR ANY DAMAGES
  141.      WHATSOEVER (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS OF
  142.      BUSINESS PROFITS, LOSS OF SAVINGS, BUSINESS INTERRUPTION,
  143.      AND THE LIKE) ARISING OUT OF YOUR USE OR INABILITY TO USE
  144.      THE PROGRAM.
  145.  
  146.      BY USING FN32-3, YOU AGREE TO THE ABOVE LIMITATIONS.
  147.  
  148.  
  149.      2.3 REGISTRATION
  150.  
  151.      If you use FN32-3 on a regular basis, you are requested to
  152.      complete the following registration form and return it along
  153.      with a $ 25 license fee.  Registration gives you the right
  154.      to use the software as documented in the license.
  155.  
  156.      Registration is necessary only once - registration allows
  157.      you licensed use of all upgrades to the product.
  158.  
  159.      Registration is required if FN32-3 is used in a commercial
  160.      environment.  Contact Norman D. Culver for information on
  161.      quantity discounts or site-license agreements.
  162.  
  163.      You can register through Compuserve, the shareware registration
  164.      id is 295.    
  165.  
  166.      Source code for FN32-3 is available to registered users for a
  167.      copying, shipping and handling fee of $5. Please send a
  168.      formatted high density diskette, 3.5 or 5.25, which will be
  169.      loaded up and returned to you.
  170.  
  171.      Registered users can obtain support from the author for a 
  172.      period of 90 days after registration. You can use regular
  173.      mail, fax or Compuserve mail to contact me.
  174.  
  175.      The following form is reproduced in the REGISTER.FRM file
  176.      for your convenience.
  177.  
  178.  
  179.  
  180.  
  181.      ------------------------------------------------------------
  182.      FN32-3 Version 1.32 Registration Form                  1-Sep-92
  183.  
  184.  
  185.      To become a registered user of FN32-3, complete and return
  186.      this form along with a $ 25 license fee.  The license fee
  187.      should be a check or money order, payable in USA funds.
  188.  
  189.      Add $ 5 for copying, shipping and handling of the source code.
  190.      Please enclose a formatted high density diskette which will
  191.      be loaded up and returned to you.
  192.  
  193.              Send to:     Norman D. Culver
  194.                           1323 S.E. 17th Street
  195.                           Box 662
  196.                           Ft. Lauderdale, FL 33316
  197.                           U.S.A.
  198.  
  199.  
  200.         Name: ___________________________________________________
  201.  
  202.      Company: ___________________________________________________
  203.  
  204.      Address: ___________________________________________________
  205.  
  206.               ___________________________________________________
  207.  
  208.               ___________________________________________________
  209.  
  210.  
  211.      Please accept this registration for FN32-3.
  212.      I agree to your disclaimer of all warranties and the
  213.      restrictions on copying.
  214.  
  215.  
  216.      ________________________________________     _______________
  217.                    SIGNED                              DATE
  218.  
  219.  
  220.      Please feel free to add any comments, friendly criticisms,
  221.      problem reports, and improvement ideas you might have about
  222.      the product.
  223.  
  224.                      THANK YOU FOR YOUR SUPPORT!
  225.      ------------------------------------------------------------
  226.  
  227.  
  228.      3.0 USING FN32-3
  229.  
  230.      3.1 RUNNING THE TSR
  231.  
  232.      FN32-3 requires an IBM PC/AT or compatible system to
  233.      work properly.  In addition, version 2.0 or greater of
  234.      PC-DOS or MS-DOS is required.
  235.  
  236.      At the DOS prompt type 'FN32' followed by a carriage return.
  237.      FN32.EXE will install itself and print a copyright message.
  238.      
  239.      To deinstall, type 'FN32 -d' followed by a carriage return.
  240.      If it is installed, FN32.EXE will deinstall itself.
  241.  
  242.      FN32.EXE sets the switch char to '-' when it is installed and
  243.      restores the old switch char when it is deinstalled.
  244.  
  245.      DOS int21 calls which supply path strings are intercepted by FN32.EXE and
  246.      those which contain file or directory names which exceed the DOS limits
  247.      of 8.3 are reformulated with appropriate short names. The long names 
  248.      (32 chars max, case insensitive) are stored in dictionary files named
  249.      $!$INDEX.$!$ in each relevant directory. The dictionary files contain a
  250.      sequence of 32 byte records. Names shorter than 32 bytes are padded on 
  251.      the right with zeros.
  252.     
  253.      Each dictionary file contains a 16 bit unsigned counter in record 0. 
  254.      Short names are constructed in one of two ways:
  255.      1. The counter is incremented and used.
  256.      2. An empty slot is found in the file (the result of an earlier delete)
  257.          and the slot number is used.
  258.      Empty slots always take precedence over bumping the counter.
  259.      Dictionary files are automatically deleted when the last entry is deleted.
  260.  
  261.      The format of a short name is X.$!$ where 'X' is 1 to 4 hex digits. To the
  262.      best of my knowledge this is a unique identifier in the DOS world.
  263.      Names start at 1.$!$ .
  264.  
  265.      The PCDOS 'DIR' command will show the dictionary files and the short
  266.      forms of the file names. Use the 'ls' program from the GNU file utilities
  267.      to see the long names.    All of the GNU file utilities work with longnames
  268.      as do all of the compilers and editors I have tried. Unfortunately
  269.      some DOS application programs are too smart for their own good and
  270.      truncate filenames to 8.3 internally so we do not have a universal
  271.      solution here.
  272.     
  273.      3.2 UTILIZING THE .OBJ FILES
  274.      
  275.      All of the .obj files have been compiled with MSC 6.0 using memory
  276.      model ACw (near code pointers, far data pointers, SS!=DS). They
  277.      will link with programs compiled as AC ACw AL and ALw. The only
  278.      external variable or function used is 'extern int errno'.
  279.  
  280.      FN32ARGV.OBJ -- create an array of arguments and optionally _stat structs
  281.                   -- + a 'DIR' package _opendir,_readdir,_telldir etc.
  282.                   -- + a version of 'rename' which handles longnames
  283.     
  284.         Include fn32argv.h
  285.  
  286.         int fn32argv(int *argcp,char ***argvp,_stat ***statvp, int flag)
  287.         void argv_free(int *argcp,char ***argvp,_stat ***statvp)
  288.  
  289.         argcp    pointer to argument count
  290.         argvp    pointer to argument array pointer
  291.         statvp    pointer to _stat structure array pointer, or NULL
  292.         flag    contains flag bits which modify filename globbing and selection
  293.  
  294.                 /* Globbing bits */
  295.                 FN32_LEADING_DOT    Allow leading dot if pattern contains one
  296.                 FN32_IS_PATH        Test string is a path, '/' is a separator
  297.                 FN32_USES_ESCAPES    Pattern contains escapes
  298.                 FN32_PCDOS            Convert '*.*' to '*'
  299.                 /* stat selection bits */
  300.                 FN32_S_IEXEC        Select executable files
  301.                 FN32_READONLY        Select readonly files
  302.                 FN32_HIDDEN            Select hidden files
  303.                 FN32_SYSTEM            Select system files
  304.                 FN32_VOLUME            Select volume labels
  305.                 FN32_DIRECTORY        Select directories
  306.                 FN32_ARCHIVE        Select files with archive bit set
  307.                 FN32_ALL_FILES        Select all files including '.' and '..'
  308.  
  309.  
  310.      fn32argv.obj is a substitute for setargv.obj but is explicitly
  311.      called from inside the user's program. This feature permits
  312.      construction of arguments from programmer defined argc and argv.
  313.      It implements POSIX filename globbing with an extension for deep
  314.      recursion. i.e. ** means go to the bottom of the subdirectory chain.
  315.      e.g. 
  316.     "/usr/**/*.h"         gets all include files in subdirectories below /usr.
  317.     "[a-z]:/**/*"         gets all files on all drives.
  318.     "**/*"                gets everything in the current and all lower subdirs
  319.     "/**/*"                gets all files from the current drive
  320.     "*:/**/*"            gets all files from all drives
  321.     "[cde]:/**/*"        gets all files from partitions c:, d: and e:
  322.     "/usr/**[ab]/*.bat"    gets all .bat files from all levels of subdirectories
  323.                         below /usr which end in 'a' or 'b'
  324.     "/usr/*[ab]/*.bat"    gets all .bat files from one level of subdirectories
  325.                         below /usr which end in 'a' or 'b'
  326.  
  327.      /* The following code prints a list of every file on the c drive */
  328.         {
  329.         int i;
  330.          int argc
  331.         char arg[] = "c:/**/*"
  332.          char **argv;
  333.          
  334.             argc = 1;
  335.             argv[0] = arg;
  336.             /* Use FN32_ALL_FILES to get files with leading dots */
  337.             /* Use FN32_DIRECTORY to get directories */
  338.              fn32argv(&argc, &argv, NULL, FN32_ALL_FILES);    
  339.             for(i = 0; i < argc; ++i)
  340.                 printf("%s\n", argv[i]);
  341.             argv_free(&argc, &argv, NULL);
  342.         }
  343.  
  344.     /* The following code gives you what you would expect from a unix shell. */
  345.         main(int argc, char **argv)
  346.         {
  347.             /* Use FN32_PCDOS to make *.* == * */
  348.             fn32argv(&argc, &argv, 0, FN32_PCDOS);
  349.         }
  350.  
  351.     /* If you don't need st_dev+st_ino to uniquely identify a file then
  352.         you can get the stats for each argument laid out in an array,
  353.         see fn32argv.h for the _stat structure which is a little more
  354.         elaborate than the standard PCDOS struct. In particular it
  355.         contains the DOS attrib byte in st_xmode and will contain 
  356.         a null terminated short filename if a longname was used. */
  357.  
  358.         main(int argc, char **argv)
  359.         {
  360.         struct _stat **statv;
  361.  
  362.             fn32argv(&argc, &argv, &statv);
  363.         }
  364.  
  365.         argv_free() is a function to free the storage (which may be very large)
  366.         allocated to the argument and optional stat arrays.
  367.  
  368.  
  369.         THE 'DIR' PACKAGE IN FN32ARGV.OBJ
  370.     
  371.         This set of functions is named _opendir, _readdir, _seekdir
  372.         _telldir and _closedir. They operate in the usual manner but
  373.         return information to structures which are quite a bit more
  374.         elaborate than the PCDOS equivalents. see fn32argv.h
  375.         There is one glaring omission, 'd_ino', which cannot be retrieved
  376.         in a time efficient manner when the file is not open. Use
  377.         'xstat' or 'xxstat' or 'xfstat'.
  378.  
  379.         THE 'RENAME' FUNCTION IN FN32ARGV.OBJ
  380.     
  381.         This function resolves all longnames except the 'to' file before
  382.         it calls PCDOS rename. The TSR fn32.exe    will create the final
  383.         longname. NOTE: PCDOS 'rename' will not rename directories. The
  384.         program 'mvdir.exe' must be used for this purpose.
  385.         
  386.     XSTAT.OBJ -- contains the 'xstat' and 'xxstat' functions    
  387.                 + x_abs_read and x_abs_write
  388.  
  389.     Include xstat.h
  390.     
  391.     struct _xstat *xxstat(char *path);
  392.     int xstat(char *path, struct _xstat *statbuf);
  393.     void xstat_free(void *statbuf);
  394.  
  395.     path        File path name
  396.     statbuf        pointer to a struct _xstat (see xstat.h, this structure
  397.                 contains a valid st_dev+st_ino pair as well as other useful
  398.                 elements such as the correct number of blocks allocated.
  399.                 If the function 'xxstat' is used it will contain a
  400.                 complete block map of the file or directory referenced. The
  401.                 first set of contiguous blocks is returned by 'xstat'. NOTE:
  402.                 the structure returned by 'xxstat' is of variable length
  403.                 and could be quite large. Use 'xstat_free' to return storage
  404.                 allocated by 'xxstat'.
  405.  
  406.     Returns: xxstat returns NULL and sets errno to ENOENT if not found.
  407.              xstat return 0 if successful and -1 with errno=ENOENT if not found.
  408.  
  409.  
  410.     int x_abs_read(int dev,unsigned long blk,unsigned short blkcnt,void *buf);
  411.     int x_abs_write(int dev, unsigned long blk,unsigned short blkcnt,void *buf);
  412.  
  413.     The functions 'x_abs_read' and 'x_abs_write' can be used to directly
  414.     access directories and files that are mapped by 'xxstat'. The functions
  415.     flush the PDCOS disk buffers before they run, thus they are safe but
  416.     slow. Nevertheless if you modify the directory entry of a file that
  417.     is currently open, PCDOS will overwrite your modifications when it
  418.     closes that file. The functions return 0 if successful and PCDOS error
  419.     numbers if unsuccessful.
  420.  
  421.     dev            logical device 0=A:
  422.     blk            block number
  423.     blkcnt        number of blocks
  424.     buf            pointer to transfer buffer
  425.  
  426.     XFSTAT.OBJ -- contains the 'xfstat' function
  427.  
  428.     Include xstat.h
  429.  
  430.     int xfstat(int fd, struct _xstat *statbuf);
  431.  
  432.     fd            File descriptor of an open file.
  433.     statbuf        Pointer to _xstat structure (see xstat.h)
  434.     
  435.     Fast accurate access to basic stat info such as st_dev+st_ino.
  436.     The block map and block counts are set to zero.
  437.  
  438.     Returns -1 if bad args, 0 otherwise.
  439.  
  440.     3.3 SAMPLE PROGRAMS
  441.  
  442.     The directory 'SAMPLES' contains a few sample programs which
  443.     demonstrate the use of the .OBJ files. 'whereis' and 'dtree'
  444.     are useful.
  445.     
  446.  
  447.