亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? homedir.c

?? BCAST Implementation for NS2
?? C
字號:
/* * Copyright (c) 2000, 2001 by Martin C. Shepherd. *  * All rights reserved. *  * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, and/or sell copies of the Software, and to permit persons * to whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. *  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT * OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR * HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL * INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. *  * Except as contained in this notice, the name of a copyright holder * shall not be used in advertising or otherwise to promote the sale, use * or other dealings in this Software without prior written authorization * of the copyright holder. */#include <stdio.h>#include <stdlib.h>#include <string.h>#include <errno.h>#include <unistd.h>#include <sys/types.h>#include <sys/stat.h>#include <pwd.h>#include "pathutil.h"#include "homedir.h"/* * Set the max length of the error-reporting string. There is no point * in this being longer than the width of a typical terminal window. * In composing error messages, I have assumed that this number is * at least 80, so you don't decrease it below this number. */#define ERRLEN 200/* * Use the reentrant POSIX threads versions of the password lookup functions? */#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 199506L#define THREAD_COMPATIBLE 1#endif/* * Provide a password buffer size fallback in case the max size reported * by sysconf() is said to be indeterminate. */#define DEF_GETPW_R_SIZE_MAX 1024/* * The resources needed to lookup and record a home directory are * maintained in objects of the following type. */struct HomeDir {  char errmsg[ERRLEN+1]; /* Error-report buffer */  char *buffer;          /* A buffer for reading password entries and */                         /*  directory paths. */  int buflen;            /* The allocated size of buffer[] */#ifdef THREAD_COMPATIBLE  struct passwd pwd;     /* The password entry of a user */#endif};static const char *hd_getpwd(HomeDir *home);/*....................................................................... * Create a new HomeDir object. * * Output: *  return  HomeDir *  The new object, or NULL on error. */HomeDir *_new_HomeDir(void){  HomeDir *home;  /* The object to be returned */  size_t pathlen; /* The estimated maximum size of a pathname *//* * Allocate the container. */  home = (HomeDir *) malloc(sizeof(HomeDir));  if(!home) {    fprintf(stderr, "_new_HomeDir: Insufficient memory.\n");    return NULL;  };/* * Before attempting any operation that might fail, initialize the * container at least up to the point at which it can safely be passed * to _del_HomeDir(). */  home->errmsg[0] = '\0';  home->buffer = NULL;  home->buflen = 0;/* * Allocate the buffer that is used by the reentrant POSIX password-entry * lookup functions. */#ifdef THREAD_COMPATIBLE/* * Get the length of the buffer needed by the reentrant version * of getpwnam(). */#ifndef _SC_GETPW_R_SIZE_MAX  home->buflen = DEF_GETPW_R_SIZE_MAX;#else  errno = 0;  home->buflen = sysconf(_SC_GETPW_R_SIZE_MAX);/* * Limit not available? */  if(home->buflen < 0) {/* * Was the limit unavailable because of an error? */    if(errno) {      fprintf(stderr, "syconf(_SC_GETPW_R_SIZE_MAX) -> %s\n", strerror(errno));      return _del_HomeDir(home);    };/* * If errno isn't set, it means that the limit is indeterminate. In this * case substitute a suitably large fallback value. */    home->buflen = DEF_GETPW_R_SIZE_MAX;  };#endif#endif/* * If the existing buffer length requirement is too restrictive to record * a pathname, increase its length. */  pathlen = _pu_pathname_dim();  if(pathlen > home->buflen)    home->buflen = pathlen;/* * Allocate a work buffer. */  home->buffer = (char *) malloc(home->buflen);  if(!home->buffer) {    fprintf(stderr, "_new_HomeDir: Insufficient memory.");    return _del_HomeDir(home);  };  return home;}/*....................................................................... * Delete a HomeDir object. * * Input: *  home   HomeDir *  The object to be deleted. * Output: *  return HomeDir *  The deleted object (always NULL). */HomeDir *_del_HomeDir(HomeDir *home){  if(home) {    if(home->buffer)      free(home->buffer);    free(home);  };  return NULL;}/*....................................................................... * Lookup the home directory of a given user in the password file. * * Input: *  home      HomeDir *   The resources needed to lookup the home directory. *  user   const char *   The name of the user to lookup, or "" to lookup *                        the home directory of the person running the *                        program. * Output: *  return const char *   The home directory. If the library was compiled *                        with threads, this string is part of the HomeDir *                        object and will change on subsequent calls. If *                        the library wasn't compiled to be reentrant, *                        then the string is a pointer into a static string *                        in the C library and will change not only on *                        subsequent calls to this function, but also if *                        any calls are made to the C library password *                        file lookup functions. Thus to be safe, you should *                        make a copy of this string before calling any *                        other function that might do a password file *                        lookup. * *                        On error, NULL is returned and a description *                        of the error can be acquired by calling *                        _hd_last_home_dir_error(). */const char *_hd_lookup_home_dir(HomeDir *home, const char *user){  const char *home_dir;   /* A pointer to the home directory of the user *//* * If no username has been specified, arrange to lookup the current * user. */  int login_user = !user || *user=='\0';/* * Check the arguments. */  if(!home) {    fprintf(stderr, "_hd_lookup_home_dir: NULL argument(s).\n");    return NULL;  };/* * Handle the ksh "~+". This expands to the absolute path of the * current working directory. */  if (!login_user && strcmp(user, "+") == 0) {    home_dir = hd_getpwd(home);    if(!home_dir) {      strncpy(home->errmsg, "Cannot determine current directory.", ERRLEN);      home->errmsg[ERRLEN] = '\0';      return NULL;    }    return home_dir;  };/* * Look up the password entry of the user. * First the POSIX threads version - this is painful! */#ifdef THREAD_COMPATIBLE  {    struct passwd *ret; /* The returned pointer to pwd */    int status;         /* The return value of getpwnam_r() *//* * Look up the password entry of the specified user. */    if(login_user)      status = getpwuid_r(geteuid(), &home->pwd, home->buffer, home->buflen,			  &ret);    else      status = getpwnam_r(user, &home->pwd, home->buffer, home->buflen, &ret);    if(status || !ret) {      const char *fmt = "User '%.*s' doesn't exist.";      sprintf(home->errmsg, fmt, ERRLEN - strlen(fmt),  user);      return NULL;    };/* * Get a pointer to the string that holds the home directory. */    home_dir = home->pwd.pw_dir;  };/* * Now the classic unix version. */#else  {    struct passwd *pwd = login_user ? getpwuid(geteuid()) : getpwnam(user);    if(!pwd) {      const char *fmt = "User '%.*s' doesn't exist.";      sprintf(home->errmsg, fmt, ERRLEN - strlen(fmt),  user);      return NULL;    };/* * Get a pointer to the home directory. */    home_dir = pwd->pw_dir;  };#endif  return home_dir;}/*....................................................................... * Return a description of the last error that caused _hd_lookup_home_dir() * to return NULL. * * Input: *  home   HomeDir *  The resources needed to record the home directory. * Output: *  return    char *  The description of the last error. */const char *_hd_last_home_dir_error(HomeDir *home){  return home ? home->errmsg : "NULL HomeDir argument";}/*....................................................................... * The _hd_scan_user_home_dirs() function calls a user-provided function * for each username known by the system, passing the function both * the name and the home directory of the user. * * Input: *  home             HomeDir *  The resource object for reading home *                              directories. *  data                void *  Anonymous data to be passed to the *                              callback function. *  callback_fn  HOME_DIR_FN(*) The function to call for each user. * Output: *  return               int    0 - Successful completion. *                              1 - An error occurred. A description *                                  of the error can be obtained by *                                  calling _hd_last_home_dir_error(). */int _hd_scan_user_home_dirs(HomeDir *home, void *data, HOME_DIR_FN(*callback_fn)){  int waserr = 0;       /* True after errors *//* * Check the arguments. */  if(!home || !callback_fn) {    if(home)      strcpy(home->errmsg,	     "_hd_scan_user_home_dirs: Missing callback function");    return 1;  };/* * There are no reentrant versions of getpwent() etc for scanning * the password file, so disable username completion when the * library is compiled to be reentrant. */#if !defined(_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 199506L  {    struct passwd *pwd;   /* The pointer to the latest password entry *//* * Open the password file. */    setpwent();/* * Read the contents of the password file, looking for usernames * that start with the specified prefix, and adding them to the * list of matches. */    while((pwd = getpwent()) != NULL && !waserr)      waserr = callback_fn(data, pwd->pw_name, pwd->pw_dir, home->errmsg,			   ERRLEN);/* * Close the password file. */    endpwent();  };#endif/* * Under ksh ~+ stands for the absolute pathname of the current working * directory. */  if (!waserr) {    const char *pwd = hd_getpwd(home);    if(pwd) {      waserr = callback_fn(data, "+", pwd, home->errmsg, ERRLEN);    } else {      waserr = 1;      strncpy(home->errmsg, "Cannot determine current directory.", ERRLEN);      home->errmsg[ERRLEN] = '\0';    };  };  return waserr;}/*....................................................................... * Return the value of getenv("PWD") if this points to the current * directory, or the return value of getcwd() otherwise. The reason for * prefering PWD over getcwd() is that the former preserves the history * of symbolic links that have been traversed to reach the current * directory. This function is designed to provide the equivalent * expansion of the ksh ~+ directive, which normally returns its value * of PWD. * * Input: *  home      HomeDir *  The resource object for reading home directories. * Output: *  return const char *  A pointer to either home->buffer, where the *                       pathname is recorded, the string returned by *                       getenv("PWD"), or NULL on error. */static const char *hd_getpwd(HomeDir *home){/* * Get the absolute path of the current working directory. */  char *cwd = getcwd(home->buffer, home->buflen);/* * Some shells set PWD with the path of the current working directory. * This will differ from cwd in that it won't have had symbolic links * expanded. */  const char *pwd = getenv("PWD");/* * If PWD was set, and it points to the same directory as cwd, return * its value. Note that it won't be the same if the current shell or * the current program has changed directories, after inheriting PWD * from a parent shell. */  struct stat cwdstat, pwdstat;  if(pwd && cwd && stat(cwd, &cwdstat)==0 && stat(pwd, &pwdstat)==0 &&     cwdstat.st_dev == pwdstat.st_dev && cwdstat.st_ino == pwdstat.st_ino)    return pwd;/* * Also return pwd if getcwd() failed, since it represents the best * information that we have access to. */  if(!cwd)    return pwd;/* * In the absence of a valid PWD, return cwd. */  return cwd;}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久三级国产网站| 成人性生交大合| 欧美日韩国产片| 亚洲国产精品久久人人爱| 欧美日韩美少妇| 日本美女一区二区三区视频| 538在线一区二区精品国产| 秋霞电影一区二区| 久久免费偷拍视频| 懂色av中文一区二区三区| 中文字幕精品综合| 91免费视频网| 亚洲图片欧美一区| 欧美一区二区三区在线观看视频| 奇米在线7777在线精品| 精品国产麻豆免费人成网站| 国产成人精品一区二区三区四区| 亚洲视频资源在线| 欧美在线免费观看亚洲| 日韩成人免费看| 国产欧美一区二区三区鸳鸯浴| 91在线云播放| 日本va欧美va瓶| 国产精品网曝门| 欧美日韩国产一区| 国产精品18久久久久久久久| 国产精品久久久久久久久果冻传媒| 在线视频国内一区二区| 美女视频一区在线观看| 国产日韩欧美精品一区| 91成人国产精品| 韩日欧美一区二区三区| 免费视频最近日韩| 中文字幕av一区二区三区免费看 | 日韩免费在线观看| av电影一区二区| 蜜桃久久av一区| 亚洲欧美aⅴ...| 精品粉嫩超白一线天av| 91极品美女在线| 成人中文字幕电影| 日韩电影一二三区| 一区二区三区欧美视频| 久久久久国产一区二区三区四区 | 成人激情小说网站| 日本麻豆一区二区三区视频| 最新欧美精品一区二区三区| 欧美一区二区三区免费大片| 99在线热播精品免费| 精品一区二区日韩| 亚洲综合区在线| 国产精品无遮挡| 亚洲精品一区二区三区蜜桃下载| 在线观看网站黄不卡| 成人国产在线观看| 国产一本一道久久香蕉| 天堂影院一区二区| 亚洲一区在线观看网站| 国产精品福利一区二区| 久久在线免费观看| 精品国产一二三| 欧美一区二区三区不卡| 日本韩国精品一区二区在线观看| 国产高清不卡一区| 极品少妇xxxx精品少妇| 日韩国产高清影视| 偷窥少妇高潮呻吟av久久免费 | 亚洲一区二区三区中文字幕| 国产精品日日摸夜夜摸av| 欧美极品美女视频| 久久尤物电影视频在线观看| 精品国产乱码久久久久久夜甘婷婷| 欧美精品国产精品| 欧美色视频在线观看| 精品视频123区在线观看| 一本色道久久加勒比精品| 丁香啪啪综合成人亚洲小说 | 国产欧美一区二区三区沐欲| 精品久久久久香蕉网| 精品国产一区二区三区久久久蜜月| 欧美一区二区三区日韩| 欧美一个色资源| 日韩精品一区二区三区视频在线观看| 91麻豆精品久久久久蜜臀| 欧美精品18+| 欧美草草影院在线视频| 精品精品国产高清a毛片牛牛 | 日韩高清欧美激情| 日本女人一区二区三区| 久久99久国产精品黄毛片色诱| 美腿丝袜亚洲三区| 精品一区二区三区免费视频| 国产一区二区福利| 国产麻豆日韩欧美久久| 成人动漫视频在线| 99久久久无码国产精品| 色噜噜夜夜夜综合网| 欧美性大战久久久久久久蜜臀| 欧美日本一道本在线视频| 欧美欧美午夜aⅴ在线观看| 日韩欧美高清dvd碟片| 久久久久国产一区二区三区四区 | 日韩视频一区二区三区在线播放| 日韩欧美一区电影| 中文字幕av免费专区久久| **欧美大码日韩| 全部av―极品视觉盛宴亚洲| 激情综合网激情| av一区二区三区在线| 欧美天天综合网| 欧美成va人片在线观看| 国产精品色在线观看| 亚洲第一狼人社区| 国产美女在线观看一区| 久久久久久一二三区| 亚洲人成网站影音先锋播放| 日本v片在线高清不卡在线观看| 国产中文一区二区三区| 色婷婷久久久亚洲一区二区三区| 在线播放中文一区| 欧美国产精品劲爆| 日韩高清电影一区| 成人av手机在线观看| 91超碰这里只有精品国产| 久久精品人人做人人爽人人| 亚洲综合另类小说| 国产精品一级在线| 4438x亚洲最大成人网| 国产欧美精品一区| 视频一区中文字幕| www.av亚洲| 欧美成人官网二区| 亚洲午夜三级在线| 国产精品一级黄| 91精品国产麻豆| 亚洲免费三区一区二区| 国内精品伊人久久久久av一坑| 91高清视频在线| 中文字幕精品一区二区三区精品| 日韩av不卡一区二区| 91视频国产资源| 国产亚洲综合av| 免费欧美在线视频| 欧美视频在线一区| 亚洲欧洲韩国日本视频 | 国产精品一区二区在线观看网站| 在线这里只有精品| 中文字幕中文字幕在线一区| 激情小说欧美图片| 日韩一级二级三级| 亚洲第一精品在线| 欧美在线你懂的| 亚洲伦理在线精品| 99精品在线免费| 国产精品美女久久久久aⅴ国产馆 国产精品美女久久久久av爽李琼 国产精品美女久久久久高潮 | 亚洲精品一区在线观看| 午夜精品影院在线观看| 欧亚一区二区三区| 亚洲三级免费观看| 国产99久久久久| 久久只精品国产| 国产资源在线一区| 精品久久人人做人人爽| 男女男精品视频网| 91精品国模一区二区三区| 亚洲一区二区三区爽爽爽爽爽| 99在线精品观看| 亚洲品质自拍视频网站| 99久久精品免费| 亚洲丝袜另类动漫二区| 91香蕉视频在线| 亚洲一区二区三区三| 91福利资源站| 亚洲成国产人片在线观看| 欧美综合亚洲图片综合区| 一区二区三区产品免费精品久久75| 不卡av在线网| 亚洲乱码国产乱码精品精98午夜 | 91蜜桃视频在线| 亚洲综合色自拍一区| 欧美日韩国产精品成人| 婷婷六月综合网| 精品福利二区三区| 日韩欧美123| 国产成人精品免费| 中文字幕亚洲精品在线观看 | 欧美久久久影院| 男人的j进女人的j一区| 欧美精品一区在线观看| 国产a精品视频| 日韩毛片一二三区| 精品视频在线视频| 麻豆视频观看网址久久| 国产午夜三级一区二区三| 97久久超碰国产精品| 香蕉乱码成人久久天堂爱免费| 日韩免费看网站| 成人白浆超碰人人人人| 亚洲午夜免费福利视频| 精品国内二区三区|