2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
15 #include <sys/types.h>
20 #include <netinet/in.h>
21 #include <sys/param.h>
36 #define UBIK_INTERNALS
39 /* This file contain useful subroutines for parsing command line args for ubik
43 ubik_ParseServerList(argc, argv, ahost, aothers)
50 register struct hostent *th;
52 afs_int32 myHost, temp, counter;
53 int inServer, sawServer;
55 gethostname(hostname, sizeof(hostname));
56 th = gethostbyname(hostname);
57 if (!th) return UBADHOST;
58 memcpy(&myHost, th->h_addr, sizeof(afs_int32));
61 inServer = 0; /* haven't seen -servers yet */
64 for(i=1; i<argc; i++) {
65 /* look for -servers argument */
73 /* otherwise this is a new host name */
74 th = gethostbyname(tp);
75 if (!th) return UBADHOST;
76 memcpy(&temp, th->h_addr, sizeof(afs_int32));
78 if (counter++ >= MAXSERVERS) return UNHOSTS;
83 /* haven't seen a -server yet */
84 if (!strcmp(tp, "-servers")) {
88 else if (!strcmp(tp, "-dubik")) {
93 /* never saw a -server */
96 if (counter < MAXSERVERS) *aothers++ = 0; /* null terminate if there's room */