* sunrpc/svc_tcp.c (svctcp_create): Call listen with SOMAXCONN
[glibc.git] / stdio-common / tst-fmemopen2.c
blob6a0ee836a2751382e9fdf33dd23a4cf54856b7d2
1 #include <assert.h>
2 #include <stdio.h>
3 #include <sys/types.h>
6 static int
7 do_test (void)
9 int result = 0;
10 char buf[100];
11 FILE *fp = fmemopen (buf, sizeof (buf), "w");
12 if (fp == NULL)
14 puts ("fmemopen failed");
15 return 0;
17 static const char str[] = "hello world";
18 #define nstr (sizeof (str) - 1)
19 fputs (str, fp);
20 off_t o = ftello (fp);
21 if (o != nstr)
23 printf ("first ftello returned %ld, expected %zu\n", o, nstr);
24 result = 1;
26 rewind (fp);
27 o = ftello (fp);
28 if (o != 0)
30 printf ("second ftello returned %ld, expected %zu\n", o, 0);
31 result = 1;
33 if (fseeko (fp, 0, SEEK_END) != 0)
35 puts ("fseeko failed");
36 return 1;
38 o = ftello (fp);
39 if (o != nstr)
41 printf ("third ftello returned %ld, expected %zu\n", o, nstr);
42 result = 1;
44 rewind (fp);
45 static const char str2[] = "just hello";
46 #define nstr2 (sizeof (str2) - 1)
47 assert (nstr2 < nstr);
48 fputs (str2, fp);
49 o = ftello (fp);
50 if (o != nstr2)
52 printf ("fourth ftello returned %ld, expected %zu\n", o, nstr2);
53 result = 1;
55 fclose (fp);
56 static const char str3[] = "just hellod";
57 if (strcmp (buf, str3) != 0)
59 printf ("final string is \"%s\", expected \"%s\"\n",
60 buf, str3);
61 result = 1;
63 return result;
66 #define TEST_FUNCTION do_test ()
67 #include "../test-skeleton.c"