nis-util
1.0.D108
|
00001 // 00002 // nis-util - NIS Administration Utilities 00003 // Copyright (C) 2012 Peter Miller 00004 // 00005 // This program is free software; you can redistribute it and/or modify 00006 // it under the terms of the GNU General Public License as published by 00007 // the Free Software Foundation; either version 2 of the License, or (at 00008 // your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License along 00016 // with this program. If not, see <http://www.gnu.org/licenses/>. 00017 // 00018 00019 #include <libexplain/output.h> 00020 00021 #include <lib/arglex.h> 00022 #include <lib/configuration.h> 00023 00024 00025 void 00026 arglex::generic_argument(void) 00027 { 00028 switch (token_cur()) 00029 { 00030 case token_configuration_file: 00031 cfg.load_command_line_file(get_filename_or_stdin()); 00032 break; 00033 00034 case arglex::token_group_name_maximum: 00035 { 00036 long n = 8; 00037 switch (token_next()) 00038 { 00039 case arglex::token_number: 00040 n = get_integer_value(); 00041 break; 00042 00043 case arglex::token_string: 00044 if (get_string_value() == "sysconf") 00045 { 00046 n = sysconf(_SC_LOGIN_NAME_MAX); 00047 if (n > 0) 00048 break; 00049 } 00050 // Fall through... 00051 00052 default: 00053 explain_output_error 00054 ( 00055 "%s: the -Group-Name-Maximum option requires a numeric " 00056 "argument", 00057 get_source_location().get_both().c_str() 00058 ); 00059 usage(); 00060 // NOTREACHED 00061 } 00062 cfg.set_command_line_long 00063 ( 00064 token_locn, 00065 SECTION_GROUP, 00066 ITEM_NAME_LENGTH_MAXIMUM, 00067 n 00068 ); 00069 } 00070 break; 00071 00072 case arglex::token_passwd_name_maximum: 00073 { 00074 long n = 8; 00075 switch (token_next()) 00076 { 00077 case arglex::token_number: 00078 n = get_integer_value(); 00079 break; 00080 00081 case arglex::token_string: 00082 if (get_string_value() == "sysconf") 00083 { 00084 n = sysconf(_SC_LOGIN_NAME_MAX); 00085 if (n > 0) 00086 break; 00087 } 00088 // Fall through... 00089 00090 default: 00091 explain_output_error 00092 ( 00093 "%s: the -Passwd-Name-Maximum option requires a numeric " 00094 "argument", 00095 get_source_location().get_both().c_str() 00096 ); 00097 usage(); 00098 // NOTREACHED 00099 } 00100 cfg.set_command_line_long 00101 ( 00102 token_locn, 00103 SECTION_PASSWD, 00104 ITEM_NAME_LENGTH_MAXIMUM, 00105 n 00106 ); 00107 } 00108 break; 00109 00110 case token_verbose: 00111 cfg.set_command_line_bool(token_locn, "verbose", true); 00112 break; 00113 00114 case token_verbose_not: 00115 cfg.set_command_line_bool(token_locn, "verbose", false); 00116 break; 00117 00118 case token_warning: 00119 cfg.set_command_line_bool(token_locn, ITEM_WARNING, true); 00120 break; 00121 00122 case token_warning_not: 00123 cfg.set_command_line_bool(token_locn, ITEM_WARNING, false); 00124 break; 00125 00126 default: 00127 explain_output_error 00128 ( 00129 "%s: misplaced %s command line argument", 00130 get_source_location().get_both().c_str(), 00131 get_string_value().quote_c().c_str() 00132 ); 00133 usage(); 00134 // NOTREACHED 00135 } 00136 } 00137 00138 00139 // vim: set ts=8 sw=4 et :