SetNLMDontUnloadFlag

Sets a flag in the header of an NLM to prevent the NLM from being unloaded with the UNLOAD command at the system console

Local Servers:nonblocking
Remote Servers:N/A
Classification:4.x, 5.x, 6.x
Service:Thread

Syntax

  #include <nwthread.h>  
   
  int SetNLMDontUnloadFlag  (  
     int   NLMID); 
  

Parameters

NLMID
(IN) Specifies the ID of the NLM that is to be made so it cannot be unload from the command line.

Return Values

The following table lists return values and descriptions.

Value

Hex

Name

Description

–1

 

EFAILURE

NLMID was an invalid NLM ID.

0

(0x00)

ESUCCESS

The don’t unload flag has been set.

Remarks

A console operator can unload an NLM from the system console command line by issuing the following command:

     UNLOAD NLM_NAME 
  

where NLM_NAME is the name of the NLM being unloaded.

If there is a check function for the NLM (declared with the OPTION CHECK directive), it is called when the "UNLOAD NLM_NAME" command is entered. This function then must decide if it is safe to unload the NLM. If it is safe to unload the NLM, the function returns 0 and the NLM is unloaded. If the function determines that the NLM should not be unloaded, it returns a nonzero value and the following prompt is displayed on the system console:

     UNLOAD module anyway? n 
  

In this case, the console operation can choose to unload the NLM anyway, by pressing the "y" key, instead of the "n" key.

If SetNLMDontUnloadFlag is called, the NLM can only be unloaded after ClearNLMDontUnloadFlag is called.

For more information about unloading NLM applications, see CHECK Function (NDK: NLM Development Concepts, Tools, and Functions).

See Also

ClearNLMDontUnloadFlag, GetNLMID

Example

  #include <nwconio.h>  
  #include <errno.h>  
  #include <stdio.h>  
  #include <nwthread.h>  
   
  main()  
  {  
     int NLMID, result;  
     NLMID=GetNLMID();  
     result=SetNLMDontUnloadFlag(NLMID);  
     if(result==ESUCCESS)  
     {  
        printf("DONTUNLD.NLM cannot be unloaded now.\n");  
        printf("Press any key to be able to unload this NLM\n");  
        getch();  
        ClearNLMDontUnloadFlag(NLMID);  
        printf("\nYou can unload DONTUNLD.NLM now.\n");  
        getch();  
     }  
     else  
        printf("Could not set the don’t unload flag.\n");  
  }