/* * Vstupní bod programu */ int main(int argc, char *argv[]) { progname = argv[0]; open_display(); create_resources(argc, argv); event_loop(); close_display(); return 0; }
static void handle_input(mrp_io_watch_t *watch, int fd, mrp_io_event_t events, void *user_data) { mrp_mainloop_t *ml = mrp_get_io_watch_mainloop(watch); char buf[1024]; int size; my_app_data *app_data = (my_app_data *) user_data; memset(buf, 0, sizeof(buf)); if (events & MRP_IO_EVENT_IN) { size = read(fd, buf, sizeof(buf) - 1); if (size > 0) { buf[size] = '\0'; printf("read line %s\n", buf); } } if (events & MRP_IO_EVENT_HUP) { mrp_del_io_watch(watch); } if (accept_input) { switch (buf[0]) { case 'C': create_resources(app_data); break; case 'A': acquire_resources(app_data); break; case 'D': giveup_resources(app_data); break; case 'Q': if (app_data->rs) mrp_res_delete_resource_set(app_data->rs); if (ml) mrp_mainloop_quit(ml, 0); break; default: printf("'C' to create resource set\n'A' to acquire\n'D' to release\n'Q' to quit\n"); break; } } else { printf("not connected to Murphy\n"); } }
/* * Vstupní bod programu */ int main(int argc, char *argv[]) { progname = argv[0]; if(argc != 3) usage(); if(!strcmp(argv[1], "Forget")) bit_gravity = ForgetGravity; else if(!strcmp(argv[1], "Static")) bit_gravity = StaticGravity; else if(!strcmp(argv[1], "NorthWest")) bit_gravity = NorthWestGravity; else if(!strcmp(argv[1], "North")) bit_gravity = NorthGravity; else if(!strcmp(argv[1], "NorthEast")) bit_gravity = NorthEastGravity; else if(!strcmp(argv[1], "West")) bit_gravity = WestGravity; else if(!strcmp(argv[1], "Center")) bit_gravity = CenterGravity; else if(!strcmp(argv[1], "East")) bit_gravity = EastGravity; else if(!strcmp(argv[1], "SouthWest")) bit_gravity = SouthWestGravity; else if(!strcmp(argv[1], "South")) bit_gravity = SouthGravity; else if(!strcmp(argv[1], "SouthEast")) bit_gravity = SouthEastGravity; else usage(); if(!strcmp(argv[2], "Unmap")) win_gravity = UnmapGravity; else if(!strcmp(argv[2], "Static")) win_gravity = StaticGravity; else if(!strcmp(argv[2], "NorthWest")) win_gravity = NorthWestGravity; else if(!strcmp(argv[2], "North")) win_gravity = NorthGravity; else if(!strcmp(argv[2], "NorthEast")) win_gravity = NorthEastGravity; else if(!strcmp(argv[2], "West")) win_gravity = WestGravity; else if(!strcmp(argv[2], "Center")) win_gravity = CenterGravity; else if(!strcmp(argv[2], "East")) win_gravity = EastGravity; else if(!strcmp(argv[2], "SouthWest")) win_gravity = SouthWestGravity; else if(!strcmp(argv[2], "South")) win_gravity = SouthGravity; else if(!strcmp(argv[2], "SouthEast")) win_gravity = SouthEastGravity; else usage(); open_display(); create_resources(argc, argv); event_loop(); close_display(); return 0; }