rem: sprintf(RErrorString, "error opening file");
context: RLoadImage(RContext *context, char *file, int index){    RImage *image = NULL;    int i;    struct stat st;        RErrorString[0] = 0;        if (RImageCacheSize<0) {	init_cache();    }        if (RImageCacheSize>0) {		for (i=0; i<RImageCacheSize; i++) {	    if (RImageCache[i].file		&& strcmp(file, RImageCache[i].file)==0) {			if (stat(file, &st)==0 		    && st.st_mtime == RImageCache[i].last_modif) {		    RImageCache[i].last_use = time(NULL);		    return RCloneImage(RImageCache[i].image);		    		} else {		    free(RImageCache[i].file);		    RImageCache[i].file = NULL;		    RDestroyImage(RImageCache[i].image);		}	    }	}    }    switch (identFile(file)) {     case IM_ERROR:	sprintf(RErrorString, "error opening file");	return NULL;     case IM_UNKNOWN:	sprintf(RErrorString, "unknown image format");	return NULL;     case IM_XPM:	image = RLoadXPM(context, file, index);	break;	#ifdef USE_TIFF     case IM_TIFF:	image = RLoadTIFF(context, file, index);	break;#endif /* USE_TIFF */#ifdef USE_PNG     case IM_PNG:	image = RLoadPNG(context, file, index);	break;#endif /* USE_PNG */#ifdef USE_JPEG     case IM_JPEG:	image = RLoadJPEG(context, file, index);	break;#endif /* USE_JPEG */#ifdef USE_GIF     case IM_GIF:	image = RLoadGIF(context, file, index);	break;#endif /* USE_GIF */     case IM_PPM:	image = RLoadPPM(context, file, index);	break;     default:	sprintf(RErrorString, "unsupported image format");	return NULL;    }        /* store image in cache */    if (RImageCacheSize>0 && image && 	(RImageCacheMaxImage==0 	 || RImageCacheMaxImage >= image->width*image->height)) {	time_t oldest=time(NULL);	int oldest_idx = 0;	int done = 0;		for (i=0; i<RImageCacheSize; i++) {	    if (!RImageCache[i].file) {		RImageCache[i].file = malloc(strlen(file)+1);		strcpy(RImageCache[i].file, file);		RImageCache[i].image = RCloneImage(image);		RImageCache[i].last_modif = st.st_mtime;		RImageCache[i].last_use = time(NULL);		done = 1;		break;	    } else {		if (oldest > RImageCache[i].last_use) {		    oldest = RImageCache[i].last_use;		    oldest_idx = i;		}	    }	}		/* if no slot available, dump least recently used one */	if (!done) {	    free(RImageCache[oldest_idx].file);	    RDestroyImage(RImageCache[oldest_idx].image);	    RImageCache[oldest_idx].file = malloc(strlen(file)+1);	    strcpy(RImageCache[oldest_idx].file, file);	    RImageCache[oldest_idx].image = RCloneImage(image);	    RImageCache[oldest_idx].last_modif = st.st_mtime;	    RImageCache[oldest_idx].last_use = time(NULL);	}    }    return image;}