亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? mailslot.c

?? 一個類似windows
?? C
字號:
/*
 *  Mailslot regression test
 *
 *  Copyright 2003 Mike McCormack
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>

#include <windef.h>
#include <winbase.h>

#include "wine/test.h"

static const char szmspath[] = "\\\\.\\mailslot\\wine_mailslot_test";

static int mailslot_test(void)
{
    HANDLE hSlot, hSlot2, hWriter, hWriter2;
    unsigned char buffer[16];
    DWORD count, dwMax, dwNext, dwMsgCount, dwTimeout;

    /* sanity check on GetMailslotInfo */
    dwMax = dwNext = dwMsgCount = dwTimeout = 0;
    ok( !GetMailslotInfo( INVALID_HANDLE_VALUE, &dwMax, &dwNext,
            &dwMsgCount, &dwTimeout ), "getmailslotinfo succeeded\n");

    /* open a mailslot that doesn't exist */
    hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
                             FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter == INVALID_HANDLE_VALUE, "nonexistent mailslot\n");

    /* open a mailslot without the right name */
    hSlot = CreateMailslot( "blah", 0, 0, NULL );
    ok( hSlot == INVALID_HANDLE_VALUE,
            "Created mailslot with invalid name\n");
    ok( GetLastError() == ERROR_INVALID_NAME,
            "error should be ERROR_INVALID_NAME\n");

    /* open a mailslot with a null name */
    hSlot = CreateMailslot( NULL, 0, 0, NULL );
    ok( hSlot == INVALID_HANDLE_VALUE,
            "Created mailslot with invalid name\n");
    ok( GetLastError() == ERROR_PATH_NOT_FOUND,
            "error should be ERROR_PATH_NOT_FOUND\n");

    /* valid open, but with wacky parameters ... then check them */
    hSlot = CreateMailslot( szmspath, -1, -1, NULL );
    ok( hSlot != INVALID_HANDLE_VALUE , "mailslot with valid name failed\n");
    dwMax = dwNext = dwMsgCount = dwTimeout = 0;
    ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
           "getmailslotinfo failed\n");
    ok( dwMax == ~0UL, "dwMax incorrect\n");
    ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
    ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
    ok( dwTimeout == ~0UL, "dwTimeout incorrect\n");
    ok( GetMailslotInfo( hSlot, NULL, NULL, NULL, NULL ),
            "getmailslotinfo failed\n");
    ok( CloseHandle(hSlot), "failed to close mailslot\n");

    /* now open it for real */
    hSlot = CreateMailslot( szmspath, 0, 0, NULL );
    ok( hSlot != INVALID_HANDLE_VALUE , "valid mailslot failed\n");

    /* try and read/write to it */
    count = 0;
    memset(buffer, 0, sizeof buffer);
    ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
            "slot read\n");
    ok( !WriteFile( hSlot, buffer, sizeof buffer, &count, NULL),
            "slot write\n");

    /* now try and openthe client, but with the wrong sharing mode */
    hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
                             0, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter == INVALID_HANDLE_VALUE, "bad sharing mode\n");
    ok( GetLastError() == ERROR_SHARING_VIOLATION,
            "error should be ERROR_SHARING_VIOLATION\n");

    /* now open the client with the correct sharing mode */
    hWriter = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
                             FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter != INVALID_HANDLE_VALUE, "existing mailslot\n");

    /*
     * opening a client should make no difference to
     * whether we can read or write the mailslot
     */
    ok( !ReadFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
            "slot read\n");
    ok( !WriteFile( hSlot, buffer, sizeof buffer/2, &count, NULL),
            "slot write\n");

    /*
     * we can't read from this client, 
     * but we should be able to write to it
     */
    ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
            "can read client\n");
    ok( WriteFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
            "can't write client\n");
    ok( !ReadFile( hWriter, buffer, sizeof buffer/2, &count, NULL),
            "can read client\n");

    /*
     * seeing as there's something in the slot,
     * we should be able to read it once
     */
    ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
            "slot read\n");
    ok( count == (sizeof buffer/2), "short read\n" );

    /* but not again */
    ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
            "slot read\n");

    /* now try open another writer... should fail */
    hWriter2 = CreateFile(szmspath, GENERIC_READ|GENERIC_WRITE,
                     FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter2 == INVALID_HANDLE_VALUE, "two writers\n");

    /* now try open another as a reader ... also fails */
    hWriter2 = CreateFile(szmspath, GENERIC_READ,
                     FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter2 == INVALID_HANDLE_VALUE, "writer + reader\n");

    /* now try open another as a writer ... still fails */
    hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
                     FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter2 == INVALID_HANDLE_VALUE, "writer\n");

    /* now open another one */
    hSlot2 = CreateMailslot( szmspath, 0, 0, NULL );
    ok( hSlot2 == INVALID_HANDLE_VALUE , "opened two mailslots\n");

    /* close the client again */
    ok( CloseHandle( hWriter ), "closing the client\n");

    /*
     * now try reopen it with slightly different permissions ...
     * shared writing
     */
    hWriter = CreateFile(szmspath, GENERIC_WRITE,
              FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter != INVALID_HANDLE_VALUE, "sharing writer\n");

    /*
     * now try open another as a writer ...
     * but don't share with the first ... fail
     */
    hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
                     FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter2 == INVALID_HANDLE_VALUE, "greedy writer succeeded\n");

    /* now try open another as a writer ... and share with the first */
    hWriter2 = CreateFile(szmspath, GENERIC_WRITE,
              FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL);
    ok( hWriter2 != INVALID_HANDLE_VALUE, "2nd sharing writer\n");

    /* check the mailslot info */
    dwMax = dwNext = dwMsgCount = dwTimeout = 0;
    ok( GetMailslotInfo( hSlot, &dwMax, &dwNext, &dwMsgCount, &dwTimeout ),
        "getmailslotinfo failed\n");
    ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
    ok( dwMax == 0, "dwMax incorrect\n");
    ok( dwMsgCount == 0, "dwMsgCount incorrect\n");
    ok( dwTimeout == 0, "dwTimeout incorrect\n");

    /* check there's still no data */
    ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL), "slot read\n");

    /* write two messages */
    buffer[0] = 'a';
    ok( WriteFile( hWriter, buffer, 1, &count, NULL), "1st write failed\n");

    /* check the mailslot info */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    ok( dwNext == 1, "dwNext incorrect\n");
    ok( dwMsgCount == 1, "dwMsgCount incorrect\n");

    buffer[0] = 'b';
    buffer[1] = 'c';
    ok( WriteFile( hWriter2, buffer, 2, &count, NULL), "2nd write failed\n");

    /* check the mailslot info */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    ok( dwNext == 1, "dwNext incorrect\n");
    todo_wine {
    ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
    }

    /* write a 3rd message with zero size */
    ok( WriteFile( hWriter2, buffer, 0, &count, NULL), "3rd write failed\n");

    /* check the mailslot info */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    ok( dwNext == 1, "dwNext incorrect\n");
    todo_wine {
    ok( dwMsgCount == 3, "dwMsgCount incorrect\n");
    }

    buffer[0]=buffer[1]=0;

    /*
     * then check that they come out with the correct order and size,
     * then the slot is empty
     */
    ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
        "1st slot read failed\n");
    ok( count == 1, "failed to get 1st message\n");
    ok( buffer[0] == 'a', "1st message wrong\n");

    /* check the mailslot info */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    ok( dwNext == 2, "dwNext incorrect\n");
    todo_wine {
    ok( dwMsgCount == 2, "dwMsgCount incorrect\n");
    }

    /* read the second message */
    ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
        "2nd slot read failed\n");
    ok( count == 2, "failed to get 2nd message\n");
    ok( ( buffer[0] == 'b' ) && ( buffer[1] == 'c' ), "2nd message wrong\n");

    /* check the mailslot info */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    todo_wine {
    ok( dwNext == 0, "dwNext incorrect\n");
    ok( dwMsgCount == 1, "dwMsgCount incorrect\n");
    }

    /* read the 3rd (zero length) message */
    todo_wine {
    ok( ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
        "3rd slot read failed\n");
    }
    ok( count == 0, "failed to get 3rd message\n");

    /*
     * now there should be no more messages
     * check the mailslot info
     */
    dwNext = dwMsgCount = 0;
    ok( GetMailslotInfo( hSlot, NULL, &dwNext, &dwMsgCount, NULL ),
        "getmailslotinfo failed\n");
    ok( dwNext == MAILSLOT_NO_MESSAGE, "dwNext incorrect\n");
    ok( dwMsgCount == 0, "dwMsgCount incorrect\n");

    /* check that reads fail */
    ok( !ReadFile( hSlot, buffer, sizeof buffer, &count, NULL),
        "3rd slot read succeeded\n");

    /* finally close the mailslot and its client */
    ok( CloseHandle( hWriter2 ), "closing 2nd client\n");
    ok( CloseHandle( hWriter ), "closing the client\n");
    ok( CloseHandle( hSlot ), "closing the mailslot\n");

    return 0;
}

START_TEST(mailslot)
{
    mailslot_test();
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲一级二级三级在线免费观看| 99久久免费国产| 99精品偷自拍| 精品国产髙清在线看国产毛片| 综合色天天鬼久久鬼色| 国内精品国产成人| 91麻豆精品久久久久蜜臀| 中文字幕欧美一区| 国产99久久久国产精品免费看| 欧美一二区视频| 亚洲一区二区高清| 99re热这里只有精品免费视频| 欧美电影免费观看高清完整版在 | 欧美性色黄大片手机版| 亚洲国产精品av| 韩国av一区二区三区| 91精品一区二区三区久久久久久| 国产精品久久久久aaaa樱花 | 色哟哟日韩精品| 国产精品盗摄一区二区三区| 国产高清一区日本| 欧美成人综合网站| 奇米影视一区二区三区小说| 欧美三级韩国三级日本三斤| 最新中文字幕一区二区三区| 国产91对白在线观看九色| 精品国产一二三| 免费人成精品欧美精品| 欧美一级艳片视频免费观看| 日韩精品视频网| 91精品国产综合久久精品麻豆| 亚洲男人的天堂av| 91香蕉国产在线观看软件| 中文一区二区在线观看| 国产精品一级片在线观看| 国产日韩欧美不卡在线| 成人av在线播放网站| 国产精品久久久久一区| 99免费精品在线观看| 国产精品国产精品国产专区不蜜| 99久久精品99国产精品| 一区二区三区蜜桃| 欧美日韩午夜在线| 日韩精品乱码免费| 欧美精品一区二区三区一线天视频 | 国产精品亚洲专一区二区三区| 精品国产露脸精彩对白| 国产黑丝在线一区二区三区| 欧美国产一区视频在线观看| 粉嫩嫩av羞羞动漫久久久| 综合久久久久久| 欧美三区在线观看| 美日韩一区二区三区| 久久久国产综合精品女国产盗摄| 国产99精品在线观看| 夜夜精品视频一区二区| 91精品国产全国免费观看| 国产一区二区三区久久久 | 亚洲精品在线一区二区| av在线不卡电影| 亚洲国产成人av| 精品99999| 欧洲生活片亚洲生活在线观看| 免费国产亚洲视频| 国产精品丝袜91| 欧美日韩一区高清| 国产福利精品一区| 天天做天天摸天天爽国产一区 | 欧美大胆人体bbbb| av一二三不卡影片| 日韩国产精品久久| 中文字幕第一区综合| 欧美色爱综合网| 国产高清亚洲一区| 午夜精品久久久久久| 国产精品国产三级国产专播品爱网 | 91蜜桃传媒精品久久久一区二区| 亚洲成人av电影在线| 国产欧美日韩卡一| 欧美一级理论片| 91久久精品一区二区三区| 国产精品99久久久久久有的能看 | 国产精品三级av| 欧美一区二区免费视频| 97久久人人超碰| 国内精品国产成人国产三级粉色| 亚洲线精品一区二区三区八戒| 久久久美女毛片| 91精品国产欧美日韩| 欧美亚日韩国产aⅴ精品中极品| 国产成人免费视频网站| 美女视频黄频大全不卡视频在线播放| 国产精品女人毛片| 久久综合色之久久综合| 欧美精品三级在线观看| 色婷婷亚洲精品| 国产成人精品免费| 激情深爱一区二区| 午夜久久久影院| 亚洲精品你懂的| 综合久久国产九一剧情麻豆| 欧美精品一区二区三区久久久| 宅男噜噜噜66一区二区66| 精品视频色一区| 在线影视一区二区三区| 91丨九色porny丨蝌蚪| 成人中文字幕在线| 国产成a人亚洲精品| 极品少妇一区二区| 极品少妇xxxx精品少妇| 久久99最新地址| 乱一区二区av| 国产在线精品一区二区不卡了 | 久久精品日产第一区二区三区高清版 | 欧美一区二区三区在线观看| 欧美日韩精品一区二区| 欧美在线视频日韩| 在线视频欧美精品| 欧美亚洲日本一区| 91 com成人网| 欧美一区二区三区成人| 欧美一区二区成人6969| 日韩女优av电影| 亚洲精品一区在线观看| 国产日产欧产精品推荐色| 久久夜色精品一区| 国产精品女同一区二区三区| 亚洲色图都市小说| 亚洲韩国精品一区| 麻豆成人综合网| 成人免费不卡视频| 91老师国产黑色丝袜在线| 欧美三级电影在线看| 欧美成人三级在线| 久久影院视频免费| 最新日韩在线视频| 午夜a成v人精品| 激情综合色播五月| 波多野结衣亚洲| 91行情网站电视在线观看高清版| 欧美精品在线视频| 欧美精品一区二区久久婷婷| 国产精品视频一二| 午夜电影网一区| 国产综合久久久久久鬼色| 91性感美女视频| 欧美日本在线一区| 久久免费视频一区| 亚洲国产综合在线| 国产在线看一区| 色一情一乱一乱一91av| 欧美日韩高清不卡| 欧美激情在线一区二区| 亚洲乱码中文字幕综合| 秋霞电影网一区二区| 成人综合婷婷国产精品久久免费| 欧美在线不卡一区| 日韩精品一区二区三区swag| 中文字幕一区二区日韩精品绯色| 亚洲国产wwwccc36天堂| 国产精品一级片在线观看| 欧美日韩国产一二三| 欧美国产精品v| 男人操女人的视频在线观看欧美| 成人黄色在线视频| 日韩欧美国产一区二区在线播放| 国产精品的网站| 国产一区二区三区四区五区美女| 欧美日韩日日摸| 亚洲精品欧美激情| 国产91对白在线观看九色| 欧美一区二区三区免费视频| 一区二区三区在线视频观看58| 国产精品系列在线播放| 日韩欧美成人一区二区| 亚洲成人av一区| 一本大道久久a久久精二百| 欧美激情一区二区三区| 国产精品一区二区久久不卡| 日韩久久久精品| 毛片av中文字幕一区二区| 欧美日韩国产一级| 亚洲一区在线视频观看| 99re6这里只有精品视频在线观看 99re8在线精品视频免费播放 | 成人aaaa免费全部观看| 久久毛片高清国产| 精品一区二区精品| 欧美久久久久中文字幕| 亚洲韩国一区二区三区| 欧美伊人久久大香线蕉综合69| 亚洲欧美综合在线精品| av电影天堂一区二区在线观看| 国产日韩v精品一区二区| 国产精品一品二品| 中文字幕精品在线不卡| 成人性视频免费网站| 国产精品二三区| 99re亚洲国产精品| 亚洲黄色尤物视频| 欧美日韩日本视频|