Changeset 1229 in kBuild for trunk/src/kash
- Timestamp:
- Oct 8, 2007 10:29:04 PM (17 years ago)
- Location:
- trunk/src/kash
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kash/main.c
r1222 r1229 450 450 { 451 451 size_t len; 452 strip_argv0(argv0, &len);452 argv0 = strip_argv0(argv0, &len); 453 453 454 454 fprintf(stdout, -
trunk/src/kash/output.c
r1218 r1229 109 109 file->fd = BLOCK_OUT; 110 110 file->flags = 0; 111 file->psh = psh; 111 112 } 112 113 #endif -
trunk/src/kash/shinstance.c
r1225 r1229 42 42 shinstance *psh; 43 43 44 psh = malloc(sizeof(*psh));44 psh = calloc(sizeof(*psh), 1); 45 45 if (psh) 46 46 { 47 memset(psh, 0, sizeof(*psh));48 49 47 /* memalloc.c */ 50 48 psh->stacknleft = MINSIZE; … … 61 59 psh->output.bufsize = OUTBUFSIZ; 62 60 psh->output.fd = 1; 61 psh->output.psh = psh; 63 62 psh->errout.bufsize = 100; 64 63 psh->errout.fd = 2; 64 psh->errout.psh = psh; 65 65 psh->memout.fd = MEM_OUT; 66 psh->memout.psh = psh; 66 67 psh->out1 = &psh->output; 67 68 psh->out2 = &psh->errout; … … 81 82 char *sh_getenv(shinstance *psh, const char *var) 82 83 { 84 #ifdef SH_PURE_STUB_MODE 83 85 return NULL; 86 #elif defined(SH_STUB_MODE) 87 return getenv(var); 88 #else 89 #endif 84 90 } 85 91 86 92 char **sh_environ(shinstance *psh) 87 93 { 94 #ifdef SH_PURE_STUB_MODE 88 95 static char *s_null[2] = {0,0}; 89 96 return &s_null[0]; 97 #elif defined(SH_STUB_MODE) 98 return environ; 99 #else 100 #endif 90 101 } 91 102 92 103 const char *sh_gethomedir(shinstance *psh, const char *user) 93 104 { 105 #ifdef SH_PURE_STUB_MODE 94 106 return NULL; 107 #elif defined(SH_STUB_MODE) 108 # ifdef _MSC_VER 109 return NULL; 110 # else 111 struct passwd *pwd = getpwnam(user); 112 return pwd ? pwd->pw_dir; 113 # endif 114 #else 115 #endif 95 116 } 96 117 97 118 int sh_sigaction(int signo, const struct sh_sigaction *newp, struct sh_sigaction *oldp) 98 119 { 99 return -1; 120 #ifdef SH_PURE_STUB_MODE 121 return -1; 122 #elif defined(SH_STUB_MODE) 123 # ifdef _MSC_VER 124 return -1; 125 # else 126 struct sigaction old; 127 if (newp) 128 return -1; 129 if (sigaction(signo, NULL, &old)) 130 return -1; 131 oldp->sh_flags = old.sa_flags; 132 oldp->sh_handler = old.sa_handler; 133 oldp->sh_mask = old.sa_mask; 134 return 0; 135 # endif 136 #else 137 #endif 100 138 } 101 139 … … 112 150 void sh_sigemptyset(sh_sigset_t *setp) 113 151 { 114 152 memset(setp, 0, sizeof(*setp)); 115 153 } 116 154 … … 122 160 void sh_abort(shinstance *psh) 123 161 { 162 #ifdef SH_PURE_STUB_MODE 163 #elif defined(SH_STUB_MODE) 164 abort(); 165 #else 166 #endif 124 167 } 125 168 126 169 void sh_raise_sigint(shinstance *psh) 127 170 { 128 171 #ifdef SH_PURE_STUB_MODE 172 #elif defined(SH_STUB_MODE) 173 raise(SIGINT); 174 #else 175 #endif 129 176 } 130 177 131 178 int sh_kill(shinstance *psh, pid_t pid, int signo) 132 179 { 133 return -1; 180 #ifdef SH_PURE_STUB_MODE 181 return -1; 182 #elif defined(SH_STUB_MODE) 183 # ifdef _MSC_VER 184 return -1; 185 # else 186 return kill(pid, signo); 187 # endif 188 #else 189 #endif 134 190 } 135 191 136 192 int sh_killpg(shinstance *psh, pid_t pgid, int signo) 137 193 { 138 return -1; 194 #ifdef SH_PURE_STUB_MODE 195 return -1; 196 #elif defined(SH_STUB_MODE) 197 # ifdef _MSC_VER 198 return -1; 199 # else 200 return killpg(pgid, signo); 201 # endif 202 #else 203 #endif 139 204 } 140 205 141 206 clock_t sh_times(shinstance *psh, shtms *tmsp) 142 207 { 143 return 0; 208 #ifdef SH_PURE_STUB_MODE 209 return 0; 210 #elif defined(SH_STUB_MODE) 211 # ifdef _MSC_VER 212 return 0; 213 # else 214 return times(tmsp); 215 # endif 216 #else 217 #endif 144 218 } 145 219 146 220 int sh_sysconf_clk_tck(void) 147 221 { 222 #ifdef SH_PURE_STUB_MODE 148 223 return 1; 224 #else 225 # ifdef _MSC_VER 226 return CLK_TCK; 227 # else 228 return sysconf(_SC_CLK_TCK) 229 # endif 230 #endif 149 231 } 150 232 151 233 pid_t sh_fork(shinstance *psh) 152 234 { 153 return -1; 235 #ifdef SH_PURE_STUB_MODE 236 return -1; 237 #elif defined(SH_STUB_MODE) 238 # ifdef _MSC_VER 239 return -1; 240 # else 241 return fork(); 242 # endif 243 #else 244 #endif 154 245 } 155 246 156 247 pid_t sh_waitpid(shinstance *psh, pid_t pid, int *statusp, int flags) 157 248 { 158 return -1; 249 #ifdef SH_PURE_STUB_MODE 250 return -1; 251 #elif defined(SH_STUB_MODE) 252 # ifdef _MSC_VER 253 return -1; 254 # else 255 return waitpid(pid, statusp, flags); 256 # endif 257 #else 258 #endif 159 259 } 160 260 161 261 void sh__exit(shinstance *psh, int rc) 162 262 { 263 #ifdef SH_PURE_STUB_MODE 264 return -1; 265 #elif defined(SH_STUB_MODE) 266 _exit(rc); 267 #else 268 #endif 163 269 } 164 270 165 271 int sh_execve(shinstance *psh, const char *exe, const char * const *argv, const char * const *envp) 166 272 { 167 return -1; 273 #ifdef SH_PURE_STUB_MODE 274 return -1; 275 #elif defined(SH_STUB_MODE) 276 # ifdef _MSC_VER 277 return -1; 278 # else 279 return execve(exe, (char **)argv, (char **)envp); 280 # endif 281 #else 282 #endif 168 283 } 169 284 170 285 uid_t sh_getuid(shinstance *psh) 171 286 { 172 return 0; 287 #ifdef SH_PURE_STUB_MODE 288 return 0; 289 #elif defined(SH_STUB_MODE) 290 # ifdef _MSC_VER 291 return 0; 292 # else 293 return getuid(); 294 # endif 295 #else 296 #endif 173 297 } 174 298 175 299 uid_t sh_geteuid(shinstance *psh) 176 300 { 177 return 0; 301 #ifdef SH_PURE_STUB_MODE 302 return 0; 303 #elif defined(SH_STUB_MODE) 304 # ifdef _MSC_VER 305 return 0; 306 # else 307 return geteuid(); 308 # endif 309 #else 310 #endif 178 311 } 179 312 180 313 gid_t sh_getgid(shinstance *psh) 181 314 { 182 return 0; 315 #ifdef SH_PURE_STUB_MODE 316 return 0; 317 #elif defined(SH_STUB_MODE) 318 # ifdef _MSC_VER 319 return 0; 320 # else 321 return getgid(); 322 # endif 323 #else 324 #endif 183 325 } 184 326 185 327 gid_t sh_getegid(shinstance *psh) 186 328 { 187 return 0; 329 #ifdef SH_PURE_STUB_MODE 330 return 0; 331 #elif defined(SH_STUB_MODE) 332 # ifdef _MSC_VER 333 return 0; 334 # else 335 return getegid(); 336 # endif 337 #else 338 #endif 188 339 } 189 340 190 341 pid_t sh_getpid(shinstance *psh) 191 342 { 192 return 0; 343 #ifdef SH_PURE_STUB_MODE 344 return 0; 345 #elif defined(SH_STUB_MODE) 346 # ifdef _MSC_VER 347 return _getpid(); 348 # else 349 return getpid(); 350 # endif 351 #else 352 #endif 193 353 } 194 354 195 355 pid_t sh_getpgrp(shinstance *psh) 196 356 { 197 return 0; 357 #ifdef SH_PURE_STUB_MODE 358 return 0; 359 #elif defined(SH_STUB_MODE) 360 # ifdef _MSC_VER 361 return _getpid(); 362 # else 363 return getpgrp(); 364 # endif 365 #else 366 #endif 198 367 } 199 368 200 369 pid_t sh_getpgid(shinstance *psh, pid_t pid) 201 370 { 371 #ifdef SH_PURE_STUB_MODE 202 372 return pid; 373 #elif defined(SH_STUB_MODE) 374 # ifdef _MSC_VER 375 return pid; 376 # else 377 return getpgid(pid); 378 # endif 379 #else 380 #endif 203 381 } 204 382 205 383 int sh_setpgid(shinstance *psh, pid_t pid, pid_t pgid) 206 384 { 207 return -1; 385 #ifdef SH_PURE_STUB_MODE 386 return -1; 387 #elif defined(SH_STUB_MODE) 388 # ifdef _MSC_VER 389 return -1; 390 # else 391 return setpgid(pid, pgid); 392 # endif 393 #else 394 #endif 208 395 } 209 396 210 397 pid_t sh_tcgetpgrp(shinstance *psh, int fd) 211 398 { 212 return -1; 399 #ifdef SH_PURE_STUB_MODE 400 return -1; 401 #elif defined(SH_STUB_MODE) 402 # ifdef _MSC_VER 403 return -1; 404 # else 405 return tcgetpgrp(fd); 406 # endif 407 #else 408 #endif 213 409 } 214 410 215 411 int sh_tcsetpgrp(shinstance *psh, int fd, pid_t pgrp) 216 412 { 217 return -1; 413 #ifdef SH_PURE_STUB_MODE 414 return -1; 415 #elif defined(SH_STUB_MODE) 416 # ifdef _MSC_VER 417 return -1; 418 # else 419 return tcsetpgrp(fd, pgrp); 420 # endif 421 #else 422 #endif 218 423 } 219 424 220 425 int sh_getrlimit(shinstance *psh, int resid, shrlimit *limp) 221 426 { 222 return -1; 427 #ifdef SH_PURE_STUB_MODE 428 return -1; 429 #elif defined(SH_STUB_MODE) 430 # ifdef _MSC_VER 431 return -1; 432 # else 433 return getrlimit(resid, limp); 434 # endif 435 #else 436 #endif 223 437 } 224 438 225 439 int sh_setrlimit(shinstance *psh, int resid, const shrlimit *limp) 226 440 { 227 return -1; 228 } 229 441 #ifdef SH_PURE_STUB_MODE 442 return -1; 443 #elif defined(SH_STUB_MODE) 444 # ifdef _MSC_VER 445 return -1; 446 # else 447 return setrlimit(resid, limp); 448 # endif 449 #else 450 #endif 451 } 452 -
trunk/src/kash/shinstance.h
r1225 r1229 200 200 int njobs; /**< size of array */ 201 201 int jobs_invalid; /**< set in child */ 202 #if JOBS203 202 int initialpgrp; /**< pgrp of shell on invocation */ 204 203 int curjob/* = -1*/;/**< current job */ 205 #endif206 204 int ttyfd/* = -1*/; 207 205 int jobctl; /**< job control enabled / disabled */ 208 206 char *cmdnextc; 209 207 int cmdnleft; 208 210 209 211 210 /* mail.c */ … … 290 289 /* var.h */ 291 290 struct localvar *localvars; 292 #if ATTY293 291 struct var vatty; 294 #endif295 292 struct var vifs; 296 293 struct var vmail;
Note:
See TracChangeset
for help on using the changeset viewer.