Lots of compiler warnings removed.
[AROS-Contrib.git] / dopus / Library / misc.c
blobbc7752cb86802b676c1c8a0997b18d168ac46fc1
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 int __saveds DoRawkeyToStr(register UWORD code __asm("d0"),
34 register UWORD qual __asm("d1"),
35 register char *buf __asm("a0"),
36 register char *kbuf __asm("a1"),
37 register int len __asm("d2"))
39 struct InputEvent inev;
40 struct MsgPort *port;
41 struct IOStdReq *req;
42 struct Process *myproc;
43 struct ConsoleDevice *ConsoleDevice;
44 char ocbuf[20],cbuf[20],*foo;
46 if (buf) buf[0]=0; ocbuf[0]=cbuf[0]=0;
47 if (code!=(UWORD)~0 && code!=0xff) {
48 if (code&IECODE_UP_PREFIX) code-=0x80;
49 if (code>=0x50 && code<=0x59) LSprintf(cbuf,"F%ld",code-0x4f);
50 else if (code!=(UWORD)~0 && code!=0xff) {
51 foo=NULL;
52 switch (code) {
53 case 0x45: foo="ESCAPE"; break;
54 case 0x46: foo="DELETE"; break;
55 case 0x41: foo="BACKSPACE"; break;
56 case 0x42: foo="TAB"; break;
57 case 0x44:
58 case 0x2b: foo="RETURN"; break;
59 case 0x5f: foo="HELP"; break;
60 case 0x60:
61 case 0x4c: foo="CURSOR-UP"; break;
62 case 0x4d: foo="CURSOR-DOWN"; break;
63 case 0x4f: foo="CURSOR-LEFT"; break;
64 case 0x4e: foo="CURSOR-RIGHT"; break;
65 case 0x43: foo="ENTER"; break;
66 case 0x40: foo="SPACE"; break;
68 if (foo) LStrCpy(cbuf,foo);
69 if (!(myproc=(struct Process *)FindTask(NULL))) return(0);
70 port=&myproc->pr_MsgPort;
71 if (!(req=(struct IOStdReq *)CreateExtIO(port,sizeof(struct IOStdReq)))) return(0);
72 if (OpenDevice("console.device",-1,(struct IORequest *)req,0)) {
73 DeleteExtIO((struct IORequest *)req);
74 return(0);
76 ConsoleDevice=(struct ConsoleDevice *)req->io_Device;
77 inev.ie_NextEvent=NULL;
78 inev.ie_Class=IECLASS_RAWKEY;
79 inev.ie_SubClass=0;
80 inev.ie_Code=code;
81 inev.ie_Qualifier=qual&(IEQUALIFIER_LSHIFT|IEQUALIFIER_RSHIFT);
82 inev.ie_EventAddress=NULL;
83 ocbuf[0]=0;
84 RawKeyConvert(&inev,ocbuf,2,NULL);
85 ocbuf[1]=0;
86 CloseDevice((struct IORequest *)req);
87 DeleteExtIO((struct IORequest *)req);
88 if (kbuf) kbuf[0]=ocbuf[0];
89 if (!foo) LStrCpy(cbuf,ocbuf);
92 if (buf) {
93 if (qual&IEQUALIFIER_LCOMMAND) DoStrConcat(buf,"LAMIGA + ",len);
94 if (qual&IEQUALIFIER_RCOMMAND) DoStrConcat(buf,"RAMIGA + ",len);
95 if (qual&IEQUALIFIER_CONTROL) DoStrConcat(buf,"CONTROL + ",len);
96 if (qual&IEQUALIFIER_LSHIFT) DoStrConcat(buf,"LSHIFT + ",len);
97 if (qual&IEQUALIFIER_RSHIFT) DoStrConcat(buf,"RSHIFT + ",len);
98 if (qual&IEQUALIFIER_LALT) DoStrConcat(buf,"LALT + ",len);
99 if (qual&IEQUALIFIER_RALT) DoStrConcat(buf,"RALT + ",len);
100 if ((code==(UWORD)~0 || code==0xff/* || code==0*/) && buf[0]) buf[strlen(buf)-3]=0;
101 else if (cbuf[0]) {
102 StrToUpper(cbuf,ocbuf);
103 DoStrConcat(buf,"'",len);
104 DoStrConcat(buf,ocbuf,len);
105 DoStrConcat(buf,"'",len);
108 return(1);
111 int __saveds DoCheckNumGad(register struct Gadget *gad __asm("a0"),
112 register struct Window *win __asm("a1"),
113 register int min __asm("d0"),
114 register int max __asm("d1"))
116 struct StringInfo *sinfo;
117 int a,b;
119 sinfo=(struct StringInfo *)gad->SpecialInfo;
120 a=b=atoi((char *)sinfo->Buffer);
121 if (a<min) a=min;
122 else if (a>max) a=max;
123 LSprintf((char *)sinfo->Buffer,"%ld",a);
124 if (a!=b) {
125 if (win) RefreshStrGad(gad,win);
126 return(1);
128 return(0);
131 int __saveds DoCheckHexGad(register struct Gadget *gad __asm("a0"),
132 register struct Window *win __asm("a1"),
133 register int min __asm("d0"),
134 register int max __asm("d1"))
136 struct StringInfo *sinfo;
137 int a,b;
139 sinfo=(struct StringInfo *)gad->SpecialInfo;
140 b=DoAtoh((char *)sinfo->Buffer,0);
141 if (sinfo->Buffer[0]==0) a=0;
142 else {
143 a=b;
144 if (a<min) a=min;
145 else if (a>max) a=max;
147 LSprintf((char *)sinfo->Buffer,"%lx",a);
148 if (a!=b) {
149 if (win) RefreshStrGad(gad,win);
150 return(1);
152 return(0);
155 void __saveds DoDecode_RLE(register char *source __asm("a0"),
156 register char *dest __asm("a1"),
157 register int size __asm("d0"))
159 register int a;
160 register char copy,count;
162 for (a=0;a<size;) {
163 if ((count=source[a++])>=0) {
164 copy=count+1;
165 while (copy--) *dest++=source[a++];
167 else if (count!=-128) {
168 copy=1-count;
169 while (copy--) *dest++=source[a];
170 ++a;
175 const static struct TagItem
176 busytags[2]={
177 {WA_BusyPointer,1},
178 {TAG_DONE,0}};
180 //extern UWORD __chip busydata13[];
181 //extern UWORD __chip busydata20[];
183 void __saveds DoSetBusyPointer(register struct Window *wind __asm("a0"))
185 // if (IntuitionBase->LibNode.lib_Version>38)
186 SetWindowPointerA(wind,busytags);
187 // else if (IntuitionBase->LibNode.lib_Version<36)
188 // SetPointer(wind,busydata13,22,16,-6,0);
189 // else SetPointer(wind,busydata20,16,16,-6,0);