[packagekit] C dude needed

Adrien BUSTANY madcat at mymadcat.com
Wed Feb 20 14:37:14 PST 2008


Well, some bare code could be like :
#include <stdio.h>

int main(int argc, char **argv) {
        char answer;
        printf("Would you like to plop ? [N/y] ");
        scanf("%c", &answer);

        switch (answer) {
                case 'y':
                        printf("Cool, let's go plopping\n");
                        break;
                default:
                        printf("Too bad, maybe another time\n");
        }
        return 0;
}

of course this could be wrapped into a neat function

regards
Adrien BUSTANY

Richard Hughes a écrit :
> I've got code to ask the user a question:
>
> 	/* check for user input */
> 	g_print ("Okay to remove additional packages? [N/y]\n");
>
> 	/* TODO: prompt the user */
> 	remove = FALSE;
>
> 	if (remove == FALSE) {
> 		g_print ("Cancelled!\n");
> 		g_free (package_id);
> 		return FALSE;
> 	}
>
> Can anybody give me some clues on a good way to do the prompting? glib
> would be lovely, but I don't mind getting down and dirty with fscanf if
> need be.
>
> Ideas welcome.
>
> Richard.
>
>
> _______________________________________________
> PackageKit mailing list
> PackageKit at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/packagekit
>   




More information about the PackageKit mailing list