All pastes #263127 Raw Edit

Unnamed

public c v1 · immutable
·published 2006-12-01 05:28 UTC
rendered paste body
#include <stdio.h>struct _state_flags {   const char *_name;   int _mask;   const char *_descr;} state_flags[] = {   {"SLBF",  0x0001, "line buffered"},   {"SNBF",  0x0002, "unbuffered"},   {"SRD",   0x0004, "OK to read"},   {"SWR",   0x0008, "OK to write"},   {"SRW",   0x0010, "open for reading & writing"},   {"SEOF",  0x0020, "found EOF"},   {"SERR",  0x0040, "found error"},   {"SMBF",  0x0080, "_buf is from malloc"},   {"SAPP",  0x0100, "fdopen()ed in append mode"},   {"SSTR",  0x0200, "this is an sprintf/snprintf string"},   {"SOPT",  0x0400, "do fseek() optimization"},   {"SNPT",  0x0800, "do not do fseek() optimization"},   {"SOFF",  0x1000, "set iff _offset is in fact correct"},   {"SMOD",  0x2000, "true => fgetln modified _p text"},   {"SALC",  0x4000, "allocate string space dynamically"},   {"SAFE",  0x8000, "don't call signal-unsafe functions"},   {NULL, 0, NULL}};void print_state_flags(FILE *fp){   struct _state_flags *psf;   for (psf = state_flags; psf; psf++) {      if ((psf->_name == NULL)          && (psf->_mask == 0)          && (psf->_descr == NULL))         break;      printf("%-40s [ %-4s ]: %s\n",             psf->_descr,             psf->_name,             (fp->_flags & psf->_mask) ? "yes" : "no");   }}void print_file_structure(FILE *fp){   printf("current position: %p\n", fp->_p);   printf("read space: %d\n", fp->_r);   printf("write space: %d\n", fp->_w);   printf("current lseek offset: %d\n", fp->_offset);}