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