home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Phoenix Heaven Sunny 2
/
APPARE2.BIN
/
oh_towns
/
dic
/
src
/
catalog.c
next >
Wrap
Text File
|
1995-06-20
|
2KB
|
82 lines
/******************************************
CATALOG? Load
*******************************************/
#include "defs.h"
CATALOG *catalog_load(char *file)
{
int n, i, gz, gh;
char ttl[82];
#ifndef UNIX
struct _CATALOG {
char type;
char resv;
char name[80];
struct {
uchar no_hi, no_low;
char path[44];
} file[10];
} id;
#else
uchar id[542];
#endif
uchar tmp[4];
CATALOG *tp = NULL;
CATALOG *cp, *bp;
for ( n = 1 ; n <= vtoc_file_max ; n++ ) {
if ( !CD_file_open(n) && strcmp(file_name, file) == 0 )
break;
}
if ( n > vtoc_file_max || IO_seek(1, 0) || IO_read(tmp, 4) != 4 )
return NULL;
n = tmp[2] * 256 + tmp[3];
while ( n-- > 0 ) {
#ifndef UNIX
if ( IO_read((char *)(&id), sizeof(id)) != sizeof(id) )
return NULL;
str_cnv(ttl, id.name, 80);
i = id.file[0].no_hi * 256 + id.file[0].no_low;
gz = id.file[2].no_hi * 256 + id.file[2].no_low; /* 外字 16全 */
gh = id.file[6].no_hi * 256 + id.file[6].no_low; /* 外字 16半 */
#else
if ( IO_read(id, 542) != 542 )
return NULL;
str_cnv(ttl, id + 2, 80);
i = id[82] * 256 + id[83];
gz = id[82 + 46 * 2] * 256 + id[83 + 46 * 2]; /* 外字 16全 */
gh = id[82 + 46 * 6] * 256 + id[83 + 46 * 6]; /* 外字 16半 */
#endif
if ( (cp = (CATALOG *)malloc(sizeof(CATALOG))) == NULL )
break;
cp->next = NULL;
cp->ttl = strdup(ttl);
cp->no = i;
cp->gah = gh;
cp->gaz = gz;
if ( tp == NULL )
tp = bp = cp;
else {
bp->next = cp;
bp = cp;
}
}
return tp;
}
void catalog_free(CATALOG *cp)
{
CATALOG *tp;
while ( (tp = cp) != NULL ) {
cp = cp->next;
free(tp);
}
}