Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "plugin.h"
- struct gob_header {
- char magic[4];
- long MASTERX;
- };
- enum plugin_status plugin_start(const void* parameter)
- {
- int gob_file = rb->open(parameter, O_RDONLY);
- struct gob_header current_header;
- rb->read(gob_file, ¤t_header, sizeof(struct gob_header));
- //I really should do magic checking here but i dont want to right now
- rb->lseek(gob_file, current_header.MASTERX, SEEK_SET);
- long mastern;
- rb->read(gob_file, &mastern, sizeof(long));
- //rb->splashf(HZ, "the number of files is %d", (int)mastern);
- char list[mastern][13];
- //fill the list array
- int i;
- int ofs = sizeof(long)*3;
- for(i = 0; i != mastern; i++) {
- rb->lseek(gob_file, current_header.MASTERX + ofs, SEEK_SET);
- char name[13];
- rb->read(gob_file, &name, 13);
- rb->snprintf(list[i], 13, "%s", name);
- ofs = ofs + ((sizeof(long)*2)+13);
- }
- ////////////////////////////
- //end of good, tested code//
- ////////////////////////////
- //here are the list functions and declarations
- struct gui_synclist gui_list;
- const char * get_list_label(int item, void *data, char *buffer, size_t buffer_len){
- (void)data;
- rb->snprintf(buffer, buffer_len, "%s", list[item]);
- return buffer;
- }
- int run_list(void){
- int button;
- while(true)
- {
- rb->gui_synclist_draw(&gui_list);
- rb->gui_synclist_do_button(&gui_list, &button, LIST_WRAP_UNLESS_HELD);
- //rb->gui_syncstatusbar_draw(rb->statusbars, false);
- button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
- if(rb->gui_synclist_do_button(&gui_list, &button, LIST_WRAP_UNLESS_HELD))
- {
- continue;
- }
- switch(button){
- case ACTION_STD_OK:
- return rb->gui_synclist_get_sel_pos(&gui_list);;
- break;
- case ACTION_STD_CANCEL:
- return -1;
- break;
- }
- }
- }
- rb->gui_synclist_init(&gui_list, &get_list_label, NULL, false, 1, NULL);
- rb->gui_synclist_set_icon_callback(&gui_list,NULL);
- rb->gui_synclist_set_title(&gui_list, "Files in the .gob", NOICON);
- rb->gui_synclist_set_nb_items(&gui_list, mastern);
- rb->gui_synclist_limit_scroll(&gui_list, true);
- rb->gui_synclist_select_item(&gui_list, 1);
- //now comes the list
- int ret = run_list();
- rb->splashf(HZ, "%d", ret);
- /////////////////
- //code to close//
- /////////////////
- rb->close(gob_file);
- return PLUGIN_OK;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement