/*
 *      TestClass.c
 *          © LFSoft 1995
 *
 *      Test Classes registering.
 *
 *      19/07/1995  First version
 *
 *      This code is fully a dommain public: Use it as you want...
 *
 *      Testing:
 *      ~~~~~~~~
 *      + First: Register your class
 *          Shell #7 STAT-RAM: > TestClass MyClass
 *              -> 3
 *          3 is uniq id for (MyClass).
 *
 *      + Second: Free your class
 *          Shell #7 STAT-RAM: >TestClass -u 3
 *
 *      Run ListRegistry to see classes' list...
 *
 *   Note:
 *       * All libraries (but registery.library) are openned and closed
 *   automaticaly by DICE's autoinit feature. You must add some code for
 *   others compilers.
 */

#include <proto/exec.h>
#include <proto/registry.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

struct Library *RegistryBase=NULL;

void cleanup( void ){   // We must close the library
    if(RegistryBase)
        CloseLibrary(RegistryBase);
}

void main(int ac, char **av){
    if(ac < 2){ // Help ???
        puts("Usage :\n\tTestClass Nom\n\tTestClass -u ClassID\n");
        exit(10);
    }

    if(!(RegistryBase = OpenLibrary("registry.library",0))){
                            //AutoOpen can't be used 'cause no glue code
        puts("Can't open registry.library");
        exit(20);
    }
    atexit(cleanup);

    if(!strcmp(av[1],"-u"))
        RL_UnRegisterClass(atol(av[2]));
    else
        printf("-> %d\n",RL_RegisterClass(av[1]));

    exit(0);    // That's all folks
}
