+}
+
+void fetch_with_rsync(const char *stem) {
+ pid_t fetcher;
+
+ sysassert( (fetcher= fork()) != -1 );
+ if (!fetcher) {
+ const char *rsync= getenv("YPPSC_PCTB_RSYNC");
+ if (!rsync) rsync= "rsync";
+
+ const char *src= getenv("YPPSC_PCTB_DICT_UPDATE");
+ char *remote= masprintf("%s/master-%s.txt", src, stem);
+ char *local= masprintf("_master-%s.txt", stem);
+ if (DEBUGP(rsync))
+ fprintf(stderr,"executing rsync to fetch %s to %s\n",remote,local);
+ execlp(rsync, "rsync",
+ DEBUGP(rsync) ? "-zvLt" : "-zLt",
+ "--",remote,local,(char*)0);
+ sysassert(!"exec rsync failed");
+ }
+
+ waitpid_check_exitstatus(fetcher, "rsync");
+}
+
+static void set_server(const char *envname, const char *defprotocol,
+ const char *defvalue, const char *defvalue_test,
+ const char *userspecified,
+ int enable) {
+ const char *value;
+
+ if (!enable) { value= "0"; goto ok; }
+
+ if (userspecified)
+ value= userspecified;
+ else if ((value= getenv(envname)))
+ ;
+ else if (o_flags & ff_testservers)
+ value= defvalue_test;
+ else
+ value= defvalue;
+
+ if (value[0]=='/' || (value[0]=='.' && value[1]=='/'))
+ /* absolute or relative pathname - or anyway, something with no hostname */
+ goto ok;
+
+ const char *colon= strchr(value, ':');
+ const char *slash= strchr(value, '/');
+
+ if (colon && (!slash || colon < slash))
+ /* colon before the first slash, if any */
+ /* rsync :: protocol specification - anyway, adding scheme:// won't help */
+ goto ok;
+
+ int vallen= strlen(value);
+
+ value= masprintf("%s%s%s", defprotocol, value,
+ vallen && value[vallen-1]=='/' ? "" : "/");
+
+ ok:
+ sysassert(! setenv(envname,value,1) );
+}