Compiler warnings about misleading indentation removed.
[AROS-Contrib.git] / dopus / Library / strings.c
blobce5f68815cba86b0f92dc228ced5c2754e7b72ee
1 /*
3 Directory Opus 4
4 Original GPL release version 4.12
5 Copyright 1993-2000 Jonathan Potter
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 All users of Directory Opus 4 (including versions distributed
22 under the GPL) are entitled to upgrade to the latest version of
23 Directory Opus version 5 at a reduced price. Please see
24 http://www.gpsoft.com.au for more information.
26 The release of Directory Opus 4 under the GPL in NO WAY affects
27 the existing commercial status of Directory Opus 5.
31 #include "dopuslib.h"
33 __saveds int DoStrCombine(register char *buf __asm("a0"),
34 register char *one __asm("a1"),
35 register char *two __asm("a2"),
36 register int lim __asm("d0"))
38 register int a;
40 a=strlen(one); if (a>=lim) a=lim-1;
41 LStrnCpy(buf,one,a); buf[a]=0;
42 return(DoStrConcat(buf,two,lim));
45 __saveds int DoStrConcat(register char *buf __asm("a0"),
46 register char *cat __asm("a1"),
47 register int lim __asm("d0"))
49 register int a,b;
51 a=strlen(cat); b=strlen(buf);
52 --lim;
53 if (a+b<lim) {
54 LStrnCpy(&buf[b],cat,a); buf[b+a]=0;
55 return(1);
57 if (lim>b) LStrnCpy(&buf[b],cat,lim-b);
58 buf[lim]=0;
59 return(0);
62 __saveds int DoAtoh(register unsigned char *buf __asm("a0"),
63 register int len __asm("d0"))
65 int a,c,d,e,f;
67 c=e=0;
68 for (a=0;;a++) {
69 if (!buf[a] || !((buf[a]>='0' && buf[a]<='9') || (buf[a]>='a' && buf[a]<='f') ||
70 (buf[a]>='A' && buf[a]<='F'))) break;
71 if ((++e)==len) break;
73 if (e==0) return(0);
74 f=1;
75 for (a=1;a<e;a++) f*=16;
76 for (a=0;a<e;a++) {
77 if (buf[a]>='0' && buf[a]<='9') d=buf[a]-'0';
78 else if (buf[a]>='A' && buf[a]<='F') d=10+(buf[a]-'A');
79 else if (buf[a]>='a' && buf[a]<='f') d=10+(buf[a]-'a');
80 c+=(d*f);
81 f/=16;
83 return(c);