GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
f_his_swpbas.c
Go to the documentation of this file.
1 // $Id: f_his_swpbas.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 /*****************+***********+****************************************/
15 /* */
16 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */
17 /* Postfach 11 05 52 */
18 /* D-64220 Darmstadt */
19 /* */
20 /*1+ C Procedure *************+****************************************/
21 /* */
22 /*+ Module : f_his_swpbas */
23 /* */
24 /*--------------------------------------------------------------------*/
25 /*+ CALLING : l_status = f_his_swpbas(ps_head) */
26 /*--------------------------------------------------------------------*/
27 /* */
28 /*+ PURPOSE : Swaps whole base (except strings) */
29 /* */
30 /*+ ARGUMENTS : */
31 /* */
32 /*+ ps_head : (s_head *) input */
33 /* pointer to header structure, address of shared */
34 /* segment. */
35 /*+ Return type : int */
36 /* */
37 /*2+Description***+***********+****************************************/
38 /* */
39 /*+ CALLING : l_status = f_his_swpbas(ps_head) */
40 /* */
41 /*+ FUNCTION : */
42 /* */
43 /*3+Function******+***********+****************************************/
44 /* */
45 /* */
46 /* */
47 /*2+Implementation************+****************************************/
48 /*+ Utility : f_his_swpbas */
49 /*+ File name : f_his_swpbas.c */
50 /*+ Home direct.: /sbs/prod/src */
51 /*+ Version : 1.01 */
52 /*+ Author : H.G.Essel */
53 /*+ Created : 06-Jul-2000 */
54 /*+ Object libr.: */
55 /*+ Updates : Date Purpose */
56 /*1- C Procedure *************+****************************************/
57 
58 #include "f_his_swpbas.h"
59 
60 #include <stdlib.h>
61 #include <stdio.h>
62 #include "s_spe.h"
63 #include "s_pol_cond.h"
64 #include "s_win_cond.h"
65 #include "f_swaplw.h"
66 
68 {
69  INTS4 i;
70  s_spe *ps_spe;
71  s_win *ps_win;
72  s_pol *ps_pol;
73  INTS4 *pl_mem,*pl;
74 
75 /* swap first two LWs to get correct size */
76 pl=(INTS4 *)ps_head;
77 f_swaplw(pl,2,NULL);
78 if(ps_head->l_endian != 1)
79 {
80  printf("endian was wrong %x\n",ps_head->l_endian);
81  return(-1);
82 }
83 
84 /* swap whole base */
85 pl += 2;
86 f_swaplw(pl,ps_head->l_len-2,NULL);
87 
88 /* swap back strings in header */
89 pl=(INTS4 *)&ps_head->c_date;
90 f_swaplw(pl,23,NULL);
91 
92 /* swap back strings in all slots */
93 ps_spe=(s_spe *)(ps_head+1);
94 pl=(INTS4 *)&ps_spe->c_name;
95 for(i=0;i<ps_head->i_slot;i++)
96 {
97  f_swaplw(pl,71,NULL);
98  pl += (sizeof(s_spe)/4);
99 }
100 
101 /* swap back strings in all conditions */
102 if(ps_head->l_cond_win > 0)
103 {
104 pl=(INTS4 *)ps_head;
105 pl = pl + ps_head->l_cond_win;
106 ps_win = (s_win *)(pl + 1);
107 /*reswap window names */
108 for(i=0;i< * pl;i++)
109 {
110  f_swaplw((INTS4 *)ps_win->c_name,28,NULL);
111  ps_win++;
112 }
113 }
114 if(ps_head->l_cond_pol > 0)
115 {
116 pl=(INTS4 *)ps_head;
117 pl = pl + ps_head->l_cond_pol;
118 ps_pol = (s_pol *)(pl + 1);
119 /*reswap window names */
120 for(i=0;i < *pl;i++)
121 {
122  f_swaplw((INTS4 *)ps_pol->c_name,28,NULL);
123  ps_pol++;
124 }
125 }
126 return(0);
127 }
128 
CHARS c_name[HIS__HISNAMLEN]
Definition: s_spe.h:63
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 l_cond_win
Definition: s_head.h:69
CHARS c_name[32]
Definition: s_pol_cond.h:16
Definition: s_head.h:36
INTS4 l_endian
Definition: s_head.h:38
CHARS c_date[28]
Definition: s_head.h:63
int INTS4
Definition: typedefs.h:28
INTS4 l_cond_pol
Definition: s_head.h:70
INTS4 l_len
Definition: s_head.h:39
Definition: s_spe.h:28
CHARS c_name[32]
Definition: s_win_cond.h:16