Annotation of OpenXM/src/kan96xx/Kan/shell.c, Revision 1.2
1.2 ! takayama 1: /* $OpenXM: OpenXM/src/kan96xx/Kan/shell.c,v 1.1 2003/11/24 12:38:17 takayama Exp $ */
1.1 takayama 2: #include <stdio.h>
3: #include <sys/types.h>
4: #include <sys/stat.h>
5: #include <fcntl.h>
6: #include <stdlib.h>
7: #include <unistd.h>
8: #include <sys/wait.h>
9: #include "datatype.h"
10: #include "stackm.h"
11: #include "extern.h"
12: #include "extern2.h"
13: #include <signal.h>
14: #include "plugin.h"
15: #include "kclass.h"
16: #include <ctype.h>
17: #include "ox_pathfinder.h"
18:
1.2 ! takayama 19: static struct object KoxShell_test1(struct object ob);
! 20:
! 21: struct object KoxShell(struct object ob) {
! 22: return KoxShell_test1(ob);
! 23: }
! 24:
! 25: static struct object KoxShell_test1(struct object ob) {
! 26: /* A simple shell. It does not implement a parser. */
! 27: struct object rob;
! 28: char *cmd;
! 29: char *arg1,*arg2;
! 30: int i,n;
! 31: rob = NullObject; cmd = NULL; arg1=NULL; arg2=NULL;
! 32: if (ob.tag != Sarray) errorKan1("%s\n","KoxShell requires an array as an argument.");
! 33: n = getoaSize(ob);
! 34: for (i=0; i<n; i++) {
! 35: if (getoa(ob,i).tag != Sdollar) errorKan1("%s\n","KoxShell requires an array of string as an argument.");
! 36: }
! 37:
! 38: if (n == 0) return(rob);
! 39: cmd = KopString(getoa(ob,0));
! 40: if (strcmp(cmd,"which")==0) {
! 41: if (n == 2) {
! 42: rob = KoxWhich(getoa(ob,1),KpoInteger(0));
! 43: }else if (n==3) {
! 44: rob = KoxWhich(getoa(ob,1),getoa(ob,2));
! 45: }else{
! 46: errorKan1("%s\n","shell: << which command-name >> or << which command-name path >>");
! 47: }
! 48: return(rob);
! 49: }else if (strcmp(cmd,"export")==0) {
! 50: }else{
! 51: }
! 52: return(rob);
! 53: }
1.1 takayama 54:
55: /* Functions for ox_shell */
56: struct object KoxWhich(struct object cmdo,struct object patho) {
57: struct object rob;
58: char *sss;
59: rob = NullObject;
60: if (cmdo.tag != Sdollar) errorKan1("%s\n","KoxWhich(str-obj,str-obj)");
61: if (patho.tag == Sdollar) {
62: sss=oxWhich(KopString(cmdo),KopString(patho));
63: if (sss != NULL) rob=KpoString(sss);
64: else{
65: sss=getCommandPath(KopString(cmdo));
66: if (sss != NULL) rob=KpoString(sss);
67: }
68: }else{
69: sss=getCommandPath(KopString(cmdo));
70: if (sss != NULL) rob=KpoString(sss);
71: }
72: return(rob);
73: }
74:
75:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>