⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 apiref.script

📁 Software Testing Automation Framework (STAF)的开发代码
💻 SCRIPT
📖 第 1 页 / 共 4 页
字号:
.***************************************************************************.* Software Testing Automation Framework (STAF).* (C) Copyright IBM Corp. 2001.*.* This software is licensed under the Common Public License (CPL) V1.0. .****************************************************************************.*************************-START-OF-PROLOG-****************************.*.*  File Name          : APIRef SCRIPT.*  Descriptive Name   : Software Test Automation Framework API Reference.*  Detail:.*.*     This file contains an API Reference..*.**************************-END-OF-PROLOG-*****************************:i1.API Reference:h1 id=apiref.API Reference:h2 id=marshall.Marshalling Structured Data:p.STAF supports the automatic marshalling and unmarshalling of structured data.The act of marshalling takes a data structure and converts it into astring-based representation.  The act of unmarshalling reverses this andconverts the string-based representation back into a data structure.:p.STAF supports the following generic data types with its marshalling.:ul compact.:li.None - a unique type representing the absence of a value:li.String - an arbitrary string value:li.List - an ordered collection of other objects:li.Map - an unordered collection of key/value pairs:li.Map class - a Map with intrinsic metadata:li.Marshalling context - represents a set of map class definitions and adata structure defined in terms of them:eul.:p.Most languages support some form of the None, String, List, and Mapdata types.  However, a map class and a marshalling context are likely newconcepts.:p.A map class is really just a specialized map that is associated with a map class definition.  The map class definition is used to reduce the size ofa marshalling map class in comparison to a map containing the same data.  Italso contains information about how to display instances of the map class.A map class definition contains for following information for each keydefined for a map class::ul compact.:li.key -  The name of the key in the map class:li.display-name - The display name for the key:li.display-short-name - The short display name for the key (Optional):eul.:p.You indicate that a map is an instance of a map class by setting the key"staf-map-class-name" to the name of the map class.  And, when you unmarshalla data structure, if you see that a map has a key called "staf-map-class-name",you know that the map is really an instance of a map class.  You get and setmap class definitions using a marshalling context.:p.A marshalling context is simply a container for map class definitions anda data structure that uses (or is defined in terms of) them.  In order touse a map class when marshalling data, you must add the map class definitionto the marshalling context, set the root object of the marshalling context tothe object you want to marshall, and then marshall the marshalling contextitself.  When you unmarshall a data structure, you will always receive amarshalling context.  Any map class definitions referenced by map classeswithin the data structure will be present in the marshalling context.:p.When a string is unmarshalled into a data structure, it is possible thatone of the string objects that is unmarshalled is itself the string form ofanother marshalled data structure.  By default, STAF will recursivelyunmarshall these nested objects.  However, each language has a way todisable these additional processing..*.*---------------------------------------------------------------------.*:h2 id=capi.C:p.STAF externalizes six primary APIs to C/C++ programs.  These APIs allow youto register/unregister with STAF, submit service requests, and free the memoryassociated with service request results.  In addition, STAF provides a widerange of APIs for defining, manipulating, and marshalling data structures.Also, STAF provides some APIs for handling private data.:p.:note.STAF-enabled programs written in C must be linked with the C++ compiler(or by using any other means which allows the C++ runtime to get initialized).Otherwise, the C++ runtime won't get a chance to initialize so the STAFstatic data doesn't get initialized.  Most systems require mixed C and C++ codeto get linked by the C++ compiler..*.*---------------------------------------------------------------------.*:ih1.registration:i2.STAFRegister C API:ih1.C API:i2.STAFRegister:h3.STAFRegister:h4.Description:p.The STAFRegister call is used by a C program to register with STAF.:h4.Syntax:xmp.STAFRC_t STAFRegister(char *handleName, STAFHandle *handle):exmp.:p.:xph.handleName:exph. points to the name by which you want this handle tobe known.:p.:xph.handle:exph. is a pointer to the STAFHandle that will be set onsuccessful return from the function.  You will use this handle on all othersubsequent STAF calls.:ih1.examples:ih2.C/C++ API:i3.STAFRegister:h4.Examples:xmp.char *myName = "MyProgram";STAFHandle_t myHandle = 0;STAFRC_t rc = STAFRegister(myName, &myHandle);:exmp..*.*---------------------------------------------------------------------.*:ih1.registration:i2.STAFRegisterUTF8 C API:ih1.C API:i2.STAFRegisterUTF8:h3.STAFRegisterUTF8:h4.Description:p.The STAFRegisterUTF8 API is identical in all respects with STAFRegister,except that :xph.handleName:exph. is a string in UTF-8 format.  This API isused primarily by the Java interfaces..*.*---------------------------------------------------------------------.*:ih1.registration:i2.STAFUnRegister C API:ih1.C API:i2.STAFUnRegister:h3.STAFUnRegister:p.The STAFUnRegister call is used by a C program to unregister withSTAF, which frees up any internal STAF resources used by the handle.:h4.Syntax:xmp.STAFRC_t STAFUnRegister(STAFHandle handle):exmp.:p.:xph.handle:exph. is the handle that you received on the call toSTAFRegister.:ih1.examples:ih2.C API:i3.STAFUnRegister:h4.Examples:xmp./* myHandle was previously set by STAFRegister */STAFRC_t rc = STAFUnRegister(myHandle);:exmp..*.*---------------------------------------------------------------------.*:ih1.C API:i2.STAFSubmit:h3.STAFSubmit:h4.Description:p.The STAFSubmit call is the primary API that you will use.  It is whatallows you to submit a request to a service.:h4.Syntax:xmp.STAFRC_t STAFSubmit(STAFHandle handle, char *where, char *service,                    char *request, unsigned int requestLength,                    char **resultPtr, unsigned int *resultLength);:exmp.:p.:xph.handle:exph. is the handle you received on the call to STAFRegister.:p.:xph.where:exph. points to a string containing the destination machine forthe service request.  This should be either LOCAL or the name of a machine.:p.:xph.service:exph. points to the name of the service to which you aresubmitting the request.:p.:xph.request:exph. points to the actual request that you are sending to theservice. This request may contain NULL (0x00) bytes.:p.:xph.requestLength:exph. indicates the length of the request buffer passedin.:p.:xph.resultPtr:exph. points to a char * that will contain the address of theresult on return from the function.  If, on return from STAFSubmit,:xph.*resultPtr:exph. is not 0, you must use STAFFree to free the result, evenif the return code from STAFSubmit was non-zero.  Note, if resultPtr isnon-zero, then the buffer that resultPtr points to will always be NULLterminated.  However, this buffer may contain NULL (0x00) bytes, therefore, itis not safe to determine the length of the buffer via strlen().  Instead, youshould use the length provided by :xph.resultLength:exph. below.:p.:xph.resultLength:exph. points to an unsigned int which, on return fromSTAFSubmit, will contain the length of the result buffer.:ih1.examples:ih2.C API:i3.STAFSubmit:h4.Examples:xmp./* myHandle was previously set by STAFRegister */char *someMachine = "testmach1";char *service = "PING";char *request = "PING";unsigned int requestLength = strlen(request);char *result = 0;unsigned int resultLength = 0;STAFRC_t rc = 0;rc = STAFSubmit(myHandle, someMachine, service, request, requestLength,                &result, &resultLength);:exmp..*.*---------------------------------------------------------------------.*:i2.STAFSubmit2:h3 id=apiss2.STAFSubmit2:h4.Description:p.The STAFSubmit2 API is identical to the STAFSubmit API except thatit has an additional parameter, syncOption, which allows submission ofasynchronous requests.:h4.Syntax:xmp.STAFRC_t STAFSubmit2(STAFHandle_t handle, STAFSyncOption_t syncOption,                     char *where, char *service,                     char *request, unsigned int requestLength,                     char **resultPtr, unsigned int *resultLength):exmp.:p.syncOption can be any of the following::ul compact.:li.kSTAFReqSync - This indicates the request should be submitted synchronously.This is equivalent to calling the STAFSubmit() API.:li.kSTAFReqFireAndForget - This indicates the request should be submittedasynchronously.  The request number will be passed back in the result buffer.The request's results will not be sent to the submitter's queue nor will theybe retained by the Service service.:li.kSTAFReqQueue - This indicates the request should be submittedasynchronously. The request number will be passed back in the result buffer.When the request completes, the results will be placed on the submitter's queue.The format of this message is described below.:li.kSTAFReqRetain - This indicates the request should be submittedasynchronously.  The request number will be passed back in the result buffer.The submitter can determine the results of the request by using the:xph.FREE:exph. command of the Service service (see :hdref refid=srvreqf. formore information).:li.kSTAFReqQueueRetain - This indicates the request should be submittedasynchronously.  The request number will be passed back in the result buffer.When the request completes, the results will be placed on the submitter's queue.The format of this message is described below.  The submitter should also freethe results of the request by using the :xph.FREE:exph. command of the Serviceservice (see :hdref refid=srvreqf. for more information).:eul.:p.The format of the queued message obtained when specifying kSTAFReqQueue orkSTAFReqQueueRetain will be a marshalled :xph.<Map&colon.STAF/RequestComplete>:exph.which represents the request completion information.  See table:tref refid=STAFRequestCompleteTable. for the map class definition.:table id='STAFRequestCompleteTable' cols='* 2* *'.:tcap.Definition of map for "STAF/RequestComplete" type message:tnote text='Description'.This map represents STAF/RequestComplete message information.:thd.:c.Key Name:c.Type:c.Format / Value:ethd.:row.:c.requestNumber:c.&stringObj.:c.:row.:c.rc:c.&stringObj.:c.:row.:c.result:c.&stringObj.:c.:etable.:p.For example, if you submitted the request "RESOLVE STRING {STAF/Config/OS/Name}"to the VAR service using kSTAFReqQueue, and received a request number of 42,then the message you would receive when the request completed might look like:xmp.{  requestNumber: 42  rc           : 0  result       : WinNT}:exmp.:p.The queued message will always be delivered with the default priority of 5..*.*---------------------------------------------------------------------.*:ih1.C API:i2.STAFSubmitUTF8:h3.STAFSubmitUTF8:h4.Description:p.The STAFSubmitUTF8 API is identical in all respects with STAFRegister,except that :xph.where:exph., :xph.service:exph., :xph.request:exph.,and :xph.*resultPtr:exph. are all strings in UTF-8 format.  This API isused primarily by the Java interfaces..*.*---------------------------------------------------------------------.*:ih1.C API:i2.STAFSubmit2UTF8:h3.STAFSubmit2UTF8:h4.Description:p.The STAFSubmit2UTF8 API is identical in all respects with STAFSubmit2,except that :xph.where:exph., :xph.service:exph., :xph.request:exph.,and :xph.*resultPtr:exph. are all strings in UTF-8 format.  This API isused primarily by the Java interfaces..*.*---------------------------------------------------------------------.*:ih1.C API:i2.STAFFree:h3.STAFFree:h4.Description:p.STAFFree is used to free the memory occupied by the result buffer on a callto STAFSubmit.  You only need to call this if result buffer pointer is not zeroon return from STAFSubmit.:h4.Syntax:xmp.STAFRC_t STAFFree(STAFHandle handle, char *result);:exmp.:p.:xph.handle:exph. is the handle you received on the call to STAFRegister.:p.:xph.result:exph. is the pointer passed back from the STAFSubmit call.:ih1.examples:ih2.C API:i3.STAFFree:h4.Examples:xmp./* myHandle was previously set by STAF     *//* result was previously set by STAFSubmit */STAFRC_t rc = 0;if (result != 0) rc = STAFFree(myHandle, result);:exmp..*.*---------------------------------------------------------------------.*:ih1.C API:i2.Data Structure and Marshalling APIs:h3.Data Structure and Marshalling APIs:p.STAF externalizes a wide range of APIs for defining data structures and(un)marshaling data structures.  Here is a list of the APIs.  A later versionof this documentation will provide more details.:xmp.typedef enum{    kSTAFNoneObject               = 0,    kSTAFScalarStringObject       = 1,    kSTAFListObject               = 2,    kSTAFMapObject                = 3,    kSTAFMarshallingContextObject = 4} STAFObjectType_t;typedef enum{    kSTAFMarshallingDefaults = 0x00000000} STAFObjectMarshallingFlags_t;typedef enum{    kSTAFUnmarshallingDefaults = 0x00000000,    kSTAFIgnoreIndirectObjects = 0x00000001} STAFObjectUnmarshallingFlags_t;// Object constructors/destructors//// Note: When a STAFObject is destructed, it recursively deletes all nested//       objectsSTAFRC_t STAFObjectConstructCopy(STAFObject_t *copy, STAFObject_t source);STAFRC_t STAFObjectConstructReference(STAFObject_t *ref, STAFObject_t source);STAFRC_t STAFObjectConstructNone(STAFObject_t *pNone);STAFRC_t STAFObjectConstructScalarString(STAFObject_t *pScalar,                                         STAFStringConst_t string);STAFRC_t STAFObjectConstructList(STAFObject_t *list);STAFRC_t STAFObjectConstructMap(STAFObject_t *map);STAFRC_t STAFObjectConstructMarshallingContext(STAFObject_t *context);STAFRC_t STAFObjectDestruct(STAFObject_t *object);// General functionsSTAFRC_t STAFObjectIsStringMarshalledData(STAFStringConst_t string,                                          unsigned int *isMarshalledData);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -