Parent Directory
|
Revision Log
Revision 16 - (view) (download) (as text)
| 1 : | mark | 16 | /* |
| 2 : | |||
| 3 : | Copyright (C) 1994- | ||
| 4 : | Free Software Foundation, Inc. | ||
| 5 : | |||
| 6 : | This file is part of GNU cfengine - written and maintained | ||
| 7 : | by Mark Burgess, Dept of Computing and Engineering, Oslo College, | ||
| 8 : | Dept. of Theoretical physics, University of Oslo | ||
| 9 : | |||
| 10 : | This program is free software; you can redistribute it and/or modify it | ||
| 11 : | under the terms of the GNU General Public License as published by the | ||
| 12 : | Free Software Foundation; either version 3, or (at your option) any | ||
| 13 : | later version. | ||
| 14 : | This program is distributed in the hope that it will be useful, | ||
| 15 : | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 16 : | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 17 : | GNU General Public License for more details. | ||
| 18 : | |||
| 19 : | You should have received a copy of the GNU General Public License | ||
| 20 : | along with this program; if not, write to the Free Software | ||
| 21 : | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | ||
| 22 : | |||
| 23 : | */ | ||
| 24 : | |||
| 25 : | /*****************************************************************************/ | ||
| 26 : | /* */ | ||
| 27 : | /* File: agent.c */ | ||
| 28 : | /* */ | ||
| 29 : | /*****************************************************************************/ | ||
| 30 : | |||
| 31 : | #include "cf3.defs.h" | ||
| 32 : | #include "cf3.extern.h" | ||
| 33 : | |||
| 34 : | int main (int argc,char *argv[]); | ||
| 35 : | |||
| 36 : | /*******************************************************************/ | ||
| 37 : | /* Command line options */ | ||
| 38 : | /*******************************************************************/ | ||
| 39 : | |||
| 40 : | /* GNU STUFF FOR LATER #include "getopt.h" */ | ||
| 41 : | |||
| 42 : | struct option OPTIONS[12] = | ||
| 43 : | { | ||
| 44 : | { "help",no_argument,0,'h' }, | ||
| 45 : | { "debug",optional_argument,0,'d' }, | ||
| 46 : | { "verbose",no_argument,0,'v' }, | ||
| 47 : | { "dry-run",no_argument,0,'n'}, | ||
| 48 : | { "version",no_argument,0,'V' }, | ||
| 49 : | { "define",required_argument,0,'D' }, | ||
| 50 : | { "negate",required_argument,0,'N' }, | ||
| 51 : | { "no-lock",no_argument,0,'K'}, | ||
| 52 : | { "inform",no_argument,0,'I'}, | ||
| 53 : | { "syntax",no_argument,0,'S'}, | ||
| 54 : | { "diagnostic",no_argument,0,'x'}, | ||
| 55 : | { NULL,0,0,'\0' } | ||
| 56 : | }; | ||
| 57 : | |||
| 58 : | /*****************************************************************************/ | ||
| 59 : | |||
| 60 : | int main(int argc,char *argv[]) | ||
| 61 : | |||
| 62 : | { | ||
| 63 : | GenericInitialize(argc,argv); | ||
| 64 : | |||
| 65 : | } | ||
| 66 : | |||
| 67 : | /*******************************************************************/ | ||
| 68 : | |||
| 69 : | void CheckOpts(int argc,char **argv) | ||
| 70 : | |||
| 71 : | { extern char *optarg; | ||
| 72 : | struct Item *actionList; | ||
| 73 : | int optindex = 0; | ||
| 74 : | int c; | ||
| 75 : | |||
| 76 : | while ((c=getopt_long(argc,argv,"d:vnIf:pD:N:VSx",OPTIONS,&optindex)) != EOF) | ||
| 77 : | { | ||
| 78 : | switch ((char) c) | ||
| 79 : | { | ||
| 80 : | case 'f': | ||
| 81 : | |||
| 82 : | strncpy(VINPUTFILE,optarg,CF_BUFSIZE-1); | ||
| 83 : | VINPUTFILE[CF_BUFSIZE-1] = '\0'; | ||
| 84 : | MINUSF = true; | ||
| 85 : | break; | ||
| 86 : | |||
| 87 : | case 'd': | ||
| 88 : | AddClassToHeap("opt_debug"); | ||
| 89 : | switch ((optarg==NULL) ? '3' : *optarg) | ||
| 90 : | { | ||
| 91 : | case '1': | ||
| 92 : | D1 = true; | ||
| 93 : | DEBUG = true; | ||
| 94 : | break; | ||
| 95 : | case '2': | ||
| 96 : | D2 = true; | ||
| 97 : | DEBUG = true; | ||
| 98 : | break; | ||
| 99 : | case '3': | ||
| 100 : | D3 = true; | ||
| 101 : | DEBUG = true; | ||
| 102 : | VERBOSE = true; | ||
| 103 : | break; | ||
| 104 : | case '4': | ||
| 105 : | D4 = true; | ||
| 106 : | DEBUG = true; | ||
| 107 : | break; | ||
| 108 : | default: | ||
| 109 : | DEBUG = true; | ||
| 110 : | break; | ||
| 111 : | } | ||
| 112 : | break; | ||
| 113 : | |||
| 114 : | case 'K': IGNORELOCK = true; | ||
| 115 : | break; | ||
| 116 : | |||
| 117 : | case 'D': AddMultipleClasses(optarg); | ||
| 118 : | break; | ||
| 119 : | |||
| 120 : | case 'N': NegateCompoundClass(optarg,&VNEGHEAP); | ||
| 121 : | break; | ||
| 122 : | |||
| 123 : | case 'I': INFORM = true; | ||
| 124 : | break; | ||
| 125 : | |||
| 126 : | case 'v': VERBOSE = true; | ||
| 127 : | break; | ||
| 128 : | |||
| 129 : | case 'n': DONTDO = true; | ||
| 130 : | IGNORELOCK = true; | ||
| 131 : | AddClassToHeap("opt_dry_run"); | ||
| 132 : | break; | ||
| 133 : | |||
| 134 : | case 'p': PARSEONLY = true; | ||
| 135 : | IGNORELOCK = true; | ||
| 136 : | break; | ||
| 137 : | |||
| 138 : | case 'V': Version("Cfengine Agent"); | ||
| 139 : | exit(0); | ||
| 140 : | |||
| 141 : | case 'h': Syntax("Cfengine Agent"); | ||
| 142 : | exit(0); | ||
| 143 : | |||
| 144 : | case 'x': SelfDiagnostic(); | ||
| 145 : | exit(0); | ||
| 146 : | |||
| 147 : | default: Syntax("Cfengine Agent"); | ||
| 148 : | exit(1); | ||
| 149 : | |||
| 150 : | } | ||
| 151 : | } | ||
| 152 : | |||
| 153 : | Debug("Set debugging\n"); | ||
| 154 : | } |
| Administrator | ViewVC Help |
| Powered by ViewVC 1.0.3 |