00001 //--------------------------------------------------------------- 00002 // Go4 Release Package v2.10-5 (build 21005) 00003 // 03-Nov-2005 00004 //--------------------------------------------------------------- 00005 // The GSI Online Offline Object Oriented (Go4) Project 00006 // Experiment Data Processing at DVEE department, GSI 00007 //--------------------------------------------------------------- 00008 // 00009 //Copyright (C) 2000- Gesellschaft f. Schwerionenforschung, GSI 00010 // Planckstr. 1, 64291 Darmstadt, Germany 00011 //Contact: http://go4.gsi.de 00012 //---------------------------------------------------------------- 00013 //This software can be used under the license agreements as stated 00014 //in Go4License.txt file which is part of the distribution. 00015 //---------------------------------------------------------------- 00016 #include "typedefs.h" 00017 /*****************+***********+****************************************/ 00018 /* */ 00019 /* GSI, Gesellschaft fuer Schwerionenforschung mbH */ 00020 /* Postfach 11 05 52 */ 00021 /* D-64220 Darmstadt */ 00022 /* */ 00023 /*1+ C Procedure *************+****************************************/ 00024 /* */ 00025 /*+ Module : f_his_swpbas */ 00026 /* */ 00027 /*--------------------------------------------------------------------*/ 00028 /*+ CALLING : l_status = f_his_swpbas(ps_head) */ 00029 /*--------------------------------------------------------------------*/ 00030 /* */ 00031 /*+ PURPOSE : Swaps whole base (except strings) */ 00032 /* */ 00033 /*+ ARGUMENTS : */ 00034 /* */ 00035 /*+ ps_head : (s_head *) input */ 00036 /* pointer to header structure, address of shared */ 00037 /* segment. */ 00038 /*+ Return type : int */ 00039 /* */ 00040 /*2+Description***+***********+****************************************/ 00041 /* */ 00042 /*+ CALLING : l_status = f_his_swpbas(ps_head) */ 00043 /* */ 00044 /*+ FUNCTION : */ 00045 /* */ 00046 /*3+Function******+***********+****************************************/ 00047 /* */ 00048 /* */ 00049 /* */ 00050 /*2+Implementation************+****************************************/ 00051 /*+ Utility : f_his_swpbas */ 00052 /*+ File name : f_his_swpbas.c */ 00053 /*+ Home direct.: /sbs/prod/src */ 00054 /*+ Version : 1.01 */ 00055 /*+ Author : H.G.Essel */ 00056 /*+ Created : 06-Jul-2000 */ 00057 /*+ Object libr.: */ 00058 /*+ Updates : Date Purpose */ 00059 /*1- C Procedure *************+****************************************/ 00060 #include <stdio.h> 00061 #include <stdlib.h> 00062 #include <string.h> 00063 #include "s_head.h" 00064 #include "s_spe.h" 00065 #include "s_pol_cond.h" 00066 #include "s_win_cond.h" 00067 #include "f_swaplw.h" 00068 00069 INTS4 f_his_swpbas(s_head *ps_head) 00070 { 00071 INTS4 i; 00072 s_spe *ps_spe; 00073 s_win *ps_win; 00074 s_pol *ps_pol; 00075 INTS4 *pl_mem,*pl; 00076 00077 /* swap first two LWs to get correct size */ 00078 pl=(INTS4 *)ps_head; 00079 f_swaplw(pl,2,NULL); 00080 if(ps_head->l_endian != 1) 00081 { 00082 printf("endian was wrong %x\n",ps_head->l_endian); 00083 return(-1); 00084 } 00085 00086 /* swap whole base */ 00087 pl += 2; 00088 f_swaplw(pl,ps_head->l_len-2,NULL); 00089 00090 /* swap back strings in header */ 00091 pl=(INTS4 *)&ps_head->c_date; 00092 f_swaplw(pl,23,NULL); 00093 00094 /* swap back strings in all slots */ 00095 ps_spe=(s_spe *)(ps_head+1); 00096 pl=(INTS4 *)&ps_spe->c_name; 00097 for(i=0;i<ps_head->i_slot;i++) 00098 { 00099 f_swaplw(pl,71,NULL); 00100 pl += (sizeof(s_spe)/4); 00101 } 00102 00103 /* swap back strings in all conditions */ 00104 if(ps_head->l_cond_win > 0) 00105 { 00106 pl=(INTS4 *)ps_head; 00107 pl = pl + ps_head->l_cond_win; 00108 ps_win = (s_win *)(pl + 1); 00109 /*reswap window names */ 00110 for(i=0;i< * pl;i++) 00111 { 00112 f_swaplw((INTS4 *)ps_win->c_name,28,NULL); 00113 ps_win++; 00114 } 00115 } 00116 if(ps_head->l_cond_pol > 0) 00117 { 00118 pl=(INTS4 *)ps_head; 00119 pl = pl + ps_head->l_cond_pol; 00120 ps_pol = (s_pol *)(pl + 1); 00121 /*reswap window names */ 00122 for(i=0;i < *pl;i++) 00123 { 00124 f_swaplw((INTS4 *)ps_pol->c_name,28,NULL); 00125 ps_pol++; 00126 } 00127 } 00128 return(0); 00129 } 00130 00131 00132 //----------------------------END OF GO4 SOURCE FILE ---------------------