taskrambler  v0.1.8
Web server and task management solution.
asset.h File Reference
#include <sys/types.h>
#include "class.h"
#include "commons.h"
#include "hash.h"
+ Include dependency graph for asset.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CLASS (Asset)
 
Asset assetPoolGet (const char *, size_t)
 
size_t assetPoolRelease (Asset)
 
void assetPoolCleanup (void)
 

Detailed Description

Represents an asset (a file on disk)

Author
Georg Hopp

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Definition in file asset.h.

Function Documentation

void assetPoolCleanup ( void  )

Definition at line 88 of file pool.c.

References asset_pool, freeAsset(), and hashEach().

Referenced by main().

89 {
90  if (NULL != asset_pool) {
92  delete(asset_pool);
93  }
94 }
static void freeAsset(const void *_node)
Definition: pool.c:37
Hash asset_pool
Definition: pool.c:32
void hashEach(Hash, void(*)(const void *))
Definition: each.c:38

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Asset assetPoolGet ( const char *  ,
size_t   
)

Definition at line 43 of file pool.c.

References asset_pool, hashAdd(), and hashGet().

Referenced by httpResponseAsset().

44 {
45  Asset asset = NULL;
46 
47  if (NULL == asset_pool) {
48  asset_pool = new(Hash);
49  } else {
50  asset = hashGet(asset_pool, path, npath);
51  }
52 
53  if (NULL == asset) {
54  asset = new(Asset, path, npath);
55  if (NULL != asset) {
56  hashAdd(asset_pool, asset);
57  }
58  } else {
59  asset->ref_count++;
60  }
61 
62  return asset;
63 }
void * hashGet(Hash, const char *, size_t)
Definition: hash/get.c:51
Hash asset_pool
Definition: pool.c:32
void * hashAdd(Hash, void *)
Definition: add.c:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

size_t assetPoolRelease ( Asset  )

Definition at line 66 of file pool.c.

References asset_pool, and hashDelete().

Referenced by httpMessageDtor().

67 {
68  if (asset->ref_count > 1) {
69  asset->ref_count--;
70  return asset->ref_count;
71  }
72 
73  if (NULL != asset) {
74  Asset found = (Asset)hashDelete(
75  asset_pool, asset->fname, asset->nfname);
76 
77  if (found == asset) {
78  delete(found);
79  } else {
80  // this should never happen....error log...
81  }
82  }
83 
84  return 0;
85 }
Hash asset_pool
Definition: pool.c:32
void * hashDelete(Hash, const char *, size_t)
Definition: hash/delete.c:48

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CLASS ( Asset  )

Definition at line 34 of file asset.h.

References size.

34  {
35  unsigned long hash;
36 
37  char fname[2049];
38  char etag[200];
39  char mtime[200];
40 
41  size_t nfname;
42  size_t netag;
43  size_t nmtime;
44 
45  char * mime_type;
46  size_t nmime_type;
47 
48  int handle;
49  char * data;
50  size_t size;
51 
52  size_t ref_count;
53 };
static size_t size