DEADSOFTWARE

Mirror gpcp-32255
[gpcp-linux.git] / libs / java / ProgArgs.java
1 //
2 // Body of ProgArgs interface.
3 // This file implements the code of the ProgArgs.cp file.
4 // kjg December 1999.
5 //
6 // The reason that this module is implemented as a Java class is
7 // that the name CPmain has special meaning to the compiler, so
8 // it must be imported secretly in the implementation.
9 //
11 package CP.ProgArgs;
12 import CP.CPmain.CPmain;
14 public class ProgArgs
15 {
17 public static int ArgNumber()
18 {
19 if (CP.CPmain.CPmain.args == null)
20 return 0;
21 else
22 return CP.CPmain.CPmain.args.length;
23 }
25 public static void GetArg(int num, char[] str)
26 {
27 int i;
28 if (CP.CPmain.CPmain.args == null) {
29 str[0] = '\0';
30 } else {
31 for (i = 0;
32 i < str.length && i < CP.CPmain.CPmain.args[num].length();
33 i++) {
34 str[i] = CP.CPmain.CPmain.args[num].charAt(i);
35 }
36 if (i == str.length)
37 i--;
38 str[i] = '\0';
39 }
40 }
42 public static void GetEnvVar(char[] ss, char[] ds)
43 {
44 String path = CP.CPJ.CPJ.MkStr(ss);
45 String valu = System.getProperty(path);
46 int i;
47 for (i = 0;
48 i < valu.length() && i < ds.length;
49 i++) {
50 ds[i] = valu.charAt(i);
51 }
52 if (i == ds.length)
53 i--;
54 ds[i] = '\0';
55 }
57 } // end of public class ProgArgs