#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <errno.h>
#include "assman_impl.h"
static int add_fop(const char *prefix, int type, struct ass_fileops *fop);
static const char *match_prefix(const char *str, const char *prefix);
-static int add_file(ass_file *file);
-static int remove_file(ass_file *file);
#define DEF_FLAGS (1 << ASS_OPEN_FALLTHROUGH)
void *mfile;
ass_file *file;
FILE *fp;
+ const char *after_prefix;
m = mlist;
while(m) {
- if(match_prefix(fname, m->prefix)) {
- if((mfile = m->fop->open(fname, m->fop->udata))) {
+ if((after_prefix = match_prefix(fname, m->prefix))) {
+ if((mfile = m->fop->open(after_prefix, m->fop->udata))) {
if(!(file = malloc(sizeof *file))) {
perror("assman: ass_fopen failed to allocate file structure");
m->fop->close(mfile, m->fop->udata);
}
file->file = mfile;
file->fop = m->fop;
-
- if(add_file(file) == -1) {
- m->fop->close(mfile, m->fop->udata);
- free(file);
- return 0;
- }
return file;
} else {
if(!(assflags & (1 << ASS_OPEN_FALLTHROUGH))) {
/* nothing matched, or failed to open, try the filesystem */
if((fp = fopen(fname, mode))) {
if(!(file = malloc(sizeof *file))) {
+ ass_errno = errno;
perror("assman: ass_fopen failed to allocate file structure");
fclose(fp);
return 0;
}
file->file = fp;
file->fop = 0;
-
- if(add_file(file) == -1) {
- fclose(fp);
- free(file);
- return 0;
- }
return file;
}
+ ass_errno = errno;
return 0;
}
} else {
fclose(fp->file);
}
- remove_file(fp);
free(fp);
}
*ptr = 0;
return ptr == s ? 0 : s;
}
-
-
-static int add_file(ass_file *file)
-{
- return -1; /* TODO */
-}
-
-static int remove_file(ass_file *file)
-{
- return -1; /* TODO */
-}