1 --- src/distcc.c.orig Mon May 5 07:25:00 2003
2 +++ src/distcc.c Mon May 5 21:07:30 2003
4 "Each host can be given in any of these forms:\n"
6 " localhost run in place\n"
7 -" HOST TCP connection, port %d\n"
8 -" HOST:PORT TCP connection, specified port\n"
9 +" HOST[:PORT][,OPT...] TCP connection (default port=%d)\n"
12 +" slots=N Maximum of N simultaneous jobs allowed\n"
13 +" N Abbreviation of the slots=N option\n"
15 +"Hostname examples:\n"
16 +" foo foo:4242 foo,4 bar:4100,2 bar,slots=3\n"
17 " @HOST SSH connection\n"
18 " USER$HOST SSH connection to specified host\n"
20 --- src/hosts.c.orig Mon May 5 06:59:53 2003
21 +++ src/hosts.c Mon May 5 21:01:23 2003
26 -static int dcc_parse_multiplier(const char **psrc, struct dcc_hostdef *hostdef)
27 +static int dcc_parse_options(const char **psrc, struct dcc_hostdef *hostdef)
30 - const char *token = *psrc;
35 - if ((*psrc)[0] == '/') {
37 - if ((ret = dcc_dup_part(psrc, &mul, "/: \t\n\f")) != 0)
38 + while ((*psrc)[0] == ',') {
40 + if ((ret = dcc_dup_part(psrc, &opt, ", \t\n\f")) != 0)
42 - if (!mul || atoi(mul) == 0) {
43 - rs_log_error("bad multiplier \"%s\" in host specification", token);
45 + if ((arg = strchr(opt, '=')) != NULL)
47 + else if (isdigit(*opt)) {
57 + rs_log_error("malformed option in host specification: \"%s\"", token);
58 + return EXIT_BAD_HOSTSPEC;
60 + if (!opt || strcmp(opt, "slots") == 0) {
61 + hostdef->n_slots = atoi(arg);
62 + if (hostdef->n_slots <= 0) {
63 + rs_log_error("invalid number of slots in host specification: \"%s\"", token);
64 + return EXIT_BAD_HOSTSPEC;
68 + rs_log_error("unknown option in host specification: \"%s\"", token);
69 return EXIT_BAD_HOSTSPEC;
71 - hostdef->n_slots = atoi(mul);
79 - if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
80 + if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
83 if (!hostdef->hostname) {
85 return EXIT_BAD_HOSTSPEC;
88 - if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
91 if (token[0] == ':') {
93 - if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, " \t\n\f")) != 0)
94 + if ((ret = dcc_dup_part(&token, &hostdef->ssh_command, ", \t\n\f")) != 0)
99 + if ((ret = dcc_parse_options(&token, hostdef)) != 0)
102 hostdef->mode = DCC_MODE_SSH;
107 const char *token = token_start;
109 - if ((ret = dcc_dup_part(&token, &hostdef->hostname, "/: \t\n\f")) != 0)
110 + if ((ret = dcc_dup_part(&token, &hostdef->hostname, ",: \t\n\f")) != 0)
113 if (!hostdef->hostname) {
114 @@ -250,14 +272,11 @@
115 return EXIT_BAD_HOSTSPEC;
118 - if ((ret = dcc_parse_multiplier(&token, hostdef)) != 0)
121 hostdef->port = dcc_default_port;
122 if (token[0] == ':') {
125 - if ((ret = dcc_dup_part(&token, &port_str, " \t\n\f")) != 0)
126 + if ((ret = dcc_dup_part(&token, &port_str, ", \t\n\f")) != 0)
136 + if ((ret = dcc_parse_options(&token, hostdef)) != 0)
139 hostdef->mode = DCC_MODE_TCP;
142 @@ -279,13 +301,13 @@
143 static int dcc_parse_localhost(struct dcc_hostdef *hostdef,
144 const char * token_start)
146 - const char *token = token_start + strlen("localhost");
147 + const char *token = token_start + (sizeof "localhost") - 1;
149 hostdef->mode = DCC_MODE_LOCAL;
150 hostdef->hostname = strdup("localhost");
151 hostdef->n_slots = 1;
153 - return dcc_parse_multiplier(&token, hostdef);
154 + return dcc_parse_options(&token, hostdef);
159 * definition. We then duplicate the relevant subcomponents into
160 * the relevant fields. */
163 + unsigned int token_len;
164 const char *token_start;
169 has_at = (memchr(token_start, '@', token_len) != NULL);
171 - if (!strncmp(token_start, "localhost", token_len)
172 - || !strncmp(token_start, "localhost/", strlen("localhost/"))) {
173 + if (token_len >= (sizeof "localhost")-1
174 + && strncmp(token_start, "localhost", (sizeof "localhost")-1) == 0
175 + && (token_len == (sizeof "localhost")-1
176 + || token_start[(sizeof "localhost")-1] == ',')) {
177 if ((ret = dcc_parse_localhost(curr, token_start)) != 0)
180 --- linuxdoc/distcc.sgml.orig Fri May 16 08:43:29 2003
181 +++ linuxdoc/distcc.sgml Sat May 17 21:38:13 2003
183 On the client, set the <tt>DISTCC_HOSTS</tt> environment
184 variable to indicate which volunteer machines to use.
186 - <tscreen><verb>DISTCC_HOSTS='angry toey:4202 localhost'</verb></tscreen>
187 + <tscreen><verb>HOSTNAME[:PORT][,OPT...]</verb></tscreen>
190 Set the <tt>CC</tt> variable or edit Makefiles to prefix
192 <tscreen><verb>distcc gcc -o hello.o -c hello.c</verb></tscreen>
197 + You can specify one or more host-specific options at the end of the
198 + host-spec by appending each one after a comma. The current option
199 + is slots=N (abbreviated as just N, if desired).
200 + The "slots" option specifies the maximum number of jobs that the
201 + associated host should be given simultaneously (e.g. "localhost,2").