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

📄 sysstr.c

📁 文件传输协议linux 下vsftpd2.1.0.tar.gz
💻 C
字号:
/* * Part of Very Secure FTPd * Licence: GPL v2 * Author: Chris Evans * sysstr.c * * This file basically wraps system functions so that we can deal in our * nice abstracted string buffer objects. */#include "sysstr.h"#include "str.h"#include "secbuf.h"#include "sysutil.h"#include "defs.h"#include "utility.h"#include "tunables.h"voidstr_getcwd(struct mystr* p_str){  static char* p_getcwd_buf;  char* p_ret;  if (p_getcwd_buf == 0)  {    vsf_secbuf_alloc(&p_getcwd_buf, VSFTP_PATH_MAX);  }  /* In case getcwd() fails */  str_empty(p_str);  p_ret = vsf_sysutil_getcwd(p_getcwd_buf, VSFTP_PATH_MAX);  if (p_ret != 0)  {    str_alloc_text(p_str, p_getcwd_buf);  }}intstr_write_loop(const struct mystr* p_str, const int fd){  return vsf_sysutil_write_loop(fd, str_getbuf(p_str), str_getlen(p_str));}intstr_read_loop(struct mystr* p_str, const int fd){  return vsf_sysutil_read_loop(    fd, (char*) str_getbuf(p_str), str_getlen(p_str));}intstr_mkdir(const struct mystr* p_str, const unsigned int mode){  return vsf_sysutil_mkdir(str_getbuf(p_str), mode);}intstr_rmdir(const struct mystr* p_str){  return vsf_sysutil_rmdir(str_getbuf(p_str));}intstr_unlink(const struct mystr* p_str){  return vsf_sysutil_unlink(str_getbuf(p_str));}intstr_chdir(const struct mystr* p_str){  return vsf_sysutil_chdir(str_getbuf(p_str));}intstr_open(const struct mystr* p_str, const enum EVSFSysStrOpenMode mode){  enum EVSFSysUtilOpenMode open_mode = kVSFSysStrOpenUnknown;  switch (mode)  {    case kVSFSysStrOpenReadOnly:      open_mode = kVSFSysUtilOpenReadOnly;      break;    default:      bug("unknown mode value in str_open");      break;  }  return vsf_sysutil_open_file(str_getbuf(p_str), open_mode);}intstr_stat(const struct mystr* p_str, struct vsf_sysutil_statbuf** p_ptr){  return vsf_sysutil_stat(str_getbuf(p_str), p_ptr);}intstr_lstat(const struct mystr* p_str, struct vsf_sysutil_statbuf** p_ptr){  return vsf_sysutil_lstat(str_getbuf(p_str), p_ptr);}intstr_create(const struct mystr* p_str){  return vsf_sysutil_create_file(str_getbuf(p_str));}intstr_create_overwrite(const struct mystr* p_str){  return vsf_sysutil_create_overwrite_file(str_getbuf(p_str));}intstr_create_append(const struct mystr* p_str){  return vsf_sysutil_create_or_open_file(      str_getbuf(p_str), tunable_file_open_mode);}intstr_chmod(const struct mystr* p_str, unsigned int mode){  return vsf_sysutil_chmod(str_getbuf(p_str), mode);}intstr_rename(const struct mystr* p_from_str, const struct mystr* p_to_str){  return vsf_sysutil_rename(str_getbuf(p_from_str), str_getbuf(p_to_str));}struct vsf_sysutil_dir*str_opendir(const struct mystr* p_str){  return vsf_sysutil_opendir(str_getbuf(p_str));}voidstr_next_dirent(struct mystr* p_filename_str, struct vsf_sysutil_dir* p_dir){  const char* p_filename = vsf_sysutil_next_dirent(p_dir);  str_empty(p_filename_str);  if (p_filename != 0)  {    str_alloc_text(p_filename_str, p_filename);  }}intstr_readlink(struct mystr* p_str, const struct mystr* p_filename_str){  static char* p_readlink_buf;  int retval;  if (p_readlink_buf == 0)  {    vsf_secbuf_alloc(&p_readlink_buf, VSFTP_PATH_MAX);  }  /* In case readlink() fails */  str_empty(p_str);  /* Note: readlink(2) does not NULL terminate, but our wrapper does */  retval = vsf_sysutil_readlink(str_getbuf(p_filename_str), p_readlink_buf,                                VSFTP_PATH_MAX);  if (vsf_sysutil_retval_is_error(retval))  {    return retval;  }  str_alloc_text(p_str, p_readlink_buf);  return 0;}struct vsf_sysutil_user*str_getpwnam(const struct mystr* p_user_str){  return vsf_sysutil_getpwnam(str_getbuf(p_user_str));}voidstr_syslog(const struct mystr* p_str, int severe){  vsf_sysutil_syslog(str_getbuf(p_str), severe);}

⌨️ 快捷键说明

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