/* * m_vpplug.h * * Manejo de Plug-ins (.dll en win32, .so en unix) para parametros * virtuales * spd@daphne.cps.unizar.es * Ultima modificacion: Sat Oct 4 23:12:26 GMT--1:00 1997 */ #ifdef __cplusplus extern "C" { #endif #define M_VPPATH "MODEL_VPPATH" #ifdef WIN32 # define PATH_SEP '\\' # define PATH_LIM ";" # define PLUG_EXT ".dll" #else # define PATH_SEP '/' # define PATH_LIM ":" # define PLUG_EXT ".so" #endif #define M_PLUG_ADD 10 #define M_PLUG_T_VP 0 #define M_PLUG_T_G 1 #define M_VPERR_NOERR 0 #define M_VPERR_NOPATH 1 #define M_VPERR_NOMEM 2 #define M_VPERR_BADPAR 3 typdef struct m_plug { int type; char *name; VP_PTR *function; char *path; #ifdef WIN32 HINSTANCE #else void * #endif lib; } M_PLUG; /* * Globales */ extern M_PLUG *vp_plug; extern unsigned vp_plug_idx; /* * Prototipos */ extern int m_vpplug_init(void); extern int m_vpplug_add(char *path, int which); extern int m_vpplug_reload(int which); extern int m_vpplug_free(int which); extern int m_vpplug_flush(void); #ifdef __cplusplus } #endif =========================================================================== int rd(char *argv); int main(int argc, char **argv) { char cwd[64]; #ifndef WIN32 char pwd[MAXPATHLEN]; #endif char *s; if (getcwd(cwd, sizeof(cwd)) == NULL) { perror("pwd"); exit(2); } printf("%s\n", cwd); rd( argv[1] ); if ( -1 == chdir( argv[2] )) { perror("chdir"); return(1); } if ((s = getcwd(NULL, 64)) == NULL) { perror("pwd"); exit(2); } printf("getcwd: %s\n", s); free(s); #ifndef WIN32 printf("getwd: %s\n", getwd(pwd)); #endif return rd( "." ); } int rd(char *argv) { #ifndef WIN32 DIR *dir; dir_type *sd; if ( NULL == (dir = opendir( argv ))) { perror("opendir"); return(1); } else { while ( NULL != ( sd = readdir( dir ))) { fprintf(stdout, "%p %10d %24s\n", sd, sd->d_ino, sd->d_name); } closedir( dir ); return(0); } #else struct _finddata_t c_file; long hFile; /* Find first file in current directory */ if( (hFile = _findfirst( "*", &c_file )) == -1L ) { perror("opendir"); return(1); } else { printf( "Listing of files\n\n" ); printf( "\n RDO HID SYS ARC FILE DATE %25c SIZE\n", ' ' ); printf( " --- --- --- --- ---- ---- %25c ----\n", ' ' ); do { printf( ( c_file.attrib & _A_SUBDIR ) ? "d " : "- " ); printf( ( c_file.attrib & _A_RDONLY ) ? " Y " : " N " ); printf( ( c_file.attrib & _A_SYSTEM ) ? " Y " : " N " ); printf( ( c_file.attrib & _A_HIDDEN ) ? " Y " : " N " ); printf( ( c_file.attrib & _A_ARCH ) ? " Y " : " N " ); printf( " %-12s %.24s %9ld\n", c_file.name, ctime( &( c_file.time_write ) ), c_file.size ); } while( _findnext( hFile, &c_file ) == 0 ); _findclose( hFile ); return(0); } #endif } /* _A_ARCH Archive. Set whenever the file is changed, and cleared by the BACKUP command. Value: 0x20 _A_HIDDEN Hidden file. Not normally seen with the DIR command, unless the /AH option is used. Returns information about normal files as well as files with this attribute. Value: 0x02 _A_NORMAL Normal. File can be read or written to without restriction. Value: 0x00 _A_RDONLY Read-only. File cannot be opened for writing, and a file with the same name cannot be created. Value: 0x01 _A_SUBDIR Subdirectory. Value: 0x10 _A_SYSTEM System file. Not normally seen with the DIR command, unless the /A or /A:S option is used. Value: 0x0 */