48#define WX_DONTINHERIT 0x10
55#define EF_CRIT_INIT 0x04
56#define EF_UNK_UNICODE 0x08
58#define MSVCRT_FD_BLOCK_SIZE 32
71static int (
__cdecl *p__wfopen_s)(
FILE**,
const wchar_t*,
const wchar_t*);
81 if(*
ret==
'\\' || *
ret==
'/')
108 fp =
fopen(
"filbuf.tst",
"wb");
109 fwrite(
"\n\n\n\n", 1, 4, fp);
112 fp =
fopen(
"filbuf.tst",
"rt");
114 ok(
c ==
'\n',
"read wrong byte\n");
126 ok(
ftell(fp) == -2,
"ascii crlf removal does not match native\n");
128 ok(
pos == -2,
"ftell does not match fgetpos\n");
135 static const char buffer[] = {0,1,2,3,4,5,6,7,8,9};
155 static const char outbuffer[] =
"0,1,2,3,4,5,6,7,8,9";
168 for (bufmode=0; bufmode <
ARRAY_SIZE(bufmodes); bufmode++)
173 if(bufmodes[bufmode] ==
_IOFBF)
174 ok(
file->_bufsiz == 2048,
"file->_bufsiz = %d\n",
file->_bufsiz);
175 ok(
file->_base !=
NULL,
"file->_base = NULL\n");
179 ok(
feof(
file) !=0,
"feof doesn't signal EOF for bufmode=%x\n", bufmodes[bufmode]);
184 ok(
strlen(
buffer) == 1,
"fgets dropped chars for bufmode=%x\n", bufmodes[bufmode]);
192 ok((
c =
fgetc(
file)) ==
EOF,
"getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
193 ok(
feof(
file),
"feof did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
194 ok(
ungetc(
c,
file) ==
EOF,
"ungetc(EOF) did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
195 ok(
feof(
file),
"feof after ungetc(EOF) did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
196 ok(
fgetc(
file) ==
EOF,
"getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
198 ok(
ungetc(
c,
file) ==
c,
"ungetc did not return its input for bufmode=%x\n", bufmodes[bufmode]);
199 ok(!
feof(
file),
"feof after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
200 ok((
c =
fgetc(
file)) !=
EOF,
"getc after ungetc returned EOF for bufmode=%x\n", bufmodes[bufmode]);
202 "getc did not return ungetc'd data for bufmode=%x\n", bufmodes[bufmode]);
203 ok(!
feof(
file),
"feof after getc returned EOF prematurely for bufmode=%x\n", bufmodes[bufmode]);
204 ok(
fgetc(
file) ==
EOF,
"getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
205 ok(
feof(
file),
"feof after getc did not return EOF for bufmode=%x\n", bufmodes[bufmode]);
208 ok(
fgetpos(
file,&
pos) == 0,
"fgetpos failed unexpected for bufmode=%x\n", bufmodes[bufmode]);
211 ok(
fsetpos(
file, &
pos) == 0,
"fsetpos failed unexpected for bufmode=%x\n", bufmodes[bufmode]);
212 ok(
fgetpos(
file,&
pos) == 0,
"fgetpos failed unexpected for bufmode=%x\n", bufmodes[bufmode]);
221 ok(
feof(
file) !=0,
"feof doesn't signal EOF\n");
226 ok(
lstrlenW(wbuffer) == 1,
"fgets dropped chars\n");
236 ok(!
feof(
file),
"feof after clearerr failed\n");
246 ok(!
feof(
file),
"feof after rewind failed\n");
267 ok(!
feof(
file),
"feof after fsetpos failed\n");
277 ok(!
feof(
file),
"feof after fsetpos failed\n");
283#define IOMODE (ao?"ascii mode":"binary mode")
286 static const char outbuffer[] =
"0,1,2,3,4,5,6,7,8,9\r\n\r\nA,B,C,D,E\r\nX,Y,Z";
287 static const char padbuffer[] =
"ghjghjghjghj";
288 static const char nlbuffer[] =
"\r\n";
313 ok(
read(
fd,
buffer, 1) == -1,
"read succeeded on write-only file\n");
321 ok(
dup2(
fd, -1) == -1,
"dup2(fd, -1) succeeded\n");
342 ok(
l == pl,
"padding line ftell got %ld should be %d in %s\n",
l, pl,
IOMODE);
343 ok(
lstrlenA(
buffer) == pl+ao,
"padding line fgets got size %d should be %d in %s\n",
350 ok(
l == pl+fp,
"line 1 ftell got %ld should be %d in %s\n",
l, pl+fp,
IOMODE);
351 ok(
lstrlenA(
buffer) == fp+ao,
"line 1 fgets got size %d should be %d in %s\n",
357 ok(
l == pl,
"ftell after seek got %ld should be %d in %s\n",
l, pl,
IOMODE);
360 ok(
l == pl+fp,
"second read of line 1 ftell got %ld should be %d in %s\n",
l, pl+fp,
IOMODE);
361 ok(
lstrlenA(
buffer) == fp+ao,
"second read of line 1 fgets got size %d should be %d in %s\n",
366 ok(
l == pl+fp,
"line 2 ftell got %ld should be %d in %s\n",
l, pl+fp,
IOMODE);
367 ok(
lstrlenA(
buffer) == 2+ao,
"line 2 fgets got size %d should be %d in %s\n",
384 ok(
l == pl+
j-(ao*4)-5,
"ftell after fread got %ld should be %d in %s\n",
l, pl+
j-(ao*4)-5,
IOMODE);
392 if (ao && (*optr ==
'\r'))
401 ok(
i==
j,
"fread failed, expected %d got %d in %s\n",
j,
i,
IOMODE);
420 ok(
i == *
ip,
"_getw failed, expected %08x got %08x in %s\n", *
ip,
i,
IOMODE);
426 for (
i=0,
j=0;
i<6;
i++) {
432 ok(
i == *
ip,
"_getw failed, expected %08x got %08x in %s\n", *
ip,
i,
IOMODE);
439 ok(
fd != -1,
"open failed\n");
446 ok(
fd != -1,
"open failed\n");
452 ok(!
i,
"fread succeeded\n");
453 ok(
file->_bufsiz == 4096,
"file->_bufsiz = %d\n",
file->_bufsiz);
454 for(
i=0;
i<4096;
i++)
455 if(
buffer[
i] != (
i==1 ? 0x1a :
'a'))
break;
469 fp =
fopen(
"ascii.tst",
"wb");
472 fp =
fopen(
"ascii.tst",
"rt");
474 ok(0 ==
strcmp(
buf,
"\r\n"),
"CR CR LF not read as CR LF\n");
481 fp =
fopen(
"ascii.tst",
"wb");
482 fputs(
"foo\032", fp);
486 fp =
fopen(
"ascii.tst",
"rt");
488 ok(0 ==
strcmp(
buf,
"foo"),
"foo ^Z not read as foo by fgets\n");
491 ok((
fread(
buf, 1,
sizeof(
buf), fp) == 3) && (0 ==
strcmp(
buf,
"foo")),
"foo ^Z not read as foo by fread\n");
492 ok((
fread(
buf, 1,
sizeof(
buf), fp) == 0),
"fread after logical EOF\n");
496 fp=
fopen(
"ascii.tst",
"wb");
497 fputs(
"0\r\n1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n", fp);
500 fp =
fopen(
"ascii.tst",
"r");
502 ok(
c ==
'0',
"fgetc failed, expected '0', got '%c'\n",
c);
504 ok(
c ==
'\n',
"fgetc failed, expected '\\n', got '%c'\n",
c);
506 for(
i=1;
i<10;
i++) {
507 ok((
j =
ftell(fp)) ==
i*3,
"ftell fails in TEXT mode\n");
509 ok((
c =
fgetc(fp)) ==
'0'+
i,
"fgetc after fseek failed in line %d\n",
i);
511 ok(
c ==
'\n',
"fgetc failed, expected '\\n', got '%c'\n",
c);
516 ok(
c ==
'0',
"fgetc failed, expected '0', got '%c'\n",
c);
518 for(
i=1;
i<10;
i++) {
519 ok((
c =
fgetc(fp)) ==
'0'+
i,
"fgetc after fseek with pos Offset failed in line %d\n",
i);
524 ok(
c ==
'9',
"fgetc failed, expected '9', got '%c'\n",
c);
526 for(
i= 8;
i>=0;
i--) {
527 ok((
c =
fgetc(fp)) ==
'0'+
i,
"fgetc after fseek with neg Offset failed in line %d\n",
i);
532 fp =
fopen(
"ascii.tst",
"r");
534 ok((
c =
fgetc(fp)) ==
'1',
"fgetc fails to read next char when positioned on \\r\n");
553 static const char obuf[] =
555"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
556"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
557"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
558"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
559"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
560"000000000000000000000000000000000000000000000000000000000000000000000000000000\n"
561"000000000000000000\n"
562"1111111111111111111";
564 fp =
fopen(
"ascii2.tst",
"wt");
568 fp =
fopen(
"ascii2.tst",
"rt");
569 ok(
getc(fp) ==
'0',
"first char not 0\n");
570 memset(ibuf, 0,
sizeof(ibuf));
571 i =
fread(ibuf, 1,
sizeof(ibuf), fp);
572 ok(
i ==
sizeof(ibuf),
"fread i %d != sizeof(ibuf)\n",
i);
573 ok(0 ==
strncmp(ibuf,
obuf+1,
sizeof(ibuf)),
"ibuf != obuf\n");
580 char DATA [] = {26,
't',
'e',
's' ,
't'};
593 f =
fopen(tempfile,
"w+bDT");
596 bytesRead =
fread(DATA2, 1,
sizeof(DATA2),
f);
600 "fopen file mode 'T' wrongly interpreted as 't'\n" );
622 char buf[513], rbuf[513];
624 for (
i = 0;
i < 511;
i++)
626 j = (
i%(
'~' -
' ')+
' ');
631 fp =
fopen(
"boundary.tst",
"wt");
634 fp =
fopen(
"boundary.tst",
"rt");
644 ok(
strcmp(
buf, rbuf) == 0,
"CRLF on buffer boundary failure\n");
654 tempfh =
fopen(tempf,
"w+");
659 ok(ich ==
ret,
"First fgetc expected %x got %x\n", ich,
ret);
661 ok(ich ==
ret,
"Second fgetc expected %x got %x\n", ich,
ret);
663 tempfh =
fopen(tempf,
"wt");
666 tempfh =
fopen(tempf,
"wt");
669 ok(
ret == -1,
"Unbuffered fgetc in text mode must failed on \\r\\n\n");
682 tempfh =
fopen(tempf,
"wb");
684 ok(0 ==
ret,
"fputc(0,tempfh) expected %x got %x\n", 0,
ret);
686 ok(0xff ==
ret,
"fputc(0xff,tempfh) expected %x got %x\n", 0xff,
ret);
688 ok(0xff ==
ret,
"fputc(0xffffffff,tempfh) expected %x got %x\n", 0xff,
ret);
691 tempfh =
fopen(tempf,
"rb");
693 ok(
EOF ==
ret,
"fputc(0,tempfh) on r/o file expected %x got %x\n",
EOF,
ret);
710 for (bufmode=0; bufmode <
ARRAY_SIZE(bufmodes); bufmode++)
712 tempfh =
fopen(tempf,
"wb");
715 ok(0 ==
ret,
"_flsbuf(0,tempfh) with bufmode %x expected %x got %x\n",
716 bufmodes[bufmode], 0,
ret);
718 ok(0xff ==
ret,
"_flsbuf(0xff,tempfh) with bufmode %x expected %x got %x\n",
719 bufmodes[bufmode], 0xff,
ret);
721 ok(0xff ==
ret,
"_flsbuf(0xffffffff,tempfh) with bufmode %x expected %x got %x\n",
722 bufmodes[bufmode], 0xff,
ret);
726 tempfh->
_base[1] =
'a';
728 ok(
ret == 0xab,
"_flsbuf(0xab,tempfh) with bufmode %x expected 0xab got %x\n",
729 bufmodes[bufmode],
ret);
730 ok(tempfh->
_base[1] ==
'a',
"tempfh->_base[1] should not be changed (%d)\n",
737 tempfh =
fopen(tempf,
"rb");
739 ok(
EOF ==
ret,
"_flsbuf(0,tempfh) on r/o file expected %x got %x\n",
EOF,
ret);
743 tempfh =
fopen(tempf,
"w");
744 ok(tempfh->
_cnt == 0,
"_cnt on freshly opened file was %d\n", tempfh->
_cnt);
746 ok(tempfh->
_cnt == 0,
"_cnt on unbuffered file was %d\n", tempfh->
_cnt);
751 ok(
'Q' ==
ret,
"_flsbuf('Q',tempfh) expected %x got %x\n",
'Q',
ret);
753 ok(tempfh->
_cnt == 0,
"after unbuf _flsbuf, _cnt was %d\n", tempfh->
_cnt);
756 tempfh =
fopen(tempf,
"r");
758 ok(
c ==
'Q',
"first byte should be 'Q'\n");
760 ok(
c ==
EOF,
"there should only be one byte\n");
769 static const char obuf[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
770 char buf1[16], buf2[24];
778 tempfh =
fopen(tempf,
"wb");
779 ok(tempfh !=
NULL,
"Can't open test file.\n");
784 tempfh =
fopen(tempf,
"rb");
785 ok(tempfh !=
NULL,
"Can't open test file.\n");
786 fread(buf1, 1,
sizeof(buf1), tempfh);
792 ok(
ret == 0,
"expected 0, got %d\n",
ret);
793 memset(buf2,
'?',
sizeof(buf2));
794 fread(buf2, 1,
sizeof(buf2), tempfh);
795 ok(
memcmp(buf1, buf2,
sizeof(buf1)) == 0,
"Got unexpected data (%c)\n", buf2[0]);
800 ok(
ret == 0,
"expected 0, got %d\n",
ret);
801 memset(buf2,
'?',
sizeof(buf2));
802 fread(buf2, 1,
sizeof(buf2), tempfh);
803 ok(
memcmp(buf1, buf2,
sizeof(buf1)) != 0,
"Got unexpected data (%c)\n", buf2[0]);
808 ok(
ret >= 0,
"unexpected ret %d\n",
ret);
809 memset(buf2,
'?',
sizeof(buf2));
810 fread(buf2, 1,
sizeof(buf2), tempfh);
811 ok(
memcmp(buf1, buf2,
sizeof(buf1)) == 0,
"Got unexpected data (%c)\n", buf2[0]);
817 tempfh =
fopen(tempf,
"wb");
818 ok(tempfh !=
NULL,
"Can't open test file.\n");
823 ok(tempfh->
_ptr - tempfh->
_base,
"buffer is empty\n");
826 ok(!(tempfh->
_ptr - tempfh->
_base),
"buffer should be empty\n");
827 ok(!tempfh->
_cnt,
"tempfh->_cnt = %d\n", tempfh->
_cnt);
841 static const char mytext[]=
"This is test_fgetwc\r\n";
850 tempfh =
fopen(tempf,
"wb");
859 fputs(mytext,tempfh);
863 tempfh =
fopen(tempf,
"rt");
870 mytextW =
AtoW (mytext);
873 for (
i=0;
i<
strlen(mytext)-2;
i++, aptr++, wptr++)
875 diff_found |= (*aptr != *wptr);
877 ok(!(diff_found),
"fgetwc difference found in TEXT mode\n");
878 ok(*wptr ==
'\n',
"Carriage return was not skipped\n");
882 tempfh =
fopen(tempf,
"wb");
897 tempfh =
fopen(tempf,
"rb");
902 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
904 ok(
i==
'a',
"fgetc expected %d got %d\n", 0x61,
i);
907 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
909 ok(wtextW[0]==
'\r',
"expected carriage return got %04hx\n", wtextW[0]);
910 ok(wtextW[1]==
'\n',
"expected newline got %04hx\n", wtextW[1]);
913 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
920 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
924 for (
i=0;
i<
strlen(mytext)-2;
i++, aptr++, wptr++)
926 ok(*aptr == *wptr,
"Char %d expected %04hx got %04hx\n",
i, *aptr, *wptr);
927 diff_found |= (*aptr != *wptr);
929 ok(!(diff_found),
"fgetwc difference found in BINARY mode\n");
930 ok(*wptr ==
'\n',
"Should get newline\n");
939 for (
i=0;
i<
strlen(mytext)-2;
i++, aptr++, wptr++)
941 ok(*aptr == *wptr,
"Char %d expected %04hx got %04hx\n",
i, *aptr, *wptr);
942 diff_found |= (*aptr != *wptr);
944 ok(!(diff_found),
"fgetwc difference found in BINARY mode\n");
945 ok(*wptr ==
'\n',
"Should get newline\n");
957 static const WCHAR wchar_text[] = { 0xfeff, 0xff1f,
'!' };
971 tempfh =
fopen(tempfile,
"wb");
972 ok(tempfh !=
NULL,
"can't open tempfile\n");
981 ok(
ret > 0,
"MultiByteToWideChar failed\n");
987 for (
p =
text; *
p !=
'\0';
p++)
988 wtextW[
ret++] = (
unsigned char)*
p;
992 tempfh =
fopen(tempfile,
"rt");
993 ok(tempfh !=
NULL,
"can't open tempfile\n");
995 for (
i = 0;
i <
ret-1;
i++)
998 ok(ch == wtextW[
i],
"got %04hx, expected %04hx (cp%d[%d])\n", ch, wtextW[
i],
codepage,
i);
1001 ok(ch ==
WEOF,
"got %04hx, expected WEOF (cp%d)\n", ch,
codepage);
1004 tempfh =
fopen(tempfile,
"wb");
1005 ok(tempfh !=
NULL,
"can't open tempfile\n");
1006 fwrite(wchar_text, 1,
sizeof(wchar_text), tempfh);
1009 tempfh =
fopen(tempfile,
"rb");
1010 ok(tempfh !=
NULL,
"can't open tempfile\n");
1014 ok(ch == wchar_text[
i],
"got %04hx, expected %04x (cp%d[%d])\n", ch, wchar_text[
i],
codepage,
i);
1017 ok(ch ==
WEOF,
"got %04hx, expected WEOF (cp%d)\n", ch,
codepage);
1026 static const WCHAR wchar_text[] = { 0xfeff, 0xff1f,
'!' };
1036 win_skip(
"fopen_s not available\n");
1040 tempfh =
fopen(tempfile,
"wb");
1041 ok(tempfh !=
NULL,
"can't open tempfile\n");
1042 fwrite(wchar_text, 1,
sizeof(wchar_text), tempfh);
1045 tempfh =
fopen(tempfile,
"rt,ccs=unicode");
1046 ok(tempfh !=
NULL,
"can't open tempfile\n");
1050 ok(ch == wchar_text[
i],
1051 "got %04hx, expected %04x (unicode[%d])\n", ch, wchar_text[
i],
i-1);
1054 ok(ch ==
WEOF,
"got %04hx, expected WEOF (unicode)\n", ch);
1057 tempfh =
fopen(tempfile,
"r,ccs=utf-8");
1058 ok(tempfh !=
NULL,
"can't open tempfile\n");
1062 ok(ch == wchar_text[
i],
1063 "got %04hx, expected %04x (unicode[%d])\n", ch, wchar_text[
i],
i-1);
1066 ok(ch ==
WEOF,
"got %04hx, expected WEOF (unicode)\n", ch);
1069 tempfh =
fopen(tempfile,
"a,ccs=utf-16le");
1070 ok(tempfh !=
NULL,
"can't open tempfile\n");
1071 ch =
fputwc(
'a', tempfh);
1072 ok(ch ==
'a',
"fputwc returned %x\n", ch);
1075 tempfh =
fopen(tempfile,
"a+,ccs=utf-8");
1076 ok(tempfh !=
NULL,
"can't open tempfile\n");
1080 ok(ch == wchar_text[
i],
1081 "got %04hx, expected %04x (unicode[%d])\n", ch, wchar_text[
i],
i-1);
1084 ok(ch ==
'a',
"got %04x, expected 'a'\n", ch);
1086 ok(ch ==
WEOF,
"got %04hx, expected WEOF (unicode)\n", ch);
1089 tempfh =
fopen(tempfile,
"wb");
1090 ok(tempfh !=
NULL,
"can't open tempfile\n");
1092 utf8_text,
sizeof(utf8_text),
NULL,
NULL);
1093 ok(
ret > 0,
"utf-8 conversion failed\n");
1094 fwrite(utf8_text,
sizeof(
char),
ret, tempfh);
1097 tempfh =
fopen(tempfile,
"rt, ccs=UTF-8");
1098 ok(tempfh !=
NULL,
"can't open tempfile\n");
1102 ok(ch == wchar_text[
i],
1103 "got %04hx, expected %04x (utf8[%d])\n", ch, wchar_text[
i],
i-1);
1106 ok(ch ==
WEOF,
"got %04hx, expected WEOF (utf8)\n", ch);
1109 tempfh =
fopen(tempfile,
"wb");
1110 ok(tempfh !=
NULL,
"can't open tempfile\n");
1111 fwrite(wchar_text+1, 1,
sizeof(wchar_text)-1, tempfh);
1114 tempfh =
fopen(tempfile,
"rt,ccs=utf-16le");
1115 ok(tempfh !=
NULL,
"can't open tempfile\n");
1119 ok(ch == wchar_text[
i],
1120 "got %04hx, expected %04x (unicode[%d])\n", ch, wchar_text[
i],
i-1);
1123 ok(ch ==
WEOF,
"got %04hx, expected WEOF (unicode)\n", ch);
1126 tempfh =
fopen(tempfile,
"wb");
1127 ok(tempfh !=
NULL,
"can't open tempfile\n");
1129 utf8_text,
sizeof(utf8_text),
NULL,
NULL);
1130 ok(
ret > 0,
"utf-8 conversion failed\n");
1132 fwrite(utf8_text,
sizeof(
char),
ret, tempfh);
1135 tempfh =
fopen(tempfile,
"rt, ccs=UTF-8");
1136 ok(tempfh !=
NULL,
"can't open tempfile\n");
1140 ok(ch == wchar_text[
i],
1141 "got %04hx, expected %04x (utf8[%d])\n", ch, wchar_text[
i],
i-1);
1144 ok(ch ==
WEOF,
"got %04hx, expected WEOF (utf8)\n", ch);
1147 tempfh =
fopen(tempfile,
"rt, ccs=unicode");
1148 ok(tempfh !=
NULL,
"can't open tempfile\n");
1149 for (
i = 0; utf8_text[
i];
i++)
1152 ok(ch == (
unsigned char) utf8_text[
i],
1153 "got %04hx, expected %04x (unicode[%d])\n", ch, (
unsigned char)utf8_text[
i],
i);
1156 ok(ch ==
WEOF,
"got %04hx, expected WEOF (unicode)\n", ch);
1173 f =
fopen(tempfile,
"w");
1175 ok(
ret ==
'a',
"fputwc returned %x, expected 'a'\n",
ret);
1177 ok(
ret ==
'\n',
"fputwc returned %x, expected '\\n'\n",
ret);
1180 f =
fopen(tempfile,
"rb");
1182 ok(
ret == 3,
"fread returned %d, expected 3\n",
ret);
1183 ok(!
memcmp(
buf,
"a\r\n", 3),
"incorrect file data\n");
1187 f =
fopen(tempfile,
"w,ccs=unicode");
1189 ok(
ret ==
'a',
"fputwc returned %x, expected 'a'\n",
ret);
1191 ok(
ret ==
'\n',
"fputwc returned %x, expected '\\n'\n",
ret);
1194 f =
fopen(tempfile,
"rb");
1196 ok(
ret == 8,
"fread returned %d, expected 8\n",
ret);
1197 ok(!
memcmp(
buf,
"\xff\xfe\x61\x00\r\x00\n\x00", 8),
"incorrect file data\n");
1200 f =
fopen(tempfile,
"w,ccs=utf-8");
1202 ok(
ret ==
'a',
"fputwc returned %x, expected 'a'\n",
ret);
1204 ok(
ret ==
'\n',
"fputwc returned %x, expected '\\n'\n",
ret);
1207 f =
fopen(tempfile,
"rb");
1209 ok(
ret == 6,
"fread returned %d, expected 6\n",
ret);
1210 ok(!
memcmp(
buf,
"\xef\xbb\xbf\x61\r\n", 6),
"incorrect file data\n");
1213 win_skip(
"fputwc tests on unicode files\n");
1221 char filename1[8] =
"AXXXXXX";
1234 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1238 ok(
ret == 0,
"fclose() returned %d\n",
ret);
1241 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1245 ok(
ret == 0,
"fclose() returned %d\n",
ret);
1248 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1250 ok(
file !=
NULL,
"fopen(filename2) returned NULL\n");
1253 ok(
ret == 1,
"fread() returned %d\n",
ret);
1254 ok(ch ==
'2',
"fread() read %c\n", ch);
1256 ok(
ret == 0,
"fclose() returned %d\n",
ret);
1259 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1261 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1263 ok(
pos == 0,
"ftell() returned %ld\n",
pos);
1266 ok(
ret == 1,
"fread() returned %d\n",
ret);
1267 ok(ch ==
'1',
"fread() read %c\n", ch);
1269 ok(
ret == 0,
"fclose() returned %d\n",
ret);
1272 ok(
file !=
NULL,
"fopen(filename1) returned NULL\n");
1274 ok(
fd > 0,
"fileno() returned %d\n",
fd);
1277 ok(
new ==
NULL,
"fopen(_:) returned non NULL\n");
1281 ok(
ret == -1,
"read() returned %d\n",
ret);
1285 ok(
ret ==
EOF,
"fclose(file) succeeded\n");
1289 ok(
file !=
NULL,
"couldn't open %s\n", filename1);
1294 ok(
new ==
file,
"freopen() didn't return same FILE*\n");
1297 ok(
fd > 0,
"fileno() returned %d\n",
fd);
1301 ok(
ret == 1,
"fread() returned %d\n",
ret);
1302 ok(ch ==
'2',
"Unexpected char\n");
1305 ok(
ret == 0,
"fclose(file) returned %d\n",
ret);
1315 static const char mytext[]=
"This is test_ctrlz";
1321 tempfh =
fopen(tempf,
"wb");
1322 fputs(mytext,tempfh);
1332 tempfh =
fopen(tempf,
"rt");
1333 ok(
fgets(
buffer,256,tempfh) != 0,
"fgets failed unexpected\n");
1336 ok(
i==
j,
"returned string length expected %d got %d\n",
j,
i);
1339 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
1340 ok(
feof(tempfh),
"did not get EOF\n");
1343 tempfh =
fopen(tempf,
"rb");
1344 ok(
fgets(
buffer,256,tempfh) != 0,
"fgets failed unexpected\n");
1347 ok(
i==
j,
"returned string length expected %d got %d\n",
j,
i);
1349 ok(
l==
j,
"ftell expected %d got %ld\n",
j,
l);
1350 ok(
fgets(
buffer,256,tempfh) != 0,
"fgets failed unexpected\n");
1352 ok(
i==1,
"returned string length expected %d got %d\n", 1,
i);
1353 ok(
feof(tempfh),
"did not get EOF\n");
1363 static const char mytext[]=
"This is a test_file_put_get\n";
1364 static const char dostext[]=
"This is a test_file_put_get\r\n";
1372 tempfh =
fopen(tempf,
"wt");
1373 fputs(mytext,tempfh);
1375 tempfh =
fopen(tempf,
"rb");
1377 ok(
strlen(mytext) + 1 ==
strlen(btext),
"TEXT/BINARY mode not handled for write\n");
1378 ok( btext[
strlen(mytext)-1] ==
'\r',
"CR not written\n");
1380 tempfh =
fopen(tempf,
"wb");
1381 fputs(dostext,tempfh);
1383 tempfh =
fopen(tempf,
"rt");
1385 ok(
strcmp(btext, mytext) == 0,
"_O_TEXT read doesn't strip CR\n");
1387 tempfh =
fopen(tempf,
"rb");
1389 ok(
strcmp(btext, dostext) == 0,
"_O_BINARY read doesn't preserve CR\n");
1392 tempfh =
fopen(tempf,
"rt");
1394 mytextW =
AtoW (mytext);
1398 for (
i=0;
i<
strlen(mytext);
i++, aptr++, wptr++)
1400 diff_found |= (*aptr != *wptr);
1402 ok(!(diff_found),
"fgetwc doesn't strip CR in TEXT mode\n");
1413 static const char mytext[]=
"This is test_file_write_read\nsecond line\n";
1414 static const char dostext[]=
"This is test_file_write_read\r\nsecond line\r\n";
1422 "Can't open '%s': %d\n", tempf,
errno);
1424 "_write _O_BINARY bad return value\n");
1429 "_read _O_BINARY got bad length\n");
1431 "problems with _O_BINARY _write / _read\n");
1435 "_read _O_TEXT got bad length\n");
1437 "problems with _O_BINARY _write / _O_TEXT _read\n");
1442 "Can't open '%s': %d\n", tempf,
errno);
1444 "_write _O_TEXT bad return value\n");
1448 "_read _O_BINARY got bad length\n");
1450 "problems with _O_TEXT _write / _O_BINARY _read\n");
1451 ok( btext[
strlen(dostext)-2] ==
'\r',
"CR not written or read\n");
1455 "_read _O_TEXT got bad length\n");
1457 "problems with _O_TEXT _write / _read\n");
1462 ok(
tell(tempfd) == 0,
"bad position %lu expecting 0\n",
tell(tempfd));
1464 ok(
memcmp(mytext,btext,
strlen(mytext)) == 0,
"problems with _O_APPEND _read\n");
1471 ok(
ret == 1 && *btext ==
'\n',
"_read expected 1 got bad length: %d\n",
ret);
1474 ok(
ret == 1 && *btext ==
'\n',
"_read expected '\\n' got bad length: %d\n",
ret);
1477 ok(
ret == 1 && *btext ==
'\n',
"_read returned %d, buf: %d\n",
ret, *btext);
1479 ok(
ret == 0,
"_read returned %d, expected 0\n",
ret);
1482 ok(
ret == 1 && *btext ==
'e',
"_read expected 'e' got \"%.*s\" bad length: %d\n",
ret, btext,
ret);
1483 ok(
tell(tempfd) == 41,
"bad position %lu expecting 41\n",
tell(tempfd));
1486 ok(
ret == 1 && *btext ==
'e',
"_read expected 'e' got \"%.*s\" bad length: %d\n",
ret, btext,
ret);
1487 ok(
tell(tempfd) == 42,
"bad position %lu expecting 42\n",
tell(tempfd));
1490 ok(
ret == 2 && *btext ==
'e',
"_read expected 'e' got \"%.*s\" bad length: %d\n",
ret, btext,
ret);
1491 ok(
tell(tempfd) == 43,
"bad position %lu expecting 43\n",
tell(tempfd));
1495 ok(
ret == 0 ,
"Can't unlink '%s': %d\n", tempf,
errno);
1501 "Can't open '%s': %d\n", tempf,
errno);
1503 "_write _O_BINARY bad return value\n");
1507 "_read _O_BINARY got bad length\n");
1509 "problems with _O_BINARY _write / _read\n");
1510 ok( btext[
strlen(dostext)-2] ==
'\r',
"CR not written or read\n");
1514 "_read _O_TEXT got bad length\n");
1516 "problems with _O_BINARY _write / _O_TEXT _read\n");
1523 _read(tempfd,btext, 1);
1524 ok(btext[0] == mytext[
i],
"_read failed at pos %d 0x%02x vs 0x%02x\n",
i, btext[0], mytext[
i]);
1526 while (
_read(tempfd,btext, 1));
1532 ok(
i ==
strlen(mytext)-1,
"_read_i %d\n",
i);
1539 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1541 ok(
ret == -1,
"_write returned %d, expected -1\n",
ret);
1542 ret =
_write(tempfd,
"a\x00\n\x00\xff\xff", 6);
1543 ok(
ret == 6,
"_write returned %d, expected 6\n",
ret);
1547 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1548 ret =
_read(tempfd, btext,
sizeof(btext));
1549 ok(
ret == 10,
"_read returned %d, expected 10\n",
ret);
1550 ok(!
memcmp(btext,
"\xff\xfe\x61\x00\r\x00\n\x00\xff\xff", 10),
"btext is incorrect\n");
1554 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1557 ok(
ret == -1,
"_read returned %d, expected -1\n",
ret);
1559 ret =
_read(tempfd, btext,
sizeof(btext));
1560 ok(
ret == 6,
"_read returned %d, expected 6\n",
ret);
1561 ok(!
memcmp(btext,
"\x61\x00\n\x00\xff\xff", 6),
"btext is incorrect\n");
1565 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1568 ok(
ret == -1,
"_write returned %d, expected -1\n",
ret);
1570 ret =
_write(tempfd,
"a\x00\n\x00\x62\x00", 6);
1571 ok(
ret == 6,
"_write returned %d, expected 6\n",
ret);
1575 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1576 ret =
_read(tempfd, btext,
sizeof(btext));
1577 ok(
ret == 7,
"_read returned %d, expected 7\n",
ret);
1578 ok(!
memcmp(btext,
"\xef\xbb\xbf\x61\r\n\x62", 7),
"btext is incorrect\n");
1582 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1583 ret =
_read(tempfd, btext,
sizeof(btext));
1584 ok(
ret == 6,
"_read returned %d, expected 6\n",
ret);
1585 ok(!
memcmp(btext,
"\x61\x00\n\x00\x62\x00", 6),
"btext is incorrect\n");
1594 ok(
ret == 2,
"_read returned %d, expected 2\n",
ret);
1595 ok(!
memcmp(btext,
"\x62\x00", 2),
"btext is incorrect\n");
1599 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1600 ret =
_write(tempfd,
"\xef\xbb\xbf\x61\xc4\x85\x62\xc5\xbc\r\r\n", 12);
1601 ok(
ret == 12,
"_write returned %d, expected 9\n",
ret);
1605 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
1606 ret =
_read(tempfd, btext,
sizeof(btext));
1607 ok(
ret == 12,
"_read returned %d, expected 12\n",
ret);
1608 ok(!
memcmp(btext,
"\x61\x00\x05\x01\x62\x00\x7c\x01\x0d\x00\x0a\x00", 12),
"btext is incorrect\n");
1612 ret =
_read(tempfd, btext,
sizeof(btext));
1613 ok(
ret == 10,
"_read returned %d, expected 10\n",
ret);
1615 ok(!
memcmp(btext,
"\xfd\xff", 2),
"invalid UTF8 character was not replaced by U+FFFD\n");
1616 ok(!
memcmp(btext+
ret-8,
"\x62\x00\x7c\x01\x0d\x00\x0a\x00", 8),
"btext is incorrect\n");
1621 win_skip(
"unicode mode tests on file\n");
1626 "Can't chmod '%s' to read-write: %d\n", tempf,
errno);
1628 ok(
ret == 0 ,
"Can't unlink '%s': %d\n", tempf,
errno);
1647 sscanf(handle_str,
"%p", &handle_value);
1649 ok(handle_value == handle_ptr[1],
"Got unexpected handle %p.\n", handle_ptr[1]);
1656 ok(
memcmp(
buffer,
"Success", 8) == 0,
"Couldn't read back the data\n");
1666 "Wrong write result in child process on %d (%s)\n",
fd,
strerror(
errno));
1684 wxflag_ptr[
i] = 0x81;
1708 sa.nLength =
sizeof(
sa);
1709 sa.lpSecurityDescriptor =
NULL;
1710 sa.bInheritHandle =
TRUE;
1716 startup->hStdOutput = hErrorFile;
1725 ok(
strcmp(
data,
"Success" ),
"%s: Error file shouldn't contain data\n",
descr );
1735 ok(
strcmp(
data,
"Success" ),
"%s: Stdout file shouldn't contain data\n",
descr );
1746 int *pipefds = argument;
1757 const char* arg_v[5];
1768 ok(
fd != -1,
"Couldn't create test file\n");
1771 arg_v[2] =
"inherit";
1775 ok(
ret == 0,
"_spawnvp returned %Id, errno %d\n",
ret,
errno);
1780 ok(
unlink(
"fdopen.tst") == 0,
"Couldn't unlink\n");
1783 ok(
fd != -1,
"Couldn't create test file\n");
1785 arg_v[2] =
"inherit_no";
1789 ok(
ret == 0,
"_spawnvp returned %Id, errno %d\n",
ret,
errno);
1793 ok(
unlink(
"fdopen.tst") == 0,
"Couldn't unlink\n");
1800 ok(
fd != -1,
"Couldn't create test file\n");
1801 arg_v[1] =
"tests/file.c";
1802 arg_v[2] =
"inherit";
1808 skip(
"Skipping test_file_inherit pipe test, because it hangs on ReactOS\n");
1814 ok(
ret == 0,
"_spawnvp returned %Id, errno %d\n",
ret,
errno);
1816 ok(
ret == 8,
"bad position %Iu expecting 8\n",
ret);
1820 ok(
unlink(
"fdopen.tst") == 0,
"Couldn't unlink\n");
1821 _write(pipefds[1],
"a", 1);
1830 sa.nLength =
sizeof(
sa);
1831 sa.lpSecurityDescriptor =
NULL;
1832 sa.bInheritHandle =
TRUE;
1855 *(
unsigned int *)
startup.lpReserved2 = 0;
1898 handles[1] = (
void *)0xdeadbeef;
1920 ok(
info->wxflag == 0xc1,
"info->wxflag = %x\n",
info->wxflag);
1922 ok(
stdin->_file == -2,
"stdin->_file = %d\n",
stdin->_file);
1926 ok(!
ret,
"fread(stdin) returned %d\n",
ret);
1931 ok(
ret == -1,
"read(-2) returned %d\n",
ret);
1936 ok(
ret == -1,
"read(STDIN_FILENO) returned %d\n",
ret);
1941 ok(
ret ==
EOF,
"_flsbuf(stdin) returned %d\n",
ret);
1946 ok(!
ret,
"fwrite(stdin) returned %d\n",
ret);
1951 ok(
ret == -1,
"write(-2) returned %d\n",
ret);
1956 ok(
ret == -1,
"write(STDIN_FILENO) returned %d\n",
ret);
1961 ok(
ret == -1,
"fclose(stdin) returned %d\n",
ret);
1966 ok(
ret == -1,
"close(-2) returned %d\n",
ret);
1971 ok(
ret==-1 || !
ret,
"close(STDIN_FILENO) returned %d\n",
ret);
1986 win_skip(
"skipping invalid stdin tests\n");
1991 ok(!
ret,
"RegOpenCurrentUser failed: %lx\n",
ret);
1997 sa.nLength =
sizeof(
sa);
1998 sa.lpSecurityDescriptor =
NULL;
1999 sa.bInheritHandle =
TRUE;
2014 ok(!
ret,
"RegCloseKey failed: %lx\n",
ret);
2023 ok(
res !=
NULL,
"tmpnam returned NULL\n");
2024 ok(
res[0] ==
'\\',
"first character is not a backslash\n");
2025 ok(
strchr(
res+1,
'\\') == 0,
"file not in the root directory\n");
2026 ok(
res[
strlen(
res)-1] ==
'.',
"first call - last character is not a dot\n");
2029 ok(
res !=
NULL,
"tmpnam returned NULL\n");
2030 ok(
res ==
name,
"supplied buffer was not used\n");
2031 ok(
res[0] ==
'\\',
"first character is not a backslash\n");
2032 ok(
strchr(
res+1,
'\\') == 0,
"file not in the root directory\n");
2033 ok(
res[
strlen(
res)-1] !=
'.',
"second call - last character is a dot\n");
2040 char temptext[] =
"012345678";
2041 char *tempfile =
_tempnam(
".",
"tst" );
2043 ok( tempfile !=
NULL,
"Couldn't create test file\n" );
2046 ok(
fd > 0,
"Couldn't open test file\n" );
2049 ok(
count > 0,
"Couldn't write to test file\n" );
2055 ok(
_chsize(
fd,
sizeof(temptext) / 2 ) == 0,
"_chsize() failed\n" );
2058 ok(
cur ==
pos,
"File pointer changed from: %ld to: %ld\n",
cur,
pos );
2062 ok(
_chsize(
fd,
sizeof(temptext) * 2 ) == 0,
"_chsize() failed\n" );
2065 ok(
cur ==
pos,
"File pointer changed from: %ld to: %ld\n",
cur,
pos );
2075 char fname1[] =
"empty1";
2076 char fname2[] =
"empty2";
2077 char fname3[] =
"empty3";
2078 FILE *stream1, *stream2, *stream3, *stream4;
2082 stream1 =
fopen(fname1,
"w+");
2083 ok(stream1 !=
NULL,
"The file '%s' was not opened\n", fname1);
2084 stream2 =
fopen(fname2,
"w ");
2085 ok(stream2 !=
NULL,
"The file '%s' was not opened\n", fname2 );
2087 stream3 =
fopen(fname3,
"r");
2088 ok(stream3 ==
NULL,
"The file '%s' shouldn't exist before\n", fname3 );
2089 stream3 =
fopen(fname3,
"w+");
2090 ok(stream3 !=
NULL,
"The file '%s' should be opened now\n", fname3 );
2092 stream4 =
fopen(
"",
"w+");
2094 "filename is empty, errno = %d (expected 2 or 22)\n",
errno);
2098 "filename is NULL, errno = %d (expected 2 or 22)\n",
errno);
2102 ok(
ret == 0,
"The file '%s' was not closed\n", fname2);
2104 ok(
ret == 0,
"The file '%s' was not closed\n", fname3);
2107 ok(
ret ==
EOF,
"Closing file '%s' returned %d\n", fname2,
ret);
2110 ok(
ret ==
EOF,
"Closing file '%s' returned %d\n", fname3,
ret);
2114 ok(
ret ==
EOF,
"Closing NULL file returned %d\n",
ret);
2121 ok(numclosed == 1,
"Number of files closed by fcloseall(): %u\n", numclosed);
2123 ok(numclosed == 0,
"Number of files closed by fcloseall(): %u\n", numclosed);
2125 ok(
_unlink(fname1) == 0,
"Couldn't unlink file named '%s'\n", fname1);
2126 ok(
_unlink(fname2) == 0,
"Couldn't unlink file named '%s'\n", fname2);
2127 ok(
_unlink(fname3) == 0,
"Couldn't unlink file named '%s'\n", fname3);
2132 const char name[] =
"empty1";
2134 unsigned char *ubuff = (
unsigned char*)
buff;
2141 win_skip(
"Skipping fopen_s test\n");
2146 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2147 ok(
file != 0,
"fopen_s failed to return value\n");
2151 ok(
ret !=
EOF,
"File failed to close\n");
2154 ok(
file != 0,
"fopen failed\n");
2161 ok(
ret !=
EOF,
"File failed to close\n");
2164 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2166 ok(
ret == 2,
"fwrite returned %d\n",
ret);
2170 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2173 ok(ubuff[0]==0xff && ubuff[1]==0xfe,
"buff[0]=%02x, buff[1]=%02x\n",
2174 ubuff[0], ubuff[1]);
2178 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2181 ok(ubuff[0]==
'a' && ubuff[1]==0,
"buff[0]=%02x, buff[1]=%02x\n",
2182 ubuff[0], ubuff[1]);
2186 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2189 ok(ubuff[0]==
'a' && ubuff[1]==0,
"buff[0]=%02x, buff[1]=%02x\n",
2190 ubuff[0], ubuff[1]);
2194 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2197 ok(ubuff[0]==
'a' && ubuff[1]==0,
"buff[0]=%02x, buff[1]=%02x\n",
2198 ubuff[0], ubuff[1]);
2202 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2206 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2209 ok(ubuff[0]==0xff && ubuff[1]==0xfe,
"buff[0]=%02x, buff[1]=%02x\n",
2210 ubuff[0], ubuff[1]);
2214 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2218 ok(
ret == 0,
"fopen_s failed with %d\n",
ret);
2221 ok(ubuff[0]==0xef && ubuff[1]==0xbb && ubuff[2]==0xbf,
2222 "buff[0]=%02x, buff[1]=%02x, buff[2]=%02x\n",
2223 ubuff[0], ubuff[1], ubuff[2]);
2229 ret = p_fopen_s(&file2,
name,
"r");
2230 ok(!
ret,
"fopen_s failed with %d\n",
ret);
2231 ok(
file == file2,
"file != file2 %p %p\n",
file, file2);
2232 ok(!
file->_ptr,
"file->_ptr != NULL\n");
2233 ok(!
file->_cnt,
"file->_cnt != 0\n");
2234 ok(!
file->_base,
"file->_base != NULL\n");
2235 ok(
file->_flag == 1,
"file->_flag = %x\n",
file->_flag);
2236 ok(
file->_file,
"file->_file == 0\n");
2237 ok(
file->_charbuf == 0xfefefefe,
"file->_charbuf = %x\n",
file->_charbuf);
2238 ok(
file->_bufsiz == 0xfefefefe,
"file->_bufsiz = %x\n",
file->_bufsiz);
2239 ok(!
file->_tmpfname,
"file->_tmpfname != NULL\n");
2247 const char name[] =
"empty1";
2255 win_skip(
"Skipping _wfopen_s test\n");
2259 ret = p__wfopen_s(&
file,
L"empty1",
L"w");
2260 ok(
ret == 0,
"_wfopen_s failed with %d\n",
ret);
2261 ok(
file != 0,
"_wfopen_s failed to return value\n");
2265 ok(
ret !=
EOF,
"File failed to close\n");
2268 ok(
file != 0,
"fopen failed\n");
2275 ok(
ret !=
EOF,
"File failed to close\n");
2282 const char name[] =
"empty1";
2286 win_skip(
"unicode file modes are not available, skipping setmode tests\n");
2292 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2297 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2301 ok(
fd != -1,
"failed to open file\n");
2305 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2310 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2315 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2320 ok(
ret == -1,
"_setmode returned %x, expected -1\n",
ret);
2348 char fname[] =
"t_get_osfhanle";
2349 DWORD bytes_written;
2357 ok(
fd != -1,
"Couldn't open '%s' after _get_osfhandle()\n", fname);
2372 ok(2048 == p__setmaxstdio(2048),
"_setmaxstdio returned %d instead of 2048\n",p__setmaxstdio(2048));
2373 ok(-1 == p__setmaxstdio(2049),
"_setmaxstdio returned %d instead of -1\n",p__setmaxstdio(2049));
2375 else win_skip(
"_setmaxstdio not supported\n" );
2392 ok((
buf.st_mode & 0777) == 0666,
"bad st_mode = %06o\n",
buf.st_mode);
2393 ok(
buf.st_dev == 0,
"st_dev is %d, expected 0\n",
buf.st_dev);
2394 ok(
buf.st_dev ==
buf.st_rdev,
"st_dev (%d) and st_rdev (%d) differ\n",
buf.st_dev,
buf.st_rdev);
2395 ok(
buf.st_nlink == 1,
"st_nlink is %d, expected 1\n",
buf.st_nlink);
2396 ok(
buf.st_size == 0,
"st_size is %d, expected 0\n",
buf.st_size);
2401 ok((
buf.st_mode & 0777) == 0666,
"bad st_mode = %06o\n",
buf.st_mode);
2402 ok(
buf.st_dev ==
buf.st_rdev,
"st_dev (%d) and st_rdev (%d) differ\n",
buf.st_dev,
buf.st_rdev);
2403 ok(
buf.st_nlink == 1,
"st_nlink is %d, expected 1\n",
buf.st_nlink);
2404 ok(
buf.st_size == 0,
"st_size is %d, expected 0\n",
buf.st_size);
2408 ok(
ret == -1,
"stat returned %d\n",
ret);
2415 skip(
"open failed with errno %d\n",
errno);
2418 if (
_dup2(0, 10) == 0)
2421 ok(!
ret,
"fstat(stdin) failed: errno=%d\n",
errno);
2425 ok(
buf.st_dev == 10,
"st_dev is %d, expected 10\n",
buf.st_dev);
2426 ok(
buf.st_rdev == 10,
"st_rdev is %d, expected 10\n",
buf.st_rdev);
2427 ok(
buf.st_nlink == 1,
"st_nlink is %d, expected 1\n",
buf.st_nlink);
2430 skip(
"stdin is not a char device? st_mode=%06o\n",
buf.st_mode);
2434 skip(
"_dup2 failed with errno %d\n",
errno);
2440 ok(!
ret,
"fstat(pipe) failed: errno=%d\n",
errno);
2442 ok(
buf.st_dev == pipes[0],
"st_dev is %d, expected %d\n",
buf.st_dev, pipes[0]);
2443 ok(
buf.st_rdev == pipes[0],
"st_rdev is %d, expected %d\n",
buf.st_rdev, pipes[0]);
2444 ok(
buf.st_nlink == 1,
"st_nlink is %d, expected 1\n",
buf.st_nlink);
2449 skip(
"pipe failed with errno %d\n",
errno);
2452 if(
mkdir(
"stat.tst") == 0)
2455 ok(!
ret,
"stat(directory) failed: errno=%d\n",
errno);
2457 ok((
buf.st_mode & 0777) == 0777,
"bad st_mode = %06o\n",
buf.st_mode);
2458 ok(
buf.st_dev ==
buf.st_rdev,
"st_dev (%d) and st_rdev (%d) differ\n",
buf.st_dev,
buf.st_rdev);
2459 ok(
buf.st_nlink == 1,
"st_nlink is %d, expected 1\n",
buf.st_nlink);
2463 ok(
ret == -1,
"stat returned %d\n",
ret);
2465 rmdir(
"stat.tst" );
2468 skip(
"mkdir failed with errno %d\n",
errno);
2472 ok(
ret == -1,
"stat returned %d\n",
ret);
2476 ok(!
ret,
"stat returned %d\n",
ret);
2477 ok(
buf.st_dev == 2,
"st_dev = %d\n",
buf.st_dev);
2478 ok(
buf.st_rdev == 2,
"st_rdev = %d\n",
buf.st_rdev);
2484#define N_TEST_MESSAGES 3
2494 ok(0,
"not enough parameters: %d\n",
argc);
2500 ok(!
i,
"unable to close %d: %d\n",
fd,
errno);
2513 ok(!
i,
"unable to close %d: %d\n",
fd,
errno);
2519 char str_fdr[12], str_fdw[12];
2521 const char* arg_v[6];
2529 win_skip(
"Skipping test_pipes, because it hangs on ReactOS\n");
2536 ok(0,
"pipe failed with errno %d\n",
errno);
2543 arg_v[3] = str_fdr;
sprintf(str_fdr,
"%d", pipes[0]);
2544 arg_v[4] = str_fdw;
sprintf(str_fdw,
"%d", pipes[1]);
2548 ok(!
i,
"unable to close %d: %d\n", pipes[1],
errno);
2559 ok(
r == 0,
"expected to read 0 bytes, got %d\n",
r);
2561 ok(!
i,
"unable to close %d: %d\n", pipes[0],
errno);
2566 ok(0,
"pipe failed with errno %d\n",
errno);
2572 arg_v[3] = str_fdr;
sprintf(str_fdr,
"%d", pipes[0]);
2573 arg_v[4] = str_fdw;
sprintf(str_fdw,
"%d", pipes[1]);
2577 ok(!
i,
"unable to close %d: %d\n", pipes[1],
errno);
2596 ok(
r == 0,
"fread() returned %d instead of 0\n",
r);
2601 ok(!
i,
"unable to close the pipe: %d\n",
errno);
2606 ok(0,
"pipe failed with errno %d\n",
errno);
2609 r =
write(pipes[1],
"\r\n\rab\r\n", 7);
2610 ok(
r == 7,
"write returned %d, errno = %d\n",
r,
errno);
2613 ok(
r == 1,
"read returned %d, expected 1\n",
r);
2614 ok(
buf[0] ==
'\n',
"buf[0] = %x, expected '\\n'\n",
buf[0]);
2616 ok(
r == 1,
"read returned %d, expected 1\n",
r);
2617 ok(
buf[0] ==
'\r',
"buf[0] = %x, expected '\\r'\n",
buf[0]);
2619 ok(
r == 1,
"read returned %d, expected 1\n",
r);
2620 ok(
buf[0] ==
'a',
"buf[0] = %x, expected 'a'\n",
buf[0]);
2622 ok(
r == 2,
"read returned %d, expected 1\n",
r);
2623 ok(
buf[0] ==
'b',
"buf[0] = %x, expected 'b'\n",
buf[0]);
2624 ok(
buf[1] ==
'\n',
"buf[1] = %x, expected '\\n'\n",
buf[1]);
2629 r =
write(pipes[1],
"a\0b", 3);
2630 ok(
r == 3,
"write returned %d, errno = %d\n",
r,
errno);
2635 ok(
r == 2,
"read returned %d, expected 2\n",
r);
2636 ok(!
memcmp(
buf,
"a\0bz", 4),
"read returned incorrect data\n");
2637 r =
write(pipes[1],
"\0", 1);
2638 ok(
r == 1,
"write returned %d, errno = %d\n",
r,
errno);
2642 ok(
r == 0,
"read returned %d, expected 0\n",
r);
2643 ok(!
memcmp(
buf,
"\0z", 2),
"read returned incorrect data\n");
2647 win_skip(
"unicode mode tests on pipe\n");
2657 ok(
mkdir(
"test_unlink") == 0,
"unable to create test dir\n");
2658 file =
fopen(
"test_unlink\\empty",
"w");
2659 ok(
file !=
NULL,
"unable to create test file\n");
2662 ok(
_unlink(
"test_unlink") != 0,
"unlinking a non-empty directory must fail\n");
2663 unlink(
"test_unlink\\empty");
2664 rmdir(
"test_unlink");
2669 ok(-1 ==
_dup2(0, -1),
"expected _dup2 to fail when second arg is negative\n" );
2680 ok(stdin_dup != -1,
"_dup(STDIN_FILENO) failed\n");
2683 "GetStdHandle(STD_INPUT_HANDLE) != _get_osfhandle(STDIN_FILENO)\n");
2686 ok(
r ==
TRUE,
"SetStdHandle returned %lx, expected TRUE\n",
r);
2695 ok(
fd != -1,
"open failed\n");
2703 ok(
r != -1,
"_dup2 failed\n");
2722 ok(!
_mktemp(
buf),
"_mktemp(\"testXXXXXXa\") != NULL\n");
2736 ok(
fd == -1,
"_open_osfhandle returned %d\n",
fd);
2741 ok(
fd > 0,
"_open_osfhandle returned %d (%d)\n",
fd,
errno);
2743 ok(
info->handle ==
h,
"info->handle = %p, expected %p\n",
info->handle,
h);
2744 ok(
info->wxflag == 1,
"info->wxflag = %x, expected 1\n",
info->wxflag);
2747 ok(
info->wxflag == 0,
"info->wxflag = %x, expected 0\n",
info->wxflag);
2752 ok(
fd == -1,
"_open_osfhandle returned %d\n",
fd);
2757 ok(
fd > 0,
"_open_osfhandle returned %d (%d)\n",
fd,
errno);
2759 ok(
info->handle ==
h,
"info->handle = %p, expected %p\n",
info->handle,
h);
2760 ok(
info->wxflag == 9,
"info->wxflag = %x, expected 9\n",
info->wxflag);
2775 _snprintf(
outbuffer,
bufsize + 1,
"0,1,2,3,4,5,6,7,8,9");
2779 ok(
file->_cnt == 0,
"_cnt should be 0 after rewind, but is %d\n",
file->_cnt);
2786 ok(
file->_cnt == 0,
"_cnt should be 0 after fflush, but is %d\n",
file->_cnt);
2807 ok(!
file->_cnt,
"file->_cnt = %d\n",
file->_cnt);
2808 ok(
file->_ptr !=
file->_base,
"file->_ptr == file->_base\n");
2811 ok(!
file->_cnt,
"file->_cnt = %d\n",
file->_cnt);
2812 ok(
file->_ptr ==
file->_base,
"file->_ptr == file->_base\n");
2827 ok(
file !=
NULL,
"unable to create test file\n");
2829 ok(
file->_bufsiz == 4096,
"incorrect default buffer size: %d\n",
file->_bufsiz);
2840 ioinfo *stdout_info, stdout_copy, *stderr_info, stderr_copy;
2841 int fd1, fd2, ret1, ret2, ret3, ret4;
2851 ok(fd1 != -1,
"_open_osfhandle failed (%d)\n",
errno);
2853 ok(fd2 != -1,
"_open_osfhandle failed (%d)\n",
errno);
2854 ok(fd1 != fd2,
"fd1 == fd2\n");
2861 ok(!ret1,
"close(fd1) failed (%d)\n",
errno);
2863 ok(
close(fd2),
"close(fd2) succeeded\n");
2868 ok(ret1 == -1,
"close(fd1) succeeded\n");
2879 stdout_copy = *stdout_info;
2880 stderr_copy = *stderr_info;
2889 *stdout_info = stdout_copy;
2890 *stderr_info = stderr_copy;
2895 ok(!ret1,
"close(STDOUT_FILENO) failed\n");
2896 ok(ret2,
"GetHandleInformation failed\n");
2897 ok(!ret3,
"close(STDERR_FILENO) failed\n");
2898 ok(!ret4,
"GetHandleInformation succeeded\n");
2905 int fd,
pos,
count, readonly, old_fmode = 0, have_fmode;
2906 char buf[6],
testdata[4] = {
'a',
'\n',
'b',
'\n'};
2908 have_fmode = p__get_fmode && p__set_fmode && !p__get_fmode(&old_fmode);
2910 win_skip(
"_fmode can't be set, skipping mode tests\n");
2915 ok(
fd > 0,
"_creat failed\n");
2919 ok(
pos == 6,
"expected pos 6 (text mode), got %d\n",
pos);
2923 ok(
count == 4,
"_read returned %d, expected 4\n",
count);
2928 ok(readonly,
"expected read-only file\n");
2935 ok(
fd > 0,
"_creat failed\n");
2939 ok(
pos == 4,
"expected pos 4 (binary mode), got %d\n",
pos);
2943 ok(
count == 4,
"_read returned %d, expected 4\n",
count);
2948 ok(!readonly,
"expected rw file\n");
2953 p__set_fmode(old_fmode);
2959 char testdata[4] = {
'a',
'\n',
'b',
'\n'};
2966 ok(
fd > 0,
"_creat failed\n");
2970 ok(
_lseek(
fd, 0, 42) == -1,
"expected failure\n");
2991 ok(!
status,
"NtQueryInformationFile failed\n");
2997 static const struct {
3018 ok(fp !=
NULL,
"unable to fopen test file with mode \"%s\"\n",
tests[
i].
mode);
3020 "unexpected sequential hint for fopen mode \"%s\"\n",
tests[
i].
mode);
3028 static const struct {
3048 ok(
fd != -1,
"unable to _open test file with flags %x\n",
tests[
i].
mode);
3050 "unexpected sequential hint for _open flags %x\n",
tests[
i].
mode);
3066 ok(tempfd != -1,
"_open failed with error: %d\n",
errno);
3070 ok(!!
info,
"NULL info.\n");
3079 ok(!
info->wxflag,
"Unexpected wxflag %#x.\n",
info->wxflag);
3082 ok(!!
info,
"NULL info.\n");
3084 ok(!
info->exflag,
"Unexpected exflag %#x.\n",
info->exflag);
3097 ok(dup_fd != -1,
"_dup failed\n");
3110 ok(
ret == 4,
"fprintf(stdout) returned %d\n",
ret);
3111 ok(!
pos,
"expected stdout to be buffered\n");
3114 ok(dup_fd != -1,
"_dup failed\n");
3120 ok(
ret == 4,
"fprintf(stderr) returned %d\n",
ret);
3122 ok(!
pos,
"expected stderr to be buffered\n");
3129 ok(dup_fd != -1,
"_dup failed\n");
3136 ok(
ret == 1,
"fscanf returned %d\n",
ret);
3137 ok(ch ==
't',
"ch = 0x%x\n", (
unsigned char)ch);
3145 ok(
DeleteFileA(
"std_stream_test.tmp"),
"DeleteFile failed\n");
3154 ok(
fd != -1,
"_dup failed\n");
3177 if (
strcmp(arg_v[2],
"inherit") == 0)
3179 else if (
strcmp(arg_v[2],
"inherit_no") == 0)
3181 else if (
strcmp(arg_v[2],
"pipes") == 0)
3183 else if (
strcmp(arg_v[2],
"stdin") == 0)
3186 ok(0,
"invalid argument '%s'\n", arg_v[2]);
int strcmp(const char *String1, const char *String2)
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
ACPI_SIZE strlen(const char *String)
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
char * strchr(const char *String, int ch)
static void startup(void)
static struct sockaddr_in sa
HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle)
#define RegCloseKey(hKey)
#define _setmode(fd, mode)
LONG WINAPI RegOpenCurrentUser(IN REGSAM samDesired, OUT PHKEY phkResult)
#define ReadFile(a, b, c, d, e)
#define GetProcAddress(x, y)
#define INVALID_HANDLE_VALUE
#define CreateFileA(a, b, c, d, e, f, g)
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
#define GetCurrentProcess()
#define FILE_ATTRIBUTE_NORMAL
#define WideCharToMultiByte
#define MultiByteToWideChar
#define ERROR_ACCESS_DENIED
BOOL WINAPI DECLSPEC_HOTPATCH SetStdHandle(DWORD nStdHandle, HANDLE hHandle)
BOOL WINAPI GetHandleInformation(IN HANDLE hObject, OUT LPDWORD lpdwFlags)
BOOL WINAPI DuplicateHandle(IN HANDLE hSourceProcessHandle, IN HANDLE hSourceHandle, IN HANDLE hTargetProcessHandle, OUT LPHANDLE lpTargetHandle, IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwOptions)
HMODULE WINAPI DECLSPEC_HOTPATCH GetModuleHandleA(LPCSTR lpModuleName)
BOOL WINAPI DECLSPEC_HOTPATCH CreateProcessA(LPCSTR lpApplicationName, LPSTR lpCommandLine, LPSECURITY_ATTRIBUTES lpProcessAttributes, LPSECURITY_ATTRIBUTES lpThreadAttributes, BOOL bInheritHandles, DWORD dwCreationFlags, LPVOID lpEnvironment, LPCSTR lpCurrentDirectory, LPSTARTUPINFOA lpStartupInfo, LPPROCESS_INFORMATION lpProcessInformation)
VOID WINAPI GetStartupInfoA(IN LPSTARTUPINFOA lpStartupInfo)
DWORD WINAPI DECLSPEC_HOTPATCH GetTempPathA(DWORD count, LPSTR path)
BOOL WINAPI DECLSPEC_HOTPATCH WriteFile(HANDLE file, LPCVOID buffer, DWORD count, LPDWORD result, LPOVERLAPPED overlapped)
BOOL WINAPI DECLSPEC_HOTPATCH SetFileAttributesA(LPCSTR name, DWORD attributes)
BOOL WINAPI DECLSPEC_HOTPATCH DeleteFileA(LPCSTR path)
UINT WINAPI DECLSPEC_HOTPATCH GetTempFileNameA(LPCSTR path, LPCSTR prefix, UINT unique, LPSTR buffer)
DWORD WINAPI DECLSPEC_HOTPATCH GetFileAttributesA(LPCSTR name)
HANDLE WINAPI DECLSPEC_HOTPATCH FindFirstFileA(const char *filename, WIN32_FIND_DATAA *data)
BOOL WINAPI DECLSPEC_HOTPATCH FindClose(HANDLE handle)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
static unsigned char buff[32768]
#define FILE_SEQUENTIAL_ONLY
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLdouble GLdouble GLdouble r
GLenum GLsizei GLuint GLint * bytesWritten
GLenum GLuint GLenum GLsizei const GLchar * buf
GLenum GLuint GLsizei bufsize
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_Check_return_opt_ _CRTIMP int __cdecl fsetpos(_Inout_ FILE *_File, _In_ const fpos_t *_Pos)
_CRTIMP char *__cdecl tmpnam(_Pre_maybenull_ _Post_z_ char *_Buffer)
_Check_return_ _CRTIMP FILE *__cdecl freopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fgetc(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl _filbuf(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl _getw(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl ferror(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP wint_t __cdecl fputwc(_In_ wchar_t _Ch, _Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl getc(_Inout_ FILE *_File)
_CRTIMP void __cdecl rewind(_Inout_ FILE *_File)
_Check_return_ _CRTIMP char *__cdecl _tempnam(_In_opt_z_ const char *_DirName, _In_opt_z_ const char *_FilePrefix)
_Check_return_opt_ _CRTIMP int __cdecl fgetpos(_Inout_ FILE *_File, _Out_ fpos_t *_Pos)
_Check_return_ _CRTIMP int __cdecl _fileno(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl _fcloseall(void)
_Check_return_ _CRTIMP int __cdecl feof(_In_ FILE *_File)
_Check_return_opt_ _CRTIMP_ALT int __cdecl ungetc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fputs(_In_z_ const char *_Str, _Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl fscanf(_Inout_ FILE *_File, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl _flushall(void)
_Check_return_opt_ _CRTIMP int __cdecl fflush(_Inout_opt_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fdopen(_In_ int _FileHandle, _In_z_ const char *_Format)
_Check_return_opt_ _CRTIMP size_t __cdecl fread(_Out_writes_bytes_(_ElementSize *_Count) void *_DstBuf, _In_ size_t _ElementSize, _In_ size_t _Count, _Inout_ FILE *_File)
_Check_return_ _CRTIMP FILE *__cdecl fopen(_In_z_ const char *_Filename, _In_z_ const char *_Mode)
_Check_return_opt_ _CRTIMP int __cdecl fputc(_In_ int _Ch, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fseek(_Inout_ FILE *_File, _In_ long _Offset, _In_ int _Origin)
_Check_return_opt_ _CRTIMP char *__cdecl fgets(_Out_writes_z_(_MaxCount) char *_Buf, _In_ int _MaxCount, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl fclose(_Inout_ FILE *_File)
_Check_return_ _CRTIMP long __cdecl ftell(_Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP size_t __cdecl fwrite(_In_reads_bytes_(_Size *_Count) const void *_Str, _In_ size_t _Size, _In_ size_t _Count, _Inout_ FILE *_File)
_CRTIMP void __cdecl setbuf(_Inout_ FILE *_File, _Inout_updates_opt_(BUFSIZ) _Post_readable_size_(0) char *_Buffer)
_Check_return_opt_ _CRTIMP wint_t __cdecl fgetwc(_Inout_ FILE *_File)
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl fputws(_In_z_ const wchar_t *_Str, _Inout_ FILE *_File)
_Check_return_opt_ _CRTIMP int __cdecl setvbuf(_Inout_ FILE *_File, _Inout_updates_opt_z_(_Size) char *_Buf, _In_ int _Mode, _In_ size_t _Size)
_CRTIMP void __cdecl clearerr(_Inout_ FILE *_File)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
const unsigned char * inbuffer
int WINAPI lstrlenA(LPCSTR lpString)
static struct test_info tests[]
#define sprintf(buf, format,...)
static PEXPLICIT_ACCESSW *static HMODULE hmod
static CHAR selfname[MAX_PATH]
static const char * read_file(HANDLE file)
static void test_invalid_stdin_child(void)
static void test_fputc(void)
static void test_tmpnam(void)
static void test_fopen_hints(void)
static void test_file_write_read(void)
static const char * get_base_name(const char *path)
static WCHAR * AtoW(const char *p)
static void test_fileops(void)
static void test_ioinfo_flags(void)
static HANDLE proc_handles[2]
static void test_flsbuf(void)
static void test_fputwc(void)
static void test_fgetc(void)
static void test_dup2(void)
static const char * pipe_string
static void test_get_osfhandle(void)
static void test_lseek(void)
static void test_freopen(void)
static void test_pipes_child(int argc, char **args)
static BOOL has_sequential_hint(int fd)
static void test_setmode(void)
static void test__creat(void)
static void test_chsize(void)
static unsigned WINAPI read_pipe_thread(void *argument)
static void test_readmode(BOOL ascii_mode)
static void test_close(void)
static void test_std_stream_buffering(void)
static void test_unlink(void)
static void test_write_flush(void)
static void test_fgetwc_locale(const char *text, const char *locale, int codepage)
static void test_stat(void)
static void test_open_hints(void)
static void test_stdout_handle(STARTUPINFOA *startup, char *cmdline, HANDLE hstdout, BOOL expect_stdout, const char *descr)
static void test_std_stream_open(void)
static void test_write_flush_size(FILE *file, int bufsize)
static void test_file_inherit_child_no(const char *fd_s)
static void test__open_osfhandle(void)
static void test_filemodeT(void)
static void test_asciimode2(void)
static void test_readboundary(void)
static void test_ctrlz(void)
static void test_fdopen(void)
static void test_fgetwc(void)
static void test_fopen_fclose_fcloseall(void)
static void test_asciimode(void)
static void test_invalid_stdin(const char *selfname)
static void test_stdin(void)
static void test_file_put_get(void)
static void test_mktemp(void)
static void test_fflush(void)
static ioinfo ** __pioinfo
static void test_pipes(const char *selfname)
static void test_fopen_s(void)
static void test__wfopen_s(void)
static void test_fgetwc_unicode(void)
static void test_setmaxstdio(void)
#define MSVCRT_FD_BLOCK_SIZE
static void create_io_inherit_block(STARTUPINFOA *startup, unsigned int count, const HANDLE *handles)
static void test_filbuf(void)
static void test_file_inherit_child(const char *fd_s, const char *handle_str)
static void test_file_inherit(const char *selfname)
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK io
static unsigned(__cdecl *hash_bstr)(bstr_t s)
const char * strerror(int err)
BOOL WINAPI CreatePipe(PHANDLE hReadPipe, PHANDLE hWritePipe, LPSECURITY_ATTRIBUTES lpPipeAttributes, DWORD nSize)
#define FILE_ATTRIBUTE_READONLY
NTSYSAPI NTSTATUS NTAPI NtQueryInformationFile(IN HANDLE hFile, OUT PIO_STATUS_BLOCK pIoStatusBlock, OUT PVOID FileInformationBuffer, IN ULONG FileInformationBufferLength, IN FILE_INFORMATION_CLASS FileInfoClass)
_CRTIMP intptr_t __cdecl _get_osfhandle(_In_ int _FileHandle)
_Check_return_opt_ _CRTIMP int __cdecl _close(_In_ int _FileHandle)
_Check_return_opt_ _CRTIMP long __cdecl _lseek(_In_ int _FileHandle, _In_ long _Offset, _In_ int _Origin)
_Check_return_ _CRTIMP long __cdecl _filelength(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl _chmod(_In_z_ const char *_Filename, _In_ int _Mode)
_CRTIMP int __cdecl _sopen(const char *_Filename, int _OpenFlag, int _ShareFlag,...)
_CRTIMP int __cdecl _write(_In_ int _FileHandle, _In_reads_bytes_(_MaxCharCount) const void *_Buf, _In_ unsigned int _MaxCharCount)
_Check_return_ _CRTIMP int __cdecl _pipe(_Inout_updates_(2) int *_PtHandles, _In_ unsigned int _PipeSize, _In_ int _TextMode)
_Check_return_ _CRTIMP long __cdecl _tell(_In_ int _FileHandle)
_Check_return_ _CRTIMP char *__cdecl _mktemp(_Inout_z_ char *_TemplateName)
_Check_return_ _CRTIMP int __cdecl _creat(_In_z_ const char *_Filename, _In_ int _PermissionMode)
_Check_return_ _CRTIMP int __cdecl _read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)
_Check_return_ _CRTIMP int __cdecl _dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
_Check_return_ _CRTIMP int __cdecl _unlink(_In_z_ const char *_Filename)
_CRTIMP char *__cdecl mktemp(_Inout_z_ char *_TemplateName)
_CRTIMP int __cdecl _open(const char *_Filename, int _OpenFlag,...)
_Check_return_ _CRTIMP int __cdecl _chsize(_In_ int _FileHandle, _In_ long _Size)
_Check_return_ _CRTIMP int __cdecl _dup(_In_ int _FileHandle)
_Check_return_ _CRTIMP int __cdecl dup2(_In_ int _FileHandleSrc, _In_ int _FileHandleDst)
_CRTIMP int __cdecl _open_osfhandle(_In_ intptr_t _OSFileHandle, _In_ int _Flags)
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
_CRTIMP intptr_t __cdecl _spawnvp(_In_ int _Mode, _In_z_ const char *_Filename, _In_z_ const char *const *_ArgList)
int winetest_get_mainargs(char ***pargv)
#define wait_child_process
__int64 CDECL _telli64(int fd)
DWORD WINAPI WaitForMultipleObjects(IN DWORD nCount, IN CONST HANDLE *lpHandles, IN BOOL bWaitAll, IN DWORD dwMilliseconds)
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
VOID WINAPI DECLSPEC_HOTPATCH Sleep(IN DWORD dwMilliseconds)
static EFI_HANDLE * handles
#define NORMAL_PRIORITY_CLASS
#define STD_OUTPUT_HANDLE
DWORD WINAPI GetLastError(void)
#define CREATE_DEFAULT_ERROR_MODE
#define STARTF_USESTDHANDLES
wchar_t * fgetws(wchar_t *buf, int bufsize, FILE *file)
#define DUPLICATE_CLOSE_SOURCE
static unsigned int block