📄 stafutil.h
字号:
STAFString_t *outputString, ...);/*********************************************************************//* STAFUtilFormatString2 - Generates a string based on a format *//* string, ala printf(). This is generally *//* used to format STAF request strings. *//* *//* Accepts: (In) The format string *//* (Out) A pointer to the output string *//* (In) A variable argument list *//* *//* Returns: Standard return codes *//* *//* Notes : 1) The caller is responsible for destructing the *//* output string *//* 2) Valid format strings are the same as defined for *//* STAFUtilFormatString() *//*********************************************************************/unsigned int STAFUtilFormatString2(STAFStringConst_t formatString, STAFString_t *outputString, va_list args);/*********************************************************************//* STAFUtilCreateTempFile - Creates a 0 length temporary file *//* *//* Accepts: (In) A pointer to a string containing the name of the *//* directory to store the temporary file in *//* (In) A pointer to a string containing the suffix for *//* the temporary file name *//* (In) The request number (used in generating a unique *//* random seed) *//* (Out) A pointer to a string containing the name of the *//* temporary file created *//* (Out) A pointer to an error string *//* (Out) A pointer to an operating system return code *//* *//* Returns: 0, if successful *//* >0, if unsuccessful (*errorBuffer and *osRC will be set) *//* *//* Notes : 1) The caller is responsible for destructing the output *//* string containing the name of the temporary file *//*********************************************************************/STAFRC_t STAFUtilCreateTempFile(STAFStringConst_t prefix, STAFStringConst_t suffix, unsigned int requestNumber, STAFString_t *tempFileName, STAFString_t *errorBuffer, unsigned int *osRC);/*********************************************************************//* STAFUtilStripPortFromEndpoint - Removes @<Port> from the end of *//* an endpoint if present. *//* *//* Accepts: (In/Out) A pointer to a string containing the endpoint *//* with format: *//* [<Interface>://<Machine Identifier>[@<Port>] *//* (Out) A pointer to a string containing the stripped *//* endpoint with format: *//* [<Interface>://<Machine Identifier> *//* *//* Returns: 0 *//* Notes : 1) The caller is responsible for destructing the output *//* string containing the stripped endpoint *//*********************************************************************/STAFRC_t STAFUtilStripPortFromEndpoint(STAFStringConst_t endpoint, STAFString_t *strippedEndpoint);/*********************************************************************//* STAFUtilValidateTrust - Verifies that the actual trust level is *//* not less than the required trust level. *//* *//* Accepts: (In) The actual trust level of the requesting machine *//* (In) The required trust level for the service request *//* (In) A pointer to a string containing the name of the *//* service *//* (In) A pointer to a string containing the request string*//* (In) A pointer to a string containing the name of the *//* local machine (it's STAF/Config/Machine value) *//* (In) A pointer to a string containing the endpoint of *//* the requesting machine *//* (In) A pointer to a string containing the physical *//* interface identifier of the requesting machine *//* (In) A pointer to a string containing the user of the *//* requesting machine *//* (Out) A pointer to an error string *//* *//* Returns: 0, if successful *//* 25, if unsuccessful (*errorBuffer will be set) *//*********************************************************************/STAFRC_t STAFUtilValidateTrust(unsigned int actualTrustLevel, unsigned int requiredTrustLevel, STAFStringConst_t service, STAFStringConst_t request, STAFStringConst_t localMachine, STAFStringConst_t requestingEndpoint, STAFStringConst_t physicalInterfaceID, STAFStringConst_t requestingUser, STAFString_t *errorBuffer);#ifdef __cplusplus/***********************************************************************//* VALIDATE_TRUST - Macro to verify that the actual trust level is *//* not less than the required trust level. This is what most of *//* the STAF C++ external services use to verify trust. *//* It assumes the service uses the following variable names: *//* - pInfo: contains the service request information *//***********************************************************************/#define VALIDATE_TRUST(requiredTrustLevel, service, request, localMachine)\STAFString_t stafUtilTrustErrorBuffer = 0;\STAFRC_t stafUtilTrustRC = STAFUtilValidateTrust(\ pInfo->trustLevel, requiredTrustLevel, STAFString(service).getImpl(),\ STAFString(request).getImpl(), localMachine.getImpl(),\ pInfo->endpoint, pInfo->physicalInterfaceID, pInfo->user,\ &stafUtilTrustErrorBuffer);\if (stafUtilTrustRC != kSTAFOk)\ return STAFResultPtr(new STAFResult(kSTAFAccessDenied,\ STAFString(stafUtilTrustErrorBuffer, STAFString::kShallow)),\ STAFResultPtr::INIT); /***********************************************************************//* VALIDATE_TRUST2- Macro to verify that the actual trust level is *//* not less than the required trust level. This is just like *//* the VALIDATE_TRUST macro except it uses different names for *//* the variables it defines so that it can be run in the same *//* function as where you ran VALIDATE_TRUST. This can be useful *//* if you want to first check if a request has a trust level *//* but then you find that an option like FORCE was specified that *//* requires a higher trust level so you can then use this macro. *//* It assumes the service uses the following variable names: *//* - pInfo: contains the service request information *//***********************************************************************/#define VALIDATE_TRUST2(requiredTrustLevel, service, request, localMachine)\STAFString_t stafUtilTrustErrorBuffer = 0;\STAFRC_t stafUtilTrustRC = STAFUtilValidateTrust(\ pInfo->trustLevel, requiredTrustLevel, STAFString(service).getImpl(),\ STAFString(request).getImpl(), localMachine.getImpl(),\ pInfo->endpoint, pInfo->physicalInterfaceID, pInfo->user,\ &stafUtilTrustErrorBuffer);\if (stafUtilTrustRC != kSTAFOk)\ return STAFResultPtr(new STAFResult(kSTAFAccessDenied,\ STAFString(stafUtilTrustErrorBuffer, STAFString::kShallow)),\ STAFResultPtr::INIT); /***********************************************************************//* VALIDATE_TRUST3 - Macro to verify that the actual trust level is *//* not less than the required trust level. This is what a STAF *//* C++ external service can use to verify trust if can't use the *//* pInfo variable (or a different named variable) to contain the *//* service request information. This macro can be used if *//* individual STAFStrings are used to contain the requesting *//* machine's trust level, endpoint, physicalInterfaceID, and/or *//* user values. *//***********************************************************************/#define VALIDATE_TRUST3(requiredTrustLevel, service, request, localMachine,\ actualTrustLevel, endpoint, physicalInterfaceID, user)\STAFString_t stafUtilTrustErrorBuffer = 0;\STAFRC_t stafUtilTrustRC = STAFUtilValidateTrust(\ actualTrustLevel, requiredTrustLevel, STAFString(service).getImpl(),\ STAFString(request).getImpl(), localMachine.getImpl(),\ STAFString(endpoint).getImpl(), STAFString(physicalInterfaceID).getImpl(),\ STAFString(user).getImpl(), &stafUtilTrustErrorBuffer);\if (stafUtilTrustRC != kSTAFOk)\ return STAFResultPtr(new STAFResult(kSTAFAccessDenied,\ STAFString(stafUtilTrustErrorBuffer, STAFString::kShallow)),\ STAFResultPtr::INIT); /***********************************************************************//* VALIDATE_TRUST4 - Macro to verify that the actual trust level is *//* not less than the required trust level. This is what a STAF *//* C++ external service can use to verify trust if it's not using *//* the standard name of pInfo to contain the service request *//* information. *//* - info: contains the service request information *//***********************************************************************/#define VALIDATE_TRUST4(requiredTrustLevel, service, request, localMachine,\ info)\STAFString_t stafUtilTrustErrorBuffer = 0;\STAFRC_t stafUtilTrustRC = STAFUtilValidateTrust(\ info->trustLevel, requiredTrustLevel, STAFString(service).getImpl(),\ STAFString(request).getImpl(), localMachine.getImpl(),\ info->endpoint, info->physicalInterfaceID, info->user,\ &stafUtilTrustErrorBuffer);\if (stafUtilTrustRC != kSTAFOk)\ return STAFResultPtr(new STAFResult(kSTAFAccessDenied,\ STAFString(stafUtilTrustErrorBuffer, STAFString::kShallow)),\ STAFResultPtr::INIT);}#endif#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -