Skip to content

Commit

Permalink
File-caching made .dev files in setup: stop working
Browse files Browse the repository at this point in the history
  • Loading branch information
mywave82 committed Feb 11, 2024
1 parent 3e9f516 commit d907abf
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 39 deletions.
6 changes: 3 additions & 3 deletions boot/plinkman.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ struct PluginInitAPI_t
const char *mdbtitle,
const char *mdbcomposer,
void *token,
int (*Init) (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API), // Client can change token for instance, it defaults to the provided one
void (*Run) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Close) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
int (*Init) (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API), // Client can change token for instance, it defaults to the provided one
void (*Run) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Close) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Destructor) (void *token)
);
struct dmDrive *dmSetup;
Expand Down
43 changes: 22 additions & 21 deletions filesel/filesystem-file-dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "config.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "types.h"
Expand All @@ -34,16 +35,17 @@ struct dev_ocpfile_t

void *token;

int (*Init) (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API); // Client can change token
void (*Run) (void **token, const struct DevInterfaceAPI_t *API); // Client can change token
void (*Close) (void **token, const struct DevInterfaceAPI_t *API); // Client can change token
int (*Init) (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API); // Client can change token
void (*Run) (void **token, const struct DevInterfaceAPI_t *API); // Client can change token
void (*Close) (void **token, const struct DevInterfaceAPI_t *API); // Client can change token
void (*Destructor) (void *token);
};

struct dev_ocpfilehandle_t
{
struct ocpfilehandle_t head;
struct dev_ocpfile_t *owner;
struct IOCTL_DevInterface devinterface;

void *token;
};
Expand Down Expand Up @@ -119,47 +121,42 @@ static int dev_filehandle_filesize_ready (struct ocpfilehandle_t *_s)
return 1;
}

static int DevInterface_Init (struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static int DevInterface_Init (struct IOCTL_DevInterface *self, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API)
{
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)f;
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)((char *)self - offsetof(struct dev_ocpfilehandle_t, devinterface));
if (s->owner->Init)
{
return s->owner->Init (&s->token, info, f, API);
return s->owner->Init (&s->token, info, API);
}
return 1;
}

static interfaceReturnEnum DevInterface_Run (struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static interfaceReturnEnum DevInterface_Run (struct IOCTL_DevInterface *self, const struct DevInterfaceAPI_t *API)
{
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)f;
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)((char *)self - offsetof(struct dev_ocpfilehandle_t, devinterface));
if (s->owner->Run)
{
s->owner->Run (&s->token, API);
}
return interfaceReturnNextAuto;
}

static void DevInterface_Close (struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static void DevInterface_Close (struct IOCTL_DevInterface *self, const struct DevInterfaceAPI_t *API)
{
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)f;
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)((char *)self - offsetof(struct dev_ocpfilehandle_t, devinterface));
if (s->owner->Close)
{
return s->owner->Close (&s->token, API);
}
}

static const struct IOCTL_DevInterface DevInterface =
{
DevInterface_Init,
DevInterface_Run,
DevInterface_Close
};

static int dev_filehandle_ioctl (struct ocpfilehandle_t *_handle, const char *cmd, void *ptr)
{
struct dev_ocpfilehandle_t *s = (struct dev_ocpfilehandle_t *)_handle;

if (!strcmp (cmd, IOCTL_DEVINTERFACE))
{
*(const struct IOCTL_DevInterface **)ptr = &DevInterface;
*(const struct IOCTL_DevInterface **)ptr = &s->devinterface;
return 0;
}
return -1;
Expand Down Expand Up @@ -189,6 +186,10 @@ static struct ocpfilehandle_t *dev_file_open (struct ocpfile_t *_owner)
1 /* refcount */
);

s->devinterface.Init = DevInterface_Init;
s->devinterface.Run = DevInterface_Run;
s->devinterface.Close = DevInterface_Close;

s->owner = owner;
_owner->ref (_owner);
s->token = owner->token;
Expand Down Expand Up @@ -241,9 +242,9 @@ struct ocpfile_t *dev_file_create
const char *mdbtitle,
const char *mdbcomposer,
void *token,
int (*Init) (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API),
void (*Run) (void **token, const struct DevInterfaceAPI_t *API),
void (*Close) (void **token, const struct DevInterfaceAPI_t *API),
int (*Init) (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API),
void (*Run) (void **token, const struct DevInterfaceAPI_t *API),
void (*Close) (void **token, const struct DevInterfaceAPI_t *API),
void (*Destructor) (void *token)
)
{
Expand Down
12 changes: 6 additions & 6 deletions filesel/filesystem-file-dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ struct DevInterfaceAPI_t

struct IOCTL_DevInterface
{
int (*Init) (struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
interfaceReturnEnum (*Run) ( struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
void (*Close) ( struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
int (*Init) (struct IOCTL_DevInterface *self, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API);
interfaceReturnEnum (*Run) (struct IOCTL_DevInterface *self, const struct DevInterfaceAPI_t *API);
void (*Close) (struct IOCTL_DevInterface *self, const struct DevInterfaceAPI_t *API);
};

struct ocpfile_t *dev_file_create
Expand All @@ -48,9 +48,9 @@ struct ocpfile_t *dev_file_create
const char *mdbtitle,
const char *mdbcomposer,
void *token,
int (*Init) (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API), // Client can change token for instance, it defaults to the provided one
void (*Run) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Close) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
int (*Init) (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API), // Client can change token for instance, it defaults to the provided one
void (*Run) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Close) (void **token, const struct DevInterfaceAPI_t *API), // Client can change token for instance
void (*Destructor) (void *token)
);

Expand Down
6 changes: 3 additions & 3 deletions filesel/pfilesel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1093,7 +1093,7 @@ static int VirtualInterfaceInit (struct moduleinfostruct *info, struct ocpfileha
}
if (CurrentVirtualDevice)
{
if (!CurrentVirtualDevice->Init (info, fi, &DevInterfaceAPI))
if (!CurrentVirtualDevice->Init (CurrentVirtualDevice, info, &DevInterfaceAPI))
{
CurrentVirtualDevice = 0;
return 0;
Expand All @@ -1108,7 +1108,7 @@ static interfaceReturnEnum VirtualInterfaceRun (void)
{
if (CurrentVirtualDevice)
{
return CurrentVirtualDevice->Run (CurrentVirtualDeviceFile, &DevInterfaceAPI);
return CurrentVirtualDevice->Run (CurrentVirtualDevice, &DevInterfaceAPI);
}
return interfaceReturnNextAuto;
}
Expand All @@ -1117,7 +1117,7 @@ static void VirtualInterfaceClose (void)
{
if (CurrentVirtualDevice)
{
CurrentVirtualDevice->Close (CurrentVirtualDeviceFile, &DevInterfaceAPI);
CurrentVirtualDevice->Close (CurrentVirtualDevice, &DevInterfaceAPI);
CurrentVirtualDeviceFile->unref (CurrentVirtualDeviceFile);
CurrentVirtualDeviceFile = 0;
CurrentVirtualDevice = 0;
Expand Down
2 changes: 1 addition & 1 deletion medialib/medialib-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ static void medialibAddClear (void)
medialibAddPath = 0;
}

static int medialibAddInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static int medialibAddInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API)
{
#ifndef _WIN32
if (API->dmFile->cwd)
Expand Down
2 changes: 1 addition & 1 deletion medialib/medialib-refresh.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void mlRefreshDraw(const char *title)
}
}

static int medialibRefreshInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static int medialibRefreshInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API)
{
if (medialib_sources_count)
{
Expand Down
2 changes: 1 addition & 1 deletion medialib/medialib-remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ static void mlRemoveDraw(const char *title)
}
}

static int medialibRemoveInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API)
static int medialibRemoveInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API)
{
if (medialib_sources_count)
{
Expand Down
6 changes: 3 additions & 3 deletions medialib/medialib.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ static struct ocpfile_t *removefiles; // needs to overlay an dialog above fi
static struct ocpdir_t listall; // complete query
static struct ocpdir_t search; // needs to throttle a dialog, before it can complete!! upon listing

static int medialibAddInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
static int medialibAddInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API);
static void medialibAddRun (void **token, const struct DevInterfaceAPI_t *API);

static int medialibRefreshInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
static int medialibRefreshInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API);
static void medialibRefreshRun (void **token, const struct DevInterfaceAPI_t *API);

static int medialibRemoveInit (void **token, struct moduleinfostruct *info, struct ocpfilehandle_t *f, const struct DevInterfaceAPI_t *API);
static int medialibRemoveInit (void **token, struct moduleinfostruct *info, const struct DevInterfaceAPI_t *API);
static void medialibRemoveRun (void **token, const struct DevInterfaceAPI_t *API);

static void ocpdir_listall_ref (struct ocpdir_t *self);
Expand Down

0 comments on commit d907abf

Please sign in to comment.