summaryrefslogtreecommitdiff
path: root/doc/de/plugins.de.xml
blob: 56f39eb204d4ae47e2bf9ea2dbdf86406c1c9d02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<?xml version="1.0" encoding="iso-8859-1"?>

<!--

WeeChat documentation (german version)

Copyright (c) 2003-2008 by FlashCode <flashcode@flashtux.org>

This manual is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.

This manual is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

-->

<chapter id="chapPlugins">
  <title>Plugins</title>
  
  <para>
    Dieses Kapitel beschreibt das Plugin-Interface (API) in WeeChat und die
    Standard-Skriptplugins (Perl, Python, Ruby, Lua), die zu WeeChat gehören.
  </para>
  
  <section id="secPluginsInWeeChat">
    <title>Plugins in WeeChat</title>
    
    <para>
      Ein Plugin ist ein C-Programm, dass WeeChat-Funktionen aufrufen kann,
      die in einem Interface definiert sind.
    </para>
    
    <para>
      Dieses C-Programm braucht nicht den Quellcode von WeeChat (aber die 
      API-Beschreibung) und kann dynamisch mit dem folgenden Kommando in 
      WeeChat geladen werden
      <command>/plugin</command>.
    </para>
    
    <para>
      Das Plugin muss in Form einer dynamischen Bibliothek vorliegen, 
      damit es das Betriebssystem dynamisch laden kann.
      Unter GNU/Linux besitzt die Datei die Endung ".so", unter
      Windows ".dll".
    </para>
    
  </section>
  
  <section id="secWriteAPlugin">
    <title>Ein Plugin schreiben</title>
    
    <para>
      Das Plugin muss die Datei "weechat-plugin.h" einbinden (verfügbar 
      im WeeChat-Quellcode).
      Diese Datei definiert die Strukturen und Typen um mit WeeChat
      zu kommunizieren.
    </para>
    
    <para>
      Das Plugin muss einige Variablen und Funktionen besitzen
      (nötig, sonst kann das Plugin nicht geladen werden):
      <informaltable colsep="0" frame="none">
        <tgroup cols="2">
          <thead>
            <row>
              <entry>Variable</entry>
              <entry>Beschreibung</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry><literal>char plugin_name[]</literal></entry>
              <entry>Plugin Name</entry>
            </row>
            <row>
              <entry><literal>char plugin_version[]</literal></entry>
              <entry>Plugin Version</entry>
            </row>
            <row>
              <entry><literal>char plugin_description[]</literal></entry>
              <entry>kurze Beschreibung des Plugins</entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>
      
      <informaltable colsep="0" frame="none">
        <tgroup cols="2">
          <thead>
            <row>
              <entry>Funktion</entry>
              <entry>Beschreibung</entry>
            </row>
          </thead>
          <tbody>
            <row>
              <entry><literal>int weechat_plugin_init (t_weechat_plugin *plugin)</literal></entry>
              <entry>
                Die Funktion wird aufgerufen, wenn das Plugin geladen wird.
                Sie muss bei Erfolg PLUGIN_RC_OK, bei Fehlschlag PLUGIN_RC_KO
                zurückgeben. (Bei einem Fehler wird das Plugin nicht geladen)
              </entry>
            </row>
            <row>
              <entry><literal>void weechat_plugin_end (t_weechat_plugin *plugin)</literal></entry>
              <entry>Funktion wird beim Abschalten aufgerufen</entry>
            </row>
          </tbody>
        </tgroup>
      </informaltable>
    </para>
    
    &plugin_api.de.xml;
    
    <section id="secCompilePlugin">
      <title>Übersetzen eines Plugins</title>
      
      <para>
        Das Übersetzen braucht keine WeeChat-Quellen, aber die Datei "<literal>weechat-plugin.h</literal>".
      </para>
      
      <para>
        Um ein Plugin zu übersetzen, das aus einer Datei "toto.c" besteht
        (unter GNU/Linux):
<screen>
<prompt>$ </prompt><userinput>gcc -fPIC -Wall -c toto.c</userinput>
<prompt>$ </prompt><userinput>gcc -shared -fPIC -o libtoto.so toto.o</userinput>
</screen>
      </para>
      
    </section>
    
    <section id="secLoadPlugin">
      <title>Laden des Plugins in WeeChat</title>
      
      <para>
        Kopiere die Datei "libtoto.so" in das Plugin-Verzeichnis der
        systemweiten Dateien WeeChats (zum Beispiel:
        "<literal>/usr/local/lib/weechat/plugins</literal>") oder in das
        Plugin-Verzeichnis des Users (zum Beispiel:
        "<literal>/home/xxxxx/.weechat/plugins</literal>").
      </para>
      
      <para>
        In WeeChat:
        <screen><userinput>/plugin load toto</userinput></screen>
      </para>
      
    </section>
    
    <section id="secPluginExample">
      <title>Plugin Beispiel</title>
      
      <para>
        Vollständiges Beispiel eines Plugins, welches das Kommando /double
        implementiert, dass seine Argumente im gegenwärtigen Channel doppelt
        ausgibt (ok, das ist weniger nützlich, aber auch nur ein Beispiel!):
<screen>
#include &lt;stdlib.h&gt;

#include "weechat-plugin.h"

char plugin_name[]        = "Double";
char plugin_version[]     = "0.1";
char plugin_description[] = "Test plugin for WeeChat";

/* "/double" command manager */

int double_cmd (t_weechat_plugin *plugin, int argc, char **argv,
                char *handler_args, void *handler_pointer)
{
    if (argv[2] &amp;&amp; (argv[2][0] != '/'))
    {
        plugin->exec_command (plugin, NULL, NULL, argv[2]);
        plugin->exec_command (plugin, NULL, NULL, argv[2]);
    }
    return PLUGIN_RC_OK;
}

int weechat_plugin_init (t_weechat_plugin *plugin)
{
    plugin->cmd_handler_add (plugin, "double",
                             "Display two times a message",
                             "msg",
                             "msg: message to display two times",
                             NULL,
                             &amp;double_cmd,
                             NULL, NULL);
    return PLUGIN_RC_OK;
}

void weechat_plugin_end (t_weechat_plugin *plugin)
{
    /* nothing done here */
}
</screen>
      </para>
      
    </section>
    
  </section>
  
  &plugin_charset.de.xml;
  
  &plugin_scripts.de.xml;
  
</chapter>