X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=instimg;a=blobdiff_plain;f=src%2Fmain.c;h=12c6cedffafed962303a2bcba241162ce0daf794;hp=43a5b6214e87be393271609ac6729371f4bf3379;hb=9f8f8c6cde6f5d9174aa8bc88f530436aecb70d9;hpb=4f312c9361b1f4c63d7697e58503cd0fb8b05fff diff --git a/src/main.c b/src/main.c index 43a5b62..12c6ced 100644 --- a/src/main.c +++ b/src/main.c @@ -1,23 +1,27 @@ #include #include +#include #include #include "widgets.h" +#include "rawdisk.h" static struct wgt_window *win; static struct wgt_widget *lb_instto, *bn_inst, *bn_cancel, *cb_devs, *ck_usbonly; +static struct rawdisk_device rawdev[64]; +static const char *items[64]; +static int num_rawdev; + + +static void update_disks(void); static void onclick(struct wgt_widget *w); static void onmodify(struct wgt_widget *w); + int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, char *cmdline, int showcmd) { int x, y; MSG msg; - static const char *items[] = { - "item one", - "item two", - "item three" - }; if(!(win = wgt_window("256boss USB stick installer", 400, 300))) { @@ -26,8 +30,7 @@ int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, char *cmdline, int show lb_instto = wgt_label(win, "Install to device:", 10, 10); x = wgt_xpos_after(lb_instto, WGT_AUTO); - cb_devs = wgt_combo(win, items, sizeof items / sizeof *items, 0, - x, 10, WGT_AUTO, WGT_AUTO, onmodify); + cb_devs = wgt_combo(win, items, num_rawdev, 0, x, 10, 200, WGT_AUTO, onmodify); y = wgt_ypos_after(cb_devs, 16); ck_usbonly = wgt_checkbox(win, "only show USB devices", 1, x, y, @@ -39,6 +42,8 @@ int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, char *cmdline, int show x = wgt_xpos_after(bn_inst, WGT_AUTO); bn_cancel = wgt_button(win, "Cancel", x, y, WGT_AUTO, WGT_AUTO, onclick); + update_disks(); + while(GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); DispatchMessage(&msg); @@ -48,9 +53,71 @@ int WINAPI WinMain(HINSTANCE hinst, HINSTANCE hprevinst, char *cmdline, int show return 0; } +static int isusbdev(struct rawdisk_device *dev) +{ + char *ptr = dev->path; + while(*ptr) { + int i; + char buf[3]; + for(i=0; i<3; i++) { + buf[i] = tolower(ptr[i]); + } + if(memcmp(buf, "usb", 3) == 0) { + return 1; + } + ptr++; + } + return 0; +} + +static void update_disks(void) +{ + int i; + + for(i=0; i