1 /* |
1 /* |
2 * CDDL HEADER START |
2 * CDDL HEADER START |
3 * |
3 * |
4 * The contents of this file are subject to the terms of the |
4 * The contents of this file are subject to the terms of the |
5 * Common Development and Distribution License, Version 1.0 only |
5 * Common Development and Distribution License (the "License"). |
6 * (the "License"). You may not use this file except in compliance |
6 * You may not use this file except in compliance with the License. |
7 * with the License. |
|
8 * |
7 * |
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
10 * or http://www.opensolaris.org/os/licensing. |
9 * or http://www.opensolaris.org/os/licensing. |
11 * See the License for the specific language governing permissions |
10 * See the License for the specific language governing permissions |
12 * and limitations under the License. |
11 * and limitations under the License. |
18 * information: Portions Copyright [yyyy] [name of copyright owner] |
17 * information: Portions Copyright [yyyy] [name of copyright owner] |
19 * |
18 * |
20 * CDDL HEADER END |
19 * CDDL HEADER END |
21 */ |
20 */ |
22 /* |
21 /* |
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved. |
22 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
24 * Use is subject to license terms. |
23 * Use is subject to license terms. |
25 * |
24 * |
26 * eftwrite.c -- routines for writing .eft files |
25 * eftwrite.c -- routines for writing .eft files |
27 * |
26 * |
28 * this module emits the table resulting from compilation of the |
27 * this module emits the table resulting from compilation of the |
63 |
61 |
64 void |
62 void |
65 eftwrite_init(void) |
63 eftwrite_init(void) |
66 { |
64 { |
67 Outbytes = stats_new_counter("eftwrite.total", "bytes written", 1); |
65 Outbytes = stats_new_counter("eftwrite.total", "bytes written", 1); |
68 } |
|
69 |
|
70 static const char * |
|
71 mygetlogin(void) |
|
72 { |
|
73 const char *result = getlogin(); |
|
74 static char id[100]; |
|
75 |
|
76 if (result != NULL) |
|
77 return (result); |
|
78 |
|
79 (void) snprintf(id, 100, "uid:%ld", getuid()); |
|
80 return (id); |
|
81 } |
66 } |
82 |
67 |
83 /*ARGSUSED*/ |
68 /*ARGSUSED*/ |
84 static void |
69 static void |
85 ident_lencalc(const char *s, void *rhs, void *arg) |
70 ident_lencalc(const char *s, void *rhs, void *arg) |
142 hdr.minor = EFT_HDR_MINOR; |
126 hdr.minor = EFT_HDR_MINOR; |
143 hdr.cmajor = VERSION_MAJOR; |
127 hdr.cmajor = VERSION_MAJOR; |
144 hdr.cminor = VERSION_MINOR; |
128 hdr.cminor = VERSION_MINOR; |
145 hdr.identlen = Identlen; |
129 hdr.identlen = Identlen; |
146 hdr.dictlen = Dictlen; |
130 hdr.dictlen = Dictlen; |
147 (void) time(&clock); |
|
148 if (gethostname(buf, BUFLEN) < 0) |
|
149 out(O_DIE|O_SYS, "gethostname"); |
|
150 buf[BUFLEN - 1] = '\0'; |
131 buf[BUFLEN - 1] = '\0'; |
151 (void) snprintf(hdr.comment, EFT_HDR_MAXCOMMENT, |
132 (void) snprintf(hdr.comment, EFT_HDR_MAXCOMMENT, |
152 "Built using esc-%d.%d by %s on %s at %s\tArgs: \"%s\"\n", |
133 "Built using esc-%d.%d\tArgs: \"%s\"\n", VERSION_MAJOR, |
153 VERSION_MAJOR, VERSION_MINOR, mygetlogin(), buf, ctime(&clock), |
134 VERSION_MINOR, Args); |
154 Args); |
|
155 |
135 |
156 if ((fp = fopen(fname, "w")) == NULL) |
136 if ((fp = fopen(fname, "w")) == NULL) |
157 out(O_DIE|O_SYS, "can't open output file: %s", fname); |
137 out(O_DIE|O_SYS, "can't open output file: %s", fname); |
158 |
138 |
159 while ((cc = fread(buf, 1, BUFLEN, tfp)) > 0) { |
139 while ((cc = fread(buf, 1, BUFLEN, tfp)) > 0) { |