示例#1
0
void mtlrchApp::EvWinIniChange (char far* section)
{
    if (lstrcmp(section, "windows") == 0) {
        // If the device changed in the WIN.INI file then the printer
        // might have changed.  If we have a TPrinter (Printer) then
        // check and make sure it's identical to the current device
        // entry in WIN.INI.
        if (Printer) {
            char printDBuffer[255];
            LPSTR printDevice = printDBuffer;
            LPSTR devName = 0;
            LPSTR driverName = 0;
            LPSTR outputName = 0;
        
            if (::GetProfileString("windows", "device", "", printDevice, sizeof(printDevice))) {
                // The string which should come back is something like:
                //
                //      HP LaserJet III,hppcl5a,LPT1:
                //
                // Where the format is:
                //
                //      devName,driverName,outputName
                //
                devName = printDevice;
                while (*printDevice) {
                    if (*printDevice == ',') {
                        *printDevice++ = 0;
                        if (!driverName)
                            driverName = printDevice;
                        else
                            outputName = printDevice;
                    } else
                        printDevice = AnsiNext(printDevice);
                }

                if ((Printer->GetSetup().Error != 0)                                ||
                    (lstrcmp(devName, Printer->GetSetup().GetDeviceName()) != 0)    ||
                    (lstrcmp(driverName, Printer->GetSetup().GetDriverName()) != 0) ||
                    (lstrcmp(outputName, Printer->GetSetup().GetOutputName()) != 0)) {
                
                    // New printer installed so get the new printer device now.
                    delete Printer;
                    Printer = new TPrinter;
                }
            } else {
                // No printer installed (GetProfileString failed).
                delete Printer;
                Printer = new TPrinter;
            }
        }
    }
}
static Pchar FetchStr(Pchar& Str)
{
  Pchar result = Str;
  LPSTR tempStr = Str;  // Used because AnsiNext returns an LPSTR;
                        // Note that we could simply use Str instead
                        // if we assumed a large data model.

  if (Str == NULL)
        return result;
  while ((*tempStr != '\0') && (*tempStr != ','))
    tempStr = AnsiNext(tempStr);
  if (*tempStr != '\0')
  {
        *tempStr = '\0';
        tempStr++;
        while (*tempStr == ' ')
                tempStr = AnsiNext(tempStr);
  }
  // Change Str to point to next field.
  Str += int(tempStr - (LPSTR) Str);
  return result;
}
示例#3
0
LPSTR NEAR _fastcall MyStrTok(LPSTR szList, char cEnd)
{
   LPSTR szTemp;

   /* if there are no more tokens return NULL */
   if(!*szList)
      return NULL;

   /* find delimiter or end of string */
   while(*szList && *szList!=cEnd)
      szList = AnsiNext(szList);

   /* if we found a delimiter insert string terminator and skip */
   if(*szList) {
      szTemp = szList;
      szList = AnsiNext(szTemp);
      *szTemp = '\0';
   }

   /* return token */
   return(szList);
}
示例#4
0
const char * AnsiStrBrk (const char * s, char c)
{
    while (*s != '\0')
#if defined (LONG_FILE_NAME)
        if (!StartsWithAnsiChar (s, c))
#else
        if (*s != c)
#endif //(LONG_FILE_NAME)
            return (s);
        else
            s = (const char *)AnsiNext ((LPSTR)s);

    return (0);
}
示例#5
0
char * StrCpyN (char * str1, const char * str2, size_t nChars)
{
    if (str1 == 0 || nChars <= 0)
        return 0;

    if (str2 == 0)
        str2 = "";

#if !defined (WIN32) && !defined (PLAT_UNIX)
    if (GetWindowsVersion () >= 0x30a)
        return (lstrcpyn (str1, (LPSTR)str2, nChars));
    else
#endif //!defined (WIN32) && !defined (PLAT_UNIX)
    {
        char * cursor = str1;

        while (*str2 != '\0')
        {
            size_t charSize = IsDBCSLeadByte (*str2) ? 2 : 1;

            if (nChars > charSize)
            {
                *cursor++ = *str2;
                --nChars;

                if (charSize == 2)
                {
                    *cursor++ = *(str2 + 1);
                    --nChars;
                }

                str2 = AnsiNext (str2);
            } else
                break;
        }
        *cursor = '\0';

        return str1;
    }
}
示例#6
0
文件: utils.c 项目: mingpen/OpenNT
/*
** void MakePathName(char ARG_PTR *pszPath, char ARG_PTR *pszFileName);
**
** Append a filename to a path string.
**
** Arguments:  pszPath     - path string to which pszFileName will be appended
**             pszFileName - file name to append
**
** Returns:    void
**
** Globals:    none
*/
VOID MakePathName(CHAR ARG_PTR *pszPath, CHAR ARG_PTR *pszFileName)
{
   CHAR chLastPathChar;

   // Make sure we have an isolated file name.
   pszFileName = ExtractFileName(pszFileName);

   // Dont append to a NULL string or a single ".".
#ifdef DBCS
   if (*pszFileName != '\0' &&
       ! (! IsDBCSLeadByte(pszFileName[0]) && pszFileName[0] == PERIOD &&
          ! IsDBCSLeadByte(pszFileName[1]) && pszFileName[1] == '\0'))
   {
      CHAR ARG_PTR *psz, *pszPrevious;

      for (psz = pszPrevious = pszPath; *psz != '\0'; psz = AnsiNext(psz))
         pszPrevious = psz;

      chLastPathChar = *pszPrevious;

      if (! IsDBCSLeadByte(chLastPathChar) && ! ISSLASH(chLastPathChar) &&
          chLastPathChar != COLON)
         STRCAT(pszPath, SEP_STR);

      STRCAT(pszPath, pszFileName);
   }
#else
   if (*pszFileName != '\0' &&
       ! (*pszFileName == PERIOD && pszFileName[1] == '\0'))
   {
      chLastPathChar = pszPath[STRLEN(pszPath) - 1];

      if (! ISSLASH(chLastPathChar) && chLastPathChar != COLON)
         STRCAT(pszPath, SEP_STR);

      STRCAT(pszPath, pszFileName);
   }
#endif
}
示例#7
0
    /* Helping functions for FNSplit */
        static void RegisterTokens (TokenIndexList * & infoList, 
                                    const char       * pathStr,
                                    char               token)
        {
            infoList = 0;
            Int16u index = 1;
            char curChar = pathStr [index];

            while (curChar)
            {
                if (curChar == token)
                {
                    TokenIndexList * aNode = new TokenIndexList;
                    aNode->index = index;
                    aNode->next = infoList;
                    infoList = aNode;
                }

                index = AnsiNext (pathStr + index) - (char *)pathStr;
                curChar = pathStr [index];
            }
        }
示例#8
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
    static int          nLineCount,lineNo;
    static int          cyClient, cxChar, cyChar;
    static int          xScroll;
    static HGLOBAL      hResource;
    static HWND         hwndScroll;
    static HWND         hScroll;

    CHAR        *szText;
    HINSTANCE   hInstance;
    HDC         hdc;
    PAINTSTRUCT ps;
    RECT        clientRect;
    int         i;

    switch(msg)
    {
    case WM_CREATE:
        hInstance = ((LPCREATESTRUCT)lParam)->hInstance;
        lineNo = 0;
        //Load Text resource
        hResource = LoadResource(hInstance, FindResource(hInstance, TEXT("ANNABELLEE"), TEXT("TEXT")));
        szText = (CHAR *)LockResource(hResource);

        //Create Scrollbar
        hScroll = CreateWindow(TEXT("scrollbar"), NULL, SB_VERT | WS_CHILD | WS_VISIBLE, 
                    0, 0, 0, 0,
                    hwnd, (HMENU)1, hInstance, NULL);
        //calculate line count
        while(*szText != '\0' && *szText != '\\')
        {
            if (*szText == '\n')
                ++nLineCount;
            szText = AnsiNext(szText);
        }
        *szText == '\0';

        //Get char size
        cxChar = LOWORD(GetDialogBaseUnits());
        cyChar = HIWORD(GetDialogBaseUnits());
        xScroll = GetSystemMetrics(SM_CXVSCROLL);

        //Setup scroll 
        SetScrollRange(hScroll, SB_CTL, 0, nLineCount, TRUE);
        SetScrollPos(hScroll, SB_CTL, 0, TRUE);
        break;
    case WM_SIZE:
        {
            MoveWindow(hScroll, LOWORD(lParam) - xScroll, 0, xScroll, HIWORD(lParam), TRUE); 
            cyClient = HIWORD(lParam);
            SetFocus(hScroll);
            break;
        }
    case WM_SETFOCUS:
        {
            SetFocus(hScroll);
            break;
        }
    case WM_VSCROLL:
        {
            switch(wParam)
            {
                case SB_TOP:
                    lineNo = 0;
                    break;
                case SB_BOTTOM:
                    lineNo = nLineCount;
                    break;
                case SB_LINEDOWN:
                    lineNo++;
                    break;
                case SB_LINEUP:
                    lineNo--;
                    break;
                case SB_PAGEDOWN:
                    lineNo += cyClient / cyChar;
                    break;
                case SB_PAGEUP:
                    lineNo -= cyClient / cyChar;
                    break;
                default:
                    break;
            }
            lineNo = max(0, lineNo);
            lineNo = min(lineNo, nLineCount);
            SetScrollPos(hScroll, SB_CTL, lineNo, TRUE);
            InvalidateRect(hwnd, NULL, TRUE);
            break;
        }
    case WM_PAINT:
        {
            hdc = BeginPaint(hwnd, &ps);
            GetClientRect(hwnd, &clientRect);
            clientRect.left += cxChar;
            clientRect.top += cyChar*(1 - lineNo);
            szText = (CHAR *)LockResource(hResource);
            DrawTextA(hdc, szText, -1, &clientRect, DT_TOP); 
            EndPaint(hwnd, &ps);
            break;
        }
    case WM_DESTROY:
        {
            FreeResource(hResource);
            PostQuitMessage(0);
            break;
        }
    }
    return DefWindowProc(hwnd, msg, wParam, lParam);
}
示例#9
0
static wBool_t printInit( void )
{
	static int initted = FALSE;
	static int printerOk = FALSE;
	if (initted) {
		if (!printerOk) {
			mswFail( "No Printers are defined" );
		}
		return printerOk;
	}
	initted = TRUE;
	printDlg.lStructSize = sizeof printDlg;
	printDlg.hwndOwner = NULL;
	printDlg.Flags = PD_RETURNDC|PD_RETURNDEFAULT;
	if (PrintDlg(&printDlg) != 0  && printDlg.hDC) {
		getPageDim( printDlg.hDC );
		DeleteDC( printDlg.hDC );
	}
#ifdef LATER
	DEVMODE * printMode;
	HDC hDc;
	char ptrInfo[80];
	char ptrDrvrDvr[80];
	char *temp;
	char *ptrDevice;
	char *ptrDrvr;
	char *ptrPort;
	int size;
	int rc;
	FARPROC extDeviceMode;
	FARPROC deviceMode;
	HINSTANCE hDriver;

	GetProfileString("windows", "device", "", ptrInfo, sizeof ptrInfo );
	if (ptrInfo[0] == 0) {
		mswFail( "No Printers are defined" );
		return FALSE;
	}
	temp = ptrDevice = ptrInfo;
	ptrDrvr = ptrPort = NULL;
	while (*temp) {
		if (*temp == ',') {
			*temp++ = 0;
			while( *temp == ' ' )
				temp++;
			if (!ptrDrvr)
				ptrDrvr = temp;
			else {
				ptrPort = temp;
				break;
			}
		}
		else
			temp = AnsiNext(temp);
	}
	strcpy( ptrDrvrDvr, ptrDrvr );
	strcat( ptrDrvrDvr, ".drv" );
	if ((long)(hDriver = LoadLibrary( ptrDrvrDvr )) <= 32) {
		mswFail( "printInit: LoadLibrary" );
		return FALSE;
	}
	if (( extDeviceMode = GetProcAddress( hDriver, "ExtDeviceMode" )) != NULL) {
		size = extDeviceMode( mswHWnd, (HANDLE)hDriver, (LPDEVMODE)NULL, (LPSTR)ptrDevice, (LPSTR)ptrPort, (LPDEVMODE)NULL, (LPSTR)NULL, 0 );
		printMode = (DEVMODE*)malloc( size );
		rc = extDeviceMode( mswHWnd, (HANDLE)hDriver, (LPDEVMODE)printMode, (LPSTR)ptrDevice, (LPSTR)ptrPort, (LPDEVMODE)NULL, (LPSTR)NULL, DM_OUT_BUFFER );
#ifdef LATER
		if (rc != IDOK && rc != IDCANCEL) {
			mswFail( "printInit: extDeviceMode" );
			return FALSE;
		}
#endif
	} else if (( deviceMode = GetProcAddress( hDriver, "DeviceMode" )) != NULL) {
		rc = deviceMode( mswHWnd, (HANDLE)hDriver, (LPSTR)ptrDevice, (LPSTR)ptrPort );
#ifdef LATER
		if (rc != IDOK && rc != IDCANCEL) {
			mswFail( "printInit: deviceMode" );
			return FALSE;
		}
#endif
	}

	hDc = CreateDC( (LPSTR)ptrDrvr, (LPSTR)ptrDevice, (LPSTR)ptrPort, NULL );
	if (hDc == NULL) {
		mswFail("printInit: createDC" );
		abort();
	}
	getPageDim( hDc );
	DeleteDC( hDc );
	
	FreeLibrary( hDriver );
#endif
	printerOk = TRUE;
	return TRUE;
}
示例#10
0
文件: utils.c 项目: mingpen/OpenNT
/*
** void MakeExpandedName(char ARG_PTR *pszFileName, BYTE byteExtensionChar);
**
** Create expanded output file name.
**
** Arguments:  pszFileName       - expanded file name to change
**             byteExtensionChar - expanded file name extension character to
**                                 use
**
** Returns:    void
**
** Globals:    none
*/
VOID MakeExpandedName(CHAR ARG_PTR *pszFileName, BYTE byteExtensionChar)
{
   CHAR ARG_PTR *pszExt;
   INT nExtLen;

   // Is there any extension to change?
   if ((pszExt = ExtractExtension(pszFileName)) != NULL)
   {
      // Determine case of extension character.  Match case of first non-DB
      // character in name.  If all characters are DB, leave case alone.

      if (ISLETTER(byteExtensionChar))
      {
         // Find first alphabetic character in name.
         while (*pszFileName)
         {
#ifdef DBCS
            if (IsDBCSLeadByte(*pszFileName))
               pszFileName += 2;
            else
#endif
            if (ISLETTER(*pszFileName))
               break;
            else
               pszFileName++;
         }

         // Here pszFileName points to the first alphabetic character in the
         // name or to the null terminator.  Set the case of the extension
         // character.

         if (ISLOWER(*pszFileName))
            byteExtensionChar = (BYTE)TOLOWERCASE(byteExtensionChar);
         else if (ISUPPER(*pszFileName))
            byteExtensionChar = (BYTE)TOUPPERCASE(byteExtensionChar);
      }

#ifdef DBCS
      if ((nExtLen = STRLEN(pszExt)) > 0)
      {
         // Find the underscore character to replace, if it exists.

         // Assert: The underscore is either the last character in the
         // extension, or it is the first character in the extension followed
         // by a double-byte character.

         if (! IsDBCSLeadByte(*pszExt) && *pszExt == chEXTENSION_CHAR &&
             IsDBCSLeadByte(pszExt[1]))
            // Here the underscore is followed by a double-byte character.
            *pszExt = byteExtensionChar;
         else
         {
            // Here the underscore is the last character in the extension, if
            // there is an underscore at all.
            CHAR ARG_PTR *psz, *pszPrevious;

            for (psz = pszPrevious = pszExt; *psz != '\0'; psz = AnsiNext(psz))
               pszPrevious = psz;

            if (! IsDBCSLeadByte(*pszPrevious) &&
                *pszPrevious == chEXTENSION_CHAR)
               *pszPrevious = byteExtensionChar;
         }
      }
#else
      if ((nExtLen = STRLEN(pszExt)) > 0 &&
          pszExt[nExtLen - 1] == chEXTENSION_CHAR)
         // Handle expected renamed form.
         pszExt[nExtLen - 1] = byteExtensionChar;
#endif

      // Get rid of trailing dot with no extension.
      if (*pszExt == '\0' && *(pszExt - 1) == PERIOD)
         *(pszExt - 1) = '\0';
   }
}
示例#11
0
		  Int16u FNSplit (const char * pathP,
								char       * driveP,
								char       * dirP,
								char       * nameP,
								char       * extP)
		  {
				Int16u     Ret;

				//Set all string to default value zero
				Ret = 0;
				if (driveP)
					 *driveP = 0;
				if (dirP)
					 *dirP = 0;
				if (nameP)
					 *nameP = 0;
				if (extP)
					 *extP = 0;

				if (pathP == 0)
					 return 0;


				const char * cursor = pathP,
							  * dirStart = 0,
							  * lastSlash = 0;

//				if (StartsWithAnsi (cursor) && _istalpha (*cursor) &&
				if (StartsWithAnsi (cursor) && isAlpha (*cursor) &&
					 StartsWithAnsiChar (cursor + 1, ':'))
				{
					 // A drive letter presents.
					 if (driveP != 0)
						  StrCpyN (driveP, cursor, MAXDRIVE);

					 cursor += 2;
                Ret |= DRIVE;
            }

            dirStart = cursor;

            // now find the last slash
            while (*cursor != '\0')
            {
                if (StartsWithAnsiChar (cursor, '/') ||
                    StartsWithAnsiChar (cursor, '\\'))
                    lastSlash = cursor;

                cursor = AnsiNext (cursor);
            }

            if (lastSlash != 0)
            {
                // a slash was seen
                if (dirP != 0)
                {
                    Int16u bytesToCopy = lastSlash - dirStart
                                         + 1  // for '/'
                                         + 1; // for '\0'

                    if (bytesToCopy > MAXDIR)
                        bytesToCopy = MAXDIR;

                    StrCpyN (dirP, dirStart, bytesToCopy);
                }

                cursor = lastSlash + 1;

                Ret |= DIRECTORY;
            } else
                cursor = dirStart;

            // cursor now points to the start of the filename
            // check for wildcards
            if (AnsiStrChr (cursor, '*') != 0 ||
                AnsiStrChr (cursor, '?') != 0)
                Ret |= WILDCARDS;

            // now see if there's an extension
            const char * period = 0;

            for (const char * ptr = cursor; *ptr != '\0'; ptr = AnsiNext (ptr))
            {
                if (StartsWithAnsiChar (ptr, '.'))
                    period = ptr;
            }

            if (period != 0)
            {
                Int16u bytesToCopy = period - cursor + 1;  // for '\0'

                if (bytesToCopy > MAXFILE)
                    bytesToCopy = MAXFILE;

                if (bytesToCopy > 0)
                {
                    if (nameP != 0)
                        StrCpyN (nameP, cursor, bytesToCopy);

                    Ret |= FILENAME;
                }

                if (extP != 0)
                    StrCpyN (extP, period, MAXEXT);

                Ret |= EXTENSION;
            } else 
            {
                if (*cursor != '\0')
                {
                    if (nameP != 0)
                        StrCpyN (nameP, cursor, MAXFILE);

                    Ret |= FILENAME;
                }
            }

        #if defined (DEBUG_FNSPLIT)
            static char buffer [MAXPATH + MAXPATH + 32];

            wsprintf (buffer, 
                      "pathP:[%s]  driveP:[%s]  dirP:[%s]  nameP:[%s]  extP:[%s]",
                      pathP,
                      driveP != NULL ? driveP : "<NULL>",
                      dirP != NULL ? dirP : "<NULL>",
                      nameP != NULL ? nameP : "<NULL>",
                      extP != NULL ? extP : "<NULL>");
            MessageBox (GetActiveWindow (), buffer, "FNSplit", MB_OK);
        #endif //(DEBUG_FNSPLIT)

            return Ret;
        }
示例#12
0
inline Boolean StartsWithAnsi (const char * string)
{
    return ((AnsiNext (string)) == (string + 1));
}
示例#13
0
文件: parse.c 项目: chunhualiu/OpenNT
long ParseFile(ULPSTR lpstrFileName)
{
  short nFile, nExt, nFileOffset, nExtOffset;
  BOOL bExt;
  BOOL bWildcard;
  short nNetwork = 0;
  BOOL  bUNCPath = FALSE;
  ULPSTR lpstr = lpstrFileName;

/* Strip off initial white space.  Note that TAB is not checked */
/* because it cannot be received out of a standard edit control */
/* 30 January 1991  clarkc                                      */
  while (*lpstr == chSpace)
      lpstr++;

  if (!*lpstr)
    {
      nFileOffset = PARSE_EMPTYSTRING;
      goto FAILURE;
    }

  if (lpstr != lpstrFileName)
    {
      lstrcpy(lpstrFileName, lpstr);
      lpstr = lpstrFileName;
    }

  if (*AnsiNext(lpstr) == ':')
    {
      char cDrive = (*lpstr | (BYTE) 0x20);  /* make lowercase */

/* This does not test if the drive exists, only if it's legal */
      if ((cDrive < 'a') || (cDrive > 'z'))
        {
          nFileOffset = PARSE_INVALIDDRIVE;
          goto FAILURE;
        }
      lpstr = AnsiNext(AnsiNext(lpstr));
    }

  if ((*lpstr == '\\') || (*lpstr == '/'))
    {
      if (*++lpstr == chPeriod)               /* cannot have c:\. */
        {
          if ((*++lpstr != '\\') && (*lpstr != '/'))   /* unless it's stupid */
            {
              if (!*lpstr)        /* it's the root directory */
                  goto MustBeDir;

              nFileOffset = PARSE_INVALIDPERIOD;
              goto FAILURE;
            }
          else
              ++lpstr;   /* it's saying top directory (again), thus allowed */
        }
      else if ((*lpstr == '\\') && (*(lpstr-1) == '\\'))
        {
/* It seems that for a full network path, whether a drive is declared or
 * not is insignificant, though if a drive is given, it must be valid
 * (hence the code above should remain there).
 * 13 February 1991           clarkc
 */
          ++lpstr;            /* ...since it's the first slash, 2 are allowed */
          nNetwork = -1;      /* Must receive server and share to be real     */
          bUNCPath = TRUE;    /* No wildcards allowed if UNC name             */
        }
      else if (*lpstr == '/')
        {
          nFileOffset = PARSE_INVALIDDIRCHAR;
          goto FAILURE;
        }
    }
  else if (*lpstr == chPeriod)
    {
      if (*++lpstr == chPeriod)  /* Is this up one directory? */
          ++lpstr;
      if (!*lpstr)
          goto MustBeDir;
      if ((*lpstr != '\\') && (*lpstr != '/'))
        {
          nFileOffset = PARSE_INVALIDPERIOD;
          goto FAILURE;
        }
      else
          ++lpstr;   /* it's saying directory, thus allowed */
    }

  if (!*lpstr)
    {
      goto MustBeDir;
    }

/* Should point to first char in 8.3 filename by now */
  nFileOffset = nExtOffset = nFile = nExt = 0;
  bWildcard = bExt = FALSE;
  while (*lpstr)
    {
/*
 *  The next comparison MUST be unsigned to allow for extended characters!
 *  21 Feb 1991   clarkc
 */
      if (*lpstr < chSpace)
        {
          nFileOffset = PARSE_INVALIDCHAR;
          goto FAILURE;
        }
      switch (*lpstr)
        {
          case '"':             /* All invalid */
          case '+':
          case ',':
          case ':':
          case ';':
          case '<':
          case '=':
          case '>':
          case '[':
          case ']':
          case '|':
            {
              nFileOffset = PARSE_INVALIDCHAR;
              goto FAILURE;
            }

          case '\\':      /* Subdirectory indicators */
          case '/':
            nNetwork++;
            if (bWildcard)
              {
                nFileOffset = PARSE_WILDCARDINDIR;
                goto FAILURE;
              }

            else if (nFile == 0)        /* can't have 2 in a row */
              {
                nFileOffset = PARSE_INVALIDDIRCHAR;
                goto FAILURE;
              }
            else
              {                         /* reset flags */
                ++lpstr;
                if (!nNetwork && !*lpstr)
                  {
                    nFileOffset = PARSE_INVALIDNETPATH;
                    goto FAILURE;
                  }
                nFile = nExt = 0;
                bExt = FALSE;
              }
            break;

          case chSpace:
            {
              ULPSTR lpSpace = lpstr;

              *lpSpace = '\0';
              while (*++lpSpace)
                {
                  if (*lpSpace != chSpace)
                    {
                      *lpstr = chSpace;        /* Reset string, abandon ship */
                      nFileOffset = PARSE_INVALIDSPACE;
                      goto FAILURE;
                    }
                }
            }
            break;

          case chPeriod:
            if (nFile == 0)
              {
                if (*++lpstr == chPeriod)
                    ++lpstr;
                if (!*lpstr)
                    goto MustBeDir;

                if ((*lpstr != '\\') && (*lpstr != '/'))
                  {
                    nFileOffset = PARSE_INVALIDPERIOD;
                    goto FAILURE;
                  }

                ++lpstr;              /* Flags are already set */
              }
            else if (bExt)
              {
                nFileOffset = PARSE_INVALIDPERIOD;  /* can't have one in ext */
                goto FAILURE;
              }
            else
              {
                nExtOffset = 0;
                ++lpstr;
                bExt = TRUE;
              }
            break;

          case '*':
          case '?':
            if (bUNCPath)
              {
                nFileOffset = PARSE_INVALIDNETPATH;
                goto FAILURE;
              }
            bWildcard = TRUE;
/* Fall through to normal character processing */

          default:
            if (bExt)
              {
                if (++nExt == 1)
                    nExtOffset = lpstr - lpstrFileName;
                else if (nExt > 3)
                  {
                    nFileOffset = PARSE_EXTENTIONTOOLONG;
                    goto FAILURE;
                  }
                if ((nNetwork == -1) && (nFile + nExt > 11))
                  {
                    nFileOffset = PARSE_INVALIDNETPATH;
                    goto FAILURE;
                  }
              }
            else if (++nFile == 1)
                nFileOffset = lpstr - lpstrFileName;
            else if (nFile > 8)
              {
                /* If it's a server name, it can have 11 characters */
                if (nNetwork != -1)
                  {
                    nFileOffset = PARSE_FILETOOLONG;
                    goto FAILURE;
                  }
                else if (nFile > 11)
                  {
                    nFileOffset = PARSE_INVALIDNETPATH;
                    goto FAILURE;
                  }
              }

            lpstr = AnsiNext(lpstr);
            break;
        }
    }

/* Did we start with a double backslash but not have any more slashes? */
  if (nNetwork == -1)
    {
      nFileOffset = PARSE_INVALIDNETPATH;
      goto FAILURE;
    }

  if (!nFile)
    {
MustBeDir:
      nFileOffset = PARSE_DIRECTORYNAME;
      goto FAILURE;
    }

  if ((*(lpstr - 1) == chPeriod) &&          /* if true, no extention wanted */
              (*AnsiNext(lpstr-2) == chPeriod))
      *(lpstr - 1) = '\0';               /* Remove terminating period   */
  else if (!nExt)
FAILURE:
      nExtOffset = lpstr - lpstrFileName;

  return(MAKELONG(nFileOffset, nExtOffset));
}