Annotation of uae/src/od-amiga/ami-appw.c, revision 1.1.1.2

1.1       root        1:  /* 
                      2:   * UAE - The Un*x Amiga Emulator
                      3:   * 
                      4:   * AppWindow interface
                      5:   * 
                      6:   * Copyright 1997 Samuel Devulder.
                      7:   */
                      8: 
                      9: /****************************************************************************/
                     10: 
                     11: #include <workbench/startup.h>
                     12: 
                     13: #include <exec/execbase.h>
                     14: #include <exec/memory.h>
                     15: 
                     16: #include <dos/dos.h>
                     17: 
1.1.1.2 ! root       18: #if defined(POWERUP)
        !            19: #ifndef USE_CLIB
        !            20: #include <powerup/ppcproto/intuition.h>
        !            21: #include <powerup/ppcproto/exec.h>
        !            22: #include <powerup/ppcproto/dos.h>
        !            23: /*#include <workbench/workbench.h> sam: a effacer*/
        !            24: #include <powerup/ppcproto/wb.h>
        !            25: #else
        !            26: #include <clib/intuition_protos.h>
        !            27: #include <clib/exec_protos.h>
        !            28: #include <clib/dos_protos.h>
        !            29: #include <clib/wb_protos.h>
        !            30: #endif
        !            31: 
        !            32: #define AddAppWindow(a0, a1, a2, a3, tags...) \
        !            33:        ({ULONG _tags[] = { tags }; AddAppWindowA((a0), (a1), (a2), (a3), (struct TagItem *)_tags);})
        !            34: 
        !            35: #else
1.1       root       36: #include <proto/intuition.h>
                     37: #include <proto/exec.h>
                     38: #include <proto/dos.h>
                     39: #include <proto/wb.h>
1.1.1.2 ! root       40: #endif
1.1       root       41: 
                     42: /****************************************************************************/
                     43: 
                     44: #include "sysconfig.h"
                     45: #include "sysdeps.h"
                     46: #include "options.h"
                     47: #include "uaeexe.h"
                     48: 
                     49: /****************************************************************************/
                     50: 
                     51: #define LEN 256
                     52: 
                     53: struct Library          *WorkbenchBase;
                     54: 
                     55: static struct AppWindow *AppWin;
                     56: static struct MsgPort   *AppPort;
                     57: 
                     58: int  appw_init(struct Window *W);
                     59: void appw_exit(void);
                     60: void appw_events(void);
                     61: 
                     62: /****************************************************************************/
                     63: 
                     64: int appw_init(struct Window *W)
                     65: {
                     66:     WorkbenchBase = (void*)OpenLibrary("workbench.library",36L);
                     67:     if(WorkbenchBase) {
                     68:         AppPort = CreatePort(0,0);
                     69:         if(AppPort) {
                     70:             AppWin = AddAppWindow(0,0,W,AppPort,NULL);
                     71:             if(AppWin) {
                     72:                 write_log("AppWindow started.\n");
                     73:                 return 1;
                     74:             }
                     75:         }
                     76:     }
                     77:     write_log("Failed to start AppWindow.\n");
                     78: 
                     79:     return 0;
                     80: }
                     81: 
                     82: /****************************************************************************/
                     83: 
                     84: void appw_exit(void)
                     85: {
                     86:     if(AppPort) {
                     87:         void *msg;
                     88:         while((msg=GetMsg(AppPort))) ReplyMsg(msg);
                     89:         DeletePort(AppPort);
                     90:         AppPort = NULL;
                     91:     }
                     92:     if(AppWin) {
                     93:         RemoveAppWindow(AppWin);
                     94:         AppWin = NULL;
                     95:     }
                     96:     if(WorkbenchBase) {
                     97:         CloseLibrary((void*)WorkbenchBase);
                     98:         WorkbenchBase = NULL;
                     99:     }
                    100: }
                    101: 
                    102: /***************************************************************************/
                    103: 
                    104: static void addcmd(char *cmd, int len, ULONG lock, char *name)
                    105: {
                    106:     len -= strlen(cmd); if(len<=0) return; while(*cmd) ++cmd;
                    107: 
                    108:     *cmd++ = ' '; if(--len<=0) return;
                    109: 
                    110:     NameFromLock(lock,cmd,len);
                    111:     len -= strlen(cmd);if(len<=0) return;while(*cmd) ++cmd;
                    112:     if(cmd[-1]!=':') {*cmd++='/'; len -= 1;if(len<=0) return;}
                    113:     strncpy(cmd,name,len);
                    114:     while(*cmd) {++cmd; if(--len<=0) *cmd='\0';}
                    115: }
                    116: 
                    117: /***************************************************************************/
                    118: 
                    119: void appw_events(void)
                    120: {
                    121:     if(AppWin) {
                    122:         struct AppMessage *msg;
                    123:         struct WBArg *arg;
                    124:         while((msg=(void*)GetMsg(AppPort))) {
                    125:             char cmd[LEN];
                    126:             int  i;
                    127: 
                    128:             arg = msg->am_ArgList;
                    129: 
                    130:             strcpy(cmd,"cd ");
                    131:             NameFromLock(arg[0].wa_Lock,&cmd[3],LEN-3);
1.1.1.2 ! root      132:             if(!uaeexe(cmd)) {
        !           133:               strcpy(cmd,"run ");strcpy(cmd+4,arg[0].wa_Name);
        !           134:                for(i=1;i<msg->am_NumArgs;++i)
        !           135:                    addcmd(cmd,LEN-2,arg[i].wa_Lock,arg[i].wa_Name);
        !           136:                    /*             ^        */
        !           137:                    /* 2 bytes for security */
        !           138:                uaeexe(cmd);
        !           139:             }
1.1       root      140:             ReplyMsg((void*)msg);
                    141:         }
                    142:     }
                    143: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.