Print this page
XXXX update sendmail to 8.14.9
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/cmd/sendmail/libsm/t-smstdio.c
+++ new/usr/src/cmd/sendmail/libsm/t-smstdio.c
1 1 /*
2 - * Copyright (c) 2000-2001 Sendmail, Inc. and its suppliers.
2 + * Copyright (c) 2000-2001 Proofpoint, Inc. and its suppliers.
3 3 * All rights reserved.
4 4 *
5 5 * By using this file, you agree to the terms and conditions set
6 6 * forth in the LICENSE file which can be found at the top level of
7 7 * the sendmail distribution.
8 8 */
9 9
10 -#pragma ident "%Z%%M% %I% %E% SMI"
11 -
12 10 #include <sm/gen.h>
13 -SM_IDSTR(id, "@(#)$Id: t-smstdio.c,v 1.9 2001/03/21 18:30:41 ca Exp $")
11 +SM_IDSTR(id, "@(#)$Id: t-smstdio.c,v 1.12 2013-11-22 20:51:43 ca Exp $")
14 12
15 13 #include <sm/io.h>
16 14 #include <sm/string.h>
17 15 #include <sm/test.h>
18 16
19 17 int
20 18 main(argc, argv)
21 19 int argc;
22 20 char **argv;
23 21 {
24 22 FILE *stream;
25 23 SM_FILE_T *fp;
26 24 char buf[128];
27 25 size_t n;
28 26 static char testmsg[] = "hello, world\n";
29 27
30 28 sm_test_begin(argc, argv,
31 29 "test sm_io_stdioopen, smiostdin, smiostdout");
32 30
33 31 stream = fopen("t-smstdio.1", "w");
34 32 SM_TEST(stream != NULL);
35 33
36 34 fp = sm_io_stdioopen(stream, "w");
37 35 SM_TEST(fp != NULL);
38 36
39 37 (void) sm_io_fprintf(fp, SM_TIME_DEFAULT, "%s", testmsg);
40 38 sm_io_close(fp, SM_TIME_DEFAULT);
41 39
42 40 #if 0
43 41 /*
44 42 ** stream should now be closed. This is a tricky way to test
45 43 ** if it is still open. Alas, it core dumps on Linux.
46 44 */
47 45
48 46 fprintf(stream, "oops! stream is still open!\n");
49 47 fclose(stream);
50 48 #endif
51 49
52 50 stream = fopen("t-smstdio.1", "r");
53 51 SM_TEST(stream != NULL);
54 52
55 53 fp = sm_io_stdioopen(stream, "r");
56 54 SM_TEST(fp != NULL);
57 55
58 56 n = sm_io_read(fp, SM_TIME_DEFAULT, buf, sizeof(buf));
59 57 if (SM_TEST(n == strlen(testmsg)))
60 58 {
61 59 buf[n] = '\0';
62 60 SM_TEST(strcmp(buf, testmsg) == 0);
63 61 }
64 62
65 63 #if 0
66 64
67 65 /*
68 66 ** Copy smiostdin to smiostdout
69 67 ** gotta think some more about how to test smiostdin and smiostdout
70 68 */
71 69
72 70 while ((c = sm_io_getc(smiostdin)) != SM_IO_EOF)
73 71 sm_io_putc(smiostdout, c);
74 72 #endif
75 73
76 74 return sm_test_end();
77 75 }
|
↓ open down ↓ |
54 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX