From: nishi Date: Sun, 26 May 2024 10:21:30 +0000 (+0000) Subject: list fields X-Git-Url: http://10.10.0.4:5575/?a=commitdiff_plain;h=3d1970aad7534def2680bd5952698bd4fb131568;p=dataworks.git list fields git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@118 d4a5a174-5a4a-5b4b-b672-37683c10d7d5 --- diff --git a/Client/main.c b/Client/main.c index 1e7af73..c78c28c 100644 --- a/Client/main.c +++ b/Client/main.c @@ -215,7 +215,22 @@ int main(int argc, char** argv) { ; printf("%d table(s) found.\n", i); for(i = 0; list[i] != NULL; i++) { - printf(" %s\n", list[i]); + printf(" %s: ", list[i]); + fflush(stdout); + char** fields = dataworks_database_get_table_fields(db, list[i]); + if(fields != NULL) { + int j; + for(j = 0; fields[j] != NULL; j++) { + printf("%s ", fields[j]); + fflush(stdout); + free(fields[j]); + } + free(fields); + } else { + printf("(failed to get)"); + fflush(stdout); + } + printf("\n"); free(list[i]); } free(list); diff --git a/Library/database_table.c b/Library/database_table.c index eb69d4e..c1815ac 100644 --- a/Library/database_table.c +++ b/Library/database_table.c @@ -172,7 +172,7 @@ char** dataworks_database_get_table_fields(struct dataworks_db* db, const char* for(j = 1;; j++) { if(index.fields[j] == 0) { char* nam = malloc(j - start + 1); - nam[start - j] = 0; + nam[j - start] = 0; memcpy(nam, index.fields + start, j - start); int k; for(k = 0; list[k] != NULL; k++)