Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

94 lines
2.9 KiB

  1. //========= Copyright � 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $Workfile: $
  6. // $Date: $
  7. // $NoKeywords: $
  8. //=============================================================================//
  9. #ifndef SCRIPLIB_H
  10. #define SCRIPLIB_H
  11. #ifdef _WIN32
  12. #pragma once
  13. #endif
  14. enum ScriptPathMode_t
  15. {
  16. SCRIPT_USE_ABSOLUTE_PATH,
  17. SCRIPT_USE_RELATIVE_PATH
  18. };
  19. // scriplib.h
  20. #define MAXTOKEN 1024
  21. extern char token[MAXTOKEN];
  22. //extern char *scriptbuffer,*script_p,*scriptend_p;
  23. extern int grabbed;
  24. extern int scriptline;
  25. extern qboolean endofscript;
  26. // If pathMode is SCRIPT_USE_ABSOLUTE_PATH, then it uses ExpandPath() on the filename before
  27. // trying to open it. Otherwise, it passes the filename straight into the filesystem
  28. // (so you can leave it as a relative path).
  29. void LoadScriptFile (char *filename, ScriptPathMode_t pathMode=SCRIPT_USE_ABSOLUTE_PATH);
  30. void ParseFromMemory (char *buffer, int size);
  31. qboolean GetToken (qboolean crossline);
  32. qboolean GetExprToken (qboolean crossline);
  33. void UnGetToken (void);
  34. qboolean TokenAvailable (void);
  35. qboolean GetTokenizerStatus( char **pFilename, int *pLine );
  36. // SCRIPT_LOADED_CALLBACK:
  37. // Is called after the contents of a file is loaded.
  38. // pFilenameLoaded is the path of a file that got loaded.
  39. // pIncludedFromFileName is the name of the parent file or NULL if loaded because of "LoadScriptFile" toplevel call.
  40. // nIncludeLineNumber is the number of the line in the parent file with $include statement or 0 in case of "LoadScriptFile"
  41. typedef void ( * SCRIPT_LOADED_CALLBACK )( char const *pFilenameLoaded, char const *pIncludedFromFileName, int nIncludeLineNumber );
  42. // SetScriptLoadedCallback:
  43. // Sets the new callback for script loading.
  44. // Returns the previous callback function.
  45. SCRIPT_LOADED_CALLBACK SetScriptLoadedCallback( SCRIPT_LOADED_CALLBACK pfnNewScriptLoadedCallback );
  46. #include "tier1/utlstring.h"
  47. #include "tier1/utlvector.h"
  48. class CUtlBuffer;
  49. enum DiskWriteMode_t
  50. {
  51. WRITE_TO_DISK_NEVER,
  52. WRITE_TO_DISK_ALWAYS,
  53. WRITE_TO_DISK_UPDATE, // file must exist
  54. };
  55. struct fileList_t
  56. {
  57. CUtlString fileName;
  58. time_t timeWrite;
  59. };
  60. class IScriptLib
  61. {
  62. public:
  63. virtual bool ReadFileToBuffer( const char *pSourceName, CUtlBuffer &buffer, bool bText = false, bool bNoOpenFailureWarning = false ) = 0;
  64. virtual bool WriteBufferToFile( const char *pTargetName, CUtlBuffer &buffer, DiskWriteMode_t writeMode ) = 0;
  65. virtual int FindFiles( char* pFileMask, bool bRecurse, CUtlVector<fileList_t> &fileList ) = 0;
  66. virtual char *MakeTemporaryFilename( char const *pchModPath, char *pPath, int pathSize ) = 0;
  67. virtual void DeleteTemporaryFiles( const char *pFileMask ) = 0;
  68. virtual int CompareFileTime( const char *pFilenameA, const char *pFilenameB ) = 0;
  69. virtual bool DoesFileExist( const char *pFilename ) = 0;
  70. };
  71. extern IScriptLib *scriptlib;
  72. extern IScriptLib *g_pScriptLib;
  73. #endif // SCRIPLIB_H