2 * Copyright (c) 2013 Proofpoint, Inc. and its suppliers.
5 * By using this file, you agree to the terms and conditions set
6 * forth in the LICENSE file which can be found at the top level of
7 * the sendmail distribution.
11 SM_IDSTR(id, "@(#)$Id: t-fget.c,v 1.2 2013-11-22 20:51:43 ca Exp $")
14 #include <sm/string.h>
19 check(char *msg, int l)
25 static char fn[] = "tfget";
27 wfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, fn,
28 SM_IO_WRONLY_B, NULL);
30 for (i = 0; i < l; i++)
32 r = sm_io_putc(wfp, SM_TIME_DEFAULT, msg[i]);
35 r = sm_io_close(wfp, SM_TIME_DEFAULT);
38 rfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, fn,
39 SM_IO_RDONLY_B, NULL);
42 r = sm_io_fgets(rfp, SM_TIME_DEFAULT, buf, n);
52 fprintf(stderr, "buf='%s', in='%s', r=%d, l=%d\n",
55 SM_TEST(memcmp(buf, msg, l) == 0);
56 r = sm_io_close(rfp, SM_TIME_DEFAULT);
69 sm_test_begin(argc, argv, "test fget");
71 check("", strlen(""));
72 check("\n", strlen("\n"));
73 check("test\n", strlen("test\n"));
75 l = snprintf(res, sizeof(res), "%c%s\n", '\0', "test ing");
78 l = snprintf(res, sizeof(res), "%c%s%c\n", '\0', "test ing", '\0');
81 l = snprintf(res, sizeof(res), "%c%s%c%s\n",
82 '\0', "test ing", '\0', "eol");