FOSSology  4.4.0
Open Source License Compliance by Open Source Software
sqlCopy.h
1 /*
2  SPDX-FileCopyrightText: © 2011 Hewlett-Packard Development Company, L.P.
3 
4  SPDX-License-Identifier: LGPL-2.1-only
5 */
6 #ifndef _SQLCOPY_H
7 #define _SQLCOPY_H
8 
9 #include <stdlib.h>
10 #include <stdio.h>
11 #include <stdarg.h>
12 #include <errno.h>
13 #include <unistd.h>
14 #include <string.h>
15 #include <ctype.h>
16 #include <time.h>
17 #include <libpq-fe.h>
18 #include "libfossology.h" /* for the libfossdb error checking functions */
19 
20 #define ERROR_RETURN(Msg) {\
21  printf("ERROR: %s:%d, %s\n %s\n", __FILE__, __LINE__, Msg, strerror(errno)); \
22  return(0);}
23 
26 {
28  PGconn* pGconn;
30  char* TableName;
32  char ColumnNames[1024];
34  int BufSize;
36  int DataIdx;
37  char* DataBuf;
38 };
39 typedef struct sqlCopy_struct sqlCopy_t, * psqlCopy_t;
40 
41 psqlCopy_t fo_sqlCopyCreate(PGconn* pGconn, char* TableName, int BufSize, int NumColumns, ...);
42 int fo_sqlCopyAdd(psqlCopy_t pCopy, char* DataRow);
43 int fo_sqlCopyExecute(psqlCopy_t pCopy);
44 void fo_sqlCopyDestroy(psqlCopy_t pCopy, int ExecuteFlag);
45 void fo_sqlCopyPrint(psqlCopy_t pCopy, int PrintRows);
46 
47 #endif /* _SQLCOPY_H */
The main FOSSology C library.
int fo_sqlCopyAdd(psqlCopy_t pCopy, char *DataRow)
Add a data row to an sqlCopy Use '\N' to pass in a null.
Definition: sqlCopy.c:146
void fo_sqlCopyPrint(psqlCopy_t pCopy, int PrintBytes)
Print the sqlCopy_struct.
Definition: sqlCopy.c:313
void fo_sqlCopyDestroy(psqlCopy_t pCopy, int ExecuteFlag)
Destructor for sqlCopy_struct.
Definition: sqlCopy.c:293
psqlCopy_t fo_sqlCopyCreate(PGconn *pGconn, char *TableName, int BufSize, int NumColumns,...)
Constructor for sqlCopy_struct.
Definition: sqlCopy.c:51
int fo_sqlCopyExecute(psqlCopy_t pCopy)
Execute the copy (ie insert the buffered records into the database).
Definition: sqlCopy.c:241
char ColumnNames[1024]
Definition: sqlCopy.h:32
char * TableName
Definition: sqlCopy.h:30
PGconn * pGconn
Definition: sqlCopy.h:28