Commit 36ab49d8 authored by Neil Turton's avatar Neil Turton
Browse files

Import from cleaned 360 CD

c/** gitlab-language=c linguist-language=c linguist-detectable=true
h/** gitlab-language=c linguist-language=c linguist-detectable=true
cmhg/** gitlab-language=cmhg linguist-language=cmhg linguist-detectable=true
*,fe1 gitlab-language=make linguist-language=make linguist-detectable=true
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
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.
# Makefile for FileInfo
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 06-Jan-94 AMcC Created
#
#
# Component specific options:
#
COMPONENT = FileInfo
ROM_MODULE = aof.${COMPONENT}
#
# Export Paths for Messages module
#
RESDIR = <resource$dir>.Resources2.${COMPONENT}
#
# Generic options:
#
MKDIR = cdir
CC = cc
CMHG = cmhg
CP = copy
LD = link
RM = remove
WIPE = -wipe
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
CFLAGS = -c -depend !Depend ${INCLUDES} -zM -ffah -zps1 ${DFLAGS}
DFLAGS = -DROM
INCLUDES = -Itbox:,C:
#
# Libraries
#
ANSILIB = CLib:o.ansilib
CLIB = CLIB:o.stubs
RLIB = RISCOSLIB:o.risc_oslib
ROMCSTUBS = RISCOSLIB:o.romcstubs
ABSSYM = RISC_OSLib:o.abssym
TBOXLIB = tbox:tboxlib
OBJS =\
o.Modhdr_NoD\
o.auxiliary\
o.copy\
o.create\
o.delete\
o.events\
o.getstate\
o.hide\
o.main\
o.miscop\
o.show\
o.task
#
# Rule patterns
#
.c.o:; ${CC} ${CFLAGS} -o $@ $<
.cmhg.o:; ${CMHG} -O $@ $<
#
# Main rules:
#
#
rom: ${ROM_MODULE}
@echo ${COMPONENT}: Module built (ROM)
install_rom: ${ROM_MODULE}
${CP} ${ROM_MODULE} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: Module installed (ROM)
resources: Messages
${MKDIR} ${RESDIR}
${CP} Messages ${RESDIR}.Messages ${CPFLAGS}
${CP} Res ${RESDIR}.Res ${CPFLAGS}
@echo ${COMPONENT}: resource files copied to Messages module
clean:
${WIPE} o.* ${WFLAGS}
${WIPE} aof ${WFLAGS}
${WIPE} linked ${WFLAGS}
${WIPE} map ${WFLAGS}
@echo ${COMPONENT}: cleaned
${ROM_MODULE}: ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
${MKDIR} aof
${LD} -o $@ -aof ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
# final link for ROM Image (using given base address)
rom_link:
${MKDIR} linked
${MKDIR} map
${LD} -o linked.${COMPONENT} -bin -base ${ADDRESS} ${ROM_MODULE} ${ABSSYM} \
-map > map.${COMPONENT}
truncate map.${COMPONENT} linked.${COMPONENT}
${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#---------------------------------------------------------------------------
# Dynamic dependencies:
# Project: FileInfo
# Toolflags:
CCflags = -c -depend !Depend -IC: -throwback -zM -ffah -zps1
C++flags = -c -depend !Depend -throwback -IC:
Pascalflags = -c -depend !Depend -throwback -IP:
Linkflags = -m -o $@
ObjAsmflags = -Throwback -Stamp -NoCache -depend !Depend -CloseExec -Quit
CMHGflags =
LibFileflags = -c -o $@
Squeezeflags = -o $@
AAsmflags = -ThrowBack -Stamp -NoCache -depend !Depend -CloseExec -Quit -To $@ -From
# Final targets:
@.FileInfo: C:o.stubs @.o.auxiliary @.o.copy @.o.create @.o.delete \
@.o.events @.o.getstate @.o.hide @.o.main @.o.miscop @.o.show @.o.task @.o.Modhdr_NoD \
@.o.res @.o.messages @.^.common.tboxlib
link $(linkflags) C:o.stubs @.o.auxiliary @.o.copy @.o.create \
@.o.delete @.o.events @.o.getstate @.o.hide @.o.main @.o.miscop @.o.show @.o.task \
@.o.Modhdr_NoD @.o.res @.o.messages @.^.common.tboxlib
# User-editable dependencies:
@.FileInfoM: @.messages
modgen @.FileInfoM FileInfoM "FileInfo Messages" 1.00 @.messages Resources.FileInfo.Messages
@.o.messages: @.Messages
resgen messages_file @.o.messages @.Messages Resources.FileInfo.Messages
@.o.res: @.Res
resgen res_file @.o.res @.Res Resources.FileInfo.Res
# Static dependencies:
@.o.auxiliary: @.c.auxiliary
cc $(ccflags) -o @.o.auxiliary @.c.auxiliary
@.o.create: @.c.create
cc $(ccflags) -o @.o.create @.c.create
@.o.Modhdr_NoD: @.cmhg.Modhdr_NoD
cmhg @.cmhg.Modhdr_NoD -o @.o.Modhdr_NoD
@.o.main: @.c.main
cc $(ccflags) -o @.o.main @.c.main
@.o.copy: @.c.copy
cc $(ccflags) -o @.o.copy @.c.copy
@.o.delete: @.c.delete
cc $(ccflags) -o @.o.delete @.c.delete
@.o.getstate: @.c.getstate
cc $(ccflags) -o @.o.getstate @.c.getstate
@.o.hide: @.c.hide
cc $(ccflags) -o @.o.hide @.c.hide
@.o.show: @.c.show
cc $(ccflags) -o @.o.show @.c.show
@.o.task: @.c.task
cc $(ccflags) -o @.o.task @.c.task
@.o.miscop: @.c.miscop
cc $(ccflags) -o @.o.miscop @.c.miscop
@.o.events: @.c.events
cc $(ccflags) -o @.o.events @.c.events
# Dynamic dependencies:
# 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.
#
# Makefile for FileInfo
#
# ***********************************
# *** C h a n g e L i s t ***
# ***********************************
# Date Name Description
# ---- ---- -----------
# 06-Jan-94 AMcC Created
#
#
# Component specific options:
#
COMPONENT = FileInfo
ROM_MODULE = aof.${COMPONENT}
#
# Export Paths for Messages module
#
RESDIR = <resource$dir>.Resources2.${COMPONENT}
#
# Generic options:
#
MKDIR = cdir
CC = cc
CMHG = cmhg
CP = copy
LD = link
RM = remove
WIPE = -wipe
CPFLAGS = ~cfr~v
WFLAGS = ~c~v
CFLAGS = -c -depend !Depend ${INCLUDES} -zM -ffah -zps1 ${DFLAGS}
DFLAGS = -DROM
INCLUDES = -Itbox:,C:
#
# Libraries
#
ANSILIB = CLib:o.ansilib
CLIB = CLIB:o.stubs
RLIB = RISCOSLIB:o.risc_oslib
ROMCSTUBS = RISCOSLIB:o.romcstubs
ABSSYM = RISC_OSLib:o.abssym
TBOXLIB = tbox:tboxlib
OBJS =\
o.Modhdr_NoD\
o.auxiliary\
o.copy\
o.create\
o.delete\
o.events\
o.getstate\
o.hide\
o.main\
o.miscop\
o.show\
o.task
#
# Rule patterns
#
.c.o:; ${CC} ${CFLAGS} -o $@ $<
.cmhg.o:; ${CMHG} -O $@ $<
#
# Main rules:
#
#
rom: ${ROM_MODULE}
@echo ${COMPONENT}: Module built (ROM)
install_rom: ${ROM_MODULE}
${CP} ${ROM_MODULE} ${INSTDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: Module installed (ROM)
resources: Messages
${MKDIR} ${RESDIR}
${CP} Messages ${RESDIR}.Messages ${CPFLAGS}
${CP} Res ${RESDIR}.Res ${CPFLAGS}
@echo ${COMPONENT}: resource files copied to Messages module
clean:
${WIPE} o.* ${WFLAGS}
${WIPE} aof ${WFLAGS}
${WIPE} linked ${WFLAGS}
${WIPE} map ${WFLAGS}
@echo ${COMPONENT}: cleaned
${ROM_MODULE}: ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
${MKDIR} aof
${LD} -o $@ -aof ${OBJS} ${TBOXLIB} ${ROMCSTUBS}
# final link for ROM Image (using given base address)
rom_link:
${MKDIR} linked
${MKDIR} map
${LD} -o linked.${COMPONENT} -bin -base ${ADDRESS} ${ROM_MODULE} ${ABSSYM} \
-map > map.${COMPONENT}
truncate map.${COMPONENT} linked.${COMPONENT}
${CP} linked.${COMPONENT} ${LINKDIR}.${COMPONENT} ${CPFLAGS}
@echo ${COMPONENT}: rom_link complete
#---------------------------------------------------------------------------
# Dynamic dependencies:
E00:FileInfo has active tasks.
E01:Memory allocation failed.
E02:Buffer too short.
E11:Task, %0, does not exist.
E12:Method, %0, not recognised.
E13:MiscOp Method, %0, not recognised.
YES:YES
NO:NO
Unt:<Untitled>
dir:directory
app:application
File added
/* 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: auxiliary.c
* Purpose: support functions for the FileInfo object class
* Author: TGR
* History: 8-Feb-94: TGR: created
*
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#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.fileinfo.h"
#include "main.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#define BufferSize 256
char *global_yes;
char *global_no;
char *global_untitled;
ObjectID global_menu;
FileInfoInternal *global_next;
int global_window_count = 0;
EventInterest events_of_interest[] = {
{wimp_ETOOLBOX_EVENT , 0},
/*
{wimp_ECLOSE , Window_ObjectClass},
*/
{-1 , -1}
};
EventInterest toolbox_events_of_interest[] = {
{FileInfo_AboutToBeShown , FileInfo_ObjectClass},
{Window_HasBeenHidden , Window_ObjectClass },
{-1 , -1}
};
/*
extern _kernel_oserror *dialogue_completed (ObjectID object_id) {
_kernel_oserror *e;
_kernel_swi_regs regs;
ToolboxEvent toolbox_event;
regs.r[0] = 0;
regs.r[1] = (int) object_id;
regs.r[2] = -1;
regs.r[3] = (int) &toolbox_event;
toolbox_event.hdr.size = sizeof (FileInfo_DialogueCompleted_Event);
toolbox_event.hdr.event_code = FileInfo_DialogueCompleted;
toolbox_event.hdr.flags = 0;
if ((e = _kernel_swi (Toolbox_RaiseToolboxEvent, &regs, &regs)) != NULL)
return e;
return NULL;
}
*/
extern _kernel_oserror *aux_set_file_size (FileInfoInternal *internal, int filesize) {
_kernel_swi_regs regs;
char buffer[FileNameBufferSize];
internal->filesize = filesize;
/*
if (filesize < 4096) {
*/
sprintf (buffer, "%d", filesize);
/*
} else if (filesize < 4096*1024) {
filesize = filesize/512;
sprintf (buffer, "%dK", filesize>>1 + (filesize & 1));
} else {
filesize = filesize/(512*1024);
sprintf (buffer, "%dM", filesize>>1 + (filesize & 1));
}
*/
regs.r[0] = 0;
regs.r[1] = (int) internal->sub_object_id;
regs.r[2] = DisplayField_SetValue;
regs.r[3] = FileInfo_DisplayField_FileSize;
regs.r[4] = (int) buffer;
return _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs);
}
extern _kernel_oserror *aux_set_file_type (FileInfoInternal *internal, int filetype) {
#define ArbitraryMaxSize 32
_kernel_oserror *e;
_kernel_swi_regs regs;
ObjectID sub_object_id = internal->sub_object_id;
char buffer[ArbitraryMaxSize];
int buffer_size = ArbitraryMaxSize;
internal->filetype = filetype;
if (filetype < 0x1000 || filetype > 0x2000) {
regs.r[0] = 18;
regs.r[2] = filetype;
if ((e = _kernel_swi (OS_FSControl, &regs, &regs)) != NULL)
return e;
memcpy (&(buffer[0]), &regs.r[2], sizeof(int));
memcpy (&(buffer[4]), &regs.r[3], sizeof(int));
sprintf (&(buffer[8]), "(%03x)", filetype & 0xfff);
} else {
if (filetype == 0x1000) {
if ((e = messages_file_lookup ("dir", buffer, &buffer_size, 0)) !=NULL)
return e;
} else {
if ((e = messages_file_lookup ("app", buffer, &buffer_size, 0)) !=NULL)
return e;
}
}
DEBUG debug_output ("f","FileInfo: setting filetype to '%s'\n", buffer);
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_SetValue;
regs.r[3] = FileInfo_DisplayField_FileType;
regs.r[4] = (int) buffer;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
if (filetype != 0x1000 && filetype != 0x2000) {
sprintf (buffer, "file_%03x", filetype & 0xfff);
} else if (filetype == 0x1000) {
strcpy (buffer, "directory");
} else if (filetype == 0x2000) {
strcpy (buffer, "application");
}
regs.r[0] = os_SpriteOp_SelectSprite;
regs.r[2] = (int) buffer;
if (_kernel_swi (Wimp_SpriteOp, &regs, &regs))
strcpy (buffer, "file_xxx");
DEBUG debug_output ("f","FileInfo: setting sprite from filetype (actually: '%s')\n",buffer);
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = Button_SetValue;
regs.r[3] = FileInfo_Button_FileType;
regs.r[4] = (int) buffer;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
return NULL;
#undef ArbitraryMaxSize
}
extern FileInfoInternal *find_internal (TaskDescriptor *t, ObjectID sub_object_id) {
FileInfoInternal *i = t->object_list,
*j;
DEBUG debug_output ("a","FileInfo: find internal, searching for sub_object_id = 0x%x\n",sub_object_id);
if (!i) return NULL;
/* Search through the objectect list until we find the one with the required underlying objectect ID */
do {
j = i->forward;
DEBUG debug_output ("a","FileInfo: internal = 0x%x, sub_object_id = 0x%x\n",i,i->sub_object_id);
if (i->sub_object_id == sub_object_id) return i;
} while ((i=j) != t->object_list);
return NULL;
}
_kernel_oserror *show_actual (void) {
_kernel_oserror *e;
_kernel_swi_regs regs;
void *show_info;
int show_type;
DEBUG debug_output ("e","FileInfo: attempting to actually show the dbox\n");
regs.r[0] = 0;
regs.r[1] = global_next->sub_object_id;
if ((e = _kernel_swi (Toolbox_GetParent, &regs, &regs)) != NULL) {
return e;
}
show_info = global_next->show_info;
show_type = (show_info) ? ((global_next->flags & FileInfoInternal_FullInfoShow) ? 1 : 2) : 0;
regs.r[4] = regs.r[0]; /* parent id */
regs.r[5] = regs.r[1]; /* parent component */
regs.r[0] = (global_next->flags & FileInfoInternal_MenuSemantics) ? 1 :
((global_next->flags & FileInfoInternal_SubMenuSemantics) ? 2 : 0);
regs.r[1] = (int) global_next->sub_object_id;
regs.r[2] = show_type;
regs.r[3] = (int) show_info;
DEBUG {
debug_output ("a","FileInfo: showing, semantics %d",show_type);
if (show_type == 2) {
debug_output ("a"," at (%d,%d)\n",*((int *) show_info), *((int *) show_info + 1));
} else {
debug_output ("a","\n");
}
}
global_next->flags |= FileInfoInternal_IsShowing;
if ((e = _kernel_swi (Toolbox_ShowObject, &regs, &regs)) != NULL)
return e;
if (show_info) {
mem_freek (show_info);
global_next->show_info = NULL;
}
global_next = NULL;
return NULL;
}
/* 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: copy.c
* Purpose: copy a FileInfo Object
* Author: TGR
* History: 7-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "copy.h"
extern _kernel_oserror *copy_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request to copy an object
* R0 = 2
* R1 = Object ID
* R2 = internal handle returned when "src" Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9:
* R0 = flags
* bit 0 set => do not recursively copy the Object
* R1 = source Object ID
*/
/*
* The Toolbox has already checked that this is not just a copy
* call for a shared Object which already exists.
* We create a new Object, and add it to the list of Objects for this
* task.
* We need to remember the ObjectID passed to us by the Toolbox, so
* that we can identify this Object if we are given an ID from the
* client's "id block".
*/
#ifdef COPY_OBJECT
_kernel_oserror *e;
_kernel_swi_regs regs;
FileInfoInternal *internal = (FileInfoInternal *) r->r[2],
*internalx;
if ((internalx = mem_alloc (sizeof (FileInfoInternal))) == NULL)
return make_error (FileInfo_AllocFailed, 0);
memcpy (internalx, internal, sizeof (FileInfoInternal));
regs.r[0] = 0;
regs.r[1] = (int) internal->sub_object_id;
if ((e = _kernel_swi (Toolbox_CopyObject, &regs, &regs)) != NULL)
goto clearup1;
internalx->sub_object_id = (ObjectID) regs.r[0];
internalx->forward = t->object_list;
internalx->backward = t->object_list->backward;
t->object_list->backward->forward = internalx;
t->object_list->backward = internalx;
r->r[0] = (int) internalx;
return NULL;
clearup1:
mem_freek (internalx);
return e;
#else
return NULL;
#endif
}
/* 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: create.c
* Purpose: create a FileInfo Object
* Author: TGR
* History: 7-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objsupport.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "objects.window.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "create.h"
#define BufferSize 256
extern _kernel_oserror *create_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request to create an object
* R0 = 0
* R1 = Object ID
* R2 = 0 (will be internal handle for other SWIs
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* bit 0 set => create from memory
* R1 -> description block
*/
/*
* The Toolbox has already checked that this is not just a create
* call for a shared Object which already exists.
* We create a new Object, and add it to the list of Objects for this
* task.
* We need to remember the ObjectID passed to us by the Toolbox, so
* that we can identify this Object if we are given an ID from the
* client's "id block".
* Note that if any template names are held in the Object, then we
* create an Object from that template, and store its ID.
* Note also that the Toolbox has changed the client's R1 to point
* at an in-core template, if it wasn't already!
*/
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
ObjectTemplateHeader *obj_temp_hdr = (ObjectTemplateHeader *) user_regs->r[1];
FileInfoTemplate *template = (FileInfoTemplate *) obj_temp_hdr->body;
FileInfoInternal *internal;
char *title,
*new_template,
*name,
buffer1[BufferSize];
if ((internal = mem_alloc (sizeof(FileInfoInternal))) == NULL)
return make_error (FileInfo_AllocFailed, 0);
internal->show_info = NULL;
internal->object_id = r->r[1];
if (template->window) {
regs.r[0] = 0;
regs.r[1] = (int) template->window;
if ((e = _kernel_swi (Toolbox_CreateObject, &regs, &regs)) != NULL)
goto clearup1;
internal->sub_object_id = regs.r[0];
} else {
name = "_FileInfo";
if ((new_template = copy_template(name)) == NULL) {
e = make_error (FileInfo_AllocFailed, 0);
goto clearup1;
}
if (template->title) {
DEBUG debug_output ("f","FileInfo: setting title to '%s'\n",template->title);
zap_window (new_template, window.title.indirect_text.buffer, template->title);
zap_window (new_template, window.title.indirect_text.buff_len, template->max_title);
} else {
title = (char *) *read_window (new_template, window.title.indirect_text.buffer);
zap_window (new_template, window.title.indirect_text.buff_len, MAX(template->max_title,strlen (title)+1));
}
/*
internal->utc = * (os_UTC *) &template->date;
*/
regs.r[0] = -1;
regs.r[1] = (int) &template->date;
regs.r[2] = (int) buffer1;
regs.r[3] = BufferSize;
if ((e = _kernel_swi (Territory_ConvertStandardDateAndTime, &regs, &regs)) != NULL)
goto clearup2;
DEBUG debug_output ("f","FileInfo: setting date to '%s'\n",buffer1);
zap_gadget (new_template, DisplayField, FileInfo_DisplayField_Date, text, buffer1);
/*
sprintf (buffer2, "%0d", template->filesize);
DEBUG debug_output ("f","FileInfo: setting filesize to '%s'\n", buffer2);
zap_gadget (new_template, DisplayField, FileInfo_DisplayField_FileSize, text, buffer2);
*/
DEBUG debug_output ("f","FileInfo: setting filename to '%s'\n",template->filename);
zap_gadget (new_template, DisplayField, FileInfo_DisplayField_FileName, text,
template->filename?template->filename:global_untitled);
DEBUG debug_output ("f","FileInfo: setting modified? to '%s'\n",(template->modified) ? global_yes:global_no);
zap_gadget (new_template, DisplayField, FileInfo_DisplayField_Modified, text, ((template->modified) ? global_yes:global_no));
if ((e = create_from_template (new_template, &(internal->sub_object_id))) != NULL) {
goto clearup1;
}
if ((e = aux_set_file_type (internal, template->filetype)) != NULL)
goto clearup1;
if ((e = aux_set_file_size (internal, template->filesize)) != NULL)
goto clearup1;
}
internal->utc = template->date;
internal->flags
= ((template->flags & FileInfo_GenerateShowEvent) ? FileInfoInternal_GenerateShowEvent : 0)
| ((template->flags & FileInfo_GenerateHideEvent) ? FileInfoInternal_GenerateHideEvent : 0);
if (t->object_list) { /* If there are already fileinfos attached to the task ... */
internal->forward = t->object_list;
internal->backward = t->object_list->backward;
t->object_list->backward->forward = internal;
t->object_list->backward = internal;
} else { /* ... if not ... */
regs.r[0] = 0;
regs.r[1] = FileInfo_PostFilter;
regs.r[2] = (int) t;
regs.r[3] = Toolbox_RegisterPostFilter_WimpEvent;
regs.r[4] = (int) events_of_interest;
if ((e = _kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs)) != NULL)
return e;
regs.r[0] = 0;
regs.r[1] = FileInfo_PostFilter;
regs.r[2] = (int) t;
regs.r[3] = Toolbox_RegisterPostFilter_ToolboxEvent;
regs.r[4] = (int) toolbox_events_of_interest;
if ((e = _kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs)) != NULL)
return e;
regs.r[0] = 0;
regs.r[1] = FileInfo_PreFilter;
regs.r[2] = (int) t;
if ((e = _kernel_swi (Toolbox_RegisterPreFilter, &regs, &regs)) != NULL) {
goto clearup1;
}
DEBUG debug_output ("f","FileInfo: PreFilter should have registered ok\n");
t->object_list = internal;
internal->forward = internal;
internal->backward = internal;
}
r->r[0] = (int) internal;
return NULL;
clearup2:
mem_freek (new_template);
clearup1:
mem_freek (internal);
return e;
}
/* 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: delete.c
* Purpose: delete a FileInfo Object
* Author: TGR
* History: 7-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "delete.h"
extern _kernel_oserror *delete_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request to delete an object
* R0 = 1
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* bit 0 set => do not recursively delete the object
* R1 = Object ID
*/
/*
* The Toolbox has already checked that this is not just a delete
* call for a shared Object.
* We delete Object from the list of Objects for this
* task.
* If recursive delete is requested then we also call Toolbox_Delete
* for any Objects "attached" to this Object.
*/
_kernel_oserror *e;
_kernel_swi_regs regs;
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
if (internal->flags & FileInfoInternal_IsShowing) {
/*
if (internal->flags & FileInfoInternal_GenerateHideEvent)
if ((e = dialogue_completed (object_id)) != NULL)
return e;
*/
regs.r[0] = 0;
regs.r[1] = (int) internal->sub_object_id;
if ((e = _kernel_swi (Toolbox_HideObject, &regs, &regs)) != NULL)
return e;
}
regs.r[0] = 0;
regs.r[1] = (int) internal->sub_object_id;
e = _kernel_swi (Toolbox_DeleteObject, &regs, &regs);
if (internal->forward == internal) { /* Unlinking from the list is regarded as imperative */
regs.r[0] = 1; /* No longer interested in events */
regs.r[1] = FileInfo_PostFilter;
regs.r[2] = (int) t;
regs.r[3] = Toolbox_RegisterPostFilter_WimpEvent;
regs.r[4] = (int) events_of_interest;
if ((e = _kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs)) != NULL)
return e; /* register interest in pre-filter */
regs.r[0] = 1; /* No longer interested in events */
regs.r[1] = FileInfo_PostFilter;
regs.r[2] = (int) t;
regs.r[3] = Toolbox_RegisterPostFilter_ToolboxEvent;
regs.r[4] = (int) toolbox_events_of_interest;
_kernel_swi (Toolbox_RegisterPostFilter, &regs, &regs);
regs.r[0] = 1;
regs.r[1] = FileInfo_PreFilter;
regs.r[2] = (int) t;
_kernel_swi (Toolbox_RegisterPreFilter, &regs, &regs);
t->object_list = NULL;
} else {
if (t->object_list == internal) {
t->object_list = internal->forward;
}
internal->forward->backward = internal->backward;
internal->backward->forward = internal->forward;
}
mem_freek (internal);
return e;
}
/* 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: events.c
* Purpose: filters registered with the Toolbox. Events are delivered here.
* Author: TGR
* History: 7-Feb-94: TGR: created from IDJ template
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "twimp.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "events.h"
_kernel_oserror *event_close_window (TaskDescriptor *t, IDBlock *id_block);
_kernel_oserror *event_fileinfo_to_show (ObjectID object_id);
/*
_kernel_oserror *event_menus_deleted (void);
*/
extern _kernel_oserror *events_postfilter (_kernel_swi_regs *r)
{
/*
* called from the main Toolbox postfilter, when an event happens which
* this module has expressed an interest in.
* R0 = Wimp event reason code
* R1 ->client's Wimp event block
* R2 = Task Descriptor of task interested in the event
* R3 ->6-word "ID block" as passed to Toolbox_Initialise
*
*/
/*
* This function gets a pointer to the task interested in the event in
* R2 (since this was the value passed to Toolbox_RegisterPostFilter).
* If the event is dealt with by this module (eg ID block gets updated).
* then set R0 to non-null before return.
*/
_kernel_oserror *e;
_kernel_swi_regs regs;
wimp_PollBlock *block = (wimp_PollBlock *)r->r[1];
IDBlock *id_block = (IDBlock *)r->r[3];
int event_code = r->r[0];
FileInfoInternal *internal;
TaskDescriptor *t = (TaskDescriptor *) r->r[2];
DEBUG debug_output ("e","FileInfo: Postfilter entered, received wimp event code = 0x%x\n",event_code);
r->r[0] = 0;
if (event_code == wimp_ETOOLBOX_EVENT) {
DEBUG debug_output ("e","FileInfo: handling a toolbox event, code = 0x%x\n",block->toolbox_event.hdr.event_code);
switch (block->toolbox_event.hdr.event_code) {
case FileInfo_AboutToBeShown:
regs.r[0] = 0;
regs.r[1] = (int) id_block->self_id;
if ((e = _kernel_swi (Toolbox_GetInternalHandle, &regs, &regs)) != NULL)
return e;
global_next = (FileInfoInternal *) regs.r[0];
break;
case Window_HasBeenHidden:
{
_kernel_swi_regs regs;
ToolboxEvent toolbox_event;
if ((internal = find_internal (t, id_block->self_id)) == NULL)
return NULL;
internal->flags &= ~FileInfoInternal_IsShowing;
if (~internal->flags & FileInfoInternal_GenerateHideEvent) return NULL;
regs.r[0] = 0;
regs.r[1] = (int) internal->object_id;
regs.r[2] = -1;
regs.r[3] = (int) &toolbox_event;
toolbox_event.hdr.size = sizeof (FileInfo_DialogueCompleted_Event);
toolbox_event.hdr.event_code = FileInfo_DialogueCompleted;
toolbox_event.hdr.flags = 0;
return _kernel_swi (Toolbox_RaiseToolboxEvent, &regs, &regs);
}
}
}
return NULL;
}
extern _kernel_oserror *events_prefilter (_kernel_swi_regs *r)
{
/*
* called from the main Toolbox prefilter, when Wimp_Poll is called.
* R0 = mask passed to Wimp_Poll
* R1 ->client's poll block passed to Wimp_Poll
* R2 = Task Descriptor.
*
*/
/*
* This function gets a pointer to the current task in
* R2 (since this was the value passed to Toolbox_RegisterPreFilter).
* This function can enable additional events by zero-ing bits in
* r->r[0]
*/
IGNORE (r);
return (global_next) ? show_actual() : NULL;
}
/*
_kernel_oserror *event_menus_deleted (void) {
_kernel_oserror *e;
_kernel_swi_regs regs;
FileInfoInternal *internal;
if (global_menu) {
regs.r[0] = 0;
regs.r[1] = (int) global_menu;
global_menu = 0;
if ((e = _kernel_swi (Toolbox_GetInternalHandle, &regs, &regs)) != NULL)
return e;
internal = (FileInfoInternal *) regs.r[0];
internal->flags &= ~FileInfoInternal_IsShowing;
if (internal->flags & FileInfoInternal_GenerateHideEvent) {
return dialogue_completed (global_menu);
}
}
return NULL;
}
*/
/* 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: getstate.c
* Purpose: return state for a FileInfo Object
* Author: TGR
* History: 26-Apr-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.generic.h"
#include "object.h"
#include "auxiliary.h"
#include "task.h"
#include "getstate.h"
extern _kernel_oserror *getstate_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request for info about an object
* R0 = 5
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
*/
/*
* return state in R0
*
*/
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
r->r[0] = (internal->flags & FileInfoInternal_IsShowing) ? Toolbox_GetObjectState_Showing : 0;
IGNORE(t);
return NULL;
}
/* 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: hide.c
* Purpose: hide a FileInfo Object
* Author: TGR
* History: 7-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "hide.h"
extern _kernel_oserror *hide_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request to hide an object
* R0 = 4
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
*
*/
/*
* Remove the object from view. For efficiency, we should stop expressing
* interest in any events which can't happen whilst the Object is
* hidden.
*
*/
_kernel_oserror *e;
_kernel_swi_regs regs;
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
if (~internal->flags & FileInfoInternal_IsShowing)
return NULL;
internal->flags &= ~FileInfoInternal_IsShowing;
regs.r[0] = 0;
regs.r[1] = (int) internal->sub_object_id;
if ((e = _kernel_swi (Toolbox_HideObject, &regs, &regs)) != NULL)
return e;
IGNORE(t);
return NULL;
/*
return (internal->flags & FileInfoInternal_GenerateHideEvent) ? dialogue_completed (object_id) : 0;
*/
}
/* 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: main.c
* Purpose: main module of a FileInfo Object module
* Author: TGR
* History: 7-Feb-94: TGR: created from IDJ template
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "rmensure.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "create.h"
#include "delete.h"
#include "copy.h"
#include "show.h"
#include "hide.h"
#include "getstate.h"
#include "miscop.h"
#include "events.h"
#include "task.h"
#include "main.h"
#define MAX_CLASS_SWI_METHODS 7
static _kernel_oserror *(*class_swi_methods [MAX_CLASS_SWI_METHODS])(_kernel_swi_regs *r, TaskDescriptor *t) =
{
create_object,
delete_object,
NULL, /*copy_object,*/
show_object,
hide_object,
getstate_object,
miscop_object
};
/* +++++++++++++++++++++++++++++++++ finalisation code +++++++++++++++++++++++++++++++++ */
#ifdef ROM
static _kernel_oserror *__ROM;
#endif
extern _kernel_oserror *FileInfo_finalise (int fatal, int podule, void *pw)
{
_kernel_swi_regs regs;
#ifndef ROM
extern int messages_file(void);
extern int res_file(void);
#endif
IGNORE(fatal);
IGNORE(podule);
IGNORE(pw);
/*
* refuse to finalise if tasks active
*/
if (task_any_active())
return make_error (FileInfo_TasksActive, 0);
/*
* close our messages file
*/
messages_file_close();
#ifndef ROM
/*
* ... and deregister from ResourceFS
*/
regs.r[0] = messages_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
regs.r[0] = res_file();
_kernel_swi (ResourceFS_DeregisterFiles, &regs, &regs);
#endif
/* deregister object module */
regs.r[0] = 0;
regs.r[1] = FileInfo_ObjectClass;
_kernel_swi(Toolbox_DeRegisterObjectModule, &regs, &regs);
/*
* free up memory we may have left allocated
*/
if (global_yes) mem_freek (global_yes);
if (global_no) mem_freek (global_no);
mem_free_all ();
#ifdef ROM
if(!__ROM) _swix(0xa2c41, 0);
#endif
return NULL;
}
/* ++++++++++++++++++++++++++++++++ initialisation code +++++++++++++++++++++++++++++++ */
extern _kernel_oserror *FileInfo_init(char *cmd_tail, int podule_base, void *pw)
{
char *filename;
_kernel_swi_regs regs;
_kernel_oserror *e;
int buffer_size;
#ifndef ROM
extern int messages_file(void);
extern int res_file(void);
#endif
IGNORE(cmd_tail);
IGNORE(podule_base);
IGNORE(pw);
#ifdef ROM
__ROM = _swix(0xa2c43, _IN(0), pw);
#endif
DEBUG debug_set_var_name("FileInfo$Debug");
if ((e = rmensure ("Window", "Toolbox.Window", "1.26")) != NULL) return e;
/*
* register our messages file with Resource FS and MessageTrans
*/
#ifndef ROM
DEBUG debug_output ("M","FileInfo: registering messages file\n");
regs.r[0] = messages_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
DEBUG debug_output ("M","FileInfo: registering resource file\n");
regs.r[0] = res_file();
if ((e = _kernel_swi (ResourceFS_RegisterFiles, &regs, &regs)) != NULL)
return e;
#endif
if (getenv ("FileInfo$Path") == NULL)
filename = "Resources:Resources.FileInfo.Messages";
else
filename = "FileInfo:Messages";
DEBUG debug_output ("M","FileInfo: opening messages file\n");
if ((e = messages_file_open (filename)) != NULL)
return e;
buffer_size = 0;
DEBUG debug_output ("M","FileInfo: looking up 'Unt'\n");
if ((e = messages_file_lookup ("Unt", 0, &buffer_size, 0)) != NULL)
return e;
if ((global_untitled = mem_alloc (buffer_size)) == NULL)
return make_error(FileInfo_AllocFailed,0);
if ((e = messages_file_lookup ("Unt", global_untitled, &buffer_size, 0)) !=NULL)
return e;
buffer_size = 0;
DEBUG debug_output ("M","FileInfo: looking up 'YES'\n");
if ((e = messages_file_lookup ("YES", 0, &buffer_size, 0)) != NULL)
return e;
if ((global_yes = mem_alloc (buffer_size)) == NULL)
return make_error(FileInfo_AllocFailed,0);
if ((e = messages_file_lookup ("YES", global_yes, &buffer_size, 0)) !=NULL)
return e;
buffer_size = 0;
DEBUG debug_output ("M","FileInfo: looking up 'NO' (1) \n");
if ((e = messages_file_lookup ("NO", 0, &buffer_size, 0)) != NULL)
return e;
DEBUG debug_output ("M","FileInfo: looking up 'NO' (mem_alloc)\n");
if ((global_no = mem_alloc (buffer_size)) == NULL)
return make_error(FileInfo_AllocFailed,0);
DEBUG debug_output ("M","FileInfo: looking up 'NO' (2) \n");
if ((e = messages_file_lookup ("NO", global_no, &buffer_size, 0)) !=NULL)
return e;
DEBUG debug_output ("M","FileInfo: looking up 'NO' (end)\n");
/* open the fileinfo template file */
if (getenv ("FileInfo$Path") == NULL)
filename = "Resources:Resources.FileInfo.Res";
else
filename = "FileInfo:Res";
DEBUG debug_output ("M","FileInfo: registering ...\n");
/* register here with the Toolbox as an Object Module */
regs.r[0] = 0;
regs.r[1] = FileInfo_ObjectClass;
regs.r[2] = FileInfo_ClassSWI;
regs.r[3] = (int) filename;
if ((e = _kernel_swi(Toolbox_RegisterObjectModule, &regs, &regs)) != NULL)
return e;
return NULL;
}
/* +++++++++++++++++++++++++++++++++ service handler code ++++++++++++++++++++++++++++++ */
extern void FileInfo_services(int service_number, _kernel_swi_regs *r, void *pw)
{
_kernel_swi_regs regs;
char *filename;
IGNORE(pw);
switch (service_number)
{
case Service_ToolboxTaskDied:
/*
* task dying - r0 holds task handle
*/
task_remove (r->r[0]);
break;
case Service_ToolboxTaskBorn:
/* Toolbox task has just started R0 == wimp task handle */
/*
* create a new "task descriptor"
*/
task_add (r->r[0]);
break;
case Service_ToolboxStarting:
/*
* register with the Toolbox as an Object Module
*/
/* open the FileInfo template file */
if (getenv ("FileInfo$Path") == NULL)
filename = "Resources:Resources.FileInfo.Res";
else
filename = "FileInfo:Res";
/* register here with the Toolbox as an Object Module */
regs.r[0] = 0;
regs.r[1] = FileInfo_ObjectClass;
regs.r[2] = FileInfo_ClassSWI;
regs.r[3] = (int) filename;
_kernel_swi (Toolbox_RegisterObjectModule, &regs, &regs);
break;
default:
break;
}
}
/* ++++++++++++++++++++++++++++++++++++++ SWI code +++++++++++++++++++++++++++++++++++++ */
extern _kernel_oserror *FileInfo_SWI_handler(int swi_no, _kernel_swi_regs *r, void *pw)
{
_kernel_oserror *e = NULL;
TaskDescriptor *t;
IGNORE(pw);
switch (swi_no + FileInfo_SWIChunkBase)
{
case FileInfo_ClassSWI:
if (r->r[0] < 0 || r->r[0] >= MAX_CLASS_SWI_METHODS)
{
return make_error_hex(FileInfo_NoSuchMethod,1,r->r[0]);
}
else
{
t = task_find (r->r[3]);
if (t == NULL)
{
return make_error_hex(FileInfo_NoSuchTask,1,r->r[3]);
}
e = (*class_swi_methods[r->r[0]])(r, t);
}
break;
case FileInfo_PostFilter:
e = events_postfilter (r);
break;
case FileInfo_PreFilter:
e = events_prefilter (r);
break;
default:
break;
}
return e;
}
#if debugging
/* ++++++++++++++++++++++++++++++++++++++ star commands ++++++++++++++++++++++++++++++++++++*/
extern _kernel_oserror *FileInfo_commands(char *arg_string, int argc, int cmd_no, void *pw)
{
IGNORE(argc);
IGNORE(pw);
IGNORE(arg_string);
switch (cmd_no)
{
case 0:
mem_print_list();
break;
default:
break;
}
return NULL;
}
#endif
/* 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: miscop.c
* Purpose: miscellanaous operations on a FileInfo Object
* Author: Timothy G Roddis
* History: 8-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "objects.window.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "miscop.h"
_kernel_oserror *fileinfo_get_modified (_kernel_swi_regs *r);
_kernel_oserror *fileinfo_get_file_size (_kernel_swi_regs *r);
_kernel_oserror *fileinfo_set_date (_kernel_swi_regs *r);
#define BufferSize 256
#define MAX_MISCOP_METHODS 13
/*
static _kernel_oserror *(*fileinfo_miscop_methods [MAX_MISCOP_METHODS]) (_kernel_swi_regs *r, TaskDescriptor *t) = {
fileinfo_get_window_id,
fileinfo_set_modified,
fileinfo_get_modified,
fileinfo_set_file_type,
fileinfo_get_file_type,
fileinfo_set_filename,
fileinfo_get_filename,
fileinfo_set_file_size,
fileinfo_get_file_size,
fileinfo_set_date,
fileinfo_get_date,
fileinfo_set_title,
fileinfo_get_title
};
*/
extern _kernel_oserror *miscop_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* do a "miscellaneous (ie object-specific) operation on an object
* R0 = 6
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
* R2 = method code
* R3-R9 method-specific data
*/
/*
* This is the routine which deals with all object-specific operations.
*
*
*/
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
ObjectID sub_object_id = internal->sub_object_id;
int method = user_regs->r[2];
DEBUG debug_output ("y","FileInfo: miscop method = 0x%x\n",method);
if (method < 0 || method >= MAX_MISCOP_METHODS) {
return make_error_hex(FileInfo_NoSuchMiscOpMethod,1,method);
}
switch (method) {
case FileInfo_GetWindowID:
user_regs->r[0] = (int) internal->sub_object_id;
return NULL;
case FileInfo_SetModified:
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_SetValue;
regs.r[3] = FileInfo_DisplayField_Modified;
regs.r[4] = (int) ((user_regs->r[3])?global_yes:global_no);
return _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs);
case FileInfo_GetModified:
return fileinfo_get_modified (r);
case FileInfo_SetFileType:
return aux_set_file_type (internal, user_regs->r[3]);
case FileInfo_GetFileType:
user_regs->r[0] = internal->filetype;
return NULL;
case FileInfo_SetFileName:
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_SetValue;
regs.r[3] = FileInfo_DisplayField_FileName;
regs.r[4] = (user_regs->r[3])?(user_regs->r[3]):((int) global_untitled);
return _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs);
case FileInfo_GetFileName:
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_GetValue;
regs.r[3] = FileInfo_DisplayField_FileName;
regs.r[4] = user_regs->r[3];
regs.r[5] = user_regs->r[4];
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
user_regs->r[3] = regs.r[4];
user_regs->r[4] = regs.r[5];
return NULL;
case FileInfo_SetFileSize:
return aux_set_file_size (internal, user_regs->r[3]);
case FileInfo_GetFileSize:
return fileinfo_get_file_size (r);
case FileInfo_SetDate:
return fileinfo_set_date (r);
case FileInfo_GetDate:
{
os_UTC *utc = (os_UTC *) user_regs->r[3];
*utc = internal->utc;
DEBUG debug_output ("m","FileInfo: utc = 0x%x, 0x%x\n", utc->low, utc->high);
return NULL;
}
case FileInfo_SetTitle:
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = Window_SetTitle;
regs.r[3] = user_regs->r[3];
return _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs);
case FileInfo_GetTitle:
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = Window_GetTitle;
regs.r[3] = user_regs->r[3];
regs.r[4] = user_regs->r[4];
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
DEBUG if (user_regs->r[3]) debug_output ("m","FileInfo: title is '%s'",user_regs->r[3]);
user_regs->r[4] = regs.r[4];
return NULL;
}
IGNORE(t);
return NULL;
}
_kernel_oserror *fileinfo_get_modified (_kernel_swi_regs *r) {
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
ObjectID sub_object_id = internal->sub_object_id;
char *buffer;
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_GetValue;
regs.r[3] = FileInfo_DisplayField_Modified;
regs.r[4] = 0;
regs.r[5] = 0;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
if ((buffer = mem_alloc (regs.r[5])) == NULL)
return make_error (FileInfo_AllocFailed, 0);
regs.r[0] = 0;
regs.r[4] = (int) buffer;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
DEBUG debug_output ("y","FileInfo: Modified? '%s'\n",buffer);
if (!(strcmp (buffer,global_yes))) {
user_regs->r[0] = 1;
} else {
user_regs->r[0] = 0;
}
/* IDJ: 6-Feb-95: bug-fix AQU-01197 - memory leak */
if (buffer)
mem_freek (buffer);
return NULL;
}
_kernel_oserror *fileinfo_get_file_size (_kernel_swi_regs *r) {
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
ObjectID sub_object_id = internal->sub_object_id;
char *buffer;
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_GetValue;
regs.r[3] = FileInfo_DisplayField_FileSize;
regs.r[4] = 0;
regs.r[5] = 0;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
return e;
if ((buffer = mem_alloc (regs.r[5])) == NULL)
return make_error (FileInfo_AllocFailed, 0);
regs.r[0] = 0;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_GetValue;
regs.r[3] = FileInfo_DisplayField_FileSize;
regs.r[4] = (int) buffer;
if ((e = _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs)) != NULL)
goto clearup1;
DEBUG debug_output ("m","FileInfo: filesize = '%s'\n",buffer);
sscanf (buffer, "%d", &user_regs->r[0]);
mem_freek (buffer);
return NULL;
clearup1:
mem_freek (buffer);
return e;
}
_kernel_oserror *fileinfo_set_date (_kernel_swi_regs *r) {
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
ObjectID sub_object_id = internal->sub_object_id;
char buffer[BufferSize];
internal->utc = * (os_UTC *) user_regs->r[3];
regs.r[0] = -1;
regs.r[1] = user_regs->r[3];
regs.r[2] = (int) buffer;
regs.r[3] = BufferSize;
if ((e = _kernel_swi (Territory_ConvertStandardDateAndTime, &regs, &regs)) != NULL)
return e;
regs.r[1] = (int) sub_object_id;
regs.r[2] = DisplayField_SetValue;
regs.r[0] = 0;
regs.r[3] = FileInfo_DisplayField_Date;
regs.r[4] = (int) buffer;
return _kernel_swi (Toolbox_ObjectMiscOp, &regs, &regs);
}
/* 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: show.c
* Purpose: show a FileInfo Object
* Author: TGR
* History: 7-Feb-94: TGR: created
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.window.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
#include "show.h"
extern _kernel_oserror *show_object (_kernel_swi_regs *r, TaskDescriptor *t)
{
/*
* request to show an object
* R0 = 3
* R1 = Object ID
* R2 = internal handle returned when Object was created
* R3 = wimp task handle of caller (use to identify task descriptor)
* R4 -> user regs R0-R9
* R0 = flags
* R1 = Object ID
* R2 = "show type"
* 0 => default place
* 1 => R3 points to buffer with full data for showing
* 2 => R3 points to buffer with coordinates
* R3 = 0
* OR R3 -> buffer giving Object-specific data for showing this
* Object
* R4 = Parent Object ID
* R5 = Parent Component ID
*/
/*
* Function to "display" an Object on the screen. If R2 == 0, then
* display in default place.
* If Object has bit set to say warn before show, then we should just
* send Toolbox Event, and wait for the next call to Wimp_Poll after
* the event is delivered before the Object is actually shown
* (ie catch it in the prefilter).
*
*/
_kernel_oserror *e;
_kernel_swi_regs regs,
*user_regs = (_kernel_swi_regs *) r->r[4];
ObjectID object_id = (ObjectID) r->r[1];
FileInfoInternal *internal = (FileInfoInternal *) r->r[2];
FileInfo_AboutToBeShown_Event
*about_to_be_shown;
ToolboxEvent toolbox_event;
global_menu = (user_regs->r[0] & 3) ? object_id : global_menu;
if (internal->show_info) mem_freek (internal->show_info);
internal->flags &= ~FileInfoInternal_SubMenuSemantics
& ~FileInfoInternal_MenuSemantics;
internal->flags |= ((user_regs->r[0] & 1) ? FileInfoInternal_MenuSemantics : 0)
| ((user_regs->r[0] & 2) ? FileInfoInternal_SubMenuSemantics : 0);
DEBUG debug_output ("s", "FileInfo: show type %d\n",user_regs->r[2]);
switch (user_regs->r[2]) {
case 1: /* full show */
internal->flags |= FileInfoInternal_FullInfoShow;
internal->show_info = mem_alloc (sizeof (WindowShowObjectBlock));
internal->show_info->window_info = *(WindowShowObjectBlock *) user_regs->r[3];
/* NB: failure to malloc space will result in a default show */
break;
case 2: /* coords */
internal->flags &= ~FileInfoInternal_FullInfoShow;
internal->show_info = mem_alloc (sizeof (Coordinates));
internal->show_info->coords = *(Coordinates *) user_regs->r[3];
break;
default: /* default (!) */
internal->show_info = NULL;
break;
}
if (internal->flags & FileInfoInternal_GenerateShowEvent) {
regs.r[0] = 0; /* flags*/
regs.r[1] = r->r[1]; /* Object id */
regs.r[2] = -1; /* Component id */
regs.r[3] = (int) &toolbox_event;
toolbox_event.hdr.size = sizeof (FileInfo_AboutToBeShown_Event);
toolbox_event.hdr.event_code = FileInfo_AboutToBeShown;
toolbox_event.hdr.flags = user_regs->r[0];
about_to_be_shown = (FileInfo_AboutToBeShown_Event *) &toolbox_event;
about_to_be_shown->show_type = user_regs->r[2];
if (user_regs->r[2] == 1) {
about_to_be_shown->info.full = *((WindowShowObjectBlock *) user_regs->r[3]);
} else if (user_regs->r[2] == 2) {
about_to_be_shown->info.coords.x = ((int *) user_regs->r[3])[0];
about_to_be_shown->info.coords.y = ((int *) user_regs->r[3])[1];
}
e = _kernel_swi (Toolbox_RaiseToolboxEvent, &regs, &regs);
return e; /* return here whatever */
}
global_next = internal;
if ((e = show_actual ()) != NULL)
return e;
internal->flags |= FileInfoInternal_IsShowing;
IGNORE(t);
return NULL;
}
/* 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: task.c
* Purpose: task handling for the FileInfo module
* Author: TGR
* History: 9-Feb-94: TGR: created from IDJ template
*
*/
#include <stdio.h>
#include <stdlib.h>
#include "kernel.h"
#include "swis.h"
#include "const.h"
#include "macros.h"
#include "services.h"
#include "debug.h"
#include "mem.h"
#include "messages.h"
#include "objects.toolbox.h"
#include "objects.fileinfo.h"
#include "auxiliary.h"
#include "object.h"
#include "task.h"
/*
* This module has a linked list of client tasks.
* task_add gets called when a Service_ToolboxTaskBorn
* service call goes round.
* The task is removed when the Service_WimpCloseDown is
* received.
* Each task keeps an Object list
*/
static TaskDescriptor *task__list = NULL;
extern BOOL task_any_active(void)
{
return task__list != NULL;
}
extern TaskDescriptor *task_find (int task_handle)
{
/*
* Function to return a TaskDescriptor corresponding to
* a task with a given Wimp handle
*/
TaskDescriptor *t;
t = task__list;
while (t != NULL)
{
if (t->task_handle == task_handle)
break;
t = t->next;
}
return t;
}
extern void task_remove (int task_handle)
{
/*
* Function to remove a task descriptor from the list, given its
* Wimp task handle. Memory is freed, and we also delete any objects
* owned by the exiting task.
*/
TaskDescriptor *t = task__list;
TaskDescriptor *prev_t = NULL, *next = NULL;
FileInfoInternal *i,*j;
while (t != NULL)
{
next = t->next;
if (t->task_handle == task_handle)
{
/*
* remove this task's object's list
*/
if (t->object_list != NULL) {
i = t->object_list;
do {
j = i->forward;
if (global_menu == i->object_id)
global_menu = NULL;
if (global_next == i)
global_next = NULL;
if (i->show_info) mem_freek (i->show_info);
mem_freek (i);
} while ((i=j) != t->object_list);
}
/*
* remove the task descriptor itself
*/
if (t == task__list)
task__list = next;
else
prev_t->next = next;
mem_free (t, "freeing task descriptor(fileinfo)");
return;
}
prev_t = t;
t = next;
}
}
extern void task_add (int task_handle)
{
/*
* Function to add a task descriptor to the list of active
* Toolbox tasks.
*/
/*
* extra safety check, we make sure that the task is not already there!
*/
TaskDescriptor *new_t;
if (task_find (task_handle) != NULL)
return;
/*
* add task to list
*/
if ((new_t = mem_allocate (sizeof(TaskDescriptor), "task descriptor")) == NULL)
{
raise_toolbox_error (FileInfo_AllocFailed,0,-1,0);
return;
}
new_t->task_handle = task_handle;
new_t->next = task__list;
task__list = new_t;
}
; 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 FileInfo Object module
; Author: TGR
; History: 7-Feb-94: TGR: created from IDJ template
; PRODUCT RELEASE
; 6-Feb-95: IDJ: version 0.14 fixes AQU-01197
;
initialisation-code: FileInfo_init
finalisation-code: FileInfo_finalise
service-call-handler: FileInfo_services 0x44ec1, 0x44ec2, 0x44ec3
title-string: FileInfo
help-string: FileInfo 0.14
command-keyword-table: FileInfo_commands
FileInfo_Memory()
swi-chunk-base-number: 0x82ac0
swi-handler-code: FileInfo_SWI_handler
swi-decoding-table: FileInfo, ClassSWI, PostFilter, PreFilter
; 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 FileInfo Object module
; Author: TGR
; History: 7-Feb-94: TGR: created from IDJ template
; PRODUCT RELEASE
; 6-Feb-95: IDJ: version 0.14 fixes AQU-01197
;
initialisation-code: FileInfo_init
finalisation-code: FileInfo_finalise
service-call-handler: FileInfo_services 0x44ec1, 0x44ec2, 0x44ec3
title-string: FileInfo
help-string: FileInfo 0.14
swi-chunk-base-number: 0x82ac0
swi-handler-code: FileInfo_SWI_handler
swi-decoding-table: FileInfo, ClassSWI, PostFilter, PreFilter
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment