FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
sqlCopy.h
1 /**************************************************************
2 Copyright (C) 2011 Hewlett-Packard Development Company, L.P.
3 
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License version 2.1 as published by the Free Software Foundation.
7 
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Lesser General Public License for more details.
12 
13 You should have received a copy of the GNU Lesser General Public License
14 along with this library; if not, write to the Free Software Foundation, Inc.0
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 **************************************************************/
17 #ifndef _SQLCOPY_H
18 #define _SQLCOPY_H
19 
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <stdarg.h>
23 #include <errno.h>
24 #include <unistd.h>
25 #include <string.h>
26 #include <ctype.h>
27 #include <time.h>
28 #include <libpq-fe.h>
29 #include "libfossology.h" /* for the libfossdb error checking functions */
30 
31 #define ERROR_RETURN(Msg) {\
32  printf("ERROR: %s:%d, %s\n %s\n", __FILE__, __LINE__, Msg, strerror(errno)); \
33  return(0);}
34 
37 {
39  PGconn* pGconn;
41  char* TableName;
43  char ColumnNames[1024];
45  int BufSize;
47  int DataIdx;
48  char* DataBuf;
49 };
50 typedef struct sqlCopy_struct sqlCopy_t, * psqlCopy_t;
51 
52 psqlCopy_t fo_sqlCopyCreate(PGconn* pGconn, char* TableName, int BufSize, int NumColumns, ...);
53 int fo_sqlCopyAdd(psqlCopy_t pCopy, char* DataRow);
54 int fo_sqlCopyExecute(psqlCopy_t pCopy);
55 void fo_sqlCopyDestroy(psqlCopy_t pCopy, int ExecuteFlag);
56 void fo_sqlCopyPrint(psqlCopy_t pCopy, int PrintRows);
57 
58 #endif /* _SQLCOPY_H */
char ColumnNames[1024]
Definition: sqlCopy.h:43
char * TableName
Definition: sqlCopy.h:41
PGconn * pGconn
Definition: sqlCopy.h:39
The main FOSSology C library.
psqlCopy_t fo_sqlCopyCreate(PGconn *pGconn, char *TableName, int BufSize, int NumColumns,...)
Constructor for sqlCopy_struct.
Definition: sqlCopy.c:62
int fo_sqlCopyExecute(psqlCopy_t pCopy)
Execute the copy (ie insert the buffered records into the database).
Definition: sqlCopy.c:252
void fo_sqlCopyDestroy(psqlCopy_t pCopy, int ExecuteFlag)
Destructor for sqlCopy_struct.
Definition: sqlCopy.c:304
void fo_sqlCopyPrint(psqlCopy_t pCopy, int PrintBytes)
Print the sqlCopy_struct.
Definition: sqlCopy.c:324
int fo_sqlCopyAdd(psqlCopy_t pCopy, char *DataRow)
Add a data row to an sqlCopy Use &#39;&#39; to pass in a null.
Definition: sqlCopy.c:157