00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "afwav_i.hpp"
00031
00032 #include "xalloc.h"
00033
00034
00035
00036 int operator < (const UInt32& a, const UInt32& b) { return a.i<b.i; };
00037 int operator == (const UInt32& a, const UInt32& b) { return a.i==b.i; };
00038 int operator > (const UInt32& a, const UInt32& b) { return a.i>b.i; };
00039
00040
00041
00042 char *wstr( FILE *f )
00043 {
00044 UINT32 l;
00045 char *buf;
00046 xfread(&l,sizeof(l),1,f); endian_fromlittle32(&l);
00047 l++;
00048 cdie_beep(l!=(size_t)l,"Wav: field too long in .wav file");
00049 buf=(char*)xmalloc(l);
00050 xfread(buf,1,(size_t)(l-1),f);
00051 buf[(size_t)(l-1)]='\0';
00052 return buf;
00053 }
00054
00055
00056
00057 char *wstr( FILE *f, UINT32 l )
00058 {
00059 char *buf;
00060 l++;
00061 cdie_beep(l!=(size_t)l,"Wav: field too long in .wav file");
00062 buf=(char*)xmalloc(l);
00063 xfread(buf,1,(size_t)(l-1),f);
00064 buf[(size_t)(l-1)]='\0';
00065 return buf;
00066 }
00067
00068
00069
00070 VOID mrk_labl(Mark1DList &m, CueNames &cn, CHAR8 *buf)
00071 {
00072 #ifndef IGNORE_CUE_LABEL
00073 struct { UINT32 n MINALIGN; CHAR s MINALIGN; } *b;
00074 (CHAR8*)b=buf;
00075 endian_fromlittle32(&(b->n));
00076
00077 Lix p=cn.seek(b->n);
00078 if (p) p=m.lix(cn.index(p));
00079 cdie_beep(!p,"Wav: error in WAV file, invalid cue label");
00080 if (m.label(p)=="") m.label(p) = &(b->s);
00081 else m.label(p) = &(b->s) + String(" // ")+m.label(p);
00082 #else
00083 (void)m;
00084 (void)cn;
00085 #endif
00086
00087 xfree(buf);
00088 }
00089
00090
00091
00092 VOID mrk_note(Mark1DList &m, CueNames &cn, CHAR8 *buf)
00093 {
00094 struct mrk_note_struct { UINT32 n MINALIGN; CHAR s MINALIGN; };
00095 #define b ((struct mrk_note_struct *)buf)
00096 endian_fromlittle32(&(b->n));
00097
00098 Lix p=cn.seek(b->n);
00099 if (p) p=m.lix(cn.index(p));
00100 cdie_beep(!p,"Wav: error in WAV file, invalid cue note");
00101 if (m.label(p)=="") m.label(p) = &(b->s);
00102 else m.label(p) = m.label(p) + String(" // ") + &(b->s);
00103
00104 xfree(buf);
00105 #undef b
00106 }
00107
00108
00109
00110 VOID mrk_ltxt(Mark1DList &m, CueNames &cn, CHAR8 *buf)
00111 {
00112 struct mrk_ltxt_struct { UINT32 n MINALIGN; UINT32 len MINALIGN; UINT32 pur MINALIGN;
00113 UINT16 country MINALIGN; UINT16 lang MINALIGN; UINT16 dialec MINALIGN;
00114 UINT16 cpage MINALIGN; CHAR s MINALIGN; };
00115 #define b ((struct mrk_ltxt_struct *)buf)
00116
00117 endian_fromlittle32(&(b->n));
00118 endian_fromlittle32(&(b->len));
00119
00120
00121 Lix p=cn.seek(b->n);
00122 if (p) p=m.lix(cn.index(p));
00123 cdie_beep(!p,"Wav: error in WAV file, invalid cue ltxt");
00124 m.span(p)=b->len;
00125 xfree(buf);
00126 #undef b
00127 }
00128
00129
00130
00131 size_t strlen_zeven( const char *s )
00132 {
00133 size_t l = strlen(s)+1;
00134
00135 return (l&1)? l+1 : l;
00136 }
00137
00138
00139
00140 void puts_zeven( const char * s, FILE *f )
00141 {
00142 size_t l=strlen(s)+1;
00143 CHAR8 z='\0';
00144
00145 xfwrite(s,1,l,f);
00146 if (l&1)
00147 xfwrite(&z,sizeof(z),1,f);
00148 }
00149
00150
00151
00152 #ifdef __CC_MSVC__
00153 #pragma pack(pop)
00154 #endif
00155
00156