From 19b2eda70e02329fcd0ab7a05968711faa539837 Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Sat, 9 May 2015 06:11:36 +0200
Subject: degesch: more shuffling
---
degesch.c | 80 +++++++++++++++++++++++++++++++++++----------------------------
1 file changed, 44 insertions(+), 36 deletions(-)
diff --git a/degesch.c b/degesch.c
index 41bffb7..f4e1a81 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2459,36 +2459,6 @@ static bool irc_connect (struct server *s, bool *should_retry, struct error **);
static void irc_cancel_timers (struct server *s);
static void on_irc_reconnect_timeout (void *user_data);
-static char *
-irc_cut_nickname (const char *prefix)
-{
- return xstrndup (prefix, strcspn (prefix, "!@"));
-}
-
-static const char *
-irc_find_userhost (const char *prefix)
-{
- const char *p = strchr (prefix, '!');
- return p ? p + 1 : NULL;
-}
-
-static bool
-irc_is_this_us (struct server *s, const char *prefix)
-{
- char *nick = irc_cut_nickname (prefix);
- bool result = !irc_strcmp (nick, s->irc_user->nickname);
- free (nick);
- return result;
-}
-
-static bool
-irc_is_channel (struct server *s, const char *ident)
-{
- (void) s; // TODO: parse prefixes from server features
-
- return *ident && !!strchr ("#&+!", *ident);
-}
-
static bool
irc_is_connected (struct server *s)
{
@@ -2866,10 +2836,39 @@ refresh_prompt (struct app_context *ctx)
str_free (&prompt);
}
-// --- Input handling ----------------------------------------------------------
+// --- Helpers -----------------------------------------------------------------
-// TODO: we will need a proper mode parser; to be shared with kike
-// TODO: we alse definitely need to parse server capability messages
+static char *
+irc_cut_nickname (const char *prefix)
+{
+ return xstrndup (prefix, strcspn (prefix, "!@"));
+}
+
+static const char *
+irc_find_userhost (const char *prefix)
+{
+ const char *p = strchr (prefix, '!');
+ return p ? p + 1 : NULL;
+}
+
+static bool
+irc_is_this_us (struct server *s, const char *prefix)
+{
+ char *nick = irc_cut_nickname (prefix);
+ bool result = !irc_strcmp (nick, s->irc_user->nickname);
+ free (nick);
+ return result;
+}
+
+static bool
+irc_is_channel (struct server *s, const char *ident)
+{
+ (void) s; // TODO: parse prefixes from server features
+
+ return *ident && !!strchr ("#&+!", *ident);
+}
+
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
static struct buffer *
irc_get_buffer_for_message (struct server *s,
@@ -2933,7 +2932,10 @@ irc_is_highlight (struct server *s, const char *message)
return result;
}
-// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+// --- Input handling ----------------------------------------------------------
+
+// TODO: we will need a proper mode parser; to be shared with kike
+// TODO: we alse definitely need to parse server capability messages
static void
irc_handle_join (struct server *s, const struct irc_message *msg)
@@ -3422,6 +3424,8 @@ irc_handle_topic (struct server *s, const struct irc_message *msg)
}
}
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
static struct irc_handler
{
char *name;
@@ -3923,8 +3927,6 @@ dump_matching_options
// --- User input handling -----------------------------------------------------
-static bool handle_command_help (struct app_context *, char *);
-
/// Cuts the longest non-whitespace portion of text and advances the pointer
static char *
cut_word (char **s)
@@ -4468,6 +4470,10 @@ handle_command_quote (struct app_context *ctx, char *arguments)
return true;
}
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+static bool handle_command_help (struct app_context *, char *);
+
static struct command_handler
{
const char *name;
@@ -4663,6 +4669,8 @@ process_user_command (struct app_context *ctx, char *command)
"%s: /%s %s", "Usage", handler->name, handler->usage);
}
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
static void
send_message_to_target (struct server *s,
const char *target, char *message, struct buffer *buffer)
--
cgit v1.2.3-70-g09d2