void initialize(struct s_file *sfile, t_lsargs lsargs) { if (lsargs.all_members == 1) s_file_print_members(sfile); else { if (lsargs.order_time == 1) if (lsargs.reverse == 1) s_file_sort_mtime_rev(sfile); else s_file_sort_mtime(sfile); else if (lsargs.reverse == 1) s_file_sort_az_rev(sfile); else s_file_sort_az(sfile); handle_print(sfile, lsargs); } }
static void handle_key( LWPanelID panel, void *pdata, LWDualKey key ) { if ( !fp ) return; switch ( key ) { case LWDK_SC_UP: change_pos( pos, -linesize ); break; case LWDK_SC_DOWN: change_pos( pos, linesize ); break; case LWDK_SC_LEFT: change_pos( pos, -1 ); break; case LWDK_SC_RIGHT: change_pos( pos, 1 ); break; case LWDK_PAGEUP: case LWDK_PAD_9: change_pos( pos, -pagesize ); break; case LWDK_PAGEDOWN: case LWDK_PAD_3: change_pos( pos, pagesize ); break; case LWDK_HOME: case LWDK_PAD_7: change_pos( 0, 0 ); break; case LWDK_END: case LWDK_PAD_1: change_pos( 0, filesize - pagesize ); break; case 'p': handle_print(); break; case 'n': handle_new( ctl[ 16 ], NULL ); break; case 'j': handle_jump( ctl[ 7 ], NULL ); break; case 's': handle_search( ctl[ 8 ], NULL ); break; case '+': SET_INT( ctl[ 12 ], 1 ); break; case '-': SET_INT( ctl[ 12 ], 2 ); break; case '*': SET_INT( ctl[ 12 ], 0 ); break; case 't': SET_INT( ctl[ 14 ], 0 ); break; case 'h': SET_INT( ctl[ 14 ], 1 ); break; case 'c': SET_INT( ctl[ 14 ], 2 ); break; case 'b': SET_INT( ctl[ 3 ], 0 ); handle_datatype( ctl[ 3 ], NULL ); break; case 'w': SET_INT( ctl[ 3 ], 1 ); handle_datatype( ctl[ 3 ], NULL ); break; case 'l': SET_INT( ctl[ 3 ], 2 ); handle_datatype( ctl[ 3 ], NULL ); break; case 'f': SET_INT( ctl[ 3 ], 3 ); handle_datatype( ctl[ 3 ], NULL ); break; case 'd': SET_INT( ctl[ 3 ], 4 ); handle_datatype( ctl[ 3 ], NULL ); break; case 'u': { int i = !unsign; SET_INT( ctl[ 4 ], i ); handle_unsigned( ctl[ 4 ], NULL ); } break; case 'i': SET_INT( ctl[ 5 ], 0 ); handle_byteorder( ctl[ 5 ], NULL ); break; case 'm': SET_INT( ctl[ 5 ], 1 ); handle_byteorder( ctl[ 5 ], NULL ); break; case ',': if ( linesize > 1 ) { SET_INT( ctl[ 6 ], linesize - 1 ); handle_rowsize( ctl[ 6 ], NULL ); } break; case '.': if ( linesize < 16 ) { SET_INT( ctl[ 6 ], linesize + 1 ); handle_rowsize( ctl[ 6 ], NULL ); } break; default: break; } }
void handle(char *fname, int fsfd, char *path) { xfs_fsop_handlereq_t handle; char buffer[1024]; char link[1024]; int ret; __u32 len; __u32 linklen; int fd; handle.path=path; handle.ohandle=buffer; handle.ohandlen=&len; ret=xfsctl(fname, fsfd, XFS_IOC_PATH_TO_FSHANDLE, &handle); if (ret) { perror("xfsctl(XFS_IOC_PATH_TO_FSHANDLE)"); exit(1); } printf("XFS_IOC_PATH_TO_FSHANDLE-\n handle: "); handle_print(handle.ohandle, *handle.ohandlen); printf("\n"); fd=open(path,O_RDONLY); if (fd<0) { perror("open"); exit(1); } handle.path=NULL; handle.fd=fd; handle.ohandle=buffer; handle.ohandlen=&len; ret=xfsctl(fname, fsfd, XFS_IOC_FD_TO_HANDLE, &handle); if (ret) { perror("ioctl(XFS_IOC_FD_TO_HANDLE)"); exit(1); } printf("XFS_IOC_FD_TO_HANDLE-\n path: %s\n handle: ", path); handle_print(handle.ohandle, *handle.ohandlen); printf("\n"); close(fd); handle.path=NULL; handle.fd=-1; handle.ihandle=buffer; handle.ihandlen=len; handle.ohandle=NULL; handle.ohandlen=NULL; ret=xfsctl(fname, fsfd, XFS_IOC_OPEN_BY_HANDLE, &handle); if (ret<0) { perror("xfsctl(XFS_IOC_OPEN_BY_HANDLE)"); exit(1); } printf("XFS_IOC_OPEN_BY_HANDLE-\n handle: "); handle_print(handle.ihandle, handle.ihandlen); printf("\n fd: %d\n stat- ", ret); stat_print(ret); close(ret); handle.path=path; handle.ohandle=buffer; handle.ohandlen=&len; ret=xfsctl(fname, fsfd, XFS_IOC_PATH_TO_HANDLE, &handle); if (ret) { perror("xfsctl(XFS_IOC_PATH_TO_HANDLE)"); exit(1); } printf("XFS_IOC_PATH_TO_HANDLE-\n path: %s\n handle: ", path); handle_print(handle.ohandle, *handle.ohandlen); printf("\n"); handle.path=NULL; handle.fd=-1; handle.ihandle=buffer; handle.ihandlen=len; handle.ohandle=link; linklen=sizeof(link); handle.ohandlen=&linklen; ret=xfsctl(fname, fsfd, XFS_IOC_READLINK_BY_HANDLE, &handle); if (ret<0) { perror("xfsctl(XFS_IOC_READLINK_BY_HANDLE)"); fprintf(stderr,"ERROR IGNORED\n"); } else { printf("XFS_IOC_READLINK_BY_HANDLE-\n handle: "); handle_print(handle.ihandle, handle.ihandlen); printf("\n link=\"%*.*s\"\n", ret, ret, (char*)handle.ohandle); } }
static void do_input(FILE *ifp) { int c; char escape; /* * Processing user input. * Basically we stuff the user input to a temp. file until * an escape char. is detected, after which we switch * to the appropriate routine to handle the escape. */ if (ifp == stdin) { if (Verbose) fprintf(stdout,"\nGo \n* "); else { if (!Silent) fprintf(stdout, "* "); } } while ((c = getc(ifp)) != EOF ) { if ( c == '\\') { /* handle escapes */ escape = getc(ifp); switch( escape ) { case 'e': handle_editor(); break; case 'g': handle_send(); break; case 'i': { bool oldVerbose; if (SingleStepMode) { oldVerbose = Verbose; Verbose = false; } handle_file_insert(ifp); if (SingleStepMode) Verbose = oldVerbose; } break; case 'p': handle_print(); break; case 'q': handle_exit(0); break; case 'r': handle_clear(); break; case 's': handle_shell(); break; case 't': handle_print_time(); break; case 'w': handle_write_to_file(); break; case '?': case 'h': handle_help(); break; case '\\': c = escape; stuff_buffer(c); break; case ';': c = escape; stuff_buffer(c); break; default: fprintf(stderr, "unknown escape given\n"); break; } /* end-of-switch */ if (ifp == stdin && escape != '\\') { if (Verbose) fprintf(stdout,"\nGo \n* "); else { if (!Silent) fprintf(stdout, "* "); } } } else { stuff_buffer(c); if (c == ';' && SemicolonIsGo) { handle_send(); if (Verbose) fprintf(stdout,"\nGo \n* "); else { if (!Silent) fprintf(stdout, "* "); } } } } }