Re: gtk_input_add_full() and marshalling



On Wed, 10 Apr 2002, Paul Davis wrote:
> what type of file are you using? from what i can tell, this should
> only request POLLIN and i don't know of anything that would return
> POLLIN at EOF.

Just a regular file. Here's a sample program that reads an arbitrary
file. When I run it, the reader() function receives the data but then
gets invoked over and over again.

#include <stdio.h>
#include <gtk/gtk.h>

void reader(gpointer data, gint source, GdkInputCondition cond)
{
    char buf[256];
    int n;

    printf("\n ** reader called **\n");
    if ((n = read(source, buf, 255)) > 0) {
        buf[n] = 0;
        printf("%s", buf);
    }
}

int main(int argc, char **argv)
{
    FILE *fp;

    if (argc != 2)
        exit(1);

    fp = fopen(argv[1], "r");
    gtk_input_add_full(fileno(fp), GDK_INPUT_READ, reader, NULL, NULL, NULL);
    gtk_main();
    fclose(fp);

    return 0;
}


-Andrei
* Think digital, act analog. *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]