GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
f_his_hist.c
Go to the documentation of this file.
1 // $Id: f_his_hist.c 478 2009-10-29 12:26:09Z linev $
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum für Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "typedefs.h"
15 #include "f_his_hist.h"
16 #include "f_his_toupper.h"
17 #include "f_his_swpbas.h"
18 #include "f_stccomm.h"
19 #include "f_swaplw.h"
20 #include "f_ut_compress.h"
21 #include "portnum_def.h"
22 #include <stdio.h>
23 #include <errno.h>
24 #include <ctype.h>
25 #include <string.h>
26 #include <stdlib.h>
28 static CHARS c_gl_serv_base[32];
34 /*****************+***********+****************************************/
35 /* */
36 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */
37 /* Postfach 11 05 41 */
38 /* D-6100 Darmstadt 11 */
39 /* */
40 /*1+ C Procedure ***********+******************************************/
41 /* */
42 /*+ Module : f_his_getbas */
43 /* */
44 /*--------------------------------------------------------------------*/
45 /*+ CALLING : l=f_his_getbas(char server, int port, char base, char password, int **p_buf)*/
46 /*--------------------------------------------------------------------*/
47 /* */
48 /*+ PURPOSE : Returns list of histogram available from server */
49 /* */
50 /*+ ARGUMENTS : */
51 /* */
52 /*+ c_server : Node of server. */
53 /*+ l_port : Port number (must be known from server) */
54 /*+ c_base : Histogram base name */
55 /*+ c_password : Password if required from server */
56 /*+ p_buf : Address of buffer pointer. */
57 /* Data base is allocated and address returned. */
58 /* */
59 /*+ Return type : int. */
60 /*- COMM__SUCCESS : OK */
61 /*- COMM__ERROR : Error */
62 /*- COMM__NOACCESS: Password wrong */
63 /*- COMM__NOBASE : Base wrong */
64 /*- COMM__NOSERVER: Cannot connect (Port?) */
65 /*- COMM__NOHIST : Histogram not there */
66 /* */
67 /*2+DESCRIPTION***+***********+****************************************/
68 /* */
69 /*+ FUNCTION : Connects to histogram server. */
70 /* Allocates and returns LEA data base */
71 /* Bse must be compressed by server. */
72 /* */
73 /*2+IMPLEMENTATION************+****************************************/
74 /* */
75 /*+ File name : f_his_hist.c */
76 /*+ Version : 1.01 */
77 /*+ Author : Hans Essel */
78 /*+ Created : 21-May-2000 */
79 /*+ Updates : Date Purpose */
80 /* */
81 /*1- C Main ****************+******************************************/
82 INTS4 f_his_getbas(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access,INTS4 **p_buffer)
83 {
84 s_his_comm s_his_comm_cli;
85 s_his_head *ps_his_head;
86 INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
87 INTS4 *pl_all,*pl_l;
88 s_compress *ps_compress;
89 struct s_tcpcomm *ps_tcpcli;
90 
91 ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
92 
93 /* get base ***************************************************/
94 s_his_comm_cli.lu_endian=1;
95 s_his_comm_cli.lu_size=0;
96 s_his_comm_cli.lu_histos=0;
97 s_his_comm_cli.lu_action=COMM__GETBASE;
98 s_his_comm_cli.l_status=COMM__SUCCESS;
99 strcpy(s_his_comm_cli.c_histo,"*");
100 strcpy(s_his_comm_cli.c_access,pc_access);
101 strcpy(s_his_comm_cli.c_base,pc_base);
102 l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
103 if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
104 l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
105 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
106 l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
107 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
108 l_swap = (s_his_comm_cli.lu_endian > 1);
109 if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
110 if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
111 
112 /* allocate buffer for comporessed base */
113 pl_all = (INTS4 *)malloc(s_his_comm_cli.lu_size);
114 l_buffer = s_his_comm_cli.lu_size;
115 /* break total buffer in TCP buffers */
116 pl_l=pl_all;
117 i_l=l_buffer/16384;
118 l_buffer=l_buffer%16384;
119 for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
120 if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
121 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
122 /* uncompress base */
123 ps_compress = (s_compress *) pl_all;
124 if(l_swap == 1)
125 {
126  f_swaplw((INTS4 *)pl_all,sizeof(s_compress)/4,NULL);
127  pl_l=pl_all+(sizeof(s_compress)/4);
128  f_swaplw((INTS4 *)pl_l,ps_compress->l_masks,NULL);
129 }
130 *p_buffer = (INTS4 *)malloc(ps_compress->l_full_bytes);
131 f_ut_compr_unpack((INTU1 *)pl_all,(INTU1 *) *p_buffer,ps_compress->l_full_bytes);
132 if(l_swap == 1) l_status = f_his_swpbas((s_head*) *p_buffer);
133 
134 l_status=COMM__SUCCESS;
135 g_return:
136 f_stc_discclient (l_chan);
137 f_stc_close (ps_tcpcli);
138 free(pl_all);
139 free(ps_tcpcli);
140 return(l_status);
141 }
142 /*1+ C Procedure ***********+******************************************/
143 /* */
144 /*+ Module : f_his_getdir */
145 /* */
146 /*--------------------------------------------------------------------*/
147 /*+ CALLING : l=f_his_getdir(char server, int port, char base, char password,*/
148 /* char histo, int **p_buf, int **l_histos)*/
149 /* */
150 /*--------------------------------------------------------------------*/
151 /* */
152 /*+ PURPOSE : Returns list of histogram available from server */
153 /* */
154 /*+ ARGUMENTS : */
155 /* */
156 /*+ c_server : Node of server. */
157 /*+ l_port : Port number (must be known from server) */
158 /*+ c_base : Histogram base name */
159 /*+ c_password : Password if required from server */
160 /*+ c_histo : Histogram wildcard */
161 /*+ p_buf : Address of buffer pointer. */
162 /* If NULL, buffer is allocated, if not l_histos gives */
163 /* size of buffer in sizeof(s_his_head). */
164 /*+ l_histos : Size in sizeof(s_his_head) of buffer, */
165 /* returns number of histograms */
166 /* */
167 /*+ Return type : int. */
168 /*- COMM__SUCCESS : OK */
169 /*- COMM__ERROR : Error */
170 /*- COMM__NOACCESS: Password wrong */
171 /*- COMM__NOBASE : Base wrong */
172 /*- COMM__NOSERVER: Cannot connect (Port?) */
173 /*- COMM__NOHIST : Histogram not there */
174 /* */
175 /*2+DESCRIPTION***+***********+****************************************/
176 /* */
177 /*+ FUNCTION : Connects to histogram server. */
178 /* Returns buffer with s_his_head slots */
179 /* */
180 /*2+IMPLEMENTATION************+****************************************/
181 /* */
182 /*+ File name : f_his_hist.c */
183 /*+ Version : 1.01 */
184 /*+ Author : Hans Essel */
185 /*+ Created : 21-May-2000 */
186 /*+ Updates : Date Purpose */
187 /* */
188 /*1- C Main ****************+******************************************/
189 INTS4 f_his_getdir(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access, CHARS *pc_histo
190  ,INTS4 **p_buffer, INTS4 *pl_histos)
191 {
192 s_his_comm s_his_comm_cli;
193 s_his_head *ps_his_head;
194 INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
195 INTS4 *pl_all,*pl_l;
196 struct s_tcpcomm *ps_tcpcli;
197 
198 ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
199 
200 /* get directory ***************************************************/
201 s_his_comm_cli.lu_endian=1;
202 s_his_comm_cli.lu_size=0;
203 s_his_comm_cli.lu_histos=0;
204 s_his_comm_cli.lu_action=COMM__GETDIR;
205 s_his_comm_cli.l_status=COMM__SUCCESS;
206 strcpy(s_his_comm_cli.c_histo,pc_histo);
207 strcpy(s_his_comm_cli.c_access,pc_access);
208 strcpy(s_his_comm_cli.c_base,pc_base);
209 l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
210 if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
211 l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
212 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
213 l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
214 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
215 l_swap = (s_his_comm_cli.lu_endian > 1);
216 if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
217 if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
218 
219 l_histos=s_his_comm_cli.lu_histos;
220 l_size=sizeof(s_his_head)*l_histos;
221 /* allocate buffer */
222 if(*p_buffer == 0)
223 {
224  pl_all = (INTS4 *)malloc(l_size);
225  *p_buffer = pl_all;
226 }
227 else
228 {
229  if(*pl_histos < l_histos) {l_status=COMM__ERROR;goto g_return;}
230  pl_all = *p_buffer;
231 }
232 *pl_histos = l_histos;
233 l_buffer = s_his_comm_cli.lu_size;
234 /* break total buffer in TCP buffers */
235 pl_l=pl_all;
236 i_l=l_buffer/16384;
237 l_buffer=l_buffer%16384;
238 for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
239 if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
240 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
241 
242 ps_his_head = (s_his_head *)pl_all;
243 for(i_j=0;i_j<s_his_comm_cli.lu_histos;i_j++)
244 {
245  if(l_swap) l_status = f_swaplw((INTS4 *)ps_his_head,16,NULL);
246  ps_his_head++;
247 
248 }
249 l_status=COMM__SUCCESS;
250 g_return:
251 f_stc_discclient (l_chan);
252 f_stc_close (ps_tcpcli);
253 free(ps_tcpcli);
254 return(l_status);
255 }
256 /*****************+***********+****************************************/
257 /* */
258 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */
259 /* Postfach 11 05 41 */
260 /* D-6100 Darmstadt 11 */
261 /* */
262 /*1+ C Procedure ***********+******************************************/
263 /* */
264 /*+ Module : f_his_gethis */
265 /* */
266 /*--------------------------------------------------------------------*/
267 /*+ CALLING : l=f_his_gethis(char server, int port, char base, char password,*/
268 /* char histo, s_his_head **p_head, int **p_buf, int **l_size)*/
269 /* */
270 /*--------------------------------------------------------------------*/
271 /* */
272 /*+ PURPOSE : Returns histogram from server */
273 /* */
274 /*+ ARGUMENTS : */
275 /* */
276 /*+ c_server : Node of server. */
277 /*+ l_port : Port number (must be known from server) */
278 /*+ c_base : Histogram base name */
279 /*+ c_password : Password if required from server */
280 /*+ c_histo : Histogram */
281 /*+ p_head : Address of header pointer (s_his_head) */
282 /* If NULL, s_his_head will be allocated */
283 /*+ p_buf : Address of buffer pointer */
284 /* If NULL, buffer for data will be allocated */
285 /*+ l_size : Size in bytes of buffer, returns size */
286 /* */
287 /*+ Return type : int. */
288 /*- COMM__SUCCESS : OK */
289 /*- COMM__ERROR : Error */
290 /*- COMM__NOACCESS: Password wrong */
291 /*- COMM__NOBASE : Base wrong */
292 /*- COMM__NOSERVER: Cannot connect (Port?) */
293 /*- COMM__NOHIST : Histogram not there */
294 /* */
295 /*2+DESCRIPTION***+***********+****************************************/
296 /* */
297 /*+ FUNCTION : Connects to histogram server. */
298 /* Returns buffer with s_his_head and data buffer */
299 /* Required buffer size can be obtained from */
300 /* s_his_head after calling f_his_getdir. */
301 /* */
302 /*2+IMPLEMENTATION************+****************************************/
303 /* */
304 /*+ File name : f_his_hist.c */
305 /*+ Version : 1.01 */
306 /*+ Author : Hans Essel */
307 /*+ Created : 21-May-2000 */
308 /*+ Updates : Date Purpose */
309 /* */
310 /*1- C Main ****************+******************************************/
311 INTS4 f_his_gethis(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access, CHARS *pc_histo
312  , s_his_head **p_head, INTS4 **p_buffer, INTS4 *pl_size)
313 {
314 s_his_comm s_his_comm_cli;
315 s_his_head *ps_his_head;
316 INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
317 INTS4 *pl_all,*pl_head,*pl_l;
318 struct s_tcpcomm *ps_tcpcli;
319 
320 ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
321 
322 /* get histogram ******************************************************/
323 s_his_comm_cli.lu_endian=1;
324 s_his_comm_cli.lu_size=0;
325 s_his_comm_cli.lu_histos=0;
326 s_his_comm_cli.lu_action=COMM__GETHIST;
327 s_his_comm_cli.l_status=COMM__SUCCESS;
328 strcpy(s_his_comm_cli.c_histo,pc_histo);
329 strcpy(s_his_comm_cli.c_access,pc_access);
330 strcpy(s_his_comm_cli.c_base,pc_base);
331 l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
332 if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
333 l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
334 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
335 l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
336 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
337 l_swap = (s_his_comm_cli.lu_endian > 1);
338 if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
339 if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
340 
341 l_size=s_his_comm_cli.lu_size-sizeof(s_his_head);
342 /* allocate buffer */
343 if(*p_buffer == 0)
344 {
345  pl_all = (INTS4 *)malloc(l_size);
346  *p_buffer = pl_all;
347 }
348 else
349 {
350  if(*pl_size < l_size) {l_status=COMM__ERROR;goto g_return;}
351  pl_all = *p_buffer;
352 }
353 /* allocate header buffer */
354 if(*p_head == 0)
355 {
356  ps_his_head = (s_his_head *)malloc(sizeof(s_his_head));
357  *p_head = ps_his_head;
358 }
359 else ps_his_head = *p_head;
360 
361 l_status = f_stc_read (ps_his_head,sizeof(s_his_head),l_chan,-1);
362 if(l_swap) l_status = f_swaplw((INTS4 *)ps_his_head,16,NULL);
363 
364 *pl_size = l_size;
365 l_buffer = l_size;
366 
367 /* break total buffer in TCP buffers */
368 pl_l=pl_all;
369 i_l=l_buffer/16384;
370 l_buffer=l_buffer%16384;
371 for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
372 if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
373 if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
374 
375 if(l_swap) l_status = f_swaplw((INTS4 *)pl_all,l_size/4,NULL);
376 
377 l_status=COMM__SUCCESS;
378 g_return:
379 f_stc_discclient (l_chan);
380 f_stc_close (ps_tcpcli);
381 free(ps_tcpcli);
382 return(l_status);
383 }
384 /*1+ C Procedure ***********+******************************************/
385 /* */
386 /*+ Module : f_his_server */
387 /* */
388 /*--------------------------------------------------------------------*/
389 /*+ CALLING : l=f_his_server(int *pl_port, char base, char accesss)*/
390 /*--------------------------------------------------------------------*/
391 /* */
392 /*+ PURPOSE : Start histogram server */
393 /* */
394 /*+ ARGUMENTS : */
395 /* */
396 /*+ pl_port : Address to receive port number used. */
397 /*+ base : Base name */
398 /*+ access : Password */
399 /* */
400 /*+ Return type : int. */
401 /*- COMM__SUCCESS : OK */
402 /*- COMM__ERROR : Error */
403 /* */
404 /*2+DESCRIPTION***+***********+****************************************/
405 /* */
406 /*+ FUNCTION : Creates histogram server. */
407 /* Returns port number */
408 /* */
409 /*2+IMPLEMENTATION************+****************************************/
410 /* */
411 /*+ File name : f_his_hist.c */
412 /*+ Version : 1.01 */
413 /*+ Author : Hans Essel */
414 /*+ Created : 21-May-2000 */
415 /*+ Updates : Date Purpose */
416 /* */
417 /*1- C Main ****************+******************************************/
418 INTS4 f_his_server(CHARS *pc_base, CHARS *pc_access, INTS4 *pl_port)
419 {
420 INTS4 *pl_l,i_j,i_l,ll,l_buffer,l_status;
421 
422 ps_tcpserv = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
424 strcpy(c_gl_serv_access,pc_access);
425 strcpy(c_gl_serv_base,pc_base);
428 
429 while((l_status = f_stc_createserver (&l_gl_serv_port, ps_tcpserv)) != STC__SUCCESS)
430 {
431  l_gl_serv_port++;
433  {
434  printf("Error creating histogram server\n");
435  return(COMM__ERROR);
436  }
437 }
438 *pl_port=l_gl_serv_port;
439 return(0);
440 }
441 
442 /*1+ C Procedure ***********+******************************************/
443 /* */
444 /*+ Module : f_his_wait */
445 /* */
446 /*--------------------------------------------------------------------*/
447 /*+ CALLING : l=f_his_wait(int *pl_action, char histogram) */
448 /*--------------------------------------------------------------------*/
449 /* */
450 /*+ PURPOSE : Wait for client */
451 /* */
452 /*+ ARGUMENTS : */
453 /* */
454 /*+ pl_action : Address to receive required action. */
455 /*+ histogram : Histogram sepc. */
456 /* */
457 /*+ Return type : int. */
458 /*- COMM__SUCCESS : OK */
459 /*- COMM__ERROR : Error */
460 /*- COMM__NOACCESS: Password wrong */
461 /*- COMM__NOBASE : Base wrong */
462 /* */
463 /*2+DESCRIPTION***+***********+****************************************/
464 /* */
465 /*+ FUNCTION : Waits for client to connect. */
466 /* Returns action required. */
467 /* Checks for correct base and password */
468 /* */
469 /*2+IMPLEMENTATION************+****************************************/
470 /* */
471 /*+ File name : f_his_hist.c */
472 /*+ Version : 1.01 */
473 /*+ Author : Hans Essel */
474 /*+ Created : 21-May-2000 */
475 /*+ Updates : Date Purpose */
476 /* */
477 /*1- C Main ****************+******************************************/
478 INTS4 f_his_wait(INTS4 *pl_action, CHARS *pc_histo)
479 {
480 INTS4 *pl_l,i_j,i_l,ll,l_buffer,l_status;
481 /* Wait for client to connect */
482  if(l_gl_serv_verb == 1) {printf("Waiting for client on port %d [%s] \n",l_gl_serv_port,c_gl_serv_access);}
483  l_status = f_stc_acceptclient (ps_tcpserv, &l_gl_serv_chan);
484  if(l_status != STC__SUCCESS) { printf("error accepting client\n"); return(COMM__ERROR);}
485  if(l_gl_serv_verb == 1) {printf("Client connected. \n");}
486  l_status = f_stc_read (&s_his_comm_serv,sizeof(s_his_comm),l_gl_serv_chan,-1);
487  if(l_status != STC__SUCCESS) { printf("error reading client\n"); f_stc_discclient(l_gl_serv_chan);return(COMM__ERROR); }
488  /* check access */
489  f_his_toupper(s_his_comm_serv.c_access,sizeof(s_his_comm_serv.c_access));
490  f_his_toupper(s_his_comm_serv.c_base,sizeof(s_his_comm_serv.c_base));
491  if((strlen(c_gl_serv_access) != 0) &
492  (strcmp(s_his_comm_serv.c_access,c_gl_serv_access) != 0))
493  {
494  printf("Client connected with wrong password [%s]. \n",s_his_comm_serv.c_access);
495  s_his_comm_serv.lu_endian=1;
496  s_his_comm_serv.lu_size=0;
497  s_his_comm_serv.lu_histos=0;
498  s_his_comm_serv.l_status=COMM__NOACCESS;
499  l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
501  return(COMM__NOACCESS);
502  }
503  /* check base name */
504  if(strcmp(s_his_comm_serv.c_base,c_gl_serv_base) != 0)
505  {
506  printf("Client connected for wrong base [%s]. \n",s_his_comm_serv.c_base);
507  s_his_comm_serv.lu_endian=1;
508  s_his_comm_serv.lu_size=0;
509  s_his_comm_serv.lu_histos=0;
510  s_his_comm_serv.l_status=COMM__NOBASE;
511  l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
513  return(COMM__NOBASE);
514  }
515  if(s_his_comm_serv.lu_endian > 100) l_status = f_swaplw((INTS4 *)&s_his_comm_serv,5,NULL);
516  if(l_gl_serv_verb == 1) {printf("%d: %d %d %d %d %d \"%s\" \"%s\" \"%s\"\n",l_status
517  ,s_his_comm_serv.lu_endian
518  ,s_his_comm_serv.lu_action
519  ,s_his_comm_serv.lu_histos
520  ,s_his_comm_serv.lu_size
521  ,s_his_comm_serv.l_status
522  ,s_his_comm_serv.c_access
523  ,s_his_comm_serv.c_base
524  ,s_his_comm_serv.c_histo);}
525 *pl_action=s_his_comm_serv.lu_action;
526 strcpy(pc_histo,s_his_comm_serv.c_histo);
527 return(COMM__SUCCESS);
528 }
529 
530 /*1+ C Procedure ***********+******************************************/
531 /* */
532 /*+ Module : f_his_senddir */
533 /* */
534 /*--------------------------------------------------------------------*/
535 /*+ CALLING : l=f_his_senddir(s_his_head *ps_head, int l_histos) */
536 /*--------------------------------------------------------------------*/
537 /* */
538 /*+ PURPOSE : Send list of available histogram */
539 /* */
540 /*+ ARGUMENTS : */
541 /* */
542 /*+ ps_head : Address of header list. */
543 /*+ l_histos : Number of histograms */
544 /* */
545 /*+ Return type : int. */
546 /*- COMM__SUCCESS : OK */
547 /*- COMM__ERROR : Error */
548 /*- COMM__NOHIST : Histogram not there */
549 /* */
550 /*2+DESCRIPTION***+***********+****************************************/
551 /* */
552 /*+ FUNCTION : Send list of s_his_head to client. */
553 /* */
554 /*2+IMPLEMENTATION************+****************************************/
555 /* */
556 /*+ File name : f_his_hist.c */
557 /*+ Version : 1.01 */
558 /*+ Author : Hans Essel */
559 /*+ Created : 21-May-2000 */
560 /*+ Updates : Date Purpose */
561 /* */
562 /*1- C Main ****************+******************************************/
563 INTS4 f_his_senddir(s_his_head *ps_head, INTS4 l_histos)
564 {
565 INTS4 *pl_l,i_j,i_l,ll,l_buffer,l_status;
566 
567 if(l_gl_serv_verb == 1) {printf("Send directory %s. \n",s_his_comm_serv.c_histo);}
568 s_his_comm_serv.lu_histos=l_histos;
569 s_his_comm_serv.lu_endian=1;
570 s_his_comm_serv.lu_action=COMM__PUTDIR;
571 s_his_comm_serv.lu_size=sizeof(s_his_head)*s_his_comm_serv.lu_histos;
572 s_his_comm_serv.l_status=COMM__SUCCESS;
573 l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
574 if(l_status != STC__SUCCESS)
575 { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan);return(COMM__ERROR);}
576 
577 /* break total buffer in TCP buffers */
578 pl_l=(INTS4 *)ps_head;
579 l_buffer = s_his_comm_serv.lu_size;
580 i_l=l_buffer/16384;
581 l_buffer=l_buffer%16384;
582 for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_write (pl_l,16384,l_gl_serv_chan);pl_l+=4096;}
583 if(l_buffer > 0) l_status = f_stc_write (pl_l,l_buffer,l_gl_serv_chan);
584 
585 if(l_status != STC__SUCCESS)
586 { printf("error writing directory to client\n"); f_stc_discclient(l_gl_serv_chan);return(COMM__ERROR);}
588 return(COMM__SUCCESS);
589 }
590 /*1+ C Procedure ***********+******************************************/
591 /* */
592 /*+ Module : f_his_sendhis */
593 /* */
594 /*--------------------------------------------------------------------*/
595 /*+ CALLING : l=f_his_sendhis(s_his_head *ps_head, int histos, char *histo, int *data)*/
596 /*--------------------------------------------------------------------*/
597 /* */
598 /*+ PURPOSE : Send histogram */
599 /* */
600 /*+ ARGUMENTS : */
601 /* */
602 /*+ ps_head : Address of header list. */
603 /*+ histos : Number of histograms */
604 /*+ histo : Name of requested histograms */
605 /*+ data : Pointer array to histogram data */
606 /* */
607 /*+ Return type : int. */
608 /*- COMM__SUCCESS : OK */
609 /*- COMM__ERROR : Error */
610 /*- COMM__NOHIST : Histogram not there */
611 /* */
612 /*2+DESCRIPTION***+***********+****************************************/
613 /* */
614 /*+ FUNCTION : Send one s_his_head and data to client. */
615 /* Histogram is searched by name. */
616 /* */
617 /*2+IMPLEMENTATION************+****************************************/
618 /* */
619 /*+ File name : f_his_hist.c */
620 /*+ Version : 1.01 */
621 /*+ Author : Hans Essel */
622 /*+ Created : 21-May-2000 */
623 /*+ Updates : Date Purpose */
624 /* */
625 /*1- C Main ****************+******************************************/
626 INTS4 f_his_sendhis(s_his_head *ps_head, INTS4 l_histos, CHARS *pc_histo, INTS4 *pl_data)
627 {
628 s_his_head *ps_his_head;
629 INTS4 *pl_l,i_j,i_l,ll,l_buffer,l_status;
630 
631 s_his_comm_serv.lu_endian=1;
632 s_his_comm_serv.lu_histos=0;
633 s_his_comm_serv.lu_action=COMM__PUTHIST;
634 ps_his_head = ps_head;
635 for(ll=0;ll<l_histos;ll++)
636 {
637  pl_l = pl_data;
638  if(strcmp(ps_his_head->c_name,pc_histo) == 0)
639  {
640  s_his_comm_serv.lu_histos=1;
641  s_his_comm_serv.l_status=COMM__SUCCESS;
642  s_his_comm_serv.lu_size=sizeof(s_his_head)+ps_his_head->l_bins_1 * ps_his_head->l_bins_2 * 4;
643  l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
644  if(l_status != STC__SUCCESS)
645  { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR);}
646  if(l_gl_serv_verb == 1) {printf("%-32s %8d\n",ps_his_head->c_name,s_his_comm_serv.lu_size-sizeof(s_his_head));}
647  l_status = f_stc_write (ps_his_head,sizeof(s_his_head), l_gl_serv_chan);
648  if(l_status != STC__SUCCESS)
649  { printf("error writing header to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
650 
651  /* break total buffer in TCP buffers */
652  l_buffer = s_his_comm_serv.lu_size-sizeof(s_his_head);
653  i_l=l_buffer/16384;
654  l_buffer=l_buffer%16384;
655  for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_write (pl_l,16384,l_gl_serv_chan);pl_l+=4096;}
656  if(l_buffer > 0) l_status = f_stc_write (pl_l,l_buffer,l_gl_serv_chan);
657  if(l_status != STC__SUCCESS)
658  { printf("error writing data to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
659  break;
660  } /* found */
661  ps_his_head++;
662 } /* loop */
663 if(s_his_comm_serv.lu_histos == 0)
664 {
665  if(l_gl_serv_verb == 1) {printf("Histogram %s not found\n",pc_histo);}
666  s_his_comm_serv.l_status=COMM__NOHIST;
667  s_his_comm_serv.lu_size=0;
668  l_status = f_stc_write (&s_his_comm_serv,sizeof(s_his_comm), l_gl_serv_chan);
669  if(l_status != STC__SUCCESS)
670  { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
672  return(COMM__NOHIST);
673 }
675 return(COMM__SUCCESS);
676 }
677 /*1+ C Procedure ***********+******************************************/
678 /* */
679 /*+ Module : f_his_close */
680 /* */
681 /*--------------------------------------------------------------------*/
682 /*+ CALLING : l=f_his_close() */
683 /*--------------------------------------------------------------------*/
684 /* */
685 /*+ PURPOSE : Stop server, close sockets */
686 /* */
687 /*+ ARGUMENTS : */
688 /* */
689 /*+ Return type : int. */
690 /*- COMM__SUCCESS : OK */
691 /*- COMM__ERROR : Error */
692 /* */
693 /*2+DESCRIPTION***+***********+****************************************/
694 /* */
695 /*+ FUNCTION : Stop server, close sockets . */
696 /* */
697 /*2+IMPLEMENTATION************+****************************************/
698 /* */
699 /*+ File name : f_his_hist.c */
700 /*+ Version : 1.01 */
701 /*+ Author : Hans Essel */
702 /*+ Created : 21-May-2000 */
703 /*+ Updates : Date Purpose */
704 /* */
705 /*1- C Main ****************+******************************************/
707 {
708 printf("Exit histogram server\n");
709 f_stc_close (ps_tcpserv);
710 free(ps_tcpserv);
711 return(COMM__SUCCESS);
712 }
INTS4 f_his_senddir(s_his_head *ps_head, INTS4 l_histos)
Definition: f_his_hist.c:563
INTS4 f_stc_close(struct s_tcpcomm *ps_tcp)
Definition: f_stccomm.c:1068
s_his_comm s_his_comm_serv
Definition: f_his_hist.c:33
INTS4 f_stc_read(void *p_buffer, INTS4 i_buflen, INTS4 i_channel, INTS4 i_timeout)
Definition: f_stccomm.c:129
int f_swaplw(int *pp_source, int l_len, int *pp_dest)
Definition: f_swaplw.c:69
INTS4 f_his_swpbas(s_head *ps_head)
Definition: f_his_swpbas.c:67
INTS4 f_stc_write(void *p_buffer, INTS4 i_buflen, INTS4 i_channel)
Definition: f_stccomm.c:315
#define COMM__SUCCESS
Definition: s_his_comm.h:27
INTS4 f_his_sendhis(s_his_head *ps_head, INTS4 l_histos, CHARS *pc_histo, INTS4 *pl_data)
Definition: f_his_hist.c:626
INTU4 lu_action
Definition: s_his_comm.h:37
#define COMM__NOSERVER
Definition: s_his_comm.h:31
INTS4 f_stc_acceptclient(struct s_tcpcomm *ps_server, INTS4 *pi_channel)
Definition: f_stccomm.c:663
INTU4 lu_histos
Definition: s_his_comm.h:38
INTS4 f_his_getbas(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access, INTS4 **p_buffer)
Definition: f_his_hist.c:82
INTU4 lu_endian
Definition: s_his_comm.h:36
INTS4 l_bins_2
Definition: s_his_head.h:23
INTS4 f_stc_discclient(INTS4 i_channel)
Definition: f_stccomm.c:1149
#define COMM__GETDIR
Definition: s_his_comm.h:20
INTS4 f_stc_connectserver(CHARS *c_node, INTS4 l_port, INTS4 *pi_channel, struct s_tcpcomm *ps_client)
Definition: f_stccomm.c:470
Definition: s_head.h:36
#define STC__SUCCESS
Definition: f_stccomm.h:364
#define COMM__PUTHIST
Definition: s_his_comm.h:23
#define COMM__ERROR
Definition: s_his_comm.h:28
INTU4 lu_size
Definition: s_his_comm.h:39
#define COMM__GETHIST
Definition: s_his_comm.h:21
int l_status
Definition: f_evcli.c:183
INTS4 f_his_wait(INTS4 *pl_action, CHARS *pc_histo)
Definition: f_his_hist.c:478
int INTS4
Definition: typedefs.h:28
CHARS c_access[32]
Definition: s_his_comm.h:41
CHARS c_histo[64]
Definition: s_his_comm.h:43
INTU4 l_full_bytes
Definition: f_ut_compress.h:21
unsigned char INTU1
Definition: typedefs.h:25
#define PORT__HIST_SERV
Definition: portnum_def.h:28
INTS4 f_his_getdir(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access, CHARS *pc_histo, INTS4 **p_buffer, INTS4 *pl_histos)
Definition: f_his_hist.c:189
CHARS c_name[64]
Definition: s_his_head.h:41
INTS4 l_status
Definition: s_his_comm.h:40
static CHARS c_gl_serv_access[64]
Definition: f_his_hist.c:27
struct s_tcpcomm * ps_tcpserv
Definition: f_his_hist.c:32
#define COMM__NOHIST
Definition: s_his_comm.h:32
#define COMM__GETBASE
Definition: s_his_comm.h:25
static INTS4 l_gl_serv_verb
Definition: f_his_hist.c:31
INTS4 f_ut_compr_unpack(INTU1 *pc_input, INTU1 *pc_output, INTS4 l_outlen)
static INTS4 l_gl_serv_chan
Definition: f_his_hist.c:30
CHARS c_base[32]
Definition: s_his_comm.h:42
void f_his_toupper(CHARS *c, INTS4 i)
Definition: f_his_toupper.c:65
#define COMM__NOBASE
Definition: s_his_comm.h:30
INTS4 f_stc_createserver(INTS4 *pl_port, struct s_tcpcomm *ps_server)
Definition: f_stccomm.c:824
INTS4 l_bins_1
Definition: s_his_head.h:22
INTS4 f_his_close()
Definition: f_his_hist.c:706
INTS4 f_his_gethis(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access, CHARS *pc_histo, s_his_head **p_head, INTS4 **p_buffer, INTS4 *pl_size)
Definition: f_his_hist.c:311
static CHARS c_gl_serv_base[32]
Definition: f_his_hist.c:28
#define COMM__PUTDIR
Definition: s_his_comm.h:22
#define COMM__NOACCESS
Definition: s_his_comm.h:29
INTU4 l_masks
Definition: f_ut_compress.h:20
static INTS4 l_gl_serv_port
Definition: f_his_hist.c:29
char CHARS
Definition: typedefs.h:21
INTS4 f_his_server(CHARS *pc_base, CHARS *pc_access, INTS4 *pl_port)
Definition: f_his_hist.c:418