term% diff /sys/src/cmd/ip/ppp . Only in .: 8632222.chat Only in .: chat.c Only in .: chat.h diff /sys/src/cmd/ip/ppp/mkfile ./mkfile 11a12 > chat.$O\ Only in .: modem.chat diff /sys/src/cmd/ip/ppp/ppp.c ./ppp.c 8a9 > #include "chat.h" 24a26 > char servername[PATH]; 2512,2572c2514,2519 < int chatfd, lineno, nb; < char *buf, *p, *s, response[128]; < Dir *dir; < < if ((chatfd = open(chatfile, OREAD)) < 0) < sysfatal("cannot open %s: %r", chatfile); < < if ((dir = dirfstat(chatfd)) == nil) < sysfatal("cannot fstat %s: %r",chatfile); < < buf = (char *)malloc(dir->length + 1); < assert(buf); < < if ((nb = read(chatfd, buf, dir->length)) < 0) < sysfatal("cannot read chatfile %s: %r", chatfile); < assert(nb == dir->length); < buf[dir->length] = '\0'; < free(dir); < close(chatfd); < < p = buf; < lineno = 0; < while (1) { < char *_args[3]; < < if ((s = strchr(p, '\n')) == nil) < break; < *s++ = '\0'; < < lineno++; < < if (*p == '#') { < p = s; < continue; < } < < if (tokenize(p, _args, 3) != 2) < sysfatal("invalid line %d (line expected: 'send' 'expect')", < lineno); < < if (debug) < print("sending %s, expecting %s\n", _args[0], _args[1]); < < if ((nb = write(fd, _args[0], strlen(_args[0]))) < 0) < sysfatal("cannot write %ss: %r", _args[0]); < assert(nb == strlen(_args[0])); < < if (strlen(_args[1]) > 0) { < if ((nb = read(fd, response, sizeof response)) < 0) < sysfatal("cannot read response from: %r"); < < if (debug) < print("response %s\n", response); < < if (nb == 0) < sysfatal("eof on input?\n"); < < if (cistrstr(response, _args[1]) == nil) < sysfatal("expected %s, got %s\n", _args[1], response); < } < p = s; --- > // Try to deduce the server name from the chatfile name. > if (!*servername) { > char *p; > strecpy(servername, servername+PATH-1, chatfile); > if ((p=strstr(servername, ".chat"))) > *p = 0; 2574c2521 < free(buf); --- > chat(fd, fd, chatfile); 2576c2523 < } --- > }; 2632c2579 < fprint(2, "usage: ppp [-cCdfPSu] [-b baud] [-k keyspec] [-m mtu] [-p dev] [-s username] [-x netmntpt] [-t modemcmd] [local-addr [remote-addr]]\n"); --- > fprint(2, "usage: ppp [-cCdfPSu] [-b baud] [-k keyspec] [-m mtu] [-p dev] [-s servername] [-x netmntpt] [-t modemcmd] [local-addr [remote-addr]]\n"); 2706a2654,2656 > case 's': > snprint(servername, PATH, "%s", EARGF(usage())); > break; 2743a2694,2701 > // If we don't have a user specified server name, > // try to deduce one from the dial string. > if(!*servername) { > char *p = strchr(dev,'!'); > snprint(servername, PATH, "%s", p+1); > p = strchr(servername, '!'); > if (p) *p = 0; > } 2751a2710 > 2885a2845,2855 > UserPasswd * > getuserpass() > { > if (servername[0]==0) > return auth_getuserpasswd(auth_getkey, > "proto=pass service=ppp %s", keyspec); > else > return auth_getuserpasswd(auth_getkey, > "proto=pass service=ppp server=%s %s", servername, keyspec); > } > 2893,2895c2863,2864 < < up = auth_getuserpasswd(auth_getkey,"proto=pass service=ppp %s", keyspec); < if(up != nil){ --- > > if((up = getuserpass()) != nil){ 2899a2869 > Only in .: telco.chat Only in .: try