⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resmgr.h

📁 空战游戏flacon源码
💻 H
📖 第 1 页 / 共 3 页
字号:
    RES_ERR_FILE_ALREADY_CLOSED,
    RES_ERR_FILE_NOT_FOUND,
    RES_ERR_CANT_ATTRIB_DIRECTORY,
    RES_ERR_CANT_ATTRIB_FILE,
    RES_ERR_DIRECTORY_EXISTS,
    RES_ERR_IS_NOT_DIRECTORY,
    RES_ERR_COULD_NOT_DELETE,
    RES_ERR_COULD_NOT_CHANGE_DIR,
    RES_ERR_MUST_CREATE_PATH,
    RES_ERR_COULDNT_SPAWN_THREAD,
    RES_ERR_COULDNT_OPEN_FILE,
    RES_ERR_PROBLEM_READING,
    RES_ERR_PROBLEM_WRITING,
    RES_ERR_NO_SYSTEM_PATH,
    RES_ERR_CANT_INTERPRET,
    RES_ERR_UNKNOWN_ARCHIVE,
    RES_ERR_TOO_MANY_FILES,
    RES_ERR_ILLEGAL_FILE_HANDLE,
    RES_ERR_CANT_DELETE_FILE,
    RES_ERR_CANT_OPEN_ARCHIVE,
    RES_ERR_BAD_ARCHIVE,
    RES_ERR_UNKNOWN,
    RES_ERR_ALREADY_IN_PATH,
    RES_ERR_UNKNOWN_WRITE_TO,
    RES_ERR_CANT_WRITE_ARCHIVE,
    RES_ERR_UNSUPPORTED_COMPRESSION,
    RES_ERR_TOO_MANY_DIRECTORIES,
    RES_ERR_LAST_ERROR
};


/* ----- USER CALLBACKS ----- */

enum RES_CALLBACKS
{
    CALLBACK_UNKNOWN_CD,
    CALLBACK_SWAP_CD,
    CALLBACK_SYNCH_CD,
    CALLBACK_RESYNCH_CD,
    CALLBACK_OPEN_FILE,                  /* for your own debugging                                       */
    CALLBACK_CLOSE_FILE,                 /*   ditto                                                      */
    CALLBACK_READ_FILE,                  /*   ditto                                                      */
    CALLBACK_WRITE_FILE,                 /*   ditto                                                      */
    CALLBACK_ERROR,                      /*   ditto                                                      */
    CALLBACK_FILL_STREAM,                /* to replace my version of _filbuf()                           */ 

    NUMBER_OF_CALLBACKS
};


/* ----- SYSTEM PATHS ----- */

enum RES_PATHS                          /* enumerated slots for system paths                            */
{
    RES_DIR_NONE,
    RES_DIR_INSTALL,
    RES_DIR_WINDOWS,
    RES_DIR_CURR,
    RES_DIR_CD,
    RES_DIR_HD,
    RES_DIR_TEMP,
    RES_DIR_SAVE,
    RES_DIR_USER1,
    RES_DIR_USER2,
    RES_DIR_USER3,
    RES_DIR_USER4,
    RES_DIR_USER5,
    RES_DIR_USER6,
    RES_DIR_USER7,
    RES_DIR_USER8,
    RES_DIR_USER9,
    RES_DIR_LAST
};

#define FORCE_BIT                (1<<31)


/* ------------------------------------------------------------------------

        D A T A   S T R U C T U R E S

   ------------------------------------------------------------------------ */

typedef unsigned char   UCH;
typedef unsigned long   ULG;

typedef struct RES_STAT
{
   int      size;                       /* size of file (bytes)                                         */
   int      csize;                      /* compressed size of file (if in archive)                      */
   int      directory;                  /* location (directory)                                         */
   int      volume;                     /* location (volume)                                            */
   int      archive;                    /* archive id                                                   */
   int      attributes;                 /* file attributes                                              */
   int      mode;                       /* open mode _O_RDWR, etc...                                    */

} RES_STAT;


typedef struct RES_DIR
{
    int     current;                    /* used to to index into name array                             */
    int     num_entries;                /* number of filenames found in directory                       */
    char ** filenames;                  /* dynamically allocated array of filenames                     */
    char *  string_pool;                /* to glob allocations                                          */
    char *  string_ptr;                 /* current write ptr into string_pool                           */
    char *  name;                       /* directory name                                               */

} RES_DIR;


typedef struct HASH_ENTRY
{
    char  * name;                       /* filename    or pathname                                      */
    size_t  offset;                     /* offset within an archive                                     */
    size_t  size;                       /* size of file                                                 */
    size_t  csize;                      /* compressed size of file                                      */
    short   method;                     /* compress method (deflate or store)                           */
    long    file_position;              /* = -1 for loose file                                          */
    int     archive;                    /* handle if from an archive, or -1    if not                   */
    int     attrib;                     /* file attributes                                              */

    int    directory;                   /* GFG changed from char to int 3/10/98 */
    char    volume;

    void  * dir;                        /* if this entry is a directory                                 */

    struct HASH_ENTRY * next;           /* for imperfect hashes    -or- a subdirectory                  */

} HASH_ENTRY;


typedef struct HASH_TABLE
{
    int     table_size;                 /* number of slots in hash table                                */
    int     num_entries;                /* number of entries entered into hash table                    */
    char  * name;                       /* name the table (usually the directory name)                  */
    char  * ptr_in;                     /* ptr to insert strings                                        */
    char  * ptr_end;                    /* end of string space for this allocation                      */
    LIST  * str_list;                   /* list of string space allocations                             */


    struct HASH_ENTRY * table;          /* array -table- of hash entries                                */

} HASH_TABLE;


typedef struct COMPRESSED_FILE
{
    UCH   * slide;                      /* sliding window                               was: slide      */    
    UCH   * in_buffer;                  /* input buffer                                 was: inbuf      */
    UCH   * in_ptr;                     /* current write-to ptr within in_buffer        was: inptr      */
    int     in_count;                   /*                                              was: incnt      */
    int     in_size;                    /* size of input buffer                         was: inbufsiz   */
    char  * out_buffer;                 /* output buffer                                was: outbuf     */
    ULG     out_count;                  /* number of bytes written to output buffer     was: outcnt     */

    unsigned        wp;                 /* Inflate state variable: current position in slide            */
    unsigned long   bb;                 /* Inflate state variable: bit buffer                           */
    unsigned        bk;                 /* Inflate state variable: bits in bit buffer                   */
    long            csize;              /* Inflate state variable:                                      */

    struct ARCHIVE * archive;           /* archive from which this file is extracted                    */

} COMPRESSED_FILE;


typedef struct ARCHIVE
{
    char    name[ _MAX_FNAME ];         /* filename of the compressed archive                           */
    int     num_entries;                /* number of files within archive                               */
    int     os_handle;                  /* handle returned by open()    was: zipfd                      */
    int     length;                     /* was: ziplen                                                  */
    int     start_buffer;               /* was: cur_zipfile_bufstart                                    */
    char    volume;                     /* used to purge during ResDismount()                           */
    char    directory;                  /* used to purge during ResDismount()                           */

    HANDLE  lock;                       /* mutex lock                                                   */

                                        /* ------------ used temporarily to parse zip hdr ------------- */
                                        /* renamed to avoid accidentally misusing COMPRESSED_FILE mmbrs */
    UCH *   tmp_hold;                   /* was: fold?                                                   */
    UCH *   tmp_slide;                  /* sliding window                               was: slide      */    
    UCH *   tmp_in_buffer;              /* input buffer                                 was: inbuf      */
    UCH *   tmp_in_ptr;                 /* current write-to ptr within in_buffer        was: inptr      */
    int     tmp_in_count;               /*                                              was: incnt      */
    int     tmp_in_size;                /* size of input buffer                         was: inbufsiz   */
    UCH *   tmp_out_buffer;             /* output buffer                                was: outbuf     */
    int     tmp_out_count;              /* number of bytes written to output buffer     was: outcnt     */
    int     tmp_len;                    /* zip file length                              was: ziplen     */
    int     tmp_bytes_to_read;          /* bytes to read...?                            was: csize      */
                                        /* ------------ used temporarily to parse zip hdr ------------- */

    LIST *  open_list;                  /* list of COMPRESSED_FILE structs pointing back here           */

    struct HASH_TABLE * table;          /* hash table for this archive                                  */

} ARCHIVE;


typedef struct FILE_ENTRY               /* called "filedes" within AFU                                  */
{
    int     os_handle;                  /* handle returned by operating system                          */
    int     seek_start;
    size_t  current_pos;
    size_t  size;                       /* uncompressed file size                                       */
    size_t  csize;                      /* compressed file size                                         */
    int     attrib;                     /* file attributes                                              */
    int     mode;                       /* mode file was opened in                                      */
    int     location;
    char    device;
    char  * data;
    char  * filename;
    size_t current_filbuf_pos;      
    struct COMPRESSED_FILE * zip;       /* struct for maintaining unzip state data                      */

} FILE_ENTRY;


typedef struct DEVICE_ENTRY
{
    char    letter;                     /* drive letter                                                 */
    char    type;                       /* type of device                                               */
    char    name[32];                   /* volume name of device                                        */
    char    id;                         /* which cd number                                              */

    unsigned long serial;               /* serial number of volume                                      */

} DEVICE_ENTRY;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -