home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
utility
/
fn32_13.zip
/
FN32.DOC
< prev
next >
Wrap
Text File
|
1993-02-10
|
17KB
|
447 lines
F N 3 2 - 3
PCDOS 32 character filename utilites.
Run Time Files
Version 1.32
February 10, 1993
Norman D. Culver
1323 S.E. 17th Street
Box 662
Ft. Lauderdale, FL 33316
Fax: (305) 760-7584
Compuserve 70672,1257
Copyright (C) 1992,1993 Norman D. Culver All rights reserved.
CONTENTS
1.0 INTRODUCTION
1.1 WHAT IS FN32
2.0 COPYRIGHT
2.1 LICENSE
2.2 WARRANTY
2.3 REGISTRATION
3.0 USING FN32-3
3.1 RUNNING THE TSR
3.2 UTILIZING THE .OBJ FILES
3.3 SAMPLE PROGRAMS
1.0 INTRODUCTION
1.1 WHAT IS FN32 ?
FN32 is a TSR, 3 object modules and 2 include files which support
32 character filenames under PCDOS. The TSR intercepts INT21h calls
and performs filename substitution by managing dictionary files in
each directory which contains longnames. The operation of
the TSR 'fn32.exe' is transparent to the user. The object modules
are substitutes for 'setargv.obj' and the 'stat' and 'fstat'
library routines. They also contain longname versions of 'opendir',
'readdir' etc.
Several of the GNU file utilities have been modified and are
in the package GNUDOS.ZIP. They are needed because many of the
standard PCDOS utilities truncate filenames to 8.3 internally.
The standard PCDOS stat info and filename globbing is inadequate
for a program written for unix so these utilities have been compiled
with the substitute obj files mentioned above.
Therefore, you get to use tar and unix or macintosh style names
without the usual PCDOS name mangling.
Also, conversion of many more unix programs for PCDOS is now a feasible
and rather simple project.
2.0 COPYRIGHT
The program fn32.exe, the object modules fn32argv.obj, xstat.obj
and xfstat.obj and the include files 'fn32argv.h' and 'xstat.h',
hereinafter known as the 'Run Time Files' are:
Copyright (c) 1992,1993 by Norman D. Culver with all rights reserved.
The readable source code for the Run Time Files is also
Copyright (c) 1992,1993 by Norman D. Culver with all rights reserved.
If you find FN32-3 to be a useful addition to your
software library, you are requested to become a registered
user by completing the registration form and returning it
along with a $ 25 license fee. The license fee is required
if FN32-3 is used in a commercial environment, it is also
a requirement for obtaining a copy of the source code.
2.1 LICENSE
You are granted a limited license to use and examine
FN32-3 on a trial basis to determine if FN32-3 is suitable for
your needs. If you find FN32-3 useful and use it on a regular
basis, you are requested to complete and return the registration
form along with the license fee.
Once you have registered, you are granted a license to
obtain the source code for your own personal use. You may
also embed the object files 'fn32argv.obj', 'xstat.obj'
and 'xfstat.obj' in programs written by you and distributed
for any purpose whatsoever.
You may not distribute the Run Time Files and especially
the program fn32.exe except under the terms of this license.
Original or modified versions of the FN32-3 source code files
are for your own personal use and may not be distributed in any form.
You are encouraged to make copies of FN32-3 Run Time Files
for the trial use of other individuals, subject to the following
restrictions:
All FN32-3 Run Time Files must be copied in
unmodified form, including the documentation,
registration and executable images.
You may not include any files other than the GNU
file utilities and FN32-3 sample programs with the copy.
FN32-3 Run Time Files may be included on electronic bulletin board
systems for downloading by users of the bulletin board provided
the above restrictions are met.
2.2 WARRANTY
FN32-3 AND ALL ACCOMPANYING MATERIALS ARE PROVIDED "AS IS"
WITHOUT WARRANTY OF ANY KIND. THE ENTIRE RISK OF USING
FN32-3 IS ASSUMED BY YOU.
Norman D. Culver makes no warranty of any kind, express or
implied, including but not limited to any warranties of
merchantability and fitness for a particular purpose.
IN NO EVENT WILL NORMAN D. CULVER BE LIABLE FOR ANY DAMAGES
WHATSOEVER (INCLUDING BUT NOT LIMITED TO DAMAGES FOR LOSS OF
BUSINESS PROFITS, LOSS OF SAVINGS, BUSINESS INTERRUPTION,
AND THE LIKE) ARISING OUT OF YOUR USE OR INABILITY TO USE
THE PROGRAM.
BY USING FN32-3, YOU AGREE TO THE ABOVE LIMITATIONS.
2.3 REGISTRATION
If you use FN32-3 on a regular basis, you are requested to
complete the following registration form and return it along
with a $ 25 license fee. Registration gives you the right
to use the software as documented in the license.
Registration is necessary only once - registration allows
you licensed use of all upgrades to the product.
Registration is required if FN32-3 is used in a commercial
environment. Contact Norman D. Culver for information on
quantity discounts or site-license agreements.
You can register through Compuserve, the shareware registration
id is 295.
Source code for FN32-3 is available to registered users for a
copying, shipping and handling fee of $5. Please send a
formatted high density diskette, 3.5 or 5.25, which will be
loaded up and returned to you.
Registered users can obtain support from the author for a
period of 90 days after registration. You can use regular
mail, fax or Compuserve mail to contact me.
The following form is reproduced in the REGISTER.FRM file
for your convenience.
------------------------------------------------------------
FN32-3 Version 1.32 Registration Form 1-Sep-92
To become a registered user of FN32-3, complete and return
this form along with a $ 25 license fee. The license fee
should be a check or money order, payable in USA funds.
Add $ 5 for copying, shipping and handling of the source code.
Please enclose a formatted high density diskette which will
be loaded up and returned to you.
Send to: Norman D. Culver
1323 S.E. 17th Street
Box 662
Ft. Lauderdale, FL 33316
U.S.A.
Name: ___________________________________________________
Company: ___________________________________________________
Address: ___________________________________________________
___________________________________________________
___________________________________________________
Please accept this registration for FN32-3.
I agree to your disclaimer of all warranties and the
restrictions on copying.
________________________________________ _______________
SIGNED DATE
Please feel free to add any comments, friendly criticisms,
problem reports, and improvement ideas you might have about
the product.
THANK YOU FOR YOUR SUPPORT!
------------------------------------------------------------
3.0 USING FN32-3
3.1 RUNNING THE TSR
FN32-3 requires an IBM PC/AT or compatible system to
work properly. In addition, version 2.0 or greater of
PC-DOS or MS-DOS is required.
At the DOS prompt type 'FN32' followed by a carriage return.
FN32.EXE will install itself and print a copyright message.
To deinstall, type 'FN32 -d' followed by a carriage return.
If it is installed, FN32.EXE will deinstall itself.
FN32.EXE sets the switch char to '-' when it is installed and
restores the old switch char when it is deinstalled.
DOS int21 calls which supply path strings are intercepted by FN32.EXE and
those which contain file or directory names which exceed the DOS limits
of 8.3 are reformulated with appropriate short names. The long names
(32 chars max, case insensitive) are stored in dictionary files named
$!$INDEX.$!$ in each relevant directory. The dictionary files contain a
sequence of 32 byte records. Names shorter than 32 bytes are padded on
the right with zeros.
Each dictionary file contains a 16 bit unsigned counter in record 0.
Short names are constructed in one of two ways:
1. The counter is incremented and used.
2. An empty slot is found in the file (the result of an earlier delete)
and the slot number is used.
Empty slots always take precedence over bumping the counter.
Dictionary files are automatically deleted when the last entry is deleted.
The format of a short name is X.$!$ where 'X' is 1 to 4 hex digits. To the
best of my knowledge this is a unique identifier in the DOS world.
Names start at 1.$!$ .
The PCDOS 'DIR' command will show the dictionary files and the short
forms of the file names. Use the 'ls' program from the GNU file utilities
to see the long names. All of the GNU file utilities work with longnames
as do all of the compilers and editors I have tried. Unfortunately
some DOS application programs are too smart for their own good and
truncate filenames to 8.3 internally so we do not have a universal
solution here.
3.2 UTILIZING THE .OBJ FILES
All of the .obj files have been compiled with MSC 6.0 using memory
model ACw (near code pointers, far data pointers, SS!=DS). They
will link with programs compiled as AC ACw AL and ALw. The only
external variable or function used is 'extern int errno'.
FN32ARGV.OBJ -- create an array of arguments and optionally _stat structs
-- + a 'DIR' package _opendir,_readdir,_telldir etc.
-- + a version of 'rename' which handles longnames
Include fn32argv.h
int fn32argv(int *argcp,char ***argvp,_stat ***statvp, int flag)
void argv_free(int *argcp,char ***argvp,_stat ***statvp)
argcp pointer to argument count
argvp pointer to argument array pointer
statvp pointer to _stat structure array pointer, or NULL
flag contains flag bits which modify filename globbing and selection
/* Globbing bits */
FN32_LEADING_DOT Allow leading dot if pattern contains one
FN32_IS_PATH Test string is a path, '/' is a separator
FN32_USES_ESCAPES Pattern contains escapes
FN32_PCDOS Convert '*.*' to '*'
/* stat selection bits */
FN32_S_IEXEC Select executable files
FN32_READONLY Select readonly files
FN32_HIDDEN Select hidden files
FN32_SYSTEM Select system files
FN32_VOLUME Select volume labels
FN32_DIRECTORY Select directories
FN32_ARCHIVE Select files with archive bit set
FN32_ALL_FILES Select all files including '.' and '..'
fn32argv.obj is a substitute for setargv.obj but is explicitly
called from inside the user's program. This feature permits
construction of arguments from programmer defined argc and argv.
It implements POSIX filename globbing with an extension for deep
recursion. i.e. ** means go to the bottom of the subdirectory chain.
e.g.
"/usr/**/*.h" gets all include files in subdirectories below /usr.
"[a-z]:/**/*" gets all files on all drives.
"**/*" gets everything in the current and all lower subdirs
"/**/*" gets all files from the current drive
"*:/**/*" gets all files from all drives
"[cde]:/**/*" gets all files from partitions c:, d: and e:
"/usr/**[ab]/*.bat" gets all .bat files from all levels of subdirectories
below /usr which end in 'a' or 'b'
"/usr/*[ab]/*.bat" gets all .bat files from one level of subdirectories
below /usr which end in 'a' or 'b'
/* The following code prints a list of every file on the c drive */
{
int i;
int argc
char arg[] = "c:/**/*"
char **argv;
argc = 1;
argv[0] = arg;
/* Use FN32_ALL_FILES to get files with leading dots */
/* Use FN32_DIRECTORY to get directories */
fn32argv(&argc, &argv, NULL, FN32_ALL_FILES);
for(i = 0; i < argc; ++i)
printf("%s\n", argv[i]);
argv_free(&argc, &argv, NULL);
}
/* The following code gives you what you would expect from a unix shell. */
main(int argc, char **argv)
{
/* Use FN32_PCDOS to make *.* == * */
fn32argv(&argc, &argv, 0, FN32_PCDOS);
}
/* If you don't need st_dev+st_ino to uniquely identify a file then
you can get the stats for each argument laid out in an array,
see fn32argv.h for the _stat structure which is a little more
elaborate than the standard PCDOS struct. In particular it
contains the DOS attrib byte in st_xmode and will contain
a null terminated short filename if a longname was used. */
main(int argc, char **argv)
{
struct _stat **statv;
fn32argv(&argc, &argv, &statv);
}
argv_free() is a function to free the storage (which may be very large)
allocated to the argument and optional stat arrays.
THE 'DIR' PACKAGE IN FN32ARGV.OBJ
This set of functions is named _opendir, _readdir, _seekdir
_telldir and _closedir. They operate in the usual manner but
return information to structures which are quite a bit more
elaborate than the PCDOS equivalents. see fn32argv.h
There is one glaring omission, 'd_ino', which cannot be retrieved
in a time efficient manner when the file is not open. Use
'xstat' or 'xxstat' or 'xfstat'.
THE 'RENAME' FUNCTION IN FN32ARGV.OBJ
This function resolves all longnames except the 'to' file before
it calls PCDOS rename. The TSR fn32.exe will create the final
longname. NOTE: PCDOS 'rename' will not rename directories. The
program 'mvdir.exe' must be used for this purpose.
XSTAT.OBJ -- contains the 'xstat' and 'xxstat' functions
+ x_abs_read and x_abs_write
Include xstat.h
struct _xstat *xxstat(char *path);
int xstat(char *path, struct _xstat *statbuf);
void xstat_free(void *statbuf);
path File path name
statbuf pointer to a struct _xstat (see xstat.h, this structure
contains a valid st_dev+st_ino pair as well as other useful
elements such as the correct number of blocks allocated.
If the function 'xxstat' is used it will contain a
complete block map of the file or directory referenced. The
first set of contiguous blocks is returned by 'xstat'. NOTE:
the structure returned by 'xxstat' is of variable length
and could be quite large. Use 'xstat_free' to return storage
allocated by 'xxstat'.
Returns: xxstat returns NULL and sets errno to ENOENT if not found.
xstat return 0 if successful and -1 with errno=ENOENT if not found.
int x_abs_read(int dev,unsigned long blk,unsigned short blkcnt,void *buf);
int x_abs_write(int dev, unsigned long blk,unsigned short blkcnt,void *buf);
The functions 'x_abs_read' and 'x_abs_write' can be used to directly
access directories and files that are mapped by 'xxstat'. The functions
flush the PDCOS disk buffers before they run, thus they are safe but
slow. Nevertheless if you modify the directory entry of a file that
is currently open, PCDOS will overwrite your modifications when it
closes that file. The functions return 0 if successful and PCDOS error
numbers if unsuccessful.
dev logical device 0=A:
blk block number
blkcnt number of blocks
buf pointer to transfer buffer
XFSTAT.OBJ -- contains the 'xfstat' function
Include xstat.h
int xfstat(int fd, struct _xstat *statbuf);
fd File descriptor of an open file.
statbuf Pointer to _xstat structure (see xstat.h)
Fast accurate access to basic stat info such as st_dev+st_ino.
The block map and block counts are set to zero.
Returns -1 if bad args, 0 otherwise.
3.3 SAMPLE PROGRAMS
The directory 'SAMPLES' contains a few sample programs which
demonstrate the use of the .OBJ files. 'whereis' and 'dtree'
are useful.