#include "squaredance.h"
#include <pthread.h>

int figureLibrariesLoaded;
FigureLib *figureLibraries[12];

static void *danceInitWorker(void *useless) {
    static int dummy_value = 0;
    char buffer[400];
    int i;

    for ( i=0; libNames[i]!=NULL; ++i ) {
	snprintf(buffer,sizeof(buffer),"%s/%s", danceLibDir(), libNames[i]);
	figureLibraries[i] = danceLoadLibrary(buffer);
	figureLibrariesLoaded |= (1<<i);
    }
    pthread_exit(&dummy_value);
return(&dummy_value);
}

void danceInit(void) {
    static int initted = false;
    pthread_t thread;

    if ( initted )
return;
    initted = true;
    pthread_create(&thread,NULL,danceInitWorker,NULL);
}
