Rework client message generation to messaging_message_client(()
git-svn-id: http://repo.ham.fi/svn/aprsc/trunk@785 3ce903b1-3385-4e86-93cd-f9a4a239f7ac
This commit is contained in:
parent
463f4ebafb
commit
f20fe045bc
|
|
@ -2436,7 +2436,6 @@ static int filter_command_reply(struct worker_t *self, struct client_t *c, int i
|
|||
{
|
||||
va_list args;
|
||||
char s[PACKETLEN_MAX];
|
||||
char msgid[5];
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(s, PACKETLEN_MAX, fmt, args);
|
||||
|
|
@ -2445,10 +2444,7 @@ static int filter_command_reply(struct worker_t *self, struct client_t *c, int i
|
|||
if (!in_message)
|
||||
return client_printf(self, c, "# %s\r\n", s);
|
||||
|
||||
messaging_generate_msgid(msgid, sizeof(msgid));
|
||||
|
||||
return client_printf(self, c, "SERVER>" APRSC_TOCALL ",TCPIP*,qAZ,%s::%-9s:%s{%s\r\n",
|
||||
serverid, c->username, s, msgid);
|
||||
return messaging_message_client(self, c, "%s", s);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -418,7 +418,6 @@ static int digi_path_drop(char *via_start, char *path_end)
|
|||
static int incoming_server_message(struct worker_t *self, struct client_t *c, struct pbuf_t *pb)
|
||||
{
|
||||
struct aprs_message_t am;
|
||||
char msgid[5];
|
||||
|
||||
int e;
|
||||
if ((e = parse_aprs_message(pb, &am))) {
|
||||
|
|
@ -445,15 +444,11 @@ static int incoming_server_message(struct worker_t *self, struct client_t *c, st
|
|||
if (strncasecmp(am.body, "filter ", 7) == 0) {
|
||||
return filter_commands(self, c, 1, am.body, am.body_len);
|
||||
} else if (strncasecmp(am.body, "filter?", 7) == 0) {
|
||||
messaging_generate_msgid(msgid, sizeof(msgid));
|
||||
return client_printf(self, c, "SERVER>" APRSC_TOCALL ",TCPIP*,qAZ,%s::%-9s:filter %s active{%s\r\n",
|
||||
serverid, c->username, c->filter_s, msgid);
|
||||
return messaging_message_client(self, c, "filter %s active", c->filter_s);
|
||||
}
|
||||
|
||||
/* unknown command */
|
||||
messaging_generate_msgid(msgid, sizeof(msgid));
|
||||
return client_printf(self, c, "SERVER>" APRSC_TOCALL ",TCPIP*,qAZ,%s::%-9.*s:Unknown command{%s\r\n",
|
||||
serverid, pb->srcname_len, pb->srcname, msgid);
|
||||
return messaging_message_client(self, c, "Unknown command");
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "messaging.h"
|
||||
#include "version.h"
|
||||
|
|
@ -39,3 +41,23 @@ int messaging_ack(struct worker_t *self, struct client_t *c, struct pbuf_t *pb,
|
|||
serverid, pb->srcname_len, pb->srcname, am->msgid_len, am->msgid);
|
||||
}
|
||||
|
||||
/*
|
||||
* Send a message to a local logged-in client
|
||||
*/
|
||||
|
||||
extern int messaging_message_client(struct worker_t *self, struct client_t *c, const char *fmt, ...)
|
||||
{
|
||||
va_list args;
|
||||
char s[PACKETLEN_MAX];
|
||||
char msgid[5];
|
||||
|
||||
va_start(args, fmt);
|
||||
vsnprintf(s, PACKETLEN_MAX, fmt, args);
|
||||
va_end(args);
|
||||
|
||||
messaging_generate_msgid(msgid, sizeof(msgid));
|
||||
|
||||
return client_printf(self, c, "SERVER>" APRSC_TOCALL ",TCPIP*,qAZ,%s::%-9s:%s{%s\r\n",
|
||||
serverid, c->username, s, msgid);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,5 +17,6 @@
|
|||
|
||||
extern void messaging_generate_msgid(char *buf, int buflen);
|
||||
extern int messaging_ack(struct worker_t *self, struct client_t *c, struct pbuf_t *pb, struct aprs_message_t *am);
|
||||
extern int messaging_message_client(struct worker_t *self, struct client_t *c, const char *fmt, ...);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue