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

📄 ch31.htm

📁 《Perl 5 Unreleased》
💻 HTM
📖 第 1 页 / 共 5 页
字号:
&nbsp;32 padTo80(buffer);<BR>

&nbsp;33 } /* End of encoding function */<BR>

&nbsp;34<BR>

&nbsp;35 /*:<BR>

&nbsp;36 ** Generated by Perl script -- Avoid editing<BR>

&nbsp;37 */<BR>

&nbsp;38 void encode_H0010_type(STRPTR buffer,P286_H0010_PTR sp)

<BR>

&nbsp;39 {<BR>

&nbsp;40 STRPTR ncp;<BR>

&nbsp;41<BR>

&nbsp;42 STRPTR cp;<BR>

&nbsp;43 register int i;<BR>

&nbsp;44 char tempbuffer[80];<BR>

&nbsp;45<BR>

&nbsp;46<BR>

&nbsp;47 /* Encode:int,numPatterns,6,7,2, */<BR>

&nbsp;48 sprintf(tempbuffer,&quot;%d2&quot;,(sp-&gt;numPatterns));

<BR>

&nbsp;49 tempbuffer[2]= 0;<BR>

&nbsp;50 strncat((STRPTR )(&amp;buffer[5]),tempbuffer,2);<BR>

&nbsp;51<BR>

&nbsp;52 /* Encode:int,sblInUse,8,8,1, */<BR>

&nbsp;53 sp-&gt;sblInUse %= 10;<BR>

&nbsp;54 tempbuffer[7] = (char)('0' + sp-&gt;sblInUse);<BR>

&nbsp;55 tempbuffer[8] = 0;<BR>

&nbsp;56 strncat((STRPTR )(&amp;buffer[7]),tempbuffer,1);<BR>

&nbsp;57<BR>

&nbsp;58 /* Encode:int,sattInUse,9,9,1, */<BR>

&nbsp;59 sp-&gt;sattInUse %= 10;<BR>

&nbsp;60 tempbuffer[8] = (char)('0' + sp-&gt;sattInUse);<BR>

&nbsp;61 tempbuffer[9] = 0;<BR>

&nbsp;62 strncat((STRPTR )(&amp;buffer[8]),tempbuffer,1);<BR>

&nbsp;63<BR>

&nbsp;64 /* Encode:int,numVessels,10,10,1, */<BR>

&nbsp;65 sp-&gt;numVessels %= 10;<BR>

&nbsp;66 tempbuffer[9] = (char)('0' + sp-&gt;numVessels);<BR>

&nbsp;67 tempbuffer[10] = 0;<BR>

&nbsp;68 strncat((STRPTR )(&amp;buffer[9]),tempbuffer,1);<BR>

&nbsp;69<BR>

&nbsp;70 /* Encode:int,numDatum,11,11,1, */<BR>

&nbsp;71 sp-&gt;numDatum %= 10;<BR>

&nbsp;72 tempbuffer[10] = (char)('0' + sp-&gt;numDatum);<BR>

&nbsp;73 tempbuffer[11] = 0;<BR>

&nbsp;74 strncat((STRPTR )(&amp;buffer[10]),tempbuffer,1);<BR>

&nbsp;75<BR>

&nbsp;76 /* Encode:int,offsetMode,12,12,1, */<BR>

&nbsp;77 sp-&gt;offsetMode %= 10;<BR>

&nbsp;78 tempbuffer[11] = (char)('0' + sp-&gt;offsetMode);<BR>

&nbsp;79 tempbuffer[12] = 0;<BR>

&nbsp;80 strncat((STRPTR )(&amp;buffer[11]),tempbuffer,1);<BR>

&nbsp;81 padTo80(buffer);<BR>

&nbsp;82 } /* End of encoding function */<BR>

&nbsp;83<BR>

&nbsp;84 /*:<BR>

&nbsp;85 ** Generated by Perl script -- Avoid editing<BR>

&nbsp;86 */<BR>

&nbsp;87 void encode_H011_type(STRPTR buffer,P286_H011_PTR sp)

<BR>

&nbsp;88 {<BR>

&nbsp;89 STRPTR ncp;<BR>

&nbsp;90<BR>

&nbsp;91 STRPTR cp;<BR>

&nbsp;92 register int i;<BR>

&nbsp;93 char tempbuffer[80];<BR>

&nbsp;94<BR>

&nbsp;95<BR>

&nbsp;96 /* Encode:int,datumId,5,5,1, */<BR>

&nbsp;97 sp-&gt;datumId %= 10;<BR>

&nbsp;98 tempbuffer[4] = (char)('0' + sp-&gt;datumId);<BR>

&nbsp;99 tempbuffer[5] = 0;<BR>

100 strncat((STRPTR )(&amp;buffer[4]),tempbuffer,1);<BR>

101<BR>

102 /* Encode:char,spheroidName,6,23,18, */<BR>

103 cp = (STRPTR )&amp;(buffer[5]);<BR>

104 for (i=0; i&lt; 18;i++)<BR>

105&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[5 + i] = sp-&gt;spheroidName[i];

<BR>

106<BR>

107 /* Encode:char,datumName,24,41,18, */<BR>

108 cp = (STRPTR )&amp;(buffer[23]);<BR>

109 for (i=0; i&lt; 18;i++)<BR>

110&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;buffer[23 + i] = sp-&gt;datumName[i];

<BR>

111<BR>

112 /* Encode:double,semimajorAxis,42,53,12,12.3 */<BR>

113 sprintf(tempbuffer,&quot;%12.3f&quot;,(sp-&gt;semimajorAxis));

<BR>

114 tempbuffer[12]= 0;<BR>

115 strncat((STRPTR )(&amp;buffer[41]),tempbuffer,12);<BR>

116<BR>

117 /* Encode:double,conversionFactor,66,77,12,12.8 */<BR>

118 sprintf(tempbuffer,&quot;%12.8f&quot;,(sp-&gt;conversionFactor));

<BR>

119 tempbuffer[12]= 0;<BR>

120 strncat((STRPTR )(&amp;buffer[65]),tempbuffer,12);<BR>

121<BR>

122 /* Encode:double,inverseFlattening,66,77,12,12.7 */<BR>

123 sprintf(tempbuffer,&quot;%12.7f&quot;,(sp-&gt;inverseFlattening));

<BR>

124 tempbuffer[12]= 0;<BR>

125 strncat((STRPTR )(&amp;buffer[65]),tempbuffer,12);<BR>

126 padTo80(buffer);<BR>

127 } /* End of encoding function */<BR>

128<BR>

129 /*:<BR>

130 ** Generated by Perl script -- Avoid editing<BR>

131 */<BR>

132 void encode_E3100_type(STRPTR buffer,P286_E3100_PTR sp)<BR>

133 {<BR>

134 STRPTR ncp;<BR>

135<BR>

136 STRPTR cp;<BR>

137 register int i;<BR>

138 char tempbuffer[80];<BR>

139<BR>

140<BR>

141 /* Encode:double,velprop,6,12,7,7.2 */<BR>

142 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;velprop));<BR>

143 tempbuffer[7]= 0;<BR>

144 strncat((STRPTR )(&amp;buffer[5]),tempbuffer,7);<BR>

145<BR>

146 /* Encode:int,srcNdx[0],13,16,4, */<BR>

147 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;srcNdx[0]));<BR>

148 tempbuffer[4]= 0;<BR>

149 strncat((STRPTR )(&amp;buffer[12]),tempbuffer,4);<BR>

150<BR>

151 /* Encode:int,srcNdx[1],26,29,4, */<BR>

152 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;srcNdx[1]));<BR>

153 tempbuffer[4]= 0;<BR>

154 strncat((STRPTR )(&amp;buffer[25]),tempbuffer,4);<BR>

155<BR>

156 /* Encode:int,srcNdx[2],39,42,4, */<BR>

157 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;srcNdx[2]));<BR>

158 tempbuffer[4]= 0;<BR>

159 strncat((STRPTR )(&amp;buffer[38]),tempbuffer,4);<BR>

160<BR>

161 /* Encode:int,srcNdx[3],52,55,4, */<BR>

162 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;srcNdx[3]));<BR>

163 tempbuffer[4]= 0;<BR>

164 strncat((STRPTR )(&amp;buffer[51]),tempbuffer,4);<BR>

165<BR>

166 /* Encode:int,srcNdx[4],65,68,4, */<BR>

167 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;srcNdx[4]));<BR>

168 tempbuffer[4]= 0;<BR>

169 strncat((STRPTR )(&amp;buffer[64]),tempbuffer,4);<BR>

170<BR>

171 /* Encode:int,dstNdx[0],13,16,4, */<BR>

172 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;dstNdx[0]));<BR>

173 tempbuffer[4]= 0;<BR>

174 strncat((STRPTR )(&amp;buffer[12]),tempbuffer,4);<BR>

175<BR>

176 /* Encode:int,dstNdx[1],26,29,4, */<BR>

177 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;dstNdx[1]));<BR>

178 tempbuffer[4]= 0;<BR>

179 strncat((STRPTR )(&amp;buffer[25]),tempbuffer,4);<BR>

180<BR>

181 /* Encode:int,dstNdx[2],39,42,4, */<BR>

182 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;dstNdx[2]));<BR>

183 tempbuffer[4]= 0;<BR>

184 strncat((STRPTR )(&amp;buffer[38]),tempbuffer,4);<BR>

185<BR>

186 /* Encode:int,dstNdx[3],52,55,4, */<BR>

187 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;dstNdx[3]));<BR>

188 tempbuffer[4]= 0;<BR>

189 strncat((STRPTR )(&amp;buffer[51]),tempbuffer,4);<BR>

190<BR>

191 /* Encode:int,dstNdx[4],65,68,4, */<BR>

192 sprintf(tempbuffer,&quot;%d4&quot;,(sp-&gt;dstNdx[4]));<BR>

193 tempbuffer[4]= 0;<BR>

194 strncat((STRPTR )(&amp;buffer[64]),tempbuffer,4);<BR>

195<BR>

196 /* Encode:double,slant[0],13,20,8,7.2 */<BR>

197 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;slant[0]));<BR>

198 tempbuffer[8]= 0;<BR>

199 strncat((STRPTR )(&amp;buffer[12]),tempbuffer,8);<BR>

200<BR>

201 /* Encode:double,slant[1],26,33,8,7.2 */<BR>

202 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;slant[1]));<BR>

203 tempbuffer[8]= 0;<BR>

204 strncat((STRPTR )(&amp;buffer[25]),tempbuffer,8);<BR>

205<BR>

206 /* Encode:double,slant[2],39,46,8,7.2 */<BR>

207 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;slant[2]));<BR>

208 tempbuffer[8]= 0;<BR>

209 strncat((STRPTR )(&amp;buffer[38]),tempbuffer,8);<BR>

210<BR>

211 /* Encode:double,slant[3],52,59,8,7.2 */<BR>

212 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;slant[3]));<BR>

213 tempbuffer[8]= 0;<BR>

214 strncat((STRPTR )(&amp;buffer[51]),tempbuffer,8);<BR>

215<BR>

216 /* Encode:double,slant[4],65,72,8,7.2 */<BR>

217 sprintf(tempbuffer,&quot;%7.2f&quot;,(sp-&gt;slant[4]));<BR>

218 tempbuffer[8]= 0;<BR>

219 strncat((STRPTR )(&amp;buffer[64]),tempbuffer,8);<BR>

220 padTo80(buffer);<BR>

221 } /* End of encoding function */</FONT></TT>

</BLOCKQUOTE>

<HR>

<HR>

<BLOCKQUOTE>

<B>Listing 31.4. The decoder file </B><TT><B><FONT FACE="Courier">P286dec.c</FONT></B></TT><B>.

<BR>

</B>

</BLOCKQUOTE>

<BLOCKQUOTE>

<TT><FONT FACE="Courier">&nbsp;&nbsp;1 /**<BR>

&nbsp;&nbsp;2 * C source file to decode records.<BR>

&nbsp;&nbsp;3 Don't edit this file<BR>

&nbsp;&nbsp;4&nbsp;&nbsp;*/<BR>

&nbsp;&nbsp;5 #include &quot;p286.h&quot;<BR>

&nbsp;&nbsp;6<BR>

&nbsp;&nbsp;7 /* The outgoing buffer must be 81 chars! */<BR>

&nbsp;&nbsp;8 extern void padTo80(STRPTR buffer);<BR>

&nbsp;&nbsp;9<BR>

&nbsp;10<BR>

&nbsp;11 /* The outgoing buffer must also be 81 chars! */<BR>

&nbsp;12 void substr(STRPTR buffer,STRPTR cut,int offset, int

len)<BR>

&nbsp;13 {<BR>

&nbsp;14 int i,j;<BR>

&nbsp;15 j = offset;<BR>

&nbsp;16 for(i=len;i&lt;80;i++) cut[i] = buffer[j];<BR>

&nbsp;17&nbsp;&nbsp;cut[len] = 0; /* NULL terminate the string*/

<BR>

&nbsp;18 } /* end of padding function */<BR>

&nbsp;19<BR>

&nbsp;20<BR>

&nbsp;21 /*:<BR>

&nbsp;22 ** Generated by Perl script -- Avoid editing<BR>

&nbsp;23 ** The outgoing buffer must also be 81 chars!<BR>

&nbsp;24 */<BR>

&nbsp;25 void decode_H0001_type(P286_H0001_PTR sp,STRPTR buffer)

<BR>

&nbsp;26 {<BR>

&nbsp;27 STRPTR cp;<BR>

&nbsp;28 register int i;<BR>

&nbsp;29 char tempbuffer[80];<BR>

&nbsp;30<BR>

&nbsp;31<BR>

&nbsp;32 strncpy(sp-&gt;SurveyType,(STRPTR )(&amp;buffer[28]),52);

<BR>

&nbsp;33 sp-&gt;SurveyType[52]= 0;<BR>

&nbsp;34 } /* End of decoding function */<BR>

&nbsp;35<BR>

&nbsp;36 /*:<BR>

&nbsp;37 ** Generated by Perl script -- Avoid editing<BR>

&nbsp;38 ** The outgoing buffer must also be 81 chars!<BR>

&nbsp;39 */<BR>

&nbsp;40 void decode_H0010_type(P286_H0010_PTR sp,STRPTR buffer)

<BR>

&nbsp;41 {<BR>

&nbsp;42 STRPTR cp;<BR>

&nbsp;43 register int i;<BR>

&nbsp;44 char tempbuffer[80];<BR>

&nbsp;45<BR>

&nbsp;46<BR>

&nbsp;47 strncpy(tempbuffer,(STRPTR )(&amp;buffer[5]),2);<BR>

&nbsp;48 tempbuffer[2]= 0;<BR>

&nbsp;49 sscanf(tempbuffer,&quot;%2d&quot;,&amp;(sp-&gt;numPatterns));

<BR>

&nbsp;50<BR>

&nbsp;51 strncpy(tempbuffer,(STRPTR )(&amp;buffer[7]),1);<BR>

&nbsp;52 tempbuffer[1]= 0;<BR>

&nbsp;53 sscanf(tempbuffer,&quot;%1d&quot;,&amp;(sp-&gt;sblInUse));

<BR>

&nbsp;54<BR>

&nbsp;55 strncpy(tempbuffer,(STRPTR )(&amp;buffer[8]),1);<BR>

&nbsp;56 tempbuffer[1]= 0;<BR>

&nbsp;57 sscanf(tempbuffer,&quot;%1d&quot;,&amp;(sp-&gt;sattInUse));

<BR>

&nbsp;58<BR>

&nbsp;59 strncpy(tempbuffer,(STRPTR )(&amp;buffer[9]),1);<BR>

&nbsp;60 tempbuffer[1]= 0;<BR>

&nbsp;61 sscanf(tempbuffer,&quot;%1d&quot;,&amp;(sp-&gt;numVessels));

<BR>

&nbsp;62<BR>

&nbsp;63 strncpy(tempbuffer,(STRPTR )(&amp;buffer[10]),1);<BR>

&nbsp;64 tempbuffer[1]= 0;<BR>

&nbsp;65 sscanf(tempbuffer,&quot;%1d&quot;

⌨️ 快捷键说明

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