• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PAL_Terminate函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PAL_Terminate函数的典型用法代码示例。如果您正苦于以下问题:C++ PAL_Terminate函数的具体用法?C++ PAL_Terminate怎么用?C++ PAL_Terminate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PAL_Terminate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main


//.........这里部分代码省略.........
#else   // __APPLE__
    const char* rgchLibraryFile = "dllmain.so";
#endif  // __APPLE__
    char        szFunction[] = "GetDetachCount";
#endif

    HANDLE      hLib = NULL;
    LPTESTFUNC  pFunc;
    int         detachCount1 = 0;
    int         detachCount2 = 0;
    
    HANDLE      hThread = NULL;
    DWORD       IDThread;

    /* initialize the PAL */
    if( PAL_Initialize(argc, argv) != 0 )
    {
	    return( FAIL );
    }
    
    /* Load the test library */
    hLib = LoadLibrary( rgchLibraryFile );
    if(hLib == NULL)
    {
        Fail("ERROR: Unable to load library %s\n", rgchLibraryFile );
    }
    

    /* Get the address of our test function in the dll */
    pFunc = (LPTESTFUNC)GetProcAddress( hLib, szFunction );
    if( pFunc == NULL )
    {
        Trace( "ERROR:%lu%:Unable to load function \"%s\" library \"%s\"\n",
                GetLastError(),
                szFunction,
                rgchLibraryFile );
        if( ! FreeLibrary( hLib ) ) {
            Trace( "FreeLibrary() failed with error code %lu\n",
                    GetLastError() );
        }
        Fail( "Exiting\n" );
    }
    
    /* Execute the test function to get the detach count */
    detachCount1 = pFunc();
    
    /* run another dummy thread to cause notification of the library       */
    hThread = CreateThread(    NULL,             /* no security attributes */
                               0,                /* use default stack size */
      (LPTHREAD_START_ROUTINE) ThreadFunc,       /* thread function        */
                      (LPVOID) NULL,             /* pass thread index as   */
                                                 /* function argument      */
                               CREATE_SUSPENDED, /* create suspended       */
                               &IDThread );      /* returns thread id      */

    /* Check the return value for success. */
    if( hThread == NULL )
    {
        /* error creating thread */
        Trace( "Unexpected CreateThread error %d\n",
              GetLastError() );
        if( ! FreeLibrary( hLib ) ) {
            Trace( "FreeLibrary() failed with error code %lu\n",
                    GetLastError() );
        }
        Fail( "Exiting\n" );
    }
    
    /* Resume the suspended thread */
    ResumeThread( hThread );

    /* wait for the thread to complete */
    WaitForSingleObject( hThread, INFINITE );

    /* Execute the test function to get the new detach count */
    detachCount2 = pFunc();
    
    /* Unload the test library */ 
    if( !FreeLibrary( hLib ) )
    {
        Fail( "ERROR:%u: Unable to free library \"%s\"\n",
                GetLastError(),
                rgchLibraryFile );
    }
    
    /* validate the result */
    if( detachCount2 != (detachCount1 + 1) )
    {
        Fail( "FAIL: unexpected DLL detach count %d, expected %d\n",
                detachCount2,
                (detachCount1 + 1) );
    }
    
    
    /* terminate the PAL */
    PAL_Terminate();
    
    /* return success */
    return PASS; 
}
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:test3.c


示例2: main


//.........这里部分代码省略.........
                  "buffer capacity.\n");
            
            WaitForClientThreadToFinish(hThreadClient);

            CloseThreadHandle(hThreadClient);

            CloseEventHandle(hThreadEvent);
            
            CloseEventHandle(hReadEvent);

             /* Do some cleanup */
            DoWSATestCleanup( testSockets,
                              numSockets );

            Fail("");
        }
        
        /* Increment bufferCounter to keep track of the number 
           of byte received */
        bufferCounter += wsaRecvOverlapped.InternalHigh;        
    }

    if(!WaitForClientThreadToFinish(hThreadClient))
    {
        /* Error waiting for the client thread */

        /* Error message generated in function */

        CloseThreadHandle(hThreadClient);
        
        CloseEventHandle(hThreadEvent);
        
        CloseEventHandle(hReadEvent);

        /* Do some cleanup */
        DoWSATestCleanup( testSockets,
                          numSockets );

        Fail("");
    }

    if(!CloseEventHandle(hThreadEvent)||
       !CloseThreadHandle(hThreadClient)||
       !CloseEventHandle(hReadEvent))
    {
        /* Do some cleanup */
        DoWSATestCleanup( testSockets,
                          numSockets );
        Fail("");
    }

    /* Expected number of bytes received is 127500 */
    if(bufferCounter!=127500)
    {        
        Trace("Server error: Invalid number of byte received from the client");

        /* Do some cleanup */
        DoWSATestCleanup( testSockets,
                          numSockets );

        Fail("");

        
    }

    /* verify that all data in the data array are as expected */
    pMyData=(unsigned char*)myData;
    for(i=0;i<bufferCounter;i++)
    {
        if(pMyData>&(myData[500][255]))
        {
            Trace("Server error: invalid access to array myData\n");                   

            /* Do some cleanup */
            DoWSATestCleanup( testSockets,
                              numSockets );
            Fail("");

        }

        if(*pMyData!=(i%255))
        {
            Trace("Server error: comparing received data at position %d"
                   " in data array",i);

            /* Do some cleanup */
            DoWSATestCleanup( testSockets,
                              numSockets );
            Fail("");
        }
        pMyData++;
    }
 
    /* Do some cleanup */
    DoWSATestCleanup( testSockets,
                      numSockets );

    PAL_Terminate();
    return PASS;
}
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:wsasendrecv3.c


示例3: main


//.........这里部分代码省略.........
    }

    /*Confirm that the WinSock DLL supports 2.2.*/
    if(LOBYTE( WsaData.wVersion ) != 2 ||
            HIBYTE( WsaData.wVersion ) != 2)
    {
        Trace("\nFailed to find a usable WinSock DLL!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
       }
        Fail("");
    }

    /*create a stream socket in AF_INET domain*/
    socketID = socket(AF_INET,SOCK_STREAM,0);

    if(INVALID_SOCKET == socketID)
    {
        Trace("\nFailed to call socket API to create a stream socket!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    /*prepare the sockaddr_in structure*/
    mySockaddr.sin_family = AF_INET;
    mySockaddr.sin_port = getRotorTestPort();
    mySockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
    memset( &(mySockaddr.sin_zero), 0, 8);

    /*connect to a stream server*/
    err = connect(socketID,(struct sockaddr *)&mySockaddr,
            sizeof(struct sockaddr));
    if(SOCKET_ERROR == err)
    {
        Trace("\nFailed to call connect API to connect a server!\n");
        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
        }
        Fail("");
    }


    err=sendto(socketID,data,nBuffer,0,(struct sockaddr *)&mySockaddr,
        sizeof(struct sockaddr));
    if(SOCKET_ERROR == err)
    {
        Trace("\nFailed to call sendto API to send data to a server!\n");
        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
            Fail(""); 
        }
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = closesocket(socketID);
    if(SOCKET_ERROR == err)
    {
        Trace("\nFailed to call closesocket API!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = WSACleanup();
    if(SOCKET_ERROR == err)
    {
        Fail("\nFailed to call WSACleanup API!\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:recvfrom_neg_client.c


示例4: main

int __cdecl main(int argc, char *argv[]) {

    /* Define some buffers needed for the function */
    char * pResultBuffer = NULL;
    int size = 0;
  
    /* A place to stash the returned values */
    int ReturnValueForLargeBuffer = 0;

    /*
     * Initialize the PAL and return FAILURE if this fails
     */

    if(0 != (PAL_Initialize(argc, argv)))
    {
        return FAIL;
    }
  
    /* Recieve and allocate the correct amount of memory for the buffer */
    size = ReturnValueForLargeBuffer = GetEnvironmentVariable("PATH",        
                                                              pResultBuffer,  
                                                              0);             
    pResultBuffer = malloc(size);
    if ( pResultBuffer == NULL )
     {
	Fail("ERROR: Failed to allocate memory for pResultBuffer pointer. "
	       "Can't properly exec test case without this.\n");
     }
  
  
    /* Normal case, PATH should fit into this buffer */
    ReturnValueForLargeBuffer = GetEnvironmentVariable("PATH",        
                                                       pResultBuffer,  
                                                       size);  
  
    /* Ensure that it returned a positive value */
    if(ReturnValueForLargeBuffer <= 0) 
    {
	free(pResultBuffer);

        Fail("The return was %d, which indicates that the function failed.\n",
             ReturnValueForLargeBuffer);  
    }

    /* Ensure that it succeeded and copied the correct number of characters.
       If this is true, then the return value should be one less of the size of 
       the buffer.  (Doesn't include that NULL byte)
    */

    if(ReturnValueForLargeBuffer != size-1) 
    {
	free(pResultBuffer);

        Fail("The value returned was %d when it should have been %d.  "
             "This should be the number of characters copied, minus the "
             "NULL byte.\n",ReturnValueForLargeBuffer, size-1);  
    }
  
  
    free(pResultBuffer);
    
    PAL_Terminate();
    return PASS;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:64,代码来源:test.c


示例5: main

int __cdecl main(int argc, char *argv[])
{
    int err;
    WCHAR *wpBuffer = NULL;
    char *pChar = NULL;
    unsigned long ul = 1234567890UL;
    char *pChar10 = "1234567890";
    char *pChar2 = "1001001100101100000001011010010";
    char *pChar16 = "499602d2";

    /*Initialize the PAL environment*/
    err = PAL_Initialize(argc, argv);
    if(0 != err)
    {
        return FAIL;
    }

    wpBuffer = malloc(64 * sizeof(WCHAR));
    if(NULL == wpBuffer)
    {
        Fail("\nFail to allocate the buffer to save a converted "
                "wide character string, error code=%d!\n",
                GetLastError());
    }

    /*convert to a 10 base string*/
    _ui64tow(ul, wpBuffer, 10);
    pChar = convertC(wpBuffer);
    if(strcmp(pChar10, pChar))
    {
        free(wpBuffer);
        free(pChar);
        Fail("\nFailed to call _ui64tow API to convert an interger "
                "to a 10 base wide character string, error code=%d\n",
                GetLastError()); 
    }
    free(pChar);
    free(wpBuffer);    

    wpBuffer = malloc(64 * sizeof(WCHAR));
    if(NULL == wpBuffer)
    {
        Fail("\nFail to allocate the buffer to save a converted "
                "wide character string, error code=%d!\n",
                GetLastError());
    }
    
    /*convert to a 16 base string*/
    _ui64tow(ul, wpBuffer, 16);
    pChar = convertC(wpBuffer);
    if(strcmp(pChar16, pChar))
    {
        free(wpBuffer);
        free(pChar);
        Fail("\nFailed to call _ui64tow API to convert an interger "
                "to a 16 base wide character string, error code = %d\n",
                GetLastError()); 
    }
    free(pChar);
    free(wpBuffer);    

    wpBuffer = malloc(64 * sizeof(WCHAR));
    if(NULL == wpBuffer)
    {
        Fail("\nFail to allocate the buffer to save a converted "
                "wide character string, error code=%d!\n",
                GetLastError());
    }
    /*convert to a 2 base string*/
    _ui64tow(ul, wpBuffer, 2);
    pChar = convertC(wpBuffer);
    if(strcmp(pChar2, pChar))
    {
        free(wpBuffer);
        free(pChar);
        Fail("\nFailed to call _ui64tow API to convert an interger "
                "to a 2 base wide character string, error code=%d\n",
                GetLastError()); 
    }
    free(pChar);
    free(wpBuffer);
   
    PAL_Terminate();
    return PASS;
}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:85,代码来源:_ui64tow.c


示例6: main

int __cdecl main(int argc, char *argv[])
{

    HANDLE FileHandle;
    HANDLE FileMappingHandle;
    int err;
    WCHAR *lpFileName = NULL;

    //Initialize the PAL environment
    err = PAL_Initialize(argc, argv);
    if(0 != err)
    {
        ExitProcess(FAIL);
    }

    //conver string to a unicode one
    lpFileName = convert("temp.txt");


    //create a file and return the file handle
    FileHandle = CreateFile(lpFileName,
        GENERIC_READ,
        FILE_SHARE_READ,
        NULL,
        CREATE_ALWAYS,
        FILE_ATTRIBUTE_ARCHIVE,
        NULL);

    //free this memory
    free(lpFileName);
   
    if(INVALID_HANDLE_VALUE == FileHandle)
    {
        Fail("Failed to call CreateFile to create a file\n");
    }

    //create a unnamed file-mapping object with file handle FileHandle
    //and with PAGE_READONLY protection
    //try to map a file which is zero length.
    FileMappingHandle = CreateFileMapping(
        FileHandle,         //File Handle
        NULL,               //not inherited
        PAGE_READONLY,      //access protection 
        0,                  //high-order of object size
        0,                  //low-orger of object size
        NULL);              //unnamed object


    if(NULL != FileMappingHandle || ERROR_FILE_INVALID != GetLastError()) 
    {//no error occured 
        Trace("\nFailed to call CreateFileMapping API for a negative test!\n");
        err = CloseHandle(FileHandle);
        if(0 == err)
        {
            Fail("\nFailed to call CloseHandle API\n");
        }
        err = CloseHandle(FileMappingHandle);
        if(0 == err)
        {
            Fail("\nFailed to call CloseHandle API\n");
        }
        Fail("");
    }
    
    //close the file handle
    err = CloseHandle(FileHandle);
    if(0 == err)
    {
        Fail("\nFailed to call CloseHandle API\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:74,代码来源:CreateFileMapping_neg.c


示例7: main

int __cdecl main(int argc, char **argv)
{
    HANDLE  hReadPipe   = NULL;
    HANDLE  hWritePipe  = NULL;
    BOOL    bRetVal     = FALSE;
    DWORD   dwFileType;
    SECURITY_ATTRIBUTES lpPipeAttributes;

    /*Initialize the PAL*/
    if ((PAL_Initialize(argc, argv)) != 0)
    {
        return (FAIL);
    }

    /*
    ** create a pipe and make sure GetFileType returns the correct value
    */

    /*Setup SECURITY_ATTRIBUTES structure for CreatePipe*/
    lpPipeAttributes.nLength              = sizeof(lpPipeAttributes); 
    lpPipeAttributes.lpSecurityDescriptor = NULL; 
    lpPipeAttributes.bInheritHandle       = TRUE; 

    /*Create a Pipe*/
    bRetVal = CreatePipe(&hReadPipe,      /* read handle*/
                &hWritePipe,              /* write handle */
                &lpPipeAttributes,        /* security attributes*/
                0);                       /* pipe size*/
    if (bRetVal == FALSE)
    {
        Fail("ERROR: %u :Unable to create pipe.\n", GetLastError());
    }

    // Get the file type
    dwFileType = GetFileType(hReadPipe);
    if (dwFileType != FILE_TYPE_PIPE)
    {
        if (!CloseHandle(hWritePipe))
        {
            Trace("ERROR: %u : Unable to close write pipe handle "
                "hWritePipe=0x%lx\n", GetLastError(), hWritePipe);
        }
        if (!CloseHandle(hReadPipe))
        {
            Trace("ERROR: %u : Unable to close read pipe handle "
                "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
        }
        Fail("ERROR: GetFileType returned %u for a pipe instead of the "
            "expected FILE_TYPE_PIPE (%u).\n",
            dwFileType,
            FILE_TYPE_PIPE);
    }

    /*Close write pipe handle*/
    if (!CloseHandle(hWritePipe))
    {
        if (!CloseHandle(hReadPipe))
        {
            Trace("ERROR: %u : Unable to close read pipe handle "
                "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
        }
        Fail("ERROR: %u : Unable to close write pipe handle "
             "hWritePipe=0x%lx\n", GetLastError(), hWritePipe);
    }

    /*Close Read pipe handle*/
    if (!CloseHandle(hReadPipe))
    {
        Fail("ERROR: %u : Unable to close read pipe handle "
             "hReadPipe=0x%lx\n", GetLastError(), hReadPipe);
    }

    PAL_Terminate();
    return (PASS);
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:75,代码来源:getfiletype.c


示例8: main

int __cdecl main(int argc, char *argv[]) {

    int childPid = -1, childStdinFd = -1, childStdoutFd = -1, childStderrFd = -1;
    FILE *childStdin = NULL, *childStdout = NULL, *childStderr = NULL;
    char* childArgv[3] = { argv[0], "child", NULL };
    int c = 0;

    // Initialize the PAL and return FAILURE if this fails
    if ((PAL_Initialize(argc, argv)) != 0)
    {
        return FAIL;
    }

    // If this is the child process, it'll have an argument.
    if (argc > 1)
    {
        // This is the child.  Receive 'a' from the parent,
        // then send back 'b' on stdout and 'c' on stderr.
        if ((c = getc(stdin)) == EOF ||
            c != 'a' ||
            fputc('b', stdout) == EOF ||
            fflush(stdout) != 0 ||
            fputc('c', stderr) == EOF ||
            fflush(stdout) != 0)
        {
            Fail("Error: Child process failed");
        }
        goto done;
    }

    // Now fork/exec the child process, with the same executable but an extra argument
    if (ForkAndExecProcess(argv[0], childArgv, environ, NULL,
                           1, 1, 1,
                           &childPid, &childStdinFd, &childStdoutFd, &childStderrFd) != 0)
    {
        Fail("Error: ForkAndExecProces failed with errno %d (%s)\n", errno, strerror(errno));
    }
    if (childPid < 0 || childStdinFd < 0 || childStdoutFd < 0 || childStderrFd < 0)
    {
        Fail("Error: ForkAndExecProcess returned childpid=%d, stdinFd=%d, stdoutFd=%d, stderrFd=%d", 
            childPid, childStdinFd, childStdoutFd, childStderrFd);
    }

    // Open files for the child's redirected stdin, stdout, and stderr
    if ((childStdin = _fdopen(childStdinFd, "w")) == NULL ||
        (childStdout = _fdopen(childStdoutFd, "r")) == NULL ||
        (childStderr = _fdopen(childStderrFd, "r")) == NULL)
    {
        Fail("Error: Opening FILE* for stdin, stdout, or stderr resulted in errno %d (%s)", 
            errno, strerror(errno));
    }

    // Send 'a' to the child
    if (fputc('a', childStdin) == EOF ||
        fflush(childStdin) != 0)
    {
        Fail("Writing to the child process failed with errno %d (%s)", errno, strerror(errno));
    }

    // Then receive 'b' from the child's stdout, then 'c' from stderr
    if ((c = getc(childStdout)) != 'b')
    {
        Fail("Received '%c' from child's stdout; expected 'b'", c);
    }
    if ((c = getc(childStderr)) != 'c')
    {
        Fail("Received '%c' from child's stderr; expected 'c'", c);
    }

done:
    PAL_Terminate();
    return PASS;
}
开发者ID:Afshintm,项目名称:coreclr,代码行数:73,代码来源:test.c


示例9: main


//.........这里部分代码省略.........

    if(DeleteFileA(sBadFilePath))

    {

        Trace("DeleteFileA: Call to DeleteFileA to delete a file"

            " that does not exist succeeded\n");

        testPass = FALSE;



    }

    else

    {

        if(GetLastError() != ERROR_PATH_NOT_FOUND)

        {

            Trace("DeleteFileA: Call GetLastError() returned [%u]"

                " while it should return ERROR_PATH_NOT_FOUND [%u]\n",

                GetLastError(),ERROR_FILE_NOT_FOUND);

            testPass = FALSE;



        }



    }



    /* test with an invalid file name */

    if(DeleteFileA(sBadFileName))

    {

        Trace("DeleteFileA: Call to DeleteFileA to delete a file"

            " that does not exist succeeded\n");

        testPass = FALSE;



    }

    else

    {

        if(GetLastError() != ERROR_FILE_NOT_FOUND)

        {

            Trace("DeleteFileA: Call GetLastError() returned [%u]"

                " while it should return ERROR_FILE_NOT_FOUND [%u]\n",

                GetLastError(),ERROR_FILE_NOT_FOUND);

            testPass = FALSE;



        }



    }



  



    if(! testPass)

    {

        Fail("");

    }

    PAL_Terminate();

    return PASS;

}
开发者ID:0-wiz-0,项目名称:coreclr,代码行数:101,代码来源:test1.cpp


示例10: main

int __cdecl main(int argc, char **argv)
{

    FILETIME UTCTime, LocalTime;
    ULONG64 FullFileTime, FullLocalTime, CorrectTime;
    TIME_ZONE_INFORMATION ZoneInfo;
    int DeltaBetweenLocalAndUTC;
    int result;

    if (0 != PAL_Initialize(argc,argv))
    {
        return FAIL;
    }

    /* This is a valid UTC file time generated with GetFileTime */
    UTCTime.dwLowDateTime = 1867954880;
    UTCTime.dwHighDateTime = 29437095;
  
    /* Call the function */
    result = FileTimeToLocalFileTime(&UTCTime,&LocalTime);
  
    if(result == 0) 
    {
        Fail("ERROR: FileTimeToLocalTime has returned zero, which "
               "indicates that it failed.");
    }

    /* We need to get the time zone that the user is running in. */
    result = GetTimeZoneInformation(&ZoneInfo);

    /* Use the Time Zone Information to construct the delta between UTC
       and local time -- in hours.
    */
    
    if(result == TIME_ZONE_ID_STANDARD)
    {
        DeltaBetweenLocalAndUTC = 
            (ZoneInfo.Bias + ZoneInfo.StandardBias);  
    }
    else if (result == TIME_ZONE_ID_DAYLIGHT) 
    {
        DeltaBetweenLocalAndUTC = 
            (ZoneInfo.Bias + ZoneInfo.DaylightBias); 
    }
    else 
    {
        DeltaBetweenLocalAndUTC = (ZoneInfo.Bias);
    }
 
    /* Change the UTC and Local FILETIME structures into ULONG64 
       types 
    */
  
    FullFileTime = ((((ULONG64)UTCTime.dwHighDateTime)<<32) | 
                    ((ULONG64)UTCTime.dwLowDateTime));
  
    FullLocalTime = ((((ULONG64)LocalTime.dwHighDateTime)<<32) | 
                     ((ULONG64)LocalTime.dwLowDateTime));

    /* This magic number is 10000000 * 60 * 60 -- which is the
       number of 100s of Nanseconds in a second, multiplied by the number
       of seconds in a minute, multiplied by the number of minutes in an
       hour.
     
       The correct time is the delta in hundreds of nanoseconds between
       Local and UTC times.
    */
  
    CorrectTime = 600000000 * ((ULONG64)DeltaBetweenLocalAndUTC);
  
    /* Now check to ensure that the difference between the Local and UTC
       times that was calculated with the function equals what it should be.
    */
    if((FullFileTime - FullLocalTime) != CorrectTime)
    {
        Fail("ERROR: The LocalFileTime that was returned is not equal to "
               "what the LocalFileTime should have been.");
    } 
  
    PAL_Terminate();
    return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:82,代码来源:filetimetolocalfiletime.c


示例11: main


//.........这里部分代码省略.........
    {
        Fail("\nFailed to find a usable WinSock DLL!\n");
    }

    /*Confirm that the WinSock DLL supports 2.2.*/
    if(LOBYTE( WsaData.wVersion ) != 2 ||
            HIBYTE( WsaData.wVersion ) != 2)
    {
        Trace("\nFailed to find a usable WinSock DLL!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
       }
        Fail("");
    }

    /*create a datagram socket in AF_INET domain*/
    socketID = socket(AF_INET, SOCK_DGRAM, 0);

    if(INVALID_SOCKET == socketID)
    {
        Trace("\nFailed to call socket API to create a datagram socket!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    /*set the socket as non-blocking*/
    err = ioctlsocket(socketID, FIONBIO, &argp);
    if(SOCKET_ERROR == err)
    {
        Trace("\nFailed to call ioctlsocket API to set "
            "non-blocking socket!\n");

        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
        }
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    /*prepare the sockaddr_in structure*/
    mySockaddr.sin_family = AF_INET;
    mySockaddr.sin_port = getRotorTestPort();
    mySockaddr.sin_addr.S_un.S_addr = inet_addr("127.0.0.1");
    memset(&(mySockaddr.sin_zero), 0, 8);
    nLength = sizeof(struct sockaddr);

    memset(data,0,BUFFERSIZE);
    /*receive data from this socket which is not bound*/
    err = recvfrom(socketID, data, BUFFERSIZE, 0,
            (struct sockaddr*)&mySockaddr,&nLength);
    if(WSAEINVAL != GetLastError() || SOCKET_ERROR != err)
    {
        Trace("\nFailed to call recvfrom API for a negative test "
            "with an unbound socket!\n");
        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
        }
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = closesocket(socketID);
    if(SOCKET_ERROR == err)
    {
        Trace("\nFailed to call closesocket API!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = WSACleanup();
    if(SOCKET_ERROR == err)
    {
        Fail("\nFailed to call WSACleanup API!\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:ArildF,项目名称:masters,代码行数:101,代码来源:recvfrom_neg_server.c


示例12: main


//.........这里部分代码省略.........
    SecondCreationTime = ( (((ULONG64)Creation.dwHighDateTime)<<32) | 
                           ((ULONG64)Creation.dwLowDateTime));
  
    SecondWrite = ( (((ULONG64)LastWrite.dwHighDateTime)<<32) | 
                    ((ULONG64)LastWrite.dwLowDateTime));
  
    SecondAccess = ((((ULONG64)LastAccess.dwHighDateTime)<<32) | 
                    ((ULONG64)LastAccess.dwLowDateTime));

  
    /* Now -- to test.  We'll ensure that the Second
       LastWrite and access times are larger than the first.
       It tells us that time is passing, which is good! 
    */

    if(FirstWrite >= SecondWrite) 
    {
        /* Close the File */
        if(!CloseHandle(hFile)) 
        {
            Trace("ERROR: Failed to close the file handle. "
                "GetLastError returned %u.\n", 
                GetLastError());
        }
        Fail("ERROR: The write-file-time (%I64d) after the first flush "
            "should be less than the write-file-time (%I64d) after the second "
               "flush.\n",
               FirstWrite, 
               LastWrite);

    }

    
    if(SecondAccess < FirstAccess) 
    {
        /* Close the File */
        if(!CloseHandle(hFile)) 
        {
            Trace("ERROR: Failed to close the file handle. "
                "GetLastError returned %u.\n", 
                GetLastError());
        }
        Fail("ERROR: The access-file-time (%I64d) after the first flush "
            "should be less than or equal to the access-file-time (%I64d) "
               "after the second flush.\n",
               FirstAccess, 
               LastAccess);
    }

#if WIN32
    /* Then we can check to make sure that the creation time
       hasn't changed.  This should always stay the same.
    */
    
    if(FirstCreationTime != SecondCreationTime) 
    {
        /* Close the File */
        if(!CloseHandle(hFile)) 
        {
            Trace("ERROR: Failed to close the file handle. "
                "GetLastError returned %u.\n", 
                GetLastError());
        }
        Fail("ERROR: The creation time after writing should not "
               "not change from the original.  The second value should be "
               "equal.\n");
    }
#else
    /* Then we can check to make sure that the creation time
       has changed.  Under FreeBSD it changes whenever the file is
       access or written.
    */
    
    if(FirstCreationTime >= SecondCreationTime) 
    {
        /* Close the File */
        if(!CloseHandle(hFile)) 
        {
            Trace("ERROR: Failed to close the file handle. "
                "GetLastError returned %u.\n", 
                GetLastError());
        }
        Fail("ERROR: The creation time after writing should be "
               "greater than the original.  The second value should be "
               "larger.\n");
    }
    
#endif
    
    /* Close the File */
    if(!CloseHandle(hFile)) 
    {
        Fail("ERROR: Failed to close the file handle. "
            "GetLastError returned %u.\n", 
            GetLastError());
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:101,代码来源:getfiletime.c


示例13: main


//.........这里部分代码省略.........
        if (!bRc)
        {
            Trace("CreateDirectoryA: RemoveDirectoryW failed to remove "
                "\"%s\" with the error code %ld.\n",
                szDirName,
                GetLastError());
        }
        Fail("CreateDirectoryA: Failed because it created a directory"
            " name 1 character longer (%d chars) than the max dir size "
            "allowed\n", 
            strlen(szDirName));
    }


    /* long directory name CREATE_MAX_PATH_SIZE + 3 chars including "..\" 
       (real path length <= CREATE_MAX_PATH_SIZE) */
    memset(szDirName, 0, buf_size);
    memset(szDirName, 'a', CREATE_MAX_PATH_SIZE + 3 - 1 - curDirLen);
    szDirName[0] = '.';
    szDirName[1] = '.';
    szDirName[2] = '\\';
    bRc = CreateDirectoryA(szDirName, NULL);
    if (bRc == FALSE)
    {
        Fail("CreateDirectoryA: Failed to create a directory name more "
            "than %d chars long and its real path name is less "
            "than %d chars, error %u\n",
            CREATE_MAX_PATH_SIZE,
            CREATE_MAX_PATH_SIZE, GetLastError());
    }
    else
    {
        /* Check to see if it's possible to navigate to directory */
        GetCurrentDirectoryA(curDirectory, buffer);
        bSuccess = SetCurrentDirectoryA(szDirName);
        if(!bSuccess)
        {
            Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
                "navigate to the newly created directory with error "
                "code %u.\n", GetLastError());
        }

        /* set directory back to initial directory */
        SetCurrentDirectoryA(buffer);

        pTemp = convert(szDirName);
        bRc = RemoveDirectoryW(pTemp);
        free(pTemp);
        if (!bRc)
        {
            Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
                " \"%s\" with the error code %ld.\n",
                szDirName,
                GetLastError());
        }
    }


    /* directories with dots  */
    memset(szDirName, 0, buf_size);
    sprintf(szDirName, szDotDir);
    bRc = CreateDirectoryA(szDirName, NULL);
    if (bRc == FALSE)
    {
        Fail("CreateDirectoryA: Failed to create \"%s\" with error code %ld\n",
            szDotDir,
            GetLastError());
    }
    else
    {
        
        /* Check to see if it's possible to navigate to directory */
        GetCurrentDirectoryA(curDirectory, buffer);
        bSuccess = SetCurrentDirectoryA(szDirName);
        if(!bSuccess)
        {
            Fail("CreateDirectoryA: SetCurrentDirectoryA failed to "
                "navigate to the newly created directory with error "
                "code %u.\n", GetLastError());
        }

        /* set directory back to initial directory */
        SetCurrentDirectoryA(buffer);
        
        pTemp = convert((LPSTR)szDotDir);
        bRc = RemoveDirectoryW(pTemp);
        free(pTemp);
        if (!bRc)
        {
            Fail("CreateDirectoryA: RemoveDirectoryW failed to remove "
                " \"%s\" with the error code %ld.\n",
                szDotDir,
                GetLastError());
        }
    }


    PAL_Terminate();  
    return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:101,代码来源:createdirectorya.c


示例14: main


//.........这里部分代码省略.........

    if(0 != (PAL_Initialize(argc, argv)))
    {
        return FAIL;
    }
  
    /* Set the first environment variable */
    bRc = SetEnvironmentVariableW(FirstEnvironmentVariable,
                            FirstEnvironmentValue);

    if(!bRc)
    {
        Fail("ERROR: SetEnvironmentVariable failed to set a "
            "proper environment variable with error %u.\n", GetLastError());
    }

    /* Normal case, PATH should fit into this buffer */
    size = GetEnvironmentVariableW(FirstEnvironmentVariable,        
                                  pResultBuffer,    
                                  0);                 

    /* To account for the nul character at the end of the string */
    size = size + 1;
    
    pResultBuffer = malloc(sizeof(WCHAR)*size);
    if ( pResultBuffer == NULL )
    {
	    Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n");
    }

    /* Try to retrieve the value of the first environment variable */
    GetEnvironmentVariableW(FirstEnvironmentVariable,
                           pResultBuffer,
                           size);

    if ( pResultBuffer == NULL )
    {
	    free(pResultBuffer);
        Fail("ERROR: GetEnvironmentVariable failed to return a value "
            "from a proper environment variable with error %u.\n",
            GetLastError());
    }

    /* Compare the strings to see that the correct variable was returned */
    if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0)
    {
        free(pResultBuffer);    
        Fail("ERROR: The value in the buffer should have been '%S' but "
             "was really '%S'.\n",FirstEnvironmentValue, pResultBuffer);          
    }

    free(pResultBuffer);

    /* Set the second environment Variable */
    bRc = SetEnvironmentVariableW(SecondEnvironmentVariable,
                            SecondEnvironmentValue);

    if(!bRc)
    {
        Fail("ERROR: SetEnvironmentVariable failed to set a "
            "proper environment variable with error %u.\n",
            GetLastError());
    }

    /* Reallocate the memory for the string */
    pResultBuffer = malloc(sizeof(WCHAR)*size);
    if ( pResultBuffer == NULL )
    {
	    Fail("ERROR: Failed to allocate memory for pResultBuffer pointer.\n");
    }

    /* Try retrieving the value of the first variable, even though the
    second variable has the same spelling and only differs in case */
    GetEnvironmentVariableW(FirstEnvironmentVariable,
                           pResultBuffer,
                           size);

    if ( pResultBuffer == NULL )
    {
	    free(pResultBuffer);
        Fail("ERROR: GetEnvironmentVariable failed to return a value "
            "from a proper environment variable with error %u.\n",
            GetLastError());
    }

    /* Compare the two strings to confirm that the right value is returned */
    if(wcsncmp(pResultBuffer,FirstEnvironmentValue,wcslen(pResultBuffer)) != 0) 
    {
        free(pResultBuffer);    
        Fail("ERROR: The value in the buffer should have been '%S' but "
             "was really '%S'.\n",FirstEnvironmentValue,pResultBuffer);          
    }
  
    free(pResultBuffer);
    
    PAL_Terminate();
    return PASS;

#endif
}
开发者ID:smartmaster,项目名称:sscli,代码行数:101,代码来源:test5.c


示例15: main


//.........这里部分代码省略.........
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
            Fail("");
        }
        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
            Fail("");
        }
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    nLength = sizeof(struct sockaddr);
    /*retrive data with specified MSG_OOB*/
    err = recvfrom(aSocket,data,BUFFERSIZE,MSG_OOB,
            (struct sockaddr*)&mySockaddr,&nLength);
    if(WSAEINVAL != GetLastError() || SOCKET_ERROR != err)
    {
        Trace("\nFailed to call recvfrom API for a negative test "
                "with MSG_OOB flag!\n");
        err = closesocket(aSocket);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
            Fail("");
        }
        err = closesocket(socketID);
        if(SOCKET_ERROR == err)
        {    
            Trace("\nFailed to call closesocket API!\n");
            err = WSACleanup();
            if(SOCKET_ERROR == err)
            {
                Trace("\nFailed to call WSACleanup API!\n");
            }
            Fail("");
        }
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = closesocket(aSocket);
    if(SOCKET_ERROR == err)
    {    
        Trace("\nFailed to call closesocket API!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = closesocket(socketID);
    if(SOCKET_ERROR == err)
    {    
        Trace("\nFailed to call closesocket API!\n");
        err = WSACleanup();
        if(SOCKET_ERROR == err)
        {
            Trace("\nFailed to call WSACleanup API!\n");
        }
        Fail("");
    }

    err = WSACleanup();
    if(SOCKET_ERROR == err)
    {
        Fail("\nFailed to call WSACleanup API!\n");
    }

    PAL_Terminate();
    return PASS;
}
开发者ID:smartmaster,项目名称:sscli,代码行数:101,代码来源:recvfrom_neg_server.c


示例16: main


//.........这里部分代码省略.........
    {
        free(szTemp);
        Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to "
            "\"non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError());
    }

    /* Get the directory full path so it is easy to get back
       to it later */
    if( 0 == GetCurrentDirectoryA(MAX_PATH, szwSubDir) )
    {
        free(szTemp);
        Fail("Error[%ul]:RemoveDirectoryA: Failed to get current directory "
            "with GetCurrentDirectoryA.\n", GetLastError());
    }

    /* Create sub_dir */
    sprintf (szDirName, "sub_dir");
    szTemp2 = (char *) malloc (sizeof(szDirName));
    szTemp2 = strncpy(szTemp2, szDirName, strlen(szDirName) + 1);
    bRc = CreateDirectoryA(szTemp2, NULL);
    if (bRc != TRUE)
    {
        free(szTemp);
        free(szTemp2);
        Fail("Error[%ul]:RemoveDirectoryA: Failed to create the directory "
            "\"sub_dir\" when it exists already.\n", GetLastError());
    }

    /* Set the current dir to the parent of non_empty_dir/sub_dir */
    if( 0 == SetCurrentDirectoryA(szwCurrentDir) )
    {
        free(szTemp);
        free(szTemp2);
        Fail("Error[%ul]:RemoveDirectoryA: Failed to set current directory to "
            "\"non_empty_dir\" with SetCurrentDirectoryA.\n", GetLastError());
    }

    /* Try to remove non_empty_dir (shouldn't work) */
    bRc = RemoveDirectoryA(szTemp);
    if (bRc == TRUE)
    {
        free(szTemp);
        free(szTemp2);
        Fail("Error[%ul]:RemoveDirectoryA: shouldn't have been able to r 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PAL_XY函数代码示例发布时间:2022-05-30
下一篇:
C++ PAL_MODE_ALTERNATE函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap