Lines Matching defs:ss

76 "	[+sort -lsync,control=xyz.ss,out02=out.2?Sorts using the"
77 " control file \bxyz.ss\b and places auxiliary file"
90 #include <ss.h>
97 Ss_t* ss;
141 for (f = state->ss->sum; f; f = f->next)
155 Ss_t* ss = state->ss;
169 if (ssannounce(ss, rs))
171 return ss->initexit ? CALLOUT(ss, ss->initexit, NiL, NiL) : 0;
175 if (state->dups && state->dupcount && ss->disc->errorf)
176 (*ss->disc->errorf)(NiL, ss->disc, 0, "%I*u duplicate key%s", sizeof(state->dupcount), state->dupcount, state->dupcount == 1 ? "" : "s");
177 if (!ss->doneexit)
180 c = CALLOUT(ss, ss->doneexit, NiL, NiL);
181 return ssclose(ss) ? -1 : c;
183 if (ss->skip)
185 ss->skip--;
188 if (ss->stop == 1)
191 if (ss->expr && (sseval(ss, ss->expr, (char*)rp->data, rp->datalen) > 0) == ss->omit)
193 fp = ss->file;
194 if (!ss->readexit)
195 c = (ss->copy || !fp->next && (rs->type & RS_IGNORE)) ? RS_DELETE : RS_ACCEPT;
196 else if ((c = CALLOUT(ss, ss->readexit, rp, NiL)) < 0 || c == RS_DELETE)
198 if (ss->stop)
199 ss->stop--;
200 if (ss->in)
202 if ((size = sscopy(ss, &state->in, (char*)rp->data, rp->datalen, state->tmp, ss->insize)) < 0)
207 if (ss->copy)
209 if (fp->group && fp->group->io && sswrite(ss, fp, (char*)rp->data, rp->datalen) < 0)
217 if (!ss->summaryexit)
219 else if ((c = CALLOUT(ss, ss->summaryexit, rp, rp->equal)) < 0 || c == RS_DELETE)
221 if (ss->sum)
223 if (sssum(ss, ss->sum, (char*)ep->data, rp->datalen, (char*)rp->data))
230 if (!ss->writeexit)
236 else if ((c = CALLOUT(ss, ss->writeexit, ep, NiL)) < 0 || c == RS_DELETE)
239 fp = ss->file;
242 else if ((size = sscopy(ss, fp, (char*)ep->data, ep->datalen, (char*)rp->data, rp->datalen)) < 0)
244 if (size > rp->datalen || ss->copy || !fp->next)
259 if (!fp->expr || (sseval(ss, fp->expr, (char*)rp->data, rp->datalen) > 0) != fp->omit)
262 if (sswrite(ss, fp, (char*)rp->data, rp->datalen) < 0)
268 if (save && !hit && sswrite(ss, save, (char*)rp->data, rp->datalen) < 0)
280 checkmark(Ss_t* ss, char** v, Ssdisc_t* ssdisc)
375 Ss_t* ss;
403 ss = 0;
421 if (!(ss = ssopen(opt_info.arg, ssdisc)))
456 if (!ss && !(ss = ssopen(NiL, ssdisc)))
458 if (ss->merge)
481 if (!(v = vmnewof(ss->vm, 0, char*, n, m)))
509 if (checkmark(ss, key->input, ssdisc))
513 ss->mark = 1;
515 ss->suffix = s;
517 if (ss->size)
518 ss->format = REC_F_TYPE(ss->size);
521 ss->size = key->fixed;
522 ss->format = REC_F_TYPE(ss->size);
527 ss->format = REC_N_TYPE();
531 ss->mark = 1;
533 if (f != ss->format && p && (RECTYPE(f) != REC_variable || RECTYPE(ss->format) != REC_variable || REC_V_ATTRIBUTES(f) != REC_V_ATTRIBUTES(ss->format)))
536 (*ssdisc->errorf)(NiL, ssdisc, 2, "%s: format %s incompatible with %s format %s", s, fmtrec(f, 0), p, fmtrec(ss->format, 0));
540 if (RECTYPE(f) != REC_variable || RECTYPE(ss->format) != REC_variable || REC_V_SIZE(ss->format) < REC_V_SIZE(f))
541 ss->format = f;
542 if (!ss->suffix && *u == '.')
543 ss->suffix = u;
546 if (!ss->suffix)
547 ss->suffix = "";
548 if ((n = ssio(ss, list)) < 0)
550 if (ss->mark)
552 if (ss->file->format == REC_N_TYPE())
553 ss->file->format = ss->format;
559 if (ss->file->format != REC_N_TYPE() && f != ss->file->format && !ss->in && !ss->file->out && (RECTYPE(f) != REC_variable || RECTYPE(ss->file->format) != REC_variable || REC_V_ATTRIBUTES(f) != REC_V_ATTRIBUTES(ss->file->format)))
562 (*ssdisc->errorf)(NiL, ssdisc, 2, "%s: format %s incompatible with %s format %s", s, fmtrec(f, 0), p, fmtrec(ss->file->format, 0));
566 else if (ss->file->format != REC_N_TYPE() && !strmatch(s, "/dev/*"))
569 s = sfprints("%-.*s%%%s%s", t - s, s, fmtrec(ss->format, 1), t);
571 s = sfprints("%s%%%s%s", s, fmtrec(ss->format, 1), ss->suffix);
572 if (!(key->output = vmstrdup(ss->vm, s)))
574 if (ss->disc->errorf)
575 (*ss->disc->errorf)(NiL, ss->disc, ERROR_SYSTEM|2, "out of space");
581 if (ss->copy && !ss->expr && !ss->file->out && !ss->file->next)
587 if (ss->initexit)
589 if (ss->expr || ss->copy || ss->readexit || ss->in || ss->skip || ss->stop)
591 if (ss->file->out || n && !ss->copy || ss->writeexit || ss->file->format != ss->format)
595 sslist(ss, sfstdout);
598 if (!(state = vmnewof(ss->vm, 0, State_t, 1, ss->insize)))
604 if (ss->in)
606 state->in.out = ss->in;
607 state->in.size = ss->insize;
609 if (ss->sum || ss->uniq)
612 if (ss->sum)
617 switch (ss->stable)
626 if (!ss->type)
627 ss->type = 'F';
628 switch (ss->type)
633 if ((s = sskey(ss, NiL)) && rskey(key, s, 0))
641 for (dp = ss->sort; dp; dp = dp->next)
642 if ((s = sskey(ss, dp)) && rskey(key, s, 0))
646 if (!(state->junksize = ss->size))
648 if (!(state->junkcount = vmnewof(ss->vm, 0, Sfulong_t, state->junksize, 0)))
661 state->ss = ss;
666 if (ss)
667 ssclose(ss);