Team Fortress 2 Source Code as on 22/4/2020
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.

118 lines
2.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //=============================================================================//
  7. // Passthrough/stubbed version of Steamlib.h/Steam.c for Linux non-Steam server
  8. #ifndef STEAMLIB_NULL_H
  9. #define STEAMLIB_NULL_H
  10. #include <stdlib.h>
  11. #include <stdio.h>
  12. #include <string.h> // for strlen()
  13. #include <stdarg.h>
  14. #include <dlfcn.h>
  15. #if !defined ( _WIN32 )
  16. #include <string.h>
  17. #endif
  18. typedef enum // Filter elements returned by SteamFind{First,Next}
  19. {
  20. STEAMFindLocalOnly, // limit search to local filesystem
  21. STEAMFindRemoteOnly, // limit search to remote repository
  22. STEAMFindAll // do not limit search (duplicates allowed)
  23. } STEAMFindFilter;
  24. // Direct drop-in replacements
  25. #define STEAM_fopen fopen
  26. #define STEAM_fclose fclose
  27. #define STEAM_fread fread
  28. #define STEAM_fwrite fwrite
  29. #define STEAM_fprintf fprintf
  30. #define STEAM_fseek fseek
  31. #define STEAM_ftell ftell
  32. #define STEAM_feof feof
  33. #define STEAM_ferror ferror
  34. #define STEAM_clearerr clearerr
  35. #define STEAM_rewind rewind
  36. #define STEAM_fflush fflush
  37. #define STEAM_setvbuf setvbuf
  38. static inline int STEAM_Mount( void ) { return 1; }
  39. static inline void STEAM_Shutdown( void ) { }
  40. static inline unsigned int STEAM_FileSize( FILE *file )
  41. {
  42. unsigned int iRet;
  43. if ( !file )
  44. {
  45. iRet = 0;
  46. }
  47. else
  48. {
  49. int iPos;
  50. iPos = ftell( file );
  51. fseek ( file, 0, SEEK_END );
  52. iRet = ftell( file );
  53. fseek ( file, iPos, SEEK_SET );
  54. }
  55. return iRet;
  56. }
  57. static inline void STEAM_strerror( FILE *stream, char * p, int maxlen )
  58. {
  59. snprintf( p, maxlen, "Steam FS unavailable" );
  60. }
  61. static inline void STEAM_GetLocalCopy( const char * fileName ) { }
  62. static inline void STEAM_LogLevelLoadStarted( const char * name ) { }
  63. static inline void STEAM_LogLevelLoadFinished( const char * name ) { }
  64. static inline int STEAM_HintResourceNeed( const char * mapcycle, int forgetEverything ) { return 1; }
  65. static inline void STEAM_TrackProgress( int enable ) { }
  66. static inline void STEAM_UpdateProgress( void ) { }
  67. static inline void STEAM_RegisterAppProgressCallback( void( *fpProgCallBack )( void ), int freq ) { }
  68. static inline void STEAM_RegisterAppKeepAliveTicCallback( void( *fpKeepAliveTicCallBack )( char * scr_msg ) ) { }
  69. static inline void STEAM_GetInterfaceVersion( char * p, int maxlen )
  70. {
  71. snprintf( p, maxlen, "0.0.0.0" );
  72. }
  73. static inline long STEAM_LoadLibrary( char * pszFileName )
  74. {
  75. void * hDll;
  76. char szCwd[ MAX_OSPATH ];
  77. char szAbsoluteLib[ MAX_OSPATH ];
  78. if ( !getcwd( szCwd, sizeof( szCwd ) ) )
  79. return 0;
  80. if ( szCwd[ strlen( szCwd ) -1 ] == '/' )
  81. {
  82. szCwd[ strlen( szCwd ) -1 ] = 0;
  83. }
  84. snprintf( szAbsoluteLib, sizeof( szAbsoluteLib ), "%s/%s", szCwd, pszFileName );
  85. hDll = dlopen( szAbsoluteLib, RTLD_NOW );
  86. return (long)hDll;
  87. }
  88. #endif // STEAMLIB_NULL_H