aboutsummaryrefslogtreecommitdiff
path: root/filmoteca.c
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2021-01-16 08:38:00 +0000
committerrodri <rgl@antares-labs.eu>2021-01-16 08:38:00 +0000
commit199753fada745e558e130a131b478ad9a9ffd0d9 (patch)
treea54c96821eba45dda1e03cb29024a87f907d6cdf /filmoteca.c
parent2ba0c4f7520d37840308ccbda4841a99700fe11a (diff)
downloadfilmoteca-199753fada745e558e130a131b478ad9a9ffd0d9.tar.gz
filmoteca-199753fada745e558e130a131b478ad9a9ffd0d9.tar.bz2
filmoteca-199753fada745e558e130a131b478ad9a9ffd0d9.zip
started work on the catalog (cache).
added assetsdir example. added readme file.
Diffstat (limited to 'filmoteca.c')
-rw-r--r--filmoteca.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/filmoteca.c b/filmoteca.c
index 7e928b5..458d7dd 100644
--- a/filmoteca.c
+++ b/filmoteca.c
@@ -100,11 +100,23 @@ char *wdir = "/filmoteca";
int lfd, ncpu;
pthread_t *threads;
pthread_mutex_t attendlock;
+Index catalog;
int debug;
char *argv0;
+uint
+hash(char *s)
+{
+ uint h;
+
+ h = 0x811c9dc5;
+ while(*s != 0)
+ h = (h*0x1000193) ^ (uchar)*s++;
+ return h % INDEXSIZE;
+}
+
long
truestrlen(char *s)
{
@@ -402,6 +414,92 @@ hparsereq(void)
return req;
}
+Movie *
+allocmovie(){}
+
+void
+freemovie(Movie *m){}
+
+Multipart *
+allocmultipart(){}
+
+void
+freemultipart(Multipart *m){}
+
+Series *
+allocserie(){}
+
+void
+freeserie(Series *s){}
+
+Resource *
+allocresource(char *title, int type, void *p)
+{
+ Resource *r;
+
+ r = emalloc(sizeof(Resource));
+ r->title = strdup(title);
+ r->type = type;
+ r->media = p;
+ r->next = nil;
+}
+
+void
+freeresource(Resource *r)
+{
+ free(r->title);
+ switch(r->type){
+ case Rmovie:
+ freemovie(r->media);
+ break;
+ case Rmulti:
+ freemultipart(r->media);
+ break;
+ case Rserie:
+ freeserie(r->media);
+ break;
+ }
+ free(r);
+}
+
+void
+addresource(Index *idx, Resource *r)
+{
+ Resource *rp;
+ uint h;
+
+ h = hash(r->title);
+ if(idx->rtab[h] == nil){
+ idx->rtab[h] = r;
+ return;
+ }
+ for(rp = idx->rtab[h]; rp->next != nil; rp = rp->next)
+ ;
+ rp->next = r;
+}
+
+void
+delresource(Index *idx, char *title)
+{
+ Resource *rp, *rn;
+ uint h;
+
+ h = hash(title);
+ if(strcmp(idx->rtab[h]->title, title) == 0){
+ rn = idx->rtab[h]->next;
+ freeresource(idx->rtab[h]);
+ idx->rtab[h] = rn;
+ return;
+ }
+ for(rp = idx->rtab[h]; rp->next != nil; rp = rp->next)
+ if(strcmp(rp->next->title, title) == 0){
+ rn = rp->next->next;
+ freeresource(rp->next);
+ rp->next = rn;
+ break;
+ }
+}
+
void
sendfile(Req *req, FILE *f, struct stat *fst)
{