Browse Source

Added context pointer to file callbacks' fopen function

master
Christopher Snowhill 5 months ago
parent
commit
38b1419c70
2 changed files with 6 additions and 3 deletions
  1. +1
    -1
      psflib.c
  2. +5
    -2
      psflib.h

+ 1
- 1
psflib.c View File

@@ -440,7 +440,7 @@ static int psf_load_internal(psf_load_state * state, const char * file_name)
strcat(full_path, file_name);
#endif

file = state->file_callbacks->fopen(full_path);
file = state->file_callbacks->fopen(state->file_callbacks->context, full_path);

free(full_path);



+ 5
- 2
psflib.h View File

@@ -1,7 +1,7 @@
/*
PSFLIB - Main PSF parser implementation
Copyright (c) 2012-2015 Christopher Snowhill
Copyright (c) 2012-2020 Christopher Snowhill
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -38,9 +38,12 @@ typedef struct psf_file_callbacks
/* list of characters which act as path separators, null terminated */
const char * path_separators;

/* Context pointer for fopen callback */
void * context;

/* opens the file pointed to by path read-only in binary mode,
* accepts UTF-8 encoding, returns file handle */
void * (* fopen )(const char * path);
void * (* fopen )(void * context, const char * path);

/* reads to specified buffer, returns count of size bytes read */
size_t (* fread )(void * buffer, size_t size, size_t count, void * handle);


Loading…
Cancel
Save