dev builds
themes manual
device status forums
mailing lists
IRC bugs
dev guide

Rockbox mail archive

Subject: Plug-in program run time error, for jpg viewer scrolling.

Plug-in program run time error, for jpg viewer scrolling.

From: XavierGr <>
Date: Tue, 9 Aug 2005 17:25:36 +0300

Hello all.

These days I am trying to make some change in jpg viewer in order to scroll
to other files instead of quiting first.

So, to test this I changed hellowrold plugin to use it as a canvas for my
I have succeed in loading other jpgs by explicitly telling the name of the
file to the viewer. But in order to make the jpg viewer to find the previous
(or next) file I need a small tree context. For this I used part of the
ft_load function of apps/filetree.c.

The problem is that both the simulator and my unit hangs with a runtime
error whenever I try to change a value in the pointer structure (renamed
my_context) tree_context (defined in apps/tree.h)

Do you think that i must avoid the use of the structure tree_context? Also
do I need the Boot information in the code?
I hope that this isn't much of a hassle.

Thanks in advance.

Here is my code:

#include "plugin.h"
#include "dir.h"
#include "file.h"
#include "settings.h"
#include "filetypes.h"
#include "tree.h"

static struct plugin_api* rb;

struct my_context {
int dirlevel;
int dircursor;
int dirstart;
int firstpos; /* which dir entry is on first
position in dir buffer */
int pos_history[MAX_DIR_LEVELS];
int dirpos[MAX_DIR_LEVELS];
int cursorpos[MAX_DIR_LEVELS];
char currdir[MAX_PATH]; /* file use */
int *dirfilter; /* file use */
int filesindir;
int dirsindir; /* file use */
int dirlength; /* total number of entries in dir, incl. those not loaded */
int table_history[MAX_DIR_LEVELS]; /* db use */
int extra_history[MAX_DIR_LEVELS]; /* db use */
int currtable; /* db use */
int currextra; /* db use */

void* dircache;
int dircache_size;
char* name_buffer;
int name_buffer_size;
int dentry_size;
bool dirfull;

int load_dir(struct my_context* c,char* tempdir)
int i;
int name_buffer_used = 0;
DIR *dir;

dir = rb->opendir(tempdir);
return -1; /* not a directory */

c->dirsindir = 0; ------------------------------------------At this point
the error occurs and I can't do anything to prevent this.
c->dirfull = false;


for ( i=0; i < 400; i++ ) {
int len;
struct dirent *entry = rb->readdir(dir);
struct entry* dptr =
(struct entry*)(c->dircache + i * sizeof(struct entry));
if (!entry)

len = rb->strlen(entry->d_name);

/* skip directories . and .. */
if ((entry->attribute & ATTR_DIRECTORY) &&
(((len == 1) &&
(!rb->strncmp(entry->d_name, ".", 1))) ||
((len == 2) &&
(!rb->strncmp(entry->d_name, "..", 2))))) {

/* Skip FAT volume ID */
if (entry->attribute & ATTR_VOLUME_ID) {

/* filter out dotfiles and hidden files */
if (*c->dirfilter != SHOW_ALL &&
((entry->d_name[0]=='.') ||
(entry->attribute & ATTR_HIDDEN))) {

dptr->attr = entry->attribute;

/* Check if file is a jpeg. */
char *dotpos;
dotpos = rb->strrchr(entry->d_name, '.');
*dotpos = 0;

if((len > 4) && (dotpos != ".jpg")){

dptr->name = &c->name_buffer[name_buffer_used];
dptr->time_write =
(long)entry->wrtdate<<16 |
(long)entry->wrttime; /* in one # */
name_buffer_used += len + 1;

if (dptr->attr & ATTR_DIRECTORY) /* count the remaining dirs */

c->filesindir = i;
c->dirlength = i;

return 0;

/* this is the plugin entry point */
enum plugin_status plugin_start(struct plugin_api* api, void* parameter)
/* this macro should be called as the first thing you do in the plugin.
it test that the api version and model the plugin was compiled for
matches the machine it is running on */

rb = api; /* copy to global api pointer */


char *path,*file;
int files, count;
path = "/.rockbox";

int check = load_dir(dir_stat,path);

rb->splash(HZ, true,path);

file = dir_stat->dircache;
files = dir_stat->filesindir;

for (count=0;count<=files;count++)

return PLUGIN_OK;
Received on 2005-08-09

Page template was last modified "Tue Sep 7 00:00:02 2021" The Rockbox Crew -- Privacy Policy