static void SortItems (void) { int i; int filtered = 0; Debug ("AppSort (begin)"); // Apply filters apps2Disp = 0; for (i = 0; i < appsCnt; i++) { apps[i].filtered = IsFiltered (i); if (apps[i].filtered && (!apps[i].hidden || showHidden)) apps2Disp++; if (apps[i].filtered) filtered++; } bsort (apps, appsCnt, sizeof(s_app), bsort_filtered); bsort (apps, filtered, sizeof(s_app), bsort_hidden); bsort (apps, apps2Disp, sizeof(s_app), bsort_name); bsort (apps, apps2Disp, sizeof(s_app), bsort_priority); pageMax = (apps2Disp - 1) / gui.spotsXpage; FeedCoverCache (); Debug ("AppSort (end)"); }
int main() { int n, a [ 10 ], i; char s [ 10 ] [ 10 ]; char **s; printf ( "\nEnter the number of elements: " ); scanf( "%d", &n ); /*printf ( "\nEnter the elements: " ); for ( i = 0 ; i < n ; i++ ) scanf ( "%d", &a [ i ] ); */ printf ( "\nEnter the strings: " ); for ( i = 0 ; i < n ; i++ ) scanf ( "%s", s [ i ] ); /*bsort ( a, n, sizeof(int), compar ); */ bsort ( s, n, sizeof(s[0]),comparstr ); /*printf ( "\nThe sorted elements are: " ); for ( i = 0 ; i < n ; i++ ) printf ( "%d\n", a [ i ] );*/ printf ( "\nThe sorted strings are: " ); for ( i = 0 ; i < n ; i++ ) printf ( "%s\n", s [ i ] ); }
int main(void) { init(); bsort(); print(); return 0; }
int operation(int no) { int a[20],b[20],n,i,j,k,fac=0; for(i=0;no!=0;i++) { b[i]=a[i]=no%10; no=no/10; } n=i; for(i=0;i<n/2;i++) { a[i]=a[i]+a[n-(i+1)]; a[n-(i+1)]=a[i]-a[n-(i+1)]; a[i]=a[i]-a[n-(i+1)]; } bsort(b,n); for(i=0;i<n;i++) for(j=0;j<n-i;j++) if(a[i]==b[j]) { fac=fac+j*fact(n-(i+1)); for(k=j;k<n;k++) b[k]=b[k+1]; } return fac; }
int main() { int n,opt; printf("Enter the number of strings\n"); scanf("%d",&n); char s[n][50]; while(1) { printf("2.Ascending order using Bubble Sort\n3.Descending order using insertion sort\n4.Exit\n"); scanf("%d",&opt); switch(opt) { case 1: { getData(s,n); break; } case 2: { bsort(s,n); break; } case 3: { isort(s,n); break; } case 4 : exit(0); } } return 0; }
int main() { int i = 0; bsort(array, 5); for (i = 0; i < 5; ++i) printf("array[%d] = {%s, %d}\n", i, array[i].data, array[i].key); return 0; }
int main() { char tab[10002][40]; int n; for(n=0; !feof(stdin); n++) scanf("%s",tab[n]); char *wsk[10002]; for(int i=0; i<10002; i++)wsk[i]=tab[i]; bsort(wsk, n-1); for(int j=0; j<n-1; j++) printf("%s\n",wsk[j]); return 0; }
// mission for thread void* mythread(void *arguments) { struct struct_th *arg; arg=(struct struct_th *)arguments; while((arg->wl)<lev){ bsort(arg->wl,arg->j,arg->k,arg->c); (arg->wl)=l; l++; } return NULL; }
/* * bsort implements a bubble sort on the expression list. */ int bsort(CSE **list) { CSE *csp1, *csp2; int i; csp1 = *list; if( csp1 == NULL || csp1->next == NULL ) return FALSE; i = bsort( &(csp1->next)); csp2 = csp1->next; if( OptimizationDesireability(csp1) < OptimizationDesireability(csp2) ) { exchange(list); return TRUE; } return FALSE; }
int main(int argc, char *argv[]) { int A[max]; int i, inum; FILE *file; file = fopen(argv[1], "r"); inum = 0; while(fscanf(file, "%d", &A[inum]) != EOF){ inum++; } fclose(file); bsort(A, inum-1); return 0; }
main() { int A[10] , i; srand(time(NULL)); for( i=0 ; i<10 ; i++) A[i] = rand()%30; bsort(A,10); for( i=0 ; i<10 ; i++) printf("%d ",A[i]); printf("\n"); printf("MAX:%d\n",max(A,10)); printf("SUM:%d\n",sum(A,10)); }
int bsort_main (void) { static int arr[ARRSZ]; unsigned swaps; randomize (arr, ARRSZ); printf ("start: "); print_array (arr, ARRSZ); swaps = bsort (arr, ARRSZ); printf (" end: "); print_array (arr, ARRSZ); printf ("swaps: %u\n", swaps); return 0; }
int main(void) { int num[N]; init(num); putit(num); bsort(num); putit(num); printf("\nwait 2s\n\n"); sleep(2); init(num); putit(num); csort(num); putit(num); return 0; }
int main(int argc, char* argv[]) { int n = ARRAY_SIZE; int array[ARRAY_SIZE]; monitor *m; make_array(&array, n, ARRAY_ALGO); NOTIFY(print_array(&array, n, OUT_LINE_SIZE)); m = monitor_init(SELF); monitor_start(m); bsort(&array, n); monitor_end(m); assert(verify(&array, n)); /* print_array(&array, n, OUT_LINE_SIZE); */ monitor_print_stats(m, VERBOSE); return 0; }
static void blocksort(unsigned char *data, int size, int &markerpos) { _BSort bsort(data, size); bsort.run(markerpos); }
title_set_info_t * DVDGetFileSet(char *dvd) { /* * TODO Fix close of files if * we error out * We also assume that all * DVD files are of valid * size i.e. file%2048 == 0 */ /* title interation */ int title_sets; int titles; int counter; int i; /* DVD file structures */ dvd_reader_t * _dvd = NULL; ifo_handle_t * vmg_ifo = NULL; ifo_handle_t * vts_ifo = NULL; dvd_file_t * vmg_vob_file = NULL; dvd_file_t * vmg_ifo_file = NULL; dvd_file_t * vts_ifo_file = NULL; dvd_file_t * vts_menu_file = NULL; dvd_file_t * vts_title_file = NULL; /* The sizes it self of each file */ int ifo; int bup; int menu_vob; int title_vob; /* Arrays keeping the title - filset relationship */ int * sector; int * title; int * title_sets_array; int * sector_sets_array; /* DVD Video files */ struct stat fileinfo; char temppoint[PATH_MAX + 1]; /* The Title Set Info struct*/ title_set_info_t * title_set_info; /* Temporary mount point - to be used later */ char mountpoint[PATH_MAX + 1]; strncpy(mountpoint, dvd, sizeof (mountpoint)); mountpoint[sizeof (mountpoint)-1] = '\0'; _dvd = DVDOpen(dvd); if (!_dvd) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Can't open device '%s'\n", dvd); #else fprintf(stderr, "Can't open device\n"); #endif return (0); } vmg_ifo = ifoOpen(_dvd, 0); if (!vmg_ifo) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Can't open VMG info for '%s'.\n", dvd); #else fprintf(stderr, "Can't open VMG info.\n"); #endif return (0); } /* Check mount point */ snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VIDEO_TS.IFO", mountpoint); if (stat(temppoint, &fileinfo) < 0) { /* If we can't stat the file, give up */ #ifdef USE_LIBSCHILY errmsg("Can't stat %s\n", temppoint); #else fprintf(stderr, "Can't stat %s\n", temppoint); perror(""); #endif return (0); } title_sets = vmg_ifo->vmgi_mat->vmg_nr_of_title_sets; titles = vmg_ifo->tt_srpt->nr_of_srpts; sector = e_malloc(titles * sizeof (int)); memset(sector, 0, titles * sizeof (int)); title = e_malloc(titles * sizeof (int)); title_sets_array = e_malloc(title_sets * sizeof (int)); sector_sets_array = e_malloc(title_sets * sizeof (int)); title_set_info = (title_set_info_t *)e_malloc(sizeof (title_set_info_t)); title_set_info->title_set = (title_set_t *)e_malloc((title_sets + 1) * sizeof (title_set_t)); title_set_info->num_titles = title_sets; /* Fill and sort the arrays for titles*/ if (titles >= 1) { for (counter = 0; counter < titles; counter++) { sector[counter] = vmg_ifo->tt_srpt->title[counter].title_set_sector; title[counter] = counter + 1; } } /* Yes, we should probably do a better sort than B - but what the heck*/ bsort(sector, title, titles); /* * Since title sets and titles are not the same we will need to sort * out "bogus" titles */ uniq(sector, title, title_sets_array, sector_sets_array, titles); /* Open VIDEO_TS.VOB is present */ vmg_vob_file = DVDOpenFile(_dvd, 0, DVD_READ_MENU_VOBS); /* Check VIDEO_TS title set */ vmg_ifo_file = DVDOpenFile(_dvd, 0, DVD_READ_INFO_FILE); if ((vmg_vob_file == 0) && vmg_ifo->vmgi_mat->vmg_last_sector + 1 < 2 * DVDFileSize(vmg_ifo_file)) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "IFO is not of correct size aborting\n"); #else fprintf(stderr, "IFO is not of correct size aborting\n"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } else if ((vmg_vob_file != 0) && (vmg_ifo->vmgi_mat->vmg_last_sector + 1 < 2 * DVDFileSize(vmg_ifo_file) + DVDFileSize(vmg_vob_file))) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size"); #else fprintf(stderr, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } /* Find the actuall right size of VIDEO_TS.IFO */ if (vmg_vob_file == 0) { if (vmg_ifo->vmgi_mat->vmg_last_sector + 1 > 2 * DVDFileSize(vmg_ifo_file)) { ifo = vmg_ifo->vmgi_mat->vmg_last_sector - DVDFileSize(vmg_ifo_file) + 1; } else { ifo = vmg_ifo->vmgi_mat->vmgi_last_sector + 1; } } else { if (vmg_ifo->vmgi_mat->vmgi_last_sector + 1 < vmg_ifo->vmgi_mat->vmgm_vobs) { ifo = vmg_ifo->vmgi_mat->vmgm_vobs; } else { ifo = vmg_ifo->vmgi_mat->vmgi_last_sector + 1; } } title_set_info->title_set[0].size_ifo = ifo * 2048; title_set_info->title_set[0].realsize_ifo = fileinfo.st_size; title_set_info->title_set[0].pad_ifo = ifo - DVDFileSize(vmg_ifo_file); /* Find the actuall right size of VIDEO_TS.VOB */ if (vmg_vob_file != 0) { if (ifo + DVDFileSize(vmg_ifo_file) + DVDFileSize(vmg_vob_file) - 1 < vmg_ifo->vmgi_mat->vmg_last_sector) { menu_vob = vmg_ifo->vmgi_mat->vmg_last_sector - ifo - DVDFileSize(vmg_ifo_file) + 1; } else { menu_vob = vmg_ifo->vmgi_mat->vmg_last_sector - ifo - DVDFileSize(vmg_ifo_file) + 1; } snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VIDEO_TS.VOB", mountpoint); if (stat(temppoint, &fileinfo) < 0) { #ifdef USE_LIBSCHILY errmsg("calc: Can't stat %s\n", temppoint); #else fprintf(stderr, "calc: Can't stat %s\n", temppoint); perror(""); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } title_set_info->title_set[0].realsize_menu = fileinfo.st_size; title_set_info->title_set[0].pad_menu = menu_vob - DVDFileSize(vmg_vob_file); title_set_info->title_set[0].size_menu = menu_vob * 2048; DVDCloseFile(vmg_vob_file); } else { title_set_info->title_set[0].size_menu = 0; title_set_info->title_set[0].realsize_menu = 0; title_set_info->title_set[0].pad_menu = 0; menu_vob = 0; } /* Finding the actuall right size of VIDEO_TS.BUP */ if (title_sets >= 1) { bup = sector_sets_array[0] - menu_vob - ifo; } else { /* Just in case we burn a DVD-Video without any title_sets */ bup = vmg_ifo->vmgi_mat->vmg_last_sector + 1 - menu_vob - ifo; } /* Never trust the BUP file - use a copy of the IFO */ snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VIDEO_TS.IFO", mountpoint); if (stat(temppoint, &fileinfo) < 0) { #ifdef USE_LIBSCHILY errmsg("calc: Can't stat %s\n", temppoint); #else fprintf(stderr, "calc: Can't stat %s\n", temppoint); perror(""); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } title_set_info->title_set[0].realsize_bup = fileinfo.st_size; title_set_info->title_set[0].size_bup = bup * 2048; title_set_info->title_set[0].pad_bup = bup - DVDFileSize(vmg_ifo_file); /* Take care of the titles which we don't have in VMG */ title_set_info->title_set[0].number_of_vob_files = 0; title_set_info->title_set[0].realsize_vob[0] = 0; title_set_info->title_set[0].pad_title = 0; DVDCloseFile(vmg_ifo_file); if (title_sets >= 1) { for (counter = 0; counter < title_sets; counter++) { vts_ifo = ifoOpen(_dvd, counter + 1); if (!vts_ifo) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Can't open VTS info.\n"); #else fprintf(stderr, "Can't open VTS info.\n"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VTS_%02i_0.IFO", mountpoint, counter + 1); if (stat(temppoint, &fileinfo) < 0) { #ifdef USE_LIBSCHILY errmsg("calc: Can't stat %s\n", temppoint); #else fprintf(stderr, "calc: Can't stat %s\n", temppoint); perror(""); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } /* Test if VTS_XX_0.VOB is present */ vts_menu_file = DVDOpenFile(_dvd, counter + 1, DVD_READ_MENU_VOBS); /* Test if VTS_XX_X.VOB are present */ vts_title_file = DVDOpenFile(_dvd, counter + 1, DVD_READ_TITLE_VOBS); /* Check VIDEO_TS.IFO */ vts_ifo_file = DVDOpenFile(_dvd, counter + 1, DVD_READ_INFO_FILE); /* * Checking that title will fit in the * space given by the ifo file */ if (vts_ifo->vtsi_mat->vts_last_sector + 1 < 2 * DVDFileSize(vts_ifo_file)) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "IFO is not of correct size aborting.\n"); #else fprintf(stderr, "IFO is not of correct size aborting\n"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } else if ((vts_title_file != 0) && (vts_menu_file != 0) && (vts_ifo->vtsi_mat->vts_last_sector + 1 < 2 * DVDFileSize(vts_ifo_file) + DVDFileSize(vts_title_file) + DVDFileSize(vts_menu_file))) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size.\n"); #else fprintf(stderr, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } else if ((vts_title_file != 0) && (vts_menu_file == 0) && (vts_ifo->vtsi_mat->vts_last_sector + 1 < 2 * DVDFileSize(vts_ifo_file) + DVDFileSize(vts_title_file))) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size.\n"); #else fprintf(stderr, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } else if ((vts_menu_file != 0) && (vts_title_file == 0) && (vts_ifo->vtsi_mat->vts_last_sector + 1 < 2 * DVDFileSize(vts_ifo_file) + DVDFileSize(vts_menu_file))) { #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size.\n"); #else fprintf(stderr, "Either VIDEO_TS.IFO or VIDEO_TS.VOB is not of correct size"); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } /* Find the actuall right size of VTS_XX_0.IFO */ if ((vts_title_file == 0) && (vts_menu_file == 0)) { if (vts_ifo->vtsi_mat->vts_last_sector + 1 > 2 * DVDFileSize(vts_ifo_file)) { ifo = vts_ifo->vtsi_mat->vts_last_sector - DVDFileSize(vts_ifo_file) + 1; } else { ifo = vts_ifo->vtsi_mat->vts_last_sector - DVDFileSize(vts_ifo_file) + 1; } } else if (vts_title_file == 0) { if (vts_ifo->vtsi_mat->vtsi_last_sector + 1 < vts_ifo->vtsi_mat->vtstt_vobs) { ifo = vmg_ifo->vtsi_mat->vtstt_vobs; } else { ifo = vmg_ifo->vtsi_mat->vtstt_vobs; } } else { if (vts_ifo->vtsi_mat->vtsi_last_sector + 1 < vts_ifo->vtsi_mat->vtsm_vobs) { ifo = vts_ifo->vtsi_mat->vtsm_vobs; } else { ifo = vts_ifo->vtsi_mat->vtsi_last_sector + 1; } } title_set_info->title_set[counter + 1].size_ifo = ifo * 2048; title_set_info->title_set[counter + 1].realsize_ifo = fileinfo.st_size; title_set_info->title_set[counter + 1].pad_ifo = ifo - DVDFileSize(vts_ifo_file); /* Find the actuall right size of VTS_XX_0.VOB */ if (vts_menu_file != 0) { if (vts_ifo->vtsi_mat->vtsm_vobs == 0) { /* * Apparently start sector 0 means that * VTS_XX_0.VOB is empty after all... */ menu_vob = 0; if (DVDFileSize(vts_menu_file) != 0) { /* * Paranoia: we most likely never * come here... */ #ifdef USE_LIBSCHILY errmsgno(EX_BAD, "%s/VIDEO_TS/VTS_%02i_0.IFO appears to be corrupted.\n", mountpoint, counter+1); #else fprintf(stderr, "%s/VIDEO_TS/VTS_%02i_0.IFO appears to be corrupted.\n", mountpoint, counter+1); #endif return (0); } } else if ((vts_title_file != 0) && (vts_ifo->vtsi_mat->vtstt_vobs - vts_ifo->vtsi_mat->vtsm_vobs > DVDFileSize(vts_menu_file))) { menu_vob = vts_ifo->vtsi_mat->vtstt_vobs - vts_ifo->vtsi_mat->vtsm_vobs; } else if ((vts_title_file == 0) && (vts_ifo->vtsi_mat->vtsm_vobs + DVDFileSize(vts_menu_file) + DVDFileSize(vts_ifo_file) - 1 < vts_ifo->vtsi_mat->vts_last_sector)) { menu_vob = vts_ifo->vtsi_mat->vts_last_sector - DVDFileSize(vts_ifo_file) - vts_ifo->vtsi_mat->vtsm_vobs + 1; } else { menu_vob = vts_ifo->vtsi_mat->vtstt_vobs - vts_ifo->vtsi_mat->vtsm_vobs; } snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VTS_%02i_0.VOB", mountpoint, counter + 1); if (stat(temppoint, &fileinfo) < 0) { #ifdef USE_LIBSCHILY errmsg("calc: Can't stat %s\n", temppoint); #else fprintf(stderr, "calc: Can't stat %s\n", temppoint); perror(""); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } title_set_info->title_set[counter + 1].realsize_menu = fileinfo.st_size; title_set_info->title_set[counter + 1].size_menu = menu_vob * 2048; title_set_info->title_set[counter + 1].pad_menu = menu_vob - DVDFileSize(vts_menu_file); } else { title_set_info->title_set[counter + 1].size_menu = 0; title_set_info->title_set[counter + 1].realsize_menu = 0; title_set_info->title_set[counter + 1].pad_menu = 0; menu_vob = 0; } /* Find the actuall total size of VTS_XX_[1 to 9].VOB */ if (vts_title_file != 0) { if (ifo + menu_vob + DVDFileSize(vts_ifo_file) - 1 < vts_ifo->vtsi_mat->vts_last_sector) { title_vob = vts_ifo->vtsi_mat->vts_last_sector + 1 - ifo - menu_vob - DVDFileSize(vts_ifo_file); } else { title_vob = vts_ifo->vtsi_mat->vts_last_sector + 1 - ifo - menu_vob - DVDFileSize(vts_ifo_file); } /* * Find out how many vob files * and the size of them */ for (i = 0; i < 9; ++i) { snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VTS_%02i_%i.VOB", mountpoint, counter + 1, i + 1); if (stat(temppoint, &fileinfo) < 0) { break; } title_set_info->title_set[counter + 1].realsize_vob[i] = fileinfo.st_size; } title_set_info->title_set[counter + 1].number_of_vob_files = i; title_set_info->title_set[counter + 1].size_title = title_vob * 2048; title_set_info->title_set[counter + 1].pad_title = title_vob - DVDFileSize(vts_title_file); } else { title_set_info->title_set[counter + 1].number_of_vob_files = 0; title_set_info->title_set[counter + 1].realsize_vob[0] = 0; title_set_info->title_set[counter + 1].size_title = 0; title_set_info->title_set[counter + 1].pad_title = 0; title_vob = 0; } /* Find the actuall total size of VTS_XX_0.BUP */ if (title_sets - 1 > counter) { bup = sector_sets_array[counter+1] - sector_sets_array[counter] - title_vob - menu_vob - ifo; } else { bup = vts_ifo->vtsi_mat->vts_last_sector + 1 - title_vob - menu_vob - ifo; } /* Never trust the BUP use a copy of the IFO */ snprintf(temppoint, sizeof (temppoint), "%s/VIDEO_TS/VTS_%02i_0.IFO", mountpoint, counter + 1); if (stat(temppoint, &fileinfo) < 0) { #ifdef USE_LIBSCHILY errmsg("calc: Can't stat %s\n", temppoint); #else fprintf(stderr, "calc: Can't stat %s\n", temppoint); perror(""); #endif DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); DVDFreeFileSet(title_set_info); return (0); } title_set_info->title_set[counter + 1].size_bup = bup * 2048; title_set_info->title_set[counter + 1].realsize_bup = fileinfo.st_size; title_set_info->title_set[counter + 1].pad_bup = bup - DVDFileSize(vts_ifo_file); /* Closing files */ if (vts_menu_file != 0) { DVDCloseFile(vts_menu_file); } if (vts_title_file != 0) { DVDCloseFile(vts_title_file); } if (vts_ifo_file != 0) { DVDCloseFile(vts_ifo_file); } ifoClose(vts_ifo); } } DVDFreeFileSetArrays(sector, title, title_sets_array, sector_sets_array); /* Close the VMG ifo file we got all the info we need */ ifoClose(vmg_ifo); /* Close the DVD */ DVDClose(_dvd); /* Return the actuall info*/ return (title_set_info); }
void make_queue() { int msqid, fid, sid; key_t key; struct mymsgbuf { long mtype; int mat_part[MAXLEN+1]; } mybuf; fid = open_file(); sid = make_sem(); if (num_cl == 1) sem_a(sid); // Generation of IPC key if((key = ftok(KEYFILE,0)) < 0) { printf("Can't generate key\n"); exit(-1); } //Get access for key if((msqid = msgget(key, 0666 | IPC_CREAT)) < 0) { printf("Can't get msqid\n"); exit(-1); } int flag=1; // Client start receive and send massages while(flag) { //rsv massage if ( (msgrcv(msqid, &mybuf,(MAXLEN+1)*sizeof(int), num_cl + cln_num, 0)) < 0) { printf("can't receive message in CLIENT!\n"); exit(-1); } write_log("CLN RSV\n", sid, fid); //analyse of massage if(mybuf.mat_part[0] == STOPWORK) flag = 0; else { //last massage in queue delite all ipc if(mybuf.mat_part[0] == BY) { if ((msgrcv(msqid, &mybuf,(MAXLEN+1)*sizeof(int),3*cln_num, 0)) < 0) { printf("can't receive message in LAST CLIENT!\n"); exit(-1); } if (semctl(sid, 0, IPC_RMID, 0)<0) { printf("ERROR in delite semophore\n"); exit(-1); } if( msgctl(msqid, IPC_RMID, NULL) < 0) { printf("ERROR in delite queue\n"); exit(-1); } if( close(fid) < 0) { printf("ERROR in close file\n"); exit(-1); } } //if it's not last massage we just close client else { mybuf.mtype = num_cl; mybuf.mat_part[0] = WORKDONE; bsort(mybuf.mat_part); if( (msgsnd(msqid, &mybuf, (MAXLEN+1)*sizeof(int), 0)) < 0) { printf("can't send message in CLIENT!\n"); exit(-1); } write_log("CLN SND\n", sid, fid); } } } write_log("I'm FINISH\n", sid, fid); }
void bupdate(void) { static win_t *lwin = NULL; int waiting, widthx = secs_getvar_int("winlistchars"), M = widthx, #ifdef ENABLE_FORCEASCII fascii = secs_getvar_int("forceascii"), #endif bb, line = 0; conn_t *conn = curconn; wbuddy_widthy = secs_getvar_int("winlistheight")*faimconf.wstatus.widthy/100; if (wbuddy_widthy > faimconf.wstatus.widthy) wbuddy_widthy = faimconf.wstatus.widthy; #ifdef ENABLE_FORCEASCII # define LINEDRAW(ch,as) ((fascii == 1) ? as : ch) #else # define LINEDRAW(ch,as) ch #endif #define ACS_ULCORNER_C LINEDRAW(ACS_ULCORNER,',') #define ACS_LLCORNER_C LINEDRAW(ACS_LLCORNER,'`') #define ACS_URCORNER_C LINEDRAW(ACS_URCORNER,'.') #define ACS_LRCORNER_C LINEDRAW(ACS_LRCORNER,'\'') #define ACS_LTEE_C LINEDRAW(ACS_LTEE,'+') #define ACS_RTEE_C LINEDRAW(ACS_RTEE,'+') #define ACS_BTEE_C LINEDRAW(ACS_BTEE,'+') #define ACS_TTEE_C LINEDRAW(ACS_TTEE,'+') #define ACS_HLINE_C LINEDRAW(ACS_HLINE,'-') #define ACS_VLINE_C LINEDRAW(ACS_VLINE,'|') #define ACS_PLUS_C LINEDRAW(ACS_PLUS,'+') #define ACS_RARROW_C LINEDRAW(ACS_RARROW,'>') nw_erase(&win_buddy); nw_vline(&win_buddy, ACS_VLINE_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS), wbuddy_widthy); bb = buddyc; buddyc = 0; if (conn == NULL) return; waiting = 0; if (inconn) { int autoclose = getvar_int(curconn, "autoclose"); assert(curconn->curbwin != NULL); if ((autoclose > 0) && (curconn->curbwin->et == BUDDY) && !USER_PERMANENT(curconn->curbwin->e.buddy) && (curconn->curbwin->waiting != 0)) curconn->curbwin->closetime = now + 60*autoclose; curconn->curbwin->waiting = 0; if ((curconn->curbwin->et == CHAT) && curconn->curbwin->e.chat->isaddressed) curconn->curbwin->e.chat->isaddressed = 0; } do { buddywin_t *bwin = conn->curbwin; char *lastgroup = NULL; int hidegroup = 0, autosort = getvar_int(conn, "autosort"); assert(conn->winname != NULL); if (line < wbuddy_widthy) { nw_move(&win_buddy, line, 0); if (line == 0) nw_addch(&win_buddy, ACS_ULCORNER_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS)); else nw_addch(&win_buddy, ACS_LTEE_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS)); nw_hline(&win_buddy, ACS_HLINE_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS), widthx); nw_move(&win_buddy, line++, widthx-strlen(conn->winname)); if (conn->online <= 0) { nw_printf(&win_buddy, C(WINLIST,BUDDY_OFFLINE), 1, " %s", conn->winname); if (line < wbuddy_widthy) { nw_move(&win_buddy, line++, 1); nw_printf(&win_buddy, C(WINLIST,TEXT), 1, "%s", " You are offline"); buddyc++; } } else nw_printf(&win_buddy, C(WINLIST,TEXT), 1, " %s", conn->winname); } buddyc++; if (bwin == NULL) continue; if (autosort == 2) { if (bwin->et == BUDDY) STRREPLACE(lastgroup, USER_GROUP(bwin->e.buddy)); else STRREPLACE(lastgroup, CHAT_GROUP); } bsort(conn); do { if ((inconn && (conn == curconn)) || bwin->waiting) { char buf[256], *group; int col = -1; assert(bwin->winname != NULL); buddyc++; if (bwin->et == BUDDY) { user_name(buf, sizeof(buf), conn, bwin->e.buddy); group = USER_GROUP(bwin->e.buddy); } else { snprintf(buf, sizeof(buf), "%s", bwin->winname); group = CHAT_GROUP; } if (autosort == 2) { if (strcmp(lastgroup, group) != 0) { if (line < wbuddy_widthy) { nw_move(&win_buddy, line++, widthx-strlen(group)-1); nw_printf(&win_buddy, C(WINLIST,TEXT), hidegroup?0:1, "%c%s%c", hidegroup?'<':'[', group, hidegroup?'>':']'); buddyc++; } STRREPLACE(lastgroup, group); } } if (bwin->waiting && !waiting) { char tmp[64]; if (conn == curconn) snprintf(tmp, sizeof(tmp), " [Ctrl-N to %s]", buf); else snprintf(tmp, sizeof(tmp), " [Ctrl-N to %s:%s]", conn->winname, buf); secs_setvar("ifpending", tmp); waiting = 1; } if (printtitle && bwin->waiting && (waiting < 2) && ((bwin->et == BUDDY) || ((bwin->et == CHAT) && bwin->e.chat->isaddressed))) { nw_titlef("[%s:%s]", conn->winname, buf); waiting = 2; } if (line >= wbuddy_widthy) continue; if (strlen(buf) > M) { buf[M-1] = '>'; buf[M] = 0; } if ((bwin->et == CHAT) && bwin->e.chat->isaddressed) { assert(bwin->waiting); col = C(WINLIST,BUDDY_ADDRESSED); } else if (bwin->waiting) if (bwin->et == BUDDY) col = C(WINLIST,BUDDY_ADDRESSED); else col = C(WINLIST,BUDDY_WAITING); else if (bwin->pouncec > 0) col = C(WINLIST,BUDDY_QUEUED); else switch (bwin->et) { case BUDDY: if (bwin->e.buddy->tag != NULL) col = CI(WINLIST,BUDDY_TAGGED); else if (bwin->e.buddy->offline) col = C(WINLIST,BUDDY_OFFLINE); else if (bwin->e.buddy->ismobile) col = C(WINLIST,BUDDY_MOBILE); else if (bwin->e.buddy->isaway) col = C(WINLIST,BUDDY_AWAY); else if (bwin->e.buddy->isidle) col = C(WINLIST,BUDDY_IDLE); else col = C(WINLIST,BUDDY); break; case CHAT: assert(bwin->e.chat != NULL); if (bwin->e.chat->offline) col = C(WINLIST,BUDDY_OFFLINE); else col = C(WINLIST,BUDDY); break; case TRANSFER: col = C(WINLIST,BUDDY); break; } assert(col != -1); if (bwin == curconn->curbwin) { int affect = col/COLOR_PAIRS, back; #if 0 if (faimconf.b[cIMWIN] == faimconf.b[cWINLIST]) back = (faimconf.b[cIMWIN]+1)%nw_COLORS; else back = faimconf.b[cIMWIN]; #else back = faimconf.b[cWINLISTHIGHLIGHT]; #endif col %= nw_COLORS; col += nw_COLORS*back; col += affect*COLOR_PAIRS; } nw_move(&win_buddy, line, 1); if ((col >= 2*COLOR_PAIRS) || (col < COLOR_PAIRS)) nw_printf(&win_buddy, col%COLOR_PAIRS, 1, "%*s", M, buf); else nw_printf(&win_buddy, col%COLOR_PAIRS, 0, "%*s", M, buf); if (bwin->waiting) { nw_move(&win_buddy, line, 0); nw_addch(&win_buddy, ACS_LTEE_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS)); nw_addch(&win_buddy, ACS_RARROW_C | A_BOLD | COLOR_PAIR(col%COLOR_PAIRS)); } line++; } assert(buddyc < 1000); } while ((bwin = bwin->next) != conn->curbwin); if (autosort == 2) { free(lastgroup); lastgroup = NULL; } else assert(lastgroup == NULL); } while ((conn = conn->next) != curconn); nw_move(&win_buddy, line-1, 0); if (line != 1) nw_addch(&win_buddy, ACS_LLCORNER_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS)); else nw_addch(&win_buddy, ACS_HLINE_C | A_BOLD | COLOR_PAIR(C(WINLIST,TEXT)%COLOR_PAIRS)); if (printtitle && (waiting != 2)) nw_titlef(""); if (waiting) buddyc = -buddyc; else secs_setvar("ifpending", ""); if (inconn) assert(curconn->curbwin != NULL); if ((buddyc != bb) || (inconn && (&(curconn->curbwin->nwin) != lwin)) || (!inconn && (&(curconn->nwin) != lwin))) { if (inconn) lwin = &(curconn->curbwin->nwin); else lwin = &(curconn->nwin); bb = buddyc - bb; buddyc = buddyc - bb; bb = buddyc + bb; naim_changetime(); buddyc = bb; } iupdate(); }
void allocate(int datareg, int addreg, int floatreg, SNODE *block ) /* * allocate will allocate registers for the expressions that have * a high enough desirability. */ { CSE *csp; ENODE *exptr; unsigned mask, rmask,i,fmask,frmask,size; AMODE *ap, *ap2; framedepth = 4+lc_maxauto; mask = 0; rmask = 0; fmask = frmask = 0; for (i=cf_freedata; i < datareg; i++) { framedepth+=4; rmask = rmask | (1 << (15 - i)); mask = mask | (1 << i); } for (i=cf_freeaddress+16; i < addreg; i++) { framedepth+=4; rmask = rmask | (1 << (23 - i)); mask = mask | (1 << (i-8)); } while( bsort(&olist) ); /* sort the expression list */ csp = olist; while( csp != 0 ) { if (csp->reg == -1 && !(csp->exp->cflags & DF_VOL) && !csp->voidf) { if( desire(csp) < 3 ) csp->reg = -1; else { if (csp->exp->nodetype == en_rcon || csp->exp->nodetype == en_fcon || csp->exp->nodetype == en_lrcon || csp->exp->nodetype == en_floatref || csp->exp->nodetype ==en_doubleref || csp->exp->nodetype == en_longdoubleref) { if (floatreg <24 && floatregs) csp->reg = floatreg++; } else if( (datareg < cf_maxdata) && (csp->duses <= csp->uses/4) && dataregs) csp->reg = (datareg)++; else if( !(csp->size == 1 || csp->size == -1) && (addreg < cf_maxaddress) &&addrregs) csp->reg = (addreg)++; } } if( csp->reg != -1 ) { if (lvalue(csp->exp) && !((SYM *)csp->exp->v.p[0]->v.p[0])->funcparm) { ((SYM *)csp->exp->v.p[0]->v.p[0])->inreg = TRUE; ((SYM *)csp->exp->v.p[0]->v.p[0])->value.i = -csp->reg; } if (csp->reg < 16) { framedepth+=4; rmask = rmask | (1 << (15 - csp->reg)); mask = mask | (1 << csp->reg); } else if (csp->reg < 32) { framedepth+=4; rmask = rmask | (1 << (23 - csp->reg)); mask = mask | (1 << (csp->reg-8)); } else { framedepth+=12; frmask = frmask | (1 << (39 - csp->reg)); fmask = fmask | (1 << (csp->reg-32)); } } csp = csp->next; } allocstack(); /* Allocate stack space for the local vars */ if (currentfunc->tp->lst.head !=0 && currentfunc->tp->lst.head != (SYM *)-1) { if (prm_phiform || currentfunc->intflag) { mask |= (1 << (linkreg +8)); rmask |= (1 << (15 - linkreg -8)); framedepth+=4; } if (currentfunc->intflag) { mask |= 0xffff; rmask |= 0xffff; framedepth = lc_maxauto; } } if (prm_linkreg && !currentfunc->intflag && (currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *)-1 || lc_maxauto)) { gen_code(op_link,0,makeareg(linkreg),make_immed(-lc_maxauto)); } if( mask != 0 ) gen_code(op_movem,4,make_mask(rmask,0,0),push); save_mask = mask; if (fmask!=0) gen_code(op_fmovem,10,make_mask(frmask,0,1),push); fsave_mask = fmask; if ((prm_phiform || currentfunc->intflag) && currentfunc->tp->lst.head && currentfunc->tp->lst.head != (SYM *) -1) { gen_code(op_move,4,makeareg(0), makeareg(linkreg)); } if ((!prm_linkreg || currentfunc->intflag) && lc_maxauto) { AMODE *ap = xalloc(sizeof(AMODE)); ap->mode = am_indx; ap->offset = makenode(en_icon,(char *)-lc_maxauto,0); ap->preg = 7; gen_code(op_lea,0,ap,makeareg(7)); } if (prm_stackcheck) { AMODE *ap1; ap = set_symbol("_stackerror",1); ap1 = set_symbol("_stackbottom",0); if (prm_rel) { ap1->mode = am_indx; ap1->preg = basereg; } else { ap1->mode = am_adirect; if (prm_smalldata) ap1->preg = 2; else ap1->preg = 4; } gen_code(op_cmp,4,ap1,makeareg(7)); gen_code(op_bhi,0,ap,0); } }
void allocate(int datareg, int addreg, int floatreg, SNODE *block) /* * allocate will allocate registers for the expressions that have * a high enough desirability. It also puts the function * header, consisting of saved registers and stack decrments for local * variables */ { CSE *csp; ENODE *exptr; unsigned mask, rmask, i, fmask, frmask, size; AMODE *ap, *ap2; mask = asmMask; rmask = asmRMask; fmask = frmask = 0; for (i = cf_freedata; i < datareg; i++) { rmask = rmask | (1 << (15-i)); mask = mask | (1 << i); } for (i = cf_freeaddress + 16; i < addreg; i++) { rmask = rmask | (1 << (23-i)); mask = mask | (1 << (i - 8)); } while (bsort(&olist)) ; /* sort the expression list */ csp = olist; while (csp != 0) { if (csp->reg == - 1 && !(csp->exp->cflags &DF_VOL) && !csp->voidf) { if (desire(csp) < 3) csp->reg = - 1; else { if (csp->exp->nodetype == en_rcon || csp->exp->nodetype == en_fcon || csp->exp->nodetype == en_lrcon || csp->exp ->nodetype == en_floatref || csp->exp->nodetype == en_doubleref || csp->exp->nodetype == en_longdoubleref || csp->exp->nodetype == en_fimaginarycon || csp->exp->nodetype == en_rimaginarycon || csp->exp->nodetype == en_lrimaginarycon || csp->exp->nodetype == en_fimaginaryref || csp->exp->nodetype == en_rimaginaryref || csp->exp->nodetype == en_lrimaginaryref) {} else if ((csp->duses <= csp->uses / 4) && (datareg < cf_maxdata) && dataregs) csp->reg = (datareg)++; else if (!(csp->size == 1 || csp->size == - 1 || csp->size == 5) && (addreg < cf_maxaddress) && addrregs) csp->reg = (addreg)++; else if ((datareg < cf_maxdata) && dataregs) csp->reg = (datareg)++; if (csp->reg != - 1) // if (lvalue(csp->exp)) // csp->seg = defseg(csp->exp->v.p[0]) ; // else if (!csp->seg) { csp->seg = defseg(csp->exp); if (csp->seg) csp->reg = -1; } } } if (csp->reg != - 1) { if (lvalue(csp->exp) && !((SYM*)csp->exp->v.p[0]->v.p[0])->funcparm) { ((SYM*)csp->exp->v.p[0]->v.p[0])->mainsym->inreg = TRUE; ((SYM*)csp->exp->v.p[0]->v.p[0])->mainsym->value.i = - csp ->reg - (csp->size < 0 ? - csp->size: csp->size) *256; } if (csp->reg < 16) { rmask = rmask | (1 << (15-csp->reg)); mask = mask | (1 << csp->reg); } if (csp->reg < 32) { rmask = rmask | (1 << (23-csp->reg)); mask = mask | (1 << (csp->reg - 8)); } else { frmask = frmask | (1 << (39-csp->reg)); fmask = fmask | (1 << (csp->reg - 32)); } } csp = csp->next; } allocstack(); /* Allocate stack space for the local vars */ floatstack_mode = 0; /* no space for floating point temps */ if (currentfunc->intflag || currentfunc->faultflag) { mask = 0; rmask = 0; if (currentfunc->loadds) loadds(); if (prm_farkeyword) { GenPush(ES + 24, am_dreg, 0); GenPush(FS + 24, am_dreg, 0); GenPush(GS + 24, am_dreg, 0); } gen_code(op_pushad, 0, 0); } if ((conscount || try_block_list || currentfunc->value.classdata.throwlist && currentfunc->value.classdata.throwlist->data) && prm_xcept) { xceptoffs = lc_maxauto += sizeof(XCEPTDATA); } if (prm_debug) { rmask = rmask | (1 << (15-EBX)); mask = mask | (1 << EBX); rmask = rmask | (1 << (15-ESI-4)); mask = mask | (1 << (ESI+4)); rmask = rmask | (1 << (15-EDI-4)); mask = mask | (1 << (EDI+4)); } if (prm_cplusplus && prm_xcept || (funcfloat || lc_maxauto || currentfunc ->tp->lst.head && currentfunc->tp->lst.head != (SYM*) - 1) || (currentfunc->value.classdata.cppflags &PF_MEMBER) && !(currentfunc ->value.classdata.cppflags &PF_STATIC) || !prm_smartframes || !stackframeoff) { /* enter is *really* inefficient so we will not use it */ if (!currentfunc->intflag) gen_codes(op_push, 4, makedreg(EBP), 0); gen_codes(op_mov, 4, makedreg(EBP), makedreg(ESP)); if (lc_maxauto) gen_code(op_sub, makedreg(ESP), make_immed(lc_maxauto)); // FIXME ... could auto-alloc an FP value when no frame! frame_ins = peep_tail; } else frame_ins = 0; if (mask != 0) PushRegs(rmask); save_mask = mask; if (fmask != 0) fsave_mask = fmask; if (currentfunc->loadds && !currentfunc->intflag) { loadds(); } if (prm_stackcheck && lc_maxauto) { AMODE *ap1; ap = set_symbol("__stackerror", 1); ap1 = set_symbol("__stackbottom", 0); ap1->mode = am_direct; gen_codes(op_cmp, 4, makedreg(ESP), ap1); gen_codes(op_jb, 0, ap, 0); } AddProfilerData(); if ((conscount || try_block_list || currentfunc->value.classdata.throwlist && currentfunc->value.classdata.throwlist->data) && prm_xcept) { currentfunc->value.classdata.conslabel = nextlabel++; currentfunc->value.classdata.destlabel = nextlabel++; gen_codes(op_mov, 4, makedreg(EAX), make_label(nextlabel - 2)); call_library("__InitExceptBlock"); gen_label(nextlabel - 1); } }