cldump-0.11~dfsg/0000775000175000017500000000000011474156645013336 5ustar julienjuliencldump-0.11~dfsg/magic0000664000175000017500000000137610164573577014352 0ustar julienjulien# # Magic numbers for the Clarion Personal/Professional Developer (v2 and above) files # # Julien BLACHE # #### Database and associated files ### Database files ## signature 0 leshort 0x3343 Clarion Personal/Professional Developer (v2 and above) data file ## interesting attributes >2 leshort &0x0001 \b, locked >2 leshort &0x0004 \b, encrypted >2 leshort &0x0008 \b, memo file exists >2 leshort &0x0010 \b, compressed >2 leshort &0x0040 \b, read only ## number of records >5 lelong x \b, %ld records ### Memo files 0 leshort 0x334d Clarion Personal/Professional Developer (v2 and above) memo data ### Key/Index files ## No magic ? :( #### Help files 0 leshort 0x49e0 Clarion Personal/Professional Developer (v2 and above) help data cldump-0.11~dfsg/src/0000775000175000017500000000000011474155647014126 5ustar julienjuliencldump-0.11~dfsg/src/cl_utils.c0000664000175000017500000000536210477017143016104 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_utils.c 53 2006-09-04 12:38:59Z julien $ */ #include #include #include #include #include #include #include #if BYTE_ORDER == BIG_ENDIAN size_t cl_fread (void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t ret; size_t i; uint16_t *p = (uint16_t *) ptr; uint32_t *pp = (uint32_t *) ptr; uint64_t *ppp = (uint64_t *) ptr; ret = fread(ptr, size, nmemb, stream); switch (size) { case 2: for (i = 0; i < ret; i++) p[i] = bswap_16(p[i]); break; case 4: for (i = 0; i < ret; i++) pp[i] = bswap_32(pp[i]); break; case 8: for (i = 0; i < ret; i++) ppp[i] = bswap_64(ppp[i]); break; default: break; } return ret; } #endif /* * WARNING : cldump.h redefines fread() to cl_fread() */ #include "cldump.h" void clarion_trim (uint8_t *data, int length) { int i; for (i = (length - 1); i >= 0; i--) { if (data[i] == 0x20) continue; else { data[i + 1] = '\0'; return; } } data[0] = '\0'; } void clarion_singlespace (char *data) { char *p = NULL; uint32_t offset; while (*data != '\0') { if (*data == 0x20) { if (p == NULL) p = data; } else { if (p != NULL) { p++; offset = data - p; memmove(p, data, strlen(data)+1); data = data - offset; p = NULL; } } data++; } } char * clarion_iconv (const char *charset, char *data) { iconv_t cd; char *buf, *tmp; size_t len; size_t buflen; size_t ret; len = strlen(data); if (len == 0) return NULL; cd = iconv_open("UTF-8", charset); if (cd == (iconv_t)(-1)) return NULL; buflen = 2 * len; buf = (char *) malloc(buflen + 1); tmp = buf; ret = iconv(cd, &data, &len, &tmp, &buflen); if (ret == (size_t)(-1)) { free(buf); return NULL; } *tmp = '\0'; iconv_close(cd); return buf; } cldump-0.11~dfsg/src/cldump.10000664000175000017500000000576511474155535015505 0ustar julienjulien.\" man page for cldump .\" groff -man -Tascii cldump.1 .\" $Id: cldump.1 67 2010-11-27 10:20:13Z julien $ .\" .TH cldump 1 "November 2010" Linux "User Manuals" .SH NAME cldump \- Clarion database extractor .SH SYNOPSIS .B cldump [\fIoptions\fR] database.dat .SH DESCRIPTION .B cldump extracts the data contained in a .I Clarion database; .I Clarion is a Windows IDE similar to .I Delphi or others, and has its own (simple) database format. .B cldump can extract the data contained in such a database, and export it to CSV, SQL (including the database schema, keys and indexes) or its own format (this format will give you all the meta information, but isn't easily parsable). A .I Clarion database consists in a set of files : .TP .B .DAT files contain the data, .TP .B .Kxx files contain the key/index data, .TP .B .MEM files contain the memo entries associated to the data. .SH OPTIONS .TP \fB\-x\fR \fIn\fR, \fB\-\-decrypt\fR \fIn\fR Decrypt an encrypted file. Required argument \fIn\fR indicates the location where the key will be retrieved. Valid values are in the range 1 \- 4 inclusive. \fIn\fR = 1 usually works. .BR Decryption happens in-place so \fBKEEP A BACKUP\fR as there is no guarantee the decryption process won't fail. Encrypted files must be decrypted before they can be dumped. .BR Note that only the data file and the memo file are decrypted in this process; key/index files are left untouched as \fBcldump\fR doesn't use them. .TP \fB\-d\fR, \fB\-\-dump\-active\fR Dump active entries only .TP \fB\-D\fR, \fB\-\-dump\-data\fR Dump the actual data (active and deleted entries) .TP \fB\-m\fR, \fB\-\-dump\-meta\fR Dump meta information (no SQL or CSV output format exist for this option) .TP \fB\-f\fR \fIc\fR, \fB\-\-field\-separator\fR \fIc\fR Set the field separator to character \fIc\fR. Only valid for CSV output (see below). .TP \fB\-c\fR, \fB\-\-csv\fR Dump data or schema in CSV format .TP \fB\-S\fR, \fB\-\-sql\fR Dump data or schema in SQL format .TP \fB\-s\fR, \fB\-\-schema\fR Dump database schema .TP \fB\-M\fR, \fB\-\-mysql\fR Use MySQL specific construct (backticks, ...) .TP \fB\-n\fR, \fB\-\-no\-memo\fR Do not dump memo entries .TP \fB\-U\fR[\fIcharset\fR], \fB\-\-utf8\fR[=\fIcharset\fR] Transcode strings and memos from \fIcharset\fR to UTF-8 (\fIcharset\fR defaults to ISO8859-1; for the list of supported charsets, see \fBiconv \-\-list\fR) .SH OUTPUT \fBcldump\fR outputs the data to \fIstdout\fR or \fIstderr\fR depending on the output format selected, the data to extract and the type of the data (data, meta data). .SH BUGS The SQL output could be improved. Not all the types supported by the \fIClarion\fR database format are implemented yet (due to lack of test databases using these types of data); see the source code for details. Please report bugs to \fBjb@jblache.org\fR; if possible, please send patches as the set of test databases I have is \fBvery\fR limited. .SH AUTHOR \fBcldump\fR was written by Julien BLACHE . .SH HOMEPAGE http://www.technologeek.org/projects/cldump/ cldump-0.11~dfsg/src/cl_meta.c0000664000175000017500000001612311474155530015670 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006,2010 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_meta.c 65 2010-11-27 10:20:08Z julien $ */ #include #include #include #include #include #include #include "cldump.h" int clarion_read_header (ClarionHandle *cl) { ClarionHeader *clh; FILE *fp = cl->data; clh = (ClarionHeader *) malloc(sizeof(ClarionHeader)); if (clh == NULL) return -1; fread(&clh->filesig, 2, 1, fp); if (clh->filesig != CL_DATA_FILE_SIG) { free(clh); fprintf(stderr, "Invalid data file !\n"); return -1; } fread(&clh->sfatr, 2, 1, fp); fread(&clh->numbkeys, 1, 1, fp); fread(&clh->numrecs, 4, 1, fp); fread(&clh->numdels, 4, 1, fp); fread(&clh->numflds, 2, 1, fp); fread(&clh->numpics, 2, 1, fp); fread(&clh->numarrs, 2, 1, fp); fread(&clh->reclen, 2, 1, fp); fread(&clh->offset, 4, 1, fp); fread(&clh->logeof, 4, 1, fp); fread(&clh->logbof, 4, 1, fp); fread(&clh->freerec, 4, 1, fp); fread(clh->recname, 1, 12, fp); clh->recname[12] = '\0'; fread(clh->memnam, 1, 12, fp); clh->memnam[12] = '\0'; fread(clh->filpre, 1, 3, fp); clh->filpre[3] = '\0'; fread(clh->recpre, 1, 3, fp); clh->recpre[3] = '\0'; fread(&clh->memolen, 2, 1, fp); fread(&clh->memowid, 2, 1, fp); fread(&clh->reserved, 4, 1, fp); fread(&clh->chgtime, 4, 1, fp); fread(&clh->chgdate, 4, 1, fp); fread(&clh->reserved2, 2, 1, fp); cl->clm.clh = clh; return 0; } int clarion_read_field_desc(ClarionHandle *cl) { int i; int numflds = cl->clm.clh->numflds; FILE *fp = cl->data; ClarionFieldDesc *clfd; if (numflds == 0) return 0; clfd = (ClarionFieldDesc *) malloc(numflds * sizeof(ClarionFieldDesc)); if (clfd == NULL) return -1; for (i = 0; i < numflds; i++) { fread(&clfd[i].fldtype, 1, 1, fp); fread(&clfd[i].fldname, 1, 16, fp); clfd[i].fldname[16] = '\0'; fread(&clfd[i].foffset, 2, 1, fp); fread(&clfd[i].length, 2, 1, fp); fread(&clfd[i].decsig, 1, 1, fp); fread(&clfd[i].decdec, 1, 1, fp); fread(&clfd[i].arrnum, 2, 1, fp); fread(&clfd[i].picnum, 2, 1, fp); clfd[i].arr = NULL; clfd[i].nbarrs = 0; } cl->clm.clfd = clfd; return 0; } int clarion_read_key_desc (ClarionHandle *cl) { int i, j, k; int l, r; int numbkeys = cl->clm.clh->numbkeys; int numparts; FILE *fp = cl->data; FILE *fk; ClarionKeyDesc *clk; ClarionKeyPart *subpart; ClarionFieldDesc *clfd; char *keyfile; if (numbkeys == 0) return 0; clk = (ClarionKeyDesc *) malloc(numbkeys * sizeof(ClarionKeyDesc)); if (clk == NULL) return -1; keyfile = strdup(cl->datfile); keyfile[strlen(keyfile) - 3] = 'K'; clfd = cl->clm.clfd; for (i = 0; i < numbkeys; i++) { fread(&clk[i].numcomps, 1, 1, fp); fread(&clk[i].keyname, 1, 16, fp); fread(&clk[i].comptype, 1, 1, fp); fread(&clk[i].complen, 1, 1, fp); /* Read the keytype from the key file */ l = (i + 1) / 16; r = (i + 1) % 16; keyfile[strlen(keyfile) - 2] = (l > 9) ? 'a' + (l - 10) : '0' + l; keyfile[strlen(keyfile) - 1] = (r > 9) ? 'a' + (r - 10) : '0' + r; fk = fopen(keyfile, "rb"); if (fk != NULL) { fseek(fk, 29, SEEK_SET); fread(&clk[i].keytype, 1, 1, fk); fclose(fk); } else { clk[i].keytype = CL_KEYTYPE_ERROR; fprintf(stderr, "Couldn't open key file %s !\n", keyfile); } /* Done */ clk[i].keypart = (ClarionKeyPart *) malloc(clk[i].numcomps * sizeof(ClarionKeyPart)); for (j = 0; j < clk[i].numcomps; j++) { fread(&clk[i].keypart[j].fldtype, 1, 1, fp); fread(&clk[i].keypart[j].fldnum, 2, 1, fp); fread(&clk[i].keypart[j].elmoff, 2, 1, fp); fread(&clk[i].keypart[j].elmlen, 1, 1, fp); /* * Collect subparts if this part of the key is * a field of type CL_FIELD_GROUP */ if (clk[i].keypart[j].fldtype == CL_FIELD_GROUP) { numparts = clfd[clk[i].keypart[j].fldnum - 1].length; clk[i].keypart[j].numparts = numparts; subpart = (ClarionKeyPart *) malloc(numparts * sizeof(ClarionKeyPart)); clk[i].keypart[j].subpart = subpart; for (k = 0; k < numparts; k++) { subpart[k].fldnum = clk[i].keypart[j].fldnum + 1 + k; subpart[k].fldtype = clfd[subpart[k].fldnum - 1].fldtype; subpart[k].elmoff = clfd[subpart[k].fldnum - 1].foffset; subpart[k].elmlen = clfd[subpart[k].fldnum - 1].length; subpart[k].numparts = 0; subpart[k].subpart = NULL; } } else { clk[i].keypart[j].numparts = 0; clk[i].keypart[j].subpart = NULL; } } } cl->clm.clk = clk; free(keyfile); return 0; } int clarion_read_pic_desc (ClarionHandle *cl) { int i; int numpics = cl->clm.clh->numpics; FILE *fp = cl->data; ClarionPicDesc *clp; if (numpics == 0) return 0; clp = (ClarionPicDesc *) malloc(numpics * sizeof(ClarionPicDesc)); if (clp == NULL) return -1; for (i = 0; i < numpics; i++) { fread(&clp[i].piclen, 2, 1, fp); clp[i].picstr = (uint8_t *) malloc(clp[i].piclen + 1); fread(clp[i].picstr, 1, clp[i].piclen, fp); clp[i].picstr[clp[i].piclen] = '\0'; } cl->clm.clp = clp; return 0; } void clarion_read_arr_desc (ClarionHandle *cl) { int i, j, k; int numflds = cl->clm.clh->numflds; unsigned long offset = cl->clm.clh->offset; FILE *fp = cl->data; ClarionFieldDesc *clfd = cl->clm.clfd; uint16_t numdim, totdim; for (i = 0; i < numflds; i++) { if (clfd[i].arrnum != 0) { j = 0; do { clfd[i].arr = (ClarionArrDesc *) realloc(clfd[i].arr, (j + 1) * sizeof(ClarionArrDesc)); fread(&clfd[i].arr[j].numdim, 2, 1, fp); fread(&clfd[i].arr[j].totdim, 2, 1, fp); fread(&clfd[i].arr[j].elmsiz, 2, 1, fp); clfd[i].arr[j].part = (ClarionArrPart *) malloc(clfd[i].arr[j].totdim * sizeof(ClarionArrPart)); for (k = 0; k < clfd[i].arr[j].totdim; k++) { fread(&clfd[i].arr[j].part[k].maxdim, 2, 1, fp); fread(&clfd[i].arr[j].part[k].lendim, 2, 1, fp); } if (ftell(fp) == offset) { clfd[i].nbarrs = j + 1; return; } fread(&numdim, 2, 1, fp); fread(&totdim, 2, 1, fp); fseek(fp, (ftell(fp) - 4), SEEK_SET); if (numdim != totdim) j++; else { clfd[i].nbarrs = j + 1; break; } } while (1); } } } cldump-0.11~dfsg/src/cldump.c0000664000175000017500000002504211474155533015553 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006,2010 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cldump.c 66 2010-11-27 10:20:11Z julien $ */ #include #include #include #include #include #include #include #include #include "cldump.h" int clarion_open_memo (ClarionHandle *cl) { FILE *fp; ClarionMemoHeader clmh; if (!(cl->clm.clh->sfatr & CL_MEMO_FILE_EXISTS)) return 0; cl->memfile = strdup(cl->datfile); cl->memfile[strlen(cl->memfile) - 1] = 'M'; cl->memfile[strlen(cl->memfile) - 2] = 'E'; cl->memfile[strlen(cl->memfile) - 3] = 'M'; fp = fopen(cl->memfile, "rb"); if ((fp == NULL) && (cl->clm.clh->sfatr & CL_MEMO_FILE_EXISTS)) { fprintf(stderr, "Error opening memo file (%s): %s\n", cl->memfile, strerror(errno)); free(cl->memfile); cl->memfile = NULL; return -1; } fread(&clmh.memsig, 2, 1, fp); fread(&clmh.firstdel, 4, 1, fp); if (clmh.memsig != CL_MEMO_FILE_SIG) { fclose(fp); fprintf(stderr, "Invalid memo file (%s) !", cl->memfile); free(cl->memfile); cl->memfile = NULL; return -1; } if (cl->opts & CL_OPT_DUMP_META) { fprintf(stderr, "===== MEMO FILE HEADER =====\n\n"); fprintf(stderr, "memsig : 0x%04x\n", clmh.memsig); fprintf(stderr, "firstdel : 0x%08x\n", clmh.firstdel); fprintf(stderr, "===== END OF MEMO FILE HEADER\n\n"); } fflush(stderr); cl->memo = fp; return 0; } void clarion_free_handle (ClarionHandle *cl) { int i, j; ClarionPicDesc *clp = cl->clm.clp; ClarionKeyDesc *clk = cl->clm.clk; ClarionFieldDesc *clfd = cl->clm.clfd; for (i = 0; i < cl->clm.clh->numbkeys; i++) { for (j = 0; j < clk[i].numcomps; j++) { if (clk[i].keypart[j].subpart != NULL) free(clk[i].keypart[j].subpart); } free(clk[i].keypart); } free(clk); if (cl->clm.clh->numpics > 0) { for (i = 0; i < cl->clm.clh->numpics; i++) { if (clp[i].picstr) free(clp[i].picstr); } free(clp); } for (i = 0; i < cl->clm.clh->numflds; i++) { if (clfd[i].arr != NULL) { for (j = 0; j < clfd[i].nbarrs; j++) { free(clfd[i].arr[j].part); } free(clfd[i].arr); } } free(clfd); free(cl->clm.clh); free(cl->datfile); if (cl->memfile != NULL) free(cl->memfile); if (cl->charset != NULL) free(cl->charset); } void cl_usage(void) { fprintf(stdout, "Usage:\n"); fprintf(stdout, " cldump [options] database.dat\n"); fprintf(stdout, "\n"); fprintf(stdout, "Options:\n"); fprintf(stdout, " -d/--dump-active Dump active entries only\n"); fprintf(stdout, "* -D/--dump-data Dump the actual data (active+deleted)\n"); fprintf(stdout, "* -m/--dump-meta Dump meta information\n"); fprintf(stdout, " -f/--field-separator Field separator for CSV output (1 character, defaults to ';')\n"); fprintf(stdout, " -c/--csv Dump data or schema in CSV format\n"); fprintf(stdout, " -S/--sql Dump data or schema in SQL format\n"); fprintf(stdout, "* -s/--schema Dump database schema\n"); fprintf(stdout, " -M/--mysql Use MySQL specific options (backticks, ...)\n"); fprintf(stdout, " -n/--no-memo Do not dump memo entries\n"); fprintf(stdout, " -U[charset] Convert strings from charset to UTF-8\n"); fprintf(stdout, " --utf8[=charset] Default charset: iso8859-1\n"); fprintf(stdout, " -x/--decrypt Decrypt database, key location 1-4\n"); fprintf(stdout, "\n"); fprintf(stdout, "By default, cldump uses a human-friendly format to dump the database.\n"); fprintf(stdout, "Options marked with a * are the default.\n"); } void cl_version(void) { fprintf(stdout, "cldump v%s - Clarion database extractor\n", CL_VERSION); fprintf(stdout, "Copyright (C) 2004-2006,2010 Julien BLACHE \n"); fprintf(stdout, "This software is released under the terms of the GNU General Public License\n"); fprintf(stdout, "version 2, as published by the Free Software Foundation.\n"); } int main (int argc, char **argv) { ClarionHandle cl; int cloptind; int clopt; int ret; static struct option clargs[] = { {"dump-active", 0, NULL, 'd'}, {"dump-data", 0, NULL, 'D'}, {"dump-meta", 0, NULL, 'm'}, {"field-separator", 1, NULL, 'f'}, {"csv", 0, NULL, 'c'}, {"sql", 0, NULL, 'S'}, {"schema", 0, NULL, 's'}, {"mysql", 0, NULL, 'M'}, {"no-memo", 0, NULL, 'n'}, {"utf8", 2, NULL, 'U'}, {"decrypt", 1, NULL, 'x'}, {"help", 0, NULL, 'h'}, {"version", 0, NULL, 'v'}, {NULL, 0, NULL, 0} }; memset(&cl, 0, sizeof(ClarionHandle)); /* Default CSV field separator */ cl.fsep = ';'; /* Default SQL quote characters */ cl.sql_quote_begin = '"'; cl.sql_quote_end = '"'; while ((clopt = getopt_long(argc, argv, "dDmf:cSsMnU::x:hv", clargs, &cloptind)) != -1) { switch (clopt) { case 'd': cl.opts |= CL_OPT_DUMP_ACTIVE; break; case 'D': cl.opts |= CL_OPT_DUMP_DATA; break; case 'm': cl.opts |= CL_OPT_DUMP_META; break; case 'f': if (strlen(optarg) > 1) { fprintf(stderr, "cldump: Error: only one character allowed as field separator.\n"); exit(1); } cl.fsep = *optarg; break; case 'c': if (cl.opts & CL_OPT_SQL_OUTPUT) { fprintf(stderr, "cldump: Error: SQL output (-S/--sql) already specified.\n"); exit(1); } cl.opts |= CL_OPT_CSV_OUTPUT; break; case 'S': if (cl.opts & CL_OPT_CSV_OUTPUT) { fprintf(stderr, "cldump: Error: CSV output (-c/--csv) already specified.\n"); exit(1); } cl.opts |= CL_OPT_SQL_OUTPUT; break; case 's': cl.opts |= CL_OPT_SCHEMA; break; case 'M': cl.sql_quote_end = '`'; cl.sql_quote_begin = '`'; break; case 'n': cl.opts |= CL_OPT_NO_MEMO; break; case 'U': cl.opts |= CL_OPT_UTF8; if (optarg != NULL) cl.charset = strdup(optarg); else cl.charset = strdup("ISO8859-1"); break; case 'x': cl.decmode = atoi(optarg); if ((cl.decmode < 1) || (cl.decmode > 4)) { fprintf(stderr, "cldump: Error: key location argument is 1-4.\n"); exit(1); } cl.opts |= CL_OPT_DECRYPT; break; case 'h': cl_version(); fprintf(stdout, "\n"); cl_usage(); exit(0); break; case 'v': cl_version(); exit(0); break; case ':': cl_version(); fprintf(stderr, "\ncldump: Error: missing parameter for option %s.\n\n", argv[optind]); cl_usage(); exit(2); break; default: cl_version(); fprintf(stderr, "\ncldump: Error: unrecognised option (%s), aborting.\n\n", argv[optind - 1]); cl_usage(); exit(2); break; } } /* No options specified on the command line */ if (cl.opts == 0) cl.opts = CL_OPT_DEFAULT; /* Force data dump if only output modifiers have been specified */ if (!(cl.opts & CL_OPT_DUMP_ACTIVE) && !(cl.opts & CL_OPT_DUMP_DATA)) { if ((cl.opts & CL_OPT_NO_MEMO) || (cl.opts & CL_OPT_CSV_OUTPUT) || (cl.opts & CL_OPT_SQL_OUTPUT)) { if (!(cl.opts & CL_OPT_DUMP_META) && !(cl.opts & CL_OPT_SCHEMA)) cl.opts |= CL_OPT_DUMP_DATA; } } if (optind >= argc) { cl_version(); fprintf(stderr, "\ncldump: Error: no filename specified.\n\n"); cl_usage(); exit(3); } cl.data = fopen(argv[optind], "rb"); if (cl.data == NULL) { fprintf(stderr, "Couldn't open file %s !\n", argv[optind]); exit(1); } cl.datfile = strdup(argv[optind]); ret = clarion_read_header(&cl); if (ret != 0) { fclose (cl.data); fprintf(stderr, "Couldn't read header !\n"); exit(2); } if (cl.clm.clh->sfatr & CL_RECORDS_ENCRYPTED) { if (cl.opts & CL_OPT_DECRYPT) { clarion_decrypt_all(&cl); /* NOT REACHED */ exit(42); } else { fprintf(stderr, "Database is encrypted, make backups and re-run with -x\n"); exit(1); } } else if (cl.opts & CL_OPT_DECRYPT) { fprintf(stderr, "Database is not encrypted; re-run without -x\n"); exit(0); } if (!(cl.opts & CL_OPT_NO_MEMO)) { ret = clarion_open_memo(&cl); if (ret != 0) { free(cl.clm.clh); fclose(cl.data); fprintf(stderr, "Couldn't open memo file !\n"); exit(3); } } ret = clarion_read_field_desc(&cl); if (ret != 0) { free(cl.clm.clh); fclose(cl.data); if (cl.memo != NULL) fclose(cl.memo); fprintf(stderr, "Couldn't read field descriptors !\n"); exit(4); } ret = clarion_read_key_desc(&cl); if (ret != 0) { free(cl.clm.clh); free(cl.clm.clfd); fclose(cl.data); if (cl.memo != NULL) fclose(cl.memo); fprintf(stderr, "Couldn't read key descriptors !\n"); exit(5); } ret = clarion_read_pic_desc(&cl); if (ret != 0) { fclose(cl.data); if (cl.memo != NULL) fclose(cl.memo); clarion_free_handle(&cl); fprintf(stderr, "Couldn't read picture descriptors !\n"); exit(6); } clarion_read_arr_desc(&cl); if (cl.opts & CL_OPT_DUMP_META) { clarion_dump_meta(&cl); } if (cl.opts & CL_OPT_SCHEMA) { if (cl.opts & CL_OPT_CSV_OUTPUT) clarion_dump_schema_csv(&cl); else if (cl.opts & CL_OPT_SQL_OUTPUT) clarion_dump_schema_sql(&cl); else clarion_dump_schema(&cl); } if ((cl.opts & CL_OPT_DUMP_DATA) || (cl.opts & CL_OPT_DUMP_ACTIVE)) { if (cl.opts & CL_OPT_CSV_OUTPUT) clarion_dump_data_csv(&cl); else if (cl.opts & CL_OPT_SQL_OUTPUT) clarion_dump_data_sql(&cl); else clarion_dump_data(&cl); } fclose(cl.data); if (cl.memo != NULL) fclose(cl.memo); clarion_free_handle(&cl); return 0; } cldump-0.11~dfsg/src/cl_dump_meta_csv.c0000664000175000017500000000371311474155537017600 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_meta_csv.c 68 2010-11-27 10:20:15Z julien $ */ #include #include #include #include #include #include #include "cldump.h" static void clarion_dump_field_desc_csv(ClarionHandle *cl) { int i; uint8_t buf[17]; uint8_t *pbuf; ClarionFieldDesc *clfd; clfd = cl->clm.clfd; for (i = 0; i < cl->clm.clh->numflds; i++) { /* * A field with type CL_FIELD_GROUP is a pseudo-field * used to indicate that the next clfd[i].length fields * are grouped together. */ if (clfd[i].fldtype == CL_FIELD_GROUP) { continue; } if (i > 0) fprintf(stdout, "%c", cl->fsep); memcpy(buf, clfd[i].fldname, 17); clarion_trim(buf, 16); pbuf = (uint8_t *)strchr((char *)buf, ':'); fprintf(stdout, "%s", (pbuf != NULL) ? ++pbuf : buf); } if ((cl->clm.clh->sfatr & CL_MEMO_FILE_EXISTS) && (!(cl->opts & CL_OPT_NO_MEMO))) { fprintf(stdout, "%cMEMO", cl->fsep); } fprintf(stdout, "\n"); fflush(stdout); } void clarion_dump_schema_csv (ClarionHandle *cl) { clarion_dump_field_desc_csv(cl); } cldump-0.11~dfsg/src/cl_dump_field.c0000664000175000017500000001224211474155540017051 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * Copyright (C) 2006 Alasdair Craig * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_field.c 69 2010-11-27 10:20:16Z julien $ */ #include #include #include #include #include #include #include "cldump.h" void clarion_dump_memo_entry (ClarionRecordHeader *clrh, FILE *fp, char *plchold, char *charset) { ClarionMemoEntry clme; char *utf; uint32_t curblk; if ((clrh->rhd & CL_RECORD_DELETED) || (clrh->rptr == 0)) { if (plchold != NULL) fprintf(stdout, "%s", plchold); return; } fseek(fp, (((clrh->rptr - 1) * 256) + 6), SEEK_SET); curblk = clrh->rptr - 1; do { fread(&clme.nxtblk, 4, 1, fp); fread(&clme.memo, 1, 252, fp); clme.memo[252] = '\0'; if (clme.nxtblk == 0) clarion_trim(clme.memo, 252); if (charset != NULL) { utf = clarion_iconv(charset, (char *)clme.memo); if (utf != NULL) { fprintf(stdout, "%s", utf); free(utf); } else fprintf(stdout, "%s", clme.memo); } else fprintf(stdout, "%s", clme.memo); if (clme.nxtblk == 0) break; else if (clme.nxtblk == curblk) { fprintf(stderr, "Memo entry %08x looping back to itself\n", curblk); break; } fseek(fp, ((clme.nxtblk * 256) + 6), SEEK_SET); curblk = clme.nxtblk; } while (1); fflush(stdout); } void clarion_dump_field_long (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold) { uint32_t *lbuf = (uint32_t *) buf; fread(buf, clfd->length, 1, fp); /* Clear the starting uninitialized byte */ if ((*lbuf >> 24) & 0x80) *lbuf &= 0x00ffffff; fprintf(stdout, "%d", *lbuf); fflush(stdout); } void clarion_dump_field_real (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold) { double *dbuf = (double *) buf; uint8_t uninit[8]; fread(buf, clfd->length, 1, fp); /* Uninitialized: BO FF FF FF FF FF EF FF */ memset(uninit, 0xff, 8); #if BYTE_ORDER == BIG_ENDIAN uninit[7] = 0xb0; uninit[1] = 0xef; #else uninit[0] = 0xb0; uninit[6] = 0xef; #endif if (memcmp(uninit, buf, clfd->length) == 0) { if (plchold != NULL) fprintf(stdout, "%s", plchold); } else fprintf(stdout, "%*f", clfd->decdec, *dbuf); fflush(stdout); } void clarion_dump_field_string (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold, char *charset) { char *utf; fread(buf, 1, clfd->length, fp); buf[clfd->length] = '\0'; clarion_trim(buf, clfd->length); if (strlen((char *)buf) > 0) { if (charset != NULL) { utf = clarion_iconv(charset, (char *)buf); if (utf != NULL) { fprintf(stdout, "%s", utf); free(utf); } else fprintf(stdout, "%s", buf); } else fprintf(stdout, "%s", buf); } else if (plchold != NULL) fprintf(stdout, "%s", plchold); fflush(stdout); } void clarion_dump_field_byte (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold) { fread(buf, clfd->length, 1, fp); fprintf(stdout, "%d", *buf); fflush(stdout); } void clarion_dump_field_short (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold) { uint16_t *sbuf = (uint16_t *) buf; fread(buf, clfd->length, 1, fp); fprintf(stdout, "%d", *sbuf); fflush(stdout); } void clarion_dump_field_decimal (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold) { int i; int count; char *cbuf, *obuf; uint8_t mask; fread(buf, 1, clfd->length, fp); /* * BCD means two figures per byte * We eventually need to put a . somewhere * Not forgetting the '\0' */ cbuf = (char *) malloc(clfd->length * 2 + 2); /* Odd number of figures, strip the first nibble */ mask = (clfd->decsig % 2) ? 0x0f : 0xf0; i = 0; count = 0; while (i < clfd->length) { if (count == clfd->decsig - clfd->decdec) { cbuf[count] = '.'; count++; } if (mask == 0x0f) { cbuf[count] = (buf[i] & mask) + '0'; mask = 0xf0; i++; } else { cbuf[count] = (buf[i] >> 4) + '0'; mask = 0x0f; } count++; } cbuf[count] = '\0'; /* Strip the leading zeros */ for (obuf = cbuf; i < strlen(cbuf); obuf++) { if (*obuf != '0') break; } if (*obuf == '.') fprintf(stdout, "0%s", obuf); else { if (strlen(obuf) > 0) fprintf(stdout, "%s", obuf); else if (plchold != NULL) fprintf(stdout, "%s", plchold); } free(cbuf); fflush(stdout); } cldump-0.11~dfsg/src/cl_dump_data_csv.c0000664000175000017500000000566611474155530017565 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_data_csv.c 65 2010-11-27 10:20:08Z julien $ */ #include #include #include #include #include #include #include "cldump.h" void clarion_dump_data_csv (ClarionHandle *cl) { int nrecs, nflds; FILE *fp = cl->data; ClarionHeader *clh = cl->clm.clh; ClarionFieldDesc *clfd = cl->clm.clfd; ClarionRecordHeader clrh; uint8_t *buf; buf = (uint8_t *) malloc(clh->reclen * sizeof(uint8_t)); for (nrecs = 0; nrecs < clh->numrecs; nrecs++) { fread(&clrh.rhd, 1, 1, fp); fread(&clrh.rptr, 4, 1, fp); if ((clrh.rhd & CL_RECORD_DELETED) && (cl->opts & CL_OPT_DUMP_ACTIVE)) { fseek(cl->data, (clh->reclen - 5), SEEK_CUR); continue; } for (nflds = 0; nflds < clh->numflds; nflds++) { /* * A field with type CL_FIELD_GROUP is a pseudo-field * used to indicate that the next clfd[i].length fields * are grouped together. */ if (clfd[nflds].fldtype == CL_FIELD_GROUP) { continue; } if (nflds > 0) fprintf(stdout, "%c", cl->fsep); switch (clfd[nflds].fldtype) { case CL_FIELD_LONG: clarion_dump_field_long(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_REAL: clarion_dump_field_real(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_STRING: case CL_FIELD_STRING_PIC_TOK: clarion_dump_field_string(buf, &clfd[nflds], cl->data, NULL, cl->charset); break; case CL_FIELD_BYTE: clarion_dump_field_byte(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_SHORT: clarion_dump_field_short(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_DECIMAL: clarion_dump_field_decimal(buf, &clfd[nflds], cl->data, NULL); break; default: fprintf(stderr, "Unknown field type %d\n", clfd[nflds].fldtype); break; } } if ((clh->sfatr & CL_MEMO_FILE_EXISTS) && (!(cl->opts & CL_OPT_NO_MEMO))) { fprintf(stdout, "%c", cl->fsep); clarion_dump_memo_entry(&clrh, cl->memo, NULL, cl->charset); } fprintf(stdout, "\n"); fflush(stdout); } free(buf); } cldump-0.11~dfsg/src/cl_dump_meta_sql.c0000664000175000017500000001250411474155537017602 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_meta_sql.c 68 2010-11-27 10:20:15Z julien $ */ #include #include #include #include #include #include #include #include "cldump.h" static void clarion_dump_field_desc_sql(ClarionHandle *cl) { int i, j; uint8_t buf[17]; uint8_t *pbuf; ClarionFieldDesc *clfd; clfd = cl->clm.clfd; for (i = 0; i < cl->clm.clh->numflds; i++) { memcpy(buf, clfd[i].fldname, 17); clarion_trim(buf, 16); pbuf = (uint8_t *)strchr((char *)buf, ':'); if (pbuf != NULL) pbuf++; else pbuf = buf; for (j = 0; j < strlen((char *)pbuf); j++) { pbuf[j] = tolower(pbuf[j]); } /* * A field with type CL_FIELD_GROUP is a pseudo-field * used to indicate that the next clfd[i].length fields * are grouped together. */ if (clfd[i].fldtype == CL_FIELD_GROUP) { fprintf(stdout, "\n-- Next %d columns were part of group named '%s'", clfd[i].length, pbuf); continue; } fprintf(stdout, "\n %c%s%c ", cl->sql_quote_begin, pbuf, cl->sql_quote_end); switch(clfd[i].fldtype) { case CL_FIELD_LONG: fprintf(stdout, "BIGINT"); /* not really standard SQL, but industry standard */ break; case CL_FIELD_REAL: fprintf(stdout, "FLOAT"); /* should mean "double precision" to most RDBMS */ break; case CL_FIELD_STRING: case CL_FIELD_STRING_PIC_TOK: fprintf(stdout, "VARCHAR(%d)", clfd[i].length); break; case CL_FIELD_BYTE: fprintf(stdout, "SMALLINT"); break; case CL_FIELD_SHORT: fprintf(stdout, "SMALLINT"); break; case CL_FIELD_DECIMAL: fprintf(stdout, "NUMERIC(%d,%d)", clfd[i].decsig, clfd[i].decdec); break; default: fprintf(stderr, "Unknown field type %d for field %s !!\n", clfd[i].fldtype, buf); break; } if (i < cl->clm.clh->numflds - 1) fprintf(stdout, ","); } /* * FIXME: unimplemented * -> arrnum and picnum */ /* Memo field */ if ((cl->clm.clh->sfatr & CL_MEMO_FILE_EXISTS) && (!(cl->opts & CL_OPT_NO_MEMO))) { fprintf(stdout, ",\n %cmemo%c TEXT", cl->sql_quote_begin, cl->sql_quote_end); } fflush(stdout); } static void clarion_dump_key_desc_sql (ClarionHandle *cl, ClarionKeyDesc *clk, ClarionFieldDesc *clfd, uint8_t numbkeys, char *tbl) { int i, j, k, l; ClarionKeyPart *clkp; int numparts; uint8_t buf[17]; uint8_t *pbuf; fprintf(stdout, "\n"); for (i = 0; i < numbkeys; i++) { memcpy(buf, clk[i].keyname, 17); clarion_trim(buf, 16); pbuf = (uint8_t *)strchr((char *)buf, ':'); if (pbuf != NULL) pbuf++; else pbuf = buf; for (j = 0; j < strlen((char *)pbuf); j++) { pbuf[j] = tolower(pbuf[j]); } if (!(clk[i].keytype & CL_KEYTYPE_DUPSW)) { fprintf(stdout, "CREATE UNIQUE INDEX %c%s_%s%c ON %c%s%c (", cl->sql_quote_begin, tbl, pbuf, cl->sql_quote_end, cl->sql_quote_begin, tbl, cl->sql_quote_end); } else { fprintf(stdout, "CREATE INDEX %c%s_%s%c ON %c%s%c (", cl->sql_quote_begin, tbl, pbuf, cl->sql_quote_end, cl->sql_quote_begin, tbl, cl->sql_quote_end); } for (j = 0; j < clk[i].numcomps; j++) { if (clk[i].keypart[j].fldtype == CL_FIELD_GROUP) { clkp = clk[i].keypart[j].subpart; numparts = clk[i].keypart[j].numparts; } else { clkp = &clk[i].keypart[j]; numparts = 1; } for (k = 0; k < numparts; k++) { memcpy(buf, clfd[clkp[k].fldnum - 1].fldname, 17); clarion_trim(buf, 16); pbuf = (uint8_t *)strchr((char *)buf, ':'); if (pbuf != NULL) pbuf++; else pbuf = buf; for (l = 0; l < strlen((char *)pbuf); l++) { pbuf[l] = tolower(pbuf[l]); } if ((j > 0) || (k > 0)) fprintf(stdout, ", "); fprintf(stdout, "%c%s%c", cl->sql_quote_begin, pbuf, cl->sql_quote_end); } } fprintf(stdout, ");\n"); } fprintf(stdout, "\n"); fflush(stdout); } void clarion_dump_schema_sql (ClarionHandle *cl) { int i; char *buf, *pbuf; buf = strdup(cl->datfile); buf[strlen(buf) - 4] = '\0'; pbuf = strrchr(buf, '/'); if (pbuf != NULL) pbuf++; else pbuf = buf; for (i = 0; i < strlen(pbuf); i++) { pbuf[i] = tolower(pbuf[i]); } fprintf(stdout, "CREATE TABLE %c%s%c (", cl->sql_quote_begin, pbuf, cl->sql_quote_end); clarion_dump_field_desc_sql(cl); fprintf(stdout, "\n);\n"); clarion_dump_key_desc_sql(cl, cl->clm.clk, cl->clm.clfd, cl->clm.clh->numbkeys, pbuf); free(buf); } cldump-0.11~dfsg/src/cl_decrypt.c0000664000175000017500000002142211474155533016415 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2010 Julien BLACHE * * Decryption based on the Clarion.pm Perl module by * Stas Ukolov * Ilya Chelpanov * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ #include #include #include #include #include #include #include #include #include #include #include #include "cldump.h" static uint8_t key[2]; static int reopen_dat_sync(ClarionHandle *cl, long fpos, uint8_t *base, uint8_t *pos) { long lret; int ret; fclose(cl->data); cl->data = NULL; ret = msync(base, pos - base, MS_SYNC | MS_INVALIDATE); if (ret != 0) { fprintf(stderr, "msync failed: %s\n", strerror(errno)); return -1; } cl->data = fopen(cl->datfile, "rb"); if (!cl->data) { fprintf(stderr, "Failed to reopen data file: %s\n", strerror(errno)); return -1; } lret = fseek(cl->data, fpos, SEEK_SET); if (lret < 0) { fprintf(stderr, "Failed to seek: %s\n", strerror(errno)); return -1; } return 0; } static void clarion_decrypt(uint8_t *buf, int len) { int i; /* 2-byte blocks, remainder byte left as is */ for (i = 0; i < (len & ~1); i += 2) { buf[i] = buf[i] ^ key[0]; buf[i + 1] = buf[i + 1] ^ key[1]; } } static void clarion_get_key(ClarionHeader *clh, int mode) { uint32_t hidden; switch (mode) { case CL_KEY_NUMDELS_HI: hidden = clh->numdels; key[0] = hidden >> 24; key[1] = (hidden >> 16) & 0xff; break; case CL_KEY_RESERVED_HI: hidden = clh->reserved; key[0] = hidden >> 24; key[1] = (hidden >> 16) & 0xff; break; case CL_KEY_RESERVED_LO: hidden = clh->reserved; key[0] = (hidden >> 8) & 0xff; key[1] = hidden & 0xff; break; case CL_KEY_RESERVED_MID: hidden = clh->reserved; key[0] = (hidden >> 8) & 0xff; key[1] = (hidden >> 16) & 0xff; break; } } static int clarion_decrypt_header(ClarionHandle *cl, uint8_t *base) { int ret; clarion_decrypt(base + 4, 81); /* Re-read header */ ret = reopen_dat_sync(cl, 0, base, base + 85); if (ret < 0) return -1; free(cl->clm.clh); cl->clm.clh = NULL; ret = clarion_read_header(cl); if (ret != 0) { fprintf(stderr, "Could not re-read header after decryption\n"); return -1; } return 0; } static int clarion_decrypt_schema(ClarionHandle *cl, uint8_t *base) { ClarionFieldDesc *clfd; uint8_t *pos; long fpos; int numcomps; int numdim; int totdim; int piclen; int i; int j; int ret; /* field desc */ fpos = ftell(cl->data); if (fpos < 0) return -1; pos = base + fpos; for (i = 0; i < cl->clm.clh->numflds; i++) { clarion_decrypt(pos, 27); pos += 27; } ret = reopen_dat_sync(cl, fpos, base, pos); if (ret < 0) return -1; ret = clarion_read_field_desc(cl); if (ret != 0) { fprintf(stderr, "Could not read field descriptors after decryption\n"); return -1; } clfd = cl->clm.clfd; /* key desc */ fpos = ftell(cl->data); if (fpos < 0) return -1; pos = base + fpos; for (i = 0; i < cl->clm.clh->numbkeys; i++) { clarion_decrypt(pos, 19); /* Get the number of components */ numcomps = pos[0]; pos += 19; for (j = 0; j < numcomps; j++) { clarion_decrypt(pos, 6); pos += 6; } /* We'd decrypt Kxx files here if we needed them */ } ret = reopen_dat_sync(cl, fpos, base, pos); if (ret < 0) return -1; ret = clarion_read_key_desc(cl); if (ret != 0) { fprintf(stderr, "Could not read key descriptors after decryption\n"); return -1; } /* pic desc */ fpos = ftell(cl->data); if (fpos < 0) return -1; pos = base + fpos; for (i = 0; i < cl->clm.clh->numpics; i++) { piclen = (pos[1] << 8) | pos[0]; clarion_decrypt(pos + 2, piclen); pos += 2 + piclen; } ret = reopen_dat_sync(cl, fpos, base, pos); if (ret < 0) return -1; clarion_read_pic_desc(cl); if (ret != 0) { fprintf(stderr, "Could not read picture descriptors after decryption\n"); return -1; } /* arr desc - UNTESTED */ fpos = ftell(cl->data); if (fpos < 0) return -1; pos = base + fpos; for (i = 0; i < cl->clm.clh->numflds; i++) { if (clfd[i].arrnum == 0) continue; while ((pos - base) < cl->clm.clh->offset) { clarion_decrypt(pos, 6); numdim = (pos[1] << 8) | pos[0]; totdim = (pos[3] << 8) | pos[2]; pos += 6; clarion_decrypt(pos, totdim * 4); pos += totdim * 4; } } ret = reopen_dat_sync(cl, fpos, base, pos); if (ret < 0) return -1; clarion_read_arr_desc(cl); return 0; } static int clarion_decrypt_data(ClarionHandle *cl, uint8_t *base, off_t size) { ClarionHeader *clh; uint8_t *pos; long fpos; int i; clh = cl->clm.clh; fpos = ftell(cl->data); if (fpos < 0) return -1; if (fpos > clh->offset) { fprintf(stderr, "Error: starting data decryption past start of data (%lx / %x)\n", fpos, clh->offset); exit(1); } pos = base + fpos; for (i = 0; i < clh->numrecs; i++) { if (pos + clh->reclen > base + size) { fprintf(stderr, "EOF reached for DAT file\n"); break; } clarion_decrypt(pos + 5, clh->reclen - 5); pos += clh->reclen; } return 0; } static int clarion_decrypt_memo(ClarionHandle *cl) { struct stat st; uint8_t *pos; void *mapbase; int fd; int ret; fd = open(cl->memfile, O_RDWR); if (fd < 0) { fprintf(stderr, "Could not open %s: %s\n", cl->memfile, strerror(errno)); return -1; } ret = fstat(fd, &st); if (ret < 0) { fprintf(stderr, "fstat failed: %s\n", strerror(errno)); close(fd); return -1; } mapbase = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (mapbase == MAP_FAILED) { fprintf(stderr, "mmap failed: %s\n", strerror(errno)); close(fd); return -1; } pos = (uint8_t *)mapbase; /* Skip file header */ pos += 6; while ((pos - (uint8_t *)mapbase) < st.st_size) { if (pos + 256 > (uint8_t *)mapbase + st.st_size) { fprintf(stderr, "EOF reached for MEM file\n"); break; } clarion_decrypt(pos + 4, 252); pos += 256; } munmap(mapbase, st.st_size); close(fd); return 0; } void clarion_decrypt_all(ClarionHandle *cl) { struct stat st; ClarionHeader *clh; void *mapbase; int fd; int ret; clh = cl->clm.clh; fd = open(cl->datfile, O_RDWR); if (fd < 0) { fprintf(stderr, "Could not open %s: %s\n", cl->datfile, strerror(errno)); exit(1); } ret = fstat(fd, &st); if (ret < 0) { fprintf(stderr, "fstat failed: %s\n", strerror(errno)); close(fd); exit(1); } mapbase = mmap(NULL, st.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (mapbase == MAP_FAILED) { fprintf(stderr, "mmap failed: %s\n", strerror(errno)); close(fd); exit(1); } /* Clear encrypted and owned flag */ clh->sfatr &= ~(CL_FILE_OWNED | CL_RECORDS_ENCRYPTED); clh->sfatr = htole16(clh->sfatr); memcpy(mapbase + 2, &clh->sfatr, 2); clarion_get_key(clh, cl->decmode); ret = clarion_decrypt_header(cl, (uint8_t *)mapbase); if (ret < 0) goto cleanup; ret = clarion_decrypt_schema(cl, (uint8_t *)mapbase); if (ret < 0) goto cleanup; ret = clarion_decrypt_data(cl, (uint8_t *)mapbase, st.st_size); if (ret < 0) goto cleanup; if (cl->clm.clh->sfatr & CL_MEMO_FILE_EXISTS) { ret = clarion_open_memo(cl); if (ret < 0) goto cleanup; ret = clarion_decrypt_memo(cl); if (ret < 0) goto cleanup; } ret = 0; cleanup: munmap(mapbase, st.st_size); close(fd); if (cl->memo) fclose(cl->memo); if (cl->data) fclose(cl->data); if (ret == 0) { clarion_free_handle(cl); exit(0); } else { if (cl->clm.clk) clarion_free_handle(cl); else { if (cl->clm.clh) free(cl->clm.clh); if (cl->clm.clfd) free(cl->clm.clfd); } exit(1); } } cldump-0.11~dfsg/src/cl_dump_meta.c0000664000175000017500000002333511474155530016720 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006,2010 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_meta.c 65 2010-11-27 10:20:08Z julien $ */ #include #include #include #include #include #include #include "cldump.h" static void clarion_dump_header (ClarionHeader *clh) { int i; int tmp, val, year, day; char *sfatr[8] = { "FILE LOCKED", "FILE OWNED", "RECORDS ENCRYPTED", "MEMO FILE EXISTS", "FILE COMPRESSED", "RECLAIM DELETED RECORDS", "READ ONLY", "MAY BE CREATED" }; int days_in_month[12] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; fprintf(stderr, "===== FILE HEADER FOLLOWS =====\n"); fprintf(stderr, "filesig : 0x%04x\n", clh->filesig); fprintf(stderr, "sfatr : 0x%04x\n", clh->sfatr); fprintf(stderr, "\tAttributes set:"); if (clh->sfatr & 0x00ff) { for (i = 0; i < 8; i++) { if ((clh->sfatr >> i) & 0x0001) fprintf(stderr, " [%s]", sfatr[i]); } } else { fprintf(stderr, " NONE"); } fprintf(stderr, "\n"); fprintf(stderr, "numbkeys : 0x%02x\n", clh->numbkeys); fprintf(stderr, "numrecs : 0x%08x\n", clh->numrecs); fprintf(stderr, "numdels : 0x%08x\n", clh->numdels); fprintf(stderr, "numflds : 0x%04x\n", clh->numflds); fprintf(stderr, "numpics : 0x%04x\n", clh->numpics); fprintf(stderr, "numarrs : 0x%04x\n", clh->numarrs); fprintf(stderr, "reclen : 0x%04x\n", clh->reclen); fprintf(stderr, "offset : 0x%08x\n", clh->offset); fprintf(stderr, "logeof : 0x%08x\n", clh->logeof); fprintf(stderr, "logbof : 0x%08x\n", clh->logbof); fprintf(stderr, "freerec : 0x%08x\n", clh->freerec); fprintf(stderr, "recname : [%s]", clh->recname); for (i = 0; i < 12; i++) { fprintf(stderr, " 0x%02x", clh->recname[i]); } fprintf(stderr, "\n"); fprintf(stderr, "memnam : [%s]", clh->memnam); for (i = 0; i < 12; i++) { fprintf(stderr, " 0x%02x", clh->memnam[i]); } fprintf(stderr, "\n"); fprintf(stderr, "filpre : [%s] ", clh->filpre); fprintf(stderr, "0x%02x 0x%02x 0x%02x\n", clh->filpre[0], clh->filpre[1], clh->filpre[2]); fprintf(stderr, "recpre : [%s] ", clh->recpre); fprintf(stderr, "0x%02x 0x%02x 0x%02x\n", clh->recpre[0], clh->recpre[1], clh->recpre[2]); fprintf(stderr, "memolen : 0x%04x\n", clh->memolen); fprintf(stderr, "memowid : 0x%04x\n", clh->memowid); fprintf(stderr, "reserved : 0x%08x\n", clh->reserved); fprintf(stderr, "chgtime : 0x%08x [", clh->chgtime); if ((clh->chgtime < 1) || (clh->chgtime > 8640000)) { fprintf(stderr, "INVALID"); } else { tmp = (clh -> chgtime - 1); val = tmp / 360000; fprintf(stderr, "%02d:", val); tmp = clh->chgtime % 360000; val = tmp / 6000; fprintf(stderr, "%02d:", val); tmp = tmp % 6000; val = tmp / 100; fprintf(stderr, "%02d.%02d", val, (tmp % 100)); } fprintf(stderr, "]\n"); fprintf(stderr, "chgdate : 0x%08x [", clh->chgdate); if ((clh->chgdate <= 3) || (clh->chgdate > 109211)) { fprintf(stderr, "INVALID"); } else { tmp = (clh->chgdate > 36527) ? (clh->chgdate - 3) : (clh->chgdate - 4); year = (1801 + (4 * (tmp / 1461))); tmp = tmp % 1461; if (tmp != 1460) { year += (tmp / 365); day = tmp % 365; } else { year += 3; day = 365; } year += (year < 100) ? 1900 : 0; if ((year % 4 == 0) && (year != 1900)) days_in_month[1] = 29; for (i = 0; i < 12; i++) { day -= days_in_month[i]; if (day < 0) { day += days_in_month[i] + 1; break; } } fprintf(stderr, "%d-%02d-%02d", year, (i + 1), day); } fprintf(stderr, "]\n"); fprintf(stderr, "reserved2: 0x%04x\n", clh->reserved2); fprintf(stderr, "===== END OF FILE HEADER =====\n\n"); fflush(stderr); } static void clarion_dump_pic_desc (ClarionPicDesc *clpd) { int i; fprintf(stderr, " === PICTURE DESCRIPTOR ===\n\n"); fprintf(stderr, "\tpiclen : 0x%04x\n", clpd->piclen); fprintf(stderr, "\tpicstr : [%s]", clpd->picstr); for (i = 0; i < clpd->piclen; i++) { fprintf(stderr, " 0x%02x", clpd->picstr[i]); } fprintf(stderr, "\n"); fflush(stderr); } static void clarion_dump_arr_desc (ClarionArrDesc *clad, int nbarrs) { int i, j; for (i = 0; i < nbarrs; i++) { fprintf(stderr, " === ARRAY DESCRIPTOR %d ===\n", (i + 1)); fprintf(stderr, "\tnumdim : 0x%04x\n", clad[i].numdim); fprintf(stderr, "\ttotdim : 0x%04x\n", clad[i].totdim); fprintf(stderr, "\telmsiz : 0x%04x\n", clad[i].elmsiz); for (j = 0; j < clad[i].totdim; j++) { fprintf(stderr, " === ARRAY PART %d ===\n", (j + 1)); fprintf(stderr, "\tmaxdim : 0x%04x\n", clad[i].part[j].maxdim); fprintf(stderr, "\tlendim : 0x%04x\n", clad[i].part[j].lendim); } } fflush(stderr); } static void clarion_dump_field_desc(ClarionFieldDesc *clfd, uint16_t numflds, ClarionPicDesc *clpd) { int i, j; char *fldtype[9] = { "*** UNDEFINED ***", "LONG", "REAL", "STRING", "STRING WITH PICTURE TOKEN", "BYTE", "SHORT", "GROUP", "DECIMAL" }; fprintf(stderr, "===== FIELD DESCRIPTORS FOLLOW =====\n\n"); for (i = 0; i < numflds; i++) { fprintf(stderr, "fldtype : 0x%02x (%s)\n", clfd[i].fldtype, fldtype[clfd[i].fldtype]); fprintf(stderr, "fldname : [%s]", clfd[i].fldname); for (j = 0; j < 16; j++) { fprintf(stderr, " 0x%02x", clfd[i].fldname[j]); } fprintf(stderr, "\n"); fprintf(stderr, "foffset : 0x%04x\n", clfd[i].foffset); fprintf(stderr, "length : 0x%04x\n", clfd[i].length); fprintf(stderr, "decsig : 0x%02x\n", clfd[i].decsig); fprintf(stderr, "decdec : 0x%02x\n", clfd[i].decdec); fprintf(stderr, "arrnum : 0x%04x (%d)\n", clfd[i].arrnum, clfd[i].nbarrs); if (clfd[i].nbarrs > 0) clarion_dump_arr_desc(clfd[i].arr, clfd[i].nbarrs); fprintf(stderr, "picnum : 0x%04x\n", clfd[i].picnum); if (clfd[i].picnum != 0) clarion_dump_pic_desc(clpd + (clfd[i].picnum - 1)); fprintf(stderr, "\n"); } fprintf(stderr, "===== END OF FIELD DESCRIPTORS =====\n\n"); fflush(stderr); } static void clarion_dump_key_desc (ClarionKeyDesc *clk, ClarionFieldDesc *clfd, uint8_t numbkeys) { int i, j, k; char *fldtype[9] = { "*** UNDEFINED ***", "LONG", "REAL", "STRING", "STRING WITH PICTURE TOKEN", "BYTE", "SHORT", "GROUP", "DECIMAL" }; fprintf(stderr, "===== KEY DESCRIPTORS FOLLOW =====\n\n"); for (i = 0; i < numbkeys; i++) { fprintf(stderr, "numcomps : 0x%02x\n", clk[i].numcomps); fprintf(stderr, "keyname : [%s]", clk[i].keyname); for (j = 0; j < 16; j++) { fprintf(stderr, " 0x%02x", clk[i].keyname[j]); } fprintf(stderr, "\n"); fprintf(stderr, "comptype : 0x%02x\n", clk[i].comptype); fprintf(stderr, "complen : 0x%02x\n", clk[i].complen); /* Key type from the key file */ fprintf(stderr, "keytyp : 0x%02x (", clk[i].keytype); if (clk[i].keytype != CL_KEYTYPE_ERROR) { if ((clk[i].keytype & 0x0f) == 1) fprintf(stderr, "[INDEX]"); else fprintf(stderr, "[KEY]"); if (clk[i].keytype & CL_KEYTYPE_DUPSW) fprintf(stderr, " [DUPLICATES]"); if (clk[i].keytype & CL_KEYTYPE_UPRSW) fprintf(stderr, " [UPPERCASE]"); if (clk[i].keytype & CL_KEYTYPE_OPTSW) fprintf(stderr, " [PADDED]"); if (clk[i].keytype & CL_KEYTYPE_LOKSW) fprintf(stderr, " [LOCKED]"); } else fprintf(stderr, "[ERROR]"); fprintf(stderr, ")\n"); /* Done */ for (j = 0; j < clk[i].numcomps; j++) { fprintf(stderr, " === KEYPART %d ===\n", (j+1)); fprintf(stderr, "\tfldtype : 0x%02x (%s)\n", clk[i].keypart[j].fldtype, fldtype[clk[i].keypart[j].fldtype]); fprintf(stderr, "\tfldnum : 0x%04x ([%s])\n", clk[i].keypart[j].fldnum, clfd[clk[i].keypart[j].fldnum - 1].fldname); fprintf(stderr, "\telmoff : 0x%04x\n", clk[i].keypart[j].elmoff); fprintf(stderr, "\telmlen : 0x%02x\n", clk[i].keypart[j].elmlen); for (k = 0; k < clk[i].keypart[j].numparts; k++) { fprintf(stderr, " === SUBPART %d ===\n", (k+1)); fprintf(stderr, "\t\tfldtype : 0x%02x (%s)\n", clk[i].keypart[j].subpart[k].fldtype, fldtype[clk[i].keypart[j].subpart[k].fldtype]); fprintf(stderr, "\t\tfldnum : 0x%04x ([%s])\n", clk[i].keypart[j].subpart[k].fldnum, clfd[clk[i].keypart[j].subpart[k].fldnum - 1].fldname); fprintf(stderr, "\t\telmoff : 0x%04x\n", clk[i].keypart[j].subpart[k].elmoff); fprintf(stderr, "\t\telmlen : 0x%02x\n", clk[i].keypart[j].subpart[k].elmlen); } } fprintf(stderr, "\n"); } fprintf(stderr, "===== END OF KEY DESCRIPTORS =====\n\n"); fflush(stderr); } void clarion_dump_meta (ClarionHandle *cl) { clarion_dump_header(cl->clm.clh); } void clarion_dump_schema (ClarionHandle *cl) { clarion_dump_field_desc(cl->clm.clfd, cl->clm.clh->numflds, cl->clm.clp); clarion_dump_key_desc(cl->clm.clk, cl->clm.clfd, cl->clm.clh->numbkeys); } cldump-0.11~dfsg/src/cldump.h0000664000175000017500000001671411474155542015566 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006,2010 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cldump.h 70 2010-11-27 10:20:18Z julien $ */ #ifndef __CLDUMP_H__ #define __CLDUMP_H__ #define CL_VERSION "0.11" /* File signatures */ #define CL_DATA_FILE_SIG 0x3343 #define CL_MEMO_FILE_SIG 0x334D /* ClarionHeader.sfatr values (bitmask) */ #define CL_FILE_LOCKED (1 << 0) #define CL_FILE_OWNED (1 << 1) #define CL_RECORDS_ENCRYPTED (1 << 2) #define CL_MEMO_FILE_EXISTS (1 << 3) #define CL_FILE_COMPRESSED (1 << 4) #define CL_RECLAIM_DELETED (1 << 5) #define CL_READ_ONLY (1 << 6) #define CL_MAY_BE_CREATED (1 << 7) /* Field types */ #define CL_FIELD_LONG 1 #define CL_FIELD_REAL 2 #define CL_FIELD_STRING 3 #define CL_FIELD_STRING_PIC_TOK 4 #define CL_FIELD_BYTE 5 #define CL_FIELD_SHORT 6 #define CL_FIELD_GROUP 7 #define CL_FIELD_DECIMAL 8 /* Record types values (bitmask) */ #define CL_RECORD_NEW (1 << 0) #define CL_RECORD_OLD (1 << 1) #define CL_RECORD_REVISED (1 << 2) #define CL_RECORD_DELETED (1 << 4) #define CL_RECORD_HELD (1 << 6) /* Key types values */ #define CL_KEYTYPE_ERROR 0xff /* not part of the Clarion spec */ /* The following apply to the LSB */ #define CL_KEYTYPE_KEY 0 #define CL_KEYTYPE_INDEX 1 /* The following apply to the MSB (bitmask) */ #define CL_KEYTYPE_DUPSW (1 << 0) /* duplicates */ #define CL_KEYTYPE_UPRSW (1 << 1) /* uppercase */ #define CL_KEYTYPE_OPTSW (1 << 2) /* padding (with spaces) */ #define CL_KEYTYPE_LOKSW (1 << 3) /* locked */ /* Command-line options */ #define CL_OPT_DUMP_ACTIVE (1 << 0) /* dump active records only */ #define CL_OPT_DUMP_DATA (1 << 1) /* dump actual data (all records, regardless of their status) */ #define CL_OPT_DUMP_META (1 << 2) /* dump meta information only */ #define CL_OPT_CSV_OUTPUT (1 << 3) /* output data in CSV format */ #define CL_OPT_SQL_OUTPUT (1 << 4) /* output data in SQL format */ #define CL_OPT_SCHEMA (1 << 5) /* output schema; combined with previous option, output SQL schema */ #define CL_OPT_NO_MEMO (1 << 6) /* do not output memo entries */ #define CL_OPT_UTF8 (1 << 7) /* convert strings to UTF-8 */ #define CL_OPT_DECRYPT (1 << 8) #define CL_OPT_DEFAULT (CL_OPT_DUMP_DATA | CL_OPT_DUMP_META | CL_OPT_SCHEMA) /* default: dump everything */ /* Encryption key location */ #define CL_KEY_NUMDELS_HI 1 #define CL_KEY_RESERVED_HI 2 #define CL_KEY_RESERVED_LO 3 #define CL_KEY_RESERVED_MID 4 typedef struct { uint16_t filesig; uint16_t sfatr; uint8_t numbkeys; uint32_t numrecs; uint32_t numdels; uint16_t numflds; uint16_t numpics; uint16_t numarrs; uint16_t reclen; uint32_t offset; uint32_t logeof; uint32_t logbof; uint32_t freerec; uint8_t recname[12+1]; uint8_t memnam[12+1]; uint8_t filpre[3+1]; uint8_t recpre[3+1]; uint16_t memolen; uint16_t memowid; uint32_t reserved; uint32_t chgtime; uint32_t chgdate; uint16_t reserved2; } ClarionHeader; typedef struct { uint16_t piclen; uint8_t *picstr; } ClarionPicDesc; typedef struct { uint16_t maxdim; uint16_t lendim; } ClarionArrPart; typedef struct { uint16_t numdim; uint16_t totdim; uint16_t elmsiz; ClarionArrPart *part; } ClarionArrDesc; typedef struct { uint8_t fldtype; uint8_t fldname[16+1]; uint16_t foffset; uint16_t length; uint8_t decsig; uint8_t decdec; uint16_t arrnum; uint16_t picnum; ClarionArrDesc *arr; int nbarrs; /* this is not part of the Clarion database format */ } ClarionFieldDesc; typedef struct cl_key_part { uint8_t fldtype; uint16_t fldnum; uint16_t elmoff; uint8_t elmlen; uint16_t numparts; /* the next 2 fields are not part of the Clarion database format */ struct cl_key_part *subpart; } ClarionKeyPart; typedef struct { uint8_t numcomps; uint8_t keyname[16+1]; uint8_t comptype; uint8_t complen; ClarionKeyPart *keypart; uint8_t keytype; /* stored in the key file header */ } ClarionKeyDesc; typedef struct { ClarionHeader *clh; ClarionFieldDesc *clfd; ClarionPicDesc *clp; ClarionKeyDesc *clk; } ClarionMeta; typedef struct { unsigned short opts; unsigned char decmode; unsigned char fsep; unsigned char sql_quote_begin; unsigned char sql_quote_end; ClarionMeta clm; char *datfile; FILE *data; char *memfile; FILE *memo; char *charset; } ClarionHandle; typedef struct { uint8_t rhd; uint32_t rptr; } ClarionRecordHeader; typedef struct { uint16_t memsig; uint32_t firstdel; } ClarionMemoHeader; typedef struct { uint32_t nxtblk; uint8_t memo[252+1]; } ClarionMemoEntry; /* In cldump.c */ void clarion_free_handle (ClarionHandle *cl); int clarion_open_memo (ClarionHandle *cl); /* In cl_decrypt.c */ void clarion_decrypt_all(ClarionHandle *cl); /* In cl_utils.c */ #if BYTE_ORDER == BIG_ENDIAN size_t cl_fread (void *ptr, size_t size, size_t nmemb, FILE *stream); #define fread cl_fread #endif void clarion_trim (uint8_t *data, int length); void clarion_singlespace (char *data); char * clarion_iconv (const char *charset, char *data); /* In cl_meta.c */ int clarion_read_header (ClarionHandle *cl); int clarion_read_field_desc(ClarionHandle *cl); int clarion_read_key_desc (ClarionHandle *cl); int clarion_read_pic_desc (ClarionHandle *cl); void clarion_read_arr_desc (ClarionHandle *cl); /* In cl_dump_meta.c */ void clarion_dump_meta (ClarionHandle *cl); void clarion_dump_schema (ClarionHandle *cl); /* In cl_dump_meta_sql.c */ void clarion_dump_schema_sql (ClarionHandle *cl); /* In cl_dump_meta_csv.c */ void clarion_dump_schema_csv (ClarionHandle *cl); /* In cl_dump_field.c */ void clarion_dump_memo_entry (ClarionRecordHeader *clrh, FILE *fp, char *plchold, char *charset); void clarion_dump_field_long (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold); void clarion_dump_field_real (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold); void clarion_dump_field_string (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold, char *charset); void clarion_dump_field_byte (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold); void clarion_dump_field_short (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold); void clarion_dump_field_decimal (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *plchold); /* In cl_dump_data.c */ void clarion_dump_data (ClarionHandle *cl); /* In cl_dump_data_csv.c */ void clarion_dump_data_csv (ClarionHandle *cl); /* In cl_dump_data_sql.c */ void clarion_dump_data_sql (ClarionHandle *cl); #endif /* !__CLDUMP_H__ */ cldump-0.11~dfsg/src/cl_dump_data_sql.c0000664000175000017500000001333511474155537017570 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_data_sql.c 68 2010-11-27 10:20:15Z julien $ */ #include #include #include #include #include #include #include #include "cldump.h" static void clarion_dump_field_string_sql (uint8_t *buf, ClarionFieldDesc *clfd, FILE *fp, char *charset) { char *utf; fread(buf, 1, clfd->length, fp); buf[clfd->length] = '\0'; clarion_trim(buf, clfd->length); if (strlen((char *)buf) > 0) { if (charset != NULL) { utf = clarion_iconv(charset, (char *)buf); if (utf != NULL) { fprintf(stdout, "'%s'", utf); free(utf); } else fprintf(stdout, "'%s'", buf); } else fprintf(stdout, "'%s'", buf); } else fprintf(stdout, "NULL"); fflush(stdout); } static void clarion_dump_memo_entry_sql (ClarionRecordHeader *clrh, FILE *fp, char *charset) { int i, j; ClarionMemoEntry clme; char buf[512]; char *utf; if ((clrh->rhd & CL_RECORD_DELETED) || (clrh->rptr == 0)) { fprintf(stdout, "NULL"); return; } fseek(fp, (((clrh->rptr - 1) * 256) + 6), SEEK_SET); fprintf(stdout, "'"); do { memset(buf, 0, 512); fread(&clme.nxtblk, 4, 1, fp); fread(&clme.memo, 1, 252, fp); clme.memo[252] = '\0'; if (clme.nxtblk == 0) { clarion_trim(clme.memo, 252); clarion_singlespace((char *)clme.memo); /* Sanitize the \r\n mess */ for (i = 0, j = 0; clme.memo[i] != '\0'; i++, j++) { switch(clme.memo[i]) { case '\n': buf[j++] = '\\'; buf[j] = 'n'; break; case '\r': j--; break; case '\'': buf[j++] = '\''; buf[j] = '\''; break; default: buf[j] = clme.memo[i]; } } } if (strlen(buf) > 0) { if (charset != NULL) { utf = clarion_iconv(charset, buf); if (utf != NULL) { fprintf(stdout, "%s", utf); free(utf); } else fprintf(stdout, "%s", buf); } else fprintf(stdout, "%s", buf); } if (clme.nxtblk == 0) break; else fseek(fp, ((clme.nxtblk * 256) + 6), SEEK_SET); } while (1); fprintf(stdout, "'"); fflush(stdout); } void clarion_dump_data_sql (ClarionHandle *cl) { int i; int nrecs, nflds; FILE *fp = cl->data; ClarionHeader *clh = cl->clm.clh; ClarionFieldDesc *clfd = cl->clm.clfd; ClarionRecordHeader clrh; uint8_t *buf; char *cbuf, *tblname; char *rhd[8] = { "NEW RECORD", "OLD RECORD", "REVISED RECORD", "*** UNDEFINED (3) ***", "DELETED RECORD", "*** UNDEFINED (5) ***", "RECORD HELD", "*** UNDEFINED (7) ***" }; buf = (uint8_t *) malloc(clh->reclen * sizeof(uint8_t)); cbuf = strdup(cl->datfile); cbuf[strlen(cbuf) - 4] = '\0'; tblname = strrchr(cbuf, '/'); if (tblname != NULL) tblname++; else tblname = cbuf; for (i = 0; i < strlen(tblname); i++) { tblname[i] = tolower(tblname[i]); } for (nrecs = 0; nrecs < clh->numrecs; nrecs++) { fread(&clrh.rhd, 1, 1, fp); fread(&clrh.rptr, 4, 1, fp); if (clrh.rhd & CL_RECORD_DELETED) { if (cl->opts & CL_OPT_DUMP_ACTIVE) { fseek(cl->data, (clh->reclen - 5), SEEK_CUR); continue; } else { fprintf(stdout, "-- Record attributes:"); for (i = 0; i < 8; i++) { if ((clrh.rhd >> i) & 0x01) fprintf(stdout, " [%s]", rhd[i]); } fprintf(stdout, "\n"); } } fprintf(stdout, "INSERT INTO %c%s%c VALUES(", cl->sql_quote_begin, tblname, cl->sql_quote_end); for (nflds = 0; nflds < clh->numflds; nflds++) { /* * A field with type CL_FIELD_GROUP is a pseudo-field * used to indicate that the next clfd[i].length fields * are grouped together. */ if (clfd[nflds].fldtype == CL_FIELD_GROUP) { continue; } switch (clfd[nflds].fldtype) { case CL_FIELD_LONG: clarion_dump_field_long(buf, &clfd[nflds], cl->data, "NULL"); break; case CL_FIELD_REAL: clarion_dump_field_real(buf, &clfd[nflds], cl->data, "NULL"); break; case CL_FIELD_STRING: case CL_FIELD_STRING_PIC_TOK: clarion_dump_field_string_sql(buf, &clfd[nflds], cl->data, cl->charset); break; case CL_FIELD_BYTE: clarion_dump_field_byte(buf, &clfd[nflds], cl->data, "NULL"); break; case CL_FIELD_SHORT: clarion_dump_field_short(buf, &clfd[nflds], cl->data, "NULL"); break; case CL_FIELD_DECIMAL: clarion_dump_field_decimal(buf, &clfd[nflds], cl->data, "NULL"); break; default: fprintf(stderr, "Unknown field type %d\n", clfd[nflds].fldtype); break; } if (nflds < clh->numflds - 1) fprintf(stdout, ", "); } if ((clh->sfatr & CL_MEMO_FILE_EXISTS) && (!(cl->opts & CL_OPT_NO_MEMO))) { fprintf(stdout, ", "); clarion_dump_memo_entry_sql(&clrh, cl->memo, cl->charset); } fprintf(stdout, ");\n"); fflush(stdout); } free(buf); } cldump-0.11~dfsg/src/cl_dump_data.c0000664000175000017500000000731711474155530016705 0ustar julienjulien/* * cldump - Dumps Clarion databases to text, SQL and CSV formats * * Copyright (C) 2004-2006 Julien BLACHE * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: cl_dump_data.c 65 2010-11-27 10:20:08Z julien $ */ #include #include #include #include #include #include #include "cldump.h" void clarion_dump_data (ClarionHandle *cl) { int i; int nrecs, nflds; FILE *fp = cl->data; ClarionHeader *clh = cl->clm.clh; ClarionFieldDesc *clfd = cl->clm.clfd; ClarionRecordHeader clrh; uint8_t *buf; char *rhd[8] = { "NEW RECORD", "OLD RECORD", "REVISED RECORD", "*** UNDEFINED (3) ***", "DELETED RECORD", "*** UNDEFINED (5) ***", "RECORD HELD", "*** UNDEFINED (7) ***" }; buf = (uint8_t *) malloc(clh->reclen * sizeof(uint8_t)); for (nrecs = 0; nrecs < clh->numrecs; nrecs++) { fread(&clrh.rhd, 1, 1, fp); fread(&clrh.rptr, 4, 1, fp); if ((clrh.rhd & CL_RECORD_DELETED) && (cl->opts & CL_OPT_DUMP_ACTIVE)) { fseek(cl->data, (clh->reclen - 5), SEEK_CUR); continue; } fprintf(stderr, "=== RECORD %d:\n", (nrecs + 1)); fprintf(stderr, "rhd : 0x%02x\n", clrh.rhd); fprintf(stderr, "\tAttributes set:"); if (clrh.rhd) { for (i = 0; i < 8; i++) { if ((clrh.rhd >> i) & 0x01) fprintf(stderr, " [%s]", rhd[i]); } } else { fprintf(stderr, " NONE"); } fprintf(stderr, "\n"); fprintf(stderr, "rptr : 0x%08x\n", clrh.rptr); fprintf(stderr, "\n"); fflush(stderr); fprintf(stdout, "=== RECORD %d:\n", (nrecs + 1)); for (nflds = 0; nflds < clh->numflds; nflds++) { /* * A field with type CL_FIELD_GROUP is a pseudo-field * used to indicate that the next clfd[i].length fields * are grouped together. */ if (clfd[nflds].fldtype == CL_FIELD_GROUP) { continue; } fprintf(stdout, "%8s : ", (clfd[nflds].fldname + 4)); switch (clfd[nflds].fldtype) { case CL_FIELD_LONG: clarion_dump_field_long(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_REAL: clarion_dump_field_real(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_STRING: case CL_FIELD_STRING_PIC_TOK: clarion_dump_field_string(buf, &clfd[nflds], cl->data, NULL, cl->charset); break; case CL_FIELD_BYTE: clarion_dump_field_byte(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_SHORT: clarion_dump_field_short(buf, &clfd[nflds], cl->data, NULL); break; case CL_FIELD_DECIMAL: clarion_dump_field_decimal(buf, &clfd[nflds], cl->data, NULL); break; default: fprintf(stderr, "Unknown field type %d\n", clfd[nflds].fldtype); break; } fprintf(stdout, "\n"); } if ((clh->sfatr & CL_MEMO_FILE_EXISTS) && (!(cl->opts & CL_OPT_NO_MEMO))) { fprintf(stdout, "MEMO ENTRY : "); clarion_dump_memo_entry(&clrh, cl->memo, NULL, cl->charset); fprintf(stdout, "\n"); } fprintf(stdout, "\n"); fflush(stdout); } free(buf); } cldump-0.11~dfsg/src/Makefile0000664000175000017500000000057611474155533015570 0ustar julienjulien# # $Id: Makefile 66 2010-11-27 10:20:11Z julien $ # CFLAGS = -Wall -g -O2 OBJS = cldump.o cl_utils.o \ cl_meta.o \ cl_dump_meta.o cl_dump_meta_csv.o cl_dump_meta_sql.o \ cl_dump_data.o cl_dump_data_csv.o cl_dump_data_sql.o \ cl_dump_field.o cl_decrypt.o all: cldump cldump: $(OBJS) $(CC) $(CFLAGS) -o cldump $(OBJS) %.c %.o: %.c cldump.h clean: rm -f $(OBJS) cldump *~ cldump-0.11~dfsg/COPYING0000664000175000017500000004311010143465022014350 0ustar julienjulien GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) year name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. cldump-0.11~dfsg/README0000664000175000017500000000157310143465022014204 0ustar julienjulienREADME for cldump ----------------- cldump - dumps Clarion databases to text, SQL and CSV formats Clarion is a Windows IDE like Delphi or others, and has its own (simple) database format. This utility can dump these databases to text, SQL and CSV formats. See the manpage (man 1 cldump, src/cldump.1) for more information. To build the utility, go to src and type make. In the doc directory you'll find some technical bulletins from Clarion which I found on the web when I wrote cldump. They're not a complete documentation of the database format and contain errors and omissions; they're a good starting point to understand the file format, but you'll be on your own for anything advanced. cldump is released under the terms of the GNU General Public License, version 2 of the license as published by the Free Software Foundation. -- Julien BLACHE , 2004-11-07 cldump-0.11~dfsg/CREDITS0000664000175000017500000000042710502775473014356 0ustar julienjulienCREDITS for cldump ------------------ Alasdair Craig contributed the support for the byte, short, long and real datatypes suggested to quote SQL identifiers to avoid clashes with reserved words helped properly supporting the group type