2 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
6 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
7 /* All Rights Reserved */
10 * Copyright (c) 1980 Regents of the University of California.
11 * All rights reserved. The Berkeley software License Agreement
12 * specifies the terms and conditions for redistribution.
15 #pragma ident "%Z%%M% %I% %E% SMI"
24 extern int soutlen
, iflong
;
25 extern long indexdate
;
33 extern long findline();
35 static int auxil(char *, char *);
38 baddrop(unsigned *mptr
, int nf
, FILE *fc
, int nitem
,
39 char *qitem
[], char *rprog
, int full
)
41 /* checks list of drops for real bad drops; finds items with "deliv" */
42 int i
, g
, j
, need
, got
, na
, len
;
44 char res
[100], *ar
[50], output
[TXTLEN
], *mput
;
46 extern int colevel
, reached
;
49 master
.b
= (long *)mptr
;
56 fprintf(stderr
, "in baddrop, nf %d master %ld %ld %ld\n",
57 nf
, master
.b
[0], master
.b
[1], master
.b
[2]);
59 fprintf(stderr
, "in baddrop, nf %d master %d %d %d\n",
60 nf
, master
.a
[0], master
.a
[1], master
.a
[2]);
62 for (i
= g
= 0; i
< nf
; i
++) {
63 lp
= iflong
? master
.b
[i
] : master
.a
[i
];
66 fprintf(stderr
, "i %d master %lo lp %lo\n",
69 fprintf(stderr
, "i %d master %o lp %lo\n",
75 fprintf(stderr
, "tag %s", res
);
77 if (!auxil(res
, output
)) {
81 fprintf(stderr
, "not auxil try rprog %c\n",
84 for (s
= res
; c
= *s
; s
++)
85 if (c
== ';' || c
== '\n') {
91 len
= corout(res
, output
, rprog
, "", TXTLEN
);
93 len
= findline(res
, &mput
, TXTLEN
, indexdate
);
94 if (len
> 0) { /* copy and free */
95 strncpy(output
, mput
, TXTLEN
);
97 } else /* insufficient memory or other... */
102 assert(len
< TXTLEN
);
103 fprintf(stderr
, "item %d of %d, tag %s len %d output\n%s\n..\n",
104 i
, nf
, res
, len
, output
);
108 need
= colevel
? reached
: nitem
;
113 ar
[na
++] = (char *)need
;
116 ar
[na
++] = (char *)len
;
117 for (j
= 0; j
< nitem
; j
++)
120 fprintf(stderr
, "calling fgrep len %d ar[4] %s %o %d \n",
121 len
, ar
[4], ar
[5], ar
[6]);
123 if (fgrep(na
, ar
) == 0) {
125 fprintf(stderr
, "fgrep found it\n");
128 master
.b
[g
++] = master
.b
[i
];
130 master
.a
[g
++] = master
.a
[i
];
133 fputs(output
, stdout
);
135 strcpy(soutput
, output
);
138 fprintf(stderr
, "after fgrep\n");
145 auxil(char *res
, char *output
)
154 sscanf(res
, "%ld,%d", &lp
, &len
);
156 fgets(output
, len
, fd
);