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

📄 fdetach.c

📁 7号信令功能代码,为开源代码
💻 C
字号:
/***************************************************************************** @(#) fdetach.c,v LiS-2_16_18-8(1.1.1.1.8.1) 2004/01/12 23:33:15 ----------------------------------------------------------------------------- Copyright (c) 2001-2004  OpenSS7 Corporation <http://www.openss7.com> Copyright (c) 1997-2000  Brian F. G. Bidulock <bidulock@openss7.org> All Rights Reserved. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ----------------------------------------------------------------------------- U.S. GOVERNMENT RESTRICTED RIGHTS.  If you are licensing this Software on behalf of the U.S. Government ("Government"), the following provisions apply to you.  If the Software is supplied by the Department of Defense ("DoD"), it is classified as "Commercial Computer Software" under paragraph 252.227-7014 of the DoD Supplement to the Federal Acquisition Regulations ("DFARS") (or any successor regulations) and the Government is acquiring only the license rights granted herein (the license rights customarily provided to non-Government users).  If the Software is supplied to any unit or agency of the Government other than DoD, it is classified as "Restricted Computer Software" and the Government's rights in the Software are defined in paragraph 52.227-19 of the Federal Acquisition Regulations ("FAR") (or any success regulations) or, in the cases of NASA, in paragraph 18.52.227-86 of the NASA Supplement to the FAR (or any successor regulations). ----------------------------------------------------------------------------- Commercial licensing and support of this software is available from OpenSS7 Corporation at a fee.  See http://www.openss7.com/ ----------------------------------------------------------------------------- Last Modified 2004/01/12 23:33:15 by brian ----------------------------------------------------------------------------- fdetach.c,v Revision 1.1.1.1.8.1  2004/01/12 23:33:15  brian - Updated LiS-2.16.18 gcom release to autoconf. Revision 1.1.1.1.4.1  2003/12/10 11:09:29  brian Start of autoconf changes. *****************************************************************************/#ident "@(#) fdetach.c,v LiS-2_16_18-8(1.1.1.1.8.1) 2004/01/12 23:33:15"static char const ident[] =    "fdetach.c,v LiS-2_16_18-8(1.1.1.1.8.1) 2004/01/12 23:33:15";/* *  fdetach.c - try to fdetach a list of paths. * *  Copyright (C) 2000  John A. Boyd Jr.  protologos, LLC * *  This library is free software; you can redistribute it and/or *  modify it under the terms of the GNU Library General Public *  License as published by the Free Software Foundation; either *  version 2 of the License, or (at your option) any later version. *  *  This library is distributed in the hope that it will be useful, *  but WITHOUT ANY WARRANTY; without even the implied warranty of *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU *  Library General Public License for more details. *  *  You should have received a copy of the GNU Library General Public *  License along with this library; if not, write to the *  Free Software Foundation, Inc., 59 Temple Place - Suite 330, Cambridge, *  MA 02139, USA. */#ident "@(#) LiS fdetach.c 1.2 12/15/00"#include <unistd.h>#include <stdlib.h>#include <stdio.h>#include <string.h>#include <memory.h>#include <fcntl.h>#include <errno.h>#include <limits.h>#ifdef _GNU_SOURCE#include <getopt.h>#endif#include <stropts.h>#include <sys/types.h>#include <sys/stat.h>#include <sys/sysmacros.h>int             output = 1;void version(int argc, char *argv[]){    if (!output)	return;    fprintf(stdout, "\%1$s %2$s:\n\    Copyright (c) 2003-2004  OpenSS7 Corporation.  All Rights Reserved.\n\ *  Copyright (c) 2000       John A. Boyd Jr.  protologos, LLC\n\\n\    Distributed by OpenSS7 Corporation under GPL Version 2,\n\    included here by reference.\n\", argv[0], ident);}void usage(int argc, char *argv[]){    if (!output)	return;    fprintf(stderr, "\Usage:\n\    %1$s [options] -a\n\    %1$s [options] PATH ...\n\    %1$s {-h,--help}\n\    %1$s {-V,--version}\n\", argv[0]);}void help(int argc, char *argv[]){    if (!output)	return;    fprintf(stdout, "\Usage:\n\    %1$s [options] -a\n\    %1$s [options] PATH ...\n\    %1$s {-h,--help}\n\    %1$s {-V,--version}\n\Arguments:\n\    PATH ...\n\        the path or paths in the directory to detach\n\Options:\n\    -a, --all\n\        detach all paths\n\    -v, --verbose\n\        verbose output\n\    -q, --quiet\n\        suppress normal output\n\    -h, --help, -?\n\        print this usage message and exit\n\    -V, --version\n\        print the version and exit\n\", argv[0]);}#ifndef PATH_MAX#define PATH_MAX 4096#endifint main(int argc, char *argv[]){    char            path[PATH_MAX];    for (;;) {	int             c;#ifdef _GNU_SOURCE	int             option_index = 0;	static struct option long_options[] = {	    {"all", 0, 0, 'a'},	    {"verbose", 0, 0, 'v'},	    {"quiet", 0, 0, 'q'},	    {"version", 0, 0, 'V'},	    {"help", 0, 0, 'h'},	    {"?", 0, 0, 'h'},	};	c = getopt_long_only(argc, argv, "avqVh?", long_options, &option_index);#else				/* _GNU_SOURCE */	c = getopt(argc, argv, "avqVh?");#endif				/* _GNU_SOURCE */	if (c == -1)	    break;	switch (c) {	case 'a':		/* -a, --all */	    strcpy(path, "*");	    break;	case 'v':		/* -v, --verbose */	    output += 1;	    break;	case 'q':		/* -q, --quiet */	    output = 0;	    break;	case 'V':		/* -V, --version */	    version(argc, argv);	    exit(0);	case 'h':		/* -h, --help */	    help(argc, argv);	    exit(0);	case '?':	default:	    optind--;	  bad_nonopt:	    if (optind < argc && output) {		fprintf(stderr, "%s: illegal syntax -- ", argv[0]);		for (; optind < argc; optind++)		    fprintf(stderr, "%s ", argv[optind]);		fprintf(stderr, "\n");	    }	  bad_usage:	    usage(argc, argv);	    exit(2);	}    }    if (strcmp(path, "*") == 0) {	if (optind < argc)	    goto bad_nonopt;	if (fdetach("*") < 0) {	    if (output)		fprintf(stderr, "%s: -a failed: %s\n", argv[0],			strerror(errno));	    exit(1);	} else {	    if (output > 1)		printf("%s: -a OK\n", argv[0]);	}    } else {	if (optind == argc) {	    if (output)		fprintf(stderr, "%s: missing path\n", argv[0]);	    goto bad_usage;	}	while (optind < argc) {	    strcpy(path, argv[optind++]);	    if (fdetach(path) < 0) {		if (output)		    fprintf(stderr, "fdetach( \"%s\" ) failed: %s\n",			    path, strerror(errno));		exit(1);	    } else {		if (output > 1)		    printf("fdetach( \"%s\" ) OK\n", path);	    }	}    }    exit(0);}

⌨️ 快捷键说明

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