~alivema4ever/ubuntu/trusty/weechat/lp-1299347-fix

« back to all changes in this revision

Viewing changes to src/plugins/plugin-api.c

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bouthenot
  • Date: 2013-01-23 18:44:36 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20130123184436-pillcj7jmtyyj00j
Tags: 0.4.0-1
* New upstream release.
* Bump Standards-Version to 3.9.4
* Remove UPGRADE_0.3 from doc (no more included in upstream sources).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2003-2012 Sebastien Helleu <flashcode@flashtux.org>
 
2
 * plugin-api.c - extra functions for plugin API
 
3
 *
 
4
 * Copyright (C) 2003-2013 Sebastien Helleu <flashcode@flashtux.org>
3
5
 *
4
6
 * This file is part of WeeChat, the extensible chat client.
5
7
 *
17
19
 * along with WeeChat.  If not, see <http://www.gnu.org/licenses/>.
18
20
 */
19
21
 
20
 
/*
21
 
 * plugin-api.c: extra functions for plugin API
22
 
 */
23
 
 
24
22
#ifdef HAVE_CONFIG_H
25
23
#include "config.h"
26
24
#endif
45
43
#include "../core/wee-string.h"
46
44
#include "../core/wee-url.h"
47
45
#include "../core/wee-util.h"
 
46
#include "../core/wee-version.h"
48
47
#include "../gui/gui-bar.h"
49
48
#include "../gui/gui-bar-item.h"
50
49
#include "../gui/gui-bar-window.h"
66
65
 
67
66
 
68
67
/*
69
 
 * plugin_api_charset_set: set plugin charset
 
68
 * Sets plugin charset.
70
69
 */
71
70
 
72
71
void
82
81
}
83
82
 
84
83
/*
85
 
 * plugin_api_gettext: translate a string using gettext
 
84
 * Translates a string using gettext.
86
85
 */
87
86
 
88
87
const char *
92
91
}
93
92
 
94
93
/*
95
 
 * plugin_api_ngettext: translate a string using gettext
 
94
 * Translates a string using gettext (with plural form).
96
95
 */
97
96
 
98
97
const char *
106
105
}
107
106
 
108
107
/*
109
 
 * plugin_api_config_get: get value of an option
 
108
 * Gets pointer on an option.
110
109
 */
111
110
 
112
111
struct t_config_option *
120
119
}
121
120
 
122
121
/*
123
 
 * plugin_api_config_get_plugin: get value of a plugin config option
 
122
 * Gets value of a plugin option.
124
123
 */
125
124
 
126
125
const char *
141
140
}
142
141
 
143
142
/*
144
 
 * plugin_api_config_is_set_plugin: return 1 if plugin option is set, otherwise 0
 
143
 * Checks if a plugin option is set.
 
144
 *
 
145
 * Returns:
 
146
 *   1: plugin option is set
 
147
 *   0: plugin option does not exist
145
148
 */
146
149
 
147
150
int
161
164
}
162
165
 
163
166
/*
164
 
 * plugin_api_config_set_plugin: set value of a plugin config option
 
167
 * Sets value of a plugin option.
165
168
 */
166
169
 
167
170
int
175
178
}
176
179
 
177
180
/*
178
 
 * plugin_api_config_set_desc_plugin: set description of a plugin config option
 
181
 * Sets description of a plugin option.
179
182
 */
180
183
 
181
184
void
188
191
}
189
192
 
190
193
/*
191
 
 * plugin_api_config_unset_plugin: unset plugin config option
 
194
 * Unsets a plugin option.
192
195
 */
193
196
 
194
197
int
208
211
}
209
212
 
210
213
/*
211
 
 * plugin_api_prefix: return a prefix for display with printf
 
214
 * Returns a prefix for display with printf.
212
215
 */
213
216
 
214
217
const char *
232
235
}
233
236
 
234
237
/*
235
 
 * plugin_api_color: return a WeeChat color for display with printf
 
238
 * Returns a WeeChat color for display with printf.
236
239
 */
237
240
 
238
241
const char *
252
255
}
253
256
 
254
257
/*
255
 
 * plugin_api_command: execute a command (simulate user entry)
 
258
 * Executes a command on a buffer (simulates user entry).
256
259
 */
257
260
 
258
261
void
273
276
}
274
277
 
275
278
/*
276
 
 * plugin_api_info_get_inernal: get info about WeeChat
 
279
 * Gets info about WeeChat.
277
280
 */
278
281
 
279
282
const char *
293
296
 
294
297
    if (string_strcasecmp (info_name, "version") == 0)
295
298
    {
296
 
        return PACKAGE_VERSION;
 
299
        return version_get_version ();
297
300
    }
298
301
    else if (string_strcasecmp (info_name, "version_number") == 0)
299
302
    {
300
303
        if (!version_number[0])
301
304
        {
302
305
            snprintf (version_number, sizeof (version_number), "%d",
303
 
                      util_version_number (PACKAGE_VERSION));
 
306
                      util_version_number (version_get_version ()));
304
307
        }
305
308
        return version_number;
306
309
    }
 
310
    else if (string_strcasecmp (info_name, "version_git") == 0)
 
311
    {
 
312
        return version_get_git ();
 
313
    }
307
314
    else if (string_strcasecmp (info_name, "date") == 0)
308
315
    {
309
 
        return __DATE__;
 
316
        return version_get_compilation_date ();
310
317
    }
311
318
    else if (string_strcasecmp (info_name, "dir_separator") == 0)
312
319
    {
384
391
}
385
392
 
386
393
/*
387
 
 * plugin_api_infolist_get_internal: get list with infos about WeeChat structures
388
 
 *                                   WARNING: caller has to free string returned
389
 
 *                                            by this function after use, with
390
 
 *                                            weechat_infolist_free()
 
394
 * Gets infolist about WeeChat.
 
395
 *
 
396
 * Note: result must be freed with function "weechat_infolist_free".
391
397
 */
392
398
 
393
399
struct t_infolist *
641
647
        if (ptr_infolist)
642
648
        {
643
649
            for (ptr_history = (pointer) ?
644
 
                     ((struct t_gui_buffer *)pointer)->history : history_global;
 
650
                     ((struct t_gui_buffer *)pointer)->history : gui_history;
645
651
                 ptr_history; ptr_history = ptr_history->next_history)
646
652
            {
647
653
                if (!gui_history_add_to_infolist (ptr_infolist, ptr_history))
872
878
}
873
879
 
874
880
/*
875
 
 * plugin_api_infolist_next: move item pointer to next item in a list
876
 
 *                           return 1 if pointer is still ok
877
 
 *                                  0 if end of list was reached
 
881
 * Moves item pointer to next item in an infolist.
 
882
 *
 
883
 * Returns:
 
884
 *   1: pointer is still OK
 
885
 *   0: end of infolist was reached
878
886
 */
879
887
 
880
888
int
887
895
}
888
896
 
889
897
/*
890
 
 * plugin_api_infolist_prev: move item pointer to previous item in a list
891
 
 *                           return 1 if pointer is still ok
892
 
 *                                  0 if beginning of list was reached
 
898
 * Moves pointer to previous item in an infolist.
 
899
 *
 
900
 * Returns:
 
901
 *   1: pointer is still OK
 
902
 *   0: beginning of infolist was reached
893
903
 */
894
904
 
895
905
int
902
912
}
903
913
 
904
914
/*
905
 
 * plugin_api_infolist_reset_item_cursor: reset item cursor in infolist
 
915
 * Resets item cursor in infolist.
906
916
 */
907
917
 
908
918
void
915
925
}
916
926
 
917
927
/*
918
 
 * plugin_api_infolist_fields: get list of fields for current list item
 
928
 * Gets list of fields for current infolist item.
919
929
 */
920
930
 
921
931
const char *
928
938
}
929
939
 
930
940
/*
931
 
 * plugin_api_infolist_integer: get an integer variable value in current list item
 
941
 * Gets integer value for a variable in current infolist item.
932
942
 */
933
943
 
934
944
int
941
951
}
942
952
 
943
953
/*
944
 
 * plugin_api_infolist_string: get a string variable value in current list item
 
954
 * Gets string value for a variable in current infolist item.
945
955
 */
946
956
 
947
957
const char *
954
964
}
955
965
 
956
966
/*
957
 
 * plugin_api_infolist_pointer: get a pointer variable value in current list item
 
967
 * Gets pointer value for a variable in current infolist item.
958
968
 */
959
969
 
960
970
void *
967
977
}
968
978
 
969
979
/*
970
 
 * plugin_api_infolist_buffer: get a buffer variable value in current list item
 
980
 * Gets buffer value for a variable in current infolist item.
 
981
 *
 
982
 * Argument "size" is set with the size of buffer.
971
983
 */
972
984
 
973
985
void *
981
993
}
982
994
 
983
995
/*
984
 
 * plugin_api_infolist_time: get a time variable value in current list item
 
996
 * Gets time value for a variable in current infolist item.
985
997
 */
986
998
 
987
999
time_t
994
1006
}
995
1007
 
996
1008
/*
997
 
 * plugin_api_infolist_free: free an infolist
 
1009
 * Frees an infolist.
998
1010
 */
999
1011
 
1000
1012
void
1005
1017
}
1006
1018
 
1007
1019
/*
1008
 
 * plugin_api_init: init plugin API
 
1020
 * Initializes plugin API.
1009
1021
 */
1010
1022
 
1011
1023
void
1016
1028
               &plugin_api_info_get_internal, NULL);
1017
1029
    hook_info (NULL, "version_number", N_("WeeChat version (as number)"), NULL,
1018
1030
               &plugin_api_info_get_internal, NULL);
 
1031
    hook_info (NULL, "version_git", N_("WeeChat git version (output of "
 
1032
                                       "command \"git describe\" for a "
 
1033
                                       "development version only, empty for a "
 
1034
                                       "stable release)"), NULL,
 
1035
               &plugin_api_info_get_internal, NULL);
1019
1036
    hook_info (NULL, "date", N_("WeeChat compilation date"), NULL,
1020
1037
               &plugin_api_info_get_internal, NULL);
1021
1038
    hook_info (NULL, "dir_separator", N_("directory separator"), NULL,