- char *user, *locn;
- int i, infosystem;
-
- 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]);
+ char* user = NULL;
+ char* locn = NULL;
+ char* auth = NULL;
+ int infosystem, ch;
+ int free_user = 0;
+
+#ifdef INFO_OPEN_DIRECTORY
+ /* since OpenDirectory works for most infosystems, make it the default */
+ infosystem = INFO_OPEN_DIRECTORY;
+#else
+ infosystem = INFO_FILE;
+#endif
+
+ while ((ch = getopt(argc, argv, "i:l:u:")) != -1)
+ switch(ch) {
+ case 'i':
+ if (!strcasecmp(optarg, "file")) {
+ infosystem = INFO_FILE;
+#ifdef INFO_NIS
+ } else if (!strcasecmp(optarg, "NIS")) {
+ infosystem = INFO_NIS;
+ } else if (!strcasecmp(optarg, "YP")) {
+ infosystem = INFO_NIS;
+#endif
+#ifdef INFO_OPEN_DIRECTORY
+ } else if (!strcasecmp(optarg, "opendirectory")) {
+ infosystem = INFO_OPEN_DIRECTORY;
+#endif
+ } else {
+ fprintf(stderr, "%s: Unknown info system \'%s\'.\n",
+ progname, optarg);