This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 #include <config.h>
21 #include <stdio.h>
22 #include <alloca.h>
23 #include <string.h>
24 #include <unistd.h>
25
26
27
28
29
30
31
32
33
34
35 int
36 main (int argc, char **argv)
37 {
38 char **args;
39 int i;
40 char *bootclasspath, *emacs_class_path;
41
42
43 args = alloca ((10 + argc) * sizeof *args);
44
45
46 memset (args, 0, (10 + argc) * sizeof *args);
47
48
49 #if defined __x86_64__ || defined __aarch64__
50 args[0] = (char *) "/system/bin/app_process64";
51 #else
52 args[0] = (char *) "/system/bin/app_process";
53 #endif
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69 #if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL
70 if (android_get_device_api_level () < 21)
71 {
72 bootclasspath = NULL;
73 goto skip_setup;
74 }
75 #else
76 if (__ANDROID_API__ < 21)
77 {
78 bootclasspath = NULL;
79 goto skip_setup;
80 }
81 #endif
82
83
84 bootclasspath = getenv ("BOOTCLASSPATH");
85
86 if (!bootclasspath)
87 {
88 fprintf (stderr, "The BOOTCLASSPATH environment variable"
89 " is not set. As a result, Emacs does not know"
90 " how to start app_process.\n"
91 "This is likely a change in the Android platform."
92 " Please report this to bug-gnu-emacs@gnu.org.\n");
93 return 1;
94 }
95
96 skip_setup:
97
98
99 emacs_class_path = getenv ("EMACS_CLASS_PATH");
100
101 if (!emacs_class_path)
102 {
103 fprintf (stderr, "EMACS_CLASS_PATH not set."
104 " Please make sure Emacs is being started"
105 " from within a running copy of Emacs.\n");
106 return 1;
107 }
108
109 if (bootclasspath)
110 {
111 if (asprintf (&bootclasspath, "-Djava.class.path=%s:%s",
112 bootclasspath, emacs_class_path) < 0)
113 {
114 perror ("asprintf");
115 return 1;
116 }
117 }
118 else
119 {
120 if (asprintf (&bootclasspath, "-Djava.class.path=%s",
121 emacs_class_path) < 0)
122 {
123 perror ("asprintf");
124 return 1;
125 }
126 }
127
128 args[1] = bootclasspath;
129 args[2] = (char *) "/system/bin";
130
131 #if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL
132
133
134 if (android_get_device_api_level () >= 26)
135 {
136 args[3] = (char *) "--nice-name=emacs";
137 args[4] = (char *) "org.gnu.emacs.EmacsNoninteractive";
138
139
140
141 args[5] = argv[0];
142
143
144 for (i = 1; i < argc; ++i)
145 args[5 + i] = argv[i];
146 }
147 else
148 {
149 #endif
150 args[3] = (char *) "org.gnu.emacs.EmacsNoninteractive";
151
152
153
154 args[4] = argv[0];
155
156
157 for (i = 1; i < argc; ++i)
158 args[4 + i] = argv[i];
159 #if HAVE_DECL_ANDROID_GET_DEVICE_API_LEVEL
160 }
161 #endif
162
163
164 execvp (args[0], args);
165
166
167 perror ("exec");
168 return 1;
169 }