diff -r 49fc8f60e4a5 -r 868db5c1f2d7 setup/setup.c --- a/setup/setup.c Thu Jul 09 08:23:50 2009 +0100 +++ b/setup/setup.c Thu Aug 13 19:01:16 2009 +0100 @@ -86,34 +86,15 @@ return realloc(ptr,nsize); } -void setup() +void setup(const char *argv0) { - char path[PATH_MAX],*s,*t,*prefix; + char *path,*s,*prefix; int changed; struct comps *comps; struct comps_group *group; struct comps_requirement *pkg; struct vector *packages=NULL; -#ifdef WIN32 - SHGetFolderPath(NULL,CSIDL_PROGRAM_FILES|CSIDL_FLAG_DONT_VERIFY,NULL,0, - path); - prefix=strdup(path); - GetModuleFileName(NULL,path,sizeof(path)); - s=strrchr(path,'/'); - if (s) - { - t=strrchr(s,'\\'); - if (t) - s=t; - } - else - s=strrchr(path,'\\'); - if (s) - *s='\0'; -#else - strcpy(path,"/tmp"); - prefix=NULL; -#endif + path=plover_get_program_directory(argv0); s=plover_strconcat(path,"/repodata/comps.xml",NULL); comps=plover_comps_new_from_file(s); if (!comps) @@ -122,11 +103,7 @@ exit(1); } free(s); -#ifdef WIN32 - s=plover_strconcat(prefix,"\\",comps->vendor?comps->vendor:"Plover",NULL); - free(prefix); - prefix=s; -#endif + prefix=plover_default_prefix_for_vendor(comps->vendor); group=plover_comps_lookup_group(comps,"base"); if (!group) { @@ -151,6 +128,7 @@ } } } while(changed); + plover_comps_free(comps); if (!packages->len) { fprintf(stderr,"No packages to install\n"); @@ -158,10 +136,8 @@ } plover_install(path,prefix,packages->strings); vector_free(packages); - plover_comps_free(comps); -#ifdef WIN32 free(prefix); -#endif + free(path); } int main(int argc,char **argv) @@ -171,5 +147,5 @@ if (argc>1 && !strcmp(argv[1],"-u")) plover_remove(NULL); else - setup(); + setup(argv[0]); }