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


C++ realpath函数代码示例

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


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

示例1: start_server

int start_server(int port_number, const char* dir_name, int period)
{
	pthread_t tid;                                  /* Passed to pthread_create */
	struct thread_arg* targ;                /* Used to pass arguments to threads */
	pthread_attr_t tattr;                   /* Specifies that thread should be detached */
	fd_set master;                                  /* Keep track of all connections / pipes to multiplex */
	fd_set read_fds;                        /* Copy of master for select to populate */
	int fdmax;                                              /* Highest numbered file descriptor */
	int i;                                                  /* Used to index the master fd list */
	int listener;                                   /* Listening socket of the server */
	int newfd;                                      /* New connection socket fd */
	struct sockaddr_in local_addr;  /* Local connection info */
	struct sockaddr_in remote_addr; /* Remote connection info */
	socklen_t addr_len;                     /* Address length */
	int pipe_buff[1];                               /* Get sockets into here */
	pipe_buff[0] = 0;

	// Init signal mask
	struct sigaction sa;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;
	sa.sa_handler = SIG_IGN;

	// Start each thread in detached mode, since we don't care about
	// their return values
	pthread_attr_init(&tattr);
	pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED);

	// Initialize the memory pool to store the direntries
	direntry_pool = init_mempool(sizeof(struct direntry), 512);

	// Set done to 0
	done = 0;

	// Initialize the clients linked list
	clients = (struct clientlist*)malloc(sizeof(struct clientlist));
	clients->head = NULL;
	clients->tail = NULL;
	clients->count = 0;

	// Copy into global init_dir
	strcpy(init_dir, dir_name);
	gperiod = period;

	// Initialize pipe
	if (pipe(remove_client_pipes) < 0) {
		syslog(LOG_ERR, "Cannot create IPC in server.");
		exit(1);
	}

	// Get full path of the directory
	if (realpath(dir_name, full_path) == NULL) {
		syslog(LOG_ERR, "Cannot resolve full path.");
		exit(1);
	}

#ifdef DAEMONIZE
	create_daemon("dirapp");
#endif
#ifndef DAEMONIZE
	openlog("dirapp", LOG_CONS, LOG_DAEMON);
#endif

	// Make sure SIGPIPE is blocked
	if (sigaction(SIGPIPE, &sa, NULL) < 0) {
		syslog(LOG_WARNING, "SIGPIPE error");
	}

	// Signals for the signal thread to handle
	sigemptyset(&mask);
	sigaddset(&mask, SIGHUP);
	sigaddset(&mask, SIGTERM);
	sigaddset(&mask, SIGINT);
	sigaddset(&mask, SIGALRM);

	// Set the mask
	if (pthread_sigmask(SIG_BLOCK, &mask, NULL) != 0)
		syslog(LOG_WARNING, "pthread_sigmask failed");

	// Initialize file descriptor lists
	FD_ZERO(&master);
	FD_ZERO(&read_fds);

	// Setup local connection info
	memset(&local_addr, 0, sizeof(local_addr));
	local_addr.sin_family = AF_INET;
	local_addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	local_addr.sin_port = htons(port_number);

	// Create listener socket
	listener = socket(AF_INET, SOCK_STREAM, 0);

	// Try to bind
	if (bind(listener, (struct sockaddr*)&local_addr, sizeof(local_addr))) {
		syslog(LOG_ERR, "Cannot bind socket to address");
		exit(1);
	}

	// Now listen!
	if (listen(listener, MAX_CLIENTS) < 0) {
//.........这里部分代码省略.........
开发者ID:cmoresid,项目名称:dirapp,代码行数:101,代码来源:server.c

示例2: proxenet_add_new_plugins

/**
 * Plugin name structure *MUST* be  `PLUGIN_DIR/[<priority>]<name>.<ext>`
 * <priority> is an int in [1, 9]. If <priority> is found as the first char of the
 * file name, it will be applied to the plugin. If no priority is specify, a default
 * priority will be applied.
 *
 * If a file does not match this pattern, it will be discarded
 *
 * @param plugin_path is the path to look for plugins
 * @param plugin_name is the name of the plugin to add. If NULL, this function will try
 *        to *all* the files in the directory.
 * @return the number of added plugins on success, -1 on error
 */
int proxenet_add_new_plugins(char* plugin_path, char* plugin_name)
{
	struct dirent *dir_ptr=NULL;
	DIR *dir = NULL;
	char* name = NULL;
	short type=-1, priority;
	int d_name_len;
        bool add_all = (plugin_name==NULL)?true:false;
        unsigned int nb_plugin_added = 0;

#ifdef DEBUG
        if (add_all)
                xlog(LOG_DEBUG, "Trying to add all files in '%s'\n", plugin_path);
        else
                xlog(LOG_DEBUG, "Trying to add '%s/%s'\n", plugin_path, plugin_name);
#endif
	dir = opendir(plugin_path);
	if (dir == NULL) {
		xlog(LOG_ERROR, "Failed to open '%s': %s\n", plugin_path, strerror(errno));
		return -1;
	}

	while ((dir_ptr=readdir(dir))) {
		if (strcmp(dir_ptr->d_name,".")==0)
                        continue;

		if (strcmp(dir_ptr->d_name,"..")==0)
                        continue;

                /* if add one plugin, loop until the right name */
                if (!add_all && strcmp(dir_ptr->d_name, plugin_name)!=0)
                        continue;

                if (dir_ptr->d_type == DT_LNK){
                        /* if entry is a symlink, ensure it's pointing to a file in plugins_path */
                        ssize_t l = -1;
                        char fullpath[PATH_MAX] = {0, };
                        char realpath_buf[PATH_MAX] = {0, };

                        l = snprintf(fullpath, PATH_MAX, "%s/%s", plugin_path, dir_ptr->d_name);
                        if(l == -1){
			        xlog(LOG_ERROR, "snprintf() failed on '%s'\n",
				     dir_ptr->d_name ,
				     errno,
				     strerror(errno));
				continue;
			}

                        if(!realpath(fullpath, realpath_buf)){
                                xlog(LOG_ERROR, "realpath failed on '%s': %d - %s\n",
                                     fullpath,
                                     errno,
                                     strerror(errno));
                                continue;
                        }

                        l = strlen(cfg->plugins_path);

                        if( strncmp(realpath_buf, cfg->plugins_path, l) != 0 )
                                continue;

                } else {
                        /* if not a symlink nor regular file, continue */
                        if (dir_ptr->d_type != DT_REG)
                                continue;
                }

                /* if first char is valid integer, this will be the plugin priority */
		if (atoi(&(dir_ptr->d_name[0])) > 0)
                        priority = (unsigned short)atoi(&(dir_ptr->d_name[0]));
                else
                        priority = (unsigned short) CFG_DEFAULT_PLUGIN_PRIORITY;

		/* plugin name  */
		d_name_len = strlen(dir_ptr->d_name);
		if (d_name_len > 510)
                        continue;

		name = dir_ptr->d_name;

		/* plugin type */
		type = proxenet_get_plugin_type(name);
		if (type < 0)
                        continue;

                if ( proxenet_is_plugin_loaded(name) ){
                        xlog(LOG_WARNING, "A plugin named '%s' is already loaded\n", name);
//.........这里部分代码省略.........
开发者ID:JohnHoder,项目名称:proxenet,代码行数:101,代码来源:plugin.c

示例3: main

int
main (int argc, char *argv[]) {
    int portable = 0;
#if STATICLINK
    int staticlink = 1;
#else
    int staticlink = 0;
#endif
#if PORTABLE
    portable = 1;
    if (!realpath (argv[0], dbinstalldir)) {
        strcpy (dbinstalldir, argv[0]);
    }
    char *e = strrchr (dbinstalldir, '/');
    if (e) {
        *e = 0;
    }
    else {
        fprintf (stderr, "couldn't determine install folder from path %s\n", argv[0]);
        exit (-1);
    }
#else
    if (!realpath (argv[0], dbinstalldir)) {
        strcpy (dbinstalldir, argv[0]);
    }
    char *e = strrchr (dbinstalldir, '/');
    if (e) {
        *e = 0;
        struct stat st;
        char checkpath[PATH_MAX];
        snprintf (checkpath, sizeof (checkpath), "%s/.ddb_portable", dbinstalldir);
        if (!stat (checkpath, &st)) {
            if (S_ISREG (st.st_mode)) {
                portable = 1;
            }
        }
    }
    if (!portable) {
        strcpy (dbinstalldir, PREFIX);
    }
#endif

#ifdef __GLIBC__
    signal (SIGSEGV, sigsegv_handler);
#endif
    setlocale (LC_ALL, "");
    setlocale (LC_NUMERIC, "C");
#ifdef ENABLE_NLS
//    fprintf (stderr, "enabling gettext support: package=" PACKAGE ", dir=" LOCALEDIR "...\n");
    if (portable) {
        char localedir[PATH_MAX];
        snprintf (localedir, sizeof (localedir), "%s/locale", dbinstalldir);
        bindtextdomain (PACKAGE, localedir);
    }
    else {
        bindtextdomain (PACKAGE, LOCALEDIR);
    }
	bind_textdomain_codeset (PACKAGE, "UTF-8");
	textdomain (PACKAGE);
#endif

    fprintf (stderr, "starting deadbeef " VERSION "%s%s\n", staticlink ? " [static]" : "", portable ? " [portable]" : "");
    srand (time (NULL));
#ifdef __linux__
    prctl (PR_SET_NAME, "deadbeef-main", 0, 0, 0, 0);
#endif

#if PORTABLE_FULL
    if (snprintf (confdir, sizeof (confdir), "%s/config", dbinstalldir) > sizeof (confdir)) {
        fprintf (stderr, "fatal: too long install path %s\n", dbinstalldir);
        return -1;
    }

    strcpy (dbconfdir, confdir);
#else
    char *homedir = getenv ("HOME");
    if (!homedir) {
        fprintf (stderr, "unable to find home directory. stopping.\n");
        return -1;
    }

    char *xdg_conf_dir = getenv ("XDG_CONFIG_HOME");
    if (xdg_conf_dir) {
        if (snprintf (confdir, sizeof (confdir), "%s", xdg_conf_dir) > sizeof (confdir)) {
            fprintf (stderr, "fatal: XDG_CONFIG_HOME value is too long: %s\n", xdg_conf_dir);
            return -1;
        }
    }
    else {
        if (snprintf (confdir, sizeof (confdir), "%s/.config", homedir) > sizeof (confdir)) {
            fprintf (stderr, "fatal: HOME value is too long: %s\n", homedir);
            return -1;
        }
    }
    if (snprintf (dbconfdir, sizeof (dbconfdir), "%s/deadbeef", confdir) > sizeof (dbconfdir)) {
        fprintf (stderr, "fatal: out of memory while configuring\n");
        return -1;
    }
    mkdir (confdir, 0755);
#endif
//.........这里部分代码省略.........
开发者ID:Gardenya,项目名称:deadbeef,代码行数:101,代码来源:main.c

示例4: rvmInitOptions

jboolean rvmInitOptions(int argc, char* argv[], Options* options, jboolean ignoreRvmArgs) {
    char path[PATH_MAX];
    if (!realpath(argv[0], path)) {
        return FALSE;
    }

    strcpy(options->executablePath, path);

    jint i = strlen(path);
    while (i >= 0 && path[i] != '/') {
        path[i--] = '\0';
    }
    if (i >= 0 && path[i] == '/') {
        path[i] = '\0';
    }

    strcpy(options->basePath, path);

    jint firstJavaArg = 1;
    for (i = 1; i < argc; i++) {
        if (startsWith(argv[i], "-rvm:")) {
            if (!ignoreRvmArgs) {
                char* arg = &argv[i][5];
                if (startsWith(arg, "log=trace")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_TRACE;
                } else if (startsWith(arg, "log=debug")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_DEBUG;
                } else if (startsWith(arg, "log=info")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_INFO;
                } else if (startsWith(arg, "log=warn")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_WARN;
                } else if (startsWith(arg, "log=error")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_ERROR;
                } else if (startsWith(arg, "log=fatal")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_FATAL;
                } else if (startsWith(arg, "log=silent")) {
                    if (options->logLevel == 0) options->logLevel = LOG_LEVEL_SILENT;
                } else if (startsWith(arg, "mx") || startsWith(arg, "ms")) {
                    char* unit;
                    jlong n = strtol(&arg[2], &unit, 10);
                    if (n > 0) {
                        if (unit[0] != '\0') {
                            switch (unit[0]) {
                            case 'g':
                            case 'G':
                                n *= 1024 * 1024 * 1024;
                                break;
                            case 'm':
                            case 'M':
                                n *= 1024 * 1024;
                                break;
                            case 'k':
                            case 'K':
                                n *= 1024;
                                break;
                            }
                        }
                    }
                    if (startsWith(arg, "mx")) {
                        options->maxHeapSize = n;
                    } else {
                        options->initialHeapSize = n;
                    }
                } else if (startsWith(arg, "MainClass=")) {
                    if (!options->mainClass) {
                        char* s = strdup(&arg[10]);
                        jint j;
                        for (j = 0; s[j] != 0; j++) {
                            if (s[j] == '.') s[j] = '/';
                        }
                        options->mainClass = s;
                    }
                }
            }
            firstJavaArg++;
        } else {
            break;
        }
    }

    options->commandLineArgs = NULL;
    options->commandLineArgsCount = argc - firstJavaArg;
    if (options->commandLineArgsCount > 0) {
        options->commandLineArgs = &argv[firstJavaArg];
    }

    return options->mainClass != NULL;
}
开发者ID:tobium,项目名称:robovm,代码行数:88,代码来源:init.c

示例5: append_path

// Resolve a path and append it to the CLI settings structure
// The FSEvents API will, internally, resolve paths using a similar scheme.
// Performing this ahead of time makes things less confusing, IMHO.
static void append_path(const char* path)
{
#ifdef DEBUG
  fprintf(stderr, "\n");
  fprintf(stderr, "append_path called for: %s\n", path);
#endif

#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060

#ifdef DEBUG
  fprintf(stderr, "compiled against 10.6+, using CFURLCreateFileReferenceURL\n");
#endif

  CFURLRef url = CFURLCreateFromFileSystemRepresentation(NULL, (const UInt8*)path, (CFIndex)strlen(path), false);
  CFURLRef placeholder = CFURLCopyAbsoluteURL(url);
  CFRelease(url);

  CFMutableArrayRef imaginary = NULL;

  // if we don't have an existing url, spin until we get to a parent that
  // does exist, saving any imaginary components for appending back later
  while(!CFURLResourceIsReachable(placeholder, NULL)) {
#ifdef DEBUG
    fprintf(stderr, "path does not exist\n");
#endif

    CFStringRef child;

    if (imaginary == NULL) {
      imaginary = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
    }

    child = CFURLCopyLastPathComponent(placeholder);
    CFArrayInsertValueAtIndex(imaginary, 0, child);
    CFRelease(child);

    url = CFURLCreateCopyDeletingLastPathComponent(NULL, placeholder);
    CFRelease(placeholder);
    placeholder = url;

#ifdef DEBUG
    fprintf(stderr, "parent: ");
    CFShow(placeholder);
#endif
  }

#ifdef DEBUG
  fprintf(stderr, "path exists\n");
#endif

  // realpath() doesn't always return the correct case for a path, so this
  // is a funky workaround that converts a path into a (volId/inodeId) pair
  // and asks what the path should be for that. since it looks at the actual
  // inode instead of returning the same case passed in like realpath()
  // appears to do for HFS+, it should always be correct.
  url = CFURLCreateFileReferenceURL(NULL, placeholder, NULL);
  CFRelease(placeholder);
  placeholder = CFURLCreateFilePathURL(NULL, url, NULL);
  CFRelease(url);

#ifdef DEBUG
  fprintf(stderr, "path resolved to: ");
  CFShow(placeholder);
#endif

  // if we stripped off any imaginary path components, append them back on
  if (imaginary != NULL) {
    CFIndex count = CFArrayGetCount(imaginary);
    for (CFIndex i = 0; i<count; i++) {
      CFStringRef component = CFArrayGetValueAtIndex(imaginary, i);
#ifdef DEBUG
      fprintf(stderr, "appending component: ");
      CFShow(component);
#endif
      url = CFURLCreateCopyAppendingPathComponent(NULL, placeholder, component, false);
      CFRelease(placeholder);
      placeholder = url;
    }
    CFRelease(imaginary);
  }

#ifdef DEBUG
  fprintf(stderr, "result: ");
  CFShow(placeholder);
#endif

  CFStringRef cfPath = CFURLCopyFileSystemPath(placeholder, kCFURLPOSIXPathStyle);
  CFArrayAppendValue(config.paths, cfPath);
  CFRelease(cfPath);
  CFRelease(placeholder);

#else

#ifdef DEBUG
  fprintf(stderr, "compiled against 10.5, using realpath()\n");
#endif

//.........这里部分代码省略.........
开发者ID:nateyu,项目名称:rb-fsevent,代码行数:101,代码来源:main.c

示例6: ShowFileSystemSize

/*
 * Displays size of file system and percent of data blocks and inodes used.
 */
void ShowFileSystemSize(char *fileSystem)
{
#ifndef _WIN32                  /* FIXME */
        char realPath[PATH_MAX];
        char *fileSystemUnitStr;
        long long int totalFileSystemSize;
        long long int freeFileSystemSize;
        long long int totalInodes;
        long long int freeInodes;
        double totalFileSystemSizeHR;
        double usedFileSystemPercentage;
        double usedInodePercentage;
#ifdef __sun                    /* SunOS does not support statfs(), instead uses statvfs() */
        struct statvfs statusBuffer;
#else                           /* !__sun */
        struct statfs statusBuffer;
#endif                          /* __sun */

#ifdef __sun
        if (statvfs(fileSystem, &statusBuffer) != 0) {
                ERR("unable to statvfs() file system");
        }
#else                           /* !__sun */
        if (statfs(fileSystem, &statusBuffer) != 0) {
                ERR("unable to statfs() file system");
        }
#endif                          /* __sun */

        /* data blocks */
#ifdef __sun
        totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_frsize;
        freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_frsize;
#else                           /* !__sun */
        totalFileSystemSize = statusBuffer.f_blocks * statusBuffer.f_bsize;
        freeFileSystemSize = statusBuffer.f_bfree * statusBuffer.f_bsize;
#endif                          /* __sun */

        usedFileSystemPercentage = (1 - ((double)freeFileSystemSize
                                         / (double)totalFileSystemSize)) * 100;
        totalFileSystemSizeHR =
                (double)totalFileSystemSize / (double)(1<<30);
        fileSystemUnitStr = "GiB";
        if (totalFileSystemSizeHR > 1024) {
                totalFileSystemSizeHR = (double)totalFileSystemSize / (double)((long long)1<<40);
                fileSystemUnitStr = "TiB";
        }

        /* inodes */
        totalInodes = statusBuffer.f_files;
        freeInodes = statusBuffer.f_ffree;
        usedInodePercentage =
            (1 - ((double)freeInodes / (double)totalInodes)) * 100;

        /* show results */
        if (realpath(fileSystem, realPath) == NULL) {
                ERR("unable to use realpath()");
        }
        fprintf(stdout, "Path: %s\n", realPath);
        fprintf(stdout, "FS: %.1f %s   Used FS: %2.1f%%   ",
                totalFileSystemSizeHR, fileSystemUnitStr,
                usedFileSystemPercentage);
        fprintf(stdout, "Inodes: %.1f Mi   Used Inodes: %2.1f%%\n",
                (double)totalInodes / (double)(1<<20),
                usedInodePercentage);
        fflush(stdout);
#endif /* !_WIN32 */

        return;
}
开发者ID:AlvaroAguilera,项目名称:ior,代码行数:72,代码来源:utilities.c

示例7: main

int main(int argc, char **argv)
{
  int arch = 32;
  magic_t magic;
  char dll_real_path[PATH_MAX];
  char wineprefix_real_path[PATH_MAX];

  if (argc != 3 && argc != 4) {
    fprintf(stderr, "usage: %s <vst.dll> <vst.so> [<wine-prefix>]\n", argv[0]);
    return 2;
  }

  int has_wineprefix = argc == 4;

  struct stat st_dll;
  if (stat(argv[1], &st_dll) ||
      !realpath(argv[1], dll_real_path)) {
    fprintf(stderr, "%s: %m\n", argv[1]);
    return 1;
  }

  struct stat st_tpl;
  if (stat(VST_BRIDGE_TPL_PATH, &st_tpl)) {
    fprintf(stderr, "%s: %m\n", VST_BRIDGE_TPL_PATH);
    return 1;
  }

  if (has_wineprefix) {
    struct stat st_wineprefix;

    if (stat(argv[3], &st_wineprefix) ||
        !realpath(argv[3], wineprefix_real_path)) {
      fprintf(stderr, "%s: %m\n", argv[3]);
      return 1;
    }

    if (!S_ISDIR(st_wineprefix.st_mode)) {
      fprintf(stderr, "%s: %s\n", argv[3], strerror(ENOTDIR));
      return 1;
    }
  }

  magic = magic_open(MAGIC_NONE);
  if (!magic)
    fprintf(stderr, "failed to initialize magic\n");
  else {
    magic_load(magic, NULL);
    if (strstr(magic_file(magic, dll_real_path), "80386"))
      arch = 32;
    else if (strstr(magic_file(magic, dll_real_path), "x86-64"))
      arch = 64;
    printf("detected %d bits dll\n", arch);
    magic_close(magic);
  }

  // copy file
  int fd_tpl = open(VST_BRIDGE_TPL_PATH, O_RDONLY, 0644);
  if (fd_tpl < 0) {
    fprintf(stderr, "%s: %m\n", VST_BRIDGE_TPL_PATH);
    return 1;
  }

  int fd_so = open(argv[2], O_CREAT | O_TRUNC | O_RDWR, 0755);
  if (fd_so < 0) {
    fprintf(stderr, "%s: %m\n", argv[2]);
    return 1;
  }

  if (fchmod(fd_so, 0755))
    fprintf(stderr, "chmod(%s, 0755): %m\n", argv[2]);

  if (sendfile(fd_so, fd_tpl, NULL, st_tpl.st_size) != st_tpl.st_size) {
    fprintf(stderr, "copy %s to %s: %m\n", VST_BRIDGE_TPL_PATH, argv[2]);
    return 1;
  }

  close(fd_tpl);

  void *mem_so = mmap(NULL, st_tpl.st_size, PROT_READ | PROT_WRITE, MAP_SHARED,
                      fd_so, 0);
  if (mem_so == MAP_FAILED) {
    fprintf(stderr, "mmap(%s): %m\n", argv[2]);
    return 1;
  }

  replace_magic(mem_so, st_tpl.st_size, VST_BRIDGE_TPL_DLL, dll_real_path);
  replace_magic(mem_so, st_tpl.st_size, VST_BRIDGE_TPL_HOST, arch == 32 ? VST_BRIDGE_HOST32_PATH : VST_BRIDGE_HOST64_PATH);
  if (has_wineprefix)
    replace_magic(mem_so, st_tpl.st_size, VST_BRIDGE_TPL_WINEPREFIX, wineprefix_real_path);

  munmap(mem_so, st_tpl.st_size);

  close(fd_so);

  return 0;
}
开发者ID:EQ4,项目名称:vst-bridge,代码行数:96,代码来源:maker.c

示例8: main

int main(int argc, char *argv[]) {

	int n;
	extern char *optarg;		/* for getopt */
	extern int optind, opterr;	/* for getopt */

	option_l = 0;
	option_a = 0;
	
	while((n = getopt(argc, argv, "la")) != -1) {
		switch(n) {
		case 'l':
			option_l = 1;
			break;
		case 'a':
			option_a = 1;
			break;
		default:
			usage();
		}
	}
	argc -= optind;
	argv += optind;

	struct list list;
	list.head = NULL;
	list.size = 0;
	int num;
	for(num = 0; num < argc; num++) {
		appendbypath(&list, argv[num], 1023);
	}

	int iterator = 0;
	struct node *node;
	DIR *dir;
	struct dirent *dirent;
	// check file type and print.
	while( (node = getnode_ite(&list, &iterator)) != NULL) {
		if(lstat(node->path, node->buf) != 0) {
			perror("lstat");
		}
		if(S_ISDIR(node->buf->st_mode)) {	// dir
			//if(strncmp(dirent->d_name, "/", 1)) {
			fprintf(stdout, "%s:\n", node->path);
			dir = opendir(node->path);
			struct stat *buf;
			buf = malloc(sizeof(struct stat));
			while( (dirent = readdir(dir)) != NULL) {
				memset(buf, 0, sizeof(buf));
				if(option_l == 1) {
					char path[1024];
					memcpy(path, node->path, strlen(node->path));
			fprintf(stdout, "%s:%d:%d\n", path, strlen(path), strlen(node->path));
			fprintf(stdout, "%s\n", path[1]);
					if(strncmp(&path[strlen(node->path) - 1], "/", 1)) {
						strcat(path, "/");
					}
					strcat(path, dirent->d_name);
					if(lstat(path, buf) != 0) 
						perror("lstat");
					print_fileinfo(dirent->d_name, *buf, option_a);
				} else {
					fprintf(stdout, "%s\n", dirent->d_name);	
				}
			}
			closedir(dir);
		} else if(S_ISLNK(node->buf->st_mode)) {	//symbolic link
			if(option_a != 1 && !strncmp(dirent->d_name, ".", 1)) {
			} else {
				char *rpath;
				rpath = realpath(node->path, NULL);
				char time[25];
				struct passwd *pw;
				// get username by passwd
				pw = getpwuid(node->buf->st_uid);
				fprintf(stdout, "%o\t%d\t%s\t%d\t%d", 
						node->buf->st_mode, node->buf->st_nlink, pw->pw_name, 
						node->buf->st_gid, node->buf->st_size
					);
				memcpy(time, (char *)ctime(&node->buf->st_mtime), 24);
				fprintf(stdout, "\t%s\t%s -> %s\n", time, node->path, rpath);

				free(rpath);
			}
		} else {	//regular file
			if(option_l == 1) {
				char time[25];
				struct passwd *pw;
				// get username by passwd
				pw = getpwuid(node->buf->st_uid);
				fprintf(stdout, "%o\t%d\t%s\t%d\t%d", 
						node->buf->st_mode, node->buf->st_nlink, pw->pw_name, 
						node->buf->st_gid, node->buf->st_size
					);
				memcpy(time, (char *)ctime(&node->buf->st_mtime), 24);
				fprintf(stdout, "\t%s\t%s\n", time, node->path);
			} else {
				fprintf(stdout, "%s\n", node->path);	
			}
		}
//.........这里部分代码省略.........
开发者ID:yassanet,项目名称:test,代码行数:101,代码来源:ls.c

示例9: doSyslogd

static void doSyslogd(void)
{
	struct sockaddr_un sunx;
	socklen_t addrLength;

	int sock_fd;
	fd_set fds;

	/* Set up signal handlers. */
	signal(SIGINT, quit_signal);
	signal(SIGTERM, quit_signal);
	signal(SIGQUIT, quit_signal);
	signal(SIGHUP, SIG_IGN);
	signal(SIGCHLD, SIG_IGN);
#ifdef SIGCLD
	signal(SIGCLD, SIG_IGN);
#endif
	signal(SIGALRM, domark);
	alarm(MarkInterval);

	/* Create the syslog file so realpath() can work. */
	if (realpath(_PATH_LOG, lfile) != NULL) {
		unlink(lfile);
	}

	memset(&sunx, 0, sizeof(sunx));
	sunx.sun_family = AF_UNIX;
	strncpy(sunx.sun_path, lfile, sizeof(sunx.sun_path));
	if ((sock_fd = socket(AF_UNIX, SOCK_DGRAM, 0)) < 0) {
		bb_perror_msg_and_die("Couldn't get file descriptor for socket "
						   _PATH_LOG);
	}

	addrLength = sizeof(sunx.sun_family) + strlen(sunx.sun_path);
	if (bind(sock_fd, (struct sockaddr *) &sunx, addrLength) < 0) {
		bb_perror_msg_and_die("Could not connect to socket " _PATH_LOG);
	}

	if (chmod(lfile, 0666) < 0) {
		bb_perror_msg_and_die("Could not set permission on " _PATH_LOG);
	}
#ifdef CONFIG_FEATURE_IPC_SYSLOG
	if (circular_logging == TRUE) {
		ipcsyslog_init();
	}
#endif

#ifdef CONFIG_FEATURE_REMOTE_LOG
	if (doRemoteLog == TRUE) {
		init_RemoteLog();
	}
#endif

	logMessage(LOG_SYSLOG | LOG_INFO, "syslogd started: " BB_BANNER);

	for (;;) {

		FD_ZERO(&fds);
		FD_SET(sock_fd, &fds);

		if (select(sock_fd + 1, &fds, NULL, NULL, NULL) < 0) {
			if (errno == EINTR) {
				/* alarm may have happened. */
				continue;
			}
			bb_perror_msg_and_die("select error");
		}

		if (FD_ISSET(sock_fd, &fds)) {
			int i;
#if MAXLINE > BUFSIZ
# define TMP_BUF_SZ BUFSIZ
#else
# define TMP_BUF_SZ MAXLINE
#endif
#define tmpbuf bb_common_bufsiz1

			if ((i = recv(sock_fd, tmpbuf, TMP_BUF_SZ, 0)) > 0) {
				tmpbuf[i] = '\0';
				serveConnection(tmpbuf, i);
			} else {
				bb_perror_msg_and_die("UNIX socket error");
			}
		}				/* FD_ISSET() */
	}					/* for main loop */
}
开发者ID:K0T0LI,项目名称:busybox,代码行数:86,代码来源:syslogd.c

示例10: main


//.........这里部分代码省略.........
	}
	else
	{
		char buffer[255] ;
		prefix = strdup( "rascaf" ) ;
		sprintf( buffer, "%s.out", prefix ) ;
		fpOut = fopen( buffer, "w" ) ;
	}
	
	if ( genomeFile != NULL )
	{
		genome.Open( alignments, genomeFile ) ;
		alignments.Rewind() ;
	}

	if ( outputConnectionSequence == true && genomeFile == NULL )
	{
		fprintf( stderr, "Must use -f to specify assembly file when using -cs\n" ) ;	
		exit( EXIT_FAILURE ) ;
	}
	// 74619
	//printf( "%c\n", genome.GetNucleotide( 74619, 4 ) ) ;
	//exit(0) ;
	// Build the graph
	ret = blocks.BuildExonBlocks( alignments, genome ) ;
	alignments.Rewind() ;
	fprintf( stderr, "Found %d exon blocks.\n", ret ) ;
	if ( clippedAlignments.IsOpened() )
	{
		fprintf( stderr, "Extend exon blocks with clipped alignments.\n" ) ;
		Blocks extendBlocks ;
		extendBlocks.BuildExonBlocks( clippedAlignments, genome ) ;
		clippedAlignments.Rewind() ;

		ret = blocks.ExtendExonBlocks( extendBlocks ) ;
		fprintf( stderr, "Found %d exon blocks after extension.\n", ret ) ;
	}

	blocks.GetAlignmentsInfo( alignments ) ;
	alignments.Rewind() ;

	ret = blocks.BuildGeneBlocks( alignments, genome ) ;
	alignments.Rewind() ;
	fprintf( stderr, "Found %d gene blocks.\n", ret ) ;
	
	blocks.BuildGeneBlockGraph( alignments ) ;
	if ( clippedAlignments.IsOpened() )
	{
		blocks.AddGeneBlockGraphByClippedAlignments( clippedAlignments ) ; 
	}
	
	// Cleaning
	blocks.CleanGeneBlockGraph( alignments, genome ) ;

	// Scaffolding
	Scaffold scaffold( blocks, genome ) ;
	//scaffold.Init( blocks ) ;
	int componentCnt = scaffold.BuildComponent() ;
	fprintf( stderr, "Found %d non-trivial gene block components.\n", componentCnt ) ;
	// Possible for parallelization
	for ( i = 0 ; i < componentCnt ; ++i )
	{
		scaffold.ScaffoldComponent( i ) ;
	}
	
	scaffold.ScaffoldGenome() ;
	
	// Output the command line
	fprintf( fpOut, "command line: " ) ;
	char *fullpath = (char *)malloc( sizeof( char ) * 4096 ) ;
	for ( i = 0 ; i < argc ; ++i )
	{
		char c = ' ' ;
		if ( i == argc - 1 )
			c = '\n' ;
		if ( i > 0 && !strcmp( argv[i - 1], "-b" ) )
		{
			if ( realpath( argv[i], fullpath ) == NULL )
			{
				fprintf( stderr, "Failed to resolve the path of file %s.\n", argv[i] ) ;
				exit( 1 ) ;
			}
			fprintf( fpOut, "%s%c", fullpath, c ) ;
		}
		else if ( i > 0 && !strcmp( argv[i - 1], "-f" ) )
		{
			if ( realpath( argv[i], fullpath ) == NULL )
			{
				fprintf( stderr, "Failed to resolve the path of file %s.\n", argv[i] ) ;
				exit( 1 ) ;
			}
			fprintf( fpOut, "%s%c", fullpath, c ) ;
		}
		else
			fprintf( fpOut, "%s%c", argv[i], c ) ;
	}
	free( fullpath ) ;
	scaffold.Output( fpOut, alignments ) ;
	return 0 ;
}
开发者ID:mourisl,项目名称:Rascaf,代码行数:101,代码来源:main.cpp

示例11: main


//.........这里部分代码省略.........
	touchFlag = FALSE;		/* Actually update targets */
	debug = 0;			/* No debug verbosity, please. */
	jobsRunning = FALSE;

	maxJobs = DEFMAXLOCAL;		/* Set default local max concurrency */
	maxJobTokens = maxJobs;
	compatMake = FALSE;		/* No compat mode */
	ignorePWD = FALSE;

	/*
	 * Initialize the parsing, directory and variable modules to prepare
	 * for the reading of inclusion paths and variable settings on the
	 * command line
	 */

	/*
	 * Initialize various variables.
	 *	MAKE also gets this name, for compatibility
	 *	.MAKEFLAGS gets set to the empty string just in case.
	 *	MFLAGS also gets initialized empty, for compatibility.
	 */
	Parse_Init();
	if (argv[0][0] == '/' || strchr(argv[0], '/') == NULL) {
	    /*
	     * Leave alone if it is an absolute path, or if it does
	     * not contain a '/' in which case we need to find it in
	     * the path, like execvp(3) and the shells do.
	     */
	    p1 = argv[0];
	} else {
	    /*
	     * A relative path, canonicalize it.
	     */
	    p1 = realpath(argv[0], mdpath);
	    if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) {
		p1 = argv[0];		/* realpath failed */
	    }
	}
	Var_Set("MAKE", p1, VAR_GLOBAL, 0);
	Var_Set(".MAKE", p1, VAR_GLOBAL, 0);
	Var_Set(MAKEFLAGS, "", VAR_GLOBAL, 0);
	Var_Set(MAKEOVERRIDES, "", VAR_GLOBAL, 0);
	Var_Set("MFLAGS", "", VAR_GLOBAL, 0);
	Var_Set(".ALLTARGETS", "", VAR_GLOBAL, 0);

	/*
	 * Set some other useful macros
	 */
	{
	    char tmp[64];
	    const char *ep;

	    if (!(ep = getenv(MAKE_LEVEL))) {
#ifdef MAKE_LEVEL_SAFE
		if (!(ep = getenv(MAKE_LEVEL_SAFE)))
#endif
		    ep = "0";
	    }
	    Var_Set(MAKE_LEVEL, ep, VAR_GLOBAL, 0);
	    snprintf(tmp, sizeof(tmp), "%u", myPid);
	    Var_Set(".MAKE.PID", tmp, VAR_GLOBAL, 0);
	    snprintf(tmp, sizeof(tmp), "%u", getppid());
	    Var_Set(".MAKE.PPID", tmp, VAR_GLOBAL, 0);
	}
	Job_SetPrefix();
开发者ID:epowers,项目名称:freebsd,代码行数:66,代码来源:main.c

示例12: main

int
main (int argc, char *argv[])
{
  inp_t input_params;
  mdl_t source_mdl;
  net_t network;
  int cell_index;

  int verbose = 1;
  char *input_file;

  /* Parse options and command line arguments. Diplay help
     message if no (or more than one) argument is given. */

    {
      int opt;

      static struct option longopts[] = {
          {"help", no_argument, NULL, 'h'},
          {"version", no_argument, NULL, 'V'},
          {"verbose", no_argument, NULL, 'v'},
          {"quiet", no_argument, NULL, 'q'},
          {0, 0, 0, 0}
      };

      while ((opt = getopt_long (argc, argv, "hVvq", longopts, NULL)) != -1)
        {
          switch (opt)
            {
            case 'h':
              usage ();
              return EXIT_SUCCESS;
              break;
            case 'V':
              version ();
              return EXIT_SUCCESS;
              break;
            case 'v':
              verbose = 2;
              break;
            case 'q':
              verbose = 0;
              break;
            default:
              usage ();
              return EXIT_FAILURE;
            }
        };
      argc -= optind;
      argv += optind;
      if (argc != 1)
        {
          usage ();
          return EXIT_FAILURE;
        }
      input_file = argv[0];
    }

  /* Read the input file */
  if( read_input_file_names (input_file, &input_params.files, verbose) != EXIT_SUCCESS )
    {
      return EXIT_FAILURE;
    }

  /* Read the chemical network file */
  if( read_network (input_params.files.chem_file, &network, verbose) != EXIT_SUCCESS )
    {
      return EXIT_FAILURE;
    }

  /* Read the input file */
  if( read_input (input_file, &input_params, &network, verbose) != EXIT_SUCCESS )
    {
      return EXIT_FAILURE;
    }

  /* Read the source model file */
  if( read_source (input_params.files.source_file, &source_mdl, &input_params,
               verbose) != EXIT_SUCCESS )
    {
      return EXIT_FAILURE;
    }

  // Hdf5 files, datatype and dataspace
  hid_t       fid, datatype, dataspace, dataset, tsDataset, tsDataspace,  speciesDataset, speciesDataspace, speciesType;
  datatype = H5Tcopy(H5T_NATIVE_DOUBLE);

  hsize_t     dimsf[ ROUTE_DATASET_RANK ]={  source_mdl.n_cells, source_mdl.ts.n_time_steps, input_params.output.n_output_species, N_OUTPUT_ROUTES };
  fid = H5Fcreate( "astrochem_output.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 
  dataspace = H5Screate_simple( ABUNDANCE_DATASET_RANK, dimsf, NULL);

  // Add Atributes
  hid_t simpleDataspace = H5Screate(H5S_SCALAR);
  hid_t attrType = H5Tcopy(H5T_C_S1);
  H5Tset_size ( attrType, MAX_CHAR_FILENAME );
  H5Tset_strpad(attrType,H5T_STR_NULLTERM);
  hid_t attrNetwork = H5Acreate( fid, "chem_file", attrType, simpleDataspace, H5P_DEFAULT, H5P_DEFAULT);
  H5Awrite( attrNetwork, attrType, realpath( input_params.files.chem_file, NULL ) );
  H5Aclose( attrNetwork );
  hid_t attrModel = H5Acreate( fid, "source_file", attrType, simpleDataspace, H5P_DEFAULT, H5P_DEFAULT);
//.........这里部分代码省略.........
开发者ID:glesur,项目名称:astrochem,代码行数:101,代码来源:astrochem.c

示例13: main

int main(int argc, char **argv)
{
	struct alias *alias;
	bool nofork = false;
	char *port;
	int opt, ch;
	int cur_fd;
	int bound = 0;
#ifdef HAVE_TLS
	struct no_tls_redirect *no_tls_redirect;
	int n_tls = 0;
	const char *tls_key = NULL, *tls_crt = NULL;
#endif

	BUILD_BUG_ON(sizeof(uh_buf) < PATH_MAX);

	uh_dispatch_add(&cgi_dispatch);
	init_defaults_pre();
	signal(SIGPIPE, SIG_IGN);

	while ((ch = getopt(argc, argv, "A:aC:c:Dd:E:fh:H:I:i:K:k:L:l:m:N:n:p:qQ:Rr:Ss:T:t:U:u:Xx:y:")) != -1) {
		switch(ch) {
#ifdef HAVE_TLS
		case 'C':
			tls_crt = optarg;
			break;

		case 'K':
			tls_key = optarg;
			break;

		case 'q':
			conf.tls_redirect = 1;
			break;

		case 'Q':
			no_tls_redirect = calloc(1, sizeof(*no_tls_redirect));
			if (!no_tls_redirect) {
				fprintf(stderr, "Error: failed to allocate no_tls_redirect\n");
				exit(1);
			}
			no_tls_redirect->path = strdup(optarg);
			list_add(&no_tls_redirect->list, &conf.no_tls_redirect);
			break;

		case 's':
			n_tls++;
			/* fall through */
#else
		case 'C':
		case 'K':
		case 'q':
		case 'Q':
		case 's':
			fprintf(stderr, "uhttpd: TLS support not compiled, "
			                "ignoring -%c\n", ch);
			break;
#endif
		case 'p':
			optarg = strdup(optarg);
			bound += add_listener_arg(optarg, (ch == 's'));
			break;

		case 'h':
			if (!realpath(optarg, uh_buf)) {
				fprintf(stderr, "Error: Invalid directory %s: %s\n",
						optarg, strerror(errno));
				exit(1);
			}
			conf.docroot = strdup(uh_buf);
			break;

		case 'H':
			if (uh_handler_add(optarg)) {
				fprintf(stderr, "Error: Failed to load handler script %s\n",
					optarg);
				exit(1);
			}
			break;

		case 'E':
			if (optarg[0] != '/') {
				fprintf(stderr, "Error: Invalid error handler: %s\n",
						optarg);
				exit(1);
			}
			conf.error_handler = optarg;
			break;

		case 'I':
			if (optarg[0] == '/') {
				fprintf(stderr, "Error: Invalid index page: %s\n",
						optarg);
				exit(1);
			}
			uh_index_add(optarg);
			break;

		case 'S':
			conf.no_symlinks = 1;
//.........这里部分代码省略.........
开发者ID:twolife,项目名称:uhttpd,代码行数:101,代码来源:main.c

示例14: Q_UNUSED

//static
QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, QFileSystemMetaData &data)
{
    if (entry.isEmpty() || entry.isRoot())
        return entry;

#if !defined(Q_OS_MAC) && !defined(Q_OS_QNX) && !defined(Q_OS_ANDROID) && _POSIX_VERSION < 200809L
    // realpath(X,0) is not supported
    Q_UNUSED(data);
    return QFileSystemEntry(slowCanonicalized(absoluteName(entry).filePath()));
#else
    char *ret = 0;
# if defined(Q_OS_MACX)
    // When using -mmacosx-version-min=10.4, we get the legacy realpath implementation,
    // which does not work properly with the realpath(X,0) form. See QTBUG-28282.
    if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) {
        ret = (char*)malloc(PATH_MAX + 1);
        if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
            const int savedErrno = errno; // errno is checked below, and free() might change it
            free(ret);
            errno = savedErrno;
            ret = 0;
        }
    } else {
        // on 10.5 we can use FSRef to resolve the file path.
        QString path = QDir::cleanPath(entry.filePath());
        FSRef fsref;
        if (FSPathMakeRef((const UInt8 *)path.toUtf8().data(), &fsref, 0) == noErr) {
            CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref);
            CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle);
            QString ret = QCFString::toQString(canonicalPath);
            CFRelease(canonicalPath);
            CFRelease(urlref);
            return QFileSystemEntry(ret);
        }
    }
# else
#  if _POSIX_VERSION >= 200801L
    ret = realpath(entry.nativeFilePath().constData(), (char*)0);
#  else
    ret = (char*)malloc(PATH_MAX + 1);
    if (realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) {
        const int savedErrno = errno; // errno is checked below, and free() might change it
        free(ret);
        errno = savedErrno;
        ret = 0;
    }
#  endif
# endif
    if (ret) {
        data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
        data.entryFlags |= QFileSystemMetaData::ExistsAttribute;
        QString canonicalPath = QDir::cleanPath(QString::fromLocal8Bit(ret));
        free(ret);
        return QFileSystemEntry(canonicalPath);
    } else if (errno == ENOENT) { // file doesn't exist
        data.knownFlagsMask |= QFileSystemMetaData::ExistsAttribute;
        data.entryFlags &= ~(QFileSystemMetaData::ExistsAttribute);
        return QFileSystemEntry();
    }
    return entry;
#endif
}
开发者ID:SfietKonstantin,项目名称:radeon-qt5-qtbase-kms,代码行数:63,代码来源:qfilesystemengine_unix.cpp

示例15: fs_whitelist

// whitelist for /home/user directory
void fs_whitelist(void) {
	char *homedir = cfg.homedir;
	assert(homedir);
	ProfileEntry *entry = cfg.profile;
	if (!entry)
		return;
	
	// realpath function will fail with ENOENT if the file is not found
	// we need to expand the path before installing a new, empty home directory
	while (entry) {
		// handle only whitelist commands
		if (strncmp(entry->data, "whitelist ", 10)) {
			entry = entry->next;
			continue;
		}

		char *new_name = expand_home(entry->data + 10, cfg.homedir);
		assert(new_name);
		char *fname = realpath(new_name, NULL);
		free(new_name);
		if (fname) {
			// change file name in entry->data
			if (strcmp(fname, entry->data + 10) != 0) {
				char *newdata;
				if (asprintf(&newdata, "whitelist %s", fname) == -1)
					errExit("asprintf");
				entry->data = newdata;
				if (arg_debug)
					printf("Replaced whitelist path: %s\n", entry->data);
			}
						
			free(fname);
		}
		else {
			// file not found, blank the entry in the list
			if (arg_debug)
				printf("Removed whitelist path: %s\n", entry->data);
			*entry->data = '\0';
		}
		entry = entry->next;
	}
		
	// create /tmp/firejail/mnt/whome directory
	fs_build_mnt_dir();
	int rv = mkdir(WHITELIST_HOME_DIR, S_IRWXU | S_IRWXG | S_IRWXO);
	if (rv == -1)
		errExit("mkdir");
	if (chown(WHITELIST_HOME_DIR, getuid(), getgid()) < 0)
		errExit("chown");
	if (chmod(WHITELIST_HOME_DIR, 0755) < 0)
		errExit("chmod");

	// keep a copy of real home dir in /tmp/firejail/mnt/whome
	if (mount(cfg.homedir, WHITELIST_HOME_DIR, NULL, MS_BIND|MS_REC, NULL) < 0)
		errExit("mount bind");

	// start building the new home directory by mounting a tmpfs fielsystem
	 fs_private();

	// go through profile rules again, and interpret whitelist commands
	entry = cfg.profile;
	while (entry) {
		// handle only whitelist commands
		if (strncmp(entry->data, "whitelist ", 10)) {
			entry = entry->next;
			continue;
		}

		whitelist_path(entry->data + 10);

		entry = entry->next;
	}

	// mask the real home directory, currently mounted on /tmp/firejail/mnt/whome
	if (mount("tmpfs", WHITELIST_HOME_DIR, "tmpfs", MS_NOSUID | MS_STRICTATIME | MS_REC,  "mode=755,gid=0") < 0)
		errExit("mount tmpfs");
}
开发者ID:satai,项目名称:firejail,代码行数:78,代码来源:fs_whitelist.c


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