SELFDIR(7)                testversion                       SELFDIR(7)


       selfdir - C-routine to get path of started executable

       WHAT IS IT ?
       ============

       selfdir()  find  out  the  path to a started executable by
       examinating argv0, which must be the very first argument of
       the  mainprogram  ( in C-programs mostly called argv[0] ),
       and the Enviromentvariable PATH of the calling shell.

       selfdir() return a string with the  path  of  the  started
       binary on success, and NULL on error.

       The  information  where  the executable lie can be used to
       make program-packages full path-independend.  This  avoids
       the  usage of special environmentvariables and the need to
       compile paths in a binary.  This is very  useful,  if  you
       want to spread program-packages over a lot of workstations
       with mirroring or nfs.

       If you hold your datafiles in the same  directory  as  the
       executable,  the  result  of selfdir() is the same path as
       the path to your datafile.

       If you append a relative path to the result of selfdir() ,
       you  can hold executable and datafiles in different subdi-
       rectories of the package.

       Cause selfdir() follows all filelinks,  when  it  searches
       the  executable,  you  can  install the directory with the
       program-package wherever you want, and you  should  lay  a
       filelink from the executable in the package to a directory
       in your PATH


       For a example, take a look at the manpage, or type 
    
       make test

       and take a look at the example-directory.


       The routine of selfdir() itself is shipped in a library called

       libselfdir.a

       its declaration comes in a file named 

       selfdir.h  


       History:
       ========     

       The orginal idea for a routine like this come from a old exotic 
       homecomputer named Acorn Archimedes. On this system programs are 
       alway started with the name of the directory. The "shell" set a 
       Environment-variable to this directory, and start the file 
       directory/!run (in 99.9% of all programs a "shell"-script), 
       which uses this Environment-variable, to find it's datafiles. 
       
       The main advantages of this concept are, that programs always find
       it's datafiles, and the easy you can deinstall program and datafiles 
       by only deleting recursivly it's directory. 

       Cause the Concept of the Acorn Archimedes is very unhandy under UNIX, 
       and non of the UNIX-shells provide the needed features, it can not
       be used under UNIX.

       One of my colleague's, Mr. Kurt Jaeger (jaeger@rus.uni-stuttgart.de),   
       has a problem, where the Concept of the Acorn Archimedes would be
       useful.
       He is a adminstartor of '/sw', a concept to spread compiled free
       software over a large range of workstations with nfs (or DCE/AFS) or   
       ftp-mirroring.
       In his concept it's one of the main problems, that programs either need
       a fix path (he uses /sw/<architecture>/<packagename>) which need to be
       compiled in the binary, or a ENVIRONMENT-variable, to point to the  
       datafiles of the programs (it is not trivial, to get a safe way to 
       spread ENVIRONMENT-variables over a lot of different workstations with 
       different administrators ...). 
       While a discussion with Mr. Jaeger i got the idea, to use a concept 
       similar to the concept of the Acorn Archimedes. If all programmers 
       would use such a concept, the problems in useing /sw will decrease.

       Now I wrote a program, I want to spread over a few workstations,
       which are connected via nfs. I improved the Acorn Archimedes concept 
       and made it independent from enviroment and the shell. 
       The result is selfdir().

       COPYRIGHT
       =========

       Copyright (c) MUFTI (Dipl. Phys. J. Scheurich (scheurich@rus.uni-stuttgart.de))

       This program is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published by
       the Free Software Foundation; version 2 of the License.

       This program is distributed in the hope that it will be useful,
       but WITHOUT ANY WARRANTY; without even the implied warranty of
       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       GNU General Public License for more details.

       You could have received a copy of the GNU General Public License
       along with this program; if not, write to the Free Software
       Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

       INSTALLATION
       ============

       Go into the directory 'selfdir' and type

       make install

       Default destination is '/usr/local'.
       Default installation method is makeing symbolic filelinks.
       Don't forget, that you may not remove the files in the directory
       'selfdir', if you use installation via filelinks.
      

       EMAILADRESS
       ===========

       If you want to improve selfdir, find a bug, even a english language 
       bug in the documentation 8-(, please write me a email.
       I can offer currently a few emailadresses, they all lead to the
       adress where I read my mail. Some of this adresses may disapear in
       the future 8-(

       mufti@ifswps4.fertigungstechnik.uni-stuttgart.de 
       scheurich@rus.uni-stuttgart.de
       zrzm0111@helpdesk.rus.uni-stuttgart.de
       zrzm0370@ftp.rus.uni-stuttgart.de


       I hope you will find 'selfdir' useful !

       yours
       MUFTI        

