~ubuntu-branches/debian/jessie/eso-midas/jessie

« back to all changes in this revision

Viewing changes to stdred/do/libsrc/decrypt1.c

  • Committer: Package Import Robot
  • Author(s): Ole Streicher
  • Date: 2014-04-22 14:44:58 UTC
  • Revision ID: package-import@ubuntu.com-20140422144458-okiwi1assxkkiz39
Tags: upstream-13.09pl1.2+dfsg
ImportĀ upstreamĀ versionĀ 13.09pl1.2+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*===========================================================================
 
2
  Copyright (C) 1995-2009 European Southern Observatory (ESO)
 
3
 
 
4
  This program is free software; you can redistribute it and/or 
 
5
  modify it under the terms of the GNU General Public License as 
 
6
  published by the Free Software Foundation; either version 2 of 
 
7
  the License, or (at your option) any later version.
 
8
 
 
9
  This program is distributed in the hope that it will be useful,
 
10
  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
  GNU General Public License for more details.
 
13
 
 
14
  You should have received a copy of the GNU General Public 
 
15
  License along with this program; if not, write to the Free 
 
16
  Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, 
 
17
  MA 02139, USA.
 
18
 
 
19
  Correspondence concerning ESO-MIDAS should be addressed as follows:
 
20
        Internet e-mail: midas@eso.org
 
21
        Postal address: European Southern Observatory
 
22
                        Data Management Division 
 
23
                        Karl-Schwarzschild-Strasse 2
 
24
                        D 85748 Garching bei Muenchen 
 
25
                        GERMANY
 
26
===========================================================================*/
 
27
 
 
28
/*
 
29
 
 
30
.VERSION
 
31
 090831         last modif
 
32
 
 
33
*/
 
34
 
 
35
 
 
36
#include <midas_def.h>
 
37
#include <str.h>
 
38
#include <string.h>
 
39
 
 
40
extern int sstrfind(), ssdelim(), sstsnum();
 
41
 
 
42
 
 
43
int decrypt1(column,line,selecrit,temp)
 
44
char *line,*selecrit,*column,*temp;
 
45
{
 
46
int i,k,str;
 
47
str = 0;
 
48
if (!*line) return(0);
 
49
oscfill(temp,256,'\0');
 
50
strcat(selecrit,column);
 
51
if (!*line) return(0);
 
52
else  {
 
53
      if (sstrfind(line,"~*[=")) { 
 
54
    /*       strcat(selecrit,".EQ."); */
 
55
           if (*line == '=') line++;
 
56
           }
 
57
      else if ((*line == '!') && (*(line+1) == '=')) {
 
58
              line += 2;
 
59
              str = 1;
 
60
              strcat(selecrit,".NE.");
 
61
              }
 
62
      else if (*line == '<') {
 
63
              str = 1;
 
64
              line++;
 
65
              if (*line == '=') {
 
66
                  strcat(selecrit,".LE.");
 
67
                  line++;
 
68
                  }
 
69
              else strcat(selecrit,".LT.");
 
70
              }
 
71
      else if (*line == '>') {
 
72
              str = 1;
 
73
              line++;
 
74
              if (*line == '=') {
 
75
                  strcat(selecrit,".GE.");
 
76
                  line++;
 
77
                  }
 
78
              else strcat(selecrit,".GT.");
 
79
              }
 
80
/*      else strcat(selecrit,".EQ."); */
 
81
      i = 0;
 
82
      while(!ssdelim(line) && (*line)) {
 
83
          *(temp+i) = *line++;
 
84
          i++;
 
85
          }
 
86
      k = strindex(temp,"..");
 
87
      if (temp[k]) {
 
88
           strcat(selecrit,".GE.");
 
89
           strncat(selecrit,temp,k);
 
90
           strcat(selecrit,".AND.");
 
91
           strcat(selecrit,column);
 
92
           temp = temp+k+2;
 
93
           strcat(selecrit,".LE.");
 
94
           strcat(selecrit,temp);
 
95
           }
 
96
      else {
 
97
           if (!str) strcat(selecrit,".EQ.");
 
98
           if (sstsnum(temp) <= 0) {
 
99
               strcat(selecrit,"\"");
 
100
               strcat(selecrit,temp);
 
101
               strcat(selecrit,"\"");
 
102
               }
 
103
           else strcat(selecrit,temp);
 
104
           }
 
105
      if (*line == '|')  strcat(selecrit,".OR.");
 
106
      else if (*line == '&') strcat(selecrit,".AND.");
 
107
      if (*line == '\0') return(0);
 
108
      line++;
 
109
      decrypt1(column,line,selecrit,temp);
 
110
      }
 
111
return 0;
 
112
}