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

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: 
                     18: #include <proto/intuition.h>
                     19: #include <proto/exec.h>
                     20: #include <proto/dos.h>
                     21: #include <proto/wb.h>
                     22: 
                     23: /****************************************************************************/
                     24: 
                     25: #include "sysconfig.h"
                     26: #include "sysdeps.h"
                     27: #include "options.h"
                     28: #include "uaeexe.h"
                     29: 
                     30: /****************************************************************************/
                     31: 
                     32: #define LEN 256
                     33: 
                     34: struct Library          *WorkbenchBase;
                     35: 
                     36: static struct AppWindow *AppWin;
                     37: static struct MsgPort   *AppPort;
                     38: 
                     39: int  appw_init(struct Window *W);
                     40: void appw_exit(void);
                     41: void appw_events(void);
                     42: 
                     43: /****************************************************************************/
                     44: 
                     45: int appw_init(struct Window *W)
                     46: {
                     47:     WorkbenchBase = (void*)OpenLibrary("workbench.library",36L);
                     48:     if(WorkbenchBase) {
                     49:         AppPort = CreatePort(0,0);
                     50:         if(AppPort) {
                     51:             AppWin = AddAppWindow(0,0,W,AppPort,NULL);
                     52:             if(AppWin) {
                     53:                 write_log("AppWindow started.\n");
                     54:                 return 1;
                     55:             }
                     56:         }
                     57:     }
                     58:     write_log("Failed to start AppWindow.\n");
                     59: 
                     60:     return 0;
                     61: }
                     62: 
                     63: /****************************************************************************/
                     64: 
                     65: void appw_exit(void)
                     66: {
                     67:     if(AppPort) {
                     68:         void *msg;
                     69:         while((msg=GetMsg(AppPort))) ReplyMsg(msg);
                     70:         DeletePort(AppPort);
                     71:         AppPort = NULL;
                     72:     }
                     73:     if(AppWin) {
                     74:         RemoveAppWindow(AppWin);
                     75:         AppWin = NULL;
                     76:     }
                     77:     if(WorkbenchBase) {
                     78:         CloseLibrary((void*)WorkbenchBase);
                     79:         WorkbenchBase = NULL;
                     80:     }
                     81: }
                     82: 
                     83: /***************************************************************************/
                     84: 
                     85: static void addcmd(char *cmd, int len, ULONG lock, char *name)
                     86: {
                     87:     len -= strlen(cmd); if(len<=0) return; while(*cmd) ++cmd;
                     88: 
                     89:     *cmd++ = ' '; if(--len<=0) return;
                     90: 
                     91:     NameFromLock(lock,cmd,len);
                     92:     len -= strlen(cmd);if(len<=0) return;while(*cmd) ++cmd;
                     93:     if(cmd[-1]!=':') {*cmd++='/'; len -= 1;if(len<=0) return;}
                     94:     strncpy(cmd,name,len);
                     95:     while(*cmd) {++cmd; if(--len<=0) *cmd='\0';}
                     96: }
                     97: 
                     98: /***************************************************************************/
                     99: 
                    100: void appw_events(void)
                    101: {
                    102:     if(AppWin) {
                    103:         struct AppMessage *msg;
                    104:         struct WBArg *arg;
                    105:         while((msg=(void*)GetMsg(AppPort))) {
                    106:             char cmd[LEN];
                    107:             int  i;
                    108: 
                    109:             arg = msg->am_ArgList;
                    110: 
                    111:             strcpy(cmd,"cd ");
                    112:             NameFromLock(arg[0].wa_Lock,&cmd[3],LEN-3);
                    113:             uaeexe(cmd);
                    114: 
                    115:            strcpy(cmd,"run ");strcpy(cmd+4,arg[0].wa_Name);
                    116:             for(i=1;i<msg->am_NumArgs;++i)
                    117:                 addcmd(cmd,LEN-2,arg[i].wa_Lock,arg[i].wa_Name);
                    118:                 /*             ^        */
                    119:                 /* 2 bytes for security */
                    120:             uaeexe(cmd);
                    121:             ReplyMsg((void*)msg);
                    122:         }
                    123:     }
                    124: }

unix.superglobalmegacorp.com

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