static Rlist *GetSQLTables(CfdbConn *cfdb) { Rlist *list = NULL; char query[CF_MAXVARSIZE]; ListTables(cfdb->type, query); CfNewQueryDB(cfdb, query); if (cfdb->maxcolumns != 1) { CfOut(cf_error, "", "Could not make sense of the columns"); CfDeleteQuery(cfdb); return NULL; } while (CfFetchRow(cfdb)) { PrependRScalar(&list, CfFetchColumn(cfdb, 0), CF_SCALAR); } CfDeleteQuery(cfdb); return list; }
static Rlist *GetSQLTables(CfdbConn *cfdb) { Rlist *list = NULL; char query[CF_MAXVARSIZE]; ListTables(cfdb->type, query); CfNewQueryDB(cfdb, query); if (cfdb->maxcolumns != 1) { Log(LOG_LEVEL_ERR, "Could not make sense of the columns"); CfDeleteQuery(cfdb); return NULL; } while (CfFetchRow(cfdb)) { RlistPrepend(&list, CfFetchColumn(cfdb, 0), RVAL_TYPE_SCALAR); } CfDeleteQuery(cfdb); return list; }
int main ( int argc, char *argv[]) { int Status; if (argc < 2) { DisplayUsage (); return (0); } if (argv[1][0] == '-') { if (argc < 3) { DisplayUsage (); return (0); } switch (argv[1][1]) { case 'a': /* Extract all tables found */ return (ExtractTables (argv[2], NULL, 0)); case 'l': /* List tables only, do not extract */ return (ListTables (argv[2])); case 's': /* Extract only tables with this signature */ return (ExtractTables (argv[2], &argv[1][2], 1)); default: DisplayUsage (); return (0); } } /* * Default output is the DSDT and all SSDTs. One DSDT is required, * any SSDTs are optional. */ Status = ExtractTables (argv[1], "DSDT", 1); if (Status) { return (Status); } Status = ExtractTables (argv[1], "SSDT", 0); return (Status); }