]> Nishi Git Mirror - dataworks.git/commitdiff
list fields
authornishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sun, 26 May 2024 10:21:30 +0000 (10:21 +0000)
committernishi <nishi@d4a5a174-5a4a-5b4b-b672-37683c10d7d5>
Sun, 26 May 2024 10:21:30 +0000 (10:21 +0000)
git-svn-id: file:///raid/svn-main/nishi-dataworks/trunk@118 d4a5a174-5a4a-5b4b-b672-37683c10d7d5

Client/main.c
Library/database_table.c

index 1e7af73a2d10de292b5e3e43f0ebc0c8978f3ee3..c78c28cd5a461be4d6deda89b1da22190be22275 100644 (file)
@@ -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);
index eb69d4ed274a1639421340dc29f046c147504a81..c1815ac70cce1c4856e3a08f4ad0981589c81652 100644 (file)
@@ -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++)