示例#1
0
static void
run_tui(void)
{
    struct app *app = app_alloc();
    
    struct result result = app_run(app);
    if (!result_is_success(result)) {
        result_print_error(result);
    }
    
    app_free(app);
}
示例#2
0
/* ins_app */
WORD ins_app(BYTE *pfname, ANODE *pa)
{			       
	LONG	tree;
	ANODE	*newpa;
	BYTE	pname[12];
	BYTE	ntypes[6*8];
	WORD	oicon, nicon;
	WORD	oflag, nflag;
	WORD	change, field;
	WORD	uninstalled, h;
#if MULTIAPP
	BYTE	memszstr[4];
	WORD	omemsz, nmemsz;
#endif

	tree = G.a_trees[ADINSAPP];
#if MULTIAPP
	LWSET(OB_NEXT(APMEMBOX),APMEMSZ);
#endif
	h = LWGET(OB_HEIGHT(APSCRLBA));
	LWSET(OB_HEIGHT(APFUPARO), gl_hbox + 2);
	LWSET(OB_Y(APFSVSLI), gl_hbox + 2);
	LWSET(OB_HEIGHT(APFSVSLI), h - (2 * (gl_hbox + 2)));
	LWSET(OB_Y(APFDNARO), h - (gl_hbox + 2));
	LWSET(OB_HEIGHT(APFDNARO), gl_hbox + 2);

	uninstalled = !is_installed(pa);
	LWSET(OB_STATE(APREMV), (uninstalled) ? DISABLED : NORMAL );
	/* stuff in appl name */
	fmt_str(pfname, &pname[0]);
	inf_sset(tree, APNAME, &pname[0]);
	/* stuff in docu types */
	insa_stypes(tree, pa->a_pdata);
	LWSET(OB_STATE(APYMEM), NORMAL);
	oflag = pa->a_flags;
	if (pa->a_flags & AF_ISCRYS)
	{
		field = APGEM;
		LWSET(OB_STATE(APYMEM), DISABLED);
	}
	else
		field = (pa->a_flags & AF_ISPARM) ? APPARMS : APDOS;
	LWSET(OB_STATE(field), SELECTED);

	field = (pa->a_flags & AF_ISFMEM) ? APYMEM : APNMEM;
	LWSET(OB_STATE(field), SELECTED);

	oicon = pa->a_aicon - IA_GENERIC;

#if MULTIAPP
	omemsz = pa->a_memreq;
	merge_str(&memszstr[0], "%W", &omemsz);
	inf_sset(tree, APMEMSZ, &memszstr[0]);
#endif

	insa_elev(tree, oicon, gl_numics);
	nicon = insa_dial(tree, oicon, gl_numics);
	change = FALSE;

#if MULTIAPP
	nmemsz = ins_latoi(LLGET(LLGET(OB_SPEC(APMEMSZ))));
#endif

	/* set memory flag */
	field = inf_gindex(tree, APYMEM, 2);
	nflag = (field == 0) ? AF_ISFMEM : 0;
	LWSET(OB_STATE(APYMEM + field), NORMAL);
	/* set type flags */
	field = inf_gindex(tree, APGEM, 3);
	if (field == 0)
		nflag = AF_ISCRYS | AF_ISGRAF;
	if (field == 2)
		nflag |= AF_ISPARM;
	LWSET(OB_STATE(APGEM + field), NORMAL);
	/* get button selection	*/
	field = inf_gindex(tree, APINST, 3);
	LWSET(OB_STATE(APINST + field), NORMAL);

	if ( field == 0 )
	{
		/* install the appl. if its uninstalled or has new types */
		insa_gtypes(tree, &ntypes[0]);
		if ( (uninstalled) || (!strcmp(&ntypes[0], pa->a_pdata)) )
		{
			newpa = (uninstalled) ? app_alloc(TRUE) : pa;

			if (newpa)
			{
				if ( (uninstalled) || (!strcmp(&ntypes[0], pa->a_pdata)) )
				{
					change = TRUE;
					ntypes[ strlen(&ntypes[0]) ] = '@';
					scan_str(&ntypes[0], &newpa->a_pdata);
				}

				if (newpa != pa)
				{
					uninstalled = change = TRUE;
					strcpy(&ntypes[0], pfname);
					ntypes[ strlen(&ntypes[0]) ] = '@';
					scan_str(&ntypes[0], &newpa->a_pappl);
					newpa->a_flags = nflag;
					newpa->a_type = AT_ISFILE;
					newpa->a_obid = NIL;
					newpa->a_letter = '\0';
					newpa->a_xspot = 0x0;
					newpa->a_yspot = 0x0;
				}
				pa = newpa;
			}
			else
				fun_alert(1, STAPGONE, NULL);
		}
		/* see if icon changed or flags changed */
		if ( (uninstalled) ||
#if MULTIAPP
			(omemsz != nmemsz) ||
#endif
			(oicon != nicon) ||
			(oflag != nflag) )
		{
			change = TRUE;
			pa->a_aicon = nicon + IA_GENERIC;
			pa->a_dicon = nicon + ID_GENERIC;
			pa->a_flags = nflag;
#if MULTIAPP
			pa->a_memreq = nmemsz;
#endif
		}
	}
	else if ( field == 1 )
	{
		/* remove installed app	*/
		if ( !uninstalled )
		{
			app_free(pa);
			change = TRUE;
		}
	}
	return(change);
} /* ins_app */
示例#3
0
/* ins_disk */
WORD ins_disk(ANODE *pa)
{
	LONG	tree;
	WORD	change, icon, flop, hard, fld;
	BYTE	cletter[2], clabel[13];
	BYTE	nletter[2], nlabel[13];
	ANODE	*newpa;

	tree = G.a_trees[ADINSDIS];

	change = FALSE;
	cletter[0] = pa->a_letter;
	cletter[1] = '\0';
	strcpy(&clabel[0], pa->a_pappl);

	inf_sset(tree, DRID, &cletter[0]);
	inf_sset(tree, DRLABEL, &clabel[0]);

	flop = (pa->a_aicon == IG_FLOPPY) ? SELECTED : NORMAL;
	hard = (pa->a_aicon == IG_HARD) ? SELECTED : NORMAL;
	LWSET(OB_STATE(DRFLOPPY), flop);
	LWSET(OB_STATE(DRHARD), hard);
	LWSET(OB_STATE(DRREM), (lastdisk()) ? DISABLED : NORMAL ); 

	inf_show(tree, 0);	

	inf_sget(tree, DRID, &nletter[0]);
	inf_sget(tree, DRLABEL, &nlabel[0]);
	fld = inf_gindex(tree, DRINST, 3);	/* which exit button?	*/
	LWSET(OB_STATE(DRINST + fld), NORMAL);
	icon = ( LWGET(OB_STATE(DRFLOPPY)) & SELECTED );
	icon = (icon) ? IG_FLOPPY : IG_HARD;
	if ( fld == 0 )	/* Install */
	{
		if ( (cletter[0] != nletter[0]) && (nletter[0] != '\0') )
		{
			newpa = get_disk(nletter[0]);
			if (!newpa)
			{
				newpa = app_alloc(FALSE);
				if (newpa)
				{
					newpa->a_flags = pa->a_flags;
					newpa->a_type = pa->a_type;
					newpa->a_obid = pa->a_obid;
					newpa->a_pappl = pa->a_pappl;
					scan_str("@", &newpa->a_pdata);
					newpa->a_aicon = pa->a_aicon;
					newpa->a_dicon = NIL;
					newpa->a_letter = nletter[0];
				} /* if newpa */
				else
					fun_alert(1, STAPGONE, NULL);
			} /* if !newpa */
			if (newpa)
				pa = newpa;
			change = TRUE;
		} /* if cletter */
		/* see if icon changed	*/
		if (pa->a_aicon != icon)
		{
			pa->a_aicon = icon;
			change = TRUE;
		}
		/* see if label changed	*/
		if ( (!strcmp(&clabel[0], &nlabel[0])) && (nlabel[0] != '\0') )
		{
			nlabel[ strlen(&nlabel[0]) ] = '@';
			scan_str(&nlabel[0], &pa->a_pappl);
			change = TRUE;
		}
	} /* if INSTALL */
	else if ( fld == 1 )	/* Remove  */
	{
		/* find matching anode delete it */
		for (pa = G.g_ahead; pa; pa = pa->a_next)
		{
			if ( (pa->a_aicon == icon) && (pa->a_letter == nletter[0]) )
			{
				app_free(pa);
				change = TRUE;
			}
		} /* for */
	} /* if REMOVE */
	return(change);
} /* ins_disk */
示例#4
0
/*
 *  Initialize the application list by reading in the EMUDESK.INF
 *  file, either from memory or from the disk if the shel_get
 *  indicates no message is there.
 */
void app_start(void)
{
    WORD i, x, y;
    ANODE *pa;
    WSAVE *pws;
    BYTE *pcurr, *ptmp, *pauto = NULL;
    WORD envr, xcnt, ycnt, xcent, wincnt, dummy;

    /* remember start drive */
    gl_stdrv = dos_gdrv();

    G.g_pbuff = gl_buffer;

    for (i = NUM_ANODES - 2; i >= 0; i--)
        G.g_alist[i].a_next = &G.g_alist[i + 1];
    G.g_ahead = (ANODE *) NULL;
    G.g_aavail = G.g_alist;
    G.g_alist[NUM_ANODES - 1].a_next = (ANODE *) NULL;

    app_rdicon();

    G.g_wicon = (12 * gl_wschar) + (2 * G.g_iblist[0].ib_xtext);
    G.g_hicon = G.g_iblist[0].ib_hicon + gl_hschar + 2;

    xcnt = G.g_wdesk / (G.g_wicon+MIN_WINT);/* icon count */
    G.g_icw = G.g_wdesk / xcnt;             /* width */

    ycnt = G.g_hdesk / (G.g_hicon+MIN_HINT);/* icon count */
    G.g_ich = G.g_hdesk / ycnt;             /* height */

    shel_get(gl_afile, SIZE_AFILE);
    if (gl_afile[0] != '#')                 /* invalid signature    */
    {                                       /*   so read from disk  */
        LONG ret;
        WORD fh;
        char inf_file_name[16];
        strcpy(inf_file_name, INF_FILE_NAME);
        inf_file_name[0] += gl_stdrv;         /* Adjust drive letter  */
        ret = dos_open(inf_file_name, 0x0);
        if (ret >= 0L)
        {
            fh = (WORD) ret;
            ret = dos_read(fh, SIZE_AFILE, gl_afile);
            G.g_afsize = (ret < 0L) ? 0L : ret;
            dos_close(fh);
            gl_afile[G.g_afsize] = '\0';
        }
    }

    /* If there's still no desktop.inf data, use built-in now: */
    if (gl_afile[0] != '#')
    {
        LONG drivemask;
        char *text;
        int icon_index = 0;
        int drive_x = 0, drive_y = 0;
        int trash_x, trash_y;
        int icon_type;
        char drive_letter;

        /* Environment and Windows */
        strcat(gl_afile, desk_inf_data1);

        /* Scan for valid drives: */
        drivemask = dos_sdrv(dos_gdrv());
        for (i = 0; i < BLKDEVNUM; i++)
        {
            if (drivemask&(1L<<i))
            {
                x = strlen(gl_afile);
                drive_x = icon_index % xcnt; /* x position */
                drive_y = icon_index / xcnt; /* y position */
                icon_type = (i > 1) ? 0 /* Hard disk */ : 1 /* Floppy */;
                drive_letter = 'A' + i;
                rsrc_gaddr(R_STRING, STDISK, (void **)&text);
                sprintf(gl_afile + x, "#M %02X %02X %02X FF %c %s %c@ @\r\n",
                        drive_x, drive_y, icon_type, drive_letter, text, drive_letter);
                icon_index++;
            }
        }

        /* Copy core data part 2 */
        strcat(gl_afile, desk_inf_data2);

        /* add Trash icon to end */
        x = strlen(gl_afile);
        trash_x = 0;            /* Left */
        trash_y = ycnt-1;       /* Bottom */
        if (drive_y >= trash_y) /* if the last drive icon overflows over */
            trash_x = xcnt-1;   /*  the trash row, force trash to right  */
        rsrc_gaddr(R_STRING, STTRASH, (void **)&text);
        sprintf(gl_afile + x, "#T %02X %02X 03 FF   %s@ @\r\n",
                trash_x, trash_y, text);
        G.g_afsize = strlen(gl_afile);
    }

    wincnt = 0;
    inf_rev_level = 0;
    pcurr = gl_afile;

    while(*pcurr)
    {
        if (*pcurr++ != '#')            /* look for start of line */
            continue;

        switch(*pcurr)
        {
        case 'R':                       /* revision level */
            pcurr++;
            pcurr = scan_2(pcurr,&inf_rev_level);
            break;
        case 'Z':                       /* autorun: Z nn pathname@ */
            pcurr = scan_str(pcurr+5,&pauto);   /* save pathname in buffer */
            break;                              /* (a bit wasteful)        */
        case 'T':                       /* Trash */
        case 'M':                       /* Media (Hard/Floppy)  */
        case 'G':                       /* GEM Application      */
        case 'Y':                       /* GEM App. with parms  */
        case 'F':                       /* File (DOS w/o parms) */
        case 'P':                       /* Parm (DOS w/ parms)  */
        case 'D':                       /* Directory            */
        case 'I':                       /* Executable file icon     */
        case 'N':                       /* Non-executable file icon */
            pa = app_alloc(TRUE);
            if (!pa)                    /* paranoia */
                return;
            pcurr = app_parse(pcurr, pa);
            if ((pa->a_type == AT_ISFILE) && pauto)
            {                           /* autorun exists & not yet merged */
                if (strcmp(pauto,pa->a_pappl) == 0)
                {
                    pa->a_flags |= AF_AUTORUN;  /* it's this program */
                    pauto = NULL;               /*  (and no other)   */
                }
            }
            break;
        case 'W':                       /* Window               */
            pcurr++;
            if (wincnt < NUM_WNODES)
            {
                pws = &G.g_cnxsave.cs_wnode[wincnt];
                pcurr = scan_2(pcurr, &dummy);
                pcurr = scan_2(pcurr, &pws->vsl_save);
/* BugFix       */
                pcurr = scan_2(pcurr, &pws->x_save);
                pws->x_save *= gl_wchar;
                pcurr = scan_2(pcurr, &pws->y_save);
                pws->y_save *= gl_hchar;
                pcurr = scan_2(pcurr, &pws->w_save);
                pws->w_save *= gl_wchar;
                pcurr = scan_2(pcurr, &pws->h_save);
                pws->h_save *= gl_hchar;
/* */
                pcurr = scan_2(pcurr, &pws->obid_save);
                ptmp = pws->pth_save;
                pcurr++;
                while(*pcurr != '@')
                    *ptmp++ = *pcurr++;
                *ptmp = '\0';
                wincnt += 1;
            }
            break;
        case 'E':                       /* Environment */
            pcurr++;
            pcurr = scan_2(pcurr, &envr);
            G.g_cnxsave.cs_view = ( (envr & INF_E1_VIEWTEXT) != 0);
            G.g_cnxsave.cs_sort = ( (envr & INF_E1_SORTMASK) >> 5);
            G.g_cnxsave.cs_confdel = ( (envr & INF_E1_CONFDEL) != 0);
            G.g_cnxsave.cs_confcpy = ( (envr & INF_E1_CONFCPY) != 0);
            G.g_cnxsave.cs_dblclick = envr & INF_E1_DCMASK;

            pcurr = scan_2(pcurr, &envr);
            G.g_cnxsave.cs_confovwr = ( (envr & INF_E2_ALLOWOVW) == 0);
            G.g_cnxsave.cs_mnuclick = ( (envr & INF_E2_MNUCLICK) != 0);
            menu_click(G.g_cnxsave.cs_mnuclick, 1); /* tell system */
            if (envr & INF_E2_IDTDATE)
                G.g_cnxsave.cs_datefmt = DATEFORM_IDT;
            else
                G.g_cnxsave.cs_datefmt = (envr & INF_E2_DAYMONTH) ? DATEFORM_DMY : DATEFORM_MDY;
            if (envr & INF_E2_IDTTIME)
                G.g_cnxsave.cs_timefmt = TIMEFORM_IDT;
            else
                G.g_cnxsave.cs_timefmt = (envr & INF_E2_24HCLOCK) ? TIMEFORM_24H : TIMEFORM_12H;
            sound(FALSE, !(envr & INF_E2_SOUND), 0);

            pcurr = scan_2(pcurr, &dummy);  /* skip video stuff */
            pcurr = scan_2(pcurr, &dummy);

            pcurr = scan_2(pcurr, &envr);
            if (envr & INF_E5_NOSORT)
                G.g_cnxsave.cs_sort = CS_NOSORT;
            break;
        }
    }

    for (pa = G.g_ahead; pa; pa = pa->a_next)
    {
        if (pa->a_flags & AF_ISDESK)
        {
            x = pa->a_xspot * G.g_icw;
            y = pa->a_yspot * G.g_ich + G.g_ydesk;
            snap_disk(x, y, &pa->a_xspot, &pa->a_yspot, 0, 0);
        }
    }

    /* set up outlines for dragging files displayed as icons */
    G.g_nmicon = 9;     /* number of points */
    memset(G.g_xyicon, 0, sizeof(G.g_xyicon));
    xcent = (G.g_wicon - G.g_iblist[0].ib_wicon) / 2;
    G.g_xyicon[0] = xcent;
    G.g_xyicon[2] = xcent;
    G.g_xyicon[3] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[5] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[7] = G.g_hicon;
    G.g_xyicon[8] = G.g_wicon;
    G.g_xyicon[9] = G.g_hicon;
    G.g_xyicon[10] = G.g_wicon;
    G.g_xyicon[11] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[12] = G.g_wicon-xcent;
    G.g_xyicon[13] = G.g_hicon-gl_hschar-2;
    G.g_xyicon[14] = G.g_wicon-xcent;
    G.g_xyicon[16] = xcent;

    /* set up outlines for dragging files displayed as text */
    G.g_nmtext = 5;     /* number of points */
    memset(G.g_xytext, 0, sizeof(G.g_xytext));
    G.g_xytext[2] = gl_wchar * DRAG_BOX_WIDTH;
    G.g_xytext[4] = gl_wchar * DRAG_BOX_WIDTH;
    G.g_xytext[5] = gl_hchar;
    G.g_xytext[7] = gl_hchar;
}