|
|
1.1 root 1: #include "String.h"
2:
3: int
4: stat(const String& s1, struct stat* x)
5: {
6: const String x1 = s1 + (char)0;
7: return stat(x1.d->start, x);
8: }
9:
10: int
11: system(const String& s1)
12: {
13: const String x1 = s1 + (char)0;
14: return system(x1.d->start);
15: }
16:
17: int
18: access(const String& s1, int i1)
19: {
20: const String x1 = s1 + (char)0;
21: return access(x1.d->start, i1);
22: }
23:
24: int
25: acct(const String& s1)
26: {
27: const String x1 = s1 + (char)0;
28: return acct(x1.d->start);
29: }
30:
31: int
32: chdir(const String& s1)
33: {
34: const String x1 = s1 + (char)0;
35: return chdir(x1.d->start);
36: }
37:
38: int
39: chmod(const String& s1, int i1)
40: {
41: const String x1 = s1 + (char)0;
42: return chmod(x1.d->start, i1);
43: }
44:
45: int
46: chown(const String& s1, int i1, int i2)
47: {
48: const String x1 = s1 + (char)0;
49: return chown(x1.d->start, i1, i2);
50: }
51:
52: int
53: creat(const String& s1, int i1)
54: {
55: const String x1 = s1 + (char)0;
56: return creat(x1.d->start, i1);
57: }
58:
59: int
60: link(const String& s1, const String& s2)
61: {
62: const String x1 = s1 + (char)0;
63: const String x2 = s2 + (char)0;
64: return link(x1.d->start, x2.d->start);
65: }
66:
67: int
68: mknod(const String& s1, int i1, int i2)
69: {
70: const String x1 = s1 + (char)0;
71: return mknod(x1.d->start, i1, i2);
72: }
73:
74: int
75: open(const String& s1, int i1)
76: {
77: const String x1 = s1 + (char)0;
78: return open(x1.d->start, i1);
79: }
80:
81: int
82: unlink(const String& s1)
83: {
84: const String x1 = s1 + (char)0;
85: return unlink(x1.d->start);
86: }
87:
88: int
89: read(int fildes, String& buffer, int nbytes)
90: {
91: int ans;
92: switch (nbytes) {
93: case 0:
94: if (read(fildes, "", 0))
95: return -1;
96: else buffer = "";
97: return 0;
98: case 1: {
99: char c;
100: switch (ans = read(fildes, &c, 1)) {
101: case 0:
102: buffer = "";
103: break;
104: case 1:
105: buffer = c;
106: break;
107: }
108: return ans;
109: }
110: }
111: Rep* temp = new Rep(nbytes);
112: if ((ans = read(fildes, temp->start, nbytes)) < nbytes)
113: switch (ans) {
114: case 0:
115: buffer = "";
116: case -1:
117: delete temp;
118: break;
119: case 1:
120: buffer = *temp->start;
121: delete temp;
122: break;
123: default:
124: {
125: temp->extend(ans - nbytes);
126: buffer = String(*temp);
127: temp->refDecr();
128: }
129: break;
130: }
131: return ans;
132: }
133:
134: int
135: write(int fildes, const String& s1)
136: {
137: return write(fildes, s1.d->start, s1.length());
138: }
139:
140:
141: FILE*
142: fopen(const String& s1, const String& s2)
143: {
144: const String x1 = s1 + (char)0;
145: const String x2 = s2 + (char)0;
146: return fopen(x1.d->start, x2.d->start);
147: }
148:
149: FILE*
150: fdopen(int i, const String& s1)
151: {
152: const String x1 = s1 + (char)0;
153: return fdopen(i, x1.d->start);
154: }
155:
156: FILE*
157: freopen(const String& s1, const String& s2, FILE* f)
158: {
159: const String x1 = s1 + (char)0;
160: const String x2 = s2 + (char)0;
161: return freopen(x1.d->start, x2.d->start, f);
162: }
163:
164: FILE*
165: popen(const String& s1, const String& s2)
166: {
167: const String x1 = s1 + (char)0;
168: const String x2 = s2 + (char)0;
169: return popen(x1.d->start, x2.d->start);
170: }
171:
172: int
173: fgets(String& s1, int n, FILE* iop)
174: {
175: register c;
176: s1 = "";
177: while (--n>0 && (c = getc(iop))>=0) {
178: s1 += c;
179: if (c=='\n')
180: break;
181: }
182: if (c<0 && s1.length()==0)
183: return 0;
184: return 1;
185: }
186:
187: int
188: gets(String& s1)
189: {
190: register c;
191:
192: s1 = "";
193: while ((c = getchar()) != '\n' && c >= 0)
194: s1 += c;
195: if (c<0 && s1.length()==0)
196: return 0;
197: return 1;
198: }
199:
200: int
201: puts(const String& s1)
202: {
203: register char* s = s1.d->start;
204: register char* e = s + s1.d->len;
205: register c;
206:
207: while (s < e) {
208: c = *s++;
209: putchar(c);
210: }
211: return(putchar('\n'));
212: }
213:
214: int
215: fputs(const String& s1, FILE* iop)
216: {
217: register char* s = s1.d->start;
218: register char* e = s + s1.d->len;
219: register r;
220: register c;
221:
222: while (s < e) {
223: c = *s++;
224: r = putc(c, iop);
225: }
226: return(r);
227: }
228:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.