printtab.c

Go to the documentation of this file.
00001 #include <string.h>
00002 #include "dbmi.h"
00003 
00004 static void print_priv();
00005 
00012 void
00013 db_print_table_definition(fd,table)
00014     FILE *fd;
00015     dbTable *table;
00016 {
00017     int ncols, col;
00018     dbColumn *column;
00019 
00020     fprintf (fd, "table:%s\n", db_get_table_name(table));
00021     fprintf (fd, "description:%s\n", db_get_table_description(table));
00022     print_priv (fd, "insert", db_get_table_insert_priv(table));
00023     print_priv (fd, "delete", db_get_table_delete_priv(table));
00024 
00025     ncols = db_get_table_number_of_columns(table);
00026     fprintf (fd, "ncols:%d\n", ncols);
00027     for (col = 0; col < ncols; col++)
00028     {
00029         column = db_get_table_column (table, col);
00030         fprintf (fd, "\n");
00031         db_print_column_definition (fd, column);
00032     }
00033 }
00034 
00035 void
00036 db_print_column_definition(fd, column)
00037     FILE *fd;
00038     dbColumn *column;
00039 {
00040     dbString value_string;
00041 
00042     fprintf (fd, "column:%s\n", db_get_column_name(column));
00043     fprintf (fd, "description:%s\n", db_get_column_description(column));
00044     fprintf (fd, "type:%s\n", db_sqltype_name(db_get_column_sqltype(column)));
00045     fprintf (fd, "len:%d\n", db_get_column_length(column));
00046     fprintf (fd, "scale:%d\n", db_get_column_scale(column));
00047     fprintf (fd, "precision:%d\n", db_get_column_precision(column));
00048     fprintf (fd, "default:");
00049     if (db_test_column_has_default_value(column))
00050     {
00051       db_init_string(&value_string);
00052       db_convert_column_default_value_to_string (column, &value_string);
00053       fprintf (fd, "%s", db_get_string(&value_string));
00054     }
00055     fprintf (fd, "\n");
00056     fprintf (fd, "nullok:%s\n", db_test_column_null_allowed(column) ? "yes" : "no");
00057     print_priv (fd, "select", db_get_column_select_priv(column));
00058     print_priv (fd, "update", db_get_column_update_priv(column));
00059 }
00060 
00061 static void
00062 print_priv (fd, label, priv)
00063     FILE *fd;
00064     char *label;
00065     int priv;
00066 {
00067     fprintf (fd, "%s:", label);
00068     switch (priv)
00069     {
00070     case DB_GRANTED:     fprintf (fd, "yes"); break;
00071     case DB_NOT_GRANTED: fprintf (fd, "no"); break;
00072     default:             fprintf (fd, "?"); break;
00073     }
00074     fprintf (fd, "\n");
00075 }

Generated on Mon Jan 1 19:49:04 2007 for GRASS by  doxygen 1.5.1