1、Standard ECMA-1584th Edition - December 1997Standardizing Information and Communication SystemsPhone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http:/www.ecma.ch - Internet: helpdeskecma.chPortable Common ToolEnvironment (PCTE) -C Programming LanguageBinding.Standard ECMA-1584th Edition - Dece
2、mber 1997Standardizing Information and Communication SystemsPhone: +41 22 849.60.00 - Fax: +41 22 849.60.01 - URL: http:/www.ecma.ch - Internet: helpdeskecma.chIW ECMA-158.DOC 22-02-99 16,01Portable Common ToolEnvironment (PCTE) -C Programming LanguageBinding.Brief History(1) PCTE, Portable Common T
3、ool Environment, is an interface standard. The interface is designed tosupport program portability by providing machine-independent access to a set of facilities. Thesefacilities, which are described in the PCTE Abstract Specification (Standard ECMA-149), aredesigned particularly to provide an infra
4、structure for programs which may be part of environmentssupporting systems engineering projects. Such programs, which are used as aids to systemsdevelopment, are often referred to as tools.(2) PCTE has its origin in the European Strategic Programme for Research and Development inInformation Technolo
5、gy (ESPRIT) project 32, called “A Basis for a Portable Common ToolEnvironment“. That project produced a specification for a tool interface, an initialimplementation, and some tools on that implementation. The interface specifications wereproduced in the C Language. A number of versions of the specif
6、ications were produced,culminating in the fourth edition known as “PCTE Version 1.4“. That was in two volumes;volume 2 covered the user interface and volume 1 covered everything else. Subsequently, theCommission of the European Communities (CEC) commissioned Ada versions of the two volumesof the PCT
7、E specification. Since 1988, a technical committee of ECMA, TC33, has continued thedevelopment of PCTE, in a form suitable for standardization under ECMA rules. This work wasundertaken by Task Group TGEP (later renamed TGOO) of ECMA TC33, which was formed inNovember 1988.(3) The work on the C Langua
8、ge Binding for ECMA PCTE was started in early 1990, as the AbstractSpecification became stable. The C Language Binding was the first binding of ECMA PCTE to bedeveloped, though the strategy for it was developed in parallel with that for the Ada LanguageBinding. The text of this binding reflects the
9、desire for the C and Ada Language Bindings to be ascompatible as possible.(4) Following acceptance of the first edition as an ECMA Standard in June 1991, review byinternational experts led to the production of second edition taking into account review commentsrelating to this standard and also maint
10、aining consistency with the second edition of StandardECMA-149. The second edition was accepted by the General Assembly of June 1993, and wassubmitted as part 2 of the draft PCTE standard to ISO/IEC JTC1 for fast-track processing tointernational standardization.(5) During the fast-track processing,
11、which was successfully completed in September 1994, commentsfrom National Bodies resulted in a number of changes to the draft standard. Some further editorialchanges were requested by JTC1 ITTF. All these were incorporated in the published internationalstandard, ISO/IEC 13719-2, with which the third
12、 edition of this ECMA standard was aligned.(6) This fourth edition incorporates the resolutions of all comments received too late for considerationduring the fast-track processing, or after, and the contents of Standards ECMA-228 (Extensions forSupport of Fine-Grain Objects) and ECMA-256 (Object Ori
13、entation Extensions). It is alignedwith the second edition of ISO/IEC 13719-2.Adopted as 4th Edition of Standard ECMA-158 by the General Assembly of December 1997.- i -Contents1 Scope 12 Conformance 13 Normative references 14 Definitions 25 Formal notations 26 Outline of the Standard 27 Binding stra
14、tegy 27.1 C programming language standard 27.2 General principles 27.3 Sets and sequences 37.4 Character strings 37.5 Memory allocation 37.6 References and names 47.7 Operation return values 47.8 Error conditions 57.9 Identifiers 57.10 Implementation limits 58 Datatype mapping 58.1 Mapping of PCTE d
15、atatypes to LI datatypes 58.1.1 Mapping of predefined PCTE datatypes 68.1.2 Mapping of private PCTE datatypes 78.1.3 Mapping of complex PCTE datatypes 78.1.4 New LI datatype generators 88.2 Mapping of LI datatypes to C datatypes 88.2.1 LI datatype boolean 88.2.2 LI datatype pcte-integer 98.2.3 LI da
16、tatype pcte-natural 108.2.4 LI datatype pcte-float 108.2.5 LI datatype pcte-time 118.2.6 LI datatype pcte-text 128.2.7 LI datatype octet 138.2.8 LI enumerated datatype pcte-xxx 138.2.9 LI private datatypes 148.2.10 LI datatype generator pcte-sequence 148.2.11 LI datatype pcte-string 158.2.12 LI data
17、type generator bounded-set 17- ii -8.2.13 LI datatype generator choice 188.2.14 LI datatype record 198.3 Private datatypes 208.4 References and names 218.5 C private type Pcte_sequence 218.5.1 Operations on sequences 258.5.2 Error conditions for sequence operators 288.6 Deriving C function semantics
18、 from the abstract specification 288.7 Headers 298.7.1 The global PCTE header 298.7.2 The PCTE basic type header 308.7.3 The PCTE sequence header 319 Object management 349.1 Object management datatypes 349.2 Link operations 369.3 Object operations 409.4 Version operations 4610 Schema management 4810
19、.1 Schema management datatypes 4810.2 Update operations 5010.3 Usage operations 5610.4 Working schema operations 5911 Volumes, devices, and archives 6211.1 Volume, device, and archive datatypes 6211.2 Volume, device, and archive operations 6311.3 Clusters 6512 Files, pipes, and devices 6612.1 File,
20、pipe, and device datatypes 6612.2 File, pipe, and device operations 6713 Process execution 6913.1 Process execution datatypes 7013.2 Process execution operations 7013.3 Security operations 7313.4 Profiling operations 7513.5 Monitoring operations 7514 Message queues 7614.1 Message queue datatypes 76-
21、 iii -14.2 Message queue operations 7715 Notification 7915.1 Notification datatypes 8015.2 Notification operations 8016 Concurrency and integrity control 8016.1 Concurrency and integrity control datatypes 8116.2 Concurrency and integrity control operations 8117 Replication 8217.1 Replication datatyp
22、es 8217.2 Replication operations 8218 Network connection 8418.1 Network connection datatypes 8418.2 Network connection operations 8518.3 Foreign system operations 8618.4 Time operations 8619 Discretionary security 8719.1 Discretionary security datatypes 8719.2 Discretionary access control operations
23、 8919.3 Discretionary security administration operations 8920 Mandatory security 9120.1 Mandatory security datatypes 9120.2 Mandatory security operations 9120.3 Mandatory security administration operations 9220.4 Mandatory security operations for processes 9421 Auditing 9421.1 Auditing datatypes 952
24、1.2 Auditing operations 9822 Accounting 10022.1 Accounting datatypes 10022.2 Accounting administration operations 10222.3 Consumer identity operations 10323 References 10323.1 Reference datatypes 10423.2 Object reference operations 105- iv -23.3 Link reference operations 10623.4 Type reference opera
25、tions 10824 Limits 10924.1 Implementation limit datatypes 10924.2 Implementation limit operations 11125 Error conditions 11125.1 Error condition datatypes 11125.2 Error condition operations 117Annex A - The object orientation module 119Index of abstract operations 125Index of C subprograms 131Index
26、of C datatypes 1391Scope(1) This ECMA Standard defines the binding of the Portable Common Tool Environment (PCTE), asspecified in ECMA-149, to the C programming language.(2) A number of features are not completely defined in ECMA-149, some freedom being allowed tothe implementor. Some of these featu
27、res are specified as implementation limits. Some constraintsare placed on these implementation limits by this ECMA Standard. These constraints are specifiedin clause 24, Implementation Limits.(3) PCTE is an interface to a set of facilities that forms the basis for constructing environmentssupporting
28、 systems engineering projects. These facilities are designed particularly to provide aninfrastructure for programs which may be part of such environments. Such programs, which areused as aids to system development, are often referred to as tools.2 Conformance(1) An implementation of PCTE conforms to
29、 this ECMA Standard if it conforms to 2.2 ofECMA-149, where the binding referred to there is taken to be the C language binding defined inclauses 1 to 5 and 8 to 25 of this ECMA Standard. All other parts of this ECMA Standard areprovided as assistance to the reader and are not normative.(2) The C la
30、nguage binding defined in this ECMA Standard conforms to 2.1 of ECMA-149.3 Normative references(1) The following standards contain provisions which, through reference in this text, constituteprovisions of this ECMA Standard. At the time of publication, the editions indicated were valid.All standards
31、 are subject to revision, and parties to agreements based on this ECMA Standard areencouraged to investigate the possibility of applying the most recent editions of the standardsindicated below. Members of IEC and ISO maintain registers of currently valid InternationalStandards.(2) ECMA-149 Portable
32、 Common Tool Environment (PCTE) - Abstract Specification(4th edition, December 1997)(3) ECMA-162 Portable Common Tool Environment (PCTE) - Ada ProgrammingLanguage Binding (4th edition, December 1997)(4) ISO 8601 Data elements and interchange formats - Information interchange -Representation of dates
33、 and times (1988)(5) ISO 9899 Information technology - Programming languages, their environments andsystem software interfaces - Programming languages - C (1990)(6) ISO/IEC/TR 10182 Information technology - Programming languages, their environments andsystem software interfaces - Guidelines for lang
34、uage bindings (1993)(7) ISO/IEC 11404 Information technology - Programming languages, their environments andsystem software interfaces - Language-independent datatypes (1996)- 2 -4 Definitions(1) All technical terms used in this ECMA Standard, other than a few in widespread use, are definedin the bo
35、dy of this ECMA Standard or in the referenced documents.5 Formal notations(1) All datatypes and subprogram definitions are expressed using ISO/IEC 8652 conformant syntax.For the C Language binding for each operation, the function prototype syntax is used as defined inISO 9899.6 Outline of the Standa
36、rd(1) Clause 7 describes the strategy used to develop this binding specification.(2) Clause 8 defines the mapping from the datatypes that are used in the abstract specification to Clanguage datatypes.(3) Clauses 9 to 22 define the bindings of datatypes and operations in the corresponding clauses ofE
37、CMA-149. The extensions for fine-grain objects are added at the end of clause 11.(4) Clause 23 defines the binding of object and type references, as specified in 23.1.2 and 23.2 ofECMA-149.(5) Clause 24 defines the binding of the implementation limit subprograms described in clause 24 ofECMA-149.(6)
38、 Clause 25 defines the binding of the error conditions specified in annex C of ECMA-149, anddefines binding-defined error conditions for the C binding.(7) Annex A, which is normative, contains the extensions for object orientation, corresponding toannex G of ECMA-149.7 Binding strategy7.1 C programm
39、ing language standard(1) This ECMA Standard is a conforming program according to ISO 9899.7.2 General principles(1) The following general principles were applied when generating the binding in this ECMAStandard.(2) ISO/IEC TR10182: Guidelines for Language Bindings should be followed as far as possib
40、le forbinding method 1: provide a completely defined procedural interface.(3) Each operation in ECMA-149 should be represented by exactly one operation in this ECMAStandard except possibly when the abstract operation has distinct functionality depending on thevalues of one or more parameters.(4) Eac
41、h operation in this ECMA Standard should have the same number of parameters as does thecorresponding operation in ECMA-149.- 3 -(5) All operations in this ECMA Standard should return an integer status value. All other valuesreturned by the operation should be passed back to the caller via an output
42、parameter. The returnvalue of the operation should indicate success or failure only.(6) Operation and parameter names should be the same in this ECMA Standard as they are inECMA-149, with the exception that identifiers with file scope should begin Pcte_ and otherwiseconsist of lowercase letters and
43、underscores. The PCTE standard guarantees that there are noambiguities in names prefixed by Pcte_.(7) All additional names introduced in this ECMA Standard which are visible across the interface(except header names, see 8.5) should begin Pcte_ and otherwise consist of lowercase letters,underscores a
44、nd digits, or begin PCTE_ and otherwise consist of uppercase letters, underscoresand digits. The PCTE standard guarantees that there are no ambiguities in names prefixed byPCTE_ or Pcte_.(8) Wherever practical, types introduced for passing complex data entities between caller andoperation (and vice
45、versa) should be private types defined by this ECMA Standard. The principleshould only be ignored for reasons of ease of use and efficiency of implementation.(9) Each simple datatype in ECMA-149 should be mapped to a corresponding type defined in thisECMA Standard. Each implementation of the binding
46、 should then be free to map the binding-defined type to an efficient C Language basic type appropriate for the platform of theimplementation, within the constraints specified in this ECMA Standard.(10) A general policy of memory allocation should be adopted; see 7.5.7.3 Sets and sequences(1) Some co
47、mplex data entities to be passed into or retrieved from an operation are defined as sets orsequences of a base type in ECMA-149. Bounded set types are mapped individually to bit-significant natural numbers; unbounded set and sequence types are mapped to a private type,Pcte_sequence with operations f
48、or creation, population, retrieval and deletion. These operationsallow multiple elements of sets and sequences to be set and read in a single operation, from or toan array object of an appropriate base type. Thus, the data for sets and sequences can be easilymanipulated using standard C Language par
49、adigms, while allowing the implementation to choosethe best implementation for such sets and sequences.7.4 Character strings(1) In ECMA-149, two different types are used to represent sequences of characters. String is asequence of Octets allowing all 8-bit values and Text is a sequence of Latin-1 graphic characters.Contents, string attributes etc., are of type String; keys, type names etc., are of type Text.(2) In the C Bindings, String is mapped to Pcte_string (see 8.2.11). Text is mapped to the native Clanguage string with a possibly fixed length, i.e. char * with operatio