| 994 | } |
| 995 | |
| 996 | static void print_column(FILE *f, cdb2_hndl_tp *hndl, int col) |
| 997 | { |
| 998 | void *val; |
| 999 | |
| 1000 | assert((printmode & DISP_TABULAR) == 0); |
| 1001 | |
| 1002 | val = cdb2_column_value(hndl, col); |
| 1003 | |
| 1004 | if (val == NULL) { |
| 1005 | if (printmode & DISP_COLTYPE) { |
| 1006 | fprintf(f, "NULL "); |
| 1007 | } |
| 1008 | |
| 1009 | if (printmode & DISP_CLASSIC) { |
| 1010 | fprintf(f, "%s=NULL", cdb2_column_name(hndl, col)); |
| 1011 | } else { |
| 1012 | fprintf(f, "NULL"); |
| 1013 | } |
| 1014 | return; |
| 1015 | } |
| 1016 | |
| 1017 | int type = cdb2_column_type(hndl, col); |
| 1018 | std::string typeStr; |
| 1019 | |
| 1020 | if (printmode & DISP_COLTYPE) { |
| 1021 | if (type >= MIN_COL_TYPE_NAME && type <= MAX_COL_TYPE_NAME) { |
| 1022 | typeStr = col_type_names[type]; |
| 1023 | typeStr.push_back(' '); |
| 1024 | } else { |
| 1025 | typeStr = "UNKNOWN "; |
| 1026 | } |
| 1027 | } else { |
| 1028 | typeStr = ""; |
| 1029 | } |
| 1030 | |
| 1031 | switch (type) { |
| 1032 | case CDB2_INTEGER: |
| 1033 | if (printmode & DISP_CLASSIC) |
| 1034 | fprintf(f, "%s%s=%lld", typeStr.c_str(), cdb2_column_name(hndl, col), |
| 1035 | *(long long *)val); |
| 1036 | else |
| 1037 | fprintf(f, "%s%lld", typeStr.c_str(), *(long long *)val); |
| 1038 | break; |
| 1039 | case CDB2_REAL: |
| 1040 | fprintf(f, "%s", typeStr.c_str()); |
| 1041 | if (printmode & DISP_CLASSIC) |
| 1042 | fprintf(f, "%s=", cdb2_column_name(hndl, col)); |
| 1043 | fprintf(f, doublefmt, *(double *)val); |
| 1044 | break; |
| 1045 | case CDB2_CSTRING: |
| 1046 | if (printmode & DISP_CLASSIC) { |
| 1047 | fprintf(f, "%s%s=", typeStr.c_str(), cdb2_column_name(hndl, col)); |
| 1048 | dumpstring(f, (char *)val, 1, 0); |
| 1049 | } else if (printmode & DISP_TABS) { |
| 1050 | fprintf(f, "%s", typeStr.c_str()); |
| 1051 | dumpstring(f, (char *)val, 0, 0); |
| 1052 | } else { |
| 1053 | fprintf(f, "%s", typeStr.c_str()); |
no test coverage detected