Source
...
Target
Commits (4)
  • Robert Sprowson's avatar
    Makefile recreated from fragments · 1a091094
    Robert Sprowson authored
    Include paths changed to Unix style.
    Debug and non debug CMHG definitions replaced by one which is selected by passing predefines to CMHG.
    Removed dummy services.h.
    Don't bother calling TinyStubs SWI since in ROM it does nothing, and the RAM versions haven't used it since ~1997.
    Use module header constants generated from CMHG rather than hand made one.
    Reject out of range SWIs (fixes ticket #305).
    
    Version 0.20. Tagged as 'ColourDbox-0_20'
    1a091094
  • Robert Sprowson's avatar
    Suppress log chatter · 196e1eeb
    Robert Sprowson authored
    No headers to export (they're in tboxlibs), state this explicitly.
    Retagged.
    196e1eeb
  • Robert Sprowson's avatar
    Fix for NULL pointer dereference when 'Default' title is selected · 7845bbed
    Robert Sprowson authored
    Contrary to the Toolbox manual, ColourDbox was taking a zero "max title length" field as the cue to substitute the title, followed by setting the title string pointer to NULL, trying to strlen() it, and ending up with the default from the Res file for this object. The code to look up the default title in the Messages was never called.
    Changed to follow the docs: a NULL title string pointer uses the default and no significance is attached to the max buffer length in that case.
    Messages file (which is now used as a result) changed to have the same default title as before.
    
    Thanks to Nick Roberts for spotting & testing this.
    
    Version 0.21. Tagged as 'ColourDbox-0_21'
    7845bbed
  • Robert Sprowson's avatar
    Fix for ColourDbox_GetColour abort when ColourDbox object isn't open · 0c3b8f71
    Robert Sprowson authored
    Copy into the provided colour_block pointer, rather than the address of the pointer.
    Also, make the calculation of required size a bit more readable by replacing multiple occurences with a variable.
    Fixes ticket #443.
    
    Version 0.22. Tagged as 'ColourDbox-0_22'
    0c3b8f71
......@@ -13,5 +13,5 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine clean COMPONENT=ColourDbox
stripdepnd Makefile
amu_machine clean
stripdepnd
| Copyright 2000 Pace Micro Technology plc
| Copyright 2015 Castle Technology Ltd
|
| Licensed under the Apache License, Version 2.0 (the "License");
| you may not use this file except in compliance with the License.
......@@ -13,4 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine trace COMPONENT=ColourDbox
amu_machine debug THROWBACK=-throwback
......@@ -13,4 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine all COMPONENT=ColourDbox
amu_machine standalone
......@@ -13,4 +13,4 @@
| limitations under the License.
|
Dir <Obey$Dir>
amu_machine rom COMPONENT=ColourDbox
amu_machine rom
......@@ -12,37 +12,21 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Makefile for a Toolbox Object module
# Makefile for ColourDbox module
#
# $Id$
#
# Component specific options:
#
RAMMESSAGES = o.msgs
COMMON_OBJ = o.Modhdr_NoD o.auxiliary o.create o.delete o.events o.getstate\
o.hide o.miscop o.show o.task
ROM_OBJS = o.mainROM ${COMMON_OBJ}
RAM_OBJS = o.main ${RAMMESSAGES} ${COMMON_OBJ}
DBG_OBJS = od.main ${RAMMESSAGES} o.Modhdr od.auxiliary od.create od.delete od.events od.getstate\
od.hide od.miscop od.show od.task
#
# Get main rules
#
include C:tboxlibint.TboxMake
#
# Module specific rules:
#
resources: resources-messages
@echo ${COMPONENT}: resource files copied to Messages module
COMPONENT = ColourDbox
OBJS = auxiliary create delete events getstate\
hide main miscop show task
CMHGDEPENDS = main
ROMCDEFINES = -DROM
CDFLAGS = -Ddebugging=1
CMHGDFLAGS = -Ddebugging=1
CINCLUDES = -IC:tboxlibint,tbox:,C:
HDRS =
LIBS = ${TBOXINTLIB}
DBG_LIBS = ${TBOXINTDBGLIB}
clean: toolbox-clean
@echo ${COMPONENT}: cleaned
include CModule
#---------------------------------------------------------------------------
# Dynamic dependencies:
......@@ -5,4 +5,4 @@ E02:The allocated buffer is too short.
E11:Task, %0, does not exist.
E12:Method, %0, not recognised.
E13:MiscOp Method, %0, not recognised.
Title:Colour Selector
Title:Colour choice
/* (0.19)
/* (0.22)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 0.19
#define Module_MajorVersion_CMHG 0.22
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 04 May 2000
#define Module_Date_CMHG 29 Nov 2017
#define Module_MajorVersion "0.19"
#define Module_Version 19
#define Module_MajorVersion "0.22"
#define Module_Version 22
#define Module_MinorVersion ""
#define Module_Date "04 May 2000"
#define Module_Date "29 Nov 2017"
#define Module_FullVersion "0.19"
#define Module_ApplicationDate "29-Nov-17"
#define Module_ComponentName "ColourDbox"
#define Module_ComponentPath "castle/RiscOS/Sources/Toolbox/ColourDbox"
#define Module_FullVersion "0.22"
#define Module_HelpVersion "0.22 (29 Nov 2017)"
#define Module_LibraryVersionInfo "0:22"
......@@ -29,19 +29,17 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "string32.h"
#include "messages.h"
#include "twimp.h"
#include "style.h"
#include "objects.toolbox.h"
#include "objects.window.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/window.h"
#include "objects/colourdbox.h"
#include "colpicker.h"
#include "main.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
......
......@@ -28,14 +28,13 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "string32.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......@@ -102,9 +101,8 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
*/
internal->x = -1; /* Rogue value */
if (!template->max_title) {
internal->title = NULL;
} else if (!template->title) {
if (!template->title) {
/* Provide a default title */
if ((e = messages_file_lookup ("Title", 0, &buffer_size, 0)) != NULL)
goto clearup1;
......@@ -115,25 +113,13 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
if ((e = messages_file_lookup ("Title", internal->title, &buffer_size, 0)) !=NULL)
goto clearup1;
} else {
/* Caller provided their own title */
if ((internal->title = mem_alloc (template->max_title)) == NULL) {
e = make_error (ColourDbox_AllocFailed, 0);
goto clearup1;
}
string_copy_chk (internal->title, template->title, template->max_title);
}
/* removed ...
if (!template->help_message || !template->max_help) {
internal->help_message = NULL;
} else {
if ((internal->help_message = mem_alloc (template->max_help)) == NULL) {
e = make_error (ColourDbox_AllocFailed, 0);
goto clearup1;
}
string_copy_chk (internal->help_message, template->help_message, template->max_help);
}
internal->max_help = template->max_help;
*/
internal->max_title = strlen(internal->title) + 1;
if (template->max_title > internal->max_title) internal->max_title = template->max_title;
internal->colour = template->colour;
......@@ -163,7 +149,7 @@ extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
return e;
clearup1:
mem_freek(internal);
return e;
clearup1:
mem_freek(internal);
return e;
}
......@@ -27,13 +27,12 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......
......@@ -29,14 +29,13 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "string32.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......
......@@ -27,13 +27,12 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "object.h"
#include "task.h"
......
......@@ -28,13 +28,12 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......
......@@ -25,18 +25,18 @@
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "Global/Services.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "rmensure.h"
#include "mem.h"
#include "messages.h"
#include "objmodule.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "object.h"
#include "auxiliary.h"
......@@ -47,10 +47,9 @@
#include "getstate.h"
#include "miscop.h"
#include "events.h"
#include "task.h"
#include "main.h"
#include "ColourDboxHdr.h"
#define MAX_CLASS_SWI_METHODS 7
static _kernel_oserror *(*class_swi_methods [MAX_CLASS_SWI_METHODS])(_kernel_swi_regs *r, TaskDescriptor *t) =
......@@ -68,10 +67,8 @@ static _kernel_oserror *(*class_swi_methods [MAX_CLASS_SWI_METHODS])(_kernel_swi
/* +++++++++++++++++++++++++++++++++ finalisation code +++++++++++++++++++++++++++++++++ */
#ifdef ROM
static _kernel_oserror *__ROM;
#else
extern int messages_file(void);
#ifndef ROM
extern int Resources(void);
#endif
extern _kernel_oserror *ColourDbox_finalise (int fatal, int podule, void *pw)
......@@ -99,7 +96,7 @@ extern _kernel_oserror *ColourDbox_finalise (int fatal, int podule, void *pw)
* ... and deregister from ResourceFS
*/
objmodule_deregister_resources(messages_file());
objmodule_deregister_resources(Resources());
#endif
/* deregister object module */
......@@ -111,10 +108,6 @@ extern _kernel_oserror *ColourDbox_finalise (int fatal, int podule, void *pw)
mem_free_all ();
#ifdef ROM
if(!__ROM) _swix(0x82c41, 0);
#endif
return NULL;
}
......@@ -122,7 +115,7 @@ extern _kernel_oserror *ColourDbox_finalise (int fatal, int podule, void *pw)
/* ++++++++++++++++++++++++++++++++ initialisation code +++++++++++++++++++++++++++++++ */
extern _kernel_oserror *ColourDbox_init(char *cmd_tail, int podule_base, void *pw)
extern _kernel_oserror *ColourDbox_init(const char *cmd_tail, int podule_base, void *pw)
{
_kernel_oserror *e;
int wimpversion;
......@@ -131,10 +124,6 @@ extern _kernel_oserror *ColourDbox_init(char *cmd_tail, int podule_base, void *p
IGNORE(podule_base);
IGNORE(pw);
#ifdef ROM
__ROM = _swix(0x82c43, _IN(0), pw);
#endif
DEBUG debug_set_var_name("ColourDbox$Debug");
DEBUG debug_output ("M","ColD: code initialise\n");
......@@ -159,7 +148,7 @@ extern _kernel_oserror *ColourDbox_init(char *cmd_tail, int podule_base, void *p
*/
#ifndef ROM
if ((e = objmodule_register_resources(messages_file())) != NULL)
if ((e = objmodule_register_resources(Resources())) != NULL)
return e;
#endif
......@@ -172,7 +161,7 @@ extern _kernel_oserror *ColourDbox_init(char *cmd_tail, int podule_base, void *p
e = objmodule_register_with_toolbox(0, ColourDbox_ObjectClass, ColourDbox_ClassSWI, 0);
if (e) {
#ifndef ROM
objmodule_deregister_resources(messages_file());
objmodule_deregister_resources(Resources());
#endif
return e;
}
......@@ -236,16 +225,16 @@ extern void ColourDbox_services(int service_number, _kernel_swi_regs *r, void *p
extern _kernel_oserror *ColourDbox_SWI_handler(int swi_no, _kernel_swi_regs *r, void *pw)
{
_kernel_oserror *e = NULL;
_kernel_oserror *e;
TaskDescriptor *t;
DEBUG debug_output ("M","ColD: SWI 0x%x\n",ColourDbox_SWIChunkBase+swi_no);
(void) pw;
IGNORE(pw);
switch (swi_no)
{
case ColourDbox_ClassSWI - ColourDbox_SWIChunkBase:
case ColourDbox_ClassSWI - ColourDbox_00:
if (r->r[0] < 0 || r->r[0] >= MAX_CLASS_SWI_METHODS)
{
return make_error_hex(ColourDbox_NoSuchMethod,1,r->r[0]);
......@@ -263,15 +252,16 @@ extern _kernel_oserror *ColourDbox_SWI_handler(int swi_no, _kernel_swi_regs *r,
}
break;
case ColourDbox_PostFilter - ColourDbox_SWIChunkBase:
case ColourDbox_PostFilter - ColourDbox_00:
e = events_postfilter (r);
break;
case ColourDbox_PreFilter - ColourDbox_SWIChunkBase:
case ColourDbox_PreFilter - ColourDbox_00:
e = events_prefilter (r);
break;
default:
e = error_BAD_SWI;
break;
}
......@@ -281,7 +271,7 @@ extern _kernel_oserror *ColourDbox_SWI_handler(int swi_no, _kernel_swi_regs *r,
#if debugging
/* ++++++++++++++++++++++++++++++++++++++ star commands ++++++++++++++++++++++++++++++++++++*/
extern _kernel_oserror *ColourDbox_commands(char *arg_string, int argc, int cmd_no, void *pw)
extern _kernel_oserror *ColourDbox_commands(const char *arg_string, int argc, int cmd_no, void *pw)
{
IGNORE(argc);
IGNORE(pw);
......@@ -289,7 +279,7 @@ extern _kernel_oserror *ColourDbox_commands(char *arg_string, int argc, int cmd_
switch (cmd_no)
{
case 0:
case CMD_ColourDbox_Memory:
mem_print_list();
break;
......
......@@ -28,14 +28,13 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "string32.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......@@ -231,6 +230,7 @@ _kernel_oserror *colourdbox_get_colour (_kernel_swi_regs *r, TaskDescri
ColourPickerHeader *colourpicker_block;
ColourPickerExtended *colourpicker_extd;
int size = user_regs->r[4];
int reqdsize;
DEBUG debug_output ("m","ColD: getting colour\n");
......@@ -304,13 +304,16 @@ _kernel_oserror *colourdbox_get_colour (_kernel_swi_regs *r, TaskDescri
} else { not_showing:
DEBUG debug_output ("y","ColD: not showing\n");
user_regs->r[0] = (internal->flags & ColourDboxInternal_SelectNoneButton) ? 1 : 0;
reqdsize = internal->colour_block_extd->hdr.extension_size + sizeof(ColourDescriptorHeader);
if (!size || !colour_block) {
DEBUG debug_output ("y","ColDbox: request for size");
user_regs->r[4] = internal->colour_block_extd->hdr.extension_size + sizeof(ColourDescriptorHeader);
user_regs->r[4] = reqdsize;
} else {
if (size >= internal->colour_block_extd->hdr.extension_size + sizeof(ColourDescriptorHeader)) {
memcpy (&colour_block, internal->colour_block_extd, sizeof(ColourDescriptorHeader) + internal->colour_block_extd->hdr.extension_size);
} else return make_error (ColourDbox_ShortBuffer, 0);
if (size >= reqdsize) {
memcpy (colour_block, internal->colour_block_extd, reqdsize);
} else {
return make_error (ColourDbox_ShortBuffer, 0);
}
}
}
DEBUG debug_output ("m","ColD: ended GetColour\n");
......
......@@ -28,13 +28,12 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "object.h"
#include "auxiliary.h"
......
......@@ -28,13 +28,12 @@
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.colourdbox.h"
#include "objects/toolbox.h"
#include "objects/colourdbox.h"
#include "auxiliary.h"
#include "object.h"
......
; Copyright 1996 Acorn Computers Ltd
; Copyright 2015 Castle Technology Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
......@@ -12,12 +12,6 @@
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Title: cmhg.toolbox
; Purpose: module header for a ColourDbox Object module
; Author: TGR
; History: 4-Mar-94: TGR: version 1.00
;
#include "VersionNum"
initialisation-code: ColourDbox_init
......@@ -30,9 +24,10 @@ title-string: ColourDbox
help-string: ColourDbox Module_MajorVersion_CMHG Module_MinorVersion_CMHG
#ifdef debugging
command-keyword-table: ColourDbox_commands
ColourDbox_Memory()
#endif
swi-chunk-base-number: 0x829c0
......@@ -40,4 +35,4 @@ swi-handler-code: ColourDbox_SWI_handler
swi-decoding-table: ColourDbox, ClassSWI, PostFilter, PreFilter
date-string: Module_Date_CMHG
date-string: Module_Date_CMHG
; Copyright 1996 Acorn Computers Ltd
;
; Licensed under the Apache License, Version 2.0 (the "License");
; you may not use this file except in compliance with the License.
; You may obtain a copy of the License at
;
; http://www.apache.org/licenses/LICENSE-2.0
;
; Unless required by applicable law or agreed to in writing, software
; distributed under the License is distributed on an "AS IS" BASIS,
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
; See the License for the specific language governing permissions and
; limitations under the License.
;
; Title: cmhg.toolbox
; Purpose: module header for a ColourDbox Object module
; Author: TGR
; History: 4-Mar-94: TGR: version 1.00
;
#include "VersionNum"
initialisation-code: ColourDbox_init
finalisation-code: ColourDbox_finalise
service-call-handler: ColourDbox_services 0x44ec1, 0x44ec2, 0x44ec3
title-string: ColourDbox
help-string: ColourDbox Module_MajorVersion_CMHG Module_MinorVersion_CMHG
swi-chunk-base-number: 0x829c0
swi-handler-code: ColourDbox_SWI_handler
swi-decoding-table: ColourDbox, ClassSWI, PostFilter, PreFilter
date-string: Module_Date_CMHG
......@@ -41,7 +41,6 @@
#include "mem.h"
#endif
#include "main.h"
#include "object.h"
#include "task.h"
......