--- /dev/null
+obj = asscat.o
+bin = asscat
+root = ../..
+
+CFLAGS = -pedantic -Wall -g -I$(root)/src
+LDFLAGS = -L$(root) -Wl,-rpath=$(root) -lassman
+
+$(bin): $(obj)
+ $(CC) -o $@ $(obj) $(LDFLAGS)
+
+.PHONY: clean
+clean:
+ rm -f $(obj) $(bin)
--- /dev/null
+#include <stdio.h>
+#include <string.h>
+#include "assman.h"
+
+void print_usage(const char *argv0);
+
+int main(int argc, char **argv)
+{
+ int i, rdsz;
+ const char *prefix = 0;
+ ass_file *fp;
+ static char buf[1024];
+
+ for(i=1; i<argc; i++) {
+ if(argv[i][0] == '-') {
+ if(strcmp(argv[i], "-prefix") == 0) {
+ prefix = argv[++i];
+
+ } else if(strcmp(argv[i], "-path") == 0) {
+ ass_add_path(prefix, argv[++i]);
+
+ } else if(strcmp(argv[i], "-archive") == 0) {
+ ass_add_archive(prefix, argv[++i]);
+
+ } else if(strcmp(argv[i], "-url") == 0) {
+ ass_add_url(prefix, argv[++i]);
+
+ } else if(strcmp(argv[i], "-help") == 0 || strcmp(argv[i], "-h") == 0) {
+ print_usage(argv[0]);
+ return 0;
+
+ } else {
+ fprintf(stderr, "invalid option: %s\n", argv[i]);
+ return 1;
+ }
+
+ } else {
+ if(!(fp = ass_fopen(argv[i], "rb"))) {
+ fprintf(stderr, "failed to open asset: %s: %s\n", argv[i], strerror(ass_errno));
+ return 1;
+ }
+ while((rdsz = ass_fread(buf, 1, sizeof buf, fp)) > 0) {
+ fwrite(buf, 1, rdsz, stdout);
+ }
+ fflush(stdout);
+ ass_fclose(fp);
+ }
+ }
+
+ return 0;
+}
+
+void print_usage(const char *argv0)
+{
+ printf("Usage: %s [options] <file 1> <file 2> ... <file n>\n");
+ printf("Options:\n");
+ printf(" -prefix <prefix> sets the path prefix to match for subsequent asset sources\n");
+ printf(" -path <path> filesystem asset source\n");
+ printf(" -archive <archive> archive asset source\n");
+ printf(" -url <url> url asset source\n");
+ printf(" -h,-help print usage and exit\n");
+}
#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);
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);
/* 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;
}
return file;
}
+ ass_errno = errno;
return 0;
}
static void *fop_open(const char *fname, void *udata)
{
- const char *prefix = (char*)udata;
+ const char *asspath = (char*)udata;
char *path;
FILE *fp;
- path = alloca(strlen(prefix) + strlen(fname) + 2);
- sprintf(path, "%s/%s", path, fname);
+ path = alloca(strlen(asspath) + strlen(fname) + 2);
+ sprintf(path, "%s/%s", asspath, fname);
if(!(fp = fopen(path, "rb"))) {
ass_errno = errno;
}
#else
-int ass_mod_url_disabled;
+struct ass_fileops *ass_alloc_url(const char *url)
+{
+ fprintf(stderr, "assman: compiled without URL asset source support\n");
+ return 0;
+}
+
+void ass_free_url(struct ass_fileops *fop)
+{
+}
#endif