📄 resource.h
字号:
SSMResourceHTMLFunc m_html_func; SSMResourcePrintFunc m_print_func; SSMSubmitHandlerFunc m_submit_func; PRBool m_resourceShutdown;};/* Macros */#define RESOURCE_CLASS(x) ( ((SSMResource *) (x))->m_classType )/************************************************************** FUNCTION: SSM_CreateResource**** DESCRIPTION: Create a new resource of type (type). If (rawData)** is not NULL, get initial values from that structure.** rawData is treated differently depending on the type** of resource being created; for example, a certificate** object will store a reference to the certificate ** structure in (rawData), whereas a connection resource** will copy values out of an SSMHashTable pointed to** by (rawData).** INPUTS:** type** The type of resource to be created.** arg** A type-dependent initial value for attribute(s) of the newly** created resource.** resID** Returns the ID of the newly created resource.** result** Returns a pointer to the newly created resource.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or the underlying NSPR error,** if it is available.***************************************************************/SSMStatus SSM_CreateResource(SSMResourceType type, void *arg, SSMControlConnection * conn, SSMResourceID *resID, SSMResource **result); /************************************************************** FUNCTION: SSM_GetResAttribute**** DESCRIPTION: Get an attribute from an SSMResource object.**** INPUTS:** res** The resource from which an attribute is to be retrieved.** attrID** The field/resource ID of the attribute.** attrType** The expected type of the retrieved attribute.** value** The attribute value to be filled in.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or the underlying NSPR error,** if it is available.**** NOTES:** ### mwelch All this memory allocation can be problematic.*************************************************************/SSMStatus SSM_GetResAttribute(SSMResource *res, SSMAttributeID attrID, SSMResourceAttrType attrType, SSMAttributeValue *value);/************************************************************** FUNCTION: SSM_SetResAttribute**** DESCRIPTION: Set an attribute on an SSMResource object. If** the attribute does not yet exist, it is created.**** INPUTS:** res** The resource in which an attribute is to be changed.** attrID** The field/resource ID of the attribute.** value** A pointer to the value of the newly changed attribute. The value** is copied into the resource.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or the underlying NSPR error,** if it is available.*************************************************************/SSMStatus SSM_SetResAttribute(SSMResource *res, SSMAttributeID attrID, SSMAttributeValue *value);/************************************************************** FUNCTION: SSM_PickleResource** ** DESCRIPTION: Pickle resource. ** ** INPUTS: ** res** The resource to be pickled.**** OUTPUTS:** len** Length of the pickled blob.** value** Pickled resource.**** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or NSPR error code.*************************************************************/ SSMStatusSSM_PickleResource(SSMResource * res, PRIntn * len, void ** value);/************************************************************** FUNCTION: SSM_FreeResource**** DESCRIPTION: Free a reference on (res). If the reference count** reaches 0, (res) is destroyed.**** INPUTS:** res** The resource to be dereferenced.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or the underlying NSPR error,** if it is available.*************************************************************/SSMStatus SSM_FreeResource(SSMResource *res);/************************************************************** FUNCTION: SSM_GetResourceReference**** DESCRIPTION: Get a reference on (res). **** INPUTS:** res** The resource to be referenced.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE or the underlying NSPR error,** if it is available.*************************************************************/SSMStatus SSM_GetResourceReference(SSMResource *res);/************************************************************** FUNCTION: SSM_RegisterResourceType**** DESCRIPTION: Register a resource type within the PSM server.**** INPUTS:** type** The new type to be registered.** superClass** Inherit functions from the already-registered superclass.** if (superClass) is not SSM_RESTYPE_NULL and any function** parameters below are NULL, those functions are inherited** from the indicated superclass.** createFunc, rDestFunc, setFunc, getFunc** Accessor functions for the resource.** RETURNS:** If successful, returns PR_SUCCESS.** If failed, returns either PR_FAILURE, the underlying NSPR error,** or the following values:** SSM_ERR_INVALID_FUNC: (superClass) was SSM_RESTYPE_NULL** and one or more of the function parameters** was also NULL.*************************************************************/SSMStatus SSM_RegisterResourceType(char * className, SSMResourceType type, SSMResourceType superClass, SSMClientDestroyAction cDestAction, SSMResourceCreateFunc createFunc, SSMResourceDestroyFunc destFunc, SSMResourceShutdownFunc shutdownFunc, SSMResourceGetAttrIDsFunc getIDsFunc, SSMResourceGetAttrFunc getFunc, SSMResourceSetAttrFunc setFunc, SSMResourcePickleFunc pickleFunc, SSMResourceUnpickleFunc unpickleFunc, SSMResourceHTMLFunc htmlFunc, SSMResourcePrintFunc printFunc, SSMSubmitHandlerFunc submitFunc);PRBool SSM_IsA(SSMResource *res, SSMResourceType type);PRBool SSM_IsAKindOf(SSMResource *res, SSMResourceType type);SSMStatus SSM_ClientGetResourceReference(SSMResource *res, SSMResourceID *id);SSMStatus SSM_ShutdownResource(SSMResource *res, SSMStatus status);SSMStatus SSM_ClientDestroyResource(SSMControlConnection *connection, SSMResourceID rid, SSMResourceType type);void SSM_LockResource(SSMResource *res);SSMStatus SSM_UnlockResource(SSMResource *res);SSMStatus SSM_WaitResource(SSMResource *res, PRIntervalTime ticks);SSMStatus SSM_WaitForOKCancelEvent(SSMResource *res, PRIntervalTime ticks);SSMStatus SSM_NotifyOKCancelEvent(SSMResource *res);SSMStatus SSM_NotifyResource(SSMResource *res);void SSM_LockUIEvent(SSMResource *res);SSMStatus SSM_UnlockUIEvent(SSMResource *res);SSMStatus SSM_WaitUIEvent(SSMResource *res, PRIntervalTime ticks);SSMStatus SSM_NotifyUIEvent(SSMResource *);SSMStatus SSM_PickleResource(SSMResource * res, PRIntn * len, void ** value);SSMStatus SSM_UnpickleResource(SSMResource ** res, SSMResourceType type, SSMControlConnection * connection, PRIntn len, void * value);SSMStatus SSM_MessageFormatResource(SSMResource *res, char *fmt, PRIntn numParam, char ** value, char **resultStr);SSMStatus SSMResource_Create(void *arg, SSMControlConnection * conn, SSMResource **res);SSMStatus SSMResource_Destroy(SSMResource *res, PRBool doFree);SSMStatus SSMResource_Shutdown(SSMResource *res, SSMStatus status);SSMStatus SSMResource_Init(SSMControlConnection * conn, SSMResource *res, SSMResourceType type);void SSMResource_Invariant(SSMResource *res);SSMStatus SSMResource_GetAttr(SSMResource *res, SSMAttributeID attrID, SSMResourceAttrType attrType, SSMAttributeValue *value);SSMStatus SSMResource_SetAttr(SSMResource *res, SSMAttributeID attrID, SSMAttributeValue *value);SSMStatus SSMResource_GetAttrIDs(SSMResource *res, SSMAttributeID **ids, PRIntn *count);SSMStatus SSMResource_Pickle(SSMResource *res, PRIntn * len, void **value);SSMStatus SSMResource_Unpickle(SSMResource ** res, SSMControlConnection *conn, PRIntn len, void * value);SSMStatus SSMResource_HTML(SSMResource *res, PRIntn * len, void ** value);SSMStatus SSMResource_Print(SSMResource *res, char *fmt, PRIntn numParam, char **value, char **resultStr);SSMStatus SSMResource_FormSubmitHandler(SSMResource *res, HTTPRequest *req);/* ALWAYS pass in msg a string allocated by NSPR (PR_smprintf for example), because the string is freed from within SSM_Debug. */void SSM_Debug(SSMResource *res, char *msg);char * SSM_ResourceClassName(SSMResource *res);/* Wait for a resource to shut down. */SSMStatus SSM_WaitForResourceShutdown(SSMResource *res);/* Register a thread with a resource (or pass arg==NULL for standalone) */void SSM_RegisterThread(char *threadName, SSMResource *arg);void SSM_RegisterNewThread(char *threadName, SSMResource *ptr);SSMStatusSSM_ShutdownResource(SSMResource *res, SSMStatus status);SSMStatus SSM_HandlePromptReply(SSMResource *res, char *reply);/* Initialize resources. Only called by main. */SSMStatus SSM_ResourceInit();/* Create a resource thread */PRThread *SSM_CreateThread(SSMResource *res, void (*func)(void *arg));#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -