• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ WStatus类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中WStatus的典型用法代码示例。如果您正苦于以下问题:C++ WStatus类的具体用法?C++ WStatus怎么用?C++ WStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了WStatus类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: UpdateUserStatsForLogin

static void UpdateUserStatsForLogin() {
  strcpy(g_szLastLoginDate, date());
  if (IsEquals(g_szLastLoginDate, session()->user()->GetLastOn())) {
    session()->user()->SetTimesOnToday(session()->user()->GetTimesOnToday() + 1);
  } else {
    session()->user()->SetTimesOnToday(1);
    session()->user()->SetTimeOnToday(0.0);
    session()->user()->SetExtraTime(0.0);
    session()->user()->SetNumPostsToday(0);
    session()->user()->SetNumEmailSentToday(0);
    session()->user()->SetNumFeedbackSentToday(0);
  }
  session()->user()->SetNumLogons(session()->user()->GetNumLogons() + 1);
  session()->set_current_user_sub_num(0);
  session()->SetNumMessagesReadThisLogon(0);
  if (session()->udir[0].subnum == 0 && session()->udir[1].subnum > 0) {
    session()->set_current_user_dir_num(1);
  } else {
    session()->set_current_user_dir_num(0);
  }
  if (session()->GetEffectiveSl() != 255 && !guest_user) {
    WStatus* pStatus = session()->status_manager()->BeginTransaction();
    pStatus->IncrementCallerNumber();
    pStatus->IncrementNumCallsToday();
    session()->status_manager()->CommitTransaction(pStatus);
  }
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:27,代码来源:lilo.cpp


示例2: make_pre_qwk

void make_pre_qwk(int msgnum, struct qwk_junk *qwk_info) {
  postrec* p = get_post(msgnum);
  if ((p->status & (status_unvalidated | status_delete)) && !lcs()) {
    return;
  }

  int nn = session()->net_num();
  if (p->status & status_post_new_net) {
    set_net_num(p->network.network_msg.net_number);
  }

  put_in_qwk(p, (session()->current_sub().filename), msgnum, qwk_info);
  if (nn != session()->net_num()) {
    set_net_num(nn);
  }

  session()->user()->SetNumMessagesRead(session()->user()->GetNumMessagesRead() + 1);
  session()->SetNumMessagesReadThisLogon(session()->GetNumMessagesReadThisLogon() + 1);

  if (p->qscan > qsc_p[session()->GetCurrentReadMessageArea()]) { // Update qscan pointer right here
    qsc_p[session()->GetCurrentReadMessageArea()] = p->qscan;  // And here
  }
  WStatus* pStatus1 = session()->status_manager()->GetStatus();
  uint32_t lQScanPtr = pStatus1->GetQScanPointer();
  delete pStatus1;
  if (p->qscan >= lQScanPtr) {
    WStatus* pStatus = session()->status_manager()->BeginTransaction();
    pStatus->SetQScanPointer(p->qscan + 1);
    session()->status_manager()->CommitTransaction(pStatus);
  }
}
开发者ID:Stephen-Gose-Game-Studio,项目名称:wwiv,代码行数:31,代码来源:qwk.cpp


示例3: CreateLastOnLogLine

static std::string CreateLastOnLogLine(const WStatus& status) {
  string log_line;
  if (a()->HasConfigFlag(OP_FLAGS_SHOW_CITY_ST) &&
    (syscfg.sysconfig & sysconfig_extended_info)) {
    const string username_num = a()->names()->UserName(a()->usernum);
    log_line = StringPrintf(
      "|#1%-6ld %-25.25s %-5.5s %-5.5s %-15.15s %-2.2s %-3.3s %-8.8s %2d\r\n",
      status.GetCallerNumber(),
      username_num.c_str(),
      times(),
      fulldate(),
      a()->user()->GetCity(),
      a()->user()->GetState(),
      a()->user()->GetCountry(),
      a()->GetCurrentSpeed().c_str(),
      a()->user()->GetTimesOnToday());
  } else {
    const string username_num = a()->names()->UserName(a()->usernum);
    log_line = StringPrintf(
      "|#1%-6ld %-25.25s %-10.10s %-5.5s %-5.5s %-20.20s %2d\r\n",
      status.GetCallerNumber(),
      username_num.c_str(),
      a()->cur_lang_name.c_str(),
      times(),
      fulldate(),
      a()->GetCurrentSpeed().c_str(),
      a()->user()->GetTimesOnToday());
  }
  return log_line;
}
开发者ID:wwiv,项目名称:wwiv,代码行数:30,代码来源:lilo.cpp


示例4: save_gat

static void save_gat(File *pMessageFile) {
  long lSectionPos = static_cast<long>(gat_section) * GATSECLEN;
  pMessageFile->Seek(lSectionPos, File::seekBegin);
  pMessageFile->Write(gat, GAT_SECTION_SIZE);
  WStatus *pStatus = session()->status_manager()->BeginTransaction();
  pStatus->IncrementFileChangedFlag(WStatus::fileChangePosts);
  session()->status_manager()->CommitTransaction(pStatus);
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:8,代码来源:message_file.cpp


示例5: InsertSmallRecord

// Inserts a record into NAMES.LST
void InsertSmallRecord(int user_number, const char *name) {
  WStatus *pStatus = session()->status_manager()->BeginTransaction();
  session()->names()->Add(name, user_number);
  session()->names()->Save();

  pStatus->IncrementNumUsers();
  pStatus->IncrementFileChangedFlag(WStatus::fileChangeNames);
  session()->status_manager()->CommitTransaction(pStatus);
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:10,代码来源:smallrecord.cpp


示例6: DeleteSmallRecord

// Deletes a record from NAMES.LST (DeleteSmallRec)
void DeleteSmallRecord(const char *name) {
  WStatus *pStatus = session()->status_manager()->BeginTransaction();
  int found_user = session()->names()->FindUser(name);
  if (found_user < 1) {
    session()->status_manager()->AbortTransaction(pStatus);
    sysoplog(false) << "#*#*#*#*#*#*#*# '" << name << "' NOT ABLE TO BE DELETED";
    sysoplog(false) << "#*#*#*#*#*#*#*# Run //RESETF to fix it.";
    return;
  }
  session()->names()->Remove(found_user);
  pStatus->DecrementNumUsers();
  pStatus->IncrementFileChangedFlag(WStatus::fileChangeNames);
  session()->names()->Save();
  session()->status_manager()->CommitTransaction(pStatus);
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:16,代码来源:smallrecord.cpp


示例7: reset_files

void reset_files() {
  WUser user;

  WStatus* pStatus = GetApplication()->GetStatusManager()->BeginTransaction();
  pStatus->SetNumUsers(0);
  GetSession()->bout.NewLine();
  int nNumUsers = GetApplication()->GetUserManager()->GetNumberOfUserRecords();
  WFile userFile(syscfg.datadir, USER_LST);
  if (userFile.Open(WFile::modeBinary | WFile::modeReadWrite)) {
    for (int i = 1; i <= nNumUsers; i++) {
      long pos = static_cast<long>(syscfg.userreclen) * static_cast<long>(i);
      userFile.Seek(pos, WFile::seekBegin);
      userFile.Read(&user.data, syscfg.userreclen);
      if (!user.IsUserDeleted()) {
        user.FixUp();
        if (isr1(i, nNumUsers, user.GetName())) {
          pStatus->IncrementNumUsers();
        }
      } else {
        memset(&user.data, 0, syscfg.userreclen);
        user.SetInactFlag(0);
        user.SetInactFlag(inact_deleted);
      }
      userFile.Seek(pos, WFile::seekBegin);
      userFile.Write(&user.data, syscfg.userreclen);
      if ((i % 10) == 0) {
        userFile.Close();
        GetSession()->bout << i << "\r ";
        userFile.Open(WFile::modeBinary | WFile::modeReadWrite);
      }
    }
    userFile.Close();
  }
  GetSession()->bout << "\r\n\r\n";

  WFile namesFile(syscfg.datadir, NAMES_LST);
  if (!namesFile.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeTruncate)) {
    std::cout << namesFile.GetFullPathName() << " NOT FOUND" << std::endl;
    GetApplication()->AbortBBS(true);
  }
  namesFile.Write(smallist, sizeof(smalrec) * pStatus->GetNumUsers());
  namesFile.Close();
  GetApplication()->GetStatusManager()->CommitTransaction(pStatus);
}
开发者ID:bhaggerty,项目名称:wwiv,代码行数:44,代码来源:sysopf.cpp


示例8: uploaded

void uploaded(char *file_name, long lCharsPerSecond) {
  uploadsrec u;

  for (auto it = begin(session()->batch); it != end(session()->batch); it++) {
    const auto& b = *it;
    if (IsEquals(file_name, b.filename) && !b.sending) {
      dliscan1(b.dir);
      int nRecNum = recno(b.filename);
      if (nRecNum > 0) {
        File downFile(g_szDownloadFileName);
        downFile.Open(File::modeBinary | File::modeCreateFile | File::modeReadWrite);
        do {
          FileAreaSetRecord(downFile, nRecNum);
          downFile.Read(&u, sizeof(uploadsrec));
          if (u.numbytes != 0) {
            nRecNum = nrecno(b.filename, nRecNum);
          }
        } while (nRecNum != -1 && u.numbytes != 0);
        downFile.Close();
        if (nRecNum != -1 && u.numbytes == 0) {
          char szSourceFileName[MAX_PATH], szDestFileName[MAX_PATH];
          sprintf(szSourceFileName, "%s%s", syscfgovr.batchdir, file_name);
          sprintf(szDestFileName, "%s%s", session()->directories[b.dir].path, file_name);
          if (!IsEquals(szSourceFileName, szDestFileName) &&
              File::Exists(szSourceFileName)) {
            bool found = false;
            if (szSourceFileName[1] != ':' && szDestFileName[1] != ':') {
              found = true;
            }
            if (szSourceFileName[1] == ':' && szDestFileName[1] == ':' && szSourceFileName[0] == szDestFileName[0]) {
              found = true;
            }
            if (found) {
              File::Rename(szSourceFileName, szDestFileName);
              File::Remove(szSourceFileName);
            } else {
              copyfile(szSourceFileName, szDestFileName, false);
              File::Remove(szSourceFileName);
            }
          }
          File file(szDestFileName);
          if (file.Open(File::modeBinary | File::modeReadOnly)) {
            if (!syscfg.upload_cmd.empty()) {
              file.Close();
              if (!check_ul_event(b.dir, &u)) {
                didnt_upload(b);
              } else {
                file.Open(File::modeBinary | File::modeReadOnly);
              }
            }
            if (file.IsOpen()) {
              u.numbytes = file.GetLength();
              file.Close();
              get_file_idz(&u, b.dir);
              session()->user()->SetFilesUploaded(session()->user()->GetFilesUploaded() + 1);
              modify_database(u.filename, true);
              session()->user()->SetUploadK(session()->user()->GetUploadK() +
                  static_cast<int>(bytes_to_k(u.numbytes)));
              WStatus *pStatus = session()->status_manager()->BeginTransaction();
              pStatus->IncrementNumUploadsToday();
              pStatus->IncrementFileChangedFlag(WStatus::fileChangeUpload);
              session()->status_manager()->CommitTransaction(pStatus);
              File fileDn(g_szDownloadFileName);
              fileDn.Open(File::modeBinary | File::modeCreateFile | File::modeReadWrite);
              FileAreaSetRecord(fileDn, nRecNum);
              fileDn.Write(&u, sizeof(uploadsrec));
              fileDn.Close();
              sysoplogf("+ \"%s\" uploaded on %s (%ld cps)", u.filename, session()->directories[b.dir].name, lCharsPerSecond);
              bout << "Uploaded '" << u.filename <<
                                 "' to " << session()->directories[b.dir].name << " (" <<
                                 lCharsPerSecond << " cps)" << wwiv::endl;
            }
          }
          it = delbatch(it);
          return;
        }
      }
      it = delbatch(it);
      if (try_to_ul(file_name)) {
        sysoplogf("!!! Couldn't find file \"%s\" in directory.", file_name);
        bout << "Deleting - couldn't find data for file " << file_name << wwiv::endl;
      }
      return;
    }
  }
  if (try_to_ul(file_name)) {
    sysoplogf("!!! Couldn't find \"%s\" in UL batch queue.", file_name);
    bout << "Deleting - don't know what to do with file " << file_name << wwiv::endl;

    File::Remove(syscfgovr.batchdir, file_name);
  }
}
开发者ID:Early-Career-Academy-Tempe-AZ,项目名称:wwiv,代码行数:92,代码来源:batch.cpp


示例9: multimail

void multimail(int *pnUserNumber, int numu) {
  mailrec m, m1;
  char s[255], s2[81];
  User user;
  memset(&m, 0, sizeof(mailrec));

  if (freek1(syscfg.msgsdir) < 10) {
    bout.nl();
    bout << "Sorry, not enough disk space left.\r\n\n";
    return;
  }
  bout.nl();

  MessageEditorData data;
  data.need_title = true;
  if (getslrec(session()->GetEffectiveSl()).ability & ability_email_anony) {
    data.anonymous_flag = anony_enable_anony;
  }
  bout << "|#5Show all recipients in mail? ";
  bool show_all = yesno();
  int j = 0;
  string s1 = StringPrintf("\003""6CC: \003""1");

  m.msg.storage_type = EMAIL_STORAGE;
  strcpy(irt, "Multi-Mail");
  irt_name[0] = 0;
  File::Remove(QUOTES_TXT);
  data.aux = "email";
  data.fsed_flags = INMSG_NOFSED;
  data.to_name = "Multi-Mail";
  data.msged_flags = MSGED_FLAG_NONE;
  if (!inmsg(data)) {
    return;
  }
  savefile(data.text, &m.msg, data.aux);
  strcpy(m.title, data.title.c_str());

  bout <<  "Mail sent to:\r\n";
  sysoplog("Multi-Mail to:");

  lineadd(&m.msg, "\003""7----", "email");

  for (int cv = 0; cv < numu; cv++) {
    if (pnUserNumber[cv] < 0) {
      continue;
    }
    session()->users()->ReadUser(&user, pnUserNumber[cv]);
    if ((user.GetSl() == 255 && (user.GetNumMailWaiting() > static_cast<unsigned int>(syscfg.maxwaiting * 5))) ||
        ((user.GetSl() != 255) && (user.GetNumMailWaiting() > syscfg.maxwaiting)) ||
        user.GetNumMailWaiting() > 200) {
      bout << session()->names()->UserName(pnUserNumber[cv]) << " mailbox full, not sent.";
      pnUserNumber[cv] = -1;
      continue;
    }
    if (user.IsUserDeleted()) {
      bout << "User deleted, not sent.\r\n";
      pnUserNumber[cv] = -1;
      continue;
    }
    strcpy(s, "  ");
    user.SetNumMailWaiting(user.GetNumMailWaiting() + 1);
    session()->users()->WriteUser(&user, pnUserNumber[cv]);
    if (pnUserNumber[cv] == 1) {
      ++fwaiting;
    }
    const string pnunn = session()->names()->UserName(pnUserNumber[cv]);
    strcat(s, pnunn.c_str());
    WStatus* pStatus = session()->status_manager()->BeginTransaction();
    if (pnUserNumber[cv] == 1) {
      pStatus->IncrementNumFeedbackSentToday();
      session()->user()->SetNumFeedbackSentToday(session()->user()->GetNumFeedbackSentToday() + 1);
      session()->user()->SetNumFeedbackSent(session()->user()->GetNumFeedbackSent() + 1);
      ++fsenttoday;
    } else {
      pStatus->IncrementNumEmailSentToday();
      session()->user()->SetNumEmailSent(session()->user()->GetNumEmailSent() + 1);
      session()->user()->SetNumEmailSentToday(session()->user()->GetNumEmailSentToday() + 1);
    }
    session()->status_manager()->CommitTransaction(pStatus);
    sysoplog(s);
    bout << s;
    bout.nl();
    if (show_all) {
      const string pnunn2 = session()->names()->UserName(pnUserNumber[cv]);
      sprintf(s2, "%-22.22s  ", pnunn2.c_str());
      s1.assign(s2);
      j++;
      if (j >= 3) {
        lineadd(&m.msg, s1, "email");
        j = 0;
        s1 = "\003""1    ";
      }
    }
  }
  if (show_all) {
    if (j) {
      lineadd(&m.msg, s1, "email");
    }
  }
  s1 = StringPrintf("\003""2Mail Sent to %d Addresses!", numu);
//.........这里部分代码省略.........
开发者ID:Early-Career-Academy-Tempe-AZ,项目名称:wwiv,代码行数:101,代码来源:multmail.cpp


示例10: beginday

void beginday(bool displayStatus) {
  if ((GetSession()->GetBeginDayNodeNumber() > 0)
      && (GetApplication()->GetInstanceNumber() != GetSession()->GetBeginDayNodeNumber())) {
    // If BEGINDAYNODENUMBER is > 0 or defined in WWIV.INI only handle beginday events on that node number
    GetApplication()->GetStatusManager()->RefreshStatusCache();
    return;
  }
  WStatus *pStatus = GetApplication()->GetStatusManager()->BeginTransaction();
  pStatus->ValidateAndFixDates();

  if (wwiv::strings::IsEquals(date(), pStatus->GetLastDate())) {
    GetApplication()->GetStatusManager()->CommitTransaction(pStatus);
    return;
  }
  GetSession()->bout << "|#7* |#1Running Daily Maintenance...\r\n";
  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Updating system activity...\r\n";
  }

  zlogrec z;
  strcpy(z.date, pStatus->GetLastDate());
  z.active            = pStatus->GetMinutesActiveToday();
  z.calls             = pStatus->GetNumCallsToday();
  z.posts             = pStatus->GetNumLocalPosts();
  z.email             = pStatus->GetNumEmailSentToday();
  z.fback             = pStatus->GetNumFeedbackSentToday();
  z.up                = pStatus->GetNumUploadsToday();
  pStatus->NewDay();


  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Cleaning up log files...\r\n";
  }
  WFile::Remove(syscfg.gfilesdir, pStatus->GetLogFileName(1));
  WFile::Remove(syscfg.gfilesdir, USER_LOG);

  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Updating ZLOG information...\r\n";
  }
  WFile fileZLog(syscfg.datadir, ZLOG_DAT);
  zlogrec z1;
  if (!fileZLog.Open(WFile::modeReadWrite | WFile::modeBinary)) {
    fileZLog.Open(WFile::modeReadWrite | WFile::modeBinary | WFile::modeCreateFile, WFile::shareDenyNone,
                  WFile::permReadWrite);
    z1.date[0]  = '\0';
    z1.active   = 0;
    z1.calls    = 0;
    z1.posts    = 0;
    z1.email    = 0;
    z1.fback    = 0;
    z1.up       = 0;
    for (int i = 0; i < 97; i++) {
      fileZLog.Write(&z1, sizeof(zlogrec));
    }
  } else {
    for (int i = 96; i >= 1; i--) {
      fileZLog.Seek((i - 1) * sizeof(zlogrec), WFile::seekBegin);
      fileZLog.Read(&z1, sizeof(zlogrec));
      fileZLog.Seek(i * sizeof(zlogrec), WFile::seekBegin);
      fileZLog.Write(&z1, sizeof(zlogrec));
    }
  }
  fileZLog.Seek(0L, WFile::seekBegin);
  fileZLog.Write(&z, sizeof(zlogrec));
  fileZLog.Close();

  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Updating STATUS.DAT...\r\n";
  }
  int nus = syscfg.maxusers - pStatus->GetNumUsers();

  GetApplication()->GetStatusManager()->CommitTransaction(pStatus);
  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Checking system directories and user space...\r\n";
  }

  double fk = freek1(syscfg.datadir);

  if (fk < 512.0) {
    ssm(1, 0, "Only %dk free in data directory.", static_cast<int>(fk));
  }
  if (!syscfg.closedsystem && nus < 15) {
    ssm(1, 0, "Only %d new user slots left.", nus);
  }
  if (syscfg.beginday_c && *syscfg.beginday_c) {
    const std::string commandLine = stuff_in(syscfg.beginday_c, create_chain_file(), "", "", "", "");
    ExecuteExternalProgram(commandLine, GetApplication()->GetSpawnOptions(SPWANOPT_BEGINDAY));
  }
  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Purging inactive users (if enabled)...\r\n";
  }
  auto_purge();
  if (displayStatus) {
    GetSession()->bout << "  |#7* |#1Updating user ages...\r\n";
  }
  set_user_age();
  if (displayStatus) {
    GetSession()->bout << "|#7* |#1Done!\r\n";
  }

//.........这里部分代码省略.........
开发者ID:bhaggerty,项目名称:wwiv,代码行数:101,代码来源:sysopf.cpp


示例11: normalupload


//.........这里部分代码省略.........
      inputl(u.description, 58);
      bout.nl();
      string ext_desc;
      modify_extended_description(&ext_desc, session()->directories[dn].name);
      if (!ext_desc.empty()) {
        add_extended_description(u.filename, ext_desc);
        u.mask |= mask_extended;
      }
      bout.nl();
      if (xfer) {
        write_inst(INST_LOC_UPLOAD, session()->current_user_dir().subnum, INST_FLAGS_ONLINE);
        auto ti = timer();
        receive_file(szReceiveFileName, &ok, u.filename, dn);
        ti = timer() - ti;
        if (ti < 0) {
          ti += SECONDS_PER_DAY;
        }
        session()->user()->SetExtraTime(session()->user()->GetExtraTime() + static_cast<float>(ti));
      }
      if (ok) {
        File file(szReceiveFileName);
        if (ok == 1) {
          if (!file.Open(File::modeBinary | File::modeReadOnly)) {
            ok = 0;
            bout.nl(2);
            bout << "OS error - File not found.\r\n\n";
            if (u.mask & mask_extended) {
              delete_extended_description(u.filename);
            }
          }
          if (ok && !syscfg.upload_cmd.empty()) {
            file.Close();
            bout << "Please wait...\r\n";
            if (!check_ul_event(dn, &u)) {
              if (u.mask & mask_extended) {
                delete_extended_description(u.filename);
              }
              ok = 0;
            } else {
              file.Open(File::modeBinary | File::modeReadOnly);
            }
          }
        }
        if (ok) {
          if (ok == 1) {
            u.numbytes = file.GetLength();
            file.Close();
            session()->user()->SetFilesUploaded(session()->user()->GetFilesUploaded() + 1);
            modify_database(u.filename, true);
            session()->user()->SetUploadK(session()->user()->GetUploadK() + bytes_to_k(u.numbytes));

            get_file_idz(&u, dn);
          } else {
            u.numbytes = 0;
          }
          time_t lCurrentTime;
          time(&lCurrentTime);
          u.daten = static_cast<uint32_t>(lCurrentTime);
          File fileDownload(session()->download_filename_);
          fileDownload.Open(File::modeBinary | File::modeCreateFile | File::modeReadWrite);
          for (int j = session()->numf; j >= 1; j--) {
            FileAreaSetRecord(fileDownload, j);
            fileDownload.Read(&u1, sizeof(uploadsrec));
            FileAreaSetRecord(fileDownload, j + 1);
            fileDownload.Write(&u1, sizeof(uploadsrec));
          }
          FileAreaSetRecord(fileDownload, 1);
          fileDownload.Write(&u, sizeof(uploadsrec));
          ++session()->numf;
          FileAreaSetRecord(fileDownload, 0);
          fileDownload.Read(&u1, sizeof(uploadsrec));
          u1.numbytes = session()->numf;
          u1.daten = static_cast<uint32_t>(lCurrentTime);
          FileAreaSetRecord(fileDownload, 0);
          fileDownload.Write(&u1, sizeof(uploadsrec));
          fileDownload.Close();
          if (ok == 1) {
            WStatus *pStatus = session()->status_manager()->BeginTransaction();
            pStatus->IncrementNumUploadsToday();
            pStatus->IncrementFileChangedFlag(WStatus::fileChangeUpload);
            session()->status_manager()->CommitTransaction(pStatus);
            sysoplog() << StringPrintf("+ \"%s\" uploaded on %s", u.filename, session()->directories[dn].name);
            bout.nl(2);
            bout.bprintf("File uploaded.\r\n\nYour ratio is now: %-6.3f\r\n", ratio());
            bout.nl(2);
            if (session()->IsUserOnline()) {
              session()->UpdateTopScreen();
            }
          }
        }
      } else {
        bout.nl(2);
        bout << "File transmission aborted.\r\n\n";
        if (u.mask & mask_extended) {
          delete_extended_description(u.filename);
        }
      }
    }
  }
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:101,代码来源:normupld.cpp


示例12: write_automessage

/**
 * Writes the auto message
 */
void write_automessage() {
  std::vector<std::string> lines;
  std::string rollOver;

  GetSession()->bout << "\r\n|#9Enter auto-message. Max 5 lines. Colors allowed:|#0\r\n\n";
  for (int i = 0; i < 5; i++) {
    GetSession()->bout << "|#7" << i + 1 << ":|#0";
    std::string line;
    inli(line, rollOver, 70);
    StringTrimEnd(line);
    lines.push_back(line);
  }
  GetSession()->bout.NewLine();
  bool bAnonStatus = false;
  if (getslrec(GetSession()->GetEffectiveSl()).ability & ability_post_anony) {
    GetSession()->bout << "|#9Anonymous? ";
    bAnonStatus = yesno();
  }

  GetSession()->bout << "|#9Is this OK? ";
  if (yesno()) {
    WStatus *pStatus = GetApplication()->GetStatusManager()->BeginTransaction();
    pStatus->SetAutoMessageAnonymous(bAnonStatus);
    pStatus->SetAutoMessageAuthorUserNumber(GetSession()->usernum);
    GetApplication()->GetStatusManager()->CommitTransaction(pStatus);

    WTextFile file(syscfg.gfilesdir, AUTO_MSG, "wt");
    std::string authorName = GetSession()->GetCurrentUser()->GetUserNameAndNumber(GetSession()->usernum);
    file.WriteFormatted("%s\r\n", authorName.c_str());
    sysoplog("Changed Auto-message");
#if defined(_MSC_VER) && (_MSC_VER < 1800)
    for (std::vector<std::string>::const_iterator iter = lines.begin(); iter != lines.end(); ++iter) {
      std::string line = (*iter);
      StringTrimEnd(line);
#else
    for (const auto& line : lines) {
#endif
      file.Write(line);
      file.Write("\r\n");
      sysoplog(line, true);
    }
    GetSession()->bout << "\r\n|#5Auto-message saved.\r\n\n";
    file.Close();
  }
}


char ShowAMsgMenuAndGetInput(const std::string& autoMessageLockFileName) {
  bool bCanWrite = false;
  if (!GetSession()->GetCurrentUser()->IsRestrictionAutomessage() && !WFile::Exists(autoMessageLockFileName)) {
    bCanWrite = (getslrec(GetSession()->GetEffectiveSl()).posts) ? true : false;
  }

  char cmdKey = 0;
  if (cs()) {
    GetSession()->bout <<
                       "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply, (|#2W|#9)rite, (|#2L|#9)ock, (|#2D|#9)el, (|#2U|#9)nlock : ";
    cmdKey = onek("QRWALDU", true);
  } else if (bCanWrite) {
    GetSession()->bout << "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply, (|#2W|#9)rite : ";
    cmdKey = onek("QRWA", true);
  } else {
    GetSession()->bout << "|#9(|#2Q|#9)uit, (|#2R|#9)ead, (|#2A|#9)uto-reply : ";
    cmdKey = onek("QRA", true);
  }
  return cmdKey;
}
开发者ID:bhaggerty,项目名称:wwiv,代码行数:70,代码来源:automsg.cpp


示例13: do_automessage

/**
 * Main Automessage menu.  Displays the auto message then queries for input.
 */
void do_automessage() {
  std::stringstream lockFileStream;
  lockFileStream << syscfg.gfilesdir << LOCKAUTO_MSG;
  std::string automessageLockFile = lockFileStream.str();

  std::stringstream autoMessageStream;
  autoMessageStream << syscfg.gfilesdir << AUTO_MSG;
  std::string autoMessageFile = autoMessageStream.str();

  // initally show the auto message
  read_automessage();

  bool done = false;
  do {
    GetSession()->bout.NewLine();
    char cmdKey = ShowAMsgMenuAndGetInput(automessageLockFile);
    switch (cmdKey) {
    case 'Q':
      done = true;
      break;
    case 'R':
      read_automessage();
      break;
    case 'W':
      write_automessage();
      break;
    case 'A': {
      grab_quotes(NULL, NULL);
      WStatus *pStatus = GetApplication()->GetStatusManager()->GetStatus();
      if (pStatus->GetAutoMessageAuthorUserNumber() > 0) {
        strcpy(irt, "Re: AutoMessage");
        email(pStatus->GetAutoMessageAuthorUserNumber(), 0, false, pStatus->IsAutoMessageAnonymous() ? anony_sender : 0);
      }
      delete pStatus;
    }
    break;
    case 'D':
      GetSession()->bout << "\r\n|#3Delete Auto-message, Are you sure? ";
      if (yesno()) {
        WFile::Remove(autoMessageFile);
      }
      GetSession()->bout.NewLine(2);
      break;
    case 'L':
      if (WFile::Exists(automessageLockFile)) {
        GetSession()->bout << "\r\n|#3Message is already locked.\r\n\n";
      } else {
        GetSession()->bout <<  "|#9Do you want to lock the Auto-message? ";
        if (yesno()) {
          /////////////////////////////////////////////////////////
          // This makes a file in your GFILES dir 1 bytes long,
          // to tell the board if it is locked or not. It consists
          // of a space.
          //
          WTextFile lockFile(automessageLockFile, "w+t");
          lockFile.WriteChar(' ');
          lockFile.Close();
        }
      }
      break;
    case 'U':
      if (!WFile::Exists(automessageLockFile)) {
        GetSession()->bout << "Message not locked.\r\n";
      } else {
        GetSession()->bout << "|#5Unlock message? ";
        if (yesno()) {
          WFile::Remove(automessageLockFile);
        }
      }
      break;
    }
  } while (!done && !hangup);
}
开发者ID:bhaggerty,项目名称:wwiv,代码行数:76,代码来源:automsg.cpp


示例14: try_to_ul_wh


//.........这里部分代码省略.........
      bout << "|#5Modify extended description? ";
      if (yesno()) {
        bout.nl();
        if (!ss.empty()) {
          bout << "|#5Delete it? ";
          if (yesno()) {
            delete_extended_description(u.filename);
            u.mask &= ~mask_extended;
          } else {
            u.mask |= mask_extended;
            modify_extended_description(&ss, session()->directories[session()->current_user_dir().subnum].name);
            if (!ss.empty()) {
              delete_extended_description(u.filename);
              add_extended_description(u.filename, ss);
            }
          }
        } else {
          modify_extended_description(&ss, session()->directories[session()->current_user_dir().subnum].name);
          if (!ss.empty()) {
            add_extended_description(u.filename, ss);
            u.mask |= mask_extended;
          } else {
            u.mask &= ~mask_extended;
          }
        }
      } else if (!ss.empty()) {
        u.mask |= mask_extended;
      } else {
        u.mask &= ~mask_extended;
      }
    } break;

    case '\r':
      bout.nl();
      done = true;
    }
  }

  bout.nl(3);

  File file(d.path, s);
  if (!file.Open(File::modeBinary | File::modeReadOnly)) {
    // dos error, file not found
    if (u.mask & mask_extended) {
      delete_extended_description(u.filename);
    }
    t2u_error(file_name, "DOS error - File not found.");
    return 1;
  }
  if (!syscfg.upload_cmd.empty()) {
    file.Close();
    bout << "Please wait...\r\n";
    if (!check_ul_event(dn, &u)) {
      if (u.mask & mask_extended) {
        delete_extended_description(u.filename);
      }
      t2u_error(file_name, "Failed upload event");
      return 1;
    } else {
      file.Open(File::modeBinary | File::modeReadOnly);
    }
  }
  long lFileLength = file.GetLength();
  u.numbytes = lFileLength;
  file.Close();
  session()->user()->SetFilesUploaded(session()->user()->GetFilesUploaded() + 1);

  time_t tCurrentDate = time(nullptr);
  u.daten = static_cast<uint32_t>(tCurrentDate);
  File fileDownload(session()->download_filename_);
  fileDownload.Open(File::modeBinary | File::modeCreateFile | File::modeReadWrite);
  for (int i = session()->numf; i >= 1; i--) {
    FileAreaSetRecord(fileDownload, i);
    fileDownload.Read(&u1, sizeof(uploadsrec));
    FileAreaSetRecord(fileDownload, i + 1);
    fileDownload.Write(&u1, sizeof(uploadsrec));
  }

  FileAreaSetRecord(fileDownload, 1);
  fileDownload.Write(&u, sizeof(uploadsrec));
  ++session()->numf;
  FileAreaSetRecord(fileDownload, 0);
  fileDownload.Read(&u1, sizeof(uploadsrec));
  u1.numbytes = session()->numf;
  u1.daten = static_cast<uint32_t>(tCurrentDate);
  FileAreaSetRecord(fileDownload, 0);
  fileDownload.Write(&u1, sizeof(uploadsrec));
  fileDownload.Close();

  modify_database(u.filename, true);

  session()->user()->SetUploadK(session()->user()->GetUploadK() + bytes_to_k(u.numbytes));

  WStatus *pStatus = session()->status_manager()->BeginTransaction();
  pStatus->IncrementNumUploadsToday();
  pStatus->IncrementFileChangedFlag(WStatus::fileChangeUpload);
  session()->status_manager()->CommitTransaction(pStatus);
  sysoplog() << StringPrintf("+ \"%s\" uploaded on %s", u.filename, session()->directories[dn].name);
  return 0;                                 // This means success
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:101,代码来源:trytoul.cpp


示例15: logoff

void logoff() {
  mailrec m;

  if (incom) {
    play_sdf(LOGOFF_NOEXT, false);
  }

  if (session()->usernum > 0) {
    if ((incom || sysop1()) && session()->user()->GetSl() < 255) {
      broadcast(StringPrintf("%s Just logged off!", session()->user()->GetName()));
    }
  }
  setiia(90);
  session()->remoteIO()->disconnect();
  hangup = true;
  if (session()->usernum < 1) {
    return;
  }

  string text = "  Logged Off At ";
  text += times();
  if (session()->GetEffectiveSl() != 255 || incom) {
    sysoplog(false) << "";
    sysoplog(false) << stripcolors(text);
  }
  session()->user()->SetLastBaudRate(modem_speed);

  // put this back here where it belongs... (not sure why it te
  session()->user()->SetLastOn(g_szLastLoginDate);

  session()->user()->SetNumIllegalLogons(0);
  if ((timer() - timeon) < -30) {
    timeon -= SECONDS_PER_DAY;
  }
  auto dTimeOnNow = timer() - timeon;
  session()->user()->SetTimeOn(session()->user()->GetTimeOn() + static_cast<float>(dTimeOnNow));
  session()->user()->SetTimeOnToday(session()->user()->GetTimeOnToday() +
    static_cast<float>(dTimeOnNow - extratimecall));
  {
    WStatus* pStatus = session()->status_manager()->BeginTransaction();
    int nActiveToday = pStatus->GetMinutesActiveToday();
    pStatus->SetMinutesActiveToday(nActiveToday + static_cast<uint16_t>(dTimeOnNow / MINUTES_PER_HOUR));
    session()->status_manager()->CommitTransaction(pStatus);
  }
  if (g_flags & g_flag_scanned_files) {
    session()->user()->SetNewScanDateNumber(session()->user()->GetLastOnDateNumber());
  }
  time_t lTime = time(nullptr);
  session()->user()->SetLastOnDateNumber(lTime);
  sysoplog(false) << "Read: " << session()->GetNumMessagesReadThisLogon() 
      << "   Time on: "  << (timer() - timeon) / MINUTES_PER_HOUR;
  {
    unique_ptr<File> pFileEmail(OpenEmailFile(true));
    if (pFileEmail->IsOpen()) {
      session()->user()->SetNumMailWaiting(0);
      int t = static_cast<int>(pFileEmail->GetLength() / sizeof(mailrec));
      int r = 0;
      int w = 0;
      while (r < t) {
        pFileEmail->Seek(static_cast<long>(sizeof(mailrec)) * static_cast<long>(r), File::seekBegin);
        pFileEmail->Read(&m, sizeof(mailrec));
        if (m.tosys != 0 || m.touser != 0) {
          if (m.tosys == 0 && m.touser == session()->usernum) {
            if (session()->user()->GetNumMailWaiting() != 255) {
              session()->user()->SetNumMailWaiting(session()->user()->GetNumMailWaiting() + 1);
            }
          }
          if (r != w) {
            pFileEmail->Seek(static_cast<long>(sizeof(mailrec)) * static_cast<long>(w), File::seekBegin);
            pFileEmail->Write(&m, sizeof(mailrec));
          }
          ++w;
        }
        ++r;
      }
      if (r != w) {
        m.tosys = 0;
        m.touser = 0;
        for (int w1 = w; w1 < r; w1++) {
          pFileEmail->Seek(static_cast<long>(sizeof(mailrec)) * static_cast<long>(w1), File::seekBegin);
          pFileEmail->Write(&m, sizeof(mailrec));
        }
      }
      pFileEmail->SetLength(static_cast<long>(sizeof(mailrec)) * static_cast<long>(w));
      WStatus *pStatus = session()->status_manager()->BeginTransaction();
      pStatus->IncrementFileChangedFlag(WStatus::fileChangeEmail);
      session()->status_manager()->CommitTransaction(pStatus);
      pFileEmail->Close();
    }
  }
  if (smwcheck) {
    File smwFile(session()->config()->datadir(), SMW_DAT);
    if (smwFile.Open(File::modeReadWrite | File::modeBinary | File::modeCreateFile)) {
      int t = static_cast<int>(smwFile.GetLength() / sizeof(shortmsgrec));
      int r = 0;
      int w = 0;
      while (r < t) {
        shortmsgrec sm;
        smwFile.Seek(r * sizeof(shortmsgrec), File::seekBegin);
        smwFile.Read(&sm, sizeof(shortmsgrec));
//.........这里部分代码省略.........
开发者ID:TRI0N,项目名称:wwiv,代码行数:101,代码来源:lilo.cpp


示例16: fill_sec

bool fill_sec(int sn) {
  int nf = 0, i, i1, n1;
  char s[81], s1[81];
  WFindFile fnd;
  bool bFound = false;

  gfilerec *g = read_sec(sn, &n1);
  string gfilesdir = session()->config()->gfilesdir();
  sprintf(s1, "%s%s%c*.*", gfilesdir.c_str(), session()->gfilesec[sn].filename, File::pathSeparatorChar);
  bFound = fnd.open(s1, 0);
  bool ok = true;
  int chd = 0;
  while ((bFound) && (!hangup) && (nf < session()->gfilesec[sn].maxfiles) && (ok)) {
    if (fnd.GetFileName()[0] == '.') {
      bFound = fnd.next();
      continue;
    }
    strcpy(s, fnd.GetFileName());
    align(s);
    i = 1;
    for (i1 = 0; i1 < nf; i1++) {
      if (compare(fnd.GetFileName(), g[i1].filename)) {
        i = 0;
      }
    }
    if (i) {
      bout << "|#2" << s << " : ";
      inputl(s1, 60);
      if (s1[0]) {
        chd = 1;
        i = 0;
        while (wwiv::strings::StringCompare(s1, g[i].description) > 0 && i < nf) {
          ++i;
        }
        for (i1 = nf; i1 > i; i1--) {
          g[i1] = g[i1 - 1];
        }
        ++nf;
        gfilerec g1;
        strcpy(g1.filename, fnd.GetFileName());
        strcpy(g1.description, s1);
        g1.daten = static_cast<long>(time(nullptr));
        g[i] = g1;
      } else {
        ok = false;
      }
    }
    bFound = fnd.next();
  }
  if (!ok) {
    bout << "|#6Aborted.\r\n";
  }
  if (nf >= session()->gfilesec[sn].maxfiles) {
    bout << "Section full.\r\n";
  }
  if (chd) {
    string file_name = StrCat(syscfg.datadir, session()->gfilesec[sn].filename, ".gfl");
    File gflFile(file_name);
    gflFile.Open(File::modeReadWrite | File::modeBinary | File::modeCreateFile | File::modeTruncate);
    gflFile.Write(g, nf * sizeof(gfilerec));
    gflFile.Close();
    WStatus *pStatus = session()->status_manager()->BeginTransaction();
    pStatus->SetGFileDate(date());
    session()->status_manager()->CommitTransaction(pStatus);
  }
  free(g);
  return !ok;
}
开发者ID:TRI0N,项目名称:wwiv,代码行数:68,代码来源:gfileedit.cpp


示例17: post

void post() {
  if (!iscan(session()->GetCurrentMessageArea())) {
    bout << "\r\n|#6A file required is in use by another instance. Try again later.\r\n";
    return;
  }
  if (session()->GetCurrentReadMessageArea() < 0) {
    bout << "\r\nNo subs available.\r\n\n";
    return;
  }

  if (freek1(syscfg.msgsdir) < 10) {
    bout << "\r\nSorry, not enough disk space left.\r\n\n";
    return;
  }
  if (session()->user()->IsRestrictionPost()
      || session()->user()->GetNumPostsToday() >= getslrec(session()->GetEffectiveSl()).posts) {
    bout << "\r\nToo many messages posted today.\r\n\n";
    return;
  }
  if (session()->GetEffectiveSl() < session()->current_sub().postsl) {
    bout << "\r\nYou can't post here.\r\n\n";
    return;
  }

  MessageEditorData data;
  messagerec m;
  m.storage_type = static_cast<unsigned char>(session()->current_sub().storage_type);
  data.anonymous_flag = session()->subboards[ session()->GetCurrentReadMessageArea() ].anony & 0x0f;
  if (data.anonymous_flag == 0 && getslrec(session()->GetEffectiveSl()).ability & ability_post_anony) {
    data.anonymous_flag = anony_enable_anony;
  }
  if (data.anonymous_flag == anony_enable_anony && session()->user()->IsRestrictionAnonymous()) {
    data.anonymous_flag = 0;
  }
  if (!session()->xsubs[ session()->GetCurrentReadMessageArea() ].nets.empty()) {
    data.anonymous_flag &= (anony_real_name);
    if (session()->user()->IsRestrictionNet()) {
      bout << "\r\nYou can't post on networked sub-boards.\r\n\n";
      return;
    }
    if (net_sysnum) {
      bout << "\r\nThis post will go out on ";
      for (size_t i = 0; i < session()->xsubs[ session()->GetCurrentReadMessageArea() ].nets.size(); i++) {
        if (i) {
          bout << ", ";
        }
        bout << session()->net_networks[session()->current_xsub().nets[i].net_num].name;
      }
      bout << ".\r\n\n";
    }
  }
  time_t lStartTime = time(nullptr);

  write_inst(INST_LOC_POST, session()->GetCurrentReadMessageArea(), INST_FLAGS_NONE);

  data.fsed_flags = INMSG_FSED;
  data.msged_flags = (session()->current_sub().anony & anony_no_tag) ? MSGED_FLAG_NO_TAGLINE : MSGED_FLAG_NONE;
  data.aux = session()->current_sub().filename;
  data.to_name = session()->current_sub().name;
  data.need_title = true;

  if (!inmsg(data)) {
    m.stored_as = 0xffffffff;
    return 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ WStrVec类代码示例发布时间:2022-05-31
下一篇:
C++ WStandardItem类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap