4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 */
25
26 #include <stdio.h>
27 #include <string.h>
28 #include "util.h"
29
30
31
32
33 /*
34 * This is just like fgets, but recognizes that "\\n" signals a continuation
35 * of a line
36 */
37 char *
38 getaline(line, maxlen, fp)
39 char *line;
40 int maxlen;
41 FILE *fp;
42 {
43 register char *p;
80 break;
81 else if (c == '\\') {
82 /*
83 * Ignore the next character except EOF
84 */
85 if (getc(fp) == EOF)
86 break;
87 }
88 }
89
90 maxlen = strlen(line) + 1;
91
92 /*
93 * Certain functions expects a newline in the buffer.
94 */
95 if (maxlen >= 2)
96 line[maxlen - 2] = '\n';
97 (void) fprintf(stderr, "Following line too long - remaining chars "
98 "ignored\n--- %s", line);
99 return (line);
100 }
101
102
103 void
104 fatal(message)
105 char *message;
106 {
107 (void) fprintf(stderr, "fatal error: %s\n", message);
108 exit(1);
109 }
|
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22 /*
23 * Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
25 */
26
27 #include <stdio.h>
28 #include <string.h>
29 #include "util.h"
30
31
32
33
34 /*
35 * This is just like fgets, but recognizes that "\\n" signals a continuation
36 * of a line
37 */
38 char *
39 getaline(line, maxlen, fp)
40 char *line;
41 int maxlen;
42 FILE *fp;
43 {
44 register char *p;
81 break;
82 else if (c == '\\') {
83 /*
84 * Ignore the next character except EOF
85 */
86 if (getc(fp) == EOF)
87 break;
88 }
89 }
90
91 maxlen = strlen(line) + 1;
92
93 /*
94 * Certain functions expects a newline in the buffer.
95 */
96 if (maxlen >= 2)
97 line[maxlen - 2] = '\n';
98 (void) fprintf(stderr, "Following line too long - remaining chars "
99 "ignored\n--- %s", line);
100 return (line);
101 }
|