home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / octave-1.1.1p1-base.tgz / octave-1.1.1p1-base.tar / fsf / octave / kpathsea / init-path.c < prev    next >
C/C++ Source or Header  |  1994-02-24  |  2KB  |  68 lines

  1. /* init-path.c: Find how to initialize a path.
  2.  
  3. Copyright (C) 1993, 94 Karl Berry.
  4.  
  5. This program is free software; you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation; either version 2, or (at your option)
  8. any later version.
  9.  
  10. This program is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. GNU General Public License for more details.
  14.  
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  18.  
  19. #include <kpathsea/config.h>
  20.  
  21. #include <kpathsea/default.h>
  22. #include <kpathsea/init-path.h>
  23.  
  24.  
  25. /* See init-path.h.  */
  26.  
  27. string
  28. kpse_init_path PVAR2C(const_string, current,
  29.                       const_string, default_path,  ap)
  30. {
  31.   string env_name;
  32.   string ret;
  33.   string env_path = NULL;
  34.  
  35.   /* First envvar that's set will exit the loop.  */
  36.   while (!env_path && (env_name = va_arg (ap, string)) != NULL)
  37.     {
  38.       env_path = getenv (env_name);
  39.     }
  40.   va_end (ap);
  41.   
  42.   /* Expand extra colons.  */
  43.   ret = kpse_expand_default (env_path ? env_path : current, default_path);
  44.   
  45.   return ret;
  46. }}
  47.  
  48. #ifdef TEST
  49. int
  50. main ()
  51. {
  52.   printf ("null = \"%s\"\n", kpse_init_path (false, "def", NULL));
  53.   printf ("TEXFONTS" = \"%s\"\n",
  54.           kpse_init_path (false, "def", "TEXFONTS", NULL));
  55.   printf ("GLYPHFONTS" = \"%s\"\n",
  56.           kpse_init_path ("false, def", "GLYPHFONTS", "TEXFONTS", NULL));
  57.   return 0;
  58. }
  59.  
  60. #endif /* TEST */
  61.  
  62.  
  63. /*
  64. Local variables:
  65. compile-command: "gcc -posix -g -I. -I.. -DTEST init-path.c kpathsea.a"
  66. End:
  67. */
  68.