コード例 #1
0
ファイル: networkf.cpp プロジェクト: wwivbbs/wwiv
static bool import_bundles(const Config& config, const FidoCallout& callout,
  const net_networks_rec& net, const std::string& dir, const std::string& mask) {
  VLOG(1) << "import_bundles: mask: " << mask;
  WFindFile files;
  bool has_next = files.open(FilePath(dir, mask), WFINDFILE_FILES);
  while (has_next) {
    if (files.GetFileSize() == 0) {
      // skip zero byte files.
      continue;
    }
    const auto& name = files.GetFileName();
    string lname = ToStringLowerCase(name);
    if (ends_with(lname, ".pkt")) {
      if (import_packet_file(config, callout, net, dir, name)) {
        LOG(INFO) << "Successfully imported packet: " << FilePath(dir, name);
        File::Remove(dir, name);
      }
    } else if (import_bundle_file(config, callout, net, dir, name)) {
      LOG(INFO) << "Successfully imported bundle: " << FilePath(dir, name);
      File::Remove(dir, name);
    }
    has_next = files.next();
  }
  return true;
}
コード例 #2
0
ファイル: menuedit.cpp プロジェクト: insidenothing/wwiv
void ListMenuDirs() {
  const string menu_directory = GetMenuDirectory();
  wwiv::menus::MenuDescriptions descriptions(menu_directory);

  bout.nl();
  bout << "|#1Available Menus Sets" << wwiv::endl 
       << "|#9============================" << wwiv::endl;

  WFindFile fnd;
  const string search_path = StrCat(menu_directory, "*");
  bool bFound = fnd.open(search_path, 0);
  while (bFound && !hangup) {
    if (fnd.IsDirectory()) {
      const string filename = fnd.GetFileName();
      if (!starts_with(filename, ".")) {
        // Skip the . and .. dir entries.
        const string description = descriptions.description(filename);
        bout.bprintf("|#2%-8.8s |#9%-60.60s\r\n", filename.c_str(), description.c_str());
      }
    }
    bFound = fnd.next();
  }
  bout.nl();
  bout.Color(0);
}
コード例 #3
0
ファイル: extract.cpp プロジェクト: firefighter389/wwiv
/* Passes a specific filename to the upload function */
static bool upload_mod(int directory_number, const char *file_name, const char *description) {
    char s[81], s1[81];

    WWIV_ASSERT(file_name);

    dliscan1(udir[directory_number].subnum);
    bout.nl(2);
    strcpy(s, file_name);
    strcpy(s1, session()->directories[udir[directory_number].subnum].path);
    int maxf = session()->directories[udir[directory_number].subnum].maxfiles;
    strcat(s1, s);
    WFindFile fnd;
    bool bDone = fnd.open(s1, 0);
    bool ok = false;
    if (!bDone) {
        ok = maybe_upload(fnd.GetFileName(), directory_number, description);
    }
    if (ok) {
        bout << "Uploaded " << file_name << "....\r\n";
    }
    if (!ok) {
        bout << "|#6Aborted.\r\n";
    }
    if (session()->numf >= maxf) {
        bout << "directory full.\r\n";
    }
    return false;
}
コード例 #4
0
ファイル: menuedit.cpp プロジェクト: insidenothing/wwiv
static void ListMenuMenus(const string& directory_name) {
  bout.nl();
  bout << "|#1Available Menus" << wwiv::endl 
       << "|#9===============" << wwiv::endl;

  WFindFile fnd;
  bool bFound = fnd.open(StrCat(GetMenuDirectory(directory_name), "*.mnu"), 0);
  while (bFound && !hangup) {
    if (fnd.IsFile()) {
      const string s = fnd.GetFileName();
      bout << "|#2" << s.substr(0, s.find_last_of('.')) << wwiv::endl;
    }
    bFound = fnd.next();
  }
  bout.nl();
  bout.Color(0);
}
コード例 #5
0
ファイル: networkf.cpp プロジェクト: wwivbbs/wwiv
static bool import_packets(const Config& config, const FidoCallout& callout, const net_networks_rec& net, const std::string& dir, const std::string& mask) {
  VLOG(1) << "Importing packets from: " << dir;
  WFindFile files;
  bool has_next = files.open(FilePath(dir, mask), WFINDFILE_FILES);
  if (!has_next) {
    LOG(INFO) << "No packets to import in: " << dir;
  }
  while (has_next) {
    const auto& name = files.GetFileName();
    if (import_packet_file(config, callout, net, dir, name)) {
      LOG(INFO) << "Successfully imported packet: " << FilePath(dir, name);
      File::Remove(dir, name);
    }
    has_next = files.next();
  }
  return true;
}
コード例 #6
0
ファイル: utility.cpp プロジェクト: ericpareja/wwiv
/**
 * Deletes files from a directory.  This is meant to be used only in the temp
 * directories of WWIV.
 *
 * @param pszFileName       Wildcard file specification to delete
 * @param pszDirectoryName  Name of the directory to delete files from
 * @param bPrintStatus      Print out locally as files are deleted
 */
void remove_from_temp(const char *pszFileName, const char *pszDirectoryName, bool bPrintStatus) {
  WWIV_ASSERT(pszFileName);
  WWIV_ASSERT(pszDirectoryName);

  const string filespec = StrCat(pszDirectoryName, stripfn(pszFileName));
  WFindFile fnd;
  bool bFound = fnd.open(filespec, 0);
  bout.nl();
  while (bFound) {
    const string filename = fnd.GetFileName();
    // We don't want to delete ".", "..".
    if (filename != "." && filename != "..") {
      if (bPrintStatus) {
        std::clog << "Deleting TEMP file: " << pszDirectoryName << filename << std::endl;
      }
      File::Remove(pszDirectoryName, filename);
    }
    bFound = fnd.next();
  }
}
コード例 #7
0
ファイル: showfiles.cpp プロジェクト: insidenothing/wwiv
// Displays list of files matching filespec pszFileName in directory pszDirectoryName.
void show_files(const char *pszFileName, const char *pszDirectoryName) {
  char s[MAX_PATH];
  char drive[MAX_PATH], direc[MAX_PATH], file[MAX_PATH], ext[MAX_PATH];

  char c = (okansi()) ? '\xCD' : '=';
  bout.nl();
#if defined (_WIN32)
  _splitpath(pszDirectoryName, drive, direc, file, ext);
#else
  strcpy(direc, pszDirectoryName);
  strcpy(drive, "");
  strcpy(file, pszFileName);
  strcpy(ext, "");
#endif

  SNPRINTF(s, sizeof(s), "|#7[|B1|15 FileSpec: %s    Dir: %s%s |B0|#7]", strupr(stripfn(pszFileName)), drive, direc);
  int i = (session()->user()->GetScreenChars() - 1) / 2 - strlen(stripcolors(s)) / 2;
  bout << "|#7" << charstr(i, c) << s;
  i = session()->user()->GetScreenChars() - 1 - i - strlen(stripcolors(s));
  bout << "|#7" << charstr(i, c);

  char szFullPathName[ MAX_PATH ];
  SNPRINTF(szFullPathName, sizeof(szFullPathName), "%s%s", pszDirectoryName, strupr(stripfn(pszFileName)));
  WFindFile fnd;
  bool bFound = fnd.open(szFullPathName, 0);
  while (bFound) {
    strncpy(s, fnd.GetFileName(), MAX_PATH);
    align(s);
    SNPRINTF(szFullPathName, sizeof(szFullPathName), "|#7[|#2%s|#7]|#1 ", s);
    if (session()->localIO()->WhereX() > (session()->user()->GetScreenChars() - 15)) {
      bout.nl();
    }
    bout << szFullPathName;
    bFound = fnd.next();
  }

  bout.nl();
  bout.Color(7);
  bout << charstr(session()->user()->GetScreenChars() - 1, c);
  bout.nl(2);
}
コード例 #8
0
ファイル: instmsg.cpp プロジェクト: wwivbbs/wwiv
void process_inst_msgs() {
  if (!inst_msg_waiting()) {
    return;
  }
  last_iia = steady_clock::now();
  auto oiia = setiia(std::chrono::milliseconds(0));

  string fndspec = StringPrintf("%smsg*.%3.3u", a()->config()->datadir().c_str(), a()->instance_number());
  WFindFile fnd;
  bool found = fnd.open(fndspec, 0);
  while (found && !hangup) {
    File file(a()->config()->datadir(), fnd.GetFileName());
    if (!file.Open(File::modeBinary | File::modeReadOnly, File::shareDenyReadWrite)) {
      LOG(ERROR) << "Unable to open file: " << file.full_pathname();
      continue;
    }
    while (true) {
      inst_msg_header ih = {};
      auto num_read = file.Read(&ih, sizeof(inst_msg_header));
      if (num_read == 0) {
        // End of file.
        break;
      }
      string m;
      if (ih.msg_size > 0) {
        m.resize(ih.msg_size + 1);
        file.Read(&m[0], ih.msg_size);
        m.resize(ih.msg_size);
      }
      handle_inst_msg(&ih, m.c_str());
    }
    file.Close();
    file.Delete();
    found = fnd.next();
  }
  setiia(oiia);
}
コード例 #9
0
ファイル: gfileedit.cpp プロジェクト: TRI0N/wwiv
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;
}
コード例 #10
0
void slash_e() {
  int user_number[MAX_LIST], numu, i, i1;
  char s[81], ch, *sss;
  bool bFound = false;
  WFindFile fnd;

  mml_s = nullptr;
  mml_started = 0;
  if (freek1(syscfg.msgsdir) < 10) {
    bout.nl();
    bout << "Sorry, not enough disk space left.\r\n\n";
    return;
  }
  if (((fsenttoday >= 5) || (session()->user()->GetNumFeedbackSentToday() >= 10) ||
       (session()->user()->GetNumEmailSentToday() >= getslrec(session()->GetEffectiveSl()).emails))
      && (!cs())) {
    bout << "Too much mail sent today.\r\n\n";
    return;
  }
  if (session()->user()->IsRestrictionEmail()) {
    bout << "You can't send mail.\r\n";
    return;
  }
  bool done = false;
  numu = 0;
  do {
    bout.nl(2);
    bout << "|#2Multi-Mail: A,M,D,L,E,Q,? : ";
    ch = onek("QAMDEL?");
    switch (ch) {
    case '?':
      printfile(MMAIL_NOEXT);
      break;
    case 'Q':
      done = true;
      break;
    case 'A':
      bout.nl();
      bout << "Enter names/numbers for users, one per line, max 20.\r\n\n";
      mml_s = nullptr;
      add_list(user_number, &numu, MAX_LIST, so());
      break;
    case 'M': {
      sprintf(s, "%s*.MML", syscfg.datadir);
      bFound = fnd.open(s, 0);
      if (bFound) {
        bout.nl();
        bout << "No mailing lists available.\r\n\n";
        break;
      }
      bout.nl();
      bout << "Available mailing lists:\r\n\n";
      while (bFound) {
        strcpy(s, fnd.GetFileName());
        sss = strchr(s, '.');
        if (sss) {
          *sss = 0;
        }
        bout << s;
        bout.nl();

        bFound = fnd.next();
      }

      bout.nl();
      bout << "|#2Which? ";
      input(s, 8);

      File fileMailList(session()->config()->datadir(), s);
      if (!fileMailList.Open(File::modeBinary | File::modeReadOnly)) {
        bout.nl();
        bout << "Unknown mailing list.\r\n\n";
      } else {
        i1 = fileMailList.GetLength();
        mml_s = static_cast<char *>(BbsAllocA(i1 + 10L));
        fileMailList.Read(mml_s, i1);
        mml_s[i1] = '\n';
        mml_s[i1 + 1] = 0;
        fileMailList.Close();
        mml_started = 0;
        add_list(user_number, &numu, MAX_LIST, so());
        if (mml_s) {
          free(mml_s);
          mml_s = nullptr;
        }
      }
    }
    break;
    case 'E':
      if (!numu) {
        bout.nl();
        bout << "Need to specify some users first - use A or M\r\n\n";
      } else {
        multimail(user_number, numu);
        done = true;
      }
      break;
    case 'D':
      if (numu) {
        bout.nl();
        bout << "|#2Delete which? ";
        input(s, 2);
        i = atoi(s);
        if ((i > 0) && (i <= numu)) {
          --numu;
          for (i1 = i - 1; i1 < numu; i1++) {
            user_number[i1] = user_number[i1 + 1];
          }
        }
      }
      break;
    case 'L':
      for (i = 0; i < numu; i++) {
        User user;
        session()->users()->ReadUser(&user, user_number[i]);
        bout << i + 1 << ". " << session()->names()->UserName(user_number[i]) << wwiv::endl;
      }
      break;
    }
    CheckForHangup();
  } while (!done && !hangup);
}
コード例 #11
0
ファイル: utility.cpp プロジェクト: ericpareja/wwiv
char *get_wildlist(char *pszFileMask) {
  int mark = 0;
  char *pszPath, t;
  WFindFile fnd;

  WWIV_ASSERT(pszFileMask);

  if (!fnd.open(pszFileMask, 0)) {
    bout << "No files found\r\n";
    pszFileMask[0] = '\0';
    return pszFileMask;
  } else {
    bout.bprintf("%12.12s ", fnd.GetFileName());
  }

  if (strchr(pszFileMask, File::pathSeparatorChar) == nullptr) {
    pszFileMask[0] = '\0';
  } else {
    for (int i = 0; i < wwiv::strings::GetStringLength(pszFileMask); i++) {
      if (pszFileMask[i] == File::pathSeparatorChar) {
        mark = i + 1;
      }
    }
  }
  t = pszFileMask[mark];
  pszFileMask[mark] = 0;
  pszPath = pszFileMask;
  pszFileMask[mark] = t;
  t = static_cast<char>(wwiv::strings::GetStringLength(pszPath));
  strcat(pszPath, fnd.GetFileName());
  int i = 1;
  for (i = 1;; i++) {
    if (i % 5 == 0) {
      bout.nl();
    }
    if (!fnd.next()) {
      break;
    }
    bout.bprintf("%12.12s ", fnd.GetFileName());
    if (bgetch() == SPACE) {
      bout.nl();
      break;
    }
  }
  bout.nl();
  if (i == 1) {
    bout << "One file found: " << fnd.GetFileName() << wwiv::endl;
    bout << "Use this file? ";
    if (yesno()) {
      return pszPath;
    } else {
      pszPath[0] = '\0';
      return pszPath;
    }
  }
  pszPath[t] = '\0';
  bout << "Filename: ";
  input(pszFileMask, 12, true);
  strcat(pszPath, pszFileMask);
  return pszPath;
}