int sys826_open() { uint i; int nboards = 0; // no boards detected at any board index int errnum = S826_ERR_OK; // no errors so far for (i = 0; i < S826_MAX_BOARDS; i++) { // For each driver-enumerated board (in range 0 to boardcount-1) ... // Open board and get its handle. ixinfo[i].hboard = OpenBoard(i, &errnum); if (ixinfo[i].hboard == -1) // Done if no more boards detected break; // Get board's base memory address. errnum = GetBoardAddress(ixinfo[i].hboard, (void **) &ixinfo[i].baseadr); if (errnum != S826_ERR_OK) break; // Create board mutex. ixinfo[i].hmutex = sys826_create_lock(i); // Attempt to create a mutex. if (ixinfo[i].hmutex == -1) { errnum = S826_ERR_CREATEMUTEX; // Abort if failed to create mutex. break; } nboards++; // Bump registered board count. } if (errnum == S826_ERR_OK) // Exit with board count if no errors. return nboards; sys826_close(); // Close all open boards. return errnum; // Return error code. }
do_postwar() { int rc, in_postwar_read, in_postwar = 1; int openflags, newmsgs; struct readnewstruct rns; char msgbuf[80], ans[4]; while(in_postwar) { bbs_set_mode(M_POSTWAR); rc = (GenericPost(0)); bbs_set_mode(M_POSTWAR); in_postwar_read = 1; while(in_postwar_read) { move(t_lines-1,0); clrtoeol(); getdata(t_lines-1, 0, "Post again, Read new posts, Exit PostWar Mode? [R]: ", ans, sizeof(ans), DOECHO, 0); switch (*ans) { case 'e': case 'E': in_postwar = in_postwar_read = 0; break; case 'p': case 'P': in_postwar_read = 0; break; default: { clear(); CloseBoard(); newmsgs = OpenBoard(&openflags, 1, NULL); if (newmsgs > 0) { rns.nummsgs = newmsgs; rns.numread = 0; rns.openflags = openflags; rns.dispflags = NEW_SKIP; rns.thread = NULL; bbs_enum_headers(10, 0, 1, NewPostReadfn, &rns); } else { sprintf(msgbuf, "No New Posts on %s\n", currboard); move(t_lines/2, t_columns/2-10); prints(msgbuf); } } } } } return rc; }