|
NCBI Home IEB Home C Toolkit docs C++ Toolkit source browser C Toolkit source browser (2) |
NCBI C Toolkit Cross ReferenceC/connect/ncbi_connector.c |
source navigation diff markup identifier search freetext search file search |
1 /* $Id: ncbi_connector.c,v 6.9 2007/10/17 15:25:43 kazimird Exp $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Author: Anton Lavrentiev
27 *
28 * File Description:
29 * This is generally not for the public use.
30 * Implementation of functions of meta-connector.
31 *
32 */
33
34 #include "ncbi_priv.h"
35 #include <connect/ncbi_connector.h>
36
37
38 #define NCBI_USE_ERRCODE_X Connect_MetaConn
39
40 /* Standard logging message
41 */
42 #define METACONN_LOG(subcode, level, descr) \
43 CORE_LOGF_X(subcode, level, \
44 ("%s (connector \"%s\", error \"%s\")", \
45 descr, (*meta->get_type)(meta->c_get_type), \
46 IO_StatusStr(status)))
47
48
49 extern EIO_Status METACONN_Remove
50 (SMetaConnector* meta,
51 CONNECTOR connector)
52 {
53 if (connector) {
54 CONNECTOR x_conn;
55
56 for (x_conn = meta->list; x_conn; x_conn = x_conn->next) {
57 if (x_conn == connector)
58 break;
59 }
60 if (!x_conn) {
61 EIO_Status status = eIO_Unknown;
62 METACONN_LOG(1, eLOG_Error,
63 "[METACONN_Remove] Connector is not in connection");
64 return status;
65 }
66 }
67
68 while (meta->list) {
69 CONNECTOR victim = meta->list;
70
71 meta->list = victim->next;
72 victim->meta = 0;
73 victim->next = 0;
74 if (victim->destroy)
75 victim->destroy(victim);
76 if (victim == connector)
77 break;
78 }
79
80 return eIO_Success;
81 }
82
83
84 extern EIO_Status METACONN_Add
85 (SMetaConnector* meta,
86 CONNECTOR connector)
87 {
88 assert(connector && meta);
89
90 if (connector->next || !connector->setup) {
91 EIO_Status status = eIO_Unknown;
92 METACONN_LOG(2, eLOG_Error,
93 "[METACONN_Add] Input connector is in use/uninitable");
94 return status;
95 }
96
97 connector->setup(meta, connector);
98 connector->meta = meta;
99 connector->next = meta->list;
100 meta->list = connector;
101
102 return eIO_Success;
103 }
104 |
This page was automatically generated by the
LXR engine.
Visit the LXR main site for more information. |