regenerated

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@590 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2005-01-17 11:09:32 +00:00
parent abd51e28a3
commit 2914a80bdb
1 changed files with 203 additions and 71 deletions

View File

@ -41,92 +41,94 @@ Contents</A>
<!--Table of Contents--> <!--Table of Contents-->
<UL> <UL>
<LI><A NAME="tex2html46" <LI><A NAME="tex2html48"
HREF="asn1c-usage.html#SECTION02000000000000000000">ASN.1 Basics</A> HREF="asn1c-usage.html#SECTION02000000000000000000">ASN.1 Basics</A>
<UL> <UL>
<LI><A NAME="tex2html47" <LI><A NAME="tex2html49"
HREF="asn1c-usage.html#SECTION02100000000000000000">Abstract Syntax Notation: ASN.1</A> HREF="asn1c-usage.html#SECTION02100000000000000000">Abstract Syntax Notation: ASN.1</A>
<UL> <UL>
<LI><A NAME="tex2html48" <LI><A NAME="tex2html50"
HREF="asn1c-usage.html#SECTION02110000000000000000">Some of the ASN.1 Basic Types</A> HREF="asn1c-usage.html#SECTION02110000000000000000">Some of the ASN.1 Basic Types</A>
<UL> <UL>
<LI><A NAME="tex2html49"
HREF="asn1c-usage.html#SECTION02111000000000000000">The BOOLEAN type</A>
<LI><A NAME="tex2html50"
HREF="asn1c-usage.html#SECTION02112000000000000000">The INTEGER type</A>
<LI><A NAME="tex2html51" <LI><A NAME="tex2html51"
HREF="asn1c-usage.html#SECTION02113000000000000000">The ENUMERATED type</A> HREF="asn1c-usage.html#SECTION02111000000000000000">The BOOLEAN type</A>
<LI><A NAME="tex2html52" <LI><A NAME="tex2html52"
HREF="asn1c-usage.html#SECTION02114000000000000000">The OCTET STRING type</A> HREF="asn1c-usage.html#SECTION02112000000000000000">The INTEGER type</A>
<LI><A NAME="tex2html53" <LI><A NAME="tex2html53"
HREF="asn1c-usage.html#SECTION02115000000000000000">The OBJECT IDENTIFIER type</A> HREF="asn1c-usage.html#SECTION02113000000000000000">The ENUMERATED type</A>
<LI><A NAME="tex2html54" <LI><A NAME="tex2html54"
HREF="asn1c-usage.html#SECTION02114000000000000000">The OCTET STRING type</A>
<LI><A NAME="tex2html55"
HREF="asn1c-usage.html#SECTION02115000000000000000">The OBJECT IDENTIFIER type</A>
<LI><A NAME="tex2html56"
HREF="asn1c-usage.html#SECTION02116000000000000000">The RELATIVE-OID type</A> HREF="asn1c-usage.html#SECTION02116000000000000000">The RELATIVE-OID type</A>
</UL> </UL>
<LI><A NAME="tex2html55" <LI><A NAME="tex2html57"
HREF="asn1c-usage.html#SECTION02120000000000000000">Some of the ASN.1 String Types</A> HREF="asn1c-usage.html#SECTION02120000000000000000">Some of the ASN.1 String Types</A>
<UL> <UL>
<LI><A NAME="tex2html56"
HREF="asn1c-usage.html#SECTION02121000000000000000">The IA5String type</A>
<LI><A NAME="tex2html57"
HREF="asn1c-usage.html#SECTION02122000000000000000">The UTF8String type</A>
<LI><A NAME="tex2html58" <LI><A NAME="tex2html58"
HREF="asn1c-usage.html#SECTION02123000000000000000">The NumericString type</A> HREF="asn1c-usage.html#SECTION02121000000000000000">The IA5String type</A>
<LI><A NAME="tex2html59" <LI><A NAME="tex2html59"
HREF="asn1c-usage.html#SECTION02124000000000000000">The PrintableString type</A> HREF="asn1c-usage.html#SECTION02122000000000000000">The UTF8String type</A>
<LI><A NAME="tex2html60" <LI><A NAME="tex2html60"
HREF="asn1c-usage.html#SECTION02123000000000000000">The NumericString type</A>
<LI><A NAME="tex2html61"
HREF="asn1c-usage.html#SECTION02124000000000000000">The PrintableString type</A>
<LI><A NAME="tex2html62"
HREF="asn1c-usage.html#SECTION02125000000000000000">The VisibleString type</A> HREF="asn1c-usage.html#SECTION02125000000000000000">The VisibleString type</A>
</UL> </UL>
<LI><A NAME="tex2html61" <LI><A NAME="tex2html63"
HREF="asn1c-usage.html#SECTION02130000000000000000">ASN.1 Constructed Types</A> HREF="asn1c-usage.html#SECTION02130000000000000000">ASN.1 Constructed Types</A>
<UL> <UL>
<LI><A NAME="tex2html62"
HREF="asn1c-usage.html#SECTION02131000000000000000">The SEQUENCE type</A>
<LI><A NAME="tex2html63"
HREF="asn1c-usage.html#SECTION02132000000000000000">The SET type</A>
<LI><A NAME="tex2html64" <LI><A NAME="tex2html64"
HREF="asn1c-usage.html#SECTION02133000000000000000">The CHOICE type</A> HREF="asn1c-usage.html#SECTION02131000000000000000">The SEQUENCE type</A>
<LI><A NAME="tex2html65" <LI><A NAME="tex2html65"
HREF="asn1c-usage.html#SECTION02134000000000000000">The SEQUENCE OF type</A> HREF="asn1c-usage.html#SECTION02132000000000000000">The SET type</A>
<LI><A NAME="tex2html66" <LI><A NAME="tex2html66"
HREF="asn1c-usage.html#SECTION02133000000000000000">The CHOICE type</A>
<LI><A NAME="tex2html67"
HREF="asn1c-usage.html#SECTION02134000000000000000">The SEQUENCE OF type</A>
<LI><A NAME="tex2html68"
HREF="asn1c-usage.html#SECTION02135000000000000000">The SET OF type</A> HREF="asn1c-usage.html#SECTION02135000000000000000">The SET OF type</A>
</UL> </UL>
</UL> </UL>
</UL><BR> </UL><BR>
<LI><A NAME="tex2html67" <LI><A NAME="tex2html69"
HREF="asn1c-usage.html#SECTION03000000000000000000">Using the ASN.1 Compiler</A> HREF="asn1c-usage.html#SECTION03000000000000000000">Using the ASN.1 Compiler</A>
<UL> <UL>
<LI><A NAME="tex2html68"
HREF="asn1c-usage.html#SECTION03100000000000000000">Introduction to the ASN.1 Compiler</A>
<LI><A NAME="tex2html69"
HREF="asn1c-usage.html#SECTION03200000000000000000">Quick start</A>
<LI><A NAME="tex2html70" <LI><A NAME="tex2html70"
HREF="asn1c-usage.html#SECTION03100000000000000000">Introduction to the ASN.1 Compiler</A>
<LI><A NAME="tex2html71"
HREF="asn1c-usage.html#SECTION03200000000000000000">Quick start</A>
<LI><A NAME="tex2html72"
HREF="asn1c-usage.html#SECTION03300000000000000000">Using the ASN.1 Compiler</A> HREF="asn1c-usage.html#SECTION03300000000000000000">Using the ASN.1 Compiler</A>
<UL> <UL>
<LI><A NAME="tex2html71"
HREF="asn1c-usage.html#SECTION03310000000000000000">Command-line options</A>
<LI><A NAME="tex2html72"
HREF="asn1c-usage.html#SECTION03320000000000000000">Recognizing compiler output</A>
<LI><A NAME="tex2html73" <LI><A NAME="tex2html73"
HREF="asn1c-usage.html#SECTION03310000000000000000">Command-line options</A>
<LI><A NAME="tex2html74"
HREF="asn1c-usage.html#SECTION03320000000000000000">Recognizing compiler output</A>
<LI><A NAME="tex2html75"
HREF="asn1c-usage.html#SECTION03330000000000000000">Invoking the ASN.1 helper code from an application</A> HREF="asn1c-usage.html#SECTION03330000000000000000">Invoking the ASN.1 helper code from an application</A>
<UL> <UL>
<LI><A NAME="tex2html74"
HREF="asn1c-usage.html#SECTION03331000000000000000">Decoding BER</A>
<LI><A NAME="tex2html75"
HREF="asn1c-usage.html#SECTION03332000000000000000">Encoding DER</A>
<LI><A NAME="tex2html76" <LI><A NAME="tex2html76"
HREF="asn1c-usage.html#SECTION03333000000000000000">Encoding XER</A> HREF="asn1c-usage.html#SECTION03331000000000000000">Decoding BER</A>
<LI><A NAME="tex2html77" <LI><A NAME="tex2html77"
HREF="asn1c-usage.html#SECTION03334000000000000000">Validating the target structure</A> HREF="asn1c-usage.html#SECTION03332000000000000000">Encoding DER</A>
<LI><A NAME="tex2html78" <LI><A NAME="tex2html78"
HREF="asn1c-usage.html#SECTION03335000000000000000">Printing the target structure</A> HREF="asn1c-usage.html#SECTION03333000000000000000">Encoding XER</A>
<LI><A NAME="tex2html79" <LI><A NAME="tex2html79"
HREF="asn1c-usage.html#SECTION03334000000000000000">Validating the target structure</A>
<LI><A NAME="tex2html80"
HREF="asn1c-usage.html#SECTION03335000000000000000">Printing the target structure</A>
<LI><A NAME="tex2html81"
HREF="asn1c-usage.html#SECTION03336000000000000000">Freeing the target structure</A> HREF="asn1c-usage.html#SECTION03336000000000000000">Freeing the target structure</A>
</UL> </UL>
</UL> </UL>
</UL><BR> </UL><BR>
<LI><A NAME="tex2html80" <LI><A NAME="tex2html82"
HREF="asn1c-usage.html#SECTION04000000000000000000">Bibliography</A> HREF="asn1c-usage.html#SECTION04000000000000000000">Examples</A>
<LI><A NAME="tex2html83"
HREF="asn1c-usage.html#SECTION05000000000000000000">Bibliography</A>
</UL> </UL>
<!--End of Table of Contents--> <!--End of Table of Contents-->
@ -159,8 +161,8 @@ semantics of data transmitted across the network. Two communicating
parties may have different formats of their native data types (i.e. parties may have different formats of their native data types (i.e.
number of bits in the integer type), thus it is important to have number of bits in the integer type), thus it is important to have
a way to describe the data in a manner which is independent from the a way to describe the data in a manner which is independent from the
particular machine's representation. The ASN.1 specifications is used particular machine's representation. The ASN.1 specifications are
to achieve one or more of the following: used to achieve the following:
<P> <P>
@ -187,14 +189,14 @@ Rectangle&nbsp;::=&nbsp;SEQUENCE&nbsp;{
</BLOCKQUOTE> </BLOCKQUOTE>
This ASN.1 specification describes a constructed type, <I>Rectangle</I>, This ASN.1 specification describes a constructed type, <I>Rectangle</I>,
containing two integer fields. This specification may tell the reader containing two integer fields. This specification may tell the reader
that there is this kind of data structure and that some entity may that there exists this kind of data structure and that some entity
be prepared to send or receive it. The question on <I>how</I> that may be prepared to send or receive it. The question on <I>how</I>
entity is going to send or receive the <I>encoded data</I> is outside that entity is going to send or receive the <I>encoded data</I> is
the scope of ASN.1. For example, this data structure may be encoded outside the scope of ASN.1. For example, this data structure may be
according to some encoding rules and sent to the destination using encoded according to some encoding rules and sent to the destination
the TCP protocol. The ASN.1 specifies several ways of encoding (or using the TCP protocol. The ASN.1 specifies several ways of encoding
''serializing'', or ''marshaling'') the data: BER, CER, DER and (or ''serializing'', or ''marshaling'') the data: BER, CER, DER
XER, some of them which will be described later. and XER, some of them which will be outlined later.
<P> <P>
The complete specification must be wrapped in a module, which looks The complete specification must be wrapped in a module, which looks
@ -203,10 +205,10 @@ like this:
<P> <P>
<BLOCKQUOTE><PRE> <BLOCKQUOTE><PRE>
UsageExampleModule1 RectangleModule1
&nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;iso&nbsp;org(3)&nbsp;dod(6)&nbsp;internet(1)&nbsp;private(4) &nbsp;&nbsp;&nbsp;&nbsp;{&nbsp;iso&nbsp;org(3)&nbsp;dod(6)&nbsp;internet(1)&nbsp;private(4)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enterprise(1)&nbsp;spelio(9363)&nbsp;software(1) &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;enterprise(1)&nbsp;spelio(9363)&nbsp;software(1)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;asn1c(5)&nbsp;docs(2)&nbsp;usage(1)&nbsp;1&nbsp;}&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;asn1c(5)&nbsp;docs(2)&nbsp;rectangle(1)&nbsp;1&nbsp;}&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;DEFINITIONS&nbsp;AUTOMATIC&nbsp;TAGS&nbsp;::= &nbsp;&nbsp;&nbsp;&nbsp;DEFINITIONS&nbsp;AUTOMATIC&nbsp;TAGS&nbsp;::=
BEGIN BEGIN
&nbsp; &nbsp;
@ -219,7 +221,7 @@ Rectangle&nbsp;::=&nbsp;SEQUENCE&nbsp;{
END END
</PRE> </PRE>
</BLOCKQUOTE> </BLOCKQUOTE>
The module header consists of module name (UsageExampleModule1), the The module header consists of module name (RectangleModule1), the
module object identifier ({...}), a keyword ''DEFINITIONS'', a module object identifier ({...}), a keyword ''DEFINITIONS'', a
set of module flags (AUTOMATIC TAGS) and ''::= BEGIN''. The module set of module flags (AUTOMATIC TAGS) and ''::= BEGIN''. The module
ends with an ''END'' statement. ends with an ''END'' statement.
@ -325,7 +327,7 @@ following OBJECT IDENTIFIER: 1 3 6 1 4 1 9363 1 5 2 1 1.
<BLOCKQUOTE><PRE> <BLOCKQUOTE><PRE>
ExampleOID&nbsp;::=&nbsp;OBJECT&nbsp;IDENTIFIER ExampleOID&nbsp;::=&nbsp;OBJECT&nbsp;IDENTIFIER
&nbsp; &nbsp;
usageExampleModule1-oid&nbsp;ExampleOID rectangleModule1-oid&nbsp;ExampleOID
&nbsp;&nbsp;::=&nbsp;{&nbsp;1&nbsp;3&nbsp;6&nbsp;1&nbsp;4&nbsp;1&nbsp;9363&nbsp;1&nbsp;5&nbsp;2&nbsp;1&nbsp;1&nbsp;} &nbsp;&nbsp;::=&nbsp;{&nbsp;1&nbsp;3&nbsp;6&nbsp;1&nbsp;4&nbsp;1&nbsp;9363&nbsp;1&nbsp;5&nbsp;2&nbsp;1&nbsp;1&nbsp;}
&nbsp; &nbsp;
--&nbsp;An&nbsp;identifier&nbsp;of&nbsp;the&nbsp;Internet. --&nbsp;An&nbsp;identifier&nbsp;of&nbsp;the&nbsp;Internet.
@ -568,7 +570,7 @@ language structures and surrounding maintenance code. For example,
the C structure which may be created by compiler to represent the the C structure which may be created by compiler to represent the
simple <I>Rectangle</I> specification defined earlier in this document, simple <I>Rectangle</I> specification defined earlier in this document,
may look like this<A NAME="tex2html2" may look like this<A NAME="tex2html2"
HREF="#foot419"><SUP>2.2</SUP></A>: HREF="#foot574"><SUP>2.2</SUP></A>:
<P> <P>
@ -594,8 +596,8 @@ Quick start</A>
<P> <P>
After building and installing the compiler, the <I>asn1c</I><A NAME="tex2html4" After building and installing the compiler, the <I>asn1c</I><A NAME="tex2html4"
HREF="#foot420"><SUP>3.1</SUP></A> command may be used to compile the ASN.1 specification<A NAME="tex2html5" HREF="#foot575"><SUP>3.1</SUP></A> command may be used to compile the ASN.1 specification<A NAME="tex2html5"
HREF="#foot421"><SUP>3.2</SUP></A>: HREF="#foot576"><SUP>3.2</SUP></A>:
<P> <P>
@ -661,7 +663,7 @@ the compiler's behavior.
<P> <P>
<BR><P></P> <BR><P></P>
<DIV ALIGN="CENTER"><A NAME="424"></A> <DIV ALIGN="CENTER"><A NAME="579"></A>
<TABLE> <TABLE>
<CAPTION><STRONG><A NAME=Table1>Table 1:</A></STRONG> <CAPTION><STRONG><A NAME=Table1>Table 1:</A></STRONG>
The list of asn1c command line options</CAPTION> The list of asn1c command line options</CAPTION>
@ -693,7 +695,7 @@ ting the usual support code.</FONT></TD></TR>
<FONT SIZE="-1">Use the specified directory with ASN.1 skeleton files.</FONT></TD></TR> <FONT SIZE="-1">Use the specified directory with ASN.1 skeleton files.</FONT></TD></TR>
</TBODY><TBODY> </TBODY><TBODY>
<TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP>-X</TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216"> <TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP>-X</TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216">
<FONT SIZE="-1">Generate the XML DTD schema for the specified ASN.1 modules.</FONT></TD></TR> Generate the XML DTD for the specified ASN.1 modules.</TD></TR>
</TBODY><TBODY> </TBODY><TBODY>
<TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP><B>Warning Options</B></TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216"> <TR><TD VALIGN=BASELINE ALIGN=LEFT NOWRAP><B>Warning Options</B></TD><TD VALIGN=BASELINE ALIGN=LEFT WIDTH="216">
<B>Description</B></TD></TR> <B>Description</B></TD></TR>
@ -805,7 +807,7 @@ be possible to compile everything with the single instruction:
<BLOCKQUOTE><PRE> <BLOCKQUOTE><PRE>
cc&nbsp;-o&nbsp;rectangle&nbsp;*.c&nbsp;&nbsp;&nbsp;#&nbsp;It&nbsp;could&nbsp;be&nbsp;<I>that</I>&nbsp;simple<A NAME="tex2html7" cc&nbsp;-o&nbsp;rectangle&nbsp;*.c&nbsp;&nbsp;&nbsp;#&nbsp;It&nbsp;could&nbsp;be&nbsp;<I>that</I>&nbsp;simple<A NAME="tex2html7"
HREF="#foot427"><SUP>4.1</SUP></A> HREF="#foot582"><SUP>4.1</SUP></A>
</PRE> </PRE>
</BLOCKQUOTE> </BLOCKQUOTE>
@ -1289,14 +1291,144 @@ It is safe to invoke the <I>free_struct</I> function with the target
structure pointer set to 0 (NULL), the function will do nothing. structure pointer set to 0 (NULL), the function will do nothing.
<P> <P>
<H2><A NAME="SECTION04000000000000000000"> <H1><A NAME="SECTION04000000000000000000">
Examples</A>
</H1>
<P>
<H1><A NAME="SECTION04100000000000000000">
Step-by-step: A ''Rectangle'' Decoder</A>
</H1>
<P>
This chapter will help you to create a simple decoder of a simple
''Rectangle'' type used throughout this document.
<P>
<OL>
<LI>Create a file named <B>rectangle.asn1</B> with the following contents:
<P>
<BLOCKQUOTE><PRE>
RectangleModule1&nbsp;DEFINITIONS&nbsp;::=
BEGIN
&nbsp;
Rectangle&nbsp;::=&nbsp;SEQUENCE&nbsp;{
&nbsp;&nbsp;&nbsp;&nbsp;height&nbsp;&nbsp;INTEGER,
&nbsp;&nbsp;&nbsp;&nbsp;width&nbsp;&nbsp;&nbsp;INTEGER
}
&nbsp;
END
</PRE>
</BLOCKQUOTE>
</LI>
<LI>Compile it into the set of .c and .h files using asn1c compiler [<A
HREF="asn1c-usage.html#ASN1C">ASN1C</A>]:
<P>
<BLOCKQUOTE><PRE>
<I>asn1c&nbsp;-fnative-types</I>&nbsp;<B>rectangle.asn1</B>
</PRE>
</BLOCKQUOTE>
</LI>
<LI>Alternatively, use the Online ASN.1 compiler [<A
HREF="asn1c-usage.html#AONL">AONL</A>] by uploading
the <B>rectangle.asn1</B> file into the Web form and unpacking the
produced archive on your computer.
</LI>
<LI>By this time, you should have gotten multiple files in the current
directory, including the <B>Rectangle.c</B> and <B>Rectangle.h</B>.
</LI>
<LI>Create a main() routine which takes the binary input file, decodes
it as it were a BER-encoded Rectangle type, and prints out the text
(XML) representation of the Rectangle type. Let's name the file <B>main.c</B>:
<P>
<BLOCKQUOTE><PRE>
<FONT SIZE="-1">#include&nbsp;&lt;stdio.h&gt;</FONT>
<FONT SIZE="-1">#include&nbsp;&lt;sys/types.h&gt;</FONT>
<FONT SIZE="-1">#include&nbsp;&lt;Rectangle.h&gt;&nbsp;&nbsp;&nbsp;/*&nbsp;Rectangle&nbsp;ASN.1&nbsp;type&nbsp;&nbsp;*/</FONT>
&nbsp;
<FONT SIZE="-1">int&nbsp;main(int&nbsp;ac,&nbsp;char&nbsp;**av)&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;char&nbsp;buf[1024];&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Temporary&nbsp;buffer&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;Rectangle_t&nbsp;*rectangle&nbsp;=&nbsp;0;&nbsp;/*&nbsp;Type&nbsp;to&nbsp;decode&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;asn_dec_rval_t&nbsp;rval;&nbsp;/*&nbsp;Decoder&nbsp;return&nbsp;value&nbsp;&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;FILE&nbsp;*fp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Input&nbsp;file&nbsp;handler&nbsp;&nbsp;&nbsp;&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;size_t&nbsp;size;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Number&nbsp;of&nbsp;bytes&nbsp;read&nbsp;&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;char&nbsp;*filename;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;/*&nbsp;Input&nbsp;file&nbsp;name&nbsp;*/</FONT>
&nbsp;
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;/*&nbsp;Require&nbsp;a&nbsp;single&nbsp;filename&nbsp;argument&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;if(ac&nbsp;!=&nbsp;2)&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&nbsp;''Usage:&nbsp;%s&nbsp;&lt;file.ber&gt;&#92;n'',&nbsp;av[0]);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(64);&nbsp;/*&nbsp;better,&nbsp;EX_USAGE&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;}&nbsp;else&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename&nbsp;=&nbsp;av[1];</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;}</FONT>
&nbsp;
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;/*&nbsp;Open&nbsp;input&nbsp;file&nbsp;as&nbsp;read-only&nbsp;binary&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;fp&nbsp;=&nbsp;fopen(filename,&nbsp;''rb'');</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;if(!fp)&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;perror(filename);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(66);&nbsp;/*&nbsp;better,&nbsp;EX_NOINPUT&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;}</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;/*&nbsp;Read&nbsp;up&nbsp;to&nbsp;the&nbsp;buffer&nbsp;size&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;size&nbsp;=&nbsp;fread(buf,&nbsp;1,&nbsp;sizeof(buf),&nbsp;fp);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;fclose(fp);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;if(!size)&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,&nbsp;''%s:&nbsp;Empty&nbsp;or&nbsp;broken&#92;n'',&nbsp;filename);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(65);&nbsp;/*&nbsp;better,&nbsp;EX_DATAERR&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;}</FONT>
&nbsp;
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;/*&nbsp;Decode&nbsp;the&nbsp;input&nbsp;buffer&nbsp;as&nbsp;Rectangle&nbsp;type&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;rval&nbsp;=&nbsp;ber_decode(0,&nbsp;&amp;asn_DEF_Rectangle,</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(void&nbsp;**)&amp;rectangle,&nbsp;buf,&nbsp;size);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;if(rval.code&nbsp;!=&nbsp;RC_OK)&nbsp;{</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;fprintf(stderr,</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;''%s:&nbsp;Broken&nbsp;Rectangle&nbsp;encoding&nbsp;at&nbsp;byte&nbsp;%ld&#92;n'',</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;filename,&nbsp;(long)rval.consumed);</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;exit(65);&nbsp;/*&nbsp;better,&nbsp;EX_DATAERR&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;}</FONT>
&nbsp;
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;/*&nbsp;Print&nbsp;the&nbsp;decoded&nbsp;Rectangle&nbsp;type&nbsp;as&nbsp;XML&nbsp;*/</FONT>
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;xer_fprint(stdout,&nbsp;&amp;asn_DEF_Rectangle,&nbsp;rectangle);</FONT>
&nbsp;
&nbsp;<FONT SIZE="-1">&nbsp;&nbsp;&nbsp;return&nbsp;0;&nbsp;/*&nbsp;Decoding&nbsp;finished&nbsp;successfully&nbsp;*/</FONT>
<FONT SIZE="-1">}</FONT>
</PRE>
</BLOCKQUOTE>
</LI>
<LI>Compile all files together using C compiler (varies by platform):
<P>
<BLOCKQUOTE><PRE>
<I>cc&nbsp;-I.&nbsp;-o</I>&nbsp;<B><I>rdecode</I></B>&nbsp;<I>*.c</I>
</PRE>
</BLOCKQUOTE>
</LI>
<LI>Voila! You have just created the Rectangle type decoder named <B>rdecode</B>!
</LI>
</OL>
<H2><A NAME="SECTION05000000000000000000">
Bibliography</A> Bibliography</A>
</H2><DL COMPACT><DD><P></P><DT><A NAME="ASN1C">ASN1C</A> </H2><DL COMPACT><DD><P></P><DT><A NAME="ASN1C">ASN1C</A>
<DD>The OpenSource ASN.1 Compiler. <A HREF=http://lionet.info/asn1c/>http://lionet.info/asn1c/</A> <DD>The OpenSource ASN.1 Compiler. <A HREF=http://lionet.info/asn1c/>http://lionet.info/asn1c/</A>
<P></P><DT><A NAME="AONL">AONL</A>
<DD>Online ASN.1 Compiler. <A HREF=http://lionet.info/asn1c/>http://lionet.info/asn1c/</A>asn1c.cgi
<P></P><DT><A NAME="Dub00">Dub00</A> <P></P><DT><A NAME="Dub00">Dub00</A>
<DD>Olivier Dubuisson - <I>ASN.1 Communication between heterogeneous <DD>Olivier Dubuisson -- <I>ASN.1 Communication between heterogeneous
systems</I> - Morgan Kaufmann Publishers, 2000. <A HREF=http://asn1.elibel.tm.fr/en/book/>http://asn1.elibel.tm.fr/en/book/</A>. systems</I> -- Morgan Kaufmann Publishers, 2000. <A HREF=http://asn1.elibel.tm.fr/en/book/>http://asn1.elibel.tm.fr/en/book/</A>.
ISBN:0-12-6333361-0. ISBN:0-12-6333361-0.
<P></P><DT><A NAME="ITU-T_ASN.1">ITU-T/ASN.1</A> <P></P><DT><A NAME="ITU-T_ASN.1">ITU-T/ASN.1</A>
<DD>ITU-T Study Group 17 - Languages for Telecommunication Systems <A HREF=http://www.itu.int/ITU-T/studygroups/com17/languages/>http://www.itu.int/ITU-T/studygroups/com17/languages/</A></DL> <DD>ITU-T Study Group 17 - Languages for Telecommunication Systems <A HREF=http://www.itu.int/ITU-T/studygroups/com17/languages/>http://www.itu.int/ITU-T/studygroups/com17/languages/</A></DL>
@ -1310,7 +1442,7 @@ ISBN:0-12-6333361-0.
not a definitive factor. not a definitive factor.
</DD> </DD>
<DT><A NAME="foot419">... this</A><A <DT><A NAME="foot574">... this</A><A
HREF="asn1c-usage.html#tex2html2"><SUP>2.2</SUP></A></DT> HREF="asn1c-usage.html#tex2html2"><SUP>2.2</SUP></A></DT>
<DD><I>-fnative-types</I> compiler option is used to produce basic C <I>int</I> <DD><I>-fnative-types</I> compiler option is used to produce basic C <I>int</I>
types instead of infinite width INTEGER_t structures. See <A HREF=#Table1>Table 1</A>. types instead of infinite width INTEGER_t structures. See <A HREF=#Table1>Table 1</A>.
@ -1322,19 +1454,19 @@ types instead of infinite width INTEGER_t structures. See <A HREF=#Table1>Table
text (XML) based. text (XML) based.
</DD> </DD>
<DT><A NAME="foot420">...asn1c</A><A <DT><A NAME="foot575">...asn1c</A><A
HREF="asn1c-usage.html#tex2html4"><SUP>3.1</SUP></A></DT> HREF="asn1c-usage.html#tex2html4"><SUP>3.1</SUP></A></DT>
<DD>The 1 symbol in asn<B>1</B>c is a digit, not an ''ell'' letter. <DD>The 1 symbol in asn<B>1</B>c is a digit, not an ''ell'' letter.
</DD> </DD>
<DT><A NAME="foot421">... specification</A><A <DT><A NAME="foot576">... specification</A><A
HREF="asn1c-usage.html#tex2html5"><SUP>3.2</SUP></A></DT> HREF="asn1c-usage.html#tex2html5"><SUP>3.2</SUP></A></DT>
<DD>This is probably <B>not</B> what you want to try out right now - <DD>This is probably <B>not</B> what you want to try out right now -
read through the rest of this chapter to find out about <B>-P</B> read through the rest of this chapter to find out about <B>-P</B>
and <B>-R</B> options. and <B>-R</B> options.
</DD> </DD>
<DT><A NAME="foot427">...that&nbsp;simple</A><A <DT><A NAME="foot582">...that&nbsp;simple</A><A
HREF="asn1c-usage.html#tex2html7"><SUP>4.1</SUP></A></DT> HREF="asn1c-usage.html#tex2html7"><SUP>4.1</SUP></A></DT>
<DD>Provided that you've also created a .c file with the <I>int main()</I> <DD>Provided that you've also created a .c file with the <I>int main()</I>
routine. routine.
@ -1356,7 +1488,7 @@ which aren't important for the size determination.
</DL><BR><HR> </DL><BR><HR>
<ADDRESS> <ADDRESS>
Lev Walkin Lev Walkin
2004-09-30 2005-01-17
</ADDRESS> </ADDRESS>
</BODY> </BODY>
</HTML> </HTML>