Lines Matching refs:state
178 pr(State_t* state, Sfio_t* op, Sfio_t* ip, char* file, int perm, struct stat* st, Sfio_t* check) in pr() argument
188 state->oldsum = state->sum; in pr()
190 verify(state, p, file, check); in pr()
191 state->sum = state->oldsum; in pr()
192 if (state->warn && !sfeof(ip)) in pr()
196 suminit(state->sum); in pr()
197 if (state->text) in pr()
207 sumblock(state->sum, "\r", 1); in pr()
217 sumblock(state->sum, p, r - p - (*r == '\n')); in pr()
220 sumblock(state->sum, p, e - p); in pr()
223 sumblock(state->sum, "\r", 1); in pr()
227 sumblock(state->sum, p, sfvalue(ip)); in pr()
230 sumdone(state->sum); in pr()
231 if (!state->total || state->all) in pr()
233 sumprint(state->sum, op, state->flags|SUM_SCALE, state->scale); in pr()
243 …(st->st_uid != state->uid && ((st->st_mode & S_ISUID) || (st->st_mode & S_IRUSR) && !(st->st_mode … in pr()
244 …(st->st_gid != state->gid && ((st->st_mode & S_ISGID) || (st->st_mode & S_IRGRP) && !(st->st_mode … in pr()
258 verify(State_t* state, register char* s, char* check, Sfio_t* rp) in verify() argument
308 pr(state, rp, sp, file, -1, NiL, NiL); in verify()
313 if (state->silent) in verify()
322 if (state->silent) in verify()
331 else if (!state->permissions) in verify()
333 if (state->silent) in verify()
340 else if (!state->permissions) in verify()
342 if (state->silent) in verify()
347 if (state->permissions && (uid >= 0 || gid >= 0)) in verify()
370 if (state->permissions) in verify()
377 else if (state->silent) in verify()
390 if (state->sum != state->oldsum) in verify()
391 sumclose(state->sum); in verify()
392 if (!(state->sum = sumopen(s))) in verify()
396 state->haveperm = 1; in verify()
406 list(State_t* state, register Sfio_t* lp) in list() argument
412 if (sp = openfile(file, state->check ? "rt" : "rb")) in list()
414 pr(state, sfstdout, sp, file, state->permissions, NiL, state->check); in list()
452 State_t state; in b_cksum() local
455 memset(&state, 0, sizeof(state)); in b_cksum()
457 state.flags = SUM_SIZE; in b_cksum()
458 state.warn = 1; in b_cksum()
467 state.all = 1; in b_cksum()
470 state.text = 0; in b_cksum()
473 state.scale = opt_info.num; in b_cksum()
476 if (!(state.check = sfstropen())) in b_cksum()
480 state.header = 1; in b_cksum()
483 state.list = 1; in b_cksum()
486 state.permissions = 1; in b_cksum()
490 state.scale = 512; in b_cksum()
491 state.flags |= SUM_LEGACY; in b_cksum()
495 state.recursive = 1; in b_cksum()
496 state.sort = order; in b_cksum()
503 state.silent = opt_info.num; in b_cksum()
506 state.total = 1; in b_cksum()
509 state.warn = opt_info.num; in b_cksum()
528 state.text = 1; in b_cksum()
547 if (method && !(state.sum = sumopen(method))) in b_cksum()
549 …if (!state.sum && !(state.sum = sumopen(error_info.id)) && !(state.sum = sumopen(astconf("UNIVERSE… in b_cksum()
550 state.sum = sumopen(NiL); in b_cksum()
561 if (state.permissions) in b_cksum()
563 state.uid = geteuid(); in b_cksum()
564 state.gid = getegid(); in b_cksum()
565 state.silent = 0; in b_cksum()
567 if (!state.check && (state.header || state.permissions)) in b_cksum()
569 sfprintf(sfstdout, "method=%s\n", state.sum->name); in b_cksum()
570 if (state.permissions) in b_cksum()
573 if (state.list) in b_cksum()
580 list(&state, sp); in b_cksum()
586 list(&state, sp); in b_cksum()
590 else if (!*argv && !state.recursive) in b_cksum()
591 pr(&state, sfstdout, sfstdin, "/dev/stdin", state.permissions, NiL, state.check); in b_cksum()
592 else if (!(fts = fts_open(argv, flags, state.sort))) in b_cksum()
606 pr(&state, sfstdout, sp, ent->fts_path, state.permissions, ent->fts_statp, state.check); in b_cksum()
625 if (state.total) in b_cksum()
627 sumprint(state.sum, sfstdout, state.flags|SUM_TOTAL|SUM_SCALE, state.scale); in b_cksum()
630 sumclose(state.sum); in b_cksum()