2 * This file is part of TISEAN
4 * Copyright (c) 1998-2007 Rainer Hegger, Holger Kantz, Thomas Schreiber
6 * TISEAN is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * TISEAN 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 TISEAN; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 /*Author: Rainer Hegger Last modified: Sep 3, 1999 */
27 char check_col(char *col)
31 for (i=0;i<strlen(col);i++)
32 if (!isdigit((unsigned int)col[i])) {
33 fprintf(stderr,"Column must be a unsigned integer. Ignoring it!\n");
39 char look_for_column(char *name,unsigned int *col)
45 check_alloc(hname=(char*)calloc(strlen(name)+1,1));
46 check_alloc(hcol=(char*)calloc(strlen(name)+1,1));
48 while (*(name+j) != '\0') {
49 if (*(name+j) == ',') {
50 in=sscanf(name+j+1,"%s",hcol);
59 *col=(unsigned int)atoi(hcol);
66 char* search_datafile(int n,char **names,unsigned int *col,
67 unsigned int verbosity)
69 char valid=0,validcol=0;
76 if (names[i] != NULL) {
78 if (strcmp(names[i],"-")) {
80 validcol=look_for_column(names[i],&hcol);
81 test=fopen(names[i],"r");
83 fprintf(stderr,"File %s not found!\n",names[i]);
87 if ((col != 0) && (validcol == 1))
90 if (verbosity&VER_INPUT)
91 fprintf(stderr,"Using %s as datafile, reading column %u\n",
95 if (verbosity&VER_INPUT)
96 fprintf(stderr,"Using %s as datafile!\n",names[i]);
98 check_alloc(retname=(char*)calloc(strlen(names[i])+1,(size_t)1));
99 strcpy(retname,names[i]);
112 if (verbosity&VER_INPUT)
113 fprintf(stderr,"Reading input from stdin!\n");
117 if (verbosity&VER_INPUT) {
118 if ((col != 0) && (validcol == 1))
119 fprintf(stderr,"Reading input from stdin, using column %u!\n",*col);
121 fprintf(stderr,"Reading input from stdin!\n");