int startwin_run(void) { MSG msg; if (!startupdlg) return 1; done = -1; ScanGroups(); SetPage(TAB_CONFIG); EnableConfig(1); settings.fullscreen = ScreenMode; settings.xdim = ScreenWidth; settings.ydim = ScreenHeight; settings.bpp = ScreenBPP; settings.samplerate = MixRate; settings.bitspersample = NumBits; settings.channels = NumChannels; settings.forcesetup = ForceSetup; settings.usemouse = UseMouse; settings.usejoy = UseJoystick; strncpy(settings.selectedgrp, grpfile, BMAX_PATH); PopulateForm(-1); while (done < 0) { switch (GetMessage(&msg, NULL, 0,0)) { case 0: done = 1; break; case -1: return -1; default: if (IsWindow(startupdlg) && IsDialogMessage(startupdlg, &msg)) break; TranslateMessage(&msg); DispatchMessage(&msg); break; } } SetPage(TAB_MESSAGES); EnableConfig(0); if (done) { ScreenMode = settings.fullscreen; ScreenWidth = settings.xdim; ScreenHeight = settings.ydim; ScreenBPP = settings.bpp; MixRate = settings.samplerate; NumBits = settings.bitspersample; NumChannels = settings.channels; ForceSetup = settings.forcesetup; UseMouse = settings.usemouse; UseJoystick = settings.usejoy; grpfile = settings.selectedgrp; } FreeGroups(); return done; }
int main(int argc, char *argv[]) { FILE *f; struct groups_t g; struct styles_t s; struct pattern_group_t *groups; struct style_t *styles; struct pattern_t *patterns; int quiet = 0; int current_arg; s.first = NULL; g.first = NULL; if(argc < 2) { printf("Format: %s [-q[uiet]] <filename1> [filename2 ...]\n", argv[0]); return 1; } if(strncmp(argv[1],"-q",2) == 0) { quiet = 1; current_arg = 2; } else { current_arg = 1; } for(;current_arg<argc;current_arg++) { if((f = fopen(argv[current_arg],"r")) == NULL) { perror("Couldn't open file"); return 1; } ParsePatterns(f,&g,&s); fclose(f); if(!quiet) { printf("File: %s\n", argv[current_arg]); groups = FirstGroup(&g); printf("Group Data\n"); while(groups) { printf(" Group Name: %s\n",Group_GetName(groups)); patterns = Group_GetPatterns(groups); while(patterns) { printf(" Pattern Name: %s\n",Patt_GetName(patterns)); printf(" Style: %s\n",Patt_GetStyle(patterns)); printf(" Data: %s\n",Patt_GetData(patterns)); printf(" Height ratio: %1.2f\n",Patt_GetHR(patterns)); printf(" Dwell Ratio: %1.2f\n",Patt_GetDR(patterns)); printf(" Author: %s\n",Patt_GetAuthor(patterns)); patterns = NextPatt(patterns); } groups = NextGroup(groups); printf("\n"); }; printf("\n\n"); printf("Style Data\n"); styles = FirstStyle(&s); while(styles) { int i; printf(" Style Name: %s\n",Style_GetName(styles)); printf(" Length: %i\n",Style_GetLength(styles)); printf(" Data:\n"); for(i=0;i<(int)Style_GetLength(styles);i++) { if((i%4) == 0) { printf(" {"); } else if ((i%4) == 2) { printf("}{"); } printf(" %i",Style_GetData(styles)[i]); if ((i%4) == 0 || (i%4) == 2) { printf(", "); } else if ((i%4) == 3) { printf("}\n"); } } styles = NextStyle(styles); printf("\n"); } printf("\n\n"); } FreeGroups(&g); FreeStyles(&s); } return 0; }
int CgptPrioritize(CgptPrioritizeParams *params) { struct drive drive; int priority; int gpt_retval; uint32_t index; uint32_t max_part; int num_root; int i,j; group_list_t *groups; if (params == NULL) return CGPT_FAILED; if (CGPT_OK != DriveOpen(params->drive_name, &drive, 0, O_RDWR)) return CGPT_FAILED; if (GPT_SUCCESS != (gpt_retval = GptSanityCheck(&drive.gpt))) { Error("GptSanityCheck() returned %d: %s\n", gpt_retval, GptError(gpt_retval)); return CGPT_FAILED; } max_part = GetNumberOfEntries(&drive); if (params->set_partition) { if (params->set_partition < 1 || params->set_partition > max_part) { Error("invalid partition number: %d (must be between 1 and %d\n", params->set_partition, max_part); goto bad; } index = params->set_partition - 1; // it must be a kernel if (!IsRoot(&drive, PRIMARY, index) && !IsMarker(&drive, PRIMARY, index)) { Error("partition %d is not a valid root\n", params->set_partition); goto bad; } } // How many kernel partitions do I have? num_root = 0; for (i = 0; i < max_part; i++) { if (IsRoot(&drive, PRIMARY, i) || IsMarker(&drive, PRIMARY, i)) num_root++; } if (num_root) { // Determine the current priority groups groups = NewGroupList(num_root); for (i = 0; i < max_part; i++) { if (!IsRoot(&drive, PRIMARY, i) && !IsMarker(&drive, PRIMARY, i)) continue; priority = GetPriority(&drive, PRIMARY, i); // Is this partition special? if (params->set_partition && (i+1 == params->set_partition)) { params->orig_priority = priority; // remember the original priority if (params->set_friends) AddToGroup(groups, priority, i); // we'll move them all later else AddToGroup(groups, 99, i); // move only this one } else { AddToGroup(groups, priority, i); // just remember } } // If we're including friends, then change the original group priority if (params->set_partition && params->set_friends) { ChangeGroup(groups, params->orig_priority, 99); } // Sorting gives the new order. Now we just need to reassign the // priorities. SortGroups(groups); // We'll never lower anything to zero, so if the last group is priority zero // we can ignore it. i = groups->num_groups; if (groups->group[i-1].priority == 0) groups->num_groups--; // Where do we start? if (params->max_priority) priority = params->max_priority; else priority = groups->num_groups > 15 ? 15 : groups->num_groups; // Figure out what the new values should be for (i=0; i<groups->num_groups; i++) { groups->group[i].priority = priority; if (priority > 1) priority--; } // Now apply the ranking to the GPT for (i=0; i<groups->num_groups; i++) for (j=0; j<groups->group[i].num_parts; j++) SetPriority(&drive, PRIMARY, groups->group[i].part[j], groups->group[i].priority); FreeGroups(groups); } // Write it all out UpdateAllEntries(&drive); return DriveClose(&drive, 1); bad: (void) DriveClose(&drive, 0); return CGPT_FAILED; }