/* @(#)classify.c 17.1.1.1 (ESO-DMD) 01/25/02 17:50:04 */ /*=========================================================================== Copyright (C) 1995 European Southern Observatory (ESO) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. Correspondence concerning ESO-MIDAS should be addressed as follows: Internet e-mail: midas@eso.org Postal address: European Southern Observatory Data Management Division Karl-Schwarzschild-Strasse 2 D 85748 Garching bei Muenchen GERMANY ===========================================================================*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .TYPE Module .NAME tbapplyrul.c .LANGUAGE C .AUTHOR IPG-ESO Garching .CATEGORY Data Organizer utilities .COMMENTS This module implements the following Midas commands: \begin{TeX} \begin{enumerate} \item {\tt CLASSIFY/IMAGE} table rule column outchar \end{enumerate} \end{TeX} .VERSION 1.0 15-Mar-1993 Definition M. Peron 991130 -----------------------------------------------------------------------*/ #include #include #include #include #include #include #define issign(c) ((c == '+') || (c == '-')) #define BUFM 30 /* synchronize with tbcomsel !! */ #define MAXS 30 #define PARLEN 256 #define MAXLEN 80 char *osmmget(); char *token,*line; double tdtrue,tdfalse; int token_type,first,nochar,refrow,action,exist; int tmno[BUFM],tmnoc[BUFM]; char *stringstar[MAXS]; int occ[PARLEN],ocp[PARLEN],principal; /* */ int classify(intable,assod,column,mycval) char intable[60],column[1+TBL_LABLEN],assod[256],*mycval; { int status,tid,nrow,ncol,nicol; int null, len, lennew, dummy, type; int col,sel,cstar[PARLEN],nstar,nstring,pnull[PARLEN]; int i,j,*index, lola,k,start,pos,pos1,pos2,ntimes,itimes,tidass,nline,ntoken ; int coldescr,colout,colchar,meth,selass,mylen; int ibuf[BUFM],nconst[BUFM], unit; int kk; char selrules[PARLEN], colstar[1+TBL_LABLEN]; char *selecrit,outdescr[8]; char *final,*stringtok[MAXS]; char descr[256],*nume,*cval; double *data[BUFM],consta[BUFM]; char *string[BUFM],*cdata[BUFM]; float tblsel; action = 1; exist = 0; cval = osmmget(MAXLEN+1); line = osmmget(PARLEN); token = osmmget(PARLEN); TCMCON(&tblsel,&tdtrue,&tdfalse); for (i=0; i 0) { status = TCERDC(tid,i+1,cstar[occ[j]-1],cval,&pnull[j]); if (pnull[j] == 0) { if (ocp[j] && final[0] != 0) strcat(final,"+"); if (*stringtok[occ[j]-1] == '*') { strcat(final,stringstar[j]); kk = strskip(cval,' '); k = strbskip(cval+kk,' '); if (cval[k+kk+1]) cval[k+kk+1] = '\0'; k = strlen(cval)-strlen(stringtok[occ[j]-1])+1; cval[k] = '\0'; strcat(final,cval+strskip(cval,' ')); } else { strcat(final,stringstar[j]); kk = strskip(cval,' '); k = strloc(cval+kk,' '); if (cval[k+kk]) cval[k+kk] = '\0'; strcat(final,cval+strlen(stringtok[occ[j]-1])-1+strskip(cval,' ')); } } } else if (pnull[-occ[j]-1] == 0) strcat(final,stringstar[j]); } TCEWRC(tid,i+1,col,final); } } } /*for (i=0; i pos2) { pos1 = strloc(mydecval,'&'); if (!stringstar[*index]) stringstar[*index] = osmmget(MAXLEN); oscfill(stringstar[*index],MAXLEN,'\0'); strncpy(stringstar[*index],mydecval,pos1); while (pos1--) mydecval++; mydecval++; occ[*index] = atoi(mydecval); if (flag == 1) ocp[*index] = 1; *index += 1; while(isdigit(*mydecval)) mydecval++; if (*mydecval == ']') mydecval++; *decval = mydecval; } else { pos2 = strloc(mydecval,'['); while (pos2) { pos1 = strloc(mydecval,'&'); if (mydecval[pos1] && (pos1 < pos2)) { if (!stringstar[*index]) stringstar[*index] = osmmget(MAXLEN); oscfill(stringstar[*index],MAXLEN,'\0'); strncpy(stringstar[*index],mydecval,pos1); while (pos1--) {mydecval++;pos2--;} mydecval++; pos2--; occ[*index] = atoi(mydecval); if (flag == 1) ocp[*index] = 1; principal = *index; *index += 1; while (isdigit(*mydecval)) {mydecval++; pos2--;} } else { if (!stringstar[*index]) stringstar[*index] = osmmget(MAXLEN); oscfill(stringstar[*index],MAXLEN,'\0'); strncpy(stringstar[*index],mydecval,pos2); mydecval += pos2; pos2 = 0; occ[*index] = -principal -1 ; /* ocp[*index] = 1; */ *index += 1; } } *decval = mydecval; deco(index,0,decval); mydecval = *decval; pos1 = strloc(mydecval,']'); if (pos1 != 0) { if (!stringstar[*index]) stringstar[*index] = osmmget(MAXLEN); oscfill(stringstar[*index],MAXLEN,'\0'); strncpy(stringstar[*index],mydecval,pos1); while (pos1--) mydecval++; occ[*index] = -1- principal; *index += 1; mydecval++; if (*mydecval == ']') mydecval++; } else mydecval++; *decval = mydecval; } }