* don't send dummy data anymore -- no longer needed
This commit is contained in:
@ -29,6 +29,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#include <glib/gprintf.h>
|
||||||
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
#ifdef HAVE_LIBREADLINE
|
||||||
#include <readline/readline.h>
|
#include <readline/readline.h>
|
||||||
#include <readline/history.h>
|
#include <readline/history.h>
|
||||||
@ -86,51 +88,28 @@ static void send_expr (const char* frm, ...) G_GNUC_PRINTF(1, 2);
|
|||||||
static void
|
static void
|
||||||
send_expr (const char* frm, ...)
|
send_expr (const char* frm, ...)
|
||||||
{
|
{
|
||||||
char *hdr;
|
char *expr;
|
||||||
va_list ap;
|
va_list ap;
|
||||||
char pfx[16];
|
char hdr[16];
|
||||||
int rv;
|
size_t exprlen, hdrlen;
|
||||||
|
|
||||||
va_start (ap, frm);
|
va_start (ap, frm);
|
||||||
|
|
||||||
hdr = g_strdup_vprintf (frm, ap);
|
expr = NULL;
|
||||||
snprintf (pfx, sizeof(pfx), BOX "%u" BOX, strlen(hdr));
|
exprlen = g_vasprintf (&expr, frm, ap);
|
||||||
|
hdrlen = snprintf (hdr, sizeof(hdr), BOX "%u" BOX, exprlen);
|
||||||
|
|
||||||
rv = write (fileno(stdout), pfx, strlen (pfx));
|
if (write (fileno(stdout), hdr, hdrlen) < 0)
|
||||||
if (rv < 0)
|
|
||||||
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
||||||
|
|
||||||
rv = write (fileno(stdout), hdr, strlen (hdr));
|
if (write (fileno(stdout), expr, exprlen) < 0)
|
||||||
if (rv < 0)
|
|
||||||
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
MU_WRITE_LOG ("error writing output: %s", strerror(errno));
|
||||||
|
|
||||||
{
|
g_free (expr);
|
||||||
MU_WRITE_LOG ("--\n%s\n--", hdr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
g_free (hdr);
|
|
||||||
va_end (ap);
|
va_end (ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ugly, ugly... emacs reads/processes the data from the server in
|
|
||||||
* up-to 4096 byte blobs (see read_process_output in the emacs source
|
|
||||||
* code), and for longer messages / more headers, it may only start
|
|
||||||
* processing (showing) the message after more data comes, instead of
|
|
||||||
* immediately. As a work-around for this, here, we just send some
|
|
||||||
* 'filler data' as to 'flush the pipe', so to speak. hopefully, one
|
|
||||||
* day I can come up with a more elegant way to do this...*/
|
|
||||||
static void
|
|
||||||
send_filler_data (unsigned len)
|
|
||||||
{
|
|
||||||
unsigned u;
|
|
||||||
const char* filler = ";; \n";
|
|
||||||
for (u = 0; u != len/8; ++u)
|
|
||||||
write (fileno(stdout), filler, strlen (filler));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static MuError server_error (GError **err, MuError merr, const char* frm, ...)
|
static MuError server_error (GError **err, MuError merr, const char* frm, ...)
|
||||||
G_GNUC_PRINTF(3, 4);
|
G_GNUC_PRINTF(3, 4);
|
||||||
|
|
||||||
@ -364,9 +343,7 @@ cmd_find (MuStore *store, MuQuery *query, GSList *lst, GError **err)
|
|||||||
mu_msg_iter_destroy (iter);
|
mu_msg_iter_destroy (iter);
|
||||||
|
|
||||||
/* return the number of results found */
|
/* return the number of results found */
|
||||||
send_expr ("(:found %u)", u);
|
send_expr ("(:found %u)\n", u);
|
||||||
|
|
||||||
send_filler_data (2048);
|
|
||||||
|
|
||||||
return MU_OK;
|
return MU_OK;
|
||||||
}
|
}
|
||||||
@ -709,18 +686,6 @@ cmd_view (MuStore *store, GSList *args, GError **err)
|
|||||||
|
|
||||||
send_expr ("(:view %s)\n", sexp);
|
send_expr ("(:view %s)\n", sexp);
|
||||||
|
|
||||||
|
|
||||||
/* ugly, ugly... emacs reads/processes the data from the
|
|
||||||
* server in up-to 4096 byte blobs (see read_process_output in
|
|
||||||
* the emacs source code), and for longer messages, it may
|
|
||||||
* only start processing (showing) the message after more data
|
|
||||||
* comes, instead of immediately. As a work-around for this,
|
|
||||||
* here, we just send some 'filler data' as to 'flush the
|
|
||||||
* pipe', so to speak. hopefully, one day I can come up with a
|
|
||||||
* more elegant way to do this...*/
|
|
||||||
if (strlen (sexp) > 4000)
|
|
||||||
send_filler_data (256);
|
|
||||||
|
|
||||||
g_free (sexp);
|
g_free (sexp);
|
||||||
|
|
||||||
return MU_OK;
|
return MU_OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user