00001
00002
00003
00004
00005
00006
00007
00008
00009 #include <stdio.h>
00010 #include <string.h>
00011 #include <stdlib.h>
00012
00013 #include "uti.h"
00014 #include "cabdef0.h"
00015 #include "cabdef1.h"
00016 #include "cabcod.h"
00017 #include "cabctrl.h"
00018 #include "cabecer.h"
00019
00020
00021
00022
00023
00024 void vleecfs( FILE * fp, struct cgsenal * cgs )
00025 {
00026 reset_cgsenal(cgs);
00027 xfseek(fp,0,SEEK_SET);
00028 lee_csenal_vieja(fp,cgs);
00029 xfseek(fp,512,SEEK_SET);
00030 }
00031
00032
00033
00034
00035
00036 void vescribecfs( FILE * fp, struct cgsenal * cgs )
00037 {
00038 xfseek(fp,0,SEEK_SET);
00039 escribe_csenal_vieja(fp,cgs);
00040 }
00041
00042
00043
00044
00045
00046
00047
00048 UCHAR1 leecfs( FILE * fp, struct cgsenal * cgs, int tdato )
00049 {
00050 struct cfich cf;
00051
00052 vete_cfich(fp);
00053 lee_cfich(fp,&cf);
00054
00055 cdie_beep(!es_fsenal(cf.tfich),"error: no es fichero de senal");
00056 cdie_beep((tdato!=-1)&&(cf.tdato!=tdato),"error: tipo de datos no valido");
00057
00058 reset_cgsenal(cgs);
00059 vete_cgsenal(fp);
00060 lee_cgsenal(fp,cgs);
00061 vete_datos(fp);
00062 return cf.tdato;
00063 }
00064
00065
00066
00067
00068
00069 void escribecfs_ftyp( FILE * fp,
00070 struct cgsenal * cgs,
00071 UINT2 ftyp,
00072 UCHAR1 tdata )
00073 {
00074 struct cfich cf;
00075
00076 cf.tfich = ftyp;
00077 cf.tdato = tdata;
00078 cf.mcab = MC_SENAL;
00079
00080 vete_principio(fp);
00081 escribe_cfich(fp,&cf);
00082
00083 escribe_long(fp,long_cgsenal(cgs));
00084 escribe_cgsenal(fp,cgs);
00085 escribe_long_actual(fp,MC_NINGUNA);
00086 }
00087
00088
00089
00090
00091
00092 void escribecfs( FILE * fp,
00093 struct cgsenal * cgs,
00094 UCHAR1 tdata )
00095 {
00096 escribecfs_ftyp(fp,cgs,TF_SORIG,tdata);
00097 }
00098
00099
00100
00101
00102
00103 void escribe_cab_preenf( FILE * fp,
00104 struct cgsenal * cgs,
00105 UCHAR1 tdata )
00106 {
00107 escribecfs_ftyp(fp,cgs,TF_SENF,tdata);
00108 }
00109
00110
00111
00112
00113
00114 void escribe_cab_deenf( FILE * fp,
00115 struct cgsenal * cgs,
00116 UCHAR1 tdata )
00117 {
00118 escribecfs_ftyp(fp,cgs,TF_SDENF,tdata);
00119 }
00120
00121
00122
00123
00124
00125 void escribe_cab_filt( FILE * fp,
00126 struct cgsenal * cgs,
00127 UCHAR1 tdata )
00128 {
00129 escribecfs_ftyp(fp,cgs,TF_FILT,tdata);
00130 }
00131
00132
00133
00134
00135
00136
00137 void escribe_cab_parcor( FILE * fp,
00138 struct cgsenal * cgs,
00139 struct cgp_parcor * cgpp )
00140 {
00141 struct cfich cf;
00142
00143 cf.tfich = TF_PARCOR;
00144 cf.tdato = TD_FLOAT4;
00145 cf.mcab = MC_SENAL | MC_PARAM;
00146
00147 vete_principio(fp);
00148 escribe_cfich(fp,&cf);
00149
00150 escribe_long(fp,long_cgsenal(cgs));
00151 escribe_cgsenal(fp,cgs);
00152
00153 escribe_long(fp,long_cgp_parcor());
00154 escribe_cgp_parcor(fp,cgpp);
00155
00156 escribe_long_actual(fp,MC_NINGUNA);
00157 }
00158
00159
00160
00161
00162
00163 void escribecfslpc( FILE * fp,
00164 struct cgsenal * cgs,
00165 struct cgp_lpc * cpl,
00166 UINT2 ftyp,
00167 UINT2 tdat )
00168 {
00169 struct cfich cf;
00170
00171 cf.tfich = ftyp;
00172 cf.tdato = (UCHAR1)tdat;
00173 cf.mcab = MC_SENAL | MC_PARAM;
00174
00175 vete_principio(fp);
00176 escribe_cfich(fp,&cf);
00177
00178 escribe_long(fp,long_cgsenal(cgs));
00179 escribe_cgsenal(fp,cgs);
00180
00181 escribe_long(fp,long_cgp_lpc());
00182 escribe_cgp_lpc(fp,cpl);
00183
00184 escribe_long_actual(fp,MC_NINGUNA);
00185 }
00186
00187
00188
00189
00190
00191
00192
00193
00194 UINT2 leecfslpc( FILE * fp,
00195 struct cgsenal * cgs,
00196 struct cgp_lpc * cpl,
00197 int tdato,
00198 BOOL * hayclpc )
00199 {
00200 struct cfich cf;
00201
00202 vete_cfich(fp);
00203 lee_cfich(fp,&cf);
00204
00205 cdie_beep(!es_fsenal(cf.tfich),"error: no es fichero de senal");
00206 cdie_beep((tdato!=-1)&&(cf.tdato!=tdato),"error: tipo de datos no valido");
00207
00208 reset_cgsenal(cgs);
00209 vete_cgsenal(fp);
00210 lee_cgsenal(fp,cgs);
00211 *hayclpc = ((((cf).mcab)&(MC_PARAM))!=0);
00212 *hayclpc = hay_cparam(cf);
00213 if (*hayclpc) {
00214 vete_cgparam(fp);
00215 lee_cgp_lpc(fp,cpl);
00216 }
00217 else
00218 memset(cpl,0,sizeof(*cpl));
00219
00220 vete_datos(fp);
00221 return cf.tdato;
00222 }
00223
00224
00225
00226
00227
00228
00229 void escribe_cab_lpc( FILE * fp,
00230 struct cgsenal * cgs,
00231 struct cgp_lpc * cgpl )
00232 {
00233 escribecfslpc(fp,cgs,cgpl,TF_LPC,TD_FLOAT4);
00234 }
00235
00236
00237
00238 void lee_cab_lpc( FILE * fp,
00239 struct cgp_lpc * cgpl )
00240 {
00241 struct cfich cf;
00242
00243 vete_cfich(fp);
00244 lee_cfich(fp,&cf);
00245
00246 cdie_beep(cf.tfich!=TF_LPC,"error: not an LPC file");
00247 cdie_beep(cf.tdato!=TD_FLOAT4,"error: file data must be 4-UCHARs floats");
00248
00249 vete_cgparam(fp);
00250 lee_cgp_lpc(fp,cgpl);
00251
00252 vete_datos(fp);
00253 }
00254
00255
00256
00257
00258
00259 void escribe_cab_err( FILE * fp,
00260 struct cgsenal * cgs,
00261 struct cgp_lpc * cgpl,
00262 UCHAR1 tdata )
00263 {
00264 escribecfslpc(fp,cgs,cgpl,TF_SERR,tdata);
00265 }
00266
00267
00268
00269
00270 void escribe_cab_lpcsint( FILE * fp,
00271 struct cgsenal * cgs,
00272 struct cgp_lpc * cgpl,
00273 UCHAR1 tdata )
00274 {
00275 escribecfslpc(fp,cgs,cgpl,TF_SLPC,tdata);
00276 }
00277
00278
00279
00280
00281
00282 void escribecfs_form( FILE * fp,
00283 struct cgsenal * cgs,
00284 int espera_en_marcas )
00285 {
00286 struct cfich cf;
00287
00288 cf.tfich = TF_SFOR;
00289 cf.tdato = TD_INT2;
00290 cf.mcab = MC_SENAL;
00291
00292 vete_principio(fp);
00293 escribe_cfich(fp,&cf);
00294
00295 escribe_long(fp,long_cgsenal(cgs));
00296 if (espera_en_marcas) {
00297 escribe_cgsenal_marc(fp,cgs);
00298 endian_tolittle32(&(cgs->marc.unimarc));
00299 xfwrite(&(cgs->marc.unimarc),sizeof(cgs->marc.unimarc),1,fp);
00300 endian_fromlittle32(&(cgs->marc.unimarc));
00301 }
00302 else {
00303 escribe_cgsenal(fp,cgs);
00304 escribe_long_actual(fp,MC_NINGUNA);
00305 }
00306 }
00307
00308