int ustristart(const unsigned int *str, const char *val, const unsigned int **ptr) { const unsigned int *p; const char *q; p = str; q = val; while (*q != '\0') { if (utoupper(*p) != utoupper(*q)) return 0; p++; q++; } if (ptr) *ptr = p; return 1; }
/* fs_dlist_proc: * Dialog procedure for the file selector disk list. */ int fs_dlist_proc(int msg, DIALOG *d, int c) { DIALOG *parent = (DIALOG *)d->dp3; char *s = (char *)parent[FS_EDIT].dp; int ret, i, temp; if(msg == MSG_START) { d->d1 = d->d2 = 0; temp = utoupper(ugetc(s)); if(((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) { temp -= 'A'; for(i=0; i<temp; i++) if(_al_drive_exists(i)) d->d1++; } } ret = jwin_droplist_proc(msg, d, c); if(ret & D_CLOSE) { temp = 'A' + get_x_drive(d->d1+1); if((temp < 'A') || (temp > 'Z')) temp = 'C'; s += usetc(s, temp); s += usetc(s, DEVICE_SEPARATOR); s += usetc(s, OTHER_PATH_SEPARATOR); usetc(s, 0); object_message(parent +FS_FILES, MSG_START, 0); object_message(parent +FS_FILES, MSG_DRAW, 0); object_message(parent +FS_EDIT, MSG_START, 0); object_message(parent +FS_EDIT, MSG_DRAW, 0); return ret - D_CLOSE + D_O_K; } return ret; }
/* fs_dlist_proc: * Dialog procedure for the file selector disk list. */ static int fs_dlist_proc(int msg, DIALOG *d, int c) { char *s = file_selector[FS_EDIT].dp; int ret, i, temp; if (msg == MSG_START) { d->d1 = d->d2 = 0; temp = utoupper(ugetc(s)); if (((temp >= 'A') && (temp <= 'Z')) && (ugetat(s, 1) == DEVICE_SEPARATOR)) { temp -= 'A'; for (i=0; i<temp; i++) if (drive_exists(i)) d->d1++; } } ret = d_text_list_proc(msg, d, c); if (ret == D_CLOSE) { temp = 'A' + get_x_drive(d->d1+1); if ((temp < 'A') || (temp > 'Z')) temp = 'C'; s += usetc(s, temp); s += usetc(s, DEVICE_SEPARATOR); s += usetc(s, OTHER_PATH_SEPARATOR); usetc(s, 0); scare_mouse(); SEND_MESSAGE(file_selector+FS_FILES, MSG_START, 0); SEND_MESSAGE(file_selector+FS_FILES, MSG_DRAW, 0); SEND_MESSAGE(file_selector+FS_EDIT, MSG_START, 0); SEND_MESSAGE(file_selector+FS_EDIT, MSG_DRAW, 0); unscare_mouse(); return D_O_K; } return ret; }
/* fs_edit_proc: * Dialog procedure for the file selector editable string. */ static int fs_edit_proc(int msg, DIALOG *d, int c) { char *s = (char *) d->dp; int size = (d->d1 + 1) * uwidth_max(U_CURRENT); /* of s (in bytes) */ int list_size; int found = 0; char b[1024], tmp[16]; int ch, attr; int i; if(msg == MSG_START) { canonicalize_filename(b, s, sizeof(b)); ustrzcpy(s, size, b); } if(msg == MSG_KEY) { if((!ugetc(s)) || (ugetat(s, -1) == DEVICE_SEPARATOR)) ustrzcat(s, size, uconvert_ascii("./", tmp)); canonicalize_filename(b, s, sizeof(b)); ustrzcpy(s, size - ucwidth(OTHER_PATH_SEPARATOR), b); ch = ugetat(s, -1); if((ch != '/') && (ch != OTHER_PATH_SEPARATOR)) { if(file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr)) { if(attr & FA_DIREC) put_backslash(s); else return D_CLOSE; } else return D_CLOSE; } object_message(file_selector+FS_FILES, MSG_START, 0); /* did we `cd ..' ? */ if(ustrlen(updir)) { /* now we have to find a directory name equal to updir */ for(i = 0; i<flist->size; i++) { if(!ustrcmp(updir, flist->name[i])) /* we got it ! */ { file_selector[FS_FILES].d1 = i; /* we have to know the number of visible lines in the filelist */ /* -1 to avoid an off-by-one problem */ list_size = (file_selector[FS_FILES].h-4) / text_height(font) - 1; if(i>list_size) file_selector[FS_FILES].d2 = i-list_size; else file_selector[FS_FILES].d2 = 0; found = 1; break; /* ok, our work is done... */ } } /* by some strange reason, we didn't find the old directory... */ if(!found) { file_selector[FS_FILES].d1 = 0; file_selector[FS_FILES].d2 = 0; } } /* and continue... */ object_message(file_selector+FS_FILES, MSG_DRAW, 0); object_message(d, MSG_START, 0); object_message(d, MSG_DRAW, 0); return D_O_K; } int allegro_lfn = ALLEGRO_LFN; //removes compiler warning if(msg == MSG_UCHAR) { if((c >= 'a') && (c <= 'z')) { if(!allegro_lfn) c = utoupper(c); } else if(c == '/') { c = OTHER_PATH_SEPARATOR; } else if(allegro_lfn) { if((c > 127) || (c < 32)) return D_O_K; } else { if((c != OTHER_PATH_SEPARATOR) && (c != '_') && (c != DEVICE_SEPARATOR) && (c != '.') && ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9'))) return D_O_K; } } // return _gui_edit_proc(msg, d, c); return jwin_edit_proc(msg, d, c); }
/* fs_edit_proc: * Dialog procedure for the file selector editable string. */ static int fs_edit_proc(int msg, DIALOG *d, int c) { char *s = d->dp; int list_size; int found = 0; char b[512]; int ch, attr; int i; if (msg == MSG_START) { fix_filename_path(b, s, sizeof(b)); ustrcpy(s, b); } if (msg == MSG_KEY) { if ((!ugetc(s)) || (ugetat(s, -1) == DEVICE_SEPARATOR)) ustrcat(s, uconvert_ascii("./", NULL)); fix_filename_path(b, s, sizeof(b)); ustrcpy(s, b); ch = ugetat(s, -1); if ((ch != '/') && (ch != OTHER_PATH_SEPARATOR)) { if (file_exists(s, FA_RDONLY | FA_HIDDEN | FA_DIREC, &attr)) { if (attr & FA_DIREC) put_backslash(s); else return D_CLOSE; } else return D_CLOSE; } scare_mouse(); SEND_MESSAGE(file_selector+FS_FILES, MSG_START, 0); /* did we `cd ..' ? */ if (ustrlen(updir)) { /* now we have to find a directory name equal to updir */ for (i = 0; i<flist->size; i++) { if (!ustrcmp(updir, flist->name[i])) { /* we got it ! */ file_selector[FS_FILES].d1 = i; /* we have to know the number of visible lines in the filelist */ /* -1 to avoid an off-by-one problem */ list_size = (file_selector[FS_FILES].h-4) / text_height(font) - 1; if (i>list_size) file_selector[FS_FILES].d2 = i-list_size; else file_selector[FS_FILES].d2 = 0; found = 1; break; /* ok, our work is done... */ } } /* by some strange reason, we didn't find the old directory... */ if (!found) { file_selector[FS_FILES].d1 = 0; file_selector[FS_FILES].d2 = 0; } } /* and continue... */ SEND_MESSAGE(file_selector+FS_FILES, MSG_DRAW, 0); SEND_MESSAGE(d, MSG_START, 0); SEND_MESSAGE(d, MSG_DRAW, 0); unscare_mouse(); return D_O_K; } if (msg == MSG_UCHAR) { if ((c >= 'a') && (c <= 'z')) { if (!ALLEGRO_LFN) c = utoupper(c); } else if (c == '/') { c = OTHER_PATH_SEPARATOR; } else if (ALLEGRO_LFN) { if ((c > 127) || (c < 32)) return D_O_K; } else { if ((c != OTHER_PATH_SEPARATOR) && (c != '_') && (c != DEVICE_SEPARATOR) && (c != '.') && ((c < 'A') || (c > 'Z')) && ((c < '0') || (c > '9'))) return D_O_K; } } return x_edit_proc(msg, d, c); }