PfAssignDllCx()

Assign a context to a local font server

Synopsis:

#include <font_api.h>

int PfAssignDllCx( struct _Pf_ctrl * context,
                   fontdll_t dll );

Arguments:

dll
A font server context, returned by PfAttachLocalDll().
context
A pointer to the font context to use, returned by PfAttachCx() or PfAttachDllCx().

Library:

font

Description:

This function assigns the dll to the font context, context.

Returns:

0
Success
-1
An error occurred (errno is set).

Errors:

EFAULT
The font context is NULL
ENOTSUP
The platform does not support this operation.

Examples:

/* A PtHook example.  Initializes a client level font server
 * instance for any application that invokes PtInit(), and has
 * knowledge of this hook.
 */
#include <font_api.h>
#include <photon/PhProto.h>
#include <stdlib.h>
#include <unistd.h>

static fontdll_t dll;
extern struct _Ph_ctrl *_Ph_;

static void cleanup_hook(void)
{  PfAssignDllCx(_Ph_->font, NULL);
   PfDetachLocalDll(dll);
   dll = NULL;
}

int PtHook(void * data)
{  if(data != NULL)
   {  if((dll = PfAttachLocalDll(NULL, NULL)) == NULL)
        return(0);
      else
      {  if(PfAssignDllCx(_Ph_->font, dll) == -1)
         {  PfDetachLocalDll(dll);
            return(0);
         }
         else
         {  if(access("/dev/fontsleuthctrl", F_OK) == 0)
              if(PfAttachSleuthMonitorDll(dll, -1) == -1)
              {  PfAssignDllCx(_Ph_->font, NULL);
                 PfDetachLocalDll(dll);
                 return(0);
              }

            if(atexit(cleanup_hook) != 0)
            {  PfAssignDllCx(_Ph_->font, NULL);
               PfDetachLocalDll(dll);
               return(0);
            }
         }
      }
   }
   else
     return(0);

   return(1);
}

Classification:

Photon

Safety:
Cancellation point No
Interrupt handler No
Signal handler No
Thread Yes

See also:

PfAttachCx(), PfAttachDllCx(), PfAttachLocalDll()

Fonts chapter of the Photon Programmer's Guide