Ejemplo n.º 1
0
char *
dispatch_docstring (const char *text)
{
  mu_stream_t str;
  struct mutool_action_tab *p;
  mu_off_t size;
  size_t n;
  char *ret;
  
  mu_memory_stream_create (&str, MU_STREAM_RDWR);
  mu_stream_printf (str, "%s\n%s\n\n", text, _("Commands are:"));
  for (p = mutool_action_tab; p->name; p++)
    mu_stream_printf (str, "  %s %-16s - %s\n",
		      mu_program_name,
		      p->name, gettext (p->docstring));
  mu_stream_printf (str,
		      _("\nTry `%s COMMAND --help' to get help on a particular "
		      "COMMAND.\n\n"),
		      mu_program_name);
  mu_stream_printf (str, "%s\n", _("Options are:"));
  mu_stream_flush (str);
  mu_stream_size (str, &size);
  ret = mu_alloc (size + 1);
  mu_stream_seek (str, 0, MU_SEEK_SET, NULL);
  mu_stream_read (str, ret, size, &n);
  ret[n] = 0;
  mu_stream_destroy (&str);
  return ret;
}
Ejemplo n.º 2
0
static PyObject *
api_memory_stream_create (PyObject *self, PyObject *args)
{
  int status;
  char *s;
  PyStream *py_stm;

  if (!PyArg_ParseTuple (args, "O!s", &PyStreamType, &py_stm, &s))
    return NULL;

  status = mu_memory_stream_create (&py_stm->stm, MU_STREAM_RDWR);
  if (status == 0)
    {
      status = mu_stream_write (py_stm->stm, s, strlen (s), NULL);
      mu_stream_seek (py_stm->stm, MU_SEEK_SET, 0, NULL);
    }
  return _ro (PyInt_FromLong (status));
}
Ejemplo n.º 3
0
static PyObject *
api_sieve_machine_init (PyObject *self, PyObject *args)
{
  int status;
  PySieveMachine *py_mach;
  mu_stream_t str, estr;
  
  if (!PyArg_ParseTuple (args, "O!", &PySieveMachineType, &py_mach))
    return NULL;

  status = mu_memory_stream_create (&str, MU_STREAM_RDWR);
  if (status)
    return _ro (PyInt_FromLong (status));
  status = mu_log_stream_create (&estr, str);
  mu_stream_unref (str);
  if (status)
    return _ro (PyInt_FromLong (status));
  
  status = mu_sieve_machine_init_ex (&py_mach->mach, NULL, estr);
  mu_stream_unref (estr);
  return _ro (PyInt_FromLong (status));
}