Advertisement
Guest User

Untitled

a guest
Sep 27th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.67 KB | None | 0 0
  1. #include "plugin.h"
  2.  
  3. struct gob_header {
  4.     char magic[4];
  5.     long MASTERX;
  6. };
  7.  
  8. enum plugin_status plugin_start(const void* parameter)
  9. {
  10.     int gob_file = rb->open(parameter, O_RDONLY);
  11.  
  12.     struct gob_header current_header;
  13.     rb->read(gob_file, &current_header, sizeof(struct gob_header));
  14.  
  15.     //I really should do magic checking here but i dont want to right now
  16.  
  17.     rb->lseek(gob_file, current_header.MASTERX, SEEK_SET);
  18.     long mastern;
  19.     rb->read(gob_file, &mastern, sizeof(long));
  20.     //rb->splashf(HZ, "the number of files is %d", (int)mastern);
  21.  
  22.     char list[mastern][13];
  23.  
  24.     //fill the list array
  25.     int i;
  26.     int ofs = sizeof(long)*3;
  27.     for(i = 0; i != mastern; i++) {
  28.         rb->lseek(gob_file, current_header.MASTERX + ofs, SEEK_SET);
  29.         char name[13];
  30.         rb->read(gob_file, &name, 13);
  31.         rb->snprintf(list[i], 13, "%s", name);
  32.         ofs = ofs + ((sizeof(long)*2)+13);
  33.     }
  34.  
  35.     ////////////////////////////
  36.     //end of good, tested code//
  37.     ////////////////////////////
  38.  
  39.  
  40.  
  41.     //here are the list functions and declarations
  42.  
  43.     struct gui_synclist gui_list;
  44.  
  45.     const char * get_list_label(int item, void *data, char *buffer, size_t buffer_len){
  46.         (void)data;
  47.         rb->snprintf(buffer, buffer_len, "%s", list[item]);
  48.         return buffer;
  49.     }
  50.     int run_list(void){
  51.         int button;
  52.         while(true)
  53.         {
  54.  
  55.             rb->gui_synclist_draw(&gui_list);
  56.             rb->gui_synclist_do_button(&gui_list, &button, LIST_WRAP_UNLESS_HELD);
  57.             //rb->gui_syncstatusbar_draw(rb->statusbars, false);
  58.             button = rb->get_action(CONTEXT_LIST, TIMEOUT_BLOCK);
  59.             if(rb->gui_synclist_do_button(&gui_list, &button, LIST_WRAP_UNLESS_HELD))
  60.             {
  61.                 continue;
  62.             }
  63.             switch(button){
  64.                 case ACTION_STD_OK:
  65.                     return rb->gui_synclist_get_sel_pos(&gui_list);;
  66.                 break;
  67.                 case ACTION_STD_CANCEL:
  68.                     return -1;
  69.                 break;
  70.             }
  71.         }
  72.     }
  73.  
  74.  
  75.     rb->gui_synclist_init(&gui_list, &get_list_label, NULL, false, 1, NULL);
  76.     rb->gui_synclist_set_icon_callback(&gui_list,NULL);
  77.     rb->gui_synclist_set_title(&gui_list, "Files in the .gob", NOICON);
  78.     rb->gui_synclist_set_nb_items(&gui_list, mastern);
  79.     rb->gui_synclist_limit_scroll(&gui_list, true);
  80.     rb->gui_synclist_select_item(&gui_list, 1);
  81.  
  82.     //now comes the list
  83.     int ret = run_list();
  84.     rb->splashf(HZ, "%d", ret);
  85.  
  86.  
  87.  
  88.  
  89.     /////////////////
  90.     //code to close//
  91.     /////////////////
  92.  
  93.     rb->close(gob_file);
  94.  
  95.     return PLUGIN_OK;
  96.  
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement