示例#1
0
static void cmd_list()
{
    char buf[128];
    GSList *list;

    list = pyloader_list();

    g_snprintf(buf, sizeof(buf), "%-15s %s", "Name", "File");

    if (list != NULL)
    {
        GSList *node;

        printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, buf);
        for (node = list; node != NULL; node = node->next)
        {
            PY_LIST_REC *item = node->data;
            g_snprintf(buf, sizeof(buf), "%-15s %s", item->name, item->file); 

            printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, buf);
        }
    }
    else
        printtext_string(NULL, NULL, MSGLEVEL_CLIENTERROR, "No python scripts are loaded");

    pyloader_list_destroy(&list);
}
示例#2
0
static PyObject *PyServer_prnt(PyServer *self, PyObject *args, PyObject *kwds)
{
    static char *kwlist[] = {"channel", "str", "level", NULL};
    char *str, *channel;
    int level = MSGLEVEL_CLIENTNOTICE;

    RET_NULL_IF_INVALID(self->data);
    
    if (!PyArg_ParseTupleAndKeywords(args, kwds, "ss|i", kwlist, &channel, &str, &level))
        return NULL;

    printtext_string(self->data, channel, level, str);
    
    Py_RETURN_NONE;
}
示例#3
0
文件: fe-help.c 项目: Brijen/MacIrssi
static int show_help_file(const char *file)
{
        const char *helppath;
	char *path, **paths, **tmp;
	GIOChannel *handle;
	GString *buf;
	gsize tpos;

        helppath = settings_get_str("help_path");

	paths = g_strsplit(helppath, ":", -1);

	handle = NULL;
	for (tmp = paths; *tmp != NULL; tmp++) {
		/* helpdir/command or helpdir/category/command */
		path = g_strdup_printf("%s/%s", *tmp, file);
		handle = g_io_channel_new_file(path, "r", NULL);
		g_free(path);

		if (handle != NULL)
			break;

	}

	g_strfreev(paths);

	if (handle == NULL)
		return FALSE;

	g_io_channel_set_encoding(handle, NULL, NULL);
	buf = g_string_sized_new(512);
	/* just print to screen whatever is in the file */
	while (g_io_channel_read_line_string(handle, buf, &tpos, NULL) == G_IO_STATUS_NORMAL) {
		buf->str[tpos] = '\0';
		g_string_prepend(buf, "%|");
		printtext_string(NULL, NULL, MSGLEVEL_CLIENTCRAP, buf->str);
	}
	g_string_free(buf, TRUE);

	g_io_channel_unref(handle);
	return TRUE;
}