

 NNNNAAAAMMMMEEEE  -  SaveNames 1.4


 _C_o_p_y_r_i_g_h_t_ _(_w_h_y_ _n_o_t_._._._)

 SSSSaaaavvvveeeeNNNNaaaammmmeeeessss    vvvv1111....1444 software and documentation are copyrighted © 1995-1996 by
 MMMMaaaarrrrcccciiiinnnn    OOOOrrrrlllloooowwwwsssskkkkiiii. All Rights Reserved.

 Update to vvvv1111....4444 is made by TTTTaaaaddddeeeekkkk    KKKKnnnnaaaappppiiiikkkk. Thanks.


 _D_i_s_t_r_i_b_u_t_i_o_n_ _(_p_i_r_a_t_e_ _o_r_ _d_i_e_!_)

 Freely distributable in complete archive with following files included:

 SaveNames.c         - source code
 SaveNames.c.info    - source icon
 SaveNames.doc       - this documentation
 SaveNames.doc.info  - documentation icon
 SaveNames.man       - this documentation in UNIX's man format
 SaveNames           - AAAAmmmmiiiiggggaaaa executable
 SaveNames.info      - AAAAmmmmiiiiggggaaaa executable icon
 SD!.displayme       - our BBS info


 _D_i_s_c_l_a_i_m_e_r_ _(_a_s_ _a_l_w_a_y_s_ _:_)

 No responsibility or liability will be accepted for any damage that
 may appear to have resulted from use of this program. All use is at
 your own risk. The software is provided "as is" without any warranty
 implied or otherwise to the fitness or accuracy of the software and
 documentation. The author reserves the right to update the software
 and/or documentation without notice.


 _U_s_a_g_e_ _(_w_h_a_t_ _i_s_ _i_t_!_?_)

 Some people (like me) are forced to use pee-cee machines to transfer
 files from internet to my AAAAmmmmiiiiggggaaaa (it doesn't mean I've bought a pc
 for my own! I use (big word:) it only at my technical university).
 As you all know, no one needs more chars to name his files than 8.3,
 which seems to be a 'professional filename format'. Any other, longer
 names are obsolete and should be forbidden. Unfortunately both AAAAmmmmiiiiggggaaaa
 and Unix based machines use longer names for their files, so
 transfering files between those platforms via pc causes 90% of name
 (mainly dots :) to be eaten by pc. So I decided to cure this.
 SaveNames is the medicine against. What does it do? Lets say, you want
 to transfer some files stored in directory _M_y_F_i_l_e_s on your Unix
 account to AAAAmmmmiiiiggggaaaa via pc floppies. Files use 'obsolete' names:

                     kickstart
                     KICKdisk.info
                     kickstart.info

 So before you start to copy them to disk type:

                     SSSSaaaavvvveeeeNNNNaaaammmmeeeessss    CCCC    MMMMyyyyFFFFiiiilllleeeessss

 and names of all files in this directory are converted (CCCC means
 CCCCOOOODDDDEEEE and may be lowercase or mixedcase) to less than 8 chars (suffix
 PPPPCCCCPPPP (pc protection :) will also be added to allow you easily detect
 those files, or automate decoding e.g. via _D_O_p_u_s_ _F_i_l_e_C_l_a_s_s. If you use
 _D_O_p_u_s set class checking to: MMMMAAAATTTTCCCCHHHHNNNNAAAAMMMMEEEE    WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx    OOOORRRR    MMMMAAAATTTTCCCCHHHHNNNNAAAAMMMMEEEE    ####????....ppppccccpppp
 and operation to ((((AAAAmmmmiiiiggggaaaaDDDDoooossss)))) SSSSaaaavvvveeeeNNNNaaaammmmeeeessss    DDDD    {{{{ssss}}}} and you will decode files
 by doubleclick.). Phew, you said? No big deal? pc does it itself! Bet it
 doesn't. If you look in your MMMMyyyyFFFFiiiilllleeeessss drawer you'll find the new file
 named WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx looking like that:

                     7204094 kickstart
                     720704c KICKdisk.info
                     72085c4 kickstart.info

 Got it? Yes! Those data are used to restore filenames after whole
 transfer on destination machine. How to do this? Copy transfered files
 from pc disks to one directory on your Amiga disk (e.g. MMMMyyyyFFFFiiiilllleeeessssTTTToooooooo)
 and type:

                     SSSSaaaavvvveeeeNNNNaaaammmmeeeessss    DDDD    MMMMyyyyFFFFiiiilllleeeessssTTTToooooooo

 This time command DDDD means DDDDeeeeccccooooddddeeee. Program opens file index
 described below and renames all known (stored in index) files back
 to theirs original names. Simple? Yes, it is. And it works too!

 NNNNOOOOTTTTEEEE:::: Command DDDD has special, expanded mode, activating by ----
 as command prefix: ----DDDD. See _T_e_c_h_n_i_c_a_l_ _I_n_f_o chapter to find
 out what this feature is for.

 While names coding SSSSaaaavvvveeeeNNNNaaaammmmeeeessss shows you estimated number of disks
 you will need to store all your crypted files on. If you want
 do this calculation without main code process use ----CCCC command
 instead of CCCC.

 Since version 1111....4444 SSSSaaaavvvveeeeNNNNaaaammmmeeeessss has ability to sssspppplllliiiitttt large files into smaller
 pieces. For what? Imagine you have just downloaded Aminet Index (as I had).
 It's big, isn't it? Of course I compressed it, but it was still more KBytes
 than PC DD diskette (however it would fit on AAAAmmmmiiiiggggaaaa DD harmless :-).
 SSSSaaaavvvveeeeNNNNaaaammmmeeeessss can help you manage it. Just type:

                     SSSSaaaavvvveeeeNNNNaaaammmmeeeessss    CCCC    MMMMyyyyFFFFiiiilllleeeessss    SSSSpppplllliiiittttSSSSiiiizzzzeeee

 which means you want files larger than SSSSpppplllliiiittttSSSSiiiizzzzeeee bytes to be parted
 into smaller pieces (with size defined as SSSSpppplllliiiittttSSSSiiiizzzeeee). In result you get:

                     78003582.pc0
                     78003582.pc1
                     78003582.pc3
                     ............
                     ............
                     78003582.p74

 while WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx still holds only one entry with '78003582.pcp'.
 Joining is done during DECODing automatically and fully transparently
 whenever needed. No need for extra switches and keywords to be used.

 Thanks to this option you don't have to use another program for splitting.
 SaveNames does everything, and does it in a convenient way, not leaving
 you with partial files after rejoining, like some splitters (unless an
 error occures, of course).

 Note: To split a file, you need spare space equal to size of splitting
 file (obvious). To join it back it, you need spare space of equal to 
 SplitSize you used while splitting. Be careful on low storage (disk full).
 Splitting may take a while...

 You can use any SSSSpppplllliiiittttSSSSiiiizzzzeeee you want but SSSSaaaavvvveeeeNNNNaaaammmmeeeessss assumes you know what you
 are doing so therefore it got no superb dumb filters built-in and is not
 idiot-proof. Every file can be maximally splited into 999 due to pee-see
 ?poor filename scheme. This should be enough for almost all cases (hey,
 you're not downloading encyclopedia everyday, are you?). Instead
 of typing 777722220000000000000000 or 1111444444440000000000000000 as SSSSpppplllliiiittttSSSSiiiizzzzeeee you can use DDDDDDDD or HHHHDDDD
 equivalents (case insensitive).


 _R_e_q_u_i_r_e_m_e_n_t_s

 Something with Intel outside, few bytes of free memory, files to eat,
 2 busty babes and 1 big beer.


 _T_e_c_h_n_i_c_a_l_ _i_n_f_o_ _(_s_o_u_n_d_s_ _s_o_o_o_o_ _w_i_s_e_._._._ _:_)

 Portability is base idea of this project, so SSSSaaaavvvveeeeNNNNaaaammmmeeeessss is written in
 plain _A_N_S_I_ _C and may be simply compiled on any machine. If you find any
 problems, let me know! And do not compile it on pc - it doesn't have any
 sense... :)

 Unfortunately small changes, as always, have to be done before you run
 the compiler, so look into the source, and select your platform (for
 now AAAMMMMIIIIGGGGAAAA, UNIX (being honest IRIX) and LINUX is checked and supported.
 If you port it to Mac world let me know and send changes to me (in this
 case please do only small GUI). AAAAMMMMIIIIGGGGAAAA side was tested on my AAAA4444000000000000, UNIX
 platform was tested on SILICON GRAPHICS' IRIS INDIGO and HP. LINUX side
 was tested on... LINUX side :-)

 Name encoding is done in two passes. 1st pass - scanning directory
 and building coded names, 2nd pass renaming files and writting
 index file. It has to be done this way, because scanning directory
 while it is changing, may (and in 99% it does) put the program in the
 infinite loop. Sometimes we may also miss some files. Decoding is done
 in one pass.

 Starting to decode, program tries to read index file first. First it
 tries to open file named WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx. If file couldn't be found,
 it tries to open file again, with name in lowercase and if it fails
 to, the last try use uppercased name. This is important mainly for
 Unix side, because Unix is casesensitive. So if you transferred
 your files via pc, the names may be 'fixed' to lower or uppercase.
 While decoding, program may do the same trick with files to decode,
 but this feature is defaulty off, which means that only one try is
 attemped, and filenames are supposed to be exactly the same as while
 coding. Use ----DDDD instead of DDDD to turn this on.

 You may convert as many file names as you wish, because there's no
 static arrays, but dynamicaly build list. You are only limited by your
 memory. To code 1000 names you will need, on AAAAmmmmiiiiggggaaaa, about 266KB. Why
 only 266KB? Because every name is stored in a list's entry containing
 pointer to next entry (on 32bit machines it takes 4 bytes), converted
 name (12 chars + trailing zero) and original file name. The size of last
 entry depends on your system. In your system includes, you will find
 definition of _M_A_X_N_A_M_E_L_E_N, which limits max length of filename. On AAAAmmmmiiiiggggaaaa
 it's set to 255 chars. For now it's too much, because you cannot use names
 longer than 30 chars (because there's no more free bytes on disk block).
 So if you are RRRREEEEAAAALLLLLLLLYYYY out of memory, you may change this by hand (see
 included source). Safe value is 108, because system structure
 FileInfoBlock reserves exactly 108 bytes for filename. You may save then
 few bytes. E.g. for those 1000 files mentioned above, with _M_A_X_N_A_M_E_L_E_N
 set to 30 you will save 248KB, with _M_A_X_N_A_M_E_L_E_N set to 108, only :) 145
 KB but think what are you doing! You probably never code more than 100
 names in one session and you surely do not use A1000 with 256 KB RAM. So
 better leave MAXNAMELEN alone...

 You may ask: How do you code filenames to those weird numbers, pal?
 I answer: I do not code it at all! I'm just copying file's own INode
 (it's kind of FileHandle on Unix machines). Because all filesystems
 use almost the same algorithms, it also use INodes without any tricks
 (maybe pc does it different, but who cares pc?). Sometimes it is
 called INode, sometimes FileHandle and sometimes BlahBlahBlah, but
 it always means the same - almost unique number belongs to file.
 On Amiga side I could use GetUniqueID() from utility.library, but
 it is available under OS3.0 and newer and, what is more important,
 generates only 4294967295 unique numbers. That's all.


 _B_u_g_s_ _(_e_e_p_._._._)
 
 Program doesn't recognize if name belongs to directory or to file and
 treats all the same. For now, it also can't scan directories
 recursively. Solution: do not create subdirs in drawer you want
 SaveNames to process.
 
 There may appear some problems if you will have two files in the dir,
 being in fact links to other file. In this case INode will be the
 same. Solution: use proper file instead of its shadows.

 You must nnnnooootttt have file named WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx in your drawer, because
 while encoding/decoding it's written/read sequentially. So while
 encoding it may be overwriten (but not if it is 1st file
 in directory :). While decoding it will be skipped, because of
 already opened (being in use) file with the same name. Solution:
 rename your file :)

 On Amiga side SaveNames doesn't work when called from WB. If I find some
 spare time I maybe add this, but I am not quite sure it's really needed.

 If you have transferred this archive from Unix account to your
 machine via pc, you have probably noticed that few letters have been
 eaten.. You should use... SaveNames to avoid it! :)

 Some older compilers requires the function to be declared in old C&R
 style (see the source if you don't know what it's about). If you are
 own such a compiler, simply uncommet the OOOOLLLLDDDD____SSSSTTTTYYYYLLLLEEEE definition before
 you start to compile the program.


 _F_u_t_u_r_e_ _p_l_a_n_s_ _(_w_o_w_!_)
 
 If someone finds a reason to decode single files too, I will add this
 feature on request, bacause it's easy to do... :)

 I also may add WB handling, but I don't think anybody needs this.

 Recursive directory scanning.


 _H_i_s_t_o_r_y_ _(_w_h_a_t_ _h_a_s_ _h_a_p_p_e_n_ _t_o_ _t_h_e_ _S_h_e_r_l_o_c_k_ _H_o_l_m_e_s_ _i_n_ _t_h_e_ _p_a_s_t_)

  * v1.0  -  Initial release
             Worldwide distribution
             Begin of SaveNames-mania....

  * v1.1  -  WWWWAAAARRRRNNNNIIIINNNNGGGG: Internal format of the _W_F_M_H_F_i_l_e_._i_d_x
             has been changed! Better decode all old stuff
             before you install this release!

             _C_h_a_n_g_e_s_:

          -  LINUX and gcc differences and needs supported
          -  Unnecessary %ld's replaced by %d's
          -  SSSSaaaavvvveeeeNNNNaaaammmmeeeessss could not find the index file on Unix
              side if its name was 'processed' by pc (see manual)

             Reported by _N_i_k_l_a_s_ _E_d_m_u_n_d_s_s_o_n

          -  Added old C&R function declaration for older compilers
              (this feature is switchable and defaulty is off)
          -  SaveNames will not remove WWWWFFFFMMMMHHHHFFFFiiiilllleeee....iiiiddddxxxx index file
              if restoring was not 100% successed

             Suggested by _K_o_n_r_a_d_ _D_u_b_i_e_l.

  * v1.2  -  Expand decoding mode added (see 'Technical Info').
          -  Solved problems with names contain spaces (this was
              the main reason I've changed the index file format).
          -  SaveNames can now calculate number of disks you will
              need to store contents of your dir on floppies
              (both for Amiga and pc disks) and number of bytes
              left free on the last diskiette.
          -  New command '-C' ('-COUNT') added, which scans given
              directory and counts total length of files and
              floppy disk usage (while coding, those information
              will also be shown).
          -  Source slightly rewritten.

  * v1.3  -  Small code improvements (it's now even more portable :-)
          -  Enforcer hit removed

  * v1.4  -  File splitting added.
          -  Bug fix: Now doesn't lock up if you already have
              WFMHFile.idx in the dir and want to CODE something.
          -  Now statistics shows total size in KB or MB only
             when needed (no more 0 KB etc).


 _A_u_t_h_o_r_ _(_i_t_'_s_ _m_e_,_ _i_t_'_s_ _m_e_)
 
 MMMMaaaarrrrcccciiiinnnn    OOOOrrrrlllloooowwwwsssskkkkiiii
 ul. Radomska 38
 71-002 Szczecin
 Poland

 _E_-_M_a_i_l: carlos@dedal.man.szczecin.pl
 _W_W_W: http://www.szczecin.pl/~carlos

 FidoNet:       Marcin Orlowski@2:481/22.2
 GlobalNet:     Marcin Orlowski@52:4800/6


 Responsible for SaveNames v1.4 is:

    TTTTaaaaddddeeeekkkk    KKKKnnnnaaaappppiiiikkkk
 ul. Duza Gora 35/88
 30-857 Krakow
 Poland

 _E_-_M_a_i_l: tadek@student.uci.agh.edu.pl

 Improving SSSSaaaavvvveeeeNNNNaaaammmmeeeessss from v1.3 to v1.4 (under the Marcin's agreement) is
 the first thing I've done in C (excluding K&R's Chapter 1 exercises :-)
 so it may be somewhat strange kind of code. It WORKS, but you should
 look at it if you're not very trusting person... :-)


--------------------- C O M M E R C I A L    B R E A K --------------------

      ______ __   __
     / ____//_/  / /            Find your way to the smallest & slowest
    / /___ __   / /  __  __ ______ _____
   /___  // /  / /  / / / // ____// .__/   BBS in central Europe !!!
  ____/ // /_ / /_ / /_/ // __/_ / /
 /_____//___//___/ \____//_____//_/           WWWW....FFFF....MMMM....HHHH.... support
                                                                 __
                       ____       GlobalNET: 52:4800/6       __ / /
  _+_4_8_ _9_1_ _5_4_0_4_3_1       / __ \        FidoNET: 2:481/22.2     / / \/
                     / / / /_____ ______ ______ _   _      / /   ______
 22224444    HHHHoooouuuurrrrssss    ////    DDDDaaaayyyy     / / / // .__// ____// __  // \_/ \    /_/   / ____/
                   / /_/ // /   / __/_ / __  // /__/ /   __    _\__  /
 1111222200000000-11119999222200000000 bps   /_____//_/   /_____//_/ /_//_/  /_/   /_/   /_____/

     Serving on AAAA3333000000000000, 2222CCCCDDDDTTTTVVVVssss, 2222AAAA555500000000++++, 5555 additional CCCCDDDD----RRRROOOOMMMMs on-line
                      For all AAAAmmmmiiiiggggaaaassss, Macs and C64

