⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 usercfg.cpp

📁 伯克利做的SFTP安全文件传输协议
💻 CPP
字号:
// usercfg.cpp// implementation of usercfg.h for sftpc// copyright SafeTP Development Group, Inc., 2000  Terms of use are as specified in license.txt#include "usercfg.h"       // this module#include "nonport.h"       // getCurrentUsername, ensurePath#include "xassert.h"       // xfailure#include <stdlib.h>        // getenv#include <iostream.h>      // coutstring userConfigDir(){  // only do the full procedure once  static string *previousVal = NULL;        // thread-safety: worst case is a one-time leak  if (previousVal != NULL) {    return *previousVal;  }  string ret;  // ideally, the user specifies where to store config info  // via an environment variable  char const *envp = getenv("SAFETP_CONFIG");  if (envp) {    ret = envp;    // verify the path exists; create parts as necessary    if (!ensurePath(ret, true /*isDirectory*/)) {      xfailure(stringb("cannot access directory " << ret <<                       "; environment variable SAFETP_CONFIG needs to "                       "be fixed"));    }  }  else {    // let's let /var/tmp/$user be the default; it's adequate in terms of    // usability, and is secure    char user[80];    getCurrentUsername(user, 80);    ret = stringb("/var/tmp/" << user);    // try it    if (!ensurePath(ret, true /*isDirectory*/)) {      xfailure(stringb("cannot access directory " << ret <<                       "; try setting environment variable SAFETP_CONFIG"));    }  }  previousVal = new string(ret);  return ret;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -