~ubuntu-branches/debian/experimental/ncbi-tools6/experimental

« back to all changes in this revision

Viewing changes to network/id2arch/id2sgen.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-07-14 19:43:15 UTC
  • mfrom: (2.1.12 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080714194315-ed44u9ek7txva2rz
Tags: 6.1.20080302-3
tools/readdb.c: enable madvise()-based code on all glibc (hence all
Debian) systems, not just Linux.  (Closes: #490437.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
   }
262
262
   AsnGenericUserSeqOfFree(ptr -> bioseqs_info, (AsnOptFreeFunc) ID2SBioseqsInfoFree);
263
263
   AsnGenericUserSeqOfFree(ptr -> chunks, (AsnOptFreeFunc) ID2SChunkInfoFree);
 
264
   SeqEntryFree(ptr -> skeleton);
264
265
   return MemFree(ptr);
265
266
}
266
267
 
326
327
      }
327
328
      atp = AsnReadId(aip,amp, atp);
328
329
   }
 
330
   if (atp == ID2S_SPLIT_INFO_skeleton) {
 
331
      ptr -> skeleton = SeqEntryAsnRead(aip, atp);
 
332
      if (aip -> io_failure) {
 
333
         goto erret;
 
334
      }
 
335
      atp = AsnReadId(aip,amp, atp);
 
336
   }
329
337
 
330
338
   if (AsnReadVal(aip, atp, &av) <= 0) {
331
339
      goto erret;
379
387
 
380
388
   AsnGenericUserSeqOfAsnWrite(ptr -> bioseqs_info, (AsnWriteFunc) ID2SBioseqsInfoAsnWrite, aip, ID2S_SPLIT_INFO_bioseqs_info, ID2S_SPLIT_INFO_bioseqs_info_E);
381
389
   AsnGenericUserSeqOfAsnWrite(ptr -> chunks, (AsnWriteFunc) ID2SChunkInfoAsnWrite, aip, ID2S_SPLIT_INFO_chunks, ID2S_SPLIT_INFO_chunks_E);
 
390
   if (ptr -> skeleton != NULL) {
 
391
      if ( ! SeqEntryAsnWrite(ptr -> skeleton, aip, ID2S_SPLIT_INFO_skeleton)) {
 
392
         goto erret;
 
393
      }
 
394
   }
382
395
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
383
396
      goto erret;
384
397
   }
1222
1235
   case ID2SChunkContent_bioseq_place:
1223
1236
      AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) ID2SBioseqPlaceInfoFree);
1224
1237
      break;
 
1238
   case ID2SChunkContent_feat_ids:
 
1239
      AsnGenericUserSeqOfFree((Pointer) pnt, (AsnOptFreeFunc) ID2SSeqFeatIdsInfoFree);
 
1240
      break;
1225
1241
   }
1226
1242
   return MemFree(anp);
1227
1243
}
1310
1326
         goto erret;
1311
1327
      }
1312
1328
   }
 
1329
   else if (atp == ID2S_CHUNK_CONTENT_feat_ids) {
 
1330
      choice = ID2SChunkContent_feat_ids;
 
1331
      anp -> data.ptrvalue =
 
1332
      AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SSeqFeatIdsInfoAsnRead,             (AsnOptFreeFunc) ID2SSeqFeatIdsInfoFree);
 
1333
      if (isError && anp -> data.ptrvalue == NULL) {
 
1334
         goto erret;
 
1335
      }
 
1336
   }
1313
1337
   anp->choice = choice;
1314
1338
   if (func != NULL)
1315
1339
   {
1398
1422
   case ID2SChunkContent_bioseq_place:
1399
1423
      retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) ID2SBioseqPlaceInfoAsnWrite, aip, ID2S_CHUNK_CONTENT_bioseq_place, CHUNK_CONTENT_bioseq_place_E);
1400
1424
      break;
 
1425
   case ID2SChunkContent_feat_ids:
 
1426
      retval = AsnGenericUserSeqOfAsnWrite((Pointer) pnt, (AsnWriteFunc) ID2SSeqFeatIdsInfoAsnWrite, aip, ID2S_CHUNK_CONTENT_feat_ids, ID2S_CHUNK_CONTENT_feat_ids_E);
 
1427
      break;
1401
1428
   }
1402
1429
   if (writetype != NULL) {
1403
1430
      retval = (* func)(pnt, aip, writetype);   /* write it out */
2095
2122
 
2096
2123
/**************************************************
2097
2124
*
 
2125
*    ID2SSeqFeatIdsInfoNew()
 
2126
*
 
2127
**************************************************/
 
2128
NLM_EXTERN 
 
2129
ID2SSeqFeatIdsInfoPtr LIBCALL
 
2130
ID2SSeqFeatIdsInfoNew(void)
 
2131
{
 
2132
   ID2SSeqFeatIdsInfoPtr ptr = MemNew((size_t) sizeof(ID2SSeqFeatIdsInfo));
 
2133
 
 
2134
   return ptr;
 
2135
 
 
2136
}
 
2137
 
 
2138
 
 
2139
/**************************************************
 
2140
*
 
2141
*    ID2SSeqFeatIdsInfoFree()
 
2142
*
 
2143
**************************************************/
 
2144
NLM_EXTERN 
 
2145
ID2SSeqFeatIdsInfoPtr LIBCALL
 
2146
ID2SSeqFeatIdsInfoFree(ID2SSeqFeatIdsInfoPtr ptr)
 
2147
{
 
2148
 
 
2149
   if(ptr == NULL) {
 
2150
      return NULL;
 
2151
   }
 
2152
   AsnGenericUserSeqOfFree(ptr -> feat_types, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
 
2153
   AsnGenericUserSeqOfFree(ptr -> xref_types, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
 
2154
   AsnGenericBaseSeqOfFree(ptr -> local_ids ,ASNCODE_INTVAL_SLOT);
 
2155
   return MemFree(ptr);
 
2156
}
 
2157
 
 
2158
 
 
2159
/**************************************************
 
2160
*
 
2161
*    ID2SSeqFeatIdsInfoAsnRead()
 
2162
*
 
2163
**************************************************/
 
2164
NLM_EXTERN 
 
2165
ID2SSeqFeatIdsInfoPtr LIBCALL
 
2166
ID2SSeqFeatIdsInfoAsnRead(AsnIoPtr aip, AsnTypePtr orig)
 
2167
{
 
2168
   DataVal av;
 
2169
   AsnTypePtr atp;
 
2170
   Boolean isError = FALSE;
 
2171
   AsnReadFunc func;
 
2172
   ID2SSeqFeatIdsInfoPtr ptr;
 
2173
 
 
2174
   if (! loaded)
 
2175
   {
 
2176
      if (! id2sgenAsnLoad()) {
 
2177
         return NULL;
 
2178
      }
 
2179
   }
 
2180
 
 
2181
   if (aip == NULL) {
 
2182
      return NULL;
 
2183
   }
 
2184
 
 
2185
   if (orig == NULL) {         /* ID2SSeqFeatIdsInfo ::= (self contained) */
 
2186
      atp = AsnReadId(aip, amp, ID2S_SEQ_FEAT_IDS_INFO);
 
2187
   } else {
 
2188
      atp = AsnLinkType(orig, ID2S_SEQ_FEAT_IDS_INFO);
 
2189
   }
 
2190
   /* link in local tree */
 
2191
   if (atp == NULL) {
 
2192
      return NULL;
 
2193
   }
 
2194
 
 
2195
   ptr = ID2SSeqFeatIdsInfoNew();
 
2196
   if (ptr == NULL) {
 
2197
      goto erret;
 
2198
   }
 
2199
   if (AsnReadVal(aip, atp, &av) <= 0) { /* read the start struct */
 
2200
      goto erret;
 
2201
   }
 
2202
 
 
2203
   atp = AsnReadId(aip,amp, atp);
 
2204
   func = NULL;
 
2205
 
 
2206
   if (atp == SEQ_FEAT_IDS_INFO_feat_types) {
 
2207
      ptr -> feat_types = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SFeatTypeInfoAsnRead, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
 
2208
      if (isError && ptr -> feat_types == NULL) {
 
2209
         goto erret;
 
2210
      }
 
2211
      atp = AsnReadId(aip,amp, atp);
 
2212
   }
 
2213
   if (atp == SEQ_FEAT_IDS_INFO_xref_types) {
 
2214
      ptr -> xref_types = AsnGenericUserSeqOfAsnRead(aip, amp, atp, &isError, (AsnReadFunc) ID2SFeatTypeInfoAsnRead, (AsnOptFreeFunc) ID2SFeatTypeInfoFree);
 
2215
      if (isError && ptr -> xref_types == NULL) {
 
2216
         goto erret;
 
2217
      }
 
2218
      atp = AsnReadId(aip,amp, atp);
 
2219
   }
 
2220
   if (atp == SEQ_FEAT_IDS_INFO_local_ids) {
 
2221
      ptr -> local_ids = AsnGenericBaseSeqOfAsnRead(aip, amp, atp, ASNCODE_INTVAL_SLOT, &isError);
 
2222
      if (isError && ptr -> local_ids == NULL) {
 
2223
         goto erret;
 
2224
      }
 
2225
      atp = AsnReadId(aip,amp, atp);
 
2226
   }
 
2227
 
 
2228
   if (AsnReadVal(aip, atp, &av) <= 0) {
 
2229
      goto erret;
 
2230
   }
 
2231
   /* end struct */
 
2232
 
 
2233
ret:
 
2234
   AsnUnlinkType(orig);       /* unlink local tree */
 
2235
   return ptr;
 
2236
 
 
2237
erret:
 
2238
   aip -> io_failure = TRUE;
 
2239
   ptr = ID2SSeqFeatIdsInfoFree(ptr);
 
2240
   goto ret;
 
2241
}
 
2242
 
 
2243
 
 
2244
 
 
2245
/**************************************************
 
2246
*
 
2247
*    ID2SSeqFeatIdsInfoAsnWrite()
 
2248
*
 
2249
**************************************************/
 
2250
NLM_EXTERN Boolean LIBCALL 
 
2251
ID2SSeqFeatIdsInfoAsnWrite(ID2SSeqFeatIdsInfoPtr ptr, AsnIoPtr aip, AsnTypePtr orig)
 
2252
{
 
2253
   DataVal av;
 
2254
   AsnTypePtr atp;
 
2255
   Boolean retval = FALSE;
 
2256
 
 
2257
   if (! loaded)
 
2258
   {
 
2259
      if (! id2sgenAsnLoad()) {
 
2260
         return FALSE;
 
2261
      }
 
2262
   }
 
2263
 
 
2264
   if (aip == NULL) {
 
2265
      return FALSE;
 
2266
   }
 
2267
 
 
2268
   atp = AsnLinkType(orig, ID2S_SEQ_FEAT_IDS_INFO);   /* link local tree */
 
2269
   if (atp == NULL) {
 
2270
      return FALSE;
 
2271
   }
 
2272
 
 
2273
   if (ptr == NULL) { AsnNullValueMsg(aip, atp); goto erret; }
 
2274
   if (! AsnOpenStruct(aip, atp, (Pointer) ptr)) {
 
2275
      goto erret;
 
2276
   }
 
2277
 
 
2278
   AsnGenericUserSeqOfAsnWrite(ptr -> feat_types, (AsnWriteFunc) ID2SFeatTypeInfoAsnWrite, aip, SEQ_FEAT_IDS_INFO_feat_types, SEQ_FEAT_IDS_INFO_feat_types_E);
 
2279
   AsnGenericUserSeqOfAsnWrite(ptr -> xref_types, (AsnWriteFunc) ID2SFeatTypeInfoAsnWrite, aip, SEQ_FEAT_IDS_INFO_xref_types, SEQ_FEAT_IDS_INFO_xref_types_E);
 
2280
   retval = AsnGenericBaseSeqOfAsnWrite(ptr -> local_ids ,ASNCODE_INTVAL_SLOT, aip, SEQ_FEAT_IDS_INFO_local_ids, SEQ_FEAT_IDS_INFO_local_ids_E);
 
2281
   if (! AsnCloseStruct(aip, atp, (Pointer)ptr)) {
 
2282
      goto erret;
 
2283
   }
 
2284
   retval = TRUE;
 
2285
 
 
2286
erret:
 
2287
   AsnUnlinkType(orig);       /* unlink local tree */
 
2288
   return retval;
 
2289
}
 
2290
 
 
2291
 
 
2292
 
 
2293
/**************************************************
 
2294
*
2098
2295
*    ID2SBioseqSetIdsFree()
2099
2296
*
2100
2297
**************************************************/