Mercurial > MadButterfly
changeset 452:cb10f3424f3a
re-indent
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 05 Aug 2009 17:46:03 +0800 |
parents | 5c9e2a8a4bd8 |
children | 84ce2d4a8c3f |
files | src/sprite.c |
diffstat | 1 files changed, 46 insertions(+), 45 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sprite.c Wed Aug 05 16:10:47 2009 +0800 +++ b/src/sprite.c Wed Aug 05 17:46:03 2009 +0800 @@ -11,61 +11,62 @@ #include "mb_observer.h" #include "mb_prop.h" -static char *Sprite_Search_Path=NULL; +static char *sprite_search_path=NULL; + static int sprite_search_so(char *path, int len, const char *name) { - struct stat st; - - if (Sprite_Search_Path == NULL) { - Sprite_Search_Path = strdup("/usr/share/madbutterffly"); - } - - snprintf(path, len, "./%s.so", name); - if (stat(path, &st)==0) { - return 0; - } - snprintf(path, len, "%s/%s.so", Sprite_Search_Path, name); - if (stat(path, &st)==0) { - return 0; - } else { - return -1; - } + struct stat st; + + if (sprite_search_path == NULL) { + sprite_search_path = strdup("/usr/share/madbutterffly"); + } + + snprintf(path, len, "./%s.so", name); + if (stat(path, &st)==0) { + return 0; + } + snprintf(path, len, "%s/%s.so", sprite_search_path, name); + if (stat(path, &st)==0) { + return 0; + } else { + return -1; + } } void sprite_set_search_path(char *path) { - if (Sprite_Search_Path) - free(Sprite_Search_Path); - Sprite_Search_Path = strdup(path); + if (sprite_search_path) + free(sprite_search_path); + sprite_search_path = strdup(path); } mb_sprite_t *sprite_load(const char *name, redraw_man_t *rdman, coord_t *root) { - char path[1024]; - const char *s; - void *handle; - mb_sprite_t *(*new)(redraw_man_t *, coord_t *); - mb_sprite_t *obj; - - if (sprite_search_so(path, sizeof(path),name)) { - fprintf(stderr," can not find %s in search path\n", name); - return NULL; - } - handle = dlopen(path,RTLD_LAZY); - if (handle == NULL) { - fprintf(stderr, "can not load object %s\n", path); - return NULL; - } - s = name + strlen(name)-1; - while((s != name) && *(s-1) != '/') s--; - snprintf(path,sizeof(path), "%s_new", s); - new = dlsym(handle,path); - if (new == NULL) { - fprintf(stderr," Can not find symbol %s at module\n", path); - return NULL; - } - obj = new(rdman, root); - return obj; + char path[1024]; + const char *s; + void *handle; + mb_sprite_t *(*new)(redraw_man_t *, coord_t *); + mb_sprite_t *obj; + + if (sprite_search_so(path, sizeof(path),name)) { + fprintf(stderr," can not find %s in search path\n", name); + return NULL; + } + handle = dlopen(path,RTLD_LAZY); + if (handle == NULL) { + fprintf(stderr, "can not load object %s\n", path); + return NULL; + } + s = name + strlen(name)-1; + while((s != name) && *(s-1) != '/') s--; + snprintf(path,sizeof(path), "%s_new", s); + new = dlsym(handle,path); + if (new == NULL) { + fprintf(stderr," Can not find symbol %s at module\n", path); + return NULL; + } + obj = new(rdman, root); + return obj; } /* vim: set ts=4 */