/*
- * $Id: globals.h,v 1.93 2000/06/25 22:28:42 wessels Exp $
+ * $Id: globals.h,v 1.94 2000/06/27 08:41:30 hno Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
extern int store_open_disk_fd; /* 0 */
extern const char *SwapDirType[];
extern storefs_entry_t *storefs_list; /* NULL */
+extern storerepl_entry_t *storerepl_list; /* NULL */
extern int store_swap_low; /* 0 */
extern int store_swap_high; /* 0 */
extern int store_pages_max; /* 0 */
/*
- * $Id: protos.h,v 1.374 2000/06/26 04:57:16 wessels Exp $
+ * $Id: protos.h,v 1.375 2000/06/27 08:41:30 hno Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
extern void storeFsInit(void);
extern void storeFsDone(void);
extern void storeFsAdd(char *, STSETUP *);
+extern void storeReplAdd(char *, REMOVALPOLICYCREATE *);
/* store_modules.c */
extern void storeFsSetup(void);
+/* repl_modules.c */
+extern void storeReplSetup(void);
+
/* store_io.c */
extern storeIOState *storeCreate(StoreEntry *, STFNCB *, STIOCB *, void *);
extern storeIOState *storeOpen(StoreEntry *, STFNCB *, STIOCB *, void *);
#!/bin/sh
-
-# NOTE: echo '\n' is not portable. Some shells interpret and
-# change it to an actual newline character. The ugly hack here
-# is to use two echo commands:
-# echo -n 'blah\'
-# echo 'n'
-# This is probably more portable in Perl.
-
-echo "/* automatically generated `date` by"
-echo " * $0 $*"
-echo ' * do not edit'
-echo ' */'
-echo '#include "squid.h"'
-echo ''
+echo "/* automatically generated by $0 $*"
+echo " * do not edit"
+echo " */"
+echo "#include \"squid.h\""
+echo ""
for module in "$@"; do
- echo "REMOVALPOLICYCREATE createRemovalPolicy_${module};"
+ echo "extern REMOVALPOLICYCREATE createRemovalPolicy_${module};"
done
-echo ''
-echo 'RemovalPolicy *'
-echo 'createRemovalPolicy(RemovalPolicySettings *settings)'
-echo '{'
+echo "void storeReplSetup(void)"
+echo "{"
for module in "$@"; do
- echo " if (strcmp(settings->type, \"${module}\") == 0)"
- echo " return createRemovalPolicy_${module}(settings->args);"
+ echo " storeReplAdd(\"$module\", createRemovalPolicy_${module});"
done
- echo -n ' debug(20, 1) ("Unknown policy %s\'
- echo 'n", settings->type);'
- echo ' return NULL;'
-echo '}'
+echo "}"
/*
- * $Id: store.cc,v 1.527 2000/06/26 04:57:16 wessels Exp $
+ * $Id: store.cc,v 1.528 2000/06/27 08:41:30 hno Exp $
*
* DEBUG: section 20 Storage Manager
* AUTHOR: Harvest Derived
void
storeFsInit(void)
{
+ storeReplSetup();
storeFsSetup();
}
setup(&storefs_list[i]);
}
+/*
+ * called to add another store removal policy module
+ */
+void
+storeReplAdd(char *type, REMOVALPOLICYCREATE * create)
+{
+ int i;
+ /* find the number of currently known repl types */
+ for (i = 0; storerepl_list && storerepl_list[i].typestr; i++) {
+ assert(strcmp(storerepl_list[i].typestr, type) != 0);
+ }
+ /* add the new type */
+ storerepl_list = xrealloc(storerepl_list, (i + 2) * sizeof(storerepl_entry_t));
+ memset(&storerepl_list[i + 1], 0, sizeof(storerepl_entry_t));
+ storerepl_list[i].typestr = type;
+ storerepl_list[i].create = create;
+}
+
+/*
+ * Create a removal policy instance
+ */
+RemovalPolicy *
+createRemovalPolicy(RemovalPolicySettings * settings)
+{
+ storerepl_entry_t *r;
+ for (r = storerepl_list; r && r->typestr; r++) {
+ if (strcmp(r->typestr, settings->type) == 0)
+ return r->create(settings->args);
+ }
+ debug(20,1)("Unknown policy %s\n", settings->type);
+ return NULL;
+}
+
#if 0
void
storeSwapFileNumberSet(StoreEntry * e, sfileno filn)
/*
- * $Id: structs.h,v 1.345 2000/06/26 05:11:13 wessels Exp $
+ * $Id: structs.h,v 1.346 2000/06/27 08:41:31 hno Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
STFSSHUTDOWN *donefunc;
};
+/*
+ * This defines an repl type
+ */
+
+struct _storerepl_entry {
+ char *typestr;
+ REMOVALPOLICYCREATE *create;
+};
+
/*
* Async disk IO - this defines a async disk io queue
*/
/*
- * $Id: typedefs.h,v 1.106 2000/06/26 04:57:17 wessels Exp $
+ * $Id: typedefs.h,v 1.107 2000/06/27 08:41:31 hno Exp $
*
*
* SQUID Internet Object Cache http://squid.nlanr.net/Squid/
typedef struct _storeIOState storeIOState;
typedef struct _link_list link_list;
typedef struct _storefs_entry storefs_entry_t;
+typedef struct _storerepl_entry storerepl_entry_t;
typedef struct _diskd_queue diskd_queue;
typedef struct _Logfile Logfile;
typedef struct _RemovalPolicy RemovalPolicy;