- char *user, *locn;
- int i, infosystem;
- struct passwd *pw;
-
- infosystem = INFO_NETINFO;
- user = NULL;
- locn = NULL;
-
- for (i = 1; i < argc; i++)
- {
- if (!strcmp(argv[i], "-i"))
- {
- if (++i >= argc)
- {
- fprintf(stderr, "no argument for -i option\n");
- usage();
- }
-
- if (!strcmp(argv[i], "NetInfo")) infosystem = INFO_NETINFO;
- else if (!strcmp(argv[i], "netinfo")) infosystem = INFO_NETINFO;
- else if (!strcmp(argv[i], "File")) infosystem = INFO_FILE;
- else if (!strcmp(argv[i], "file")) infosystem = INFO_FILE;
- else if (!strcmp(argv[i], "NIS")) infosystem = INFO_NIS;
- else if (!strcmp(argv[i], "nis")) infosystem = INFO_NIS;
- else if (!strcmp(argv[i], "YP")) infosystem = INFO_NIS;
- else if (!strcmp(argv[i], "yp")) infosystem = INFO_NIS;
- else
- {
- fprintf(stderr, "unknown info system \"%s\"\n", argv[i]);
- usage();
- }
- }
-
- else if (!strcmp(argv[i], "-l"))
- {
- if (++i >= argc)
- {
- fprintf(stderr, "no argument for -l option\n");
+ char* user = NULL;
+ char* locn = NULL;
+ int infosystem, ch;
+
+ infosystem = INFO_PAM;
+
+ while ((ch = getopt(argc, argv, "ci:l:")) != -1) {
+ switch(ch) {
+ case 'i':
+ if (!strcasecmp(optarg, "file")) {
+ infosystem = INFO_FILE;
+ } else if (!strcasecmp(optarg, "NIS")) {
+ infosystem = INFO_NIS;
+ } else if (!strcasecmp(optarg, "YP")) {
+ infosystem = INFO_NIS;
+ } else if (!strcasecmp(optarg, "opendirectory")) {
+ infosystem = INFO_OPEN_DIRECTORY;
+ } else if (!strcasecmp(optarg, "PAM")) {
+ infosystem = INFO_PAM;
+ } else {
+ fprintf(stderr, "%s: Unknown info system \'%s\'.\n",
+ progname, optarg);