示例#1
0
文件: subacc.cpp 项目: bhaggerty/wwiv
bool iscan1(int si)
// Initializes use of a sub value (subboards[], not usub[]).  If quick, then
// don't worry about anything detailed, just grab qscan info.
{
  postrec p;

  // make sure we have cache space
  if (!cache) {
    cache = static_cast<postrec *>(malloc(MAX_TO_CACHE * sizeof(postrec)));
    if (!cache) {
      return false;
    }
  }
  // forget it if an invalid sub #
  if (si < 0 || si >= initinfo.num_subs) {
    return false;
  }

  // see if a sub has changed
  if (subchg) {
    SetCurrentReadMessageArea(-1);
  }

  // if already have this one set, nothing more to do
  if (si == GetCurrentReadMessageArea()) {
    return true;
  }
  // sub cache no longer valid
  believe_cache = false;

  // set sub filename
  snprintf(subdat_fn, sizeof(subdat_fn), "%s%s.sub", syscfg.datadir, subboards[si].filename);

  // open file, and create it if necessary
  if (!WFile::Exists(subdat_fn)) {
    if (!open_sub(true)) {
      return false;
    }
    p.owneruser = 0;
    fileSub.Write(&p, sizeof(postrec));
  } else if (!open_sub(false)) {
    return false;
  }

  // set sub
  SetCurrentReadMessageArea(si);
  subchg = 0;
  last_msgnum = 0;

  // read in first rec, specifying # posts
  fileSub.Seek(0L, WFile::seekBegin);
  fileSub.Read(&p, sizeof(postrec));
  SetNumMessagesInCurrentMessageArea(p.owneruser);

  // close file
  close_sub();

  // iscanned correctly
  return true;
}
示例#2
0
文件: subacc.cpp 项目: bhaggerty/wwiv
void write_post(int mn, postrec * pp) {
  postrec *p1;

  if (fileSub.IsOpen()) {
    fileSub.Seek(mn * sizeof(postrec), WFile::seekBegin);
    fileSub.Write(pp, sizeof(postrec));
    if (believe_cache) {
      if (mn >= cache_start && mn < (cache_start + MAX_TO_CACHE)) {
        p1 = cache + (mn - cache_start);
        if (p1 != pp) {
          *p1 = *pp;
        }
      }
    }
  }
}