summaryrefslogtreecommitdiff
path: root/vfs/null_plugin/null_plugin.c
blob: 0d24765fbcd8f5296fcb934024d728e26f68c7eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
/* null plugin for Tux Commander
 * Copyright (C) 2005 Tomas Bzatek <tbzatek@users.sourceforge.net>
 *  Check for updates on tuxcmd.sourceforge.net
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

#include <string.h>
#include <stdlib.h>
#include <stdint.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include "vfs_types.h"


//  Declaration of the global plugin object
struct TVFSGlobs {
  TVFSLogFunc log_func;
  int list_item_id;
  char *curr_dir;
};



//  Basic initialization functions
int VFSAllocNeeded()
{
  return sizeof(struct TVFSGlobs);
}

void VFSInit(struct TVFSGlobs *globs, TVFSLogFunc log_func)
{

  globs->log_func = log_func;
  globs->log_func("null plugin: VFSInit");
  globs->curr_dir = NULL;
 
}

void VFSDestroy(struct TVFSGlobs *globs)
{

  globs->log_func("null plugin: VFSDestroy");

}

int VFSVersion()
{
  return cVFSVersion;
}

struct TVFSInfo VFSGetInfo()
{

  static const struct TVFSInfo info =
  {
     "Null plugin",
     "null testing plugin",
     "Plugin API version 2",
     "Copyright © 2007 Tomáš Bžatek"
  };

  return info;
}

char *VFSGetPrefix(struct TVFSGlobs *globs)
{
  return "null";
}

TVFSResult VFSOpen(struct TVFSGlobs *globs, char *sName)
{
 return cVFS_OK;
}

TVFSResult VFSClose(struct TVFSGlobs *globs)
{
 return cVFS_OK;
}

char *VFSGetPath(struct TVFSGlobs *globs)
{
  return globs->curr_dir;
}

u_int64_t VFSGetFileSystemFree(struct TVFSGlobs *globs, char *APath)
{
  return 0;
}

u_int64_t VFSGetFileSystemSize(struct TVFSGlobs *globs, char *APath)
{
  return 0;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////

TVFSResult VFSChangeDir(struct TVFSGlobs *globs, char *NewPath)
{
  if (globs->curr_dir != NULL) free(globs->curr_dir);
  globs->curr_dir = strdup(NewPath);
  return cVFS_OK;
}

int VFSLogin(struct TVFSGlobs *globs, char *user, char *pass)
{
  return cVFS_OK;
}



////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////

static char *items[] =
{
   "This is the first item",
   "This is the second item",
   "This is the third item",
   "This is the fourth item",
   "This is the fifth item",
   "This is the sixth item",
   "This is the seventh item",
   "This is the eight item",
   "This is the nineth item",
   "This is the tenth item",
   "This is the eleventh item",
   "This is the twelveth item",
   "This is the thirteenth item",
   "This is the fourteenth item",
   "This is the fifteenth item",
   "This is the sixteeth item",
   "This is the seventeenth item",
   "This is the eighteenth item",
};


TVFSResult VFSListFirst(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item)
{
  globs->list_item_id = 0;
  printf("C Item = %lu \n", (long int)Item);

  Item->sFileName = strdup(items[globs->list_item_id]);
//  Item->iSize = rand();
  Item->iSize = globs->list_item_id + 1;
  Item->iMode = S_IRWXO + S_IRWXG + S_IRWXU;
  Item->sLinkTo = "/tmp";
  Item->ItemType = vSymlink;
  Item->iUID = 100;
  Item->iGID = 1000;
  Item->m_time = time(NULL) + globs->list_item_id;
  printf("C sizeof(TVFSItem) = %ld \n", sizeof(struct TVFSItem));
  printf("C sizeof(Item->sFileName) = %ld \n", sizeof(Item->sFileName));
  printf("C sizeof(Item->iSize) = %ld \n", sizeof(Item->iSize));
  printf("C sizeof(Item->m_time) = %ld \n", sizeof(Item->m_time));
  printf("C sizeof(Item->a_time) = %ld \n", sizeof(Item->a_time));
  printf("C sizeof(Item->c_time) = %ld \n", sizeof(Item->c_time));
  printf("C sizeof(Item->iMode) = %ld \n", sizeof(Item->iMode));
  printf("C sizeof(Item->sLinkTo) = %ld \n", sizeof(Item->sLinkTo));
  printf("C sizeof(Item->iUID) = %ld \n", sizeof(Item->iUID));
  printf("C sizeof(Item->iGID) = %ld \n", sizeof(Item->iGID));
  printf("C sizeof(Item->ItemType) = %ld \n", sizeof(Item->ItemType));

  static struct TVFSItem x;
  printf("C sizeof(x.sFileName) = %ld \n", sizeof(x.sFileName));
  printf("C sizeof(x.iSize) = %ld \n", sizeof(x.iSize));
  printf("C sizeof(x.m_time) = %ld \n", sizeof(x.m_time));
  printf("C sizeof(x.a_time) = %ld \n", sizeof(x.a_time));
  printf("C sizeof(x.c_time) = %ld \n", sizeof(x.c_time));
  printf("C sizeof(x.iMode) = %ld \n", sizeof(x.iMode));
  printf("C sizeof(x.sLinkTo) = %ld \n", sizeof(x.sLinkTo));
  printf("C sizeof(x.iUID) = %ld \n", sizeof(x.iUID));
  printf("C sizeof(x.iGID) = %ld \n", sizeof(x.iGID));
  printf("C sizeof(x.ItemType) = %ld \n", sizeof(x.ItemType));

  return cVFS_OK;
}

TVFSResult VFSListNext(struct TVFSGlobs *globs, char *sDir, struct TVFSItem *Item)
{
  globs->list_item_id++;
  printf("C Item = %lu \n", (long int)Item);

  if (globs->list_item_id >= (sizeof(items) / sizeof(items[0]))) {
   Item = NULL;
   return cVFS_No_More_Files;
  }

  Item->sFileName = strdup(items[globs->list_item_id]);

  Item->iSize = globs->list_item_id + 1;
  Item->iMode = S_IRWXO +  /* S_IRWXG + */ S_IRWXU;
  Item->sLinkTo = NULL;
  Item->iUID = 100;
  Item->iGID = 1000;
  Item->m_time = time(NULL) + globs->list_item_id;

  if (globs->list_item_id < 4) Item->ItemType = vDirectory;
  else Item->ItemType = vRegular;

  return cVFS_OK;
}

TVFSResult VFSListClose(struct TVFSGlobs *globs)
{
  return cVFS_OK;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////
long VFSFileExists(struct TVFSGlobs *globs, const char *FileName, const long Use_lstat)
{
  return 0;
}

TVFSResult VFSFileInfo(struct TVFSGlobs *globs, char *AFileName, struct TVFSItem *Item)
{
  return cVFS_OK;
}

TVFSResult VFSMkDir(struct TVFSGlobs *globs, const char *sDirName)
{
  return cVFS_OK;
}

TVFSResult VFSRemove(struct TVFSGlobs *globs, const char *APath)
{
  return cVFS_OK;
}

TVFSResult VFSRename(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName)
{
  return cVFS_OK;
}

TVFSResult VFSMakeSymLink(struct TVFSGlobs *globs, const char *NewFileName, const char *PointTo)
{
  return cVFS_OK;
}

TVFSResult VFSChmod(struct TVFSGlobs *globs, const char *FileName, const uint Mode)
{
  return cVFS_OK;
}

TVFSResult VFSChown(struct TVFSGlobs *globs, const char *FileName, const uint UID, const uint GID)
{
  return cVFS_OK;
}

TVFSResult VFSChangeTimes(struct TVFSGlobs *globs, char *APath, long mtime, long atime)
{
  return cVFS_OK;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////

u_int64_t VFSGetDirSize(struct TVFSGlobs *globs, char *APath)
{
  return 0;
}


void VFSBreakGetDirSize(struct TVFSGlobs *globs)
{

}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////

TVFSFileDes VFSOpenFile(struct TVFSGlobs *globs, const char *APath, int Mode, int *Error)
{
  *Error = 0;
  return (TVFSFileDes)0;
}

TVFSResult VFSCloseFile(struct TVFSGlobs *globs, TVFSFileDes FileDescriptor)
{
  return cVFS_OK;
}

u_int64_t VFSFileSeek(struct TVFSGlobs *globs, TVFSFileDes FileDescriptor, u_int64_t AbsoluteOffset, int *Error)
{
  *Error = 0;
  return 0;
}

int VFSReadFile(struct TVFSGlobs *globs, TVFSFileDes FileDescriptor, void *Buffer, int ABlockSize, int *Error)
{
  *Error = 0;
  return 0;
}

int VFSWriteFile(struct TVFSGlobs *globs, TVFSFileDes FileDescriptor, void *Buffer, int BytesCount, int *Error)
{
  *Error = 0;
  return 0;
}

void VFSSetBlockSize(struct TVFSGlobs *globs, int Value)
{

}

int VFSIsOnSameFS(struct TVFSGlobs *globs, const char *Path1, const char *Path2)
{
  return 0;
}

int VFSTwoSameFiles(struct TVFSGlobs *globs, const char *Path1, const char *Path2)
{
  return 0;
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////

TVFSResult VFSCopyOut(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append)
{
  return cVFS_OK;
}

TVFSResult VFSCopyIn(struct TVFSGlobs *globs, const char *sSrcName, const char *sDstName, TVFSCopyCallBackFunc pCallBackProgress, void *data, int Append)
{
  return cVFS_OK;
}

////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////