1 /* atlc - arbitrary transmission line calculator, for the analysis of
2 transmission lines are directional couplers.
4 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either package_version 2
9 of the License, or (at your option) any later package_version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
21 Dr. David Kirkby, e-mail drkirkby at ntlworld.com
25 /* This function take a filename with the extension .bmp (eg coax.bmp)
26 and will produce files such as coax.V.bmp, coax.E.bmp, coax.E.bin etc */
42 #include "definitions.h"
43 #include "exit_codes.h"
45 FILE *get_file_pointer_with_right_filename(char *filename, const char *extension)
47 char *basename, *temp;
49 basename=string(0,1024);
51 (void) memset((void *)temp,0,(size_t) 1024);
52 (void) memset((void *)basename,0,(size_t) 1024);
54 basename=strncpy(basename,filename,strlen(filename)-4);
55 (void) strcpy(temp,basename);
56 (void) strcat(temp,extension);
57 if((fp=fopen(temp,"w+b"))==NULL)
59 fprintf(stderr,"Sorry, cant open %s for writing\n", temp);
60 exit_with_msg_and_exit_code("",CANT_OPEN_FOR_WRITING);
62 free_string(basename,0,1024);
63 free_string(temp,0,1024);