int gs_chdir(char *dirname) { int rc = 0; DosError(FERR_DISABLEHARDERR); #ifdef __BORLANDC__ if (isalpha(dirname[0]) && (dirname[1]==':')) (void) setdisk(toupper(dirname[0])-'A'); if (!((strlen(dirname)==2) && isalpha(dirname[0]) && (dirname[1]==':'))) chdir(dirname); rc = 1; #else #ifdef __IBMC__ if (isalpha(dirname[0]) && (dirname[1]==':')) if (_chdrive(toupper(dirname[0])-'A'+1)) rc = -1; if (!rc && !((strlen(dirname)==2) && isalpha(dirname[0]) && (dirname[1]==':'))) rc = _chdir(dirname); #else if (isalpha((int)(dirname[0])) && (dirname[1]==':')) if (_chdrive(dirname[0])) rc = -1; rc = _chdir2(dirname); #endif #endif DosError(FERR_ENABLEHARDERR); return rc; }
int HEFileOpen(HWND hwnd,char *filename,int enableReload) { char *buf = NULL; ULONG size; int ret = 0; WinSendMsg(hwndHMLE,HMLM_NEWDOC,0L,0L); size = fileRead2Buf( filename, &buf ); if( buf != NULL ) { BOOL readOnly = ( BOOL )WinSendMsg( hwndHMLE, HMLM_QUERYREADONLY, 0, 0 ); WinSendMsg( hwndHMLE, HMLM_SETREADONLY, MPFROMLONG( FALSE ), 0 ); WinSendMsg(hwndHMLE,HMLM_SETIMPORTEXPORT,buf,MPFROMLONG(size+1)); WinSendMsg(hwndHMLE,HMLM_IMPORT,0,0); WinSendMsg(hwndHMLE,HMLM_SETFIRSTCHAR,MPFROMLONG(0),0); WinSendMsg( hwndHMLE, HMLM_SETREADONLY, MPFROMLONG( readOnly ), 0 ); /* _fullpath( szFullPath,filename, sizeof( szFullPath )); extractDirname(); _chdir2(szDir); */ if (enableReload) EnableReloadButton(hwnd); ret = queryHanTypeBuf( buf ); free( buf ); } else { // szFullPath[0]=0; ret = -1; } _fullpath( szFullPath,filename, sizeof( szFullPath )); extractDirname(); _chdir2(szDir); HESetTitlebarText(hwnd); WinPostMsg(hwndStatbar,STATBAR_USERM_SETMODIFIED,0L,0L); WinPostMsg(hwndHMLE,HMLM_SETCHANGED,0,0); WinPostMsg(hwndHMLE,HMLM_REFRESH,0,0); return ret; }
/* to handle the drive letter and DBCS characters within a given path */ int chdir(__const__ char *path) { return _chdir2(path); }
void xf86OpenConsole() { /* try to catch problems before they become obvious */ os2_checkinstallation(); if (serverGeneration == 1) { HKBD fd; ULONG drive; ULONG dummy; KBDHWID hwid; APIRET rc; int VioTid; ULONG actual_handles; LONG new_handles; /* hv 250197 workaround for xkb-Problem: switch to X11ROOT drive */ char *x11r = getenv("X11ROOT"); /* Make sure X11ROOT is set before we go further sm280297 */ if (x11r == NULL){ ErrorF("The environment variable X11ROOT is not set! The xserver is aborting.\n"); exit(1); } if (_chdir2(x11r) < 0) { ErrorF("xf86-OS/2: Cannot change to X11ROOT directory!\n"); } ErrorF("xf86-OS/2: Console opened\n"); OriginalVideoMode.cb=sizeof(VIOMODEINFO); rc=VioGetMode(&OriginalVideoMode,(HVIO)0); if(rc!=0) ErrorF("xf86-OS/2: Could not get original video mode. RC=%d\n",rc); xf86Info.consoleFd = -1; /* Set the number of handles to higher than the default 20. Set to 80 which should be plenty */ new_handles = 0; rc = DosSetRelMaxFH(&new_handles,&actual_handles); if (actual_handles < 80) { new_handles = 80 - actual_handles; rc = DosSetRelMaxFH(&new_handles,&actual_handles); ErrorF("xf86-OS/2: Increased number of available handles to %d\n",actual_handles); } /* grab the keyboard */ rc = KbdGetFocus(0,0); if (rc != 0) FatalError("xf86OpenConsole: cannot grab kbd focus, rc=%d\n",rc); /* open the keyboard */ rc = KbdOpen(&fd); if (rc != 0) FatalError("xf86OpenConsole: cannot open keyboard, rc=%d\n",rc); xf86Info.consoleFd = fd; ErrorF("xf86-OS/2: Keyboard opened\n"); /* assign logical keyboard */ KbdFreeFocus(0); rc = KbdGetFocus(0,fd); if (rc != 0) FatalError("xf86OpenConsole: cannot set local kbd focus, rc=%d\n",rc); /* Create kbd queue semaphore */ rc = DosCreateEventSem(NULL,&hKbdSem,DC_SEM_SHARED,TRUE); if (rc != 0) FatalError("xf86OpenConsole: cannot create keyboard queue semaphore, rc=%d\n",rc); /* Create popup semaphore */ rc=DosCreateEventSem("\\SEM32\\XF86PUP",&hevPopupPending,DC_SEM_SHARED,1); if(rc) ErrorF("xf86-OS/2: Could not create popup semaphore! RC=%d\n",rc); /* rc=VioRegister("xf86vio","XF86POPUP_SUBCLASS",0x20002004L,0L); if(rc) { FatalError("xf86-OS2: Could not register XF86VIO.DLL module. Please install in LIBPATH! RC=%d\n",rc); } */ /* Start up the VIO monitor thread */ VioTid=_beginthread(os2VideoNotify,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started Vio thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Start up the hard-error VIO monitor thread */ VioTid=_beginthread(os2HardErrorNotify,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started hard error Vio mode monitor thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Start up the kbd monitor thread */ VioTid=_beginthread(os2KbdMonitorThread,NULL,0x4000,(void *)NULL); ErrorF("xf86-OS/2: Started Kbd monitor thread, Tid=%d\n",VioTid); rc=DosSetPriority(2,3,0,VioTid); /* Disable hard-errors through DosError */ rc = DosQuerySysInfo(5,5,&drive,sizeof(drive)); rc = DosSuppressPopUps(0x0001L,drive+96); /* Disable popups */ rc = KbdSetCp(0,0,fd); if(rc != 0) FatalError("xf86-OS/2: xf86OpenConsole: cannot set keyboard codepage, rc=%d\n",rc); hwid.cb = sizeof(hwid); /* fix crash on P9000 */ rc = KbdGetHWID(&hwid, fd); if (rc == 0) { switch (hwid.idKbd) { default: case 0xab54: /* 88/89 key */ case 0: /*unknown*/ case 1: /*real AT 84 key*/ xf86Info.kbdType = KB_84; break; case 0xab85: /* 122 key */ FatalError("xf86-OS/2: OS/2 has detected an extended 122key keyboard: unsupported!\n"); case 0xab41: /* 101/102 key */ xf86Info.kbdType = KB_101; break; } } else xf86Info.kbdType = KB_84; /*defensive*/ /* Start up the Kbd bit-bucket thread. We don't want to leave the kbd events in the driver queue */ VioTid=_beginthread(os2KbdBitBucketThread,NULL,0x2000,(void *)NULL); ErrorF("xf86-OS/2: Started Kbd bit-bucket thread, Tid=%d\n",VioTid); xf86Config(FALSE); /* Read XF86Config */ } return; }