r105: This commit was manufactured by cvs2svn to create tag
[cinelerra_cv/mob.git] / hvirtual / cinelerra / renderfarmfsclient.h
blob322ae2b3c89e0f60834e5e4b6ad60fd87516c7b7
1 #ifndef RENDERFARMFSCLIENT_H
2 #define RENDERFARMFSCLIENT_H
4 #include "mutex.inc"
5 #include "renderfarmclient.inc"
6 #include "renderfarmfsclient.inc"
9 // This should override the stdio commands and inderect operations on any file
10 // starting with RENDERFARM_FS_PREFIX to the network.
12 // The server runs on the master node.
13 // The client runs on the client.
15 // The traffic shares the same socket as the rest of the rendering traffic
16 // so the server and client command loops have to give control to the
17 // VFS objects when they get a VFS command.
19 // Only one RenderFarmClient can exist per image because the stdio operations
20 // don't allow pointers to local storage. Fortunately only one
21 // RenderFarmClient exists per image by default. The RenderFarmClient just needs
22 // to wait until it's forked before creating RenderFarmFSClient.
23 // The RenderFarmClient is a mutual
24 // exclusion lock and table of file descriptors.
25 // It searches through the table to see if the file descriptor is virtual.
26 // Then it translates a single stdio call at a time to and from
27 // network commands, complete with the original parameters and return values.
29 // The RenderFarmFSServer takes one command from the network at a time and passes
30 // it directly to the stdio call. If call has a buffer, the buffer is
31 // created by the RenderFarmFSServer and streamed over the network.
32 // The return values are passed untouched back through the network.
34 // FILE* and int on RenderFarmClient are meaningless.
35 // They can't be dereferenced.
36 // Unfortunately, nothing else in Cinelerra can override stdio now.
38 // All the stdio functions are transferred in endian independant ways except
39 // stat, stat64.
41 extern RenderFarmFSClient *renderfarm_fs_global;
43 class RenderFarmFSClient
45 public:
46 RenderFarmFSClient(RenderFarmClientThread *client);
47 ~RenderFarmFSClient();
49 void initialize();
51 // Called by the overloaded C library functions.
52 // There may be more.
53 FILE* fopen(const char *path, const char *mode);
54 int fclose(FILE *file);
55 int remove (__const char *__filename);
56 int rename (__const char *__old, __const char *__new);
57 int fgetc (FILE *__stream);
58 int fputc (int __c, FILE *__stream);
59 size_t fread (void *__restrict __ptr, size_t __size,
60 size_t __n, FILE *__restrict __stream);
61 size_t fwrite (__const void *__restrict __ptr, size_t __size,
62 size_t __n, FILE *__restrict __s);
63 int fseek (FILE *__stream, int64_t __off, int __whence);
64 int64_t ftell (FILE *__stream);
65 int stat64 (__const char *__restrict __file,
66 struct stat64 *__restrict __buf);
67 int stat (__const char *__restrict __file,
68 struct stat *__restrict __buf);
69 char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream);
71 // Locking order:
72 // 1) RenderFarmFSClient
73 // 2) RenderFarmClient
74 void lock();
75 void unlock();
76 int is_open(FILE *ptr);
77 void set_open(FILE *ptr);
78 void unset_open(FILE *ptr);
80 Mutex *mutex_lock;
81 ArrayList<FILE*> files;
82 RenderFarmClientThread *client;
89 #endif