chat.c (58028) | chat.c (64465) |
---|---|
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $FreeBSD: head/usr.sbin/ppp/chat.c 58028 2000-03-14 01:46:09Z brian $ | 26 * $FreeBSD: head/usr.sbin/ppp/chat.c 64465 2000-08-09 19:29:50Z brian $ |
27 */ 28 29#include <sys/param.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <sys/un.h> 34 --- 173 unchanged lines hidden (view full) --- 208 } 209 210 /* 211 * c->argptr now temporarily points into c->script (via c->argv) 212 * If it's an expect-send-expect sequence, we've just got the correct 213 * portion of that sequence. 214 */ 215 | 27 */ 28 29#include <sys/param.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <sys/un.h> 34 --- 173 unchanged lines hidden (view full) --- 208 } 209 210 /* 211 * c->argptr now temporarily points into c->script (via c->argv) 212 * If it's an expect-send-expect sequence, we've just got the correct 213 * portion of that sequence. 214 */ 215 |
216 needcr = c->state == CHAT_SEND && *c->argptr != '!'; | 216 needcr = c->state == CHAT_SEND && 217 (*c->argptr != '!' || c->argptr[1] == '!'); |
217 218 /* We leave room for a potential HDLC header in the target string */ 219 ExpandString(c, c->argptr, c->exp + 2, sizeof c->exp - 2, needcr); 220 221 /* 222 * Now read our string. If it's not a special string, we unset 223 * ``special'' to break out of the loop. 224 */ --- 24 unchanged lines hidden (view full) --- 249 if (c->TimeoutSec <= 0) 250 c->TimeoutSec = 30; 251 gottimeout = 0; 252 } else if (c->nargptr == NULL && !strcmp(c->exp+2, "ABORT")) 253 gotabort = 1; 254 else if (c->nargptr == NULL && !strcmp(c->exp+2, "TIMEOUT")) 255 gottimeout = 1; 256 else { | 218 219 /* We leave room for a potential HDLC header in the target string */ 220 ExpandString(c, c->argptr, c->exp + 2, sizeof c->exp - 2, needcr); 221 222 /* 223 * Now read our string. If it's not a special string, we unset 224 * ``special'' to break out of the loop. 225 */ --- 24 unchanged lines hidden (view full) --- 250 if (c->TimeoutSec <= 0) 251 c->TimeoutSec = 30; 252 gottimeout = 0; 253 } else if (c->nargptr == NULL && !strcmp(c->exp+2, "ABORT")) 254 gotabort = 1; 255 else if (c->nargptr == NULL && !strcmp(c->exp+2, "TIMEOUT")) 256 gottimeout = 1; 257 else { |
257 if (c->exp[2] == '!') 258 ExecStr(c->physical, c->exp + 3, c->exp + 2, sizeof c->exp - 2); | 258 if (c->exp[2] == '!' && c->exp[3] != '!') 259 ExecStr(c->physical, c->exp + 3, c->exp + 3, sizeof c->exp - 3); |
259 260 if (c->exp[2] == '\0') { 261 /* Empty string, reparse (this may be better as a `goto start') */ 262 c->argptr = &arg_term; 263 return chat_UpdateSet(d, r, w, e, n); 264 } 265 266 special = 0; --- 7 unchanged lines hidden (view full) --- 274 log_Printf(LogWARN, "chat_UpdateSet: ABORT: Argument expected\n"); 275 276 /* End of script - all ok */ 277 c->state = CHAT_DONE; 278 return 0; 279 } 280 281 /* set c->argptr to point in the right place */ | 260 261 if (c->exp[2] == '\0') { 262 /* Empty string, reparse (this may be better as a `goto start') */ 263 c->argptr = &arg_term; 264 return chat_UpdateSet(d, r, w, e, n); 265 } 266 267 special = 0; --- 7 unchanged lines hidden (view full) --- 275 log_Printf(LogWARN, "chat_UpdateSet: ABORT: Argument expected\n"); 276 277 /* End of script - all ok */ 278 c->state = CHAT_DONE; 279 return 0; 280 } 281 282 /* set c->argptr to point in the right place */ |
282 c->argptr = c->exp + 2; | 283 c->argptr = c->exp + (c->exp[2] == '!' ? 3 : 2); |
283 c->arglen = strlen(c->argptr); 284 285 if (c->state == CHAT_EXPECT) { 286 /* We must check to see if the string's already been found ! */ 287 char *begin, *end; 288 289 end = c->bufend - c->arglen + 1; 290 if (end < c->bufstart) --- 495 unchanged lines hidden --- | 284 c->arglen = strlen(c->argptr); 285 286 if (c->state == CHAT_EXPECT) { 287 /* We must check to see if the string's already been found ! */ 288 char *begin, *end; 289 290 end = c->bufend - c->arglen + 1; 291 if (end < c->bufstart) --- 495 unchanged lines hidden --- |