| 1 | /*
|
|---|
| 2 | * This file is (C) Chris Wohlgemuth 2002
|
|---|
| 3 | * It is part of the MediaFolder package
|
|---|
| 4 | */
|
|---|
| 5 | /*
|
|---|
| 6 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | * it under the terms of the GNU General Public License as published by
|
|---|
| 8 | * the Free Software Foundation; either version 2, or (at your option)
|
|---|
| 9 | * any later version.
|
|---|
| 10 | *
|
|---|
| 11 | * This program is distributed in the hope that it will be useful,
|
|---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | * GNU General Public License for more details.
|
|---|
| 15 | *
|
|---|
| 16 | * You should have received a copy of the GNU General Public License
|
|---|
| 17 | * along with this program; see the file COPYING. If not, write to
|
|---|
| 18 | * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
|---|
| 19 | */
|
|---|
| 20 | #define INCL_GPILCIDS
|
|---|
| 21 | #define INCL_GPIPRIMITIVES
|
|---|
| 22 | #define INCL_GPIBITMAPS
|
|---|
| 23 | #define INCL_SW
|
|---|
| 24 | #define INCL_REXXSAA
|
|---|
| 25 |
|
|---|
| 26 | #include "mediafolder.hh"
|
|---|
| 27 | #include "mediafolderres.h"
|
|---|
| 28 |
|
|---|
| 29 | //#pragma SOMAsDefault(pop)
|
|---|
| 30 | #include <os2.h>
|
|---|
| 31 | #include <rexxsaa.h> /* needed for RexxStart() */
|
|---|
| 32 | #include <stdio.h>
|
|---|
| 33 | #include <stdlib.h>
|
|---|
| 34 | //#pragma SOMAsDefault(on)
|
|---|
| 35 |
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | typedef ULONG (APIENTRY *PFNWPSFUNC)(WPObject* ,...);
|
|---|
| 39 |
|
|---|
| 40 | extern ULONG calculateHash(char * theString);
|
|---|
| 41 | ULONG calculateHash2(char * theString);
|
|---|
| 42 | void parameterError(char *chrMethod);
|
|---|
| 43 | extern SOMClass* somhlpGetSomClass(char* chrClassName);
|
|---|
| 44 |
|
|---|
| 45 |
|
|---|
| 46 | void parameterError(char *chrMethod)
|
|---|
| 47 | {
|
|---|
| 48 | char text[200];
|
|---|
| 49 | sprintf(text, "%s(): wrong number of parameters.", chrMethod);
|
|---|
| 50 |
|
|---|
| 51 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Method error",
|
|---|
| 52 | 1234, MB_OK|MB_MOVEABLE);
|
|---|
| 53 |
|
|---|
| 54 | }
|
|---|
| 55 |
|
|---|
| 56 | void wpObjectError(char *chrMethod)
|
|---|
| 57 | {
|
|---|
| 58 | char text[200];
|
|---|
| 59 | sprintf(text, "%s(): object pointer is not valid.", chrMethod);
|
|---|
| 60 |
|
|---|
| 61 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "Object error",
|
|---|
| 62 | 1234, MB_OK|MB_MOVEABLE);
|
|---|
| 63 |
|
|---|
| 64 | }
|
|---|
| 65 |
|
|---|
| 66 |
|
|---|
| 67 | #define HASHSIZE 101
|
|---|
| 68 | ULONG calculateHash(char * theString)
|
|---|
| 69 | {
|
|---|
| 70 | ULONG ulHash=0;
|
|---|
| 71 |
|
|---|
| 72 | if(theString)
|
|---|
| 73 | for(ulHash=0;*theString!='\0'; theString++)
|
|---|
| 74 | ulHash=*theString+31*ulHash;
|
|---|
| 75 |
|
|---|
| 76 | return ulHash%HASHSIZE;
|
|---|
| 77 | }
|
|---|
| 78 |
|
|---|
| 79 | #define HASHSIZE2 123
|
|---|
| 80 | ULONG calculateHash2(char * theString)
|
|---|
| 81 | {
|
|---|
| 82 | ULONG ulHash=0;
|
|---|
| 83 |
|
|---|
| 84 | if(theString)
|
|---|
| 85 | for(ulHash=0;*theString!='\0'; theString++)
|
|---|
| 86 | ulHash=*theString+37*ulHash;
|
|---|
| 87 |
|
|---|
| 88 | return ulHash%HASHSIZE;
|
|---|
| 89 | }
|
|---|
| 90 |
|
|---|
| 91 | /* This function handles new WPS functions introduced by private classes */
|
|---|
| 92 | ULONG EXPENTRY rxCallCWWPSFunc(PSZ name, LONG argc, RXSTRING argv[], PSZ queuename,PRXSTRING retstring)
|
|---|
| 93 | {
|
|---|
| 94 | char text[200];
|
|---|
| 95 | ULONG ulHash;
|
|---|
| 96 | ULONG ulReturn;
|
|---|
| 97 | WPObject* wpObject;
|
|---|
| 98 | WPFileSystem* wpFSObject;
|
|---|
| 99 |
|
|---|
| 100 | /* At least WPObject* and name of method */
|
|---|
| 101 | if(argc<2)
|
|---|
| 102 | return 40;
|
|---|
| 103 |
|
|---|
| 104 | TRY_LOUD(RX) {
|
|---|
| 105 |
|
|---|
| 106 | /* Get a hash for the methodname for the switch() statement */
|
|---|
| 107 | ulHash=calculateHash(argv[0].strptr)<<8;
|
|---|
| 108 | ulHash+=calculateHash2(argv[0].strptr);
|
|---|
| 109 | ulReturn=0;
|
|---|
| 110 |
|
|---|
| 111 | wpObject=(WPObject*)atol(argv[1].strptr);
|
|---|
| 112 | /* Check if it's a valid object */
|
|---|
| 113 | if(somIsObj(wpObject)) {
|
|---|
| 114 | PFNWPSFUNC procAddr;
|
|---|
| 115 |
|
|---|
| 116 | /* Try to find the requested method */
|
|---|
| 117 | if((procAddr=(PFNWPSFUNC) somResolveByName(wpObject, argv[0].strptr))==NULL) {
|
|---|
| 118 | /* method not found. Check if it's a wrapped one */
|
|---|
| 119 | switch(ulHash)
|
|---|
| 120 | {
|
|---|
| 121 | case 0x1b2a: /* cwIsA */
|
|---|
| 122 | procAddr=(PFNWPSFUNC) somResolveByName(wpObject, "somIsA");
|
|---|
| 123 | break;
|
|---|
| 124 | case 0x2c21: /* cwIsInstanceOf */
|
|---|
| 125 | procAddr=(PFNWPSFUNC) somResolveByName(wpObject, "somIsInstanceOf");
|
|---|
| 126 | break;
|
|---|
| 127 | case 0x5226: /* cwQueryRealName */
|
|---|
| 128 | procAddr=(PFNWPSFUNC) somResolveByName(wpObject, "wpQueryRealName");
|
|---|
| 129 | break;
|
|---|
| 130 | #if 0
|
|---|
| 131 | case 0x24 : /* cwQueryFilename */
|
|---|
| 132 | procAddr=(PFNWPSFUNC) somResolveByName(wpObject, "wpQueryFilename");
|
|---|
| 133 | break;
|
|---|
| 134 | #endif
|
|---|
| 135 | default:
|
|---|
| 136 | break;
|
|---|
| 137 | }
|
|---|
| 138 | }
|
|---|
| 139 |
|
|---|
| 140 | if(procAddr==NULL) {
|
|---|
| 141 | /* method not found and no private one */
|
|---|
| 142 | sprintf(retstring->strptr, "ERROR_METHOD:");
|
|---|
| 143 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 144 | }
|
|---|
| 145 | else {
|
|---|
| 146 | switch(ulHash)
|
|---|
| 147 | {
|
|---|
| 148 | /* WPS method without a parameter returning ULONG or WPObject* */
|
|---|
| 149 | case 0x0f10: /* cwQueryCurrentlyPlayingObject */
|
|---|
| 150 | {
|
|---|
| 151 | sprintf(retstring->strptr,"%d",procAddr(wpObject));
|
|---|
| 152 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 153 | break;
|
|---|
| 154 | }
|
|---|
| 155 | /* Functions with one (ULONG) param returning ULONG, BOOL or WPObject* */
|
|---|
| 156 | /* WPObject */
|
|---|
| 157 | case 0x3f5e: /* cwStopAudioFile */ /* Obsolete with V0.2.5 */
|
|---|
| 158 | case 0x303d: /* cwPauseAudioFile */ /* Obsolete with V0.2.5 */
|
|---|
| 159 | case 0x5954: /* cwGetFileSystemObject */
|
|---|
| 160 | case 0x244a: /* mfldrStopAudioFile */ /* new with V0.2.5 */
|
|---|
| 161 | case 0x3601: /* mfldrPauseAudioFile */ /* new with V0.2.5 */
|
|---|
| 162 | {
|
|---|
| 163 | ULONG ulParam1;
|
|---|
| 164 |
|
|---|
| 165 | if(argc<3) {
|
|---|
| 166 | parameterError(argv[0].strptr);
|
|---|
| 167 | ulReturn=40;
|
|---|
| 168 | break;
|
|---|
| 169 | }
|
|---|
| 170 |
|
|---|
| 171 | ulParam1=atol(argv[2].strptr);
|
|---|
| 172 | sprintf(retstring->strptr,"%d",procAddr(wpObject, ulParam1));
|
|---|
| 173 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 174 | break;
|
|---|
| 175 | }
|
|---|
| 176 | /* Functions with one (ULONG) param returning a string: */
|
|---|
| 177 | case 0x5226: /* cwQueryRealName */
|
|---|
| 178 | {
|
|---|
| 179 | ULONG ulParam1;
|
|---|
| 180 |
|
|---|
| 181 | if(argc<3) {
|
|---|
| 182 | parameterError(argv[0].strptr);
|
|---|
| 183 | ulReturn=40;
|
|---|
| 184 | break;
|
|---|
| 185 | }
|
|---|
| 186 | ulParam1=atol(argv[2].strptr);/* BOOL fQualified */
|
|---|
| 187 |
|
|---|
| 188 | if(!procAddr(wpObject, retstring->strptr, &retstring->strlength, ulParam1))
|
|---|
| 189 | sprintf(retstring->strptr,"ERROR:");
|
|---|
| 190 | /*
|
|---|
| 191 | if(!procAddr(wpObject, &retstring->strptr, &retstring->strlength, ulParam1))*/
|
|---|
| 192 |
|
|---|
| 193 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 194 | break;
|
|---|
| 195 | }
|
|---|
| 196 | /* Function with two ULONG (or alike) params returning ULONG */
|
|---|
| 197 | case 0x2f58: /* cwPlayAudioFile */ /* Obsolete with V0.2.5 */
|
|---|
| 198 | case 0x1423: /* mfldrPlayAudioFile */ /* new with V0.2.5 */
|
|---|
| 199 | {
|
|---|
| 200 | ULONG ulParam1;
|
|---|
| 201 | ULONG ulParam2;
|
|---|
| 202 |
|
|---|
| 203 | if(argc<4) {
|
|---|
| 204 | parameterError(argv[0].strptr);
|
|---|
| 205 | ulReturn=40;
|
|---|
| 206 | break;
|
|---|
| 207 | }
|
|---|
| 208 | ulParam1=atol(argv[2].strptr);
|
|---|
| 209 | ulParam2=atol(argv[3].strptr);
|
|---|
| 210 |
|
|---|
| 211 | sprintf(retstring->strptr,"%d", procAddr(wpObject, ulParam1, ulParam2));
|
|---|
| 212 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 213 | break;
|
|---|
| 214 | }
|
|---|
| 215 | case 0x631e: /* mfldrSetStatusLineText */ /* new with V0.2.5 */
|
|---|
| 216 | case 0x5121: /* cwSetStatusLineText */ /* Obsolete with V0.2.5 */
|
|---|
| 217 | {
|
|---|
| 218 | if(argc<3) {
|
|---|
| 219 | parameterError(argv[0].strptr);
|
|---|
| 220 | ulReturn=40;
|
|---|
| 221 | break;
|
|---|
| 222 | }
|
|---|
| 223 | if(atoi(argv[2].strptr)==0 && strlen(argv[2].strptr)==1)
|
|---|
| 224 | procAddr(wpObject, NULLHANDLE);
|
|---|
| 225 | else
|
|---|
| 226 | procAddr(wpObject, argv[2].strptr);
|
|---|
| 227 | break;
|
|---|
| 228 | }
|
|---|
| 229 | /* Function with one param returning ULONG */
|
|---|
| 230 | case 0x1b2a: /* cwIsA */
|
|---|
| 231 | case 0x2c21: /* cwIsInstanceOf */
|
|---|
| 232 | {
|
|---|
| 233 | SOMClass *somClass;
|
|---|
| 234 |
|
|---|
| 235 | if(argc<3) {
|
|---|
| 236 | parameterError(argv[0].strptr);
|
|---|
| 237 | ulReturn=40;
|
|---|
| 238 | break;
|
|---|
| 239 | }
|
|---|
| 240 |
|
|---|
| 241 | somClass=somhlpGetSomClass(argv[2].strptr);
|
|---|
| 242 | if(!somIsObj(somClass)) {
|
|---|
| 243 | sprintf(retstring->strptr,"ERROR_CLASS:");/* Return error */
|
|---|
| 244 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 245 | break;
|
|---|
| 246 | }
|
|---|
| 247 |
|
|---|
| 248 | sprintf(retstring->strptr,"%d", procAddr(wpObject, somClass));
|
|---|
| 249 | retstring->strlength=strlen(retstring->strptr);
|
|---|
| 250 | break;
|
|---|
| 251 | }
|
|---|
| 252 | default:
|
|---|
| 253 | ulReturn=40;
|
|---|
| 254 | }/* switch */
|
|---|
| 255 | }/* else if((procAddr=(PFNWPSFUNC) somResolveByName(wpObject, argv[1].strptr))==NULL) */
|
|---|
| 256 | }/* if(somIsObj(wpObject)) */
|
|---|
| 257 | else {
|
|---|
| 258 | /* wpObject is not valid */
|
|---|
| 259 | wpObjectError(argv[0].strptr);
|
|---|
| 260 |
|
|---|
| 261 | ulReturn=40;
|
|---|
| 262 | }
|
|---|
| 263 | /*
|
|---|
| 264 | sprintf(text, "%s HAsh: %x, Hash2: %x",argv[0].strptr, ulHash, calculateHash2(argv[0].strptr));
|
|---|
| 265 | WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, text, "",
|
|---|
| 266 | 1234, MB_OK|MB_MOVEABLE);
|
|---|
| 267 | */
|
|---|
| 268 | }
|
|---|
| 269 | CATCH(RX)
|
|---|
| 270 | {}END_CATCH;
|
|---|
| 271 |
|
|---|
| 272 | return ulReturn;
|
|---|
| 273 | }
|
|---|
| 274 | /*
|
|---|
| 275 |
|
|---|
| 276 | Functions without params returning a string:
|
|---|
| 277 |
|
|---|
| 278 |
|
|---|
| 279 | Functions with one (ULONG) param returning ULONG, BOOL or WPObject*:
|
|---|
| 280 |
|
|---|
| 281 | 0x3f: cwStopAudioFile 0x5e obsolete with V0.2.5
|
|---|
| 282 | 0x30: cwPauseAudioFile 0x3d obsolete with V0.2.5
|
|---|
| 283 | 0x59: cwGetFileSystemObject 0x54
|
|---|
| 284 | 0x1b: cwIsA 0x2a
|
|---|
| 285 | 0x244a: mfldrStopAudioFile new with V0.2.5
|
|---|
| 286 | 0x3601: mfldrPauseAudioFile new with V0.2.5
|
|---|
| 287 |
|
|---|
| 288 | Functions with one (ULONG) param returning a string:
|
|---|
| 289 | 0x52: cwQueryRealName 0x26
|
|---|
| 290 | 0x24 : cwQueryFilename
|
|---|
| 291 |
|
|---|
| 292 | Function with two ULONG (or alike) params:
|
|---|
| 293 | 0x2f: cwPlayAudioFile 0x58 obsolete with V0.2.5
|
|---|
| 294 | 0x1423: mfldrPlayAudioFile new with V0.2.5
|
|---|
| 295 |
|
|---|
| 296 | 0x2c: cwIsInstanceOf 0x21
|
|---|
| 297 | 0x51: cwSetStatusLineText 0x21
|
|---|
| 298 | 0x631e: mfldrSetStatusLineText
|
|---|
| 299 |
|
|---|
| 300 | ( 0x2e: cwGetVersionNumbers hash2: 0x58)
|
|---|
| 301 |
|
|---|
| 302 | 0xf: cwQueryCurrentlyPlayingObject 0x10
|
|---|
| 303 |
|
|---|
| 304 | */
|
|---|
| 305 |
|
|---|
| 306 |
|
|---|
| 307 |
|
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
|
|---|
| 311 |
|
|---|
| 312 |
|
|---|
| 313 |
|
|---|
| 314 |
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 |
|
|---|
| 318 |
|
|---|
| 319 |
|
|---|
| 320 |
|
|---|
| 321 |
|
|---|
| 322 |
|
|---|
| 323 |
|
|---|
| 324 |
|
|---|
| 325 |
|
|---|
| 326 |
|
|---|
| 327 |
|
|---|
| 328 |
|
|---|
| 329 |
|
|---|
| 330 |
|
|---|
| 331 |
|
|---|
| 332 |
|
|---|
| 333 |
|
|---|
| 334 |
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|