summaryrefslogtreecommitdiff
path: root/connect/ncbi_file_connector.h
blob: 945190adaf8af6b39991b5a8ec0deae92c15c52c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef CONNECT___NCBI_FILE_CONNECTOR__H
#define CONNECT___NCBI_FILE_CONNECTOR__H

/* $Id: ncbi_file_connector.h,v 6.6 2012/01/20 14:54:32 kazimird Exp $
 * ===========================================================================
 *
 *                            PUBLIC DOMAIN NOTICE
 *               National Center for Biotechnology Information
 *
 *  This software/database is a "United States Government Work" under the
 *  terms of the United States Copyright Act.  It was written as part of
 *  the author's official duties as a United States Government employee and
 *  thus cannot be copyrighted.  This software/database is freely available
 *  to the public for use. The National Library of Medicine and the U.S.
 *  Government have not placed any restriction on its use or reproduction.
 *
 *  Although all reasonable efforts have been taken to ensure the accuracy
 *  and reliability of the software and data, the NLM and the U.S.
 *  Government do not and cannot warrant the performance or results that
 *  may be obtained by using this software or data. The NLM and the U.S.
 *  Government disclaim all warranties, express or implied, including
 *  warranties of performance, merchantability or fitness for any particular
 *  purpose.
 *
 *  Please cite the author in any work or product based on this material.
 *
 * ===========================================================================
 *
 * Authors:  Vladimir Alekseyev, Denis Vakatov
 *
 * File Description:
 *   Implement CONNECTOR for a FILE stream
 *
 *   See in "connectr.h" for the detailed specification of the underlying
 *   connector("CONNECTOR", "SConnectorTag") methods and structures.
 *
 */

#include <connect/ncbi_connector.h>


/** @addtogroup Connectors
 *
 * @{
 */


#ifdef __cplusplus
extern "C" {
#endif


/* Create new CONNECTOR structure to handle a data transfer between two files
 * (equivalent to FILE_CreateConnectorEx(.,.,NULL)).
 * Can have either ifname or ofname (not both!) as NULL or empty causing
 * either no input or no output available, respectively.
 * Return NULL on error.
 */
extern NCBI_XCONNECT_EXPORT CONNECTOR FILE_CreateConnector
(const char* ifname,  /* to read data from         */
 const char* ofname   /* to write the read data to */
 );


/* Open mode for the output data file
 */
typedef enum {
    eFCM_Truncate,  /* create new or replace existing file               */
    eFCM_Append,    /* add at the end of file                            */
    eFCM_Seek       /* seek to specified position before doing first I/O */
} EFILE_ConnMode;


/* Extended file connector attributes
 */
typedef struct {
    EFILE_ConnMode w_mode;  /* how to open output file                   */
    TNCBI_BigCount w_pos;   /* eFCM_Seek only: begin to write at "w_pos" */
    TNCBI_BigCount r_pos;   /* file position to start reading at         */
} SFILE_ConnAttr;


/* An extended version of FILE_CreateConnector().
 */
extern NCBI_XCONNECT_EXPORT CONNECTOR FILE_CreateConnectorEx
(const char*           ifname,
 const char*           ofname,
 const SFILE_ConnAttr* attr
 );


#ifdef __cplusplus
}  /* extern "C" */
#endif


/* @} */

#endif /* CONNECT___NCBI_FILE_CONNECTOR__H */