summaryrefslogtreecommitdiff
path: root/src/modules/manager/main.c
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-09-10 19:35:31 +0200
committerAlexis211 <alexis211@gmail.com>2010-09-10 19:35:31 +0200
commita8da6dba7ddc5e3d31a1914597e7b38fbc2d197c (patch)
treefbef80d474e5b9c891e0eb353cfa602acf67fdae /src/modules/manager/main.c
parentaba6ed4b91aff5d914be11704e34de75bfd4d003 (diff)
downloadTCE-a8da6dba7ddc5e3d31a1914597e7b38fbc2d197c.tar.gz
TCE-a8da6dba7ddc5e3d31a1914597e7b38fbc2d197c.zip
Removed all old object/request/... stuff (that was crap)
Diffstat (limited to 'src/modules/manager/main.c')
-rw-r--r--src/modules/manager/main.c109
1 files changed, 0 insertions, 109 deletions
diff --git a/src/modules/manager/main.c b/src/modules/manager/main.c
deleted file mode 100644
index 58d9232..0000000
--- a/src/modules/manager/main.c
+++ /dev/null
@@ -1,109 +0,0 @@
-#include <gc/syscall.h>
-#include <gc/mem.h>
-#include <gc/server.h>
-#include <gm/method.h>
-#include <gm/call/manager.h>
-#include <string.h>
-
-char *loglevels[] = {"Critical", "Error", "Warning", "Notice", "Status", "Debug"};
-int loglevel = LL_DEBUG;
-
-struct service {
- char* name;
- int pid;
- Object obj;
- struct service *next;
-};
-
-struct service *services = 0;
-
-//************************ FUNCTIONS THAT DO STUFF ********************
-void logsvc(int pid, char* log, int level) {
- if (level > loglevel || level < 0) return;
- struct service *svc = services;
- while (svc) {
- if (svc->pid == pid) break;
- svc = svc->next;
- }
- if (svc == 0) {
- printk("[log:??] ");
- } else {
- printk("[log:"); printk(svc->name); printk("] ");
- }
- printk(loglevels[level]); printk(": ");
- printk(log); printk("\n");
-}
-
-void registersvc(int pid, char* name, Object descriptor) {
- struct service *svc = malloc(sizeof(struct service));
- svc->name = strdup(name);
- svc->pid = pid;
- svc->obj = descriptor;
- svc->next = services;
- services = svc;
- char msg[100] = "Service registered: ";
- strcat(msg, svc->name);
- logsvc(1, msg, LL_NOTICE);
-}
-
-//****************************** HANDLING METHODS ON MAIN OBJECT *****************
-struct method_ret handle_nothing(struct method_data *d) {
- if (d->blocking) logsvc(1, "Received a {nothing} request.", LL_DEBUG);
- else logsvc(1, "Received a {nothing} message.", LL_DEBUG);
- return mr_void();
-}
-
-struct method_ret handle_open(struct method_data *d) {
- CHKSSTR(d, 0);
- char *svc = d->parameters[0].p;
- char *sep, *res;
- sep = strchr(svc, ':');
- if (sep != 0) *sep = '0';
- struct service *s = services;
- while (s) {
- if (strcmp(s->name, svc) == 0) break;
- s = s->next;
- }
- if (s == 0) return mr_err(-2);
- if (sep == 0) {
- return mr_obj(s->obj);
- } else {
- *sep = ':';
- res = sep + 1;
- // open service svc, ressource res
- Object r = c_open(s->obj, 1, res);
- if (r == -1) return mr_err(-3);
- return mr_obj(r);
- }
-}
-
-struct method_ret handle_registersvc(struct method_data *d) {
- CHKSSTR(d, 0);
- if (d->parameters[1].i == 0) return mr_err(-1);
- registersvc(d->pid, d->parameters[0].p, d->parameters[1].i);
- return mr_void();
-}
-
-struct method_ret handle_logsvc(struct method_data *d) {
- CHKSSTR(d, 0);
- logsvc(d->pid, d->parameters[0].p, d->parameters[1].i);
- return mr_void();
-}
-
-int main() {
- logsvc(1, "Manager module configuring...", LL_NOTICE);
- registersvc(1, "manager", 0);
-
- Server *mgr = srv_get(0);
- srv_addHandler(mgr, M_NOTHING_VVVV, handle_nothing);
-
- srv_addHandler(mgr, M_OPEN_OMVV, handle_open);
- srv_addHandler(mgr, M_REGISTERSVC_VMOV, handle_registersvc);
- srv_addHandler(mgr, M_LOGSVC_VMIV, handle_logsvc);
-
- logsvc(1, "Manager module configured : starting request handling.", LL_STATUS);
- srv_handle(mgr, HA_LOOP);
-
- printk("[manager] Manager EPIC FAIL.\n");
- return 0;
-}