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

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

?? misc.c

?? FAT文件系統源代碼
?? C
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// This source code is licensed under Microsoft Shared Source License
// Version 1.0 for Windows CE.
// For a copy of the license visit http://go.microsoft.com/fwlink/?LinkId=3223.
//
/*++


Module Name:

    misc.c

Abstract:

    This file contains miscellaneous routines.

Revision History:

--*/

#include "fatfs.h"


#ifndef _PREFAST_
#pragma warning(disable: 4068) // Disable pragma warnings
#endif
// 計算傳入參數n應該是2的多少次冪,即2^x=n,返回值為n
int Log2(unsigned int n)
{
    int l;

    if ((n & n-1) != 0)
        return -1;              // n is not a power of 2
    for (l = -1 ; n ; ++l)
        n >>= 1;
    return l;
}


void InitList(PDLINK pdl)
{
    pdl->next = pdl->prev = pdl;
}


int ListIsEmpty(PDLINK pdl)
{
    return pdl->next == pdl;
}


void AddItem(PDLINK pdlIns, PDLINK pdlNew)
{
    pdlNew->prev = pdlIns;
    (pdlNew->next = pdlIns->next)->prev = pdlNew;
    pdlIns->next = pdlNew;
}


void RemoveItem(PDLINK pdl)
{
    pdl->prev->next = pdl->next;
    pdl->next->prev = pdl->prev;
}


/*  pchtoi - convert decimal string to integer
 *
 *  ENTRY
 *      pch - pointer to CHAR (not WCHAR or TCHAR) array
 *      cch - number of characters required (0 if any number allowed)
 *
 *  EXIT
 *      value of number, -1 if error (numbers < 0 are not supported)
 */

int pchtoi(PCHAR pch, int cch)
{
    int i = 0;

    while (TRUE) {
        if (*pch < '0' || *pch > '9')
            break;
        i = i * 10 + (*pch++ - '0');
        if (cch) {
            if (--cch == 0)
                break;
        }
    }
    if (cch)
        i = -1;
    return i;
}


/*  itopch - convert integer to decimal string
 *
 *  ENTRY
 *      i - integer to convert (numbers < 0 or > 9999 are not supported)
 *      pch - pointer to CHAR (not WCHAR or TCHAR) array
 *
 *  EXIT
 *      number of characters in string; note the string is NOT null-terminated
 */
#pragma prefast(disable: 394, "Private implementation for not null-terminated string.")
int itopch(int i, PCHAR pch)
{
    int c, q;
    CONST int *piDiv;
    static CONST int iDiv[] = {10000,1000,100,10,1};

    c = 0;      // total number of digits output
    if (i >= 0 && i < iDiv[0]) {
        piDiv = &iDiv[1];
        do {
            if (c != 0 || *piDiv == 1 || i >= *piDiv) {
                q = i / (*piDiv);
                *pch++ = '0' + q;
                i -= q * (*piDiv);
                c++;
            }
        } while (*piDiv++ != 1);
    }
    return c;
}
#pragma prefast(pop)        


/*  SetBitArray - set bit in bit array
 *
 *  ENTRY
 *      pdwBitArray - pointer to bit array
 *      i - 0-based position of bit to set (i is range-checked)
 *
 *  EXIT
 *      None
 *
 *  NOTES
 *      Bit arrays start with two special DWORDs that are not part of
 *      of the actual array of bits.  The first DWORD is initialized to
 *      the number of bits that can be held, and the second DWORD keeps track
 *      of the total number of SET bits.
 *
 *      You can either allocate and initialize the bit array yourself, or
 *      call CreateBitArray;  the latter is a macro in FATFS.H that creates a
 *      temporary array that's automatically freed upon leaving the current
 *      scope.
 */

void SetBitArray(PDWORD pdwBitArray, int i)
{
    DWORD mask;
    PDWORD pdw;

    if (i >= 0 && (DWORD)i < pdwBitArray[0]) {

        mask = 1 << (i % 32);
        pdw = pdwBitArray + i/32+2;

        if ((*pdw & mask) == 0)
            pdwBitArray[1]++;

        *pdw |= mask;
    }
}


#ifdef LATER    // no one needs this function yet -JTP

/*  ClearBitArray - clear bit in bit array
 *
 *  ENTRY
 *      pdwBitArray - pointer to bit array
 *      i - 0-based position of bit to clear (i is range-checked)
 *
 *  EXIT
 *      None
 *
 *  NOTES
 *      Bit arrays start with two special DWORDs that are not part of
 *      of the actual array of bits.  The first DWORD is initialized to
 *      the number of bits that can be held, and the second DWORD keeps track
 *      of the total number of SET bits.
 *
 *      You can either allocate and initialize the bit array yourself, or
 *      call CreateBitArray;  the latter is a macro in FATFS.H that creates a
 *      temporary array that's automatically freed upon leaving the current
 *      scope.
 */

void ClearBitArray(PDWORD pdwBitArray, int i)
{
    DWORD mask;
    PDWORD pdw;

    if (i >= 0 && (DWORD)i < pdwBitArray[0]) {

        mask = 1 << (i % 32);
        pdw = pdwBitArray + i/32+2;

        if ((*pdw & mask) != 0) {
            ASSERT(pdwBitArray[1] != 0);
            pdwBitArray[1]--;
        }

        *pdw &= ~mask;
    }
}

#endif


/*  TestBitArray - test bit in bit array
 *
 *  ENTRY
 *      pdwBitArray - pointer to bit array
 *      i - 0-based position of bit to test (i is range-checked)
 *
 *  EXIT
 *      TRUE if bit is set, FALSE if bit is not set
 *
 *  NOTES
 *      Bit arrays start with two special DWORDs that are not part of
 *      of the actual array of bits.  The first DWORD is initialized to
 *      the number of bits that can be held, and the second DWORD keeps track
 *      of the total number of SET bits.
 *
 *      You can either allocate and initialize the bit array yourself, or
 *      call CreateBitArray;  the latter is a macro in FATFS.H that creates a
 *      temporary array that's automatically freed upon leaving the current
 *      scope.
 */

BOOL TestBitArray(PDWORD pdwBitArray, int i)
{
    ASSERT(i >= 0 && (DWORD)i < pdwBitArray[0]);

    return i >= 0 && (DWORD)i < pdwBitArray[0]?
        (pdwBitArray[i/32+2] & (1 << (i % 32))) != 0 : FALSE;
}


/*  DOSTimeToFileTime - convert DOS format time to NT FILETIME
 *
 *  FAT files use a bit-packed date & time format versus NT's 64bit integer
 *  time format.
 *
 *  DOS Date format: YYYY YYYM MMMD DDDD (Year since 1980, Month, Day of month)
 *  DOS Time format: HHHH HMMM MMMS SSSS (Hour, Minute, Seconds/2 (0-29))
 *
 *  ENTRY
 *      dosDate - date in DOS bitpacked format
 *      dosTime - time in DOS bitpacked format
 *      tenMSec - milliseconds / 10
 *      pft - pointer to FILETIME structure to fill in
 *
 *  EXIT
 *      TRUE if successful, FALSE if error
 */

BOOL DOSTimeToFileTime(WORD dosDate, WORD dosTime, BYTE tenMSec, PFILETIME pft)
{
    FILETIME ft;
    SYSTEMTIME st;
    WORD wMSec = tenMSec * 10;

    st.wYear = (dosDate >> 9) + 1980;
    st.wMonth = (dosDate >> 5) & 0xf;
    st.wDayOfWeek = 0;
    st.wDay = dosDate & 0x1f;
    st.wHour = dosTime >> 11;
    st.wMinute = (dosTime >> 5) & 0x3f;
    st.wSecond = (dosTime & 0x1f) << 1;

    // The ms field can range from 0 - 1999 ms inclusive.  
    // Use if statements to avoid expensive division operation.
    if (wMSec >= 2000) {
        DEBUGMSG(ZONE_ERRORS,(DBGTEXT("FATFS!DOSTimeToFileTime failed: invalid milliseconds value: %d.\r\n"), wMSec));
        return FALSE;
    } else if (wMSec >= 1000) {
        st.wSecond++;
        st.wMilliseconds = wMSec - 1000;            
    } else {
        st.wMilliseconds = wMSec;
    }

    DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!DOSTimeToFileTime: local file system time: y=%d,m=%d,d=%d,h=%d,m=%d,s=%d\r\n"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond));
    if (SystemTimeToFileTime(&st, &ft)) {

        DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!DOSTimeToFileTime: local file time: %08x,%08x\r\n"), ft.dwLowDateTime, ft.dwHighDateTime));
        if (LocalFileTimeToFileTime(&ft, pft)) {

            DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!DOSTimeToFileTime: file time: %08x,%08x\r\n"), pft->dwLowDateTime, pft->dwHighDateTime));
            return TRUE;
        }
    }
    return FALSE;
}


/*  FileTimeToDOSTime - convert NT FILETIME to DOS format time
 *
 *  FAT files use a bit-packed date & time format versus NT's 64bit integer
 *  time format.
 *
 *  DOS Date format: YYYY YYYM MMMD DDDD (Year since 1980, Month, Day of month)
 *  DOS Time format: HHHH HMMM MMMS SSSS (Hour, Minute, Seconds/2 (0-29))
 *
 *  ENTRY
 *      dosDate - date in DOS bitpacked format
 *      dosTime - time in DOS bitpacked format
 *      tenMSec - milliseconds / 10
 *      pft - pointer to FILETIME structure to fill in
 *
 *  EXIT
 *      TRUE if successful, FALSE if error
 */

BOOL FileTimeToDOSTime(PFILETIME pft, PWORD pdosDate, PWORD pdosTime, PBYTE ptenMSec)
{
    FILETIME ft;
    SYSTEMTIME st;

    ASSERT(pdosDate);

    DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!FileTimeToDOSTime: file time: %08x,%08x\r\n"), pft->dwLowDateTime, pft->dwHighDateTime));
    FileTimeToLocalFileTime(pft, &ft);

    DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!FileTimeToDOSTime: local file time: %08x,%08x\n"), ft.dwLowDateTime, ft.dwHighDateTime));
    FileTimeToSystemTime(&ft, &st);

    DEBUGMSG(ZONE_STREAMS && ZONE_LOGIO,(DBGTEXT("FATFS!FileTimeToDOSTime: local file system time: y=%d,m=%d,d=%d,h=%d,m=%d,s=%d\n"), st.wYear, st.wMonth, st.wDay, st.wHour, st.wMinute, st.wSecond));
    *pdosDate = ((st.wYear-1980) << 9) | (st.wMonth << 5) | (st.wDay);

    if (pdosTime)
        *pdosTime = (st.wHour << 11) | (st.wMinute << 5) | (st.wSecond >> 1);
    if (ptenMSec)
        *ptenMSec = (st.wMilliseconds / 10);

    return TRUE;
}


#ifdef OLD_IOCTLS       // defunct code

/*  SetSizePointer - update a SIZEPTR structure as appropriate
 *
 *  For consistency, certain APIs (like IOCTLs) pass us DWORD/PVOID pairs,
 *  where the DWORD represents the number of elements in an array, and the
 *  PVOID is the address of the array.  Furthermore, if the caller doesn't
 *  know how many elements are in the array yet, then the convention is for
 *  the caller to pass us a NULL PVOID, and we'll set the DWORD to the
 *  number of elements.  Then the caller can allocate the appropriate amount
 *  of memory and call us again with a non-NULL PVOID.
 *
 *  ENTRY
 *      psp - pointer to a DWORD/PVOID pair
 *      cb - size of each element in bytes
 *      c - count of elements
 *      pSrc - pointer to caller's buffer, NULL if none
 *      hproc - handle to caller's process, NULL if current process
 *
 *  EXIT
 *      None;  either the caller's PVOID buffer is filled in, or the DWORD
 *      size is filled in.  The calling function should have a try/except in
 *      place.
 */

void SetSizePointer(PSIZEPTR psp, DWORD cb, DWORD c, PVOID pSrc, HANDLE hProc)
{
    if (psp->p == NULL) {

        psp->c = c;             // just return number of elements to caller

    } else {

        PVOID pDst = psp->p;

        if (hProc)
            pDst = MapPtrToProcess(pDst, hProc);

        if (c > psp->c)         // if there are more elements than caller wants,
            c = psp->c;         // reduce it

        memcpy(pDst, pSrc, cb * c);
    }
}

#endif  // OLD_IOCTLS

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久久精品一品道一区| 免费观看成人鲁鲁鲁鲁鲁视频| 中文字幕亚洲在| 亚洲五码中文字幕| 国内外精品视频| 欧美人与z0zoxxxx视频| 国产亚洲综合色| 日韩激情在线观看| 91在线观看高清| 国产丝袜欧美中文另类| 午夜国产精品一区| 91玉足脚交白嫩脚丫在线播放| 精品乱码亚洲一区二区不卡| 亚洲乱码国产乱码精品精可以看| 久久av中文字幕片| 欧美裸体一区二区三区| 17c精品麻豆一区二区免费| 国产麻豆成人传媒免费观看| 欧美蜜桃一区二区三区| 亚洲三级小视频| 成人视屏免费看| 久久久久久久综合色一本| 青青草国产精品97视觉盛宴| 欧美最猛黑人xxxxx猛交| 中文字幕一区av| 成人午夜电影网站| 久久久久国产精品人| 久久精品国产亚洲5555| 欧美精品久久天天躁| 亚洲五码中文字幕| 欧美日韩中文字幕一区| 亚洲裸体在线观看| 色婷婷综合久久久| 亚洲欧美激情一区二区| 欧美在线|欧美| 夜夜嗨av一区二区三区网页 | 久久午夜国产精品| 欧美bbbbb| 日韩欧美一级在线播放| 蜜臀久久99精品久久久久宅男| 欧美精品久久久久久久多人混战 | 美女性感视频久久| 日韩欧美亚洲国产精品字幕久久久 | 欧美视频一区二区三区四区| 亚洲男人的天堂av| 在线欧美小视频| 亚洲成人午夜影院| 91精品国产综合久久小美女| 日韩精品乱码av一区二区| 91精品国产乱码久久蜜臀| 视频一区在线视频| www久久精品| 成人看片黄a免费看在线| 精品制服美女丁香| 久久无码av三级| 高清在线不卡av| 亚洲免费av高清| 欧美日韩五月天| 久久激情五月激情| 中文字幕免费一区| 在线视频中文字幕一区二区| 五月综合激情网| 久久夜色精品国产噜噜av| 成人福利视频在线看| 亚洲综合成人在线视频| 日韩三级中文字幕| 风间由美一区二区av101| 亚洲综合色网站| 日韩一卡二卡三卡| 99久精品国产| 奇米色一区二区| 国产精品伦一区二区三级视频| 91成人免费在线| 狠狠色丁香婷婷综合| 亚洲人123区| 日韩欧美一级特黄在线播放| 99re这里只有精品视频首页| 午夜精品福利一区二区蜜股av | 欧美电影免费观看高清完整版在线观看| 精一区二区三区| 一区二区三区在线视频观看 | 成人不卡免费av| 图片区小说区区亚洲影院| 国产三级欧美三级日产三级99| 91啪九色porn原创视频在线观看| 日韩精品亚洲专区| 国产精品乱子久久久久| 日韩亚洲国产中文字幕欧美| 波多野结衣一区二区三区| 丝袜诱惑制服诱惑色一区在线观看| 久久精品人人做人人综合| 欧美日韩在线播| 成人激情动漫在线观看| 美腿丝袜亚洲综合| 亚洲国产综合色| 亚洲免费观看在线观看| 国产蜜臀av在线一区二区三区| 91精品国产91热久久久做人人| 99精品桃花视频在线观看| 国产精品自在在线| 免费的成人av| 丝袜国产日韩另类美女| 亚洲黄色免费网站| 中文字幕一区二区三区在线不卡 | 91麻豆精品秘密| 国产不卡在线播放| 激情综合一区二区三区| 蜜桃91丨九色丨蝌蚪91桃色| 亚洲一二三四区| 亚洲精品成a人| 亚洲精品国久久99热| 中文字幕中文字幕一区| 中文字幕第一区第二区| 国产精品色婷婷| 欧美国产丝袜视频| 国产精品少妇自拍| 日本一区二区综合亚洲| 国产精品美女一区二区在线观看| 国产校园另类小说区| 日本一区二区综合亚洲| 欧美高清在线一区二区| 国产精品福利一区| 亚洲欧美综合色| 亚洲精品ww久久久久久p站| 亚洲精品一二三区| 一区二区三区电影在线播| 亚洲国产精品影院| 天涯成人国产亚洲精品一区av| 日韩精品一级二级| 麻豆成人久久精品二区三区红 | 欧美激情中文不卡| 国产精品乱码妇女bbbb| 亚洲日本在线观看| 一区二区欧美国产| 日韩经典一区二区| 国产乱妇无码大片在线观看| 成人午夜免费视频| 色欧美88888久久久久久影院| 欧美自拍偷拍一区| 欧美一区永久视频免费观看| 精品国产1区二区| 国产精品五月天| 亚洲无线码一区二区三区| 欧美96一区二区免费视频| 国产精品一区在线观看你懂的| 成人黄色在线网站| 欧美日韩一卡二卡三卡 | 日韩欧美色综合| 国产欧美视频一区二区| 亚洲激情av在线| 久久99国产精品麻豆| 成人av在线影院| 欧美精品三级在线观看| 久久久久国产一区二区三区四区| 亚洲美女一区二区三区| 免费高清视频精品| 91在线免费看| 日韩欧美视频在线| 亚洲美女屁股眼交3| 久久99精品国产麻豆不卡| 91在线免费视频观看| 日韩三级免费观看| 亚洲精品第一国产综合野| 韩国成人精品a∨在线观看| 91福利在线免费观看| 久久亚洲一区二区三区明星换脸 | 亚洲色图在线播放| 久久99国产精品免费| 日本一区二区在线不卡| 亚洲第四色夜色| 成人激情小说乱人伦| 日韩视频一区二区三区在线播放 | 午夜精品一区二区三区电影天堂 | 国产久卡久卡久卡久卡视频精品| 色综合久久88色综合天天 | 欧美日韩国产免费| 17c精品麻豆一区二区免费| 国模大尺度一区二区三区| 欧美在线观看禁18| 自拍偷拍国产精品| 国产精品自拍三区| 欧美一区二区三区的| 亚洲国产精品视频| 97se亚洲国产综合自在线观| 久久久高清一区二区三区| 久久精品国产99国产| 欧美日韩一级片在线观看| 亚洲精品五月天| 99国产精品久久久久久久久久| 国产亚洲欧美一级| 久久99久久99精品免视看婷婷| 欧美色综合天天久久综合精品| 自拍偷拍欧美精品| 成人高清视频免费观看| 亚洲国产精品成人综合色在线婷婷| 国内精品嫩模私拍在线| 欧美不卡一二三| 精品在线一区二区| 久久久av毛片精品| 国产精品资源网站|