当前位置: 首页>>代码示例>>C++>>正文


C++ gnu类代码示例

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


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

示例1: selectBlockSize

static int selectBlockSize(const CipherV1::CipherAlgorithm &alg) {
  if (alg.blockSize.min() == alg.blockSize.max()) {
    cout << autosprintf(
                // xgroup(setup)
                _("Using filesystem block size of %i bytes"),
                alg.blockSize.min()) << "\n";
    return alg.blockSize.min();
  }

  cout << autosprintf(
              // xgroup(setup)
              _("Select a block size in bytes.  The cipher you have chosen\n"
                "supports sizes from %i to %i bytes in increments of %i.\n"
                "Or just hit enter for the default (%i bytes)\n"),
              alg.blockSize.min(), alg.blockSize.max(), alg.blockSize.inc(),
              DefaultBlockSize);

  // xgroup(setup)
  cout << "\n" << _("filesystem block size: ");

  int blockSize = DefaultBlockSize;
  char answer[10];
  char *res = fgets(answer, sizeof(answer), stdin);
  cout << "\n";

  if (res != 0 && atoi(answer) >= alg.blockSize.min()) blockSize = atoi(answer);

  blockSize = alg.blockSize.closest(blockSize);

  // xgroup(setup)
  cout << autosprintf(_("Using filesystem block size of %i bytes"), blockSize)
       << "\n\n";

  return blockSize;
}
开发者ID:UIKit0,项目名称:encfs,代码行数:35,代码来源:FileUtils.cpp

示例2: main

int main(int argc, char **argv) {
  encfs::init_mpool_mutex();
  
  START_EASYLOGGINGPP(argc, argv);
  encfs::initLogging();

#if defined(ENABLE_NLS) && defined(LOCALEDIR)
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);
#endif

  SSL_load_error_strings();
  SSL_library_init();

  if (argc < 2) {
    usage(argv[0]);
    return EXIT_FAILURE;
  }

  // Skip over uninteresting args.
  while (argc > 2 && *argv[1] == '-') {
    VLOG(1) << "skipping arg " << argv[1];
    argc--;
    argv[1] = argv[0];
    argv++;
  }

  if (argc == 2 && !(*argv[1] == '-' && *(argv[1] + 1) == '-')) {
    // default command when only 1 argument given -- treat the argument as
    // a directory..
    return showInfo(argc, argv);
  } else {
    // find the specified command
    int offset = 0;
    while (commands[offset].name != 0) {
      if (!strcmp(argv[1], commands[offset].name)) break;
      ++offset;
    }

    if (commands[offset].name == 0) {
      cerr << autosprintf(_("invalid command: \"%s\""), argv[1]) << "\n";
    } else {
      if ((argc - 2 < commands[offset].minOptions) ||
          (argc - 2 > commands[offset].maxOptions)) {
        cerr << autosprintf(
                    _("Incorrect number of arguments for command \"%s\""),
                    argv[1])
             << "\n";
      } else
        return (*commands[offset].func)(argc - 1, argv + 1);
    }
  }

  return EXIT_FAILURE;
}
开发者ID:irslambouf,项目名称:encfs4win,代码行数:56,代码来源:encfsctl.cpp

示例3: selectKeySize

static
int selectKeySize( const CipherV1::CipherAlgorithm &alg )
{
  if(alg.keyLength.min() == alg.keyLength.max())
  {
    cout << autosprintf(_("Using key size of %i bits"), 
        alg.keyLength.min()) << "\n";
    return alg.keyLength.min();
  }

  cout << autosprintf(
      // xgroup(setup)
      _("Please select a key size in bits.  The cipher you have chosen\n"
        "supports sizes from %i to %i bits in increments of %i bits.\n"
        "For example: "), alg.keyLength.min(), alg.keyLength.max(), 
      alg.keyLength.inc()) << "\n";

  int numAvail = (alg.keyLength.max() - alg.keyLength.min()) 
    / alg.keyLength.inc();

  if(numAvail < 5)
  {
    // show them all
    for(int i=0; i<=numAvail; ++i)
    {
      if(i) 
        cout << ", ";
      cout << alg.keyLength.min() + i * alg.keyLength.inc();
    }
  } else
  {
    // partial
    for(int i=0; i<3; ++i)
    {
      if(i) 
        cout << ", ";
      cout << alg.keyLength.min() + i * alg.keyLength.inc();
    }
    cout << " ... " << alg.keyLength.max() - alg.keyLength.inc();
    cout << ", " << alg.keyLength.max();
  }
  // xgroup(setup)
  cout << "\n" << _("Selected key size: ");

  char answer[10];
  char *res = fgets( answer, sizeof(answer), stdin );
  int keySize = (res == 0 ? 0 : atoi( answer ));
  cout << "\n";

  keySize = alg.keyLength.closest( keySize );

  // xgroup(setup)
  cout << autosprintf(_("Using key size of %i bits"), keySize) << "\n\n";

  return keySize;
}
开发者ID:bentolor,项目名称:encfs,代码行数:56,代码来源:FileUtils.cpp

示例4: showInfo

static int showInfo(int argc, char **argv) {
  (void)argc;
  string rootDir = argv[1];
  if (!checkDir(rootDir)) return EXIT_FAILURE;

  shared_ptr<EncFSConfig> config(new EncFSConfig);
  ConfigType type = readConfig(rootDir, config);

  // show information stored in config..
  switch (type) {
    case Config_None:
      // xgroup(diag)
      cout << _("Unable to load or parse config file\n");
      return EXIT_FAILURE;
    case Config_Prehistoric:
      // xgroup(diag)
      cout << _(
          "A really old EncFS filesystem was found. \n"
          "It is not supported in this EncFS build.\n");
      return EXIT_FAILURE;
    case Config_V3:
      // xgroup(diag)
      cout << "\n" << autosprintf(_("Version 3 configuration; "
                                    "created by %s\n"),
                                  config->creator.c_str());
      break;
    case Config_V4:
      // xgroup(diag)
      cout << "\n" << autosprintf(_("Version 4 configuration; "
                                    "created by %s\n"),
                                  config->creator.c_str());
      break;
    case Config_V5:
      // xgroup(diag)
      cout << "\n" << autosprintf(_("Version 5 configuration; "
                                    "created by %s (revision %i)\n"),
                                  config->creator.c_str(), config->subVersion);
      break;
    case Config_V6:
      // xgroup(diag)
      cout << "\n" << autosprintf(_("Version 6 configuration; "
                                    "created by %s (revision %i)\n"),
                                  config->creator.c_str(), config->subVersion);
      break;
  }

  showFSInfo(config);

  return EXIT_SUCCESS;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:50,代码来源:encfsctl.cpp

示例5: main

int main(int argc, char **argv) {
  RLogInit(argc, argv);

#if defined(ENABLE_NLS) && defined(LOCALEDIR)
  setlocale(LC_ALL, "");
  bindtextdomain(PACKAGE, LOCALEDIR);
  textdomain(PACKAGE);
#endif

  SSL_load_error_strings();
  SSL_library_init();

  StdioNode *slog = new StdioNode(STDERR_FILENO);
  slog->subscribeTo(GetGlobalChannel("error"));
  slog->subscribeTo(GetGlobalChannel("warning"));

  if (argc < 2) {
    usage(argv[0]);
    return EXIT_FAILURE;
  }

  if (argc == 2 && !(*argv[1] == '-' && *(argv[1] + 1) == '-')) {
    // default command when only 1 argument given -- treat the argument as
    // a directory..
    return showInfo(argc, argv);
  } else {
    // find the specified command
    int offset = 0;
    while (commands[offset].name != 0) {
      if (!strcmp(argv[1], commands[offset].name)) break;
      ++offset;
    }

    if (commands[offset].name == 0) {
      cerr << autosprintf(_("invalid command: \"%s\""), argv[1]) << "\n";
    } else {
      if ((argc - 2 < commands[offset].minOptions) ||
          (argc - 2 > commands[offset].maxOptions)) {
        cerr << autosprintf(
                    _("Incorrect number of arguments for command \"%s\""),
                    argv[1]) << "\n";
      } else
        return (*commands[offset].func)(argc - 1, argv + 1);
    }
  }

  return EXIT_FAILURE;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:48,代码来源:encfsctl.cpp

示例6: userAllowMkdir

bool userAllowMkdir(int promptno, const char *path, mode_t mode) {
  // TODO: can we internationalize the y/n names?  Seems strange to prompt in
  // their own language but then have to respond 'y' or 'n'.
  // xgroup(setup)
  cerr << autosprintf(_("The directory \"%s\" does not exist. "
                        "Should it be created? (y,n) "),
                      path);
  char answer[10];
  char *res;

  switch (promptno) {
    case 1:
      cerr << endl << "$PROMPT$ create_root_dir" << endl;
      break;
    case 2:
      cerr << endl << "$PROMPT$ create_mount_point" << endl;
      break;
    default:
      break;
  }
  res = fgets(answer, sizeof(answer), stdin);

  if (res != 0 && toupper(answer[0]) == 'Y') {
    int result = mkdir(path, mode);
    if (result < 0) {
      perror(_("Unable to create directory: "));
      return false;
    } else
      return true;
  } else {
    // Directory not created, by user request
    cerr << _("Directory not created.") << "\n";
    return false;
  }
}
开发者ID:UIKit0,项目名称:encfs,代码行数:35,代码来源:FileUtils.cpp

示例7: showVersion

static int showVersion(int argc, char **argv) {
  (void)argc;
  (void)argv;
  // xgroup(usage)
  cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n";

  return EXIT_SUCCESS;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:8,代码来源:encfsctl.cpp

示例8: checkDir

static bool checkDir(string &rootDir) {
  if (!isDirectory(rootDir.c_str())) {
    cerr << autosprintf(_("directory %s does not exist.\n"), rootDir.c_str());
    return false;
  }
  if (rootDir[rootDir.length() - 1] != '/') rootDir.append("/");

  return true;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:9,代码来源:encfsctl.cpp

示例9: usage

static void usage(const char *name) {
  // xgroup(usage)
  cerr << autosprintf(_("Build: encfs version %s"), VERSION) << "\n\n"
       // xgroup(usage)
       << autosprintf(
              _("Usage: %s [options] rootDir mountPoint [-- [FUSE Mount "
                "Options]]"),
              name) << "\n\n"
       // xgroup(usage)
       << _("Common Options:\n"
            "  -H\t\t\t"
            "show optional FUSE Mount Options\n"
            "  -s\t\t\t"
            "disable multithreaded operation\n"
            "  -f\t\t\t"
            "run in foreground (don't spawn daemon).\n"
            "\t\t\tError messages will be sent to stderr\n"
            "\t\t\tinstead of syslog.\n")

       // xgroup(usage)
       << _("  -v, --verbose\t\t"
            "verbose: output encfs debug messages\n"
            "  -i, --idle=MINUTES\t"
            "Auto unmount after period of inactivity\n"
            "  --anykey\t\t"
            "Do not verify correct key is being used\n"
            "  --forcedecode\t\t"
            "decode data even if an error is detected\n"
            "\t\t\t(for filesystems using MAC block headers)\n")
       << _("  --public\t\t"
            "act as a typical multi-user filesystem\n"
            "\t\t\t(encfs must be run as root)\n") << _("  --reverse\t\t"
                                                        "reverse encryption\n")

       // xgroup(usage)
       << _("  --extpass=program\tUse external program for password prompt\n"
            "\n"
            "Example, to mount at ~/crypt with raw storage in ~/.crypt :\n"
            "    encfs ~/.crypt ~/crypt\n"
            "\n")
       // xgroup(usage)
       << _("For more information, see the man page encfs(1)") << "\n" << endl;
}
开发者ID:Ledest,项目名称:encfs,代码行数:43,代码来源:main.cpp

示例10: selectKDFDuration

static int selectKDFDuration() {
  cout << autosprintf(_("Select desired KDF duration in milliseconds.\n"
                        "The default is 500 (half a second): "));

  char answer[10];
  char *res = fgets( answer, sizeof(answer), stdin );
  int duration = (res == 0 ? 0 : atoi( answer ));
  cout << "\n";

  return duration;
}
开发者ID:bentolor,项目名称:encfs,代码行数:11,代码来源:FileUtils.cpp

示例11: usage

static void usage(const char *name) {
  cerr << autosprintf(_("encfsctl version %s"), VERSION) << "\n"
       << _("Usage:\n")
       // displays usage commands, eg "./encfs (root dir) ..."
       // xgroup(usage)
       << autosprintf(
              _("%s (root dir)\n"
                "  -- displays information about the filesystem, or \n"),
              name);

  int offset = 0;
  while (commands[offset].name != 0) {
    if (commands[offset].argStr != 0) {
      cerr << "encfsctl " << commands[offset].name << " "
           << commands[offset].argStr << "\n"
           << gettext(commands[offset].usageStr) << "\n";
    }
    ++offset;
  }

  cerr << "\n"
       // xgroup(usage)
       << autosprintf(_("Example: \n%s info ~/.crypt\n"), name) << "\n";
}
开发者ID:Konubinix,项目名称:encfs,代码行数:24,代码来源:encfsctl.cpp

示例12: cmd_showcruft

/*
    iterate recursively through the filesystem and print out names of files
    which have filenames which cannot be decoded with the given key..
*/
static int cmd_showcruft(int argc, char **argv) {
  (void)argc;

  RootPtr rootInfo = initRootInfo(argv[1]);

  if (!rootInfo) return EXIT_FAILURE;

  int filesFound = showcruft(rootInfo, "/");

  // TODO: the singular version should say "Found an invalid file", but all the
  // translations
  // depend upon this broken singular form, so it isn't easy to change.
  cerr << autosprintf(ngettext("Found %i invalid file.",
                               "Found %i invalid files.", filesFound),
                      filesFound) << "\n";

  return EXIT_SUCCESS;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:22,代码来源:encfsctl.cpp

示例13: selectNameCoding

static
Interface selectNameCoding(const CipherV1::CipherAlgorithm &alg)
{
  for(;;)
  {
    // figure out what cipher they want to use..
    // xgroup(setup)
    cout << _("The following filename encoding algorithms are available:")
      << "\n";
    NameIO::AlgorithmList algorithms = NameIO::GetAlgorithmList();
    NameIO::AlgorithmList::const_iterator it;
    int optNum = 1;
    map<int, NameIO::AlgorithmList::const_iterator> algMap;
    for(it = algorithms.begin(); it != algorithms.end(); ++it)
    {
      cout << optNum << ". " << it->name
        << " : " << gettext(it->description.c_str()) << "\n";
      algMap[optNum++] = it;
    }

    // xgroup(setup)
    cout << "\n" << _("Enter the number corresponding to your choice: ");
    char answer[10];
    char *res = fgets( answer, sizeof(answer), stdin );
    int algNum = (res == 0 ? 0 : atoi( answer ));
    cout << "\n";

    if( algNum < 1 || algNum >= optNum )
    {
      cerr << _("Invalid selection.") << "\n";
      continue;
    }

    it = algMap[algNum];

    // xgroup(setup)
    cout << autosprintf(_("Selected algorithm \"%s\""), it->name.c_str()) 
      << "\"\n\n";

    return it->iface;
  }
}
开发者ID:bentolor,项目名称:encfs,代码行数:42,代码来源:FileUtils.cpp

示例14: showcruft

int showcruft(const std::shared_ptr<EncFS_Root> &rootInfo,
              const char *dirName) {
  int found = 0;
  DirTraverse dt = rootInfo->root->openDir(dirName);
  if (dt.valid()) {
    bool showedDir = false;
    for (string name = dt.nextInvalid(); !name.empty();
         name = dt.nextInvalid()) {
      string cpath = rootInfo->root->cipherPath(dirName);
      cpath += '/';
      cpath += name;

      if (!showedDir) {
        // just before showing a list of files in a directory
        cout << autosprintf(_("In directory %s: \n"), dirName);
        showedDir = true;
      }
      ++found;
      cout << cpath << "\n";
    }

    // now go back and look for directories to recurse into..
    dt = rootInfo->root->openDir(dirName);
    if (dt.valid()) {
      for (string name = dt.nextPlaintextName(); !name.empty();
           name = dt.nextPlaintextName()) {
        if (name == "." || name == "..") continue;

        string plainPath = dirName;
        plainPath += '/';
        plainPath += name;

        string cpath = rootInfo->root->cipherPath(plainPath.c_str());

        if (isDirectory(cpath.c_str()))
          found += showcruft(rootInfo, plainPath.c_str());
      }
    }
  }

  return found;
}
开发者ID:aidan-fitz,项目名称:encfs,代码行数:42,代码来源:encfsctl.cpp

示例15: do_chpasswd

static int do_chpasswd(bool useStdin, bool annotate, int argc, char **argv) {
  (void)argc;
  string rootDir = argv[1];
  if (!checkDir(rootDir)) return EXIT_FAILURE;

  shared_ptr<EncFSConfig> config(new EncFSConfig);
  ConfigType cfgType = readConfig(rootDir, config);

  if (cfgType == Config_None) {
    cout << _("Unable to load or parse config file\n");
    return EXIT_FAILURE;
  }

  // instanciate proper cipher
  shared_ptr<Cipher> cipher = Cipher::New(config->cipherIface, config->keySize);
  if (!cipher) {
    cout << autosprintf(_("Unable to find specified cipher \"%s\"\n"),
                        config->cipherIface.name().c_str());
    return EXIT_FAILURE;
  }

  // ask for existing password
  cout << _("Enter current Encfs password\n");
  if (annotate) cerr << "$PROMPT$ passwd" << endl;
  CipherKey userKey = config->getUserKey(useStdin);
  if (!userKey) return EXIT_FAILURE;

  // decode volume key using user key -- at this point we detect an incorrect
  // password if the key checksum does not match (causing readKey to fail).
  CipherKey volumeKey = cipher->readKey(config->getKeyData(), userKey);

  if (!volumeKey) {
    cout << _("Invalid password\n");
    return EXIT_FAILURE;
  }

  // Now, get New user key..
  userKey.reset();
  cout << _("Enter new Encfs password\n");
  // reinitialize salt and iteration count
  config->kdfIterations = 0;  // generate new

  if (useStdin) {
    if (annotate) cerr << "$PROMPT$ new_passwd" << endl;
    userKey = config->getUserKey(true);
  } else
    userKey = config->getNewUserKey();

  // re-encode the volume key using the new user key and write it out..
  int result = EXIT_FAILURE;
  if (userKey) {
    int encodedKeySize = cipher->encodedKeySize();
    unsigned char *keyBuf = new unsigned char[encodedKeySize];

    // encode volume key with new user key
    cipher->writeKey(volumeKey, keyBuf, userKey);
    userKey.reset();

    config->assignKeyData(keyBuf, encodedKeySize);
    delete[] keyBuf;

    if (saveConfig(cfgType, rootDir, config)) {
      // password modified -- changes volume key of filesystem..
      cout << _("Volume Key successfully updated.\n");
      result = EXIT_SUCCESS;
    } else {
      cout << _("Error saving modified config file.\n");
    }
  } else {
    cout << _("Error creating key\n");
  }

  volumeKey.reset();

  return result;
}
开发者ID:Konubinix,项目名称:encfs,代码行数:76,代码来源:encfsctl.cpp


注:本文中的gnu类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。