/* * Read patterns from file. */ void patfile(char *fn) { struct stat st; struct expr *e = NULL; char *cp; struct iblok *ip; size_t sz, len; int nl; if ((ip = ib_open(fn, 0)) == NULL || fstat(ip->ib_fd, &st) < 0) { fprintf(stderr, "%s: can't open %s\n", progname, fn); exit(2); } if (e0) { if (sus) for (e = e0; e->e_nxt; e = e->e_nxt); else e0 = NULL; } while (cp = NULL, sz = 0, (len = ib_getlin(ip, &cp, &sz, srealloc)) > 0) { if ((nl = cp[len - 1] == '\n') != 0) cp[len - 1] = '\0'; addpat(&e, cp, len - nl, nl); } ib_close(ip); }
/** * Shut down CMRC connection gracefully * * @v cmrc Communication-Managed Reliable Connection * * The Infiniband data structures are not reference-counted or * guarded. It is therefore unsafe to shut them down while we may be * in the middle of a callback from the Infiniband stack (e.g. in a * receive completion handler). * * This shutdown process will run some time after the call to * ib_cmrc_close(), after control has returned out of the Infiniband * core, and will shut down the Infiniband interfaces cleanly. * * The shutdown process holds an implicit reference on the CMRC * connection, ensuring that the structure is not freed before the * shutdown process has run. */ static void ib_cmrc_shutdown ( struct ib_cmrc_connection *cmrc ) { DBGC ( cmrc, "CMRC %p shutting down\n", cmrc ); /* Shut down Infiniband interface */ ib_destroy_conn ( cmrc->ibdev, cmrc->qp, cmrc->conn ); ib_destroy_qp ( cmrc->ibdev, cmrc->qp ); ib_destroy_cq ( cmrc->ibdev, cmrc->cq ); ib_close ( cmrc->ibdev ); /* Drop the remaining reference */ ref_put ( &cmrc->refcnt ); }
int main(int argc, char **argv) { int c; char *termtype; #ifdef USE_TERMCAP char termcap[2048]; #endif struct iblok *f; progname = basename(argv[0]); setlocale(LC_CTYPE, ""); mb_cur_max = MB_CUR_MAX; termtype = getenv("TERM"); if (termtype == NULL || (progname[0] == 'c' && !isatty(1))) termtype = "lpr"; while ((c=getopt(argc, argv, "it:T:?")) != EOF) switch(c) { case 't': case 'T': /* for nroff compatibility */ termtype = optarg; break; case 'i': iflag = 1; break; default: fprintf(stderr, "Usage: %s [ -i ] [ -tTerm ] file...\n", progname); exit(1); } #ifndef USE_TERMCAP setupterm(termtype, 1, &c); if (c < 0) fprintf(stderr,"trouble reading termcap"); if (c <= 0) termtype = "dumb"; #else /* USE_TERMCAP */ switch (tgetent(termcap, termtype)) { case 1: break; default: fprintf(stderr,"trouble reading termcap"); /*FALLTHRU*/ case 0: strcpy(termcap, "dumb:os:col#80:cr=^M:sf=^J:am:"); } initcap(); #endif /* USE_TERMCAP */ if ( (over_strike && enter_bold_mode==NULL ) || (transparent_underline && enter_underline_mode==NULL && underline_char==NULL)) must_overstrike = 1; initbuf(); if (optind == argc) filtr(ib_alloc(0, 0)); else for (; optind<argc; optind++) { f = ib_open(argv[optind], 0); if (f == NULL) { perror(argv[optind]); exit(1); } else { filtr(f); ib_close(f); } } exit(0); }