Fixes
[opsoft.git] / silentbob / templates / simple_plugin.cxx
blobf295cf94dad9ce58b0a573af27d2ff2cf23338e2
1 /*
2 * (c) Oleg Puchinin 2007
3 * graycardinalster@gmail.com
5 */
7 #include <stdio.h>
8 #include <stdlib.h>
9 #include <unistd.h>
10 #include <fcntl.h>
11 #include <gclib/gclib.h>
12 #include <gclib/gclib_c.h>
13 #include <mod.h>
14 #include <head.h>
15 #include <dbg.h>
17 extern "C" DArray * plugin_init (struct env_t *env);
18 struct env_t *ENV;
20 char simple_plugin_opt (DArray * d_opts, int * pos)
22 int count;
23 char * S;
25 if (! d_opts || ! pos)
26 return 0;
28 count = d_opts->get_size ();
29 S = d_opts->get (*pos);
30 if (EQ (S, "--simple_plugin")) {
31 if (++(*pos) >= count)
32 return 0; // Missed argument for option "--simple-plugin".
33 // Do somethings.
36 return 0;
39 char simple_plugin_opt2 (DArray * d_opts, int * pos)
41 char * S;
43 if (! d_opts || ! pos)
44 return 0;
46 S = d_opts->get (*pos);
47 if (EQ (S, "--simple_plugin")) {
48 // Do somethings at stage two.
51 return 0;
54 void simple_plugin_short_info ()
56 printf ("Simple plugin.");
59 void simple_plugin_long_info ()
61 printf ("Simple plugin.\n");
62 printf ("Version: 1.0\n");
63 printf ("options: --simple-plugin\n");
66 DArray * plugin_init (struct env_t *env)
68 DArray * Ret;
69 mod_t * plug;
71 Ret = new DArray (1);
72 plug = CNEW (mod_t, 1);
73 memset (plug, 0, sizeof (mod_t));
75 plug->Version = strdup ("1.0");
76 plug->short_info = simple_plugin_short_info;
77 plug->long_info = simple_plugin_long_info;
78 plug->opt = simple_plugin_opt;
79 plug->opt2 = simple_plugin_opt2;
81 Ret->add (LPCHAR (plug));
82 return Ret;