home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 January / Chip_2001-01_cd1.bin / tema / mysql / mysql-3.23.28g-win-source.exe / isam / _dbug.c < prev    next >
C/C++ Source or Header  |  2000-08-31  |  4KB  |  133 lines

  1. /* Copyright (C) 2000 MySQL AB & MySQL Finland AB & TCX DataKonsult AB
  2.    
  3.    This program is free software; you can redistribute it and/or modify
  4.    it under the terms of the GNU General Public License as published by
  5.    the Free Software Foundation; either version 2 of the License, or
  6.    (at your option) any later version.
  7.    
  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.
  12.    
  13.    You should have received a copy of the GNU General Public License
  14.    along with this program; if not, write to the Free Software
  15.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  16.  
  17. /* Support rutiner with are using with dbug */
  18.  
  19. #include "isamdef.h"
  20.  
  21.     /* Print a key in user understandable format */
  22.  
  23. void _nisam_print_key(FILE *stream, register N_KEYSEG *keyseg, const uchar *key)
  24. {
  25.   int flag;
  26.   short int s_1;
  27.   long    int l_1;
  28.   float f_1;
  29.   double d_1;
  30.   uchar *end;
  31.  
  32.   VOID(fputs("Key: \"",stream));
  33.   flag=0;
  34.   for (; keyseg->base.type ;keyseg++)
  35.   {
  36.     if (flag++)
  37.       VOID(putc('-',stream));
  38.     end= (uchar*) key+ keyseg->base.length;
  39.     switch (keyseg->base.type) {
  40.     case HA_KEYTYPE_BINARY:
  41.       if (!(keyseg->base.flag & HA_SPACE_PACK) && keyseg->base.length == 1)
  42.       {                        /* packed binary digit */
  43.     VOID(fprintf(stream,"%d",(uint) *key++));
  44.     break;
  45.       }
  46.       /* fall through */
  47.     case HA_KEYTYPE_TEXT:
  48.     case HA_KEYTYPE_NUM:
  49.       if (keyseg->base.flag & HA_SPACE_PACK)
  50.       {
  51.     VOID(fprintf(stream,"%.*s",(int) *key,key+1));
  52.     key+= (int) *key+1;
  53.       }
  54.       else
  55.       {
  56.     VOID(fprintf(stream,"%.*s",(int) keyseg->base.length,key));
  57.     key=end;
  58.       }
  59.       break;
  60.     case HA_KEYTYPE_INT8:
  61.       VOID(fprintf(stream,"%d",(int) *((signed char*) key)));
  62.       key=end;
  63.       break;
  64.     case HA_KEYTYPE_SHORT_INT:
  65.       shortget(s_1,key);
  66.       VOID(fprintf(stream,"%d",(int) s_1));
  67.       key=end;
  68.       break;
  69.     case HA_KEYTYPE_USHORT_INT:
  70.       {
  71.     ushort u_1;
  72.     ushortget(u_1,key);
  73.     VOID(fprintf(stream,"%u",(uint) u_1));
  74.     key=end;
  75.     break;
  76.       }
  77.     case HA_KEYTYPE_LONG_INT:
  78.       longget(l_1,key);
  79.       VOID(fprintf(stream,"%ld",l_1));
  80.       key=end;
  81.       break;
  82.     case HA_KEYTYPE_ULONG_INT:
  83.       longget(l_1,key);
  84.       VOID(fprintf(stream,"%lu",(ulong) l_1));
  85.       key=end;
  86.       break;
  87.     case HA_KEYTYPE_INT24:
  88.       VOID(fprintf(stream,"%d",sint3korr(key)));
  89.       key=end;
  90.       break;
  91.     case HA_KEYTYPE_UINT24:
  92.       VOID(fprintf(stream,"%ld",uint3korr(key)));
  93.       key=end;
  94.       break;
  95.     case HA_KEYTYPE_FLOAT:
  96.       bmove((byte*) &f_1,(byte*) key,(int) sizeof(float));
  97.       VOID(fprintf(stream,"%g",(double) f_1));
  98.       key=end;
  99.       break;
  100.     case HA_KEYTYPE_DOUBLE:
  101.       doubleget(d_1,key);
  102.       VOID(fprintf(stream,"%g",d_1));
  103.       key=end;
  104.       break;
  105. #ifdef HAVE_LONG_LONG
  106.     case HA_KEYTYPE_LONGLONG:
  107.     {
  108.       char buff[21];
  109.       longlong tmp;
  110.       longlongget(tmp,key);
  111.       longlong2str(tmp,buff,-10);
  112.       VOID(fprintf(stream,"%s",buff));
  113.       key=end;
  114.       break;
  115.     }
  116.     case HA_KEYTYPE_ULONGLONG:
  117.     {
  118.       char buff[21];
  119.       longlong tmp;
  120.       longlongget(tmp,key);
  121.       longlong2str(tmp,buff,10);
  122.       VOID(fprintf(stream,"%s",buff));
  123.       key=end;
  124.       break;
  125.     }
  126. #endif
  127.     default: break;            /* This never happens */
  128.     }
  129.   }
  130.   VOID(fputs("\n",stream));
  131.   return;
  132. } /* print_key */
  133.