home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / misc / sci / gfft / source / gopen.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-25  |  1.4 KB  |  44 lines

  1. /***************************************************************************
  2.  *          Copyright (C) 1994  Charles P. Peterson                  *
  3.  *         4007 Enchanted Sun, San Antonio, Texas 78244-1254             *
  4.  *              Email: Charles_P_Peterson@fcircus.sat.tx.us                *
  5.  *                                                                         *
  6.  *          This is free software with NO WARRANTY.                  *
  7.  *          See gfft.c, or run program itself, for details.              *
  8.  *              Support is available for a fee.                      *
  9.  ***************************************************************************
  10.  *
  11.  * Program:     gfft--General FFT analysis
  12.  * File:        gopen.c
  13.  * Purpose:     Open a file (using provided path list)
  14.  * Author:      Charles Peterson (CPP)
  15.  * History:     13-September-1993 CPP; Created.
  16.  * Comments:    
  17.  */
  18.  
  19. #include <stdio.h>
  20. #include <strings.h>
  21. #include "gfft.h"
  22.  
  23. void *gopen (char *path_list[], char *filename, char *mode)
  24. {
  25.     FILE *file = NULL;
  26.     char full_filename [MAX_PATH];
  27.     int path_index = 0;
  28.  
  29.     while (!file)
  30.     {
  31.     if (!path_list[path_index]) break;
  32.     if (strlen (path_list[path_index]) + strlen (filename) + 1 > 
  33.         MAX_PATH)
  34.     {
  35.         error_message (FILENAME_TOO_LONG);
  36.     }
  37.     strcpy (full_filename, path_list[path_index]);
  38.     strcat (full_filename, filename);
  39.     file = fopen (full_filename, mode);
  40.     path_index++;
  41.     }    
  42.     return file;
  43. }
  44.