/* * GETFILE.C get file name from File Manager and write to clipboard * 11/23/1994 Takeshi Sugiyama * Ver 0.0 Test Version BEEP ONLY 11/23/1994 * Ver 0.1 Test Version chk_char() 11/26/1994 * Ver 0.2 Test Version my_str***() 11/27/1994 * check OK chk_char()&write_cb() * Ver 0.3 Test Version except get_path() 11/27/1994 * but not worked! * Ver 0.4 Test Version get_file() worked 11/27/1994 * fixed some bugs in chk_char() * Ver 0.5 Test Version pointer->array 11/27/1994 * find_cursor() OK. only get_path() remains * Ver 0.6 Test Version get_path() 11/27/1994 * right half doesn't work * Ver 0.7 Beta Version everything works 11/27/1994 * upload to nifty * Ver 0.8 Beta Version 100Buddy&200LX Font OK 11/30/1994 * fixed some bugs upload to nifty * Ver 0.9 Beta Version used m_getdrv & m_getdir() 12/01/1994 * fixed some bugs upload to nifty * Ver 1.0 use config.sys as env file 12/03/1994 * Ver 1.01 hung up bug fix 12/14/1994 * Ver 1.02 hung up bug fix 12/19/1994 * Ver 1.03 add secret option for *.pcx 01/04/1995 * Ver 1.1 CAPITAL char support 02/11/1995 * Ver 1.11 move is_filer() to normal.h 02/17/1995 * Ver 2.0 use NKIT&LHAPI 12/3/1995 * Ver 2.01 fixed a bug 12/30/1995 */ #include #include #include #include "mydos.h" /* function prottype */ void app_ini(void); void app_main(void); BOOL env_open(void); BOOL env_close(void); void rmv_space( char *tstring ); BOOL Chk200( void ); void GetFileName( void ); void write_cb( char far *full_path, unsigned int length ); /* grobal constant */ char fileinf[80],filepre[9],fileext[4],filename[100]; char mappot[] = "PCX:"; char pcx_dir[] = "A:\pcx"; char pcx_ext[] = "PCX"; int mode; FILE envp; /* program body */ void main(void) { m_init_app(SYSTEM_MANAGER_VERSION); m_lock(); app_ini(); app_main(); m_unlock(); m_fini(); } void app_main(void) { GetFileName(); switch (mode) { case 0: /* full path */ strcat(filename, fileinf); strcat(filename, "\\"); strcat(filename, filepre); strcat(filename, "."); strcat(filename, fileext); break; case 1: /* file_name only */ strcat(filename, filepre); strcat(filename, "."); strcat(filename, fileext); break; case 2: /* path_name only */ strcat(filename, fileinf); break; case 3: /* secret option for *.pcx */ strcat(filename, "PCX:"); strcat(filename, fileinf); strcat(filename, "\\"); strcat(filename, filepre); break; } write_cb(filename, strlen(filename)); return; } void app_ini(void) { char mode_char; int lenp; if (!env_open()) { mode = 0; return; } m_seek(&envp, seek_beginning, 4L); m_read(&envp, &mode_char, 1, &lenp); if (!env_close()) { m_beep(); } if (mode_char == '1') { mode = 1; } else if (mode_char == '2') { mode = 2; } else if (mode_char == '3') { mode = 3; } else { mode = 0; } /* if( lenp != 1) { m_beep(); } if (!env_close()) { m_beep(); } */ return; } BOOL env_open(void) { if (m_openro(&envp, "c:\\_dat\\getfile.env", 19, 0, -1) != 0) { if (m_openro(&envp, "a:\\_dat\\getfile.env", 19, 0, -1) != 0) { if (m_openro(&envp, "c:\\config.sys", 13, 0, -1) != 0) { if (m_openro(&envp, "a:\\config.sys", 13, 0, -1) != 0) { return FALSE; } } } } return TRUE; } BOOL env_close(void) { if (m_close(&envp) == 0) return TRUE; return FALSE; } /* * rmv_space( *tstring ) * *tstringのスペース他を0x00に置換する */ void rmv_space( char *tstring ) { int i; for( i=0; i < strlen( tstring ); i++) { if( *( tstring + i ) < 0x21 || *( tstring + i ) > 0x7e ) *( tstring + i ) = 0x00; } } /* * Chk200() * 200LXならTRUE、100LXならFALSEを返す */ BOOL Chk200( void ) { asm { mov AH,4Dh; mov AL,0D4h; int 15h; } if(_DH == 0) return FALSE; return TRUE; } /* * GetFileName * FILERのカーソル位置のファイル名を取得する */ void GetFileName( void ) { int i, j, t_len; struct task far *spTCB; unsigned char far *memptr; /* ファイラーのTCBを取得  */ spTCB = m_get_TCB(); j = (int)m_get_TCB_size(); for( i = 0; i < j; i++) { if( spTCB[i].t_hotkey == 0xa800 ) break; } memptr = (unsigned char far *)MK_FP( spTCB[i].t_ds, 0 ); if( Chk200()) memptr += 0x20; if ( *( memptr + 0xcd74 )) memptr += 0xa3ae; else memptr += 0x7bca; lstrcpyto((UCHAR far *)filepre, memptr, 9); rmv_space( filepre ); memptr += 8; lstrcpyto((UCHAR far *)fileext, memptr, 4); rmv_space( fileext ); memptr += 0x16; if ( *(memptr+0x42)+1 > 80 ) t_len = 80; else t_len = *(memptr+0x42)+1; lstrcpyto((UCHAR far *)fileinf, memptr, t_len ); if( fileinf[strlen(fileinf)-1] == '\\' ) fileinf[strlen(fileinf)-1] = 0x00; filename[0] = 0x00; return; } void write_cb(char far *full_path, unsigned int length) { m_open_cb(); m_reset_cb("GetFile"); m_new_rep("TEXT"); m_cb_write(full_path,length); m_fini_rep(); m_close_cb(); }