remove unused plugins
[opsoft.git] / silentbob / plugins / plugin_ruby_newclass.cxx
blob97d2eafb9ad46cf154b1d2c78c966c6d20ee13a7
1 /*
2 * (c) Oleg Puchinin 2008
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 void ruby_create_class (int pos)
22 char * className;
23 char * S;
24 int size;
26 ++pos;
27 className = ENV->d_opts->get (pos);
28 if (! className)
29 return;
31 printf ("class %s\n\n", className);
32 printf ("\tdef initialize\n\tend\n\n");
34 ++pos;
35 size = ENV->d_opts->get_size ();
36 for (; pos < size; ++pos) {
37 S = ENV->d_opts->get (pos);
38 printf ("\tdef %s\n", S);
39 printf ("\tend\n\n");
41 printf ("end\n\n");
44 char ruby_opt (DArray * d_opts, int * pos)
46 if (! d_opts || ! pos)
47 return 0;
49 if (EQ (ENV->language, "Ruby") && (EQ(d_opts->get (*pos), "--new-class")
50 || EQ(d_opts->get (*pos), "-nc"))) {
51 ruby_create_class (*pos);
52 exit (0);
55 return 0;
58 void ruby_short_info ()
60 printf ("Ruby new class plugin.");
63 void ruby_long_info ()
65 printf ("Ruby new class plugin.\n");
66 printf ("Version: 1.0\n");
67 printf ("options: --ruby --new-class\n");
68 printf ("Usage: bob --ruby --new-class <classname> <class functions>\n");
71 DArray * plugin_init (struct env_t *env)
73 DArray * Ret;
74 mod_t * plug;
76 Ret = new DArray (1);
77 plug = CNEW (mod_t, 1);
78 memset (plug, 0, sizeof (mod_t));
80 plug->Version = strdup ("1.0");
81 plug->short_info = ruby_short_info;
82 plug->long_info = ruby_long_info;
83 plug->opt = ruby_opt;
85 ENV->listOptions->add ("--new-class");
86 ENV->listOptions->add ("-nc");
88 Ret->add (LPCHAR (plug));
89 return Ret;