2 * Test of resource management.
4 * Europagate, 1994-1995.
6 * $Log: gw-res-test.c,v $
7 * Revision 1.3 1995/02/23 08:32:22 adam
10 * Revision 1.1.1.1 1995/02/09 17:27:12 adam
11 * Initial version of email gateway under CVS control.
13 * Initial: Dec 7, 94 (Adam Dickmeiss)
26 static void showf (const char *name, const char *value)
28 printf ("%s: %s\n", name, value);
31 static void interactive (void)
45 if (!(fgets (buffer, sizeof(buffer)-1, stdin)))
47 while ((cp = strchr (buffer, '\n')))
51 no_arg = sscanf (buffer+1, "%s %s %s", arg[0], arg[1], arg[2]);
57 r = gw_res_merge (res, arg[0]);
61 r = gw_res_put (res, arg[0], arg[1], arg[2]);
66 value = gw_res_get (res, arg[0], "<unknown>");
67 printf ("%s has value `%s'\n", arg[0], value);
73 r = gw_res_trav (res, arg[0], showf);
75 r = gw_res_trav (res, NULL, showf);
79 r = gw_res_commit (res, arg[0]);
82 printf ("m <file> merge\n"
84 "p <name> <value> <file> put\n"
94 printf ("syntax, type 'h' for help\n");
96 printf ("returned %d\n", r);
102 static void do_intensive (void)
105 for (i = 0; i<100; i++)
109 res = gw_res_init ();
111 gw_res_merge (res, "big.res");
112 gw_res_merge (res, "default.res");
113 gw_res_merge (res, "adam.res");
115 cp = gw_res_get (res, "loopvar", "0");
116 sprintf (new_val, "%d", atoi(cp)+1);
117 gw_res_put (res, "loopvar", new_val, "big.res");
119 gw_res_commit (res, "big.res");
124 int main (int argc, char **argv)
135 gw_log_level (GW_LOG_ALL);
141 gw_log (GW_LOG_FATAL, "Fatal", "Unknown option %s",
147 gw_log_file (GW_LOG_ALL, "all.log");
149 res = gw_res_init ();