dattypes.cc Source File (libkmid Library)

| # libkmid Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# dattypes.cc

    00001 /**************************************************************************
    00002
    00003     dattypes.cc  - Some always useful definitions and functions
    00004     This file is part of LibKMid 0.9.5
    00005     Copyright (C) 1997,98,99,2000  Antonio Larrosa Jimenez
    00006     LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
    00007
    00008     This library is free software; you can redistribute it and/or
    00009     modify it under the terms of the GNU Library General Public
    00010     License as published by the Free Software Foundation; either
    00011     version 2 of the License, or (at your option) any later version.
    00012
    00013     This library is distributed in the hope that it will be useful,
    00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00016     Library General Public License for more details.
    00017
    00018     You should have received a copy of the GNU Library General Public License
    00019     along with this library; see the file COPYING.LIB.  If not, write to
    00020     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00021     Boston, MA 02111-1307, USA.
    00022
    00023     Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
    00024
    00025 ***************************************************************************/
    00026 #include "dattypes.h"
    00027 #include <stdio.h>
    00028
    00029 ushort readShort(FILE *fh)
    00030 {
    00031   uchar c1;
    00032   uchar c2;
    00033
    00034   fread(&c1,1,1,fh);
    00035   fread(&c2,1,1,fh);
    00036   return (c1<<8)|c2;
    00037 }
    00038
    00039 ulong readLong(FILE *fh)
    00040 {
    00041   uchar c1;
    00042   uchar c2;
    00043   uchar c3;
    00044   uchar c4;
    00045   ulong l;
    00046
    00047   fread(&c1,1,1,fh);
    00048   fread(&c2,1,1,fh);
    00049   fread(&c3,1,1,fh);
    00050   fread(&c4,1,1,fh);
    00051   l=((c1<<24)|(c2<<16)|(c3<<8)|c4);
    00052   return l;
    00053 }
    00054
    00055 #ifdef DEBUG
    00056
    00057 void printfdebug(const char *format, int a, int b, int c)
    00058 {
    00059   char *s=(char *)format;
    00060   int i=0;
    00061   while (*s!=0)
    00062   {
    00063     if (*s=='%') i++;
    00064     s++;
    00065   }
    00066   switch (i)
    00067   {
    00068     case (1) : fprintf(stderr,format,a); break;
    00069     case (2) : fprintf(stderr,format,a,b); break;
    00070     case (3) : fprintf(stderr,format,a,b,c); break;
    00071     default : fprintf(stderr,format); break;
    00072   }
    00073
    00074 }
    00075
    00076 void printfdebug(const char *format, int a, long b)
    00077 {
    00078   fprintf(stderr,format,a,b);
    00079 }
    00080
    00081 void printfdebug(const char *format, double a, double b, double c)
    00082 {
    00083   char *s=(char *)format;
    00084   int i=0;
    00085   while (*s!=0)
    00086   {
    00087     if (*s=='%') i++;
    00088     s++;
    00089   }
    00090   switch (i)
    00091   {
    00092     case (1) : fprintf(stderr,format,a); break;
    00093     case (2) : fprintf(stderr,format,a,b); break;
    00094     case (3) : fprintf(stderr,format,a,b,c); break;
    00095     default : fprintf(stderr,format); break;
    00096   }
    00097
    00098 }
    00099 #else
    00100
    00101 void printfdebug(const char *, int , int , int )
    00102 {
    00103 }
    00104 void printfdebug(const char *, int , long )
    00105 {
    00106 }
    00107 void printfdebug(const char *, double , double , double )
    00108 {
    00109 }
    00110 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:28:28 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001