~ubuntu-branches/ubuntu/precise/ncbi-tools6/precise

« back to all changes in this revision

Viewing changes to network/taxon1/taxon2/txcdproc.c

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-03-27 12:00:15 UTC
  • mfrom: (2.1.2 hoary)
  • Revision ID: james.westby@ubuntu.com-20050327120015-embhesp32nj73p9r
Tags: 6.1.20041020-3
* Fix FTBFS under GCC 4.0 caused by inconsistent use of "static" on
  functions.  (Closes: #295110.)
* Add a watch file, now that we can.  (Upstream's layout needs version=3.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
*
30
30
* Version Creation Date:   07/15/97
31
31
*
32
 
* $Revision: 1.12 $
 
32
* $Revision: 1.16 $
33
33
*
34
34
* File Description: 
35
35
*       API for Taxonomy service
44
44
*
45
45
* RCS Modification History:
46
46
* $Log: txcdproc.c,v $
 
47
* Revision 1.16  2003/11/04 17:13:58  soussov
 
48
* adds NetFini() call if service can not start properly
 
49
*
 
50
* Revision 1.15  2003/06/12 16:46:25  soussov
 
51
* changes severity for AsnRead failures
 
52
*
 
53
* Revision 1.14  2003/03/06 16:30:32  kans
 
54
* tdp->org needed a cast to (OrgRefPtr) due to Mac compiler complaint
 
55
*
 
56
* Revision 1.13  2003/03/05 21:32:00  soussov
 
57
* new lookup procedure
 
58
*
47
59
* Revision 1.12  2001/09/28 15:53:15  soussov
48
60
* tax1e_maxTaxId() added
49
61
*
127
139
static void report_service_error(CharPtr proc_name, Taxon1RespPtr taxbp)
128
140
{
129
141
    if(taxbp == NULL) {
130
 
        ErrPostEx(SEV_ERROR, 0, 0, "%s got NULL responce from service");
 
142
        ErrPostEx(SEV_ERROR, 0, 0, "%s got NULL responce from service", proc_name);
131
143
    }
132
144
    else if(taxbp->choice == Taxon1Resp_error) {
133
145
        Taxon1ErrorPtr tep= taxbp->data.ptrvalue;
157
169
 
158
170
    if ((taxbp == NULL) || ErrFetch(&err))
159
171
    {
160
 
        ErrPost (CTX_UNKNOWN, 1, "Null message read from server");
 
172
        ErrPostEx (SEV_WARNING, 1, 1, "Null message read from server");
161
173
    }
162
174
    ErrSetOpts(erract, 0);
163
175
 
206
218
    Taxon1ReqFree (taxrp);
207
219
 
208
220
    if((taxbp = NetTaxArchReadAsn()) == NULL) {
 
221
        NetFini();
209
222
        return FALSE;
210
223
    }
211
224
    else  {
1195
1208
            retval = myNetInit();
1196
1209
        }
1197
1210
        else {
1198
 
            ErrPost(CTX_UNKNOWN, 1, "Unable to re-contact dispatcher");
 
1211
            ErrPostEx(SEV_ERROR, 1,2, "Unable to re-contact dispatcher");
1199
1212
            if (showErrs) {
1200
1213
                ErrShow();
1201
1214
            }
1206
1219
 
1207
1220
    if (! retval )
1208
1221
    {
1209
 
        sprintf (buf, "Unable to re-establish %s service", svcName);
1210
 
        ErrPost(CTX_UNKNOWN, 1, buf);
 
1222
        /*sprintf (buf, "Unable to re-establish %s service", svcName);*/
 
1223
        ErrPostEx(SEV_ERROR, 1, 3, "Unable to re-establish %s service", svcName);
1211
1224
        if (showErrs) {
1212
1225
            ErrShow();
1213
1226
        }
1453
1466
 
1454
1467
    return tax_id;
1455
1468
}
 
1469
 
 
1470
static OrgRefPtr s_findbyorg(OrgRefPtr orgRef)
 
1471
{
 
1472
    Taxon1ReqPtr taxrp;
 
1473
    Taxon1RespPtr taxbp;
 
1474
    Taxon1DataPtr tdp;
 
1475
 
 
1476
    if((taxrp= ValNodeNew(NULL)) == NULL) return 0;
 
1477
    taxrp->choice= Taxon1Req_lookup;
 
1478
    taxrp->data.ptrvalue= orgRef;
 
1479
    Taxon1ReqAsnWrite(taxrp, asnout, NULL);
 
1480
    AsnIoReset(asnout);
 
1481
    taxrp->data.ptrvalue= NULL;
 
1482
    Taxon1ReqFree(taxrp);
 
1483
 
 
1484
    if((taxbp= NetTaxArchReadAsn()) == NULL) return 0;
 
1485
    
 
1486
    if(taxbp->choice != Taxon1Resp_lookup) {
 
1487
        report_service_error("txc_getTaxIdByOrgRef", taxbp);
 
1488
        Taxon1RespFree(taxbp);
 
1489
        return NULL;
 
1490
    }
 
1491
    
 
1492
    tdp= taxbp->data.ptrvalue;
 
1493
    orgRef= (OrgRefPtr) tdp->org;
 
1494
    tdp->org= NULL;
 
1495
    Taxon1RespFree(taxbp);
 
1496
    
 
1497
    return orgRef;
 
1498
}
 
1499
 
 
1500
Int4 txc_findByOrg(OrgRefPtr inp_orgRef, OrgModPtr* hitName)
 
1501
{
 
1502
    Int4 i;
 
1503
    short erract;
 
1504
    ErrDesc err;
 
1505
    OrgRefPtr orp= NULL;
 
1506
    Int4 tax_id= 0;
 
1507
 
 
1508
    if(tax_track) tax_time1= clock();
 
1509
    for (i= TAXARCH_SERV_RETRIES; i >= 0; --i) {
 
1510
        ErrGetOpts(&erract, NULL);
 
1511
        ErrSetOpts(ERR_IGNORE, 0);
 
1512
        ErrFetch(&err);
 
1513
 
 
1514
        orp = s_findbyorg(inp_orgRef);
 
1515
 
 
1516
        ErrSetOpts(erract, 0);
 
1517
        if (!ErrFetch(&err))  break; /* success */
 
1518
        
 
1519
        if(!ReestablishNetTaxArch()) break;
 
1520
    }
 
1521
    
 
1522
    if(tax_track) {
 
1523
        double diff= (double)(clock() - tax_time1)/CLOCKS_PER_SEC;
 
1524
        printf("tax1_getTaxIdByOrgRef() %f\n", diff);
 
1525
    }
 
1526
    
 
1527
    if(orp && orp->db) {
 
1528
        ValNodePtr vnp= orp->db;
 
1529
        DbtagPtr dbtag= vnp->data.ptrvalue;
 
1530
        ObjectIdPtr object_id= dbtag->tag;
 
1531
        tax_id= object_id->id;
 
1532
        
 
1533
        if(hitName) {
 
1534
            if(orp->orgname) {
 
1535
                *hitName= orp->orgname->mod;
 
1536
                orp->orgname->mod= NULL;
 
1537
            }
 
1538
            else *hitName= NULL;
 
1539
        }
 
1540
    }
 
1541
 
 
1542
    if(orp) OrgRefFree(orp);
 
1543
 
 
1544
    return tax_id;
 
1545
}
 
1546