register_library

Registers third-party library code as a library with LibC.

Library:LibC
Service:Library

Syntax

  #include <library.h> 
   
  int register_library (
     int   (*cleanupFunc) (void *data_area)); 
  

Parameters

cleanupFunc

(IN) Points to a function to be called whenever one of the clients of the library is terminated by either an UNLOAD command or because the NLM terminated itself by calling exit, abort, NXThreadExit, or so on.

Return Values

If successful, returns a lib_id. Otherwise, returns -1 and sets errno to the following:

Decimal

Name

Description

5

ENOMEM

No memory could be allocated.

Remarks

If the calling library wants to support downstream clients that are coding to LibC, call register_library.

register_library must be called prior to calling any other function that requires a LibC library handle (which is the returned lib_id).

Because a library ID is returned every time register_library is called and the caller remembers this value when it calls other functions, no context is required to call register_library.

When the calling application goes down, the registered cleanup function is called and passed a pointer to the application's saved data area (as set by the registered library).

The return value of the cleanup function is ignored but is designated as an int value in case the application wants to call the function itself for other purposes.

For sample code, see Library.c.

See Also