diff options
Diffstat (limited to 'includes')
| -rw-r--r-- | includes/Buffer.h | 10 | ||||
| -rw-r--r-- | includes/Exceptions.h | 16 | ||||
| -rw-r--r-- | includes/Handle.h | 21 | ||||
| -rw-r--r-- | includes/Image.h | 6 | ||||
| -rw-r--r-- | includes/Input.h | 16 | ||||
| -rw-r--r-- | includes/Output.h | 20 | ||||
| -rw-r--r-- | includes/String.h | 6 | ||||
| -rw-r--r-- | includes/cdreader.h | 12 | ||||
| -rw-r--r-- | includes/cdutils.h | 123 | ||||
| -rw-r--r-- | includes/generic.h | 2 | ||||
| -rw-r--r-- | includes/lzss.h | 76 | ||||
| -rw-r--r-- | includes/yazedc.h | 85 | 
12 files changed, 204 insertions, 189 deletions
| diff --git a/includes/Buffer.h b/includes/Buffer.h index 79d0e02..dc4d768 100644 --- a/includes/Buffer.h +++ b/includes/Buffer.h @@ -17,12 +17,12 @@ class Buffer : public Handle {        virtual ~Buffer();      virtual ssize_t write(const void *buf, size_t count) throw(GeneralException);      virtual ssize_t read(void *buf, size_t count) throw (GeneralException); -    virtual bool CanRead(); -    virtual bool CanWrite(); -    virtual String GetName(); +    virtual bool CanRead() const; +    virtual bool CanWrite() const; +    virtual String GetName() const;      virtual Buffer operator=(const Buffer &); -    virtual bool CanWatch(); -    virtual ssize_t GetSize(); +    virtual bool CanWatch() const; +    virtual ssize_t GetSize() const;      char operator[](size_t) const;      char & operator[](size_t); diff --git a/includes/Exceptions.h b/includes/Exceptions.h index ef697e7..49be085 100644 --- a/includes/Exceptions.h +++ b/includes/Exceptions.h @@ -21,6 +21,7 @@ class Base {      void operator delete(void * p);      static void free(void *& p);      static void free(char *& p); +    static void free(unsigned char *& p);      static int pipe(int * p, int flag = 0);      static pid_t fork();  }; @@ -32,7 +33,7 @@ class GeneralException : public Base {        GeneralException(String);        GeneralException(const GeneralException &);        ~GeneralException(); -    char * GetMsg(); +    const char * GetMsg() const;    protected:        GeneralException(); @@ -44,6 +45,7 @@ char * xstrdup(const char *);  void * xmalloc(size_t) throw (GeneralException);  void xfree(void *&);  void xfree(char *&); +void xfree(unsigned char *&);  void * xrealloc(void *, size_t);  int xpipe(int *, int = 0) throw (GeneralException);  pid_t xfork() throw (GeneralException); @@ -84,6 +86,10 @@ INLINE void Base::free(char *& p) {      xfree(p);  } +INLINE void Base::free(unsigned char *& p) { +    xfree(p); +} +  INLINE int Base::pipe(int * p, int flag) {      return xpipe(p, flag);  } @@ -129,6 +135,14 @@ class TaskSwitch : public GeneralException {        TaskSwitch();  }; +class Exit : public GeneralException { +  public: +      Exit(int); +      int GetCode(); +  private: +    int code; +}; +  #include <String.h>  #else diff --git a/includes/Handle.h b/includes/Handle.h index 4bab879..a82aa52 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -19,26 +19,27 @@ class Handle : public Base {        virtual ~Handle();      virtual ssize_t read(void *buf, size_t count) throw (GeneralException);      virtual ssize_t write(const void *buf, size_t count) throw (GeneralException); -    bool IsClosed(void); -    bool IsNonBlock(void); +    bool IsClosed(void) const; +    bool IsNonBlock(void) const;      void SetNonBlock(void); -    virtual bool CanRead(); -    virtual bool CanWrite(); -    virtual bool CanSeek(); +    virtual bool CanRead() const; +    virtual bool CanWrite() const; +    virtual bool CanSeek() const;      virtual off_t seek(off_t, int = SEEK_SET) throw (GeneralException); -    virtual off_t tell(); -    virtual String GetName(); -    virtual ssize_t GetSize(); -    virtual time_t GetModif(); +    virtual off_t tell() const; +    virtual String GetName() const; +    virtual ssize_t GetSize() const; +    virtual time_t GetModif() const;      void close() throw (GeneralException);      int GetHandle(); -    virtual bool CanWatch(); +    virtual bool CanWatch() const;      virtual void Dup(const Handle &);  #ifdef HAVE_ZLIB      virtual void SetZ(int) throw (GeneralException);  #endif    protected:        Handle(int h); +    int GetHandle() const;      off_t itell;    private:      ssize_t uwrite(const void *, size_t) throw (GeneralException); diff --git a/includes/Image.h b/includes/Image.h index fc94a12..09b4cb5 100644 --- a/includes/Image.h +++ b/includes/Image.h @@ -19,12 +19,12 @@ class Image : public Buffer {    public:        Image(unsigned int, unsigned int);        virtual ~Image(); -    Color GetPixel(unsigned int, unsigned int); +    Color GetPixel(unsigned int, unsigned int) const;      void SetPixel(unsigned int, unsigned int, Color);      bool Prepare(unsigned int = FORMAT_TGA_BASIC);      void Fill(Color = Color(0, 0, 0)); -    virtual String GetName(); -    virtual bool CanWrite(); +    virtual String GetName() const; +    virtual bool CanWrite() const;    private:      typedef unsigned char Byte; diff --git a/includes/Input.h b/includes/Input.h index d1755e7..1fb48c3 100644 --- a/includes/Input.h +++ b/includes/Input.h @@ -12,13 +12,13 @@ class Input : public Handle {        Input(const String & = "") throw (GeneralException);        Input(const Input &);        virtual ~Input() {} -    virtual bool CanWrite(); -    virtual bool CanRead(); -    virtual bool CanSeek(); +    virtual bool CanWrite() const; +    virtual bool CanRead() const; +    virtual bool CanSeek() const;      virtual off_t seek(off_t, int) throw (GeneralException); -    virtual String GetName(); -    virtual ssize_t GetSize(); -    virtual time_t GetModif(); +    virtual String GetName() const; +    virtual ssize_t GetSize() const; +    virtual time_t GetModif() const;    protected:      String n; @@ -30,8 +30,8 @@ class Stdin_t : public Input {    public:        Stdin_t();        virtual ~Stdin_t() {} -    virtual bool CanSeek(); -    virtual String GetName(); +    virtual bool CanSeek() const; +    virtual String GetName() const;  };  extern Stdin_t Stdin; diff --git a/includes/Output.h b/includes/Output.h index bce4160..3ec5158 100644 --- a/includes/Output.h +++ b/includes/Output.h @@ -12,11 +12,11 @@ class Output : public Handle {        Output(String = "", int create = 1, int trunc = 1) throw (GeneralException);        Output(const Output &);        virtual ~Output() {} -    virtual bool CanWrite(); -    virtual bool CanRead(); -    virtual bool CanSeek(); +    virtual bool CanWrite() const; +    virtual bool CanRead() const; +    virtual bool CanSeek() const;      virtual off_t seek(off_t, int) throw (GeneralException); -    virtual String GetName(); +    virtual String GetName() const;    protected:      String n; @@ -28,18 +28,18 @@ class Stdout_t : public Output {    public:        Stdout_t();        virtual ~Stdout_t() {} -    virtual bool CanSeek(); -    virtual String GetName(); +    virtual bool CanSeek() const; +    virtual String GetName() const;  };  class Stderr_t : public Handle {    public:        Stderr_t();        virtual ~Stderr_t() {} -    virtual bool CanWrite(); -    virtual bool CanRead(); -    virtual bool CanSeek(); -    virtual String GetName(); +    virtual bool CanWrite() const; +    virtual bool CanRead() const; +    virtual bool CanSeek() const; +    virtual String GetName() const;  };  extern Stdout_t Stdout; diff --git a/includes/String.h b/includes/String.h index ea501b2..7e2f848 100644 --- a/includes/String.h +++ b/includes/String.h @@ -9,10 +9,10 @@  class String : public Base {    public:        String(const String &); -#if 0        String(const char * = ""); -#endif +#if 0        String(const char * = "", ...); +#endif        String(char);        String(int);        String(unsigned int); @@ -53,6 +53,8 @@ class String : public Base {      bool operator<(const String &) const;      bool operator>(const String &) const;      char operator[](size_t i) const; +    String & toupper(); +    String & tolower();    private:        String(int hs, const char *); diff --git a/includes/cdreader.h b/includes/cdreader.h index 3991225..ed3bc00 100644 --- a/includes/cdreader.h +++ b/includes/cdreader.h @@ -12,17 +12,17 @@ class cdreader : public Handle {        cdreader(const String & = "/dev/cdrom") throw (GeneralException);        cdreader(const cdreader &);        virtual ~cdreader() {} -    virtual bool CanWrite(); -    virtual bool CanRead(); -    virtual bool CanSeek(); +    virtual bool CanWrite() const; +    virtual bool CanRead() const; +    virtual bool CanSeek() const;      virtual ssize_t read(void *buf, size_t count) throw (GeneralException);                                                           virtual off_t seek(off_t, int) throw (GeneralException); -    virtual String GetName(); -    virtual ssize_t GetSize(); +    virtual String GetName() const; +    virtual ssize_t GetSize() const;      virtual void getsector(void *, int = -1) throw (GeneralException);      virtual void sectorseek(int); -  protected: +  private:      String n;      int sector;  }; diff --git a/includes/cdutils.h b/includes/cdutils.h index e3cf8fb..38eb118 100644 --- a/includes/cdutils.h +++ b/includes/cdutils.h @@ -27,62 +27,77 @@  #define GUESS 5 -struct DirEntry { -    unsigned char R; -    unsigned char NExt; -    unsigned long Sector; -    unsigned long BESector; -    unsigned long Size; -    unsigned long BESize; -    unsigned char Year; -    unsigned char Month; -    unsigned char Day; -    unsigned char Hour; -    unsigned char Minute; -    unsigned char Second; -    unsigned char Offset; -    unsigned char Flags; -    unsigned char HandleUnit; -    unsigned char HandleGap; -    unsigned short VolSeq; -    unsigned short BEVolSeq; -    unsigned char N; -    char id; -} PACKED; +extern const long sec_sizes[]; +extern const long sec_offsts[]; +extern const String sec_modes[]; -extern struct DirEntry rootDir; +class cdutils : public Base { +  public: +      cdutils(Handle * f_iso_r, Handle * f_iso_w = 0); +      virtual ~cdutils(); -extern long sec_sizes[]; -extern long sec_offsts[]; -extern String sec_modes[]; +    struct DirEntry { +	unsigned char R; +	unsigned char NExt; +	unsigned long Sector; +	unsigned long BESector; +	unsigned long Size; +	unsigned long BESize; +	unsigned char Year; +	unsigned char Month; +	unsigned char Day; +	unsigned char Hour; +	unsigned char Minute; +	unsigned char Second; +	unsigned char Offset; +	unsigned char Flags; +	unsigned char HandleUnit; +	unsigned char HandleGap; +	unsigned short VolSeq; +	unsigned short BEVolSeq; +	unsigned char N; +	char id; +    } PACKED; -Handle * open_ppf(String ppf, Handle * iso, String comment) throw(GeneralException); -void close_ppf() throw(GeneralException); -unsigned short int swap_word(unsigned short int i); -unsigned long int swap_dword(unsigned long int i); -int guess_type(Handle * f_iso, int number); -void sector_seek(Handle * f_iso, long sector); -long read_sector(Handle * f_iso, Byte * buffer, int type, int number = -1); -void read_datas(Handle * f_iso, Byte * buffer, int type, int number, long size); -void read_file(Handle * f_iso, Handle * Handle, int type, int number, long size); -void write_sector(Handle * f_iso_r, Handle * f_iso_w, Byte * buffer, int type, int number = -1); -void write_datas(Handle * f_iso_r, Handle * f_iso_w, Byte * buffer, int type, int number, long size); -void write_file(Handle * f_iso_r, Handle * f_iso_w, Handle * Handle, int type, int number = -1); -int get_iso_infos(Handle * h); -int show_iso_infos(Handle * h); -int get_pt_infos(Handle * h); -int show_pt_infos(Handle * h); -struct DirEntry find_path(Handle * h, String path); -struct DirEntry find_parent(Handle * h, String path); -void show_head_entry(void); -int show_entry(struct DirEntry * dir); -int show_dir(Handle * h, struct DirEntry * dir); -struct DirEntry find_dir_entry(Handle * h, struct DirEntry * dir, String name); -struct DirEntry * find_dir_entry(Handle * h, Byte ** buffer, struct DirEntry * dir, String name); -unsigned char from_BCD(unsigned char x); -unsigned char to_BCD(unsigned char x); -int is_valid_BCD(unsigned char x); -unsigned long from_MSF(unsigned long msf, unsigned long start = 150); -unsigned long from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start = 150); + +    struct DirEntry rootDir; + +    Handle * open_ppf(String ppf, String comment) throw(GeneralException); +    void close_ppf() throw(GeneralException); +    void set_iso_w(Handle *); +    unsigned short int swap_word(unsigned short int i); +    unsigned long int swap_dword(unsigned long int i); +    int guess_type(int number = -1); +    void sector_seek(long sector); +    long read_sector(Byte * buffer, int type, int number = -1); +    void read_datas(Byte * buffer, int type, int number, long size); +    void read_file(Handle * Handle, int type, int number, long size); +    void write_sector(Byte * buffer, int type, int number = -1); +    void write_datas(Byte * buffer, int type, int number, long size); +    void write_file(Handle * Handle, int type, int number = -1); +    int get_iso_infos(); +    int show_iso_infos(); +    int get_pt_infos(); +    int show_pt_infos(); +    struct DirEntry find_path(String path); +    struct DirEntry find_parent(String path); +    void show_head_entry(void); +    int show_entry(struct DirEntry * dir); +    int show_dir(struct DirEntry * dir); +    struct DirEntry find_dir_entry(struct DirEntry * dir, String name); +    struct DirEntry * find_dir_entry(Byte ** buffer, struct DirEntry * dir, String name); +    unsigned char from_BCD(unsigned char x); +    unsigned char to_BCD(unsigned char x); +    int is_valid_BCD(unsigned char x); +    unsigned long from_MSF(unsigned long msf, unsigned long start = 150); +    unsigned long from_MSF(unsigned char m, unsigned char s, unsigned char f, unsigned long start = 150); +  private: +    void write_ppf(Byte * old_sec, Byte * new_sec, int sec_num); +    String format_date(String input); +    yazedc yazedc_o; +     +    Handle * f_iso_r, * f_iso_w, * ppf_file; +    int pt1, pt2, snum, ptl, root; +};  #endif diff --git a/includes/generic.h b/includes/generic.h index 168c9d3..62a9942 100644 --- a/includes/generic.h +++ b/includes/generic.h @@ -79,6 +79,8 @@ typedef Uint32 DWord;  #if defined __linux__ || defined __CYGWIN32__  #define PACKED __attribute__((packed)) +#else +#define PACKED  #endif  extern char verbosity; diff --git a/includes/lzss.h b/includes/lzss.h index 5bfa68a..17f4806 100644 --- a/includes/lzss.h +++ b/includes/lzss.h @@ -24,41 +24,57 @@  #include "generic.h"  #include "Handle.h" -#define LZSS_VERSION "3.0.0-pre1" -#define LZSS_NAME "lzss" +#define LZSS_VERSION String("3.0.0-pre1") +#define LZSS_NAME String("lzss") -typedef struct { -    char * name; -    int one_is_compressed, bitmap_inversed, one_jump, overlap_trick, negative_trick, sixteen_bits, ptrb, filling; -    int window_start; -    int l_mask_1, l_shft_1, l_mask_2, l_shft_2; -    int j_mask_1, j_shft_1, j_mask_2, j_shft_2; -    int f_mask_1, f_shft_1, f_mask_2, f_shft_2; -    int v_mask_1, v_shft_1, v_mask_2, v_shft_2; -} scheme_t; +class lzss : public Base { +  public: +      lzss(); +    typedef struct { +	char * name; +	int one_is_compressed, bitmap_inversed, one_jump, overlap_trick, negative_trick, sixteen_bits, ptrb, filling; +	int window_start; +	int l_mask_1, l_shft_1, l_mask_2, l_shft_2; +	int j_mask_1, j_shft_1, j_mask_2, j_shft_2; +	int f_mask_1, f_shft_1, f_mask_2, f_shft_2; +	int v_mask_1, v_shft_1, v_mask_2, v_shft_2; +    } scheme_t; -enum { -    XENO = 0, -    DBZ, -    FF7, -    LM, -    MM, -    OB, -    LODOSS, -    FF6, -    VP_1, -    VP_2, -    END -}; +    enum { +	XENO = 0, +	DBZ, +	FF7, +	LM, +	MM, +	OB, +	LODOSS, +	FF6, +	VP_1, +	VP_2, +	END +    }; -extern scheme_t scheme, schemes[]; +    static const scheme_t schemes[]; +    int tolerate, blockb; +    long blk, bitmap_count; -extern int tolerate, blockb; -extern long blk, bitmap_count; +    unsigned long lzss_decomp(Handle * f_source, Handle * f_cible, long true_length = -1); +    void lzss_comp(Handle * f_source, Handle * f_cible, long * delta = NULL); -unsigned long lzss_decomp(Handle * f_source, Handle * f_cible, long true_length = -1); -void lzss_comp(Handle * f_source, Handle * f_cible, long * delta = NULL); +    Byte swap_bits(Byte); +     +    void change_scheme(scheme_t); +    scheme_t get_scheme(); -char swap_bits(char); +  private: +    scheme_t scheme; +    int lzss_maxsize, lzss_maxptr; +     +    unsigned int shift(unsigned int, int); +    void compute_limits(void); +    unsigned char lzss_rd(unsigned char *, long); +    long lzss_comp_strstr(unsigned char *, unsigned char *, long *, long); +    unsigned char * lzss_memcomp(unsigned char *, long *, long *); +};  #endif diff --git a/includes/yazedc.h b/includes/yazedc.h index b990d3e..298c0eb 100644 --- a/includes/yazedc.h +++ b/includes/yazedc.h @@ -22,6 +22,8 @@  #ifndef __YAZEDC_H__ +#include "Exceptions.h" +  #define RS_L12_BITS 8  /* audio sector definitions for CIRC */ @@ -32,17 +34,6 @@  #define L1_Q   4  #define L1_P   4 -/* audio sector Cross Interleaved Reed-Solomon Code (CIRC) encoder (layer 1) */ -/* adds P- and Q- parity information to audio (f2) frames. Also -   optionally handles the various delays and permutations. The output with all -   stages enabled can be fed into the Eight-Fourteen-Modulator. -   On input: 2352 bytes of audio data is given. -   On output: 3136 bytes of CIRC enriched audio data are returned. - */ -int do_encode_L1(unsigned char in[L1_RAW*FRAMES_PER_SECTOR], -		unsigned char out[(L1_RAW+L1_Q+L1_P)*FRAMES_PER_SECTOR], -		int delay1, int delay2, int delay3, int scramble); -  /* data sector definitions for RSPC */  /* user data bytes per frame */  #define L2_RAW (1024*2) @@ -57,14 +48,25 @@ int do_encode_L1(unsigned char in[L1_RAW*FRAMES_PER_SECTOR],  #define MODE_2_FORM_1	3  #define MODE_2_FORM_2	4 -#ifdef __cplusplus -extern "C" { -#endif +/* r-w sub channel definitions */ +#define RS_SUB_RW_BITS 6 + +#define PACKETS_PER_SUBCHANNELFRAME 4 +#define LSUB_RAW 18 +#define LSUB_QRAW 2 +/* 6 bit */ +#define LSUB_Q 2 +#define LSUB_P 4 + +class yazedc : public Base { + +  public: +      yazedc();  /* set one of the MODE_* constants for subsequent data sector formatting */ -int set_sector_type(int st); +    int set_sector_type(int st);  /* get the current sector type setting for data sector formatting */ -int get_sector_type(void); +    int get_sector_type(void);  /* data sector layer 2 Reed-Solomon Product Code encoder */  /* encode the given data portion depending on sector type (see @@ -88,55 +90,18 @@ int get_sector_type(void);                      in the inout array.                      Sync-, header- and edc- fields will be added.  */ -int do_encode_L2(unsigned char *inout, int sectortype, unsigned address); -int decode_L2_Q(unsigned char inout[4 + L2_RAW + 12 + L2_Q]); -int decode_L2_P(unsigned char inout[4 + L2_RAW + 12 + L2_Q + L2_P]); -unsigned long int build_edc(unsigned char inout[], int from, int upto); +    int do_encode_L2(unsigned char *inout, int sectortype, unsigned address);  /* generates f2 frames from otherwise fully formatted sectors (generated by     do_encode_L2()). */ -int scramble_L2(unsigned char *inout); +    int scramble_L2(unsigned char *inout); -#ifdef __cplusplus -} -#endif - -/* r-w sub channel definitions */ -#define RS_SUB_RW_BITS 6 +    unsigned char minute, second, frame; -#define PACKETS_PER_SUBCHANNELFRAME 4 -#define LSUB_RAW 18 -#define LSUB_QRAW 2 -/* 6 bit */ -#define LSUB_Q 2 -#define LSUB_P 4 - -#ifdef __cplusplus -extern "C" { -#endif - -/* R-W subchannel encoder */ -/* On input: 72 bytes packed user data, four frames with each 18 bytes. -   On output: per frame: 2 bytes user data, 2 bytes Q parity,  -                         16 bytes user data, 4 bytes P parity. -   Options: -     delay1: use low level delay line -     scramble: perform low level permutations - */ -int do_encode_sub(unsigned char in[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], -		unsigned char out[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME], -		int delay1, int scramble); -int do_decode_sub(unsigned char in[(LSUB_RAW+LSUB_Q+LSUB_P)*PACKETS_PER_SUBCHANNELFRAME], -		unsigned char out[LSUB_RAW*PACKETS_PER_SUBCHANNELFRAME], -		int delay1, int scramble); - -int decode_LSUB_Q(unsigned char inout[LSUB_QRAW + LSUB_Q]); -int decode_LSUB_P(unsigned char inout[LSUB_RAW + LSUB_Q + LSUB_P]); - -#ifdef __cplusplus -} -#endif +  private: +    int sectortype; +    int build_address(unsigned char inout[], int sectortype, unsigned address); -extern unsigned char minute, second, frame; +};  #endif | 
