version 1.10, 2004/02/05 10:35:04 |
version 1.14, 2005/07/03 11:08:54 |
|
|
/* $OpenXM: OpenXM/src/kan96xx/Kan/shell.c,v 1.9 2003/12/13 13:29:44 takayama Exp $ */ |
/* $OpenXM: OpenXM/src/kan96xx/Kan/shell.c,v 1.13 2005/06/16 05:07:23 takayama Exp $ */ |
#include <stdio.h> |
#include <stdio.h> |
|
#include <string.h> |
#include <sys/types.h> |
#include <sys/types.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <fcntl.h> |
#include <fcntl.h> |
Line 108 void KoxShellHelp(char *key,FILE *fp) { |
|
Line 109 void KoxShellHelp(char *key,FILE *fp) { |
|
|
|
static struct object KoxShell_test1(struct object ob) { |
static struct object KoxShell_test1(struct object ob) { |
/* A simple shell. It does not implement a parser. */ |
/* A simple shell. It does not implement a parser. */ |
struct object rob; |
struct object rob = OINIT; |
char *cmd; |
char *cmd; |
char *arg1,*arg2; |
char *arg1,*arg2; |
int i,n; |
int i,n; |
Line 125 static struct object KoxShell_test1(struct object ob) |
|
Line 126 static struct object KoxShell_test1(struct object ob) |
|
rob = testmain(ob); |
rob = testmain(ob); |
}else if (strcmp(cmd,"which")==0) { |
}else if (strcmp(cmd,"which")==0) { |
if (n == 2) { |
if (n == 2) { |
|
pathFinderErrorVerbose(0); |
rob = KoxWhich(getoa(ob,1),KpoInteger(0)); |
rob = KoxWhich(getoa(ob,1),KpoInteger(0)); |
|
pathFinderErrorVerbose(-1); |
}else if (n==3) { |
}else if (n==3) { |
|
pathFinderErrorVerbose(0); |
rob = KoxWhich(getoa(ob,1),getoa(ob,2)); |
rob = KoxWhich(getoa(ob,1),getoa(ob,2)); |
|
pathFinderErrorVerbose(-1); |
}else{ |
}else{ |
errorKan1("%s\n","shell: << which command-name >> or << which command-name path >>"); |
errorKan1("%s\n","shell: << which command-name >> or << which command-name path >>"); |
} |
} |
Line 155 static struct object KoxShell_test1(struct object ob) |
|
Line 160 static struct object KoxShell_test1(struct object ob) |
|
|
|
/* Functions for ox_shell */ |
/* Functions for ox_shell */ |
struct object KoxWhich(struct object cmdo,struct object patho) { |
struct object KoxWhich(struct object cmdo,struct object patho) { |
struct object rob; |
struct object rob = OINIT; |
char *sss; |
char *sss; |
rob = NullObject; |
rob = NullObject; |
if (cmdo.tag != Sdollar) errorKan1("%s\n","KoxWhich(str-obj,str-obj)"); |
if (cmdo.tag != Sdollar) errorKan1("%s\n","KoxWhich(str-obj,str-obj)"); |
Line 180 static int mysetenv(char *name, char *value, int overw |
|
Line 185 static int mysetenv(char *name, char *value, int overw |
|
char *orig; |
char *orig; |
s = (char *)getenv(name); |
s = (char *)getenv(name); |
if ((s == NULL) || overwrite) { |
if ((s == NULL) || overwrite) { |
s = (char *) malloc(strlen(name)+strlen(value)+5); |
s = (char *) mymalloc(strlen(name)+strlen(value)+5); |
if (s == 0) { fprintf(stderr,"No more memory.\n"); exit(10); } |
if (s == 0) { fprintf(stderr,"No more memory.\n"); exit(10); } |
strcpy(s,name); |
strcpy(s,name); |
strcat(s,"="); strcat(s,value); |
strcat(s,"="); strcat(s,value); |
Line 197 static myunsetenv(char *name) { |
|
Line 202 static myunsetenv(char *name) { |
|
|
|
/* Example. [(export) (PATH) (=) (/usr/new/bin:$PATH)] */ |
/* Example. [(export) (PATH) (=) (/usr/new/bin:$PATH)] */ |
static struct object oxsSetenv(struct object ob) { |
static struct object oxsSetenv(struct object ob) { |
struct object rob; |
struct object rob = OINIT; |
int i,n; |
int i,n; |
char *envp; |
char *envp; |
char *new; |
char *new; |
Line 371 char *oxsURIgetFileName(char *s) { |
|
Line 376 char *oxsURIgetFileName(char *s) { |
|
|
|
|
|
static struct object testmain(struct object ob) { |
static struct object testmain(struct object ob) { |
struct object rob; |
struct object rob = OINIT; |
char *s; |
char *s; |
struct object ot; |
struct object ot = OINIT; |
char **av; |
char **av; |
int i; |
int i; |
rob = NullObject; |
rob = NullObject; |
Line 402 char *oxsVarToFile(char *v,char *ext,char *command,int |
|
Line 407 char *oxsVarToFile(char *v,char *ext,char *command,int |
|
FILE *fp; |
FILE *fp; |
int n,i,prevc,c; |
int n,i,prevc,c; |
char *prog; |
char *prog; |
struct object vv; |
struct object vv = OINIT; |
|
|
/*bug; winname must be automatically set by looking at command. |
/*bug; winname must be automatically set by looking at command. |
If command is win32-native-application, then winname=1; else winname=0. |
If command is win32-native-application, then winname=1; else winname=0. |
Line 484 static char **oxsBuildArgv(struct object ob) { |
|
Line 489 static char **oxsBuildArgv(struct object ob) { |
|
char *ext, *v; |
char *ext, *v; |
int usetmp=1; |
int usetmp=1; |
int win=0; |
int win=0; |
struct object ocmd; |
struct object ocmd = OINIT; |
|
|
/* bug: win variable must be properly set on windows native. */ |
/* bug: win variable must be properly set on windows native. */ |
|
|