/* * Part 2 of early emudesk.inf processing * * This has two functions: * 1. Determine the auto-run program to be started (from #Z). * 2. Set the double-click speed (from #E). This is done here * in case we have an auto-run program. * * Returns: * TRUE if initial program is a GEM program (normal) * FALSE if initial program is character-mode (only if an autorun * entry exists, and it is for a character-mode program). */ static BOOL process_inf2(void) { WORD env, isgem = TRUE; char *pcurr; BYTE tmp; pcurr = infbuf; while (*pcurr) { if ( *pcurr++ != '#' ) continue; tmp = *pcurr; if (tmp == 'E') /* #E 3A 11 */ { /* desktop environment */ pcurr += 2; scan_2(pcurr, &env); ev_dclick(env & 0x07, TRUE); } else if (tmp == 'Z') /* something like "#Z 01 C:\THING.APP@" */ { BYTE *tmpptr1, *tmpptr2; pcurr += 2; scan_2(pcurr, &isgem); /* 00 => not GEM, otherwise GEM */ pcurr += 3; tmpptr1 = pcurr; while (*pcurr && (*pcurr != '@')) ++pcurr; *pcurr = 0; tmpptr2 = sh_name(tmpptr1); *(tmpptr2-1) = 0; KDEBUG(("Found #Z entry in EMUDESK.INF: path=%s, prg=%s\n",tmpptr1,tmpptr2)); sh_wdef(tmpptr2, tmpptr1); ++pcurr; } } return isgem ? TRUE : FALSE; }
/* * Part 2 of early emudesk.inf processing * * This has two functions: * 1. Determine the auto-run program to be started (from #Z). * 2. Set the double-click speed (from #E). This is done here * in case we have an auto-run program. */ static void process_inf2(void) { WORD env; char *pcurr; BYTE tmp; pcurr = infbuf; while (*pcurr) { if ( *pcurr++ != '#' ) continue; tmp = *pcurr; if (tmp == 'E') /* #E 3A 11 */ { /* desktop environment */ pcurr += 2; scan_2(pcurr, &env); ev_dclick(env & 0x07, TRUE); } else if (tmp == 'Z') /* something like "#Z 01 C:\THING.APP@" */ { BYTE *tmpptr1, *tmpptr2; pcurr += 5; tmpptr1 = pcurr; while (*pcurr && (*pcurr != '@')) ++pcurr; *pcurr = 0; tmpptr2 = sh_name(tmpptr1); *(tmpptr2-1) = 0; #if DBG_GEMINIT kprintf("Found #Z entry in EMUDESK.INF with path=%s and prg=%s\n", tmpptr1, tmpptr2); #endif sh_wdef(tmpptr2, tmpptr1); ++pcurr; } } }
static void sh_init(void) { WORD cnt, need_ext; BYTE *psrc, *pdst, *pend; BYTE *s_tail; SHELL *psh; BYTE savch; psh = &sh[0]; sh_deskf(2, (LONG)&ad_pfile); /* add in internal */ /* search paths with */ /* right drive letter */ sh_addpath(); /* set defaults */ psh->sh_doexec = psh->sh_dodef = gl_shgem = psh->sh_isgem = TRUE; psh->sh_fullstep = FALSE; /* parse command tail */ /* that was stored in */ /* geminit */ psrc = s_tail = &D.g_dir[0]; /* reuse part of globals*/ memcpy(s_tail,ad_stail,128); cnt = *psrc++; if (cnt) { /* null-terminate it */ pend = psrc + cnt; *pend = NULL; /* scan off leading */ /* spaces */ while( (*psrc) && (*psrc == ' ') ) psrc++; /* if only white space */ /* get out don't */ /* bother parsing */ if (*psrc) { pdst = psrc; while ( (*pdst) && (*pdst != ' ') ) pdst++; /* find end of app name */ /* save command to do */ /* instead of desktop */ savch = *pdst; *pdst = '\0'; /* mark for sh_name() */ pend = sh_name(psrc); /* see if path also */ *pdst = savch; /* either blank or null */ pdst = &D.s_cmd[0]; if (pend != psrc) { if (*(psrc+1) != ':') /* need drive */ { *pdst++ = gl_logdrv; /* current drive */ *pdst++ = ':'; if (*psrc != '\\') *pdst++ = '\\'; } while (psrc < pend) /* copy rest of path */ *pdst++ = *psrc++; if (*(pdst-1) == '\\') /* back up one char */ pdst--; *pdst = '\0'; pend = &D.s_cmd[0]; while (*pend) /* upcase the path */ { *pend = toupper(*pend); pend++; } dos_sdrv(D.s_cmd[0] -'A'); dos_chdir(D.s_cmd); *pdst++ = '\\'; } need_ext = TRUE; while ( (*psrc) && (*psrc != ' ') ) { if (*psrc == '.') need_ext = FALSE; *pdst++ = *psrc++; } /* append .APP if no */ /* extension given */ if (need_ext) strcpy(pdst, ".APP"); else *pdst = NULL; pdst = &D.s_cmd[0]; while (*pdst) /* upcase the command */ { *pdst = toupper(*pdst); pdst++; } psh->sh_dodef = FALSE; /* save the remainder */ /* into command tail */ /* for the application*/ pdst = &s_tail[1]; /* if ( (*psrc) && * if tail then take * (*psrc != 0x0D) && * out first space * (*psrc == ' ') ) psrc++; */ if (*psrc == ' ') psrc++; /* the batch file allows */ /* three arguments */ /* one for a gem app */ /* and 2 for arguments */ /* to the gem app. */ /* if there are < three */ /* there will be a space */ /* at the end of the last*/ /* arg followed by a 0D */ while ( (*psrc) && (*psrc != 0x0D) && (*psrc != 0x09) && /* what is this?? */ !((*psrc == '/') && (toupper(*(psrc+1)) == 'D')) ) { if ( (*psrc == ' ') && ( (*(psrc+1) == 0x0D) || (*(psrc+1) == NULL)) ) psrc++; else *pdst++ = toupper(*psrc++); } *pdst = NULL; s_tail[0] = strlen(&s_tail[1]); /* don't do the desktop */ /* after this command */ /* unless a /d was */ /* encounterd */ psh->sh_doexec = (toupper(*(psrc+1)) == 'D'); } } LBCOPY(ad_stail, (LONG)(&s_tail[0]), 128); }
void sh_ldapp() { WORD ret, badtry, retry; SHELL *psh; psh = &sh[rlr->p_pid]; strcpy(sh_apdir, D.s_cdir); /* initialize sh_apdir */ badtry = 0; /* Set default DESKTOP if there isn't any yet: */ if(psh->sh_desk[0] == 0) { strcpy(&psh->sh_desk[0], DEF_DESKTOP); strcpy(&psh->sh_cdir[0], &D.s_cdir[0]); } do { sh_chdef(psh); /* set up so that we */ /* will exec the */ /* default next time */ /* unless the */ /* application does */ /* a set command */ psh->sh_dodef = TRUE; /* init graph/char mode */ sh_chgrf(psh); if (gl_shgem) { wm_start(); ratinit(); } /* fix up/parse cmd tail*/ sh_fixtail(psh->sh_fullstep == 2); sh_draw(D.s_cmd, 0, 0); /* redraw the desktop */ /* clear his desk field */ desk_tree[rlr->p_pid] = 0x0L; /* exec it */ /* handle bad try msg */ if (badtry) { ret = fm_show(badtry, NULLPTR, 1); if (badtry == ALNOFIT) break; badtry = 0; } do { retry = FALSE; Dprintf(("sh_ldapp: Starting %s\n", D.s_cmd)); if(psh->sh_isdef && strcmp(D.s_cmd, DEF_DESKTOP) == 0) { /* Start the ROM desktop: */ sh_show(D.s_cmd); p_nameit(rlr, sh_name(&D.s_cmd[0])); p_setappdir(rlr, D.s_cmd); aes_run_rom_program(deskstart); } #if WITH_CLI != 0 else if(strcmp(D.s_cmd, "EMUCON") == 0) { /* start the EmuCON shell: */ aes_run_rom_program(coma_start); } #endif else if ( sh_find(D.s_cmd) ) { /* Run a normal application: */ sh_show(D.s_cmd); p_nameit(rlr, sh_name(&D.s_cmd[0])); p_setappdir(rlr, D.s_cmd); if (psh->sh_fullstep == 0) { dos_exec(0, D.s_cmd, ad_stail, ad_envrn); /* Run the APP */ /* If the user ran an alternative desktop and quitted it, return now to the default desktop: (experimental) */ if(psh->sh_isdef && psh->sh_dodef) { Dprintf(("sh_ldapp: Returning to ROM desktop!\n")); strcpy(&psh->sh_desk[0], DEF_DESKTOP); strcpy(&psh->sh_cdir[0], &D.s_cdir[0]); } } else if (psh->sh_fullstep == 1) { dos_exec(0, D.s_cmd, ad_stail, ad_envrn); DOS_ERR = psh->sh_doexec = FALSE; } if (DOS_ERR) badtry = (psh->sh_isdef) ? ALNOFIT : AL08ERR; /* 02/11/86 LKW begin */ if (wind_spb.sy_owner == rlr) /* if he still owns screen*/ unsync(&wind_spb); /* then take him off. */ /* 02/11/86 LKW end */ } else { if ( (gl_shgem) && (psh->sh_isdef) ) { ret = fm_show(ALOKDESK, NULLPTR, 1); if (ret == 1) retry = TRUE; else retry = psh->sh_doexec = FALSE; } else badtry = AL18ERR; } } while (retry && !badtry); desk_tree[rlr->p_pid] = 0x0L; /* clear his desk field */ } while(psh->sh_doexec && !gl_changerez); }
WORD sh_find(BYTE *pspec) { WORD path; BYTE gotdir, *pname; pname = sh_name(pspec); /* get ptr to name */ gotdir = (pname != pspec); dos_sdta((LONG)D.g_dta); /* first, search in the application directory */ if (!gotdir && rlr->p_appdir[0] != '\0') { strcpy(D.g_dir, rlr->p_appdir); strcat(D.g_dir, pname); dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); if (!DOS_ERR) { strcpy(pspec, D.g_dir); return 1; } } /* second, search in the current directory */ strcpy(D.g_dir, pspec); /* copy to local buffer */ if (!gotdir) { sh_curdir(D.g_dir); /* get current drive/dir*/ if (D.g_dir[3] != NULL) /* if not at root */ strcat(&D.g_dir[0], "\\"); /* add foreslash */ strcat(&D.g_dir[0], pname); /* append name to drive */ /* and directory. */ /* the actual search will be performed in the loop below */ } /* third, search in the AES path */ path = 0; do { dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); if ( (DOS_AX == E_PATHNOTFND) || ((DOS_ERR) && ((DOS_AX == E_NOFILES) || (DOS_AX == E_PATHNOTFND) || (DOS_AX == E_FILENOTFND))) ) { path = sh_path(path, (LONG)D.g_dir, pname); DOS_ERR = TRUE; } else path = 0; } while ( !gotdir && DOS_ERR && path ); /* fourth, search in the current drive root directory */ if (DOS_ERR && !gotdir) { strcpy(D.g_dir, "\\"); strcat(D.g_dir, pname); dos_sfirst(D.g_dir, F_RDONLY | F_SYSTEM); } if (!DOS_ERR) strcpy(pspec, D.g_dir); return(!DOS_ERR); }