/***************************************************************************** - - - POLONY SEQUENCER ACQUISITION SUITE - - Church Lab - - Harvard Medical School - - - - Free software for running a Polony Sequencing automated microscope - - - - ========================================================================= - - - - - - config_reader.cpp - - - - Class for reading parameters from a config (.cfg) file - - - - Written by Greg Porreca, 03-22-2006 - - - - Revised - - - - - - This software may be used, modified, and distributed freely, but this - - header may not be modified and must appear at the top of this file. - - - - - *****************************************************************************/ #include "config_reader.h" Config_reader::Config_reader(){;} Config_reader::Config_reader(char *cfgfn){ strcpy(CFGFILENAME, cfgfn); } Config_reader::~Config_reader(){;} int Config_reader::getTag(char *tag_value, char *tag_name){ FILE *CFGFILE; int return_val=0; char currtag_name[80]; char currtag_value[80]; if((CFGFILE = fopen(CFGFILENAME, "r")) == NULL){ // fprintf(stderr, "ERROR opening %s; trying ..\\..\\master.cfg\n", CFGFILENAME); if((CFGFILE = fopen("..\\..\\master.cfg", "r")) == NULL){ fprintf(stderr, "ERROR OPENING CONFIG FILE %s\n", CFGFILENAME); return 0; } } while( (fscanf(CFGFILE, "%s %s\r\n", currtag_name, currtag_value))!=EOF){ if(!(strcmp(currtag_name, tag_name))){ strcpy(tag_value, currtag_value); return_val = 1; } } fclose(CFGFILE); return return_val; }