tmac: add 9term.app, Plumb.app - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
commit afea5fc3fd16a2865d0af52563f601a4c03d8256
parent c84e737c3f64030dc9b66ddb931cac757e9ba986
Author: Russ Cox 
Date:   Wed, 27 Oct 2010 18:22:03 -0700

mac: add 9term.app, Plumb.app

R=rsc
http://codereview.appspot.com/2783041

Diffstat:
  M lib/moveplan9.files                 |       2 ++
  A mac/9term.app/Contents/Info.plist   |      28 ++++++++++++++++++++++++++++
  A mac/9term.app/Contents/MacOS/9term  |       5 +++++
  A mac/9term.app/Contents/PkgInfo      |       2 ++
  A mac/9term.app/Contents/Resources/s… |       0 
  A mac/Plumb.app/Contents/Info.plist   |      78 +++++++++++++++++++++++++++++++
  A mac/Plumb.app/Contents/MacOS/plumb  |       4 ++++
  A mac/Plumb.app/Contents/PkgInfo      |       2 ++
  A mac/Plumb.app/Contents/Resources/p… |       0 
  A mac/spaceglenda.icns                |       0 
  A mac/spaceglenda.png                 |       0 
  A src/cmd/devdraw/macargv.c           |      90 +++++++++++++++++++++++++++++++
  M src/cmd/devdraw/mkfile              |       5 +++++
  M src/cmd/devdraw/mkwsysrules.sh      |       1 +
  M src/cmd/rio/mkfile                  |       3 +++

15 files changed, 220 insertions(+), 0 deletions(-)
---
diff --git a/lib/moveplan9.files b/lib/moveplan9.files
t@@ -23,6 +23,8 @@ bin/unmount
 bin/vwhois
 bin/vmount
 bin/yesterday
+mac/9term.app/Contents/MacOS/9term
+mac/Plumb.app/Contents/MacOS/plumb
 mail/lib/qmail
 mail/lib/remotemail
 man/mkindex
diff --git a/mac/9term.app/Contents/Info.plist b/mac/9term.app/Contents/Info.plist
t@@ -0,0 +1,28 @@
+
+
+
+
+        CFBundleDevelopmentRegion
+        English
+        CFBundleExecutable
+        9term
+        CFBundleGetInfoString
+        0.1-1
+        CFBundleIconFile
+        spaceglenda.icns
+        CFBundleIdentifier
+        com.swtch.9term
+        CFBundleInfoDictionaryVersion
+        6.0
+        CFBundleName
+        9term
+        CFBundlePackageType
+        APPL
+        CFBundleShortVersionString
+        0.1
+        CFBundleSignature
+        9term1
+        CFBundleVersion
+        1
+
+
diff --git a/mac/9term.app/Contents/MacOS/9term b/mac/9term.app/Contents/MacOS/9term
t@@ -0,0 +1,5 @@
+#!/bin/bash
+cd $HOME
+. ~/.bashrc
+PLAN9=${PLAN9:-/usr/local/plan9}
+$PLAN9/bin/9term -W600x800 &
diff --git a/mac/9term.app/Contents/PkgInfo b/mac/9term.app/Contents/PkgInfo
t@@ -0,0 +1,2 @@
+APPL9term
+
diff --git a/mac/9term.app/Contents/Resources/spaceglenda.icns b/mac/9term.app/Contents/Resources/spaceglenda.icns
Binary files differ.
diff --git a/mac/Plumb.app/Contents/Info.plist b/mac/Plumb.app/Contents/Info.plist
t@@ -0,0 +1,78 @@
+
+
+
+
+        CFBundleDevelopmentRegion
+        English
+        CFBundleExecutable
+        plumb
+        CFBundleGetInfoString
+        1
+        CFBundleIconFile
+        pjw.icns
+        CFBundleIdentifier
+        com.swtch.plan9port.plumb
+        CFBundleInfoDictionaryVersion
+        6.0
+        CFBundleName
+        Plumb
+        CFBundlePackageType
+        APPL
+        CFBundleShortVersionString
+        1
+        CFBundleSignature
+        Plumb1
+        CFBundleVersion
+        1
+        CFBundleDocumentTypes
+        
+                
+                        CFBundleTypeExtensions
+                        
+                                C
+                                asm
+                                b
+                                c
+                                cc
+                                cgi
+                                cgo
+                                cpp
+                                cs
+                                go
+                                goc
+                                h
+                                java
+                                l
+                                lx
+                                m
+                                ms
+                                pl
+                                py
+                                s
+                                tex
+                                txt
+                                xy
+                                y
+                        
+                        CFBundleTypeIconFile
+                        spaceglenda.icns
+                        CFBundleTypeMIMETypes
+                        
+                                text/plain
+                        
+                        LSItemContentTypes
+                        
+                                public.plain-text
+                                public.source-code
+                        
+                        CFBundleTypeName
+                        Program Files
+                        CFBundleTypeOSTypes
+                        
+                        
+                        CFBundleTypeRole
+                        Viewer
+                
+        
+
+
diff --git a/mac/Plumb.app/Contents/MacOS/plumb b/mac/Plumb.app/Contents/MacOS/plumb
t@@ -0,0 +1,4 @@
+#!/bin/bash
+. ~/.bashrc
+PLAN9=${PLAN9:-/usr/local/plan9}
+$PLAN9/bin/plumb $($PLAN9/bin/macargv)
diff --git a/mac/Plumb.app/Contents/PkgInfo b/mac/Plumb.app/Contents/PkgInfo
t@@ -0,0 +1,2 @@
+APPLPlumb
+
diff --git a/mac/Plumb.app/Contents/Resources/pjw.icns b/mac/Plumb.app/Contents/Resources/pjw.icns
Binary files differ.
diff --git a/mac/spaceglenda.icns b/mac/spaceglenda.icns
Binary files differ.
diff --git a/mac/spaceglenda.png b/mac/spaceglenda.png
Binary files differ.
diff --git a/src/cmd/devdraw/macargv.c b/src/cmd/devdraw/macargv.c
t@@ -0,0 +1,90 @@
+#include 
+#include 
+#include 
+
+AUTOFRAMEWORK(Carbon)
+
+static OSErr Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon);
+
+int
+main(void)
+{
+        AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, Handler, 0, false);
+        RunApplicationEventLoop();
+        return 0;
+}
+
+static OSErr
+GetFullPathname(FSSpec *fss, char *path, int len)
+{
+        FSRef fsr;
+        OSErr err;
+
+        *path = '\0';
+        err = FSpMakeFSRef(fss, &fsr);
+        if (err == fnfErr) {
+                /* FSSpecs can point to non-existing files, fsrefs can't. */
+                FSSpec fss2;
+                int tocopy;
+
+                err = FSMakeFSSpec(fss->vRefNum, fss->parID,
+                                   (unsigned char*)"", &fss2);
+                if (err)
+                        return err;
+                err = FSpMakeFSRef(&fss2, &fsr);
+                if (err)
+                        return err;
+                err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len-1);
+                if (err)
+                        return err;
+                /* This part is not 100% safe: we append the filename part, but
+                ** I'm not sure that we don't run afoul of the various 8bit
+                ** encodings here. Will have to look this up at some point...
+                */
+                strcat(path, "/");
+                tocopy = fss->name[0];
+                if ((strlen(path) + tocopy) >= len)
+                        tocopy = len - strlen(path) - 1;
+                if (tocopy > 0)
+                        strncat(path, (char*)fss->name+1, tocopy);
+        }
+        else {
+                if (err)
+                        return err;
+                err = (OSErr)FSRefMakePath(&fsr, (unsigned char*)path, len);
+                if (err)
+                        return err;
+        }
+        return 0;
+}
+
+static void
+chk(int err)
+{
+        if(err != 0) {
+                printf("err %d\n", err);
+                exit(1);
+        }
+}
+
+static OSErr
+Handler(const AppleEvent *event, AppleEvent *reply, long handlerRefcon)
+{
+        AEDesc list;
+        DescType type;
+        FSSpec f;
+        AEKeyword keyword;
+        Size actual;
+        long len;
+        char s[1000];
+
+        chk(AEGetParamDesc(event, keyDirectObject, typeAEList, &list));
+        chk(AECountItems(&list, &len));
+        chk(AEGetNthPtr(&list, 1, typeFSS, &keyword, &type, (Ptr*)&f, sizeof(FSSpec), &actual));
+        chk(GetFullPathname(&f, s, sizeof s));
+        printf("%s\n", s);
+        fflush(stdout);
+
+        // uncomment to keep handling more open events
+        exit(0);
+}
diff --git a/src/cmd/devdraw/mkfile b/src/cmd/devdraw/mkfile
t@@ -41,3 +41,8 @@ CLEANFILES=latin1.h $O.mklatinkbd
 devdraw-cocoa: devdraw.o latin1.o mouseswap.o winsize.o osx-screen-objc.o osx-draw.o osx-srv-objc.o osx-delegate-objc.o
         $LD -o $target $prereq
 
+install-macargv: $O.macargv
+        install $O.macargv $PLAN9/bin/macargv
+
+$O.macargv: macargv.$O
+        $LD -o $target $prereq
diff --git a/src/cmd/devdraw/mkwsysrules.sh b/src/cmd/devdraw/mkwsysrules.sh
t@@ -52,6 +52,7 @@ elif [ $WSYSTYPE = osx ]; then
                 echo 'LDFLAGS=$LDFLAGS -F/System/Library/PrivateFrameworks'
         fi
         echo 'WSYSOFILES=$WSYSOFILES osx-screen-carbon-objc.o osx-draw.o osx-srv.o'
+        echo 'install: install-macargv'
 elif [ $WSYSTYPE = nowsys ]; then
         echo 'WSYSOFILES=nowsys.o'
 fi
diff --git a/src/cmd/rio/mkfile b/src/cmd/rio/mkfile
t@@ -41,3 +41,6 @@ error.$O: showevent/ShowEvent.c
 $O.xshove: xshove.$O
         $LD -o $O.xshove xshove.$O -lX11
 
+# bug in reusing mksysrules.sh
+install-macargv:
+        true