示例#1
0
BOOL __far __pascal GetFilesExtension( char __far * szFilePath, char __far * szExtBuffer )
{
  char __far * szFileExt;
  
  
  /*
  ** Get the szFilePath's extension. 
  */

  /* Get the extension separator in path. */
  szFileExt = _fstrrchr( szFilePath, EXTENSION_CHAR_SEPARATOR ); 

  /* If didn't find the separator in path. */
  if( szFileExt == NULL ) return FALSE;

  /* Move to the character after the extension character. */
  szFileExt++;
  
  /* ** If we are at the end of the name string - no extension. */ 
  if( *szFileExt == NULL_CHAR ) return FALSE;

  /* Copy the extension into the buffer. */
  _fstrcpy( szExtBuffer, szFileExt );

  return TRUE;
}
示例#2
0
文件: winunzip.c 项目: 131/gsview
/* unzip to current directory */
int
unzip(char *zipname)
{
LPSTR p;
	 lpDCL->Overwrite = TRUE;  /* overwrite existing files */
	 lpDCL->ncflag = FALSE;	/* don't write to stdout */
	 lpDCL->ntflag = FALSE;	/* don't test zip file */
	 lpDCL->nvflag = FALSE;	/* don't verbose list */
	 lpDCL->nUflag = FALSE;	/* replace all files */
	 lpDCL->nzflag = FALSE;	/* don't display zip file comment */
	 lpDCL->ndflag = TRUE;       /* all args are files/dir to be extracted */
	 lpDCL->noflag = FALSE;      /* */
	 lpDCL->naflag = FALSE;      /* do ASCII-EBCDIC and/or end of line translation */

	 lstrcpy(lpumb->szFileName, zipname);
	 lstrcpy(lpumb->szDirName, zipname);
	 p = _fstrrchr(lpumb->szDirName, '\\');
	 if (p)
	*p = '\0';

	 lpDCL->lpszZipFN = zipname;
	 lpDCL->argc = 0;
	 lpDCL->FNV = NULL;

	 return (*DllProcessZipFiles)(lpDCL);
}
示例#3
0
/*************************************
*
*  Given a file's full path
*  and a simple file name, see if
*  the filenames match.
*
**************************************/
BOOL __far __pascal DoFileNamesMatch( char __far * szLibFilePath, char __far * szFilePath )
{
  char __far * szSeparator;
  char __far * szLibFileName;
  int nReturn;
  
  
  /* Is the supplied szFilePath is a full path. */
  szSeparator = _fstrrchr( szFilePath, DIR_CHAR_SEPARATOR );
  
  /* If we found a DIR_CHAR_SEPARATOR, then compare as full paths. */
  if( szSeparator != NULL )
  {
    /* Compare the full file paths. */
    nReturn = _fstricmp( szLibFilePath, szFilePath ); 

    if( nReturn == 0 ) return TRUE;
    else return FALSE;
  }
  

  /* 
  ** The supplied szFilePath is not a full path, compare it
  ** to the libraries filename.
  */
  else
  {
    /* Point to the filename in the library's full path. */
    szLibFileName = _fstrrchr( szLibFilePath, DIR_CHAR_SEPARATOR );
    
    /* Could not find the last occurence of the DIR_CHAR_SEPARATOR. */ 
    if( szLibFileName == NULL )  return FALSE;
  
    /* Point to the next char - the lib's filename. */
    szLibFileName++;
    
    /* Compare the file names. */
    nReturn = _fstricmp( szLibFileName, szFilePath ); 
  }

  /* We did not find the library we are looking for. */
  if( nReturn != 0 )  return FALSE;
  
  /* Found match. */
  return( TRUE );
}
示例#4
0
/******************************************************************************
    SaveOnCommand
    when the Type selection changes, replace the current filename extension
    (or append) with the first extension in the list for the new type -- unless
    the current extension already occurs in the list
 ******************************************************************************/
static void SaveOnTypeSelChange(LPSTR pszType, LPSTR pszFilename)
{
    LPSTR psz;
    LPSTR pszx;
    LPSTR pszDot;
    LPSTR pszStar;
    
    /* get pointer to the place in szFilename to stuff the ".ext" string */
    psz = pszFilename;
    if ( psz[0] != '\0' && psz[1] == ':' )
        psz += 2;
    pszx = _fstrrchr(psz, '//');
    psz = _fstrrchr(psz, '\\');
    if ( psz == NULL || ( pszx != NULL && psz < pszx ) )
        psz = pszx;
    if ( psz == NULL )
        psz = pszFilename;
    pszDot = _fstrrchr(psz, '.');
    if ( pszDot == NULL )
        pszDot = psz + lstrlen(psz);

    pszStar = NULL;
    while ( ( psz = _fstrrchr(pszType, '*') ) != NULL )
        {
        *psz = '\0';
        pszStar = ++psz;
        while ( *psz > ' ' && *psz != ')' && *psz != ';' && *psz != ',' )
            psz++;
        *psz = '\0';
        if ( lstrcmpi(pszStar, pszDot) == 0 )
            return;
        }
    assert(pszStar != NULL);
    if ( pszStar == NULL )
    {
        ErrorMessage(STYLE_ERROR, IDS_SAVEINTERNAL1);        
    }
    else
        lstrcpy(pszDot, pszStar);
}
示例#5
0
void TestSearchF( void )
{
    char            buf[] = "The quick brown fox jumped over the lazy dogs.";
    char __far      *ptr;

    ptr = _fstrchr( buf, '!' );                 /* try to find a '!' */
    VERIFY( ptr == NULL );

    ptr = _fstrchr( buf, 0x00 );                /* try to find the NULL */
    VERIFY( ptr == buf+strlen(buf) );

    ptr = _fstrchr( buf, 'k' );                 /* try to find a 'k' */
    VERIFY( ptr == buf+8 );

    ptr = _fstrrchr( buf, '!' );                /* try to find a '!' */
    VERIFY( ptr == NULL );

    ptr = _fstrrchr( buf, 0x00 );               /* try to find the NULL */
    VERIFY( ptr == buf+strlen(buf) );

    ptr = _fstrrchr( buf, 'k' );                /* try to find a 'k' */
    VERIFY( ptr == buf+8 );
}
示例#6
0
文件: winmain.c 项目: Sheetalm9/test
int
main(int argc, char **argv)
#endif
{
	LPSTR tail;
	int i;

#ifdef WGP_CONSOLE
	HINSTANCE hInstance = GetModuleHandle(NULL), hPrevInstance = NULL;
#endif


#ifndef WGP_CONSOLE
# if defined( __MINGW32__) && !defined(_W64)
#  define argc _argc
#  define argv _argv
# else /* MSVC, WATCOM, MINGW-W64 */
#  define argc __argc
#  define argv __argv
# endif
#endif /* WGP_CONSOLE */

        szModuleName = (LPSTR)malloc(MAXSTR+1);
        CheckMemory(szModuleName);

        /* get path to EXE */
        GetModuleFileName(hInstance, (LPSTR) szModuleName, MAXSTR);
        if ((tail = (LPSTR)_fstrrchr(szModuleName,'\\')) != (LPSTR)NULL)
        {
                tail++;
                *tail = 0;
        }
        szModuleName = (LPSTR)realloc(szModuleName, _fstrlen(szModuleName)+1);
        CheckMemory(szModuleName);

        if (_fstrlen(szModuleName) >= 5 && _fstrnicmp(&szModuleName[_fstrlen(szModuleName)-5], "\\bin\\", 5) == 0)
        {
                int len = _fstrlen(szModuleName)-4;
                szPackageDir = (LPSTR)malloc(len+1);
                CheckMemory(szPackageDir);
                _fstrncpy(szPackageDir, szModuleName, len);
                szPackageDir[len] = '\0';
        }
        else
                szPackageDir = szModuleName;

#ifndef WGP_CONSOLE
        textwin.hInstance = hInstance;
        textwin.hPrevInstance = hPrevInstance;
        textwin.nCmdShow = nCmdShow;
        textwin.Title = "gnuplot";
#endif

		/* create structure of first graph window */
		graphwin = (LPGW) calloc(1, sizeof(GW));
		listgraphs = graphwin;

		/* locate ini file */
		{
			char * inifile;
			get_user_env(); /* this hasn't been called yet */
			inifile = gp_strdup("~\\wgnuplot.ini");
			gp_expand_tilde(&inifile);

			/* if tilde expansion fails use current directory as
			   default - that was the previous default behaviour */
			if (inifile[0] == '~') {
				free(inifile);
				inifile = "wgnuplot.ini";
			}

#ifndef WGP_CONSOLE
			textwin.IniFile = inifile;
#endif
			graphwin->IniFile = inifile;

			ReadMainIni(inifile, "WGNUPLOT");
		}

#ifndef WGP_CONSOLE
        textwin.IniSection = "WGNUPLOT";
        textwin.DragPre = "load '";
        textwin.DragPost = "'\n";
        textwin.lpmw = &menuwin;
        textwin.ScreenSize.x = 80;
        textwin.ScreenSize.y = 80;
        textwin.KeyBufSize = 2048;
        textwin.CursorFlag = 1; /* scroll to cursor after \n & \r */
        textwin.shutdown = MakeProcInstance((FARPROC)ShutDown, hInstance);
        textwin.AboutText = (LPSTR)malloc(1024);
        CheckMemory(textwin.AboutText);
        sprintf(textwin.AboutText,
	    "Version %s patchlevel %s\n" \
	    "last modified %s\n" \
	    "%s\n%s, %s and many others\n" \
	    "gnuplot home:     http://www.gnuplot.info\n",
            gnuplot_version, gnuplot_patchlevel,
	    gnuplot_date,
	    gnuplot_copyright, authors[1], authors[0]);
        textwin.AboutText = (LPSTR)realloc(textwin.AboutText, _fstrlen(textwin.AboutText)+1);
        CheckMemory(textwin.AboutText);

        menuwin.szMenuName = szMenuName;
#endif

        pausewin.hInstance = hInstance;
        pausewin.hPrevInstance = hPrevInstance;
        pausewin.Title = "gnuplot pause";

        graphwin->hInstance = hInstance;
        graphwin->hPrevInstance = hPrevInstance;
#ifdef WGP_CONSOLE
        graphwin->lptw = NULL;
#else
        graphwin->lptw = &textwin;
#endif

		/* init common controls */
	{
	    INITCOMMONCONTROLSEX initCtrls;
	    initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
	    initCtrls.dwICC = ICC_WIN95_CLASSES;
	    InitCommonControlsEx(&initCtrls);
	}

#ifndef WGP_CONSOLE
	if (TextInit(&textwin))
		gp_exit(EXIT_FAILURE);
	textwin.hIcon = LoadIcon(hInstance, "TEXTICON");
	SetClassLongPtr(textwin.hWndParent, GCLP_HICON, (LONG_PTR)textwin.hIcon);

	/* Note: we want to know whether this is an interactive session so that we can
	 * decide whether or not to write status information to stderr.  The old test
	 * for this was to see if (argc > 1) but the addition of optional command line
	 * switches broke this.  What we really wanted to know was whether any of the
	 * command line arguments are file names or an explicit in-line "-e command".
	 * (This is a copy of a code snippet from plot.c)
	 */
	for (i = 1; i < argc; i++) {
		if (!stricmp(argv[i], "/noend"))
			continue;
		if ((argv[i][0] != '-') || (argv[i][1] == 'e')) {
			interactive = FALSE;
			break;
		}
	}
	if (interactive)
		ShowWindow(textwin.hWndParent, textwin.nCmdShow);
	if (IsIconic(textwin.hWndParent)) { /* update icon */
		RECT rect;
		GetClientRect(textwin.hWndParent, (LPRECT) &rect);
		InvalidateRect(textwin.hWndParent, (LPRECT) &rect, 1);
		UpdateWindow(textwin.hWndParent);
	}
# ifndef __WATCOMC__
	/* Finally, also redirect C++ standard output streams. */
	RedirectOutputStreams(TRUE);
# endif
#else /* WGP_CONSOLE */
#ifdef CONSOLE_SWITCH_CP
        /* Change codepage of console to match that of the graph window.
           WinExit() will revert this.
           Attention: display of characters does not work correctly with
           "Terminal" font! Users will have to use "Lucida Console" or similar.
        */
        cp_input = GetConsoleCP();
        cp_output = GetConsoleOutputCP();
        if (cp_input != GetACP()) {
            cp_changed = TRUE;
            SetConsoleCP(GetACP()); /* keyboard input */
            SetConsoleOutputCP(GetACP()); /* screen output */
            SetFileApisToANSI(); /* file names etc. */
        }
#endif
#endif

	gp_atexit(WinExit);

	if (!isatty(fileno(stdin)))
		setmode(fileno(stdin), O_BINARY);

	gnu_main(argc, argv);

	/* First chance to close help system for console gnuplot,
	   second for wgnuplot */
	WinCloseHelp();
	gp_exit_cleanup();
	return 0;
}
示例#7
0
文件: winmain.c 项目: mojca/gnuplot
int main(int argc, char **argv)
#endif
{
        /*WNDCLASS wndclass;*/
        LPSTR tail;

#ifdef WGP_CONSOLE
# define _argv argv
# define _argc argc
        HINSTANCE hInstance = GetModuleHandle(NULL), hPrevInstance = NULL;
#else
#if defined(__MSC__) || defined(__WATCOMC__)
#  define _argv __argv
#  define _argc __argc
#endif
#endif /* WGP_CONSOLE */

        szModuleName = (LPSTR)malloc(MAXSTR+1);
        CheckMemory(szModuleName);

        /* get path to EXE */
        GetModuleFileName(hInstance, (LPSTR) szModuleName, MAXSTR);
        if ((tail = (LPSTR)_fstrrchr(szModuleName,'\\')) != (LPSTR)NULL)
        {
                tail++;
                *tail = 0;
        }
        szModuleName = (LPSTR)realloc(szModuleName, _fstrlen(szModuleName)+1);
        CheckMemory(szModuleName);

        if (_fstrlen(szModuleName) >= 5 && _fstrnicmp(&szModuleName[_fstrlen(szModuleName)-5], "\\bin\\", 5) == 0)
        {
                int len = _fstrlen(szModuleName)-4;
                szPackageDir = (LPSTR)malloc(len+1);
                CheckMemory(szPackageDir);
                _fstrncpy(szPackageDir, szModuleName, len);
                szPackageDir[len] = '\0';
        }
        else
                szPackageDir = szModuleName;

#ifndef WGP_CONSOLE
        textwin.hInstance = hInstance;
        textwin.hPrevInstance = hPrevInstance;
        textwin.nCmdShow = nCmdShow;
        textwin.Title = "gnuplot";
#endif

		/* create structure of first graph window */
		graphwin = calloc(1, sizeof(GW));
		listgraphs = graphwin;

		/* locate ini file */
		{
			char * inifile;
			get_user_env(); /* this hasn't been called yet */
			inifile = gp_strdup("~\\wgnuplot.ini");
			gp_expand_tilde(&inifile);

			/* if tilde expansion fails use current directory as
			   default - that was the previous default behaviour */
			if (inifile[0] == '~') {
				free(inifile);
				inifile = "wgnuplot.ini";
			}

#ifndef WGP_CONSOLE
			textwin.IniFile = inifile;
#endif
			graphwin->IniFile = inifile;

			ReadMainIni(inifile, "WGNUPLOT");
		}

#ifndef WGP_CONSOLE
        textwin.IniSection = "WGNUPLOT";
        textwin.DragPre = "load '";
        textwin.DragPost = "'\n";
        textwin.lpmw = &menuwin;
        textwin.ScreenSize.x = 80;
        textwin.ScreenSize.y = 80;
        textwin.KeyBufSize = 2048;
        textwin.CursorFlag = 1; /* scroll to cursor after \n & \r */
        textwin.shutdown = MakeProcInstance((FARPROC)ShutDown, hInstance);
        textwin.AboutText = (LPSTR)malloc(1024);
        CheckMemory(textwin.AboutText);
        sprintf(textwin.AboutText,
	    "Version %s patchlevel %s\n" \
	    "last modified %s\n" \
	    "%s\n%s, %s and many others\n" \
	    "gnuplot home:     http://www.gnuplot.info\n",
            gnuplot_version, gnuplot_patchlevel,
	    gnuplot_date,
	    gnuplot_copyright, authors[1], authors[0]);
        textwin.AboutText = (LPSTR)realloc(textwin.AboutText, _fstrlen(textwin.AboutText)+1);
        CheckMemory(textwin.AboutText);

        menuwin.szMenuName = szMenuName;
#endif

        pausewin.hInstance = hInstance;
        pausewin.hPrevInstance = hPrevInstance;
        pausewin.Title = "gnuplot pause";

        graphwin->hInstance = hInstance;
        graphwin->hPrevInstance = hPrevInstance;
#ifdef WGP_CONSOLE
        graphwin->lptw = NULL;
#else
        graphwin->lptw = &textwin;
#endif

		/* init common controls */
	{
	    INITCOMMONCONTROLSEX initCtrls;
	    initCtrls.dwSize = sizeof(INITCOMMONCONTROLSEX);
	    initCtrls.dwICC = ICC_WIN95_CLASSES;
	    InitCommonControlsEx(&initCtrls);
	}

#ifndef WGP_CONSOLE
        if (TextInit(&textwin))
                exit(1);
        textwin.hIcon = LoadIcon(hInstance, "TEXTICON");
        SetClassLong(textwin.hWndParent, GCL_HICON, (DWORD)textwin.hIcon);
        if (_argc>1) {
                int i,noend=FALSE;
                for (i=0; i<_argc; ++i)
                        if (!stricmp(_argv[i],"-noend") || !stricmp(_argv[i],"/noend")
                            || !stricmp(_argv[i],"-persist"))
                                noend = TRUE;
                if (noend)
                        ShowWindow(textwin.hWndParent, textwin.nCmdShow);
        }
        else
                ShowWindow(textwin.hWndParent, textwin.nCmdShow);
        if (IsIconic(textwin.hWndParent)) { /* update icon */
                RECT rect;
                GetClientRect(textwin.hWndParent, (LPRECT) &rect);
                InvalidateRect(textwin.hWndParent, (LPRECT) &rect, 1);
                UpdateWindow(textwin.hWndParent);
        }
#else /* WGP_CONSOLE */
#ifdef CONSOLE_SWITCH_CP
        /* Change codepage of console to match that of the graph window.
           WinExit() will revert this.
           Attention: display of characters does not work correctly with
           "Terminal" font! Users will have to use "Lucida Console" or similar.
        */
        cp_input = GetConsoleCP();
        cp_output = GetConsoleOutputCP();
        if (cp_input != GetACP()) {
            cp_changed = TRUE;
            SetConsoleCP(GetACP()); /* keyboard input */
            SetConsoleOutputCP(GetACP()); /* screen output */
            SetFileApisToANSI(); /* file names etc. */
        }
#endif
#endif

        atexit(WinExit);

        if (!isatty(fileno(stdin)))
            setmode(fileno(stdin), O_BINARY);

        gnu_main(_argc, _argv, environ);

        /* First chance to close help system for console gnuplot,
        second for wgnuplot */
        WinCloseHelp();
        return 0;
}
示例#8
0
文件: slmmgr.c 项目: mingpen/OpenNT
/*
 * create a slm object for the given directory. The pathname may include
 * a filename component.
 * If the directory is not enlisted in a SLM library, this will return NULL.
 *
 * Check that the directory is valid, and that we can open slm.ini, and
 * build a UNC path to the master source library before declaring everything
 * valid.
 */
SLMOBJECT
SLM_New(LPSTR pathname)
{
    SLMOBJECT pslm;
    char slmpath[MAX_PATH];
    HFILE fh;
    BOOL bOK;
    LPSTR pfinal = NULL;



    pslm = (SLMOBJECT) gmem_get(hHeap, sizeof(struct _slmobject));

    if (pslm == NULL) {
	return(NULL);
    }

    if (pathname == NULL) {
	pathname = ".";
    }

    /*
     * find the directory portion of the path.
     */
    if (dir_isvaliddir(pathname)) {

	/*
	 * its a valid directory as it is.
	 */
	lstrcpy(pslm->CurDir, pathname);

    } else {

	/* it's not a valid directory, perhaps because it has a filename on
	 * the end. remove the final element and try again.
	 */

	pfinal = _fstrrchr(pathname, '\\');
	if (pfinal == NULL) {
	    /*
	     * there is no backslash in this name and it is not a directory
	     * - it can only be valid if it is a file in the current dir.
	     * so create a current dir of '.'
	     */
	    lstrcpy(pslm->CurDir, ".");

	    // remember the final element in case it was a wild card
	    pfinal = pathname;
	} else {
	    /*
	     * pfinal points to the final backslash.
	     */
	    _fstrncpy(pslm->CurDir, pathname, pfinal - pathname);
	}
    }

    /*
     * look for slm.ini in the specified directory
     */
    lstrcpy(slmpath, pslm->CurDir);
    if (pslm->CurDir[lstrlen(pslm->CurDir) -1] != '\\') {
	lstrcat(slmpath, "\\");
    }
    lstrcat(slmpath, "slm.ini");

    fh = _lopen(slmpath, 0);
    if (fh != -1) {
	bOK = SLM_ReadIni(pslm, fh);

	/*
	 * if pfinal is not null, then it might be a *.* wildcard pattern
	 * at the end of the path - if so, we should append it to the masterpath.
	 */
	if (pfinal && (_fstrchr(pfinal, '*') || _fstrchr(pfinal, '?'))) {
    	    if ( (pslm->MasterPath[lstrlen(pslm->MasterPath)-1] != '\\') &&
		 (pfinal[0] != '\\')) {
		     lstrcat(pslm->MasterPath, "\\");
	    }
	    lstrcat(pslm->MasterPath, pfinal);
	}


    	_lclose(fh);
    } else {
	bOK = FALSE;
    }

    if (!bOK) {
	gmem_free(hHeap, (LPSTR) pslm, sizeof(struct _slmobject));
	return(NULL);
    } else {
	return(pslm);
    }
}