diff options
| author | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
|---|---|---|
| committer | Joe Ludwig <[email protected]> | 2013-06-26 15:22:04 -0700 |
| commit | 39ed87570bdb2f86969d4be821c94b722dc71179 (patch) | |
| tree | abc53757f75f40c80278e87650ea92808274aa59 /mp/src/utils/common/scriplib.h | |
| download | source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.tar.xz source-sdk-2013-39ed87570bdb2f86969d4be821c94b722dc71179.zip | |
First version of the SOurce SDK 2013
Diffstat (limited to 'mp/src/utils/common/scriplib.h')
| -rw-r--r-- | mp/src/utils/common/scriplib.h | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/mp/src/utils/common/scriplib.h b/mp/src/utils/common/scriplib.h new file mode 100644 index 00000000..6b119525 --- /dev/null +++ b/mp/src/utils/common/scriplib.h @@ -0,0 +1,96 @@ +//========= Copyright Valve Corporation, All rights reserved. ============//
+//
+// Purpose:
+//
+// $Workfile: $
+// $Date: $
+// $NoKeywords: $
+//=============================================================================//
+
+#ifndef SCRIPLIB_H
+#define SCRIPLIB_H
+
+#ifdef _WIN32
+#pragma once
+#endif
+
+
+enum ScriptPathMode_t
+{
+ SCRIPT_USE_ABSOLUTE_PATH,
+ SCRIPT_USE_RELATIVE_PATH
+};
+
+
+// scriplib.h
+
+#define MAXTOKEN 1024
+
+extern char token[MAXTOKEN];
+extern char *scriptbuffer,*script_p,*scriptend_p;
+extern int grabbed;
+extern int scriptline;
+extern qboolean endofscript;
+
+
+// If pathMode is SCRIPT_USE_ABSOLUTE_PATH, then it uses ExpandPath() on the filename before
+// trying to open it. Otherwise, it passes the filename straight into the filesystem
+// (so you can leave it as a relative path).
+void LoadScriptFile (char *filename, ScriptPathMode_t pathMode=SCRIPT_USE_ABSOLUTE_PATH);
+void ParseFromMemory (char *buffer, int size);
+
+qboolean GetToken (qboolean crossline);
+qboolean GetExprToken (qboolean crossline);
+void UnGetToken (void);
+qboolean TokenAvailable (void);
+qboolean GetTokenizerStatus( char **pFilename, int *pLine );
+bool SetCheckSingleCharTokens( bool bCheck );
+
+// SCRIPT_LOADED_CALLBACK:
+// Is called after the contents of a file is loaded.
+// pFilenameLoaded is the path of a file that got loaded.
+// pIncludedFromFileName is the name of the parent file or NULL if loaded because of "LoadScriptFile" toplevel call.
+// nIncludeLineNumber is the number of the line in the parent file with $include statement or 0 in case of "LoadScriptFile"
+typedef void ( * SCRIPT_LOADED_CALLBACK )( char const *pFilenameLoaded, char const *pIncludedFromFileName, int nIncludeLineNumber );
+
+// SetScriptLoadedCallback:
+// Sets the new callback for script loading.
+// Returns the previous callback function.
+SCRIPT_LOADED_CALLBACK SetScriptLoadedCallback( SCRIPT_LOADED_CALLBACK pfnNewScriptLoadedCallback );
+
+#include "tier1/utlstring.h"
+#include "tier1/utlvector.h"
+
+CUtlString SetSingleCharTokenList( const char *pszSingleCharTokenList );
+
+class CUtlBuffer;
+
+enum DiskWriteMode_t
+{
+ WRITE_TO_DISK_NEVER,
+ WRITE_TO_DISK_ALWAYS,
+ WRITE_TO_DISK_UPDATE, // file must exist
+};
+
+struct fileList_t
+{
+ CUtlString fileName;
+ time_t timeWrite;
+};
+
+class IScriptLib
+{
+public:
+ virtual bool ReadFileToBuffer( const char *pSourceName, CUtlBuffer &buffer, bool bText = false, bool bNoOpenFailureWarning = false ) = 0;
+ virtual bool WriteBufferToFile( const char *pTargetName, CUtlBuffer &buffer, DiskWriteMode_t writeMode ) = 0;
+ virtual int FindFiles( char* pFileMask, bool bRecurse, CUtlVector<fileList_t> &fileList ) = 0;
+ virtual char *MakeTemporaryFilename( char const *pchModPath, char *pPath, int pathSize ) = 0;
+ virtual void DeleteTemporaryFiles( const char *pFileMask ) = 0;
+ virtual int CompareFileTime( const char *pFilenameA, const char *pFilenameB ) = 0;
+ virtual bool DoesFileExist( const char *pFilename ) = 0;
+};
+
+extern IScriptLib *scriptlib;
+
+
+#endif // SCRIPLIB_H
|