GSI Object Oriented Online Offline (Go4) GO4-6.4.0
Loading...
Searching...
No Matches
f_his_hist.c
Go to the documentation of this file.
1// $Id$
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 fuer 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>
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 ****************+******************************************/
82INTS4 f_his_getbas(CHARS *pc_server, INTS4 l_port, CHARS *pc_base, CHARS *pc_access,INTS4 **p_buffer)
83{
84s_his_comm s_his_comm_cli;
85INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer;
86INTS4 *pl_all,*pl_l;
87s_compress *ps_compress;
88struct s_tcpcomm *ps_tcpcli;
89
90ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
91pl_all = NULL;
92
93/* get base ***************************************************/
94s_his_comm_cli.lu_endian=1;
95s_his_comm_cli.lu_size=0;
96s_his_comm_cli.lu_histos=0;
97s_his_comm_cli.lu_action=COMM__GETBASE;
98s_his_comm_cli.l_status=COMM__SUCCESS;
99strcpy(s_his_comm_cli.c_histo,"*");
100strcpy(s_his_comm_cli.c_access,pc_access);
101strcpy(s_his_comm_cli.c_base,pc_base);
102l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
103if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
104l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
105if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
106l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
107if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
108l_swap = (s_his_comm_cli.lu_endian > 1);
109if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
110if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
111
112/* allocate buffer for compressed base */
113pl_all = (INTS4 *)malloc(s_his_comm_cli.lu_size);
114l_buffer = s_his_comm_cli.lu_size;
115/* break total buffer in TCP buffers */
116pl_l=pl_all;
117i_l=l_buffer/16384;
118l_buffer=l_buffer%16384;
119for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
120if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
121if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
122/* uncompress base */
123ps_compress = (s_compress *) pl_all;
124if(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);
131f_ut_compr_unpack((INTU1 *)pl_all,(INTU1 *) *p_buffer,ps_compress->l_full_bytes);
132if(l_swap == 1) l_status = f_his_swpbas((s_head*) *p_buffer);
133
135g_return:
136f_stc_discclient (l_chan);
137f_stc_close (ps_tcpcli);
138free(pl_all);
139free(ps_tcpcli);
140return(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 ****************+******************************************/
189INTS4 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{
192s_his_comm s_his_comm_cli;
193s_his_head *ps_his_head;
194INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_histos,l_size;
195INTS4 *pl_all,*pl_l;
196struct s_tcpcomm *ps_tcpcli;
197
198ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
199
200/* get directory ***************************************************/
201s_his_comm_cli.lu_endian=1;
202s_his_comm_cli.lu_size=0;
203s_his_comm_cli.lu_histos=0;
204s_his_comm_cli.lu_action=COMM__GETDIR;
205s_his_comm_cli.l_status=COMM__SUCCESS;
206strcpy(s_his_comm_cli.c_histo,pc_histo);
207strcpy(s_his_comm_cli.c_access,pc_access);
208strcpy(s_his_comm_cli.c_base,pc_base);
209l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
210if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
211l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
212if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
213l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
214if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
215l_swap = (s_his_comm_cli.lu_endian > 1);
216if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
217if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
218
219l_histos=s_his_comm_cli.lu_histos;
220l_size=sizeof(s_his_head)*l_histos;
221/* allocate buffer */
222if(*p_buffer == 0)
223{
224 pl_all = (INTS4 *)malloc(l_size);
225 *p_buffer = pl_all;
226}
227else
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;
233l_buffer = s_his_comm_cli.lu_size;
234/* break total buffer in TCP buffers */
235pl_l=pl_all;
236i_l=l_buffer/16384;
237l_buffer=l_buffer%16384;
238for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
239if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
240if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
241
242ps_his_head = (s_his_head *)pl_all;
243for(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}
250g_return:
251f_stc_discclient (l_chan);
252f_stc_close (ps_tcpcli);
253free(ps_tcpcli);
254return(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 ****************+******************************************/
311INTS4 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{
314s_his_comm s_his_comm_cli;
315s_his_head *ps_his_head;
316INTS4 i_j,i_l,l_status,l_chan,l_swap,l_buffer,l_size;
317INTS4 *pl_all,*pl_l;
318struct s_tcpcomm *ps_tcpcli;
319
320ps_tcpcli = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
321
322/* get histogram ******************************************************/
323s_his_comm_cli.lu_endian=1;
324s_his_comm_cli.lu_size=0;
325s_his_comm_cli.lu_histos=0;
326s_his_comm_cli.lu_action=COMM__GETHIST;
327s_his_comm_cli.l_status=COMM__SUCCESS;
328strcpy(s_his_comm_cli.c_histo,pc_histo);
329strcpy(s_his_comm_cli.c_access,pc_access);
330strcpy(s_his_comm_cli.c_base,pc_base);
331l_status = f_stc_connectserver (pc_server,l_port, &l_chan, ps_tcpcli);
332if(l_status != STC__SUCCESS) {l_status=COMM__NOSERVER;goto g_return;}
333l_status = f_stc_write(&s_his_comm_cli,sizeof(s_his_comm),l_chan);
334if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
335l_status = f_stc_read (&s_his_comm_cli,sizeof(s_his_comm),l_chan,-1);
336if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
337l_swap = (s_his_comm_cli.lu_endian > 1);
338if(l_swap) l_status = f_swaplw((INTS4 *)&s_his_comm_cli,5,NULL);
339if(s_his_comm_cli.l_status != COMM__SUCCESS) {l_status=s_his_comm_cli.l_status;goto g_return;}
340
341l_size=s_his_comm_cli.lu_size-sizeof(s_his_head);
342/* allocate buffer */
343if(*p_buffer == 0)
344{
345 pl_all = (INTS4 *)malloc(l_size);
346 *p_buffer = pl_all;
347}
348else
349{
350 if(*pl_size < l_size) {l_status=COMM__ERROR;goto g_return;}
351 pl_all = *p_buffer;
352}
353/* allocate header buffer */
354if(*p_head == 0)
355{
356 ps_his_head = (s_his_head *)malloc(sizeof(s_his_head));
357 *p_head = ps_his_head;
358}
359else ps_his_head = *p_head;
360
361l_status = f_stc_read (ps_his_head,sizeof(s_his_head),l_chan,-1);
362if(l_swap) l_status = f_swaplw((INTS4 *)ps_his_head,16,NULL);
363
364*pl_size = l_size;
365l_buffer = l_size;
366
367/* break total buffer in TCP buffers */
368pl_l=pl_all;
369i_l=l_buffer/16384;
370l_buffer=l_buffer%16384;
371for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_read (pl_l,16384,l_chan,-1);pl_l+=4096;}
372if(l_buffer > 0) l_status = f_stc_read (pl_l,l_buffer,l_chan,-1);
373if(l_status != STC__SUCCESS) {l_status=COMM__ERROR;goto g_return;}
374
375if(l_swap) l_status = f_swaplw((INTS4 *)pl_all,l_size/4,NULL);
376
378g_return:
379f_stc_discclient (l_chan);
380f_stc_close (ps_tcpcli);
381free(ps_tcpcli);
382return(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 ****************+******************************************/
418INTS4 f_his_server(CHARS *pc_base, CHARS *pc_access, INTS4 *pl_port)
419{
421
422ps_tcpserv = (struct s_tcpcomm *) malloc (sizeof( struct s_tcpcomm));
424strcpy(c_gl_serv_access,pc_access);
425strcpy(c_gl_serv_base,pc_base);
428
430{
433 {
434 printf("Error creating histogram server\n");
435 return(COMM__ERROR);
436 }
437}
438*pl_port=l_gl_serv_port;
439return(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 ****************+******************************************/
478INTS4 f_his_wait(INTS4 *pl_action, CHARS *pc_histo)
479{
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);}
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");}
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;
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;
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;
526strcpy(pc_histo,s_his_comm_serv.c_histo);
527return(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 ****************+******************************************/
564{
565INTS4 *pl_l,i_j,i_l,l_buffer,l_status;
566
567if(l_gl_serv_verb == 1) {printf("Send directory %s. \n",s_his_comm_serv.c_histo);}
568s_his_comm_serv.lu_histos=l_histos;
569s_his_comm_serv.lu_endian=1;
571s_his_comm_serv.lu_size=sizeof(s_his_head)*s_his_comm_serv.lu_histos;
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 */
578pl_l=(INTS4 *)ps_head;
579l_buffer = s_his_comm_serv.lu_size;
580i_l=l_buffer/16384;
581l_buffer=l_buffer%16384;
582for(i_j=0;i_j<i_l;i_j++){l_status = f_stc_write (pl_l,16384,l_gl_serv_chan);pl_l+=4096;}
583if(l_buffer > 0) l_status = f_stc_write (pl_l,l_buffer,l_gl_serv_chan);
584
586{ printf("error writing directory to client\n"); f_stc_discclient(l_gl_serv_chan);return(COMM__ERROR);}
588return(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 ****************+******************************************/
626INTS4 f_his_sendhis(s_his_head *ps_head, INTS4 l_histos, CHARS *pc_histo, INTS4 *pl_data)
627{
628s_his_head *ps_his_head;
629INTS4 *pl_l,i_j,i_l,ll,l_buffer,l_status;
630
631s_his_comm_serv.lu_endian=1;
632s_his_comm_serv.lu_histos=0;
634ps_his_head = ps_head;
635for(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;
642 s_his_comm_serv.lu_size=sizeof(s_his_head)+ps_his_head->l_bins_1 * ps_his_head->l_bins_2 * 4;
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 %8lu\n",ps_his_head->c_name, (long unsigned) (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);
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);
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 */
663if(s_his_comm_serv.lu_histos == 0)
664{
665 if(l_gl_serv_verb == 1) {printf("Histogram %s not found\n",pc_histo);}
667 s_his_comm_serv.lu_size=0;
670 { printf("error writing comm to client\n"); f_stc_discclient(l_gl_serv_chan); return(COMM__ERROR); }
672 return(COMM__NOHIST);
673}
675return(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");
710 free(ps_tcpserv);
711 return(COMM__SUCCESS);
712}
int l_status
Definition f_evcli.c:169
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 INTS4 l_gl_serv_port
Definition f_his_hist.c:29
INTS4 f_his_wait(INTS4 *pl_action, CHARS *pc_histo)
Definition f_his_hist.c:478
INTS4 f_his_senddir(s_his_head *ps_head, INTS4 l_histos)
Definition f_his_hist.c:563
INTS4 f_his_close(void)
Definition f_his_hist.c:706
static INTS4 l_gl_serv_chan
Definition f_his_hist.c:30
static CHARS c_gl_serv_access[64]
Definition f_his_hist.c:27
struct s_tcpcomm * ps_tcpserv
Definition f_his_hist.c:32
s_his_comm s_his_comm_serv
Definition f_his_hist.c:33
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
INTS4 f_his_server(CHARS *pc_base, CHARS *pc_access, INTS4 *pl_port)
Definition f_his_hist.c:418
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
INTS4 f_his_sendhis(s_his_head *ps_head, INTS4 l_histos, CHARS *pc_histo, INTS4 *pl_data)
Definition f_his_hist.c:626
static CHARS c_gl_serv_base[32]
Definition f_his_hist.c:28
static INTS4 l_gl_serv_verb
Definition f_his_hist.c:31
INTS4 f_his_swpbas(s_head *ps_head)
void f_his_toupper(CHARS *c, INTS4 i)
INTS4 f_stc_write(void *p_buffer, INTS4 i_buflen, INTS4 i_channel)
Definition f_stccomm.c:339
INTS4 f_stc_read(void *p_buffer, INTS4 i_buflen, INTS4 i_channel, INTS4 i_timeout)
Definition f_stccomm.c:134
INTS4 f_stc_connectserver(CHARS *c_node, INTS4 l_port, INTS4 *pi_channel, struct s_tcpcomm *ps_client)
Definition f_stccomm.c:494
INTS4 f_stc_discclient(INTS4 i_channel)
Definition f_stccomm.c:1170
INTS4 f_stc_createserver(INTS4 *pl_port, struct s_tcpcomm *ps_server)
Definition f_stccomm.c:849
INTS4 f_stc_acceptclient(struct s_tcpcomm *ps_server, INTS4 *pi_channel)
Definition f_stccomm.c:685
INTS4 f_stc_close(struct s_tcpcomm *ps_tcp)
Definition f_stccomm.c:1089
#define STC__SUCCESS
Definition f_stccomm.h:369
int f_swaplw(int *pp_source, int l_len, int *pp_dest)
Definition f_swaplw.c:69
INTS4 f_ut_compr_unpack(INTU1 *pc_input, INTU1 *pc_output, INTS4 l_outlen)
#define PORT__HIST_SERV
Definition portnum_def.h:30
#define COMM__ERROR
Definition s_his_comm.h:28
#define COMM__GETHIST
Definition s_his_comm.h:21
#define COMM__PUTDIR
Definition s_his_comm.h:22
#define COMM__GETBASE
Definition s_his_comm.h:25
#define COMM__NOACCESS
Definition s_his_comm.h:29
#define COMM__NOHIST
Definition s_his_comm.h:32
#define COMM__PUTHIST
Definition s_his_comm.h:23
#define COMM__NOSERVER
Definition s_his_comm.h:31
#define COMM__GETDIR
Definition s_his_comm.h:20
#define COMM__SUCCESS
Definition s_his_comm.h:27
#define COMM__NOBASE
Definition s_his_comm.h:30
INTU4 l_full_bytes
CHARS c_access[32]
Definition s_his_comm.h:41
INTU4 lu_size
Definition s_his_comm.h:39
INTS4 l_status
Definition s_his_comm.h:40
CHARS c_histo[64]
Definition s_his_comm.h:43
INTU4 lu_endian
Definition s_his_comm.h:36
INTU4 lu_histos
Definition s_his_comm.h:38
CHARS c_base[32]
Definition s_his_comm.h:42
INTU4 lu_action
Definition s_his_comm.h:37
CHARS c_name[64]
Definition s_his_head.h:41
INTS4 l_bins_2
Definition s_his_head.h:23
INTS4 l_bins_1
Definition s_his_head.h:22
unsigned char INTU1
Definition typedefs.h:25
int INTS4
Definition typedefs.h:28
char CHARS
Definition typedefs.h:21