1 // This may look like C code, but it is really -*- C++ -*-
2
3 // ------------------------------------------------------------------
4 // The Goldware Library
5 // Copyright (C) 1990-1999 Odinn Sorensen
6 // Copyright (C) 1999-2000 Alexander S. Aganichev
7 // ------------------------------------------------------------------
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this program; if not, write to the Free
20 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 // MA 02111-1307, USA
22 // ------------------------------------------------------------------
23 // $Id: gutlmisc.h,v 1.5 2005/10/31 22:18:26 ssianky Exp $
24 // ------------------------------------------------------------------
25 // Utility functions.
26 // ------------------------------------------------------------------
27
28 #ifndef __gutlmisc_h
29 #define __gutlmisc_h
30
31
32 // ------------------------------------------------------------------
33
34 #include <gdefs.h>
35 #include <gctype.h>
36 #include <cstdlib>
37
38
39 // ------------------------------------------------------------------
40 // Prototypes
41
42 uint32_t atoulx(const char* s);
43
atow(const char * p)44 inline word atow(const char* p) { return (word)atoi(p); }
xtoi(char c)45 inline int xtoi(char c) { return isdigit(c) ? (c - '0') : (g_toupper(c) - ('A' - 10)); }
atox(const char * s)46 inline int atox(const char* s) { return (int)atoulx(s); }
47
48 char* ltob(char* dst, uint32_t value, int fill=32);
49
50 int GetYesno(const char* value);
51 int Pct(uint32_t x, uint32_t y);
52 int tabstop(int col, int tabwidth);
53
54 char* ggetosstring();
55
56 // Convert between Microsoft MKS format and long int
57 dword B2L(dword b);
58 dword L2B(dword l);
59
SwapWord32(uint32_t * dw)60 inline void SwapWord32(uint32_t* dw) { *dw = ((*dw) << 16) | ((*dw) >> 16); }
61
62
63 // ------------------------------------------------------------------
64
65 #endif
66
67 // ------------------------------------------------------------------
68
69