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

« back to all changes in this revision

Viewing changes to ctools/asn_connection.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:
1
 
/*  $Id: asn_connection.c,v 1.3 2001/09/24 20:32:44 lavr Exp $
 
1
/*  $Id: asn_connection.c,v 1.7 2004/03/23 02:29:19 lavr Exp $
2
2
 * ===========================================================================
3
3
 *
4
4
 *                            PUBLIC DOMAIN NOTICE
28
28
 * File Description:
29
29
 *     Build C Toolkit ASN streams on top of CONN (connection).
30
30
 *
31
 
 * --------------------------------------------------------------------------
32
 
 * $Log: asn_connection.c,v $
33
 
 * Revision 1.3  2001/09/24 20:32:44  lavr
34
 
 * +SSERVICE_Extra* parameter in CreateAsnConn_ServiceEx()
35
 
 *
36
 
 * Revision 1.2  2001/06/29 14:04:17  lavr
37
 
 * Close callback removes itself when called; fixes not to add callbacks
38
 
 * in CreateAsnConn_ServiceEx, because they are already there!
39
 
 *
40
 
 * Revision 1.1  2001/06/28 21:58:23  lavr
41
 
 * Initial revision
42
 
 *
43
 
 * ==========================================================================
44
31
 */
45
32
 
46
33
#include <connect/ncbi_service_connector.h>
47
34
#include <ctools/asn_connection.h>
48
35
#include "../connect/ncbi_priv.h"
49
 
#include <assert.h>
50
 
#include <stdio.h>
51
 
#include <stdlib.h>
52
36
 
53
37
 
54
38
#ifdef __cplusplus
62
46
 
63
47
static Int2 LIBCALLBACK s_AsnRead(Pointer p, CharPtr buff, Uint2 len)
64
48
{
65
 
    size_t n_read = 0;
66
 
    CONN_Read((CONN) p, buff, len, &n_read, eIO_Plain);
 
49
    size_t n_read;
 
50
    CONN_Read((CONN) p, buff, len, &n_read, eIO_ReadPlain);
67
51
    return (Int2) n_read;
68
52
}
69
53
 
70
54
 
71
55
static Int2 LIBCALLBACK s_AsnWrite(Pointer p, CharPtr buff, Uint2 len)
72
56
{
73
 
    size_t n_written = 0;
74
 
    CONN_Write((CONN) p, buff, len, &n_written);
 
57
    size_t n_written;
 
58
    CONN_Write((CONN) p, buff, len, &n_written, eIO_WritePersist);
75
59
    return (Int2) n_written;
76
60
}
77
61
 
89
73
    assert(type == eCONN_OnClose && cbdata && cbdata->ptr);
90
74
    CONN_SetCallback(conn, type, &cbdata->cb, 0); 
91
75
    AsnIoFree(cbdata->ptr, 0/*not a file - don't close*/);
92
 
    if (cbdata->cb.func)
 
76
    if ( cbdata->cb.func )
93
77
        (*cbdata->cb.func)(conn, type, cbdata->cb.data);
94
78
    free(cbdata);
95
79
}
100
84
    struct SAsnConn_Cbdata* cbdata = (struct SAsnConn_Cbdata*)
101
85
        malloc(sizeof(*cbdata));
102
86
 
103
 
    assert(ptr);
104
 
    if (cbdata) {
 
87
    assert( ptr );
 
88
    if ( cbdata ) {
105
89
        SCONN_Callback cb;
106
90
        cbdata->ptr = ptr;
107
91
        cb.func = s_CloseAsnConn;
182
166
    return CreateAsnConn_ServiceEx(service, input_fmt, input,
183
167
                                   output_fmt, output, fSERV_Any, 0, 0);
184
168
}
 
169
 
 
170
 
 
171
/*
 
172
 * --------------------------------------------------------------------------
 
173
 * $Log: asn_connection.c,v $
 
174
 * Revision 1.7  2004/03/23 02:29:19  lavr
 
175
 * Remove redundant inits in I/O callbacks
 
176
 *
 
177
 * Revision 1.6  2004/02/23 15:23:50  lavr
 
178
 * New (last) parameter "how" added in CONN_Write() API call
 
179
 *
 
180
 * Revision 1.5  2003/11/13 16:01:31  lavr
 
181
 * Included headers revised
 
182
 *
 
183
 * Revision 1.4  2002/08/07 16:38:18  lavr
 
184
 * EIO_ReadMethod enums changed accordingly; log moved to end
 
185
 *
 
186
 * Revision 1.3  2001/09/24 20:32:44  lavr
 
187
 * +SSERVICE_Extra* parameter in CreateAsnConn_ServiceEx()
 
188
 *
 
189
 * Revision 1.2  2001/06/29 14:04:17  lavr
 
190
 * Close callback removes itself when called; fixes not to add callbacks
 
191
 * in CreateAsnConn_ServiceEx, because they are already there!
 
192
 *
 
193
 * Revision 1.1  2001/06/28 21:58:23  lavr
 
194
 * Initial revision
 
195
 *
 
196
 * ==========================================================================
 
197
 */