[Pkg-privacy-commits] [irssi-plugin-otr] 100/267: Move core around and put logging in utils
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 12:26:22 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository irssi-plugin-otr.
commit 349632b5e002e7637367c2ed02511829664d3051
Author: David Goulet <dgoulet at ev0ke.net>
Date: Sat Nov 3 18:10:03 2012 -0400
Move core around and put logging in utils
Signed-off-by: David Goulet <dgoulet at ev0ke.net>
---
src/module.c | 64 +++++++++++++++--------------------------------------------
src/otr-ops.c | 1 -
src/otr.h | 14 +------------
src/utils.c | 31 +++++++++++++++++++++++++++++
src/utils.h | 13 ++++++++++++
5 files changed, 61 insertions(+), 62 deletions(-)
diff --git a/src/module.c b/src/module.c
index 1f85301..946db8a 100644
--- a/src/module.c
+++ b/src/module.c
@@ -23,11 +23,6 @@
#include "otr.h"
#include "utils.h"
-static const char *lvlstring[] = {
- "NOTICE",
- "DEBUG"
-};
-
static const char *signal_args_otr_event[] = {
"iobject", "string", "string", "NULL" };
@@ -43,12 +38,6 @@ void perl_signal_register(const char *signal, const char **args);
static IOUSTATE *ioustate;
-void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg)
-{
- ircctx->send_message(ircctx, recipient, msg,
- GPOINTER_TO_INT(SEND_TARGET_NICK));
-}
-
/*
* Pipes all outgoing private messages through OTR
*/
@@ -180,16 +169,6 @@ static void otr_statusbar(struct SBAR_ITEM_REC *item, int get_size_only)
formatnum ? formats[formatnum].def : "", " ", FALSE);
}
-void otr_query_create(SERVER_REC *server, const char *nick)
-{
- if (!server || !nick || !settings_get_bool("otr_createqueries") ||
- query_find(server, nick)) {
- return;
- }
-
- irc_query_create(server->tag, nick, TRUE);
-}
-
static void read_settings(void)
{
otr_setpolicies(ioustate, settings_get_str("otr_policy"), FALSE);
@@ -204,6 +183,22 @@ static void read_settings(void)
#endif
}
+void irc_send_message(IRC_CTX *ircctx, const char *recipient, char *msg)
+{
+ ircctx->send_message(ircctx, recipient, msg,
+ GPOINTER_TO_INT(SEND_TARGET_NICK));
+}
+
+void otr_query_create(SERVER_REC *server, const char *nick)
+{
+ if (!server || !nick || !settings_get_bool("otr_createqueries") ||
+ query_find(server, nick)) {
+ return;
+ }
+
+ irc_query_create(server->tag, nick, TRUE);
+}
+
/*
* irssi init()
*/
@@ -303,30 +298,3 @@ IRC_CTX *ircctx_by_peername(const char *peername, char *nick)
error:
return NULL;
}
-
-void otr_log(IRC_CTX *server, const char *nick, int level,
- const char *format, ...)
-{
- va_list params;
- va_start( params, format );
- char msg[LOGMAX], *s = msg;
-
- if ((level == LVL_DEBUG) && !debug) {
- return;
- }
-
- s += sprintf(s, "%s", "%9OTR%9");
-
- if (level != LVL_NOTICE) {
- s += sprintf(s, "(%s)", lvlstring[level]);
- }
-
- s += sprintf(s, ": ");
-
- if (vsnprintf(s, LOGMAX, format, params ) < 0) {
- sprintf(s, "internal error parsing error string (BUG)");
- }
- va_end(params);
-
- printtext(server, nick, MSGLEVEL_MSGS, msg);
-}
diff --git a/src/otr-ops.c b/src/otr-ops.c
index 436113e..5a002b4 100644
--- a/src/otr-ops.c
+++ b/src/otr-ops.c
@@ -38,7 +38,6 @@ static const char *otr_msg_event_txt[] = {
"RCVDMSG_FOR_OTHER_INSTANCE"
};
-
OtrlPolicy IO_DEFAULT_OTR_POLICY =
OTRL_POLICY_MANUAL | OTRL_POLICY_WHITESPACE_START_AKE;
diff --git a/src/otr.h b/src/otr.h
index 40b87d2..79c2aa4 100644
--- a/src/otr.h
+++ b/src/otr.h
@@ -38,6 +38,7 @@
#include <glib/gstdio.h>
#include "irssi_otr.h"
+#include "utils.h"
extern OtrlMessageAppOps otr_ops;
@@ -54,19 +55,6 @@ typedef struct {
extern IOUSTATE ioustate_uniq;
#endif
-/* log stuff */
-
-#define LOGMAX 1024
-
-#define LVL_NOTICE 0
-#define LVL_DEBUG 1
-
-#define otr_logst(level, format, ...) \
- otr_log(NULL, NULL, level, format, ## __VA_ARGS__)
-
-void otr_log(IRC_CTX *server, const char *to,
- int level, const char *format, ...);
-
/* own */
#include "io-config.h"
diff --git a/src/utils.c b/src/utils.c
index bf543cb..c397975 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -23,6 +23,11 @@
#include "otr.h"
#include "utils.h"
+static const char *lvlstring[] = {
+ "NOTICE",
+ "DEBUG"
+};
+
void utils_io_explode_args(const char *args, char ***argvp, char ***argv_eolp,
int *argcp)
{
@@ -56,3 +61,29 @@ void utils_io_explode_args(const char *args, char ***argvp, char ***argv_eolp,
*argv_eolp = argv_eol;
*argcp = argc;
}
+
+void otr_log(IRC_CTX *server, const char *nick, int lvl, const char *fmt, ...)
+{
+ va_list params;
+ va_start(params, fmt);
+ char msg[LOGMAX], *s = msg;
+
+ if ((lvl == LVL_DEBUG) && !debug) {
+ return;
+ }
+
+ s += sprintf(s, "%s", "%9OTR%9");
+
+ if (lvl != LVL_NOTICE) {
+ s += sprintf(s, "(%s)", lvlstring[lvl]);
+ }
+
+ s += sprintf(s, ": ");
+
+ if (vsnprintf(s, LOGMAX, fmt, params ) < 0) {
+ sprintf(s, "internal error parsing error string (BUG)");
+ }
+ va_end(params);
+
+ printtext(server, nick, MSGLEVEL_MSGS, msg);
+}
diff --git a/src/utils.h b/src/utils.h
index 76830cc..978e340 100644
--- a/src/utils.h
+++ b/src/utils.h
@@ -21,6 +21,19 @@
#ifndef IRSSI_OTR_UTILS_H
#define IRSSI_OTR_UTILS_H
+/*
+ * Max size of a log message.
+ */
+#define LOGMAX 1024
+
+#define LVL_NOTICE 0
+#define LVL_DEBUG 1
+
+#define otr_logst(level, fmt, ...) \
+ otr_log(NULL, NULL, level, fmt, ## __VA_ARGS__)
+
+void otr_log(IRC_CTX *server, const char *to, int lvl, const char *fmt, ...);
+
void utils_io_explode_args(const char *args, char ***argvp, char ***argv_eolp,
int *argcp);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/irssi-plugin-otr.git
More information about the Pkg-privacy-commits
mailing list