1: static  char    sccsid[] = "@(#)px_header.c	2.2";   /*	SCCS id keyword	*/
   2: /* Copyright (c) 1979 Regents of the University of California */
   3: 
   4: extern  errno;
   5: 
   6: #define ETXTBSY 26
   7: 
   8: struct header
   9:     {
  10:     int     magic;
  11:     unsigned    txt_size;
  12:     unsigned    data_size;
  13:     unsigned    bss_size;
  14:     unsigned    syms_size;
  15:     unsigned    entry_point;
  16:     unsigned    tr_size;
  17:     unsigned    dr_size;
  18:     };
  19: 
  20: #define HEADER_BYTES    1024
  21: #define ADDR_LC     (HEADER_BYTES-sizeof (struct header))  - sizeof (short)
  22: 
  23: main(argc, argv)
  24:     register int argc;
  25:     register char *argv[];
  26: {
  27:     register int i, j;
  28:     register short *ip;
  29:     int largv[512], pv[2];
  30: 
  31:     if (argc > 510) {
  32:         error("Too many arguments.\n");
  33:         exit(1);
  34:     }
  35:     largv[0] = argv[0];
  36:     largv[1] = "-";
  37:     for (i = 1; i < argc; i++)
  38:         largv[i + 1] = argv[i];
  39:     largv[argc + 1] = 0;
  40:     pipe(pv);
  41:     i = fork();
  42:     if (i == -1)
  43:         error("Try again.\n");
  44:     if (i == 0) {
  45:         close(pv[0]);
  46:         write(pv[1], ADDR_LC, sizeof ( short ));
  47:         ip = ADDR_LC;
  48:         i = *ip++;
  49:         while (i != 0) {
  50:             j = (i > 0 && i < 512) ? i : 512;
  51:             write(pv[1], ip, j);
  52:             ip += 512 / sizeof ( short );
  53:             i -= j;
  54:         }
  55:         exit(1);
  56:     }
  57:     close(pv[1]);
  58:     if (pv[0] != 3) {
  59:         close(3);
  60:         dup(pv[0]);
  61:         close(pv[0]);
  62:     }
  63:     execv("/usr/ucb/px", largv);
  64:     error("Px not found.\n");
  65: }
  66: 
  67: error(cp)
  68:     register char *cp;
  69: {
  70:     register int i;
  71:     register char *dp;
  72: 
  73:     dp = cp;
  74:     i = 0;
  75:     while (*dp++)
  76:         i++;
  77:     write(2, cp, i);
  78:     exit(1);
  79: }
  80: 
  81: exit(i)
  82: {
  83:     _exit(i);
  84: }

Defined functions

error defined in line 67; used 197 times
exit defined in line 81; used 6 times
main defined in line 23; never used

Defined variables

sccsid defined in line 1; never used

Defined struct's

header defined in line 8; never used

Defined macros

ADDR_LC defined in line 21; used 2 times
ETXTBSY defined in line 6; never used
HEADER_BYTES defined in line 20; used 1 times
  • in line 21
Last modified: 1987-07-25
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2305
Valid CSS Valid XHTML 1.0 Strict