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

« back to all changes in this revision

Viewing changes to prim/table/libsrc/tbhist.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
.VERSION
 
28
 
 
29
 090903         last modif
 
30
===========================================================================*/
 
31
 
 
32
#include <midas_def.h>
 
33
 
 
34
#include <stdio.h>
 
35
 
 
36
 
 
37
void   descw(tid,j,values,klen,khisto)
 
38
int tid,j;
 
39
int values[9],*klen;
 
40
char khisto[81];
 
41
 
 
42
{
 
43
int ioff,iav,kuni,ll;
 
44
int jj;
 
45
 
 
46
char cbuf[81],parm[2];
 
47
 
 
48
 
 
49
 
 
50
  ll = values[j];
 
51
  sprintf(parm,"P%d",j);
 
52
  SCKGETC(parm,1,ll,&iav,cbuf); 
 
53
  if (khisto[0]) {
 
54
        khisto[*klen] = ' ';
 
55
        ioff = *klen+1;
 
56
        khisto[ioff] = '\0';
 
57
        }
 
58
  else ioff=0;
 
59
  iav = *klen+1+ll;
 
60
  if (iav>80)
 
61
           {
 
62
           SCDWRC(tid,"HISTORY",1,khisto,-1,80,&kuni);
 
63
           if (ll == 80)
 
64
              {
 
65
              SCDWRC(tid,"HISTORY",1,cbuf,-1,80,&kuni);
 
66
              *klen = -1;
 
67
               }
 
68
            else
 
69
               {
 
70
               *klen = -1;
 
71
               descw(tid,j,values,klen,khisto);
 
72
                }
 
73
            }
 
74
   else
 
75
            {
 
76
            *klen = *klen+1+ll;
 
77
            jj = 0;
 
78
            while (cbuf[jj]){
 
79
                  khisto[ioff+jj] = cbuf[jj]; 
 
80
                  jj++;
 
81
                  }
 
82
            khisto[ioff+jj] = ' ';
 
83
            }
 
84
}
 
85
 
 
86
 
 
87
 
 
88
int tbl_hist(tid)
 
89
int tid;
 
90
 
 
91
{
 
92
static int one = 1;
 
93
static int zero = 0;
 
94
int  ec,el,ed,knul,flag,iav,values[9];
 
95
int  ibuf[5];
 
96
int  kuni,i,j,status,noelem,bytelm,*klen;       /* `kuni' is of type int !! */
 
97
 
 
98
char type,khisto[81];
 
99
char *fin, name[60] ;
 
100
 
 
101
 
 
102
SCECNT("GET",&ec,&el,&ed);
 
103
SCECNT("PUT",&one,&zero,&zero);
 
104
status = SCDRDI(tid,"HISTORY_UPDA",1,1,&iav,&flag,&kuni,&knul);
 
105
SCECNT("PUT",&ec,&el,&ed);
 
106
if ((status==0)&&(flag==0)) return(0);
 
107
SCDFND(tid,"HISTORY",&type,&noelem,&bytelm);
 
108
if (type != ' ') {
 
109
    SCFNAME(tid,name,60);
 
110
    SCFINF(name,1,ibuf);
 
111
    if (ibuf[0] <= 5) {
 
112
       noelem = noelem/72;
 
113
       fin = osmmget(8*noelem);
 
114
       oscfill(fin,noelem*8,' ');
 
115
       SCDWRC(tid,"HISTORY",1,fin,-1,8*noelem,&kuni);
 
116
       }
 
117
    }
 
118
SCKGETC("HISTORY",1,80,&iav,khisto);
 
119
i = strlen(khisto);
 
120
klen = &i;
 
121
if (khisto[0])
 
122
    {
 
123
     if (*klen==80)
 
124
       {
 
125
       SCDWRC(tid,"HISTORY",1,khisto,-1,80,&kuni);
 
126
       *klen = 0;
 
127
       khisto[0] = '\0';
 
128
       }
 
129
    }
 
130
else *klen = -1;
 
131
SCKRDI("PCOUNT",1,9,&iav,values,&kuni,&knul);
 
132
if (values[0]>=1)
 
133
   {
 
134
    for (j=1;j<=values[0];j++)  descw(tid,j,values,klen,khisto);
 
135
    }  
 
136
khisto[*klen] = '\0';
 
137
if (*klen>0) 
 
138
 SCDWRC(tid,"HISTORY",1,khisto,-1,80,&kuni);
 
139
return(0);
 
140
 
141