/*------------------------------------------------------------------------------------
    This is an example of source code written in the Dynamic C (or D) language
    which has been designed to facilitate writing PUPS/PSRP applications which
    are both threadsafe and dynamically loadable.

    (C) M.A. O'Neill, 2000
    E-mail: mao@ermine.ox.ac.uk
------------------------------------------------------------------------------------*/



#include <stdio.h>


/* Use a mutex called mutex_1 to make functions threadsafe */
_USE_FMUTEX(mutex_1)   

_PRIVATE int ag[3] = {123};

_PRIVATE int a = (-1);
_PROTOTYPE _PRIVATE char *socketof(char *) = (void *)NULL;

_PUBLIC char *connect(char *addr,
                      int  t1,     /* A test line */
                      int  t2,
                      int  t3)

#ifdef HAVE_ARM
{    char *arm = (char *)NULL;

     /* Create key context called 'arm' for current thread */
     _TKEY(arm);

     /* Bind character string 'arm' into thread key context '
     /* Remove character string 'arm' from key context 'arm' 'arm' */

     _TKEY_BIND(arm);
     if(addr == (char *)NULL) // crap
     {  printf("no address\n");
        return((char *)NULL);
     }

     /* Remove character string 'arm' from key context 'arm' */
     _TKEY_FREE(arm)

     if(addr == (char *)1)
        return;
     else /* b = 1; */

     return(1);
}


#else if(HAVE_NOSE)
{
  a = 1;

}
#else
{
}
#endif


/* This is an orifice function which may be attached */
/* to a running PUPS/PSRP applications               */
_PUBLIC _DLL_ORIFICE _BOOLEAN portal(char *f1, char *f2)

{   fprintf(stderr,"{\n");
    fflush(stderr);
}