Print this page
5218 posix definition of NULL
correct unistd.h and iso/stddef_iso.h
update gate source affected
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/bnu/sysfiles.c
+++ new/usr/src/cmd/bnu/sysfiles.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
27 27 /* All Rights Reserved */
28 28
29 29 #include "uucp.h"
30 30
31 31 #include <unistd.h>
32 32 #include "sysfiles.h"
33 33 #include <sys/stropts.h>
34 34
35 35 /*
36 36 * manage systems files (Systems, Devices, and Dialcodes families).
37 37 *
38 38 * also manage new file Devconfig, allows per-device setup.
39 39 * present use is to specify what streams modules to push/pop for
40 40 * AT&T TLI/streams network.
41 41 *
42 42 * TODO:
43 43 * call bsfix()?
44 44 * combine the 3 versions of everything (sys, dev, and dial) into one.
45 45 * allow arbitrary classes of service.
46 46 * need verifysys() for uucheck.
47 47 * nameserver interface?
48 48 * pass sysname (or 0) to getsysline(). (might want reg. exp. or NS processing
49 49 */
50 50
51 51 /* private variables */
52 52 static void tokenize(), nameparse(), setfile(), setioctl(),
53 53 scansys(), scancfg(), setconfig();
54 54 static int namematch(), nextdialers(), nextdevices(), nextsystems(), getaline();
55 55
56 56 /* pointer arrays might be dynamically allocated */
57 57 static char *Systems[64] = {0}; /* list of Systems files */
58 58 static char *Devices[64] = {0}; /* list of Devices files */
59 59 static char *Dialers[64] = {0}; /* list of Dialers files */
60 60 static char *Pops[64] = {0}; /* list of STREAMS modules to be popped */
61 61 static char *Pushes[64] = {0}; /* list of STREAMS modules to be pushed */
62 62
63 63 static int nsystems; /* index into list of Systems files */
64 64 static int ndevices; /* index into list of Devices files */
65 65 static int ndialers; /* index into list of Dialers files */
66 66 static int npops; /* index into list of STREAMS modules */
67 67 /*to be popped */
68 68 static int npushes; /* index into list of STREAMS modules */
69 69 /*to be pushed */
70 70
71 71 GLOBAL unsigned connecttime = CONNECTTIME;
72 72 GLOBAL unsigned expecttime = EXPECTTIME;
73 73 GLOBAL unsigned msgtime = MSGTIME;
74 74
75 75 static FILE *fsystems;
76 76 static FILE *fdevices;
77 77 static FILE *fdialers;
78 78
79 79 static char errformat[BUFSIZ];
80 80
81 81 /* this might be dynamically allocated */
82 82 #define NTOKENS 16
83 83 static char *tokens[NTOKENS], **tokptr;
84 84
85 85 /* export these */
86 86 EXTERN void sysreset(), devreset(), dialreset(), setdevcfg(), setservice();
87 87 EXTERN char *strsave();
88 88
89 89 /* import these */
90 90 extern char *strcpy(), *strtok(), *strchr(), *strsave();
91 91 EXTERN int eaccess();
92 92
93 93 /*
94 94 * setservice init's Systems, Devices, Dialers lists from Sysfiles
95 95 */
96 96 GLOBAL void
97 97 setservice(service)
98 98 char *service;
99 99 {
100 100 char *prev = _uu_setlocale(LC_ALL, "C");
101 101
102 102 setconfig();
103 103 scansys(service);
104 104 (void) _uu_resetlocale(LC_ALL, prev);
105 105 return;
106 106 }
107 107
108 108 /*
109 109 * setdevcfg init's Pops, Pushes lists from Devconfig
110 110 */
111 111
112 112 GLOBAL void
113 113 setdevcfg(service, device)
114 114 char *service, *device;
115 115 {
116 116 char *prev = _uu_setlocale(LC_ALL, "C");
117 117
118 118 scancfg(service, device);
119 119 (void) _uu_resetlocale(LC_ALL, prev);
120 120 return;
121 121 }
122 122
123 123 /* administrative files access */
124 124 GLOBAL int
125 125 sysaccess(type)
126 126 int type;
127 127 {
128 128 switch (type) {
129 129
130 130 case ACCESS_SYSTEMS:
131 131 return(access(Systems[nsystems], R_OK));
132 132 case ACCESS_DEVICES:
133 133 return(access(Devices[ndevices], R_OK));
134 134 case ACCESS_DIALERS:
135 135 return(access(Dialers[ndialers], R_OK));
136 136 case EACCESS_SYSTEMS:
137 137 return(eaccess(Systems[nsystems], R_OK));
138 138 case EACCESS_DEVICES:
139 139 return(eaccess(Devices[ndevices], R_OK));
140 140 case EACCESS_DIALERS:
141 141 return(eaccess(Dialers[ndialers], R_OK));
142 142 default:
143 143 (void)sprintf(errformat, "bad access type %d", type);
144 144 logent(errformat, "sysaccess");
145 145 return(FAIL);
146 146 }
147 147 }
148 148
149 149
150 150 /*
151 151 * read Sysfiles, set up lists of Systems/Devices/Dialers file names.
152 152 * allow multiple entries for a given service, allow a service
153 153 * type to describe resources more than once, e.g., systems=foo:baz systems=bar.
154 154 */
155 155 static void
156 156 scansys(service)
157 157 char *service;
158 158 { FILE *f;
159 159 char *tok, buf[BUFSIZ];
160 160
161 161 Systems[0] = Devices[0] = Dialers[0] = NULL;
162 162 if ((f = fopen(SYSFILES, "r")) != 0) {
163 163 while (getaline(f, buf) > 0) {
164 164 /* got a (logical) line from Sysfiles */
165 165 /* strtok's of this buf continue in tokenize() */
166 166 tok = strtok(buf, " \t");
167 167 if (namematch("service=", tok, service)) {
168 168 tokenize();
169 169 nameparse();
170 170 }
171 171 }
172 172 (void) fclose(f);
173 173 }
174 174
175 175 /* if didn't find entries in Sysfiles, use defaults */
176 176 if (Systems[0] == NULL) {
177 177 Systems[0] = strsave(SYSTEMS);
178 178 ASSERT(Systems[0] != NULL, Ct_ALLOCATE, "scansys: Systems", 0);
179 179 Systems[1] = NULL;
180 180 }
181 181 if (Devices[0] == NULL) {
182 182 Devices[0] = strsave(DEVICES);
183 183 ASSERT(Devices[0] != NULL, Ct_ALLOCATE, "scansys: Devices", 0);
184 184 Devices[1] = NULL;
185 185 }
186 186 if (Dialers[0] == NULL) {
187 187 Dialers[0] = strsave(DIALERS);
188 188 ASSERT(Dialers[0] != NULL, Ct_ALLOCATE, "scansys: Dialers", 0);
189 189 Dialers[1] = NULL;
190 190 }
191 191 return;
192 192 }
193 193
194 194
195 195 /*
196 196 * read Devconfig. allow multiple entries for a given service, allow a service
197 197 * type to describe resources more than once, e.g., push=foo:baz push=bar.
198 198 */
199 199 static void
200 200 scancfg(service, device)
201 201 char *service, *device;
202 202 { FILE *f;
203 203 char *tok, buf[BUFSIZ];
204 204
205 205 /* (re)initialize device-specific information */
206 206
207 207 npops = npushes = 0;
208 208 Pops[0] = Pushes[0] = NULL;
209 209 connecttime = CONNECTTIME;
210 210 expecttime = EXPECTTIME;
211 211 msgtime = MSGTIME;
212 212
213 213 if ((f = fopen(DEVCONFIG, "r")) != 0) {
214 214 while (getaline(f, buf) > 0) {
215 215 /* got a (logical) line from Devconfig */
216 216 /* strtok's of this buf continue in tokenize() */
217 217 tok = strtok(buf, " \t");
218 218 if (namematch("service=", tok, service)) {
219 219 tok = strtok((char *)0, " \t");
220 220 if ( namematch("device=", tok, device)) {
221 221 tokenize();
222 222 nameparse();
223 223 }
224 224 }
225 225 }
226 226 (void) fclose(f);
227 227 }
228 228
229 229 return;
230 230
231 231 }
232 232
233 233 /*
234 234 * given a file pointer and buffer, construct logical line in buffer
235 235 * (i.e., concatenate lines ending in '\'). return length of line
236 236 * ASSUMES that buffer is BUFSIZ long!
237 237 */
238 238
239 239 static int
240 240 getaline(f, line)
241 241 FILE *f;
242 242 char *line;
243 243 { char *lptr, *lend;
244 244
245 245 lptr = line;
246 246 while (fgets(lptr, (line + BUFSIZ) - lptr, f) != NULL) {
247 247 lend = lptr + strlen(lptr);
248 248 if (lend == lptr || lend[-1] != '\n')
249 249 /* empty buf or line too long! */
250 250 break;
251 251 *--lend = '\0'; /* lop off ending '\n' */
252 252 if ( lend == line ) /* empty line - ignore */
253 253 continue;
254 254 lptr = lend;
255 255 if (lend[-1] != '\\')
256 256 break;
257 257 /* continuation */
258 258 lend[-1] = ' ';
259 259 }
260 260 return(lptr - line);
261 261 }
262 262
263 263 /*
264 264 * given a label (e.g., "service=", "device="), a name ("cu", "uucico"),
265 265 * and a line: if line begins with the label and if the name appears
266 266 * in a colon-separated list of names following the label, return true;
267 267 * else return false
268 268 */
269 269 static int
270 270 namematch(label, line, name)
271 271 char *label, *line, *name;
272 272 { char *lend;
273 273
274 274 if (strncmp(label, line, strlen(label)) != SAME) {
275 275 return(FALSE); /* probably a comment line */
276 276 }
277 277 line += strlen(label);
278 278 if (*line == '\0')
279 279 return(FALSE);
280 280 /*
281 281 * can't use strtok() in the following because scansys(),
282 282 * scancfg() do an initializing call to strtok() before
283 283 * coming here and then CONTINUE calling strtok() in tokenize(),
284 284 * after returning from namematch().
285 285 */
286 286 while ((lend = strchr(line, ':')) != NULL) {
287 287 *lend = '\0';
288 288 if (strcmp(line, name) == SAME)
289 289 return(TRUE);
290 290 line = lend+1;
291 291 }
292 292 return(strcmp(line, name) == SAME);
293 293 }
294 294
295 295 /*
296 296 * tokenize() continues pulling tokens out of a buffer -- the
297 297 * initializing call to strtok must have been made before calling
298 298 * tokenize() -- and starts stuffing 'em into tokptr.
299 299 */
300 300 static void
301 301 tokenize()
302 302 { char *tok;
303 303
304 304 tokptr = tokens;
305 305 while ((tok = strtok((char *) NULL, " \t")) != NULL) {
306 306 *tokptr++ = tok;
307 307 if (tokptr - tokens >= NTOKENS)
308 308 break;
309 309 }
310 310 *tokptr = NULL;
311 311 return;
312 312 }
313 313
314 314 /*
315 315 * look at top token in array: should be line of the form
316 316 * name=item1:item2:item3...
317 317 * if name is one we recognize, then call set[file|ioctl] to set up
318 318 * corresponding list. otherwise, log bad name.
319 319 */
320 320 static void
321 321 nameparse()
322 322 { char **line, *equals;
323 323 int temp;
324 324
325 325 #define setuint(a,b,c) a = ( ((temp = atoi(b)) <= 0) ? (c) : temp )
326 326
327 327 for (line = tokens; (line - tokens) < NTOKENS && *line; line++) {
328 328 equals = strchr(*line, '=');
329 329 if (equals == NULL)
330 330 continue; /* may be meaningful someday? */
331 331 *equals = '\0';
332 332 /* ignore entry with empty rhs */
333 333 if (*++equals == '\0')
334 334 continue;
335 335 if (strcmp(*line, "systems") == SAME)
336 336 setfile(Systems, equals);
337 337 else if (strcmp(*line, "devices") == SAME)
338 338 setfile(Devices, equals);
339 339 else if (strcmp(*line, "dialers") == SAME)
340 340 setfile(Dialers, equals);
341 341 else if (strcmp(*line, "pop") == SAME)
342 342 setioctl(Pops, equals);
343 343 else if (strcmp(*line, "push") == SAME)
344 344 setioctl(Pushes, equals);
345 345 else if (strcmp(*line, "connecttime") == SAME)
346 346 setuint(connecttime, equals, CONNECTTIME);
347 347 else if (strcmp(*line, "expecttime") == SAME)
348 348 setuint(expecttime, equals, EXPECTTIME);
349 349 else if (strcmp(*line, "msgtime") == SAME)
350 350 setuint(msgtime, equals, MSGTIME);
351 351 else {
352 352 (void)sprintf(errformat,"unrecognized label %s",*line);
353 353 logent(errformat, "Sysfiles|Devconfig");
354 354 }
355 355 }
356 356 return;
357 357 }
358 358
359 359 /*
360 360 * given the list for a particular type (systems, devices,...)
361 361 * and a line of colon-separated files, add 'em to list
362 362 */
363 363
364 364 static void
365 365 setfile(type, line)
366 366 char **type, *line;
367 367 { char **tptr, *tok;
368 368 char expandpath[BUFSIZ];
369 369
370 370 if (*line == 0)
371 371 return;
372 372 tptr = type;
373 373 while (*tptr) /* skip over existing entries to*/
374 374 tptr++; /* concatenate multiple entries */
375 375
376 376 for (tok = strtok(line, ":"); tok != NULL;
377 377 tok = strtok((char *) NULL, ":")) {
378 378 expandpath[0] = '\0';
379 379 if ( *tok != '/' )
380 380 /* by default, file names are relative to SYSDIR */
381 381 sprintf(expandpath, "%s/", SYSDIR);
382 382 strcat(expandpath, tok);
383 383 if (eaccess(expandpath, R_OK) != 0)
384 384 /* if we can't read it, no point in adding to list */
385 385 continue;
386 386 *tptr = strsave(expandpath);
387 387 ASSERT(*tptr != NULL, Ct_ALLOCATE, "setfile: tptr", 0);
388 388 tptr++;
389 389 }
390 390 return;
391 391 }
392 392
393 393 /*
394 394 * given the list for a particular ioctl (push, pop)
395 395 * and a line of colon-separated modules, add 'em to list
396 396 */
397 397
398 398 static void
399 399 setioctl(type, line)
400 400 char **type, *line;
401 401 { char **tptr, *tok;
402 402
403 403 if (*line == 0)
404 404 return;
405 405 tptr = type;
406 406 while (*tptr) /* skip over existing entries to*/
407 407 tptr++; /* concatenate multiple entries */
408 408 for (tok = strtok(line, ":"); tok != NULL;
409 409 tok = strtok((char *) NULL, ":")) {
410 410 *tptr = strsave(tok);
411 411 ASSERT(*tptr != NULL, Ct_ALLOCATE, "setioctl: tptr", 0);
412 412 tptr++;
413 413 }
414 414 return;
415 415 }
416 416
417 417 /*
418 418 * reset Systems files
419 419 */
420 420 GLOBAL void
421 421 sysreset()
422 422 {
423 423 if (fsystems)
424 424 fclose(fsystems);
425 425 fsystems = NULL;
426 426 nsystems = 0;
427 427 devreset();
428 428 return;
429 429 }
430 430
431 431 /*
432 432 * reset Devices files
433 433 */
434 434 GLOBAL void
435 435 devreset()
436 436 {
437 437 if (fdevices)
438 438 fclose(fdevices);
439 439 fdevices = NULL;
440 440 ndevices = 0;
441 441 dialreset();
442 442 return;
443 443 }
444 444
445 445 /*
446 446 * reset Dialers files
447 447 */
448 448 GLOBAL void
449 449 dialreset()
450 450 {
451 451 if (fdialers)
452 452 fclose(fdialers);
453 453 fdialers = NULL;
454 454 ndialers = 0;
455 455 return;
456 456 }
457 457
458 458 /*
459 459 * get next line from Systems file
460 460 * return TRUE if successful, FALSE if not
461 461 */
462 462 GLOBAL int
463 463 getsysline(buf, len)
464 464 char *buf;
465 465 {
466 466 char *prev = _uu_setlocale(LC_ALL, "C");
467 467
468 468 if (Systems[0] == NULL)
469 469 /* not initialized via setservice() - use default */
470 470 setservice("uucico");
471 471
472 472 /* initialize devices and dialers whenever a new line is read */
↓ open down ↓ |
472 lines elided |
↑ open up ↑ |
473 473 /* from systems */
474 474 devreset();
475 475 if (fsystems == NULL)
476 476 if (nextsystems() == FALSE) {
477 477 (void) _uu_resetlocale(LC_ALL, prev);
478 478 return(FALSE);
479 479 }
480 480
481 481 ASSERT(len >= BUFSIZ, "BUFFER TOO SMALL", "getsysline", 0);
482 482 for(;;) {
483 - while (getaline(fsystems, buf) != NULL)
483 + while (getaline(fsystems, buf) != 0)
484 484 if ((*buf != '#') && (*buf != ' ') &&
485 485 (*buf != '\t') && (*buf != '\n')) {
486 486 (void) _uu_resetlocale(LC_ALL, prev);
487 487 return(TRUE);
488 488 }
489 489 if (nextsystems() == FALSE) {
490 490 (void) _uu_resetlocale(LC_ALL, prev);
491 491 return(FALSE);
492 492 }
493 493 }
494 494 }
495 495
496 496 /*
497 497 * move to next systems file. return TRUE if successful, FALSE if not
498 498 */
499 499 static int
500 500 nextsystems()
501 501 {
502 502 devreset();
503 503
504 504 if (fsystems != NULL) {
505 505 (void) fclose(fsystems);
506 506 nsystems++;
507 507 } else {
508 508 nsystems = 0;
509 509 }
510 510 for ( ; Systems[nsystems] != NULL; nsystems++)
511 511 if ((fsystems = fopen(Systems[nsystems], "r")) != NULL)
512 512 return(TRUE);
513 513 return(FALSE);
514 514 }
515 515
516 516 /*
517 517 * get next line from Devices file
518 518 * return TRUE if successful, FALSE if not
519 519 */
520 520 GLOBAL int
521 521 getdevline(buf, len)
522 522 char *buf;
523 523 {
524 524 char *prev = _uu_setlocale(LC_ALL, "C");
525 525
526 526 if (Devices[0] == NULL)
527 527 /* not initialized via setservice() - use default */
528 528 setservice("uucico");
529 529
530 530 if (fdevices == NULL)
531 531 if (nextdevices() == FALSE) {
532 532 (void) _uu_resetlocale(LC_ALL, prev);
533 533 return(FALSE);
534 534 }
535 535 for(;;) {
536 536 if (fgets(buf, len, fdevices) != NULL) {
537 537 (void) _uu_resetlocale(LC_ALL, prev);
538 538 return(TRUE);
539 539 }
540 540 if (nextdevices() == FALSE) {
541 541 (void) _uu_resetlocale(LC_ALL, prev);
542 542 return(FALSE);
543 543 }
544 544 }
545 545 }
546 546
547 547 /*
548 548 * move to next devices file. return TRUE if successful, FALSE if not
549 549 */
550 550 static int
551 551 nextdevices()
552 552 {
553 553 if (fdevices != NULL) {
554 554 (void) fclose(fdevices);
555 555 ndevices++;
556 556 } else {
557 557 ndevices = 0;
558 558 }
559 559 for ( ; Devices[ndevices] != NULL; ndevices++)
560 560 if ((fdevices = fopen(Devices[ndevices], "r")) != NULL)
561 561 return(TRUE);
562 562 return(FALSE);
563 563 }
564 564
565 565
566 566 /*
567 567 * get next line from Dialers file
568 568 * return TRUE if successful, FALSE if not
569 569 */
570 570
571 571 GLOBAL int
572 572 getdialline(buf, len)
573 573 char *buf;
574 574 {
575 575 char *prev = _uu_setlocale(LC_ALL, "C");
576 576
577 577 if (Dialers[0] == NULL)
578 578 /* not initialized via setservice() - use default */
579 579 setservice("uucico");
580 580
581 581 if (fdialers == NULL)
582 582 if (nextdialers() == FALSE) {
583 583 (void) _uu_resetlocale(LC_ALL, prev);
584 584 return(FALSE);
585 585 }
586 586 for(;;) {
587 587 if (fgets(buf, len, fdialers) != NULL) {
588 588 (void) _uu_resetlocale(LC_ALL, prev);
589 589 return(TRUE);
590 590 }
591 591 if (nextdialers() == FALSE) {
592 592 (void) _uu_resetlocale(LC_ALL, prev);
593 593 return(FALSE);
594 594 }
595 595 }
596 596 }
597 597
598 598 /*
599 599 * move to next dialers file. return TRUE if successful, FALSE if not
600 600 */
601 601 static int
602 602 nextdialers()
603 603 {
604 604 if (fdialers) {
605 605 (void) fclose(fdialers);
606 606 ndialers++;
607 607 } else {
608 608 ndialers = 0;
609 609 }
610 610
611 611 for ( ; Dialers[ndialers] != NULL; ndialers++)
612 612 if ((fdialers = fopen(Dialers[ndialers], "r")) != NULL)
613 613 return(TRUE);
614 614 return(FALSE);
615 615 }
616 616
617 617 /*
618 618 * get next module to be popped
619 619 * return TRUE if successful, FALSE if not
620 620 */
621 621 static int
622 622 getpop(buf, len, optional)
623 623 char *buf;
624 624 int len, *optional;
625 625 {
626 626 int slen;
627 627
628 628 if ( Pops[0] == NULL || Pops[npops] == NULL )
629 629 return(FALSE);
630 630
631 631 /* if the module name is enclosed in parentheses, */
632 632 /* is optional. set flag & strip parens */
633 633 slen = strlen(Pops[npops]) - 1;
634 634 if ( Pops[npops][0] == '(' && Pops[npops][slen] == ')' ) {
635 635 *optional = 1;
636 636 len = ( slen < len ? slen : len );
637 637 strncpy(buf, &(Pops[npops++][1]), len);
638 638 } else {
639 639 *optional = 0;
640 640 strncpy(buf, Pops[npops++], len);
641 641 }
642 642 buf[len-1] = '\0';
643 643 return(TRUE);
644 644 }
645 645
646 646 /*
647 647 * get next module to be pushed
648 648 * return TRUE if successful, FALSE if not
649 649 */
650 650 static int
651 651 getpush(buf, len)
652 652 char *buf;
653 653 int len;
654 654 {
655 655 if ( Pushes[0] == NULL || Pushes[npushes] == NULL )
656 656 return(FALSE);
657 657 strncpy(buf, Pushes[npushes++], len);
658 658 return(TRUE);
659 659 }
660 660
661 661 /*
662 662 * pop/push requested modules
663 663 * return TRUE if successful, FALSE if not
664 664 */
665 665 GLOBAL int
666 666 pop_push(fd)
667 667 int fd;
668 668 {
669 669 char strmod[FMNAMESZ], onstream[FMNAMESZ];
670 670 int optional;
671 671 char *prev = _uu_setlocale(LC_ALL, "C");
672 672
673 673 /* check for streams modules to pop */
674 674 while ( getpop(strmod, sizeof(strmod), &optional) ) {
675 675 DEBUG(5, (optional ? "pop_push: optionally POPing %s\n"
676 676 : "pop_push: POPing %s\n" ), strmod);
677 677 if ( ioctl(fd, I_LOOK, onstream) == -1 ) {
678 678 DEBUG(5, "pop_push: I_LOOK on fd %d failed ", fd);
679 679 DEBUG(5, "errno %d\n", errno);
680 680 (void) _uu_resetlocale(LC_ALL, prev);
681 681 return(FALSE);
682 682 }
683 683 if ( strcmp(strmod, onstream) != SAME ) {
684 684 if ( optional )
685 685 continue;
686 686 DEBUG(5, "pop_push: I_POP: %s not there\n", strmod);
687 687 (void) _uu_resetlocale(LC_ALL, prev);
688 688 return(FALSE);
689 689 }
690 690 if ( ioctl(fd, I_POP, 0) == -1 ) {
691 691 DEBUG(5, "pop_push: I_POP on fd %d failed ", fd);
692 692 DEBUG(5, "errno %d\n", errno);
693 693 (void) _uu_resetlocale(LC_ALL, prev);
694 694 return(FALSE);
695 695 }
696 696 }
697 697
698 698 /* check for streams modules to push */
699 699 while ( getpush(strmod, sizeof(strmod)) ) {
700 700 DEBUG(5, "pop_push: PUSHing %s\n", strmod);
701 701 if ( ioctl(fd, I_PUSH, strmod) == -1 ) {
702 702 DEBUG(5, "pop_push: I_PUSH on fd %d failed ", fd);
703 703 DEBUG(5, "errno %d\n", errno);
704 704 (void) _uu_resetlocale(LC_ALL, prev);
705 705 return(FALSE);
706 706 }
707 707 }
708 708 (void) _uu_resetlocale(LC_ALL, prev);
709 709 return(TRUE);
710 710 }
711 711
712 712 /*
713 713 * return name of currently open Systems file
714 714 */
715 715 GLOBAL char *
716 716 currsys()
717 717 {
718 718 return(Systems[nsystems]);
719 719 }
720 720
721 721 /*
722 722 * return name of currently open Devices file
723 723 */
724 724 GLOBAL char *
725 725 currdev()
726 726 {
727 727 return(Devices[ndevices]);
728 728 }
729 729
730 730 /*
731 731 * return name of currently open Dialers file
732 732 */
733 733 GLOBAL char *
734 734 currdial()
735 735 {
736 736 return(Dialers[ndialers]);
737 737 }
738 738
739 739 /*
740 740 * set configuration parameters provided in Config file
741 741 */
742 742 static void
743 743 setconfig()
744 744 {
745 745 FILE *f;
746 746 char buf[BUFSIZ];
747 747 char *tok;
748 748 extern char _ProtoCfg[];
749 749
750 750 if ((f = fopen(CONFIG, "r")) != 0) {
751 751 while (getaline(f, buf) > 0) {
752 752 /* got a (logical) line from Config file */
753 753 tok = strtok(buf, " \t");
754 754 if ( (tok != NULL) && (*tok != '#') ) {
755 755 /* got a token */
756 756
757 757 /* this probably should be table driven when
758 758 * the list of configurable parameters grows.
759 759 */
760 760 if (strncmp("Protocol=", tok, strlen("Protocol=")) == SAME) {
761 761 tok += strlen("Protocol=");
762 762 if ( *tok != '\0' ) {
763 763 if ( _ProtoCfg[0] != '\0' ) {
764 764 DEBUG(7, "Protocol string %s ", tok);
765 765 DEBUG(7, "overrides %s\n", _ProtoCfg);
766 766 }
767 767 strcpy(_ProtoCfg, tok);
768 768 }
769 769 } else {
770 770 DEBUG(7, "Unknown configuration parameter %s\n", tok);
771 771 }
772 772 }
773 773 }
774 774 }
775 775 }
↓ open down ↓ |
282 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX