initial checkin of FilePort/NullPort sources

This commit is contained in:
gdr 1997-12-19 07:54:52 +00:00
parent c1f439e0a7
commit 0e5599af83
43 changed files with 1139 additions and 0 deletions

View File

@ -0,0 +1 @@
FilePort is a Port Driver that simply prints to a file (instead of a printer port). If you need to capture output from a printer driver to print something on a printer you don't own then this port driver might be what you're looking for. The only restriction that this software has is that appletalk printer drivers aren't supported (so don't try using this port driver with the laserwriter driver, you'll crash into the monitor). NullPort is another Port Driver - this port driver doesn't print to anything. It seems kind of strange, but this is actually very usefull. Especially when you want to time the performance of a printer driver. Almost everyone assumes the printer driver is the slow part, when actually the slowest portions of printing are typically the transfering of data to the printer and actually printing. This port driver can be used by anyone to time just about any printer driver (again, the laserwriter driver isn't supported). Requirements: An Apple IIGS with probably 1.5 meg of memory or more, possibly a hard disk drive and system software 5.0.4 or later. The FilePort driver uses a 64k buffer so you'll need at least that much free memory to be able to use it to print to a file. Installation: Copy all of the files in this archive to your system disk and put them in your system:drivers folder. Select the direct connect printer control panel document and choose FilePort (or NullPort) from the port driver list. To change the folder where printer data files will be generated, simply edit the FilePort.Data file with any text editor and change the pathname. These programs are FreeWare - Do anything you want to with them. The sources to these programs are available to programmers that are interested - simply send me a blank diskette (3.5" only) and a self addressed and stamped return diskette mailer. The sources are a collection or Orca/C and Orca/M. That brings up the runtime libraries of Orca/C so here goes: This program contains material from the Orca/C Run-Time Libraries, copyright 1987-1991 by Byte Works, Inc. Used with permission. I would also like Apple II DTS and Development for their Technotes on printer port drivers - without them I wouldn't have been able to write these drivers. If your computer does something strange with this software then please tell me about it - I'd be interested in what went wrong. If you want to get in contact with me, send regular mail to: Kopriha Software c/o Dave Koppper 81 Main Boulevard Shrewsbury, MA 01545-3146 My electronic mail addresses are: Internet: dave@mystie.webo.dg.com or dave%mystie.webo.dg.com@relay.cs.net GEnie: D.Kopper

View File

@ -0,0 +1 @@
# # $Id: Makefile,v 1.1 1997/12/19 07:54:44 gdr Exp $ # # Devin Reade, December 1997 ODIR = obj INCLUDE = ../includes CFLAGS += -I$(INCLUDE) -w -v OBJS = $(ODIR)/port.o $(ODIR)/c.port.o $(ODIR)/errors.o $(ODIR)/errormsgs.o LDLIBS = -l ../support/libdvr HDRS = $(INCLUDE)/ks.fileio.e $(INCLUDE)/ks.defines.h \ $(INCLUDE)/portable.c.h $(INCLUDE)/ks.routines.h \ $(INCLUDE)/ks.memory.h build: $(ODIR) FilePort FilePort: $(OBJS) $(CC) -o $@ $(LDFLAGS) $(OBJS) $(LDLIBS) chtyp -t187 -a2 $@ # 187 == 0xBB $(ODIR): install -d $(ODIR) $(ODIR)/%.o: %.c; $(CC) -o $@ -c $(CFLAGS) $< $(ODIR)/%.o: %.asm; $(CC) -o $@ -c $(CFLAGS) $< port.o:: port.macros c.port.o:: $(HDRS) errors.h errors.o:: $(INCLUDE)/portable.c.h errors.h

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
;*********************************************************************** ;* ;* Copyright (C) Kopriha Software, 1990 - 1991 ;* All rights reserved. ;* Licensed material -- property of Kopriha Software ;* ;* This software is made available solely pursuant to the terms ;* of a Kopriha Software license agreement which governs its use. ;* ;* ;* Memory copy of copyright notice ;* Error messages for FilePort Port Driver ;* ;* ;* Description: ;* The copyright notice is included for anyone that gets a copy of ;* this software and decides to disassemble it. ;* ;* The error messages are defined in assembler, because Orca/C makes ;* the errors take up extra space (i.e.: All strings must be of a ;* fixed length). In assembler, no such restriction exists... ;* ;* ;* History: April 13 Dave Created this module ;* ;* ;* ;*********************************************************************** case on Set case sensitivity in assembler objcase on Set case sensitivity in object gen off List generated code trace off List all macro generation dummy start Throw away *.root file end ;*********************************************************************** ;* copyright_strings data ;* ;*********************************************************************** ; First a copyright notice that will be in our executable... dc c'Copyright (C) Kopriha Software, 1990 - 1991 ' dc c'All rights reserved. ' dc c'Licensed material -- property of Kopriha Software ' dc c'This software is made available solely pursuant to the terms ' dc c'of a Kopriha Software license agreement which governs its use. ' dc c'**** If you are reading this message then I''ll assume that you ' dc c'are disassembling this program - Good Luck! It is a collection ' dc c'of Orca/C and Orca/M. If you would like a copy of the sources ' dc c'then send a self addressed diskette mailer with a ProDOS formatted ' dc c'diskette to me: Kopriha Software, c/o Dave Kopper, 81 Main ' dc c'Boulevard, Shrewsbury, MA 01545-3146 ****' ; Define pointers to all the error messages... error_strings entry dc a4'E0' dc a4'E1' dc a4'E2' dc a4'E3' dc a4'E4' dc a4'E5' dc a4'E6' dc a4'E7' dc a4'E8' dc a4'E9' dc a4'E10' dc a4'E11' dc a4'EI' ; Now define all the error message strings... E0 dc c'I can''t set the buffer size correctly',i1'0' E1 dc c'I can''t open the configuration file {FilePort.Data}',i1'0' E2 dc c'I can''t allocate the pathname buffer',i1'0' E3 dc c'I can''t read the configuration file {FilePort.Data}',i1'0' E4 dc c'I can''t open the FilePort output directory',i1'0' E5 dc c'I can''t get the FilePort output directory count',i1'0' E6 dc c'I can''t get the next FilePort output directory entry',i1'0' E7 dc c'I can''t create the FilePort output file. ' dc c'There are too many printer data files in the ' dc c'FilePort output directory. Delete at least one and ' dc c'print your document again.',i1'0' E8 dc c'I can''t create a FilePort output file',i1'0' E9 dc c'I can''t open the FilePort output file',i1'0' E10 dc c'I can''t write to the FilePort output file',i1'0' E11 dc c'The line printer daemon is not active',i1'0' EI dc c'Oops... Invalid error message number (programmer error)',i1'0' end ; End of Error message definitions

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1991 * All Rights Reserved * * Errors.CC * * Description: * This module is the heart of the file support of the * printer port driver. * * * Table of Contents: * * error_dialog . . . . . . . . . Display an error dialog for * our user - return whatever * button they click on. * * * History:April 13, 1991 Dave Created this file * */ #pragma noroot /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #include <stdio.h> #include "errors.h" #ifndef __WINDOW__ #include <Window.h> #endif char error_string1[80]; Pointer substitute_array[10]; extern Pointer error_strings[NUMBER_OF_ERROR_CODES+1]; /* ****************************************************************** * * error_dialog - display an error dialog and return the selected * * button (typically the 'Ok' button). * * * * History: April 13, 1991 Dave Created this routine * * ****************************************************************** */ #define ROUTINE_NAME "error_dialog" Word error_dialog(Word error_message, Word error_code) { Word button; /* ************************************************************** * * Check for validity of the error code - if it is not a known * * error code then we will use the 'invalid error' message. * * ************************************************************** */ if ((error_message < 0) || (error_message > NUMBER_OF_ERROR_CODES)) { error_message = NUMBER_OF_ERROR_CODES+1; }; /* ************************************************************** * * Setup the substitution strings... * * ************************************************************** */ /* ************************************************************** * * Check if the window manager is active or not... * * ************************************************************** */ if (WindStatus() != 0) { /* ********************************************************** * * The window manager is available... so we are allowed to * * put up a simple alert window. Setup the substitution * * array and put up the dialog... * * ********************************************************** */ if (error_message == TOO_MANY_SPOOLFILES) { sprintf(error_string1, "32/FilePort error - *0/^#0", error_code); } else { sprintf(error_string1, "32/FilePort error - *0 (error code $%X)/^#0", error_code); }; substitute_array[0] = (Pointer) error_strings[ ((error_message >= 0) || (error_message < NUMBER_OF_ERROR_CODES)) ? error_message : (NUMBER_OF_ERROR_CODES+1)]; button = AlertWindow((Word) 0, (Pointer) &substitute_array, (Ref) error_string1); } else /* ********************************************************** * * The window manager isn't active... that means we can't * * put up a simple alertwindow... print the error strings * * out to standard out... lets hope a user sees it. * * ********************************************************** */ { printf("FilePort error - %s", (char *) error_strings[ ((error_message >= 0) || (error_message < NUMBER_OF_ERROR_CODES)) ? error_message : (NUMBER_OF_ERROR_CODES+1)]); if (error_message != TOO_MANY_SPOOLFILES) { printf(" (error code $%X)\n", error_code); }; button = 0; } /* ************************************************************** * * Return the button that was pressed. * * ************************************************************** */ return(button); } /* End of error_dialog() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1991 * All Rights Reserved * * Errors.H * * Description: This include file contains all the error * code definitions required for this program. * * * Table of contents: * * Macros: * * ERROR_DIALOG() . . . . . . . . Display an error dialog and * wait for the user to choose * an option (usually only one). * * * History:April 13, 1991 Dave Created this file * */ #ifndef _ERROR_ #define _ERROR_ #ifndef __TYPES__ #include <types.h> #endif #ifndef _PORTABLE_C_ #include "Portable.C.h" #endif /* ****************************************************************** * * Error code definitions for this product: * * ****************************************************************** */ #define BAD_BUFFER_SIZE 0 #define CANT_OPEN_CONFIG_FILE BAD_BUFFER_SIZE+1 #define CANT_ALLOCATE_PATHNAME CANT_OPEN_CONFIG_FILE+1 #define CANT_READ_PATHNAME CANT_ALLOCATE_PATHNAME+1 #define CANT_OPEN_DIR CANT_READ_PATHNAME+1 #define CANT_GET_ENTRY_COUNT CANT_OPEN_DIR+1 #define CANT_GET_NEXT_FILE CANT_GET_ENTRY_COUNT+1 #define TOO_MANY_SPOOLFILES CANT_GET_NEXT_FILE+1 #define CANT_CREATE_SPOOL_FILE TOO_MANY_SPOOLFILES+1 #define CANT_OPEN_SPOOL_FILE CANT_CREATE_SPOOL_FILE+1 #define CANT_WRITE_DATA CANT_OPEN_SPOOL_FILE+1 #define DAEMON_NOT_ACTIVE CANT_WRITE_DATA+1 #define NUMBER_OF_ERROR_CODES DAEMON_NOT_ACTIVE+1 /* ****************************************************************** * * Macro definitions: * * ****************************************************************** */ /* * ERROR_DIALOG - display an error dialog (with string substitution). * Returning the button pressed to our caller. */ #define ERROR_DIALOG(_error_msg, _error_code, _button) \ \ /*word*/_button = error_dialog( (_error_msg), (_error_code)) /* ****************************************************************** * * Prototypes of all functions: * * ****************************************************************** */ Word error_dialog(Word, Word); #endif

View File

@ -0,0 +1 @@
:var:spool:lpq:

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
#include <stdio.h> void c_port_open(void); void c_port_write(char *, int); void c_port_close(void); char buffer[] = {"This is a simple test...\n"}; int main(int argc, char * argv[]) { c_port_open(); c_port_write(&buffer[0], (int) 25); c_port_close(); exit(0); }

View File

@ -0,0 +1 @@
#include <stdio.h> #include <texttool.h> void dor(int r) { if (r < 32) { ErrWriteChar(' '); ErrWriteChar('^'); ErrWriteChar(r+64); ErrWriteChar(' '); } else { ErrWriteChar(' '); ErrWriteChar(r); ErrWriteChar(' '); } } int main(int argc, char *argv[]) { int r; SetInputDevice(1,1l); SetOutputDevice(1,1l); InitTextDev(0); WriteChar(27); WriteChar('?'); r = ReadChar(0); dor(r); r = ReadChar(0); dor(r); r = ReadChar(0); dor(r); r = ReadChar(0); dor(r); r = ReadChar(0); dor(r); }

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1991 * All Rights Reserved * * ks.memory.h * * Description: This include file contains all the memory * support macros. * * * Table of contents: * * Macros: * * KS_MEMORY_ALLOCATE() . . . . . Allocate a block of memory * KS_MEMORY_FREE() . . . . . . . Free a block of memory * * * Notes: Why create these macros instead of using the standard * C I/O routines? I believe that the support * routines will require some user interface work to handle * cases like when we run out of memory. Standard C memory * routines don't give me the ability to do such processing. * * For now, these macros will simply call the C library * routines (malloc and free). I'm sure this will change * in the future. * * * History: March 2, 1991 Dave Created this file * */ #ifndef _KS_MEMORY_ #define _KS_MEMORY_ #ifndef _PORTABLE_C_ #include "Portable.C.h" #endif #ifndef _stdlib_ #include <stdlib.h> #endif #ifndef __MEMORY__ #include <memory.h> #endif /* * KS_MEMORY_ALLOCATE() - Allocate some memory */ #define KS_MEMORY_ALLOCATE(_memory_attr,_memory_size,_memory_id,_memory_hdl,_error)\ \ (_memory_hdl) = NewHandle((Long) (_memory_size), \ (_memory_id), \ (_memory_attr), \ 0L); \ (_error) = GET_ERROR() /* * KS_MEMORY_DEALLOCATE() - Release a block of memory back to the * free pool of memory */ #define KS_MEMORY_DEALLOCATE(_memory_hdl, _error) \ \ DisposeHandle( (_memory_hdl)); \ _error = KS_E_SUCCESS /* ****************************************************************** * * Memory routine prototypes: * * ****************************************************************** */ #endif

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990 * All Rights Reserved * * Portable.C.h * * Description: This include file contains all the portable C language * definitions for Font Forge. * * * Table of contents: * * Structures: * * Macros: * * COPY_BYTES . . . . . . . . . . Copy bytes from one place to another * MAX . . . . . . . . . . . . . Return the maximum of two values * MIN . . . . . . . . . . . . . Return the minimum of two values * TO_POINTER . . . . . . . . . . Convert some pointer type to Pointer * ZERO . . . . . . . . . . . . . Initialize a structure to zero * * * Notes: Wherever possible, the macros defined in this module * will be used!!!! * * History:August 10, 1990 Dave Created this file * */ #ifndef _PORTABLE_C_ #define _PORTABLE_C_ #ifndef __stddef__ #include <stddef.h> #endif /* * COPY_BYTES() - Copies the specified number of bytes */ #define COPY_BYTES(_src_ptr, _src_offset, _dest_ptr, _dest_offset, _size)\ \ BlockMove( &(((char *) (_src_ptr))[(_src_offset)]), \ &(((char *) (_dest_ptr))[(_dest_offset)]), \ (Long) (_size)) /* * GET_ERROR() - returns the error from the last toolbox call. * Use this macro only in a assignment statement * (IE: z = MAX(x,y);) */ #define GET_ERROR() \ \ toolerror() /* * MAX(a,b) - returns the minimum value, use this macro only * in a assignment statement (IE: z = MAX(x,y);) */ #define MAX(_arg1, _arg2) \ \ (((_arg1) > (_arg2)) ? (_arg1) : (_arg2)) /* * MIN(a,b) - returns the minimum value, use this macro only * in a assignment statement (IE: z = MIN(x,y);) */ #define MIN(_arg1, _arg2) \ \ (((_arg1) < (_arg2)) ? (_arg1) : (_arg2)) /* * TO_POINTER(some_pointer) - returns some_pointer typecase as * a Pointer. Use this macro only in a assignment * statement (IE: z = MIN(x,y);) */ #define TO_POINTER(_some_pointer) \ \ ((Pointer) (_some_pointer)) /* * ZERO(structure) - sets a structure to zero. */ #define ZERO(_struct) \ \ memset( (char *) &(_struct), \ 0, \ ((size_t) sizeof(_struct)) ) #endif

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1991 * All Rights Reserved * * SharedData.H * * Description: This include file contains the definition of the * shared data structure that has a pointer to it posted * to the message center. * * * Table of contents: * * Structures: * KS_SHARED_DATA . . . . . . . Shared data structure * * * History:April 21, 1991 Dave Created this file * */ #ifndef _KS_SHARED_DATA_ #define _KS_SHARED_DATA_ #ifndef _KS_DEFINES_ #include "KS.Defines.H" #endif #ifndef __GSOS__ #include <gsos.h> #endif /* * Filetype/auxtype of spoolfiles. */ #define SPOOLFILE_FILETYPE ((Word) 4) #define SPOOLFILE_AUXTYPE ((LongWord) 0) #define SPOOL_DONE_AUXTYPE ((LongWord) 256) /* * Shared data spoolport flag states */ enum port_flags {PORT_NOT_ACTIVE = 1, PORT_READY, PORT_SPOOLING, PORT_ERROR}; /* * Shared data spool flag states... */ enum spool_flags {SPOOL_INIT = 0, /* First call - initialize everything */ SPOOL_SCANNING, /* Scanning spool directory for a file */ SPOOL_OPEN, /* Setting up for printing */ SPOOL_WAITING, /* Waiting for port to be ready */ SPOOL_PRINTING, /* Printing a spoolfile */ SPOOL_CLOSE, /* Finished with a spoolfile */ SPOOL_ERROR}; /* Some error stopped spooling */ /* * KS_SHARED_DATA - generic shared data structure */ typedef struct { KS_STRUCT_ID struct_id; /* Structure id */ Word port_driver_length; /* Length of the port driver filename*/ char port_driver_name[64]; /* Name of port driver to print with */ Word spool_filename_length;/* Length of spool basename */ char spool_filename[64]; /* Basename of spool file */ LongWord buffer_size; /* User specified buffer size */ /* (This is the value of the */ /* scrollbar control) */ /* * Flag words (should use bits, but we'll be a little foolish): */ Word delete_flag; /* Delete spoolfile after printing */ Word print_flag; /* Print new spoolfiles */ /* * Data for the spoolport driver */ enum port_flags port_status; Word port_error; Word port_spoolnumber; /* * Now for the background task information. */ Pointer start_address; /* Start address of routine - pass */ /* this to add to run q! */ enum spool_flags spool_status; /* Status of spooler */ Word spool_error; /* Saved Error from spooler */ Word spool_spoolnumber; /* Spoolfile number being printed */ Pointer file_ptr; /* Pointer to the file we're spooling*/ LongWord bytes_written; /* Bytes written to the printer for */ /* the current spool file */ Word driver_user_id; /* Memory manager User ID for spooler*/ Handle buffer_handle; /* Handle to the I/O buffer */ Byte *buffer; /* Pointer to the I/O buffer */ LongWord buffer_bytesize; /* Size of the buffer (in bytes) */ LongWord buffer_offset; /* Offset of next available byte */ } KS_SHARED_DATA, *KS_SHARED_DATA_PTR, **KS_SHARED_DATA_HDL; typedef struct { Word length; char text[768]; } GSString768, *GSString768Ptr, **GSString768Hdl; typedef struct { Word bufSize; GSString768 buffer; } ResultBuf768, *ResultBuf768Ptr, **ResultBuf768Hdl; /* * KS_DATA_MESSAGE - record pointer passed to message center by name * This holds most of the user specifiable data. The only structure * missing is the pathname - and that is in the second message struct... */ typedef struct { Word blockLen; char name_length; /* 123456789 123456789 12345678 */ char message_name[28]; /* = "Kopriha Software SpoolMaster" */ KS_SHARED_DATA_HDL shared_data_handle; ResultBuf768Hdl shared_path_handle; } KS_NAMED_MESSAGE, *KS_NAMED_MSG_PTR, **KS_NAMED_MSG_HDL; /* * Function prototypes (for message center routines): */ void send_message(KS_SHARED_DATA_HDL *, ResultBuf255Hndl *); void receive_message(KS_SHARED_DATA_HDL *, ResultBuf255Hndl *); #endif

View File

@ -0,0 +1,11 @@
#
# $Id: Makefile,v 1.1 1997/12/19 07:54:49 gdr Exp $
#
# Devin Reade, December 1997
build: nullport
nullport: port.o
$(CC) -o $@ $(LDFLAGS) $< $(LDLIBS)
chtyp -t187 -a2 $@
# 187 == 0xBB

View File

@ -0,0 +1,876 @@
;***********************************************************************
;*
;* Copyright (C) Kopriha Software, 1990 - 1991
;* All rights reserved.
;* Licensed material -- property of Kopriha Software
;*
;* This software is made available solely pursuant to the terms
;* of a Kopriha Software license agreement which governs its use.
;*
;*
;* File Printer Port Driver
;*
;*
;* Description:
;* The goal of this GS port driver is to allow the user of any printer
;* driver to save their printer driver output in a user specified file.
;*
;* The user interface includes a standard file dialog box of where to
;* save the printer driver output.
;*
;* If this port driver encounters any error, a dialog box will be
;* displayed with the error code and a message saying that the printer
;* output could not be saved. The user will have two buttons -
;* DELETE_OUTPUT and OK. Delete output will simply delete the output
;* file and act as an OK button.
;*
;* Rational for this driver: I want to be able to 'print' a file on
;* my GS, bring the file to work and print the file on a printer here.
;* (An additional utility (hopefully a CDEV) will do the inverse of
;* what this driver does - it will put up a dialog box to get the user
;* to select a printer data file to to printed. Lets get this to work
;* first).
;*
;*
;* Notes:
;* This printer port driver is complies to the version 3.0 printer
;* driver specs. See IIGS technotes 35 (dated March 1990) and
;* technote 36 (dated September 1989) for the printer/port driver
;* specificiations.
;*
;* The resulting port driver must be given filetype $BB
;* auxiliary type $02 (IE: Port driver for local printer).
;*
;* The entire file port driver is designed to fit within one 64K
;* segment/bank of memory. If it must span more than one memory
;* bank, then you will have to correct the dispatch routine and
;* possibly some references to the internal data structures.
;*
;* Further References:
;* Apple IIGS Toolbox Reference, Volumes 1 & 2
;* Apple IIGS Technical Note #35, Printer Driver Specifications
;* Apple IIGS Technical Note #36, Port Driver Specifications
;*
;*
;* History: Nov 11 1990 Dave Began coding this port driver.
;* (started with IIGS technotes 35 & 36)
;*
;* Jan 19 1991 Dave Got this code compiled and attempted
;* the first couple of tests... results
;* are that the calling convention isn't
;* what I expected (Orca/C...) - technote
;* #35 confirmed my guess... time for
;* some macros to replace csubroutine &
;* creturn.
;*
;* Jan 20 1991 Dave Changed all routines to use the new
;* set of port_subroutine/return/complete
;* macros.
;* Now its time to check the macros and
;* after that try the driver again...
;*
;* Jan 21 1991 Dave Changed return macro to include the
;* completion routine - this was after
;* hours of looking at the 'Printer' port
;* driver.
;*
;* This revision caused 'Printer
;* Communication Error's from the
;* Imagewriter printer driver.
;*
;* The epson printer driver was happy...
;*
;* Jan 31 1991 Dave After a trip into the Orca/Disassembler
;* to peek into the port drivers from
;* Bill Heinman to see the return procedure
;* from all the entry points, now we have
;* another port_return macro (named
;* port_return2).
;*
;* Another 'Printer Communication Error'...
;*
;* Feb 3 1991 Dave Well... that didn't work out too well.
;* Besides, I didn't really like the second
;* return macro.
;*
;* The second macro is gone now and I've
;* changed the return macro so that it now
;* JSL's to the completion routine and
;* the RTL was removed from the macro.
;* This allows me to add the CMP #1 for
;* the routines that need it (like lots
;* of them, but not all of them...) and
;* then you have to pop an RTL in the code.
;*
;* With these changes, I have gotten the
;* Imagewriter driver to complete (and
;* now I have to test the rest, once I
;* finish with the comments here and in
;* the macro source...)
;*
;* This version works correctly with the
;* Imagewriter and Epson printer drivers.
;* The Imagewriter LQ driver returns a
;* 'Printer not Imagewriter LQ, not ready
;* or out of paper.' (cancel) dialog.
;* The Laserwriter (renamed) creates a
;* blank dialog box (no message) then hangs.
;*
;* Feb 3 1991 Dave I added the calls to the completion
;* routines for the async_read & write
;* background calls and a set of counters
;* for each port call.
;*
;* Results same as before...
;*
;* Feb 12 1991 Dave Well, after debugging to find out that
;* the ImageWriter LQ problem is related
;* to the information read from the printer
;* it was time to disassemble the code until
;* I found out what we can do about it.
;*
;* The IWLQ driver puts up the status dialog
;* after the following calls:
;* Open (no problem here)
;* Write
;* 6 bytes ($1b,$5a,$00,$02,$1b,$3f)
;* Read
;* 8 bytes (we returned zero)
;* Write
;* 8 bytes (All $ff...)
;* Status
;* Bits checked $87 - one at a time
;* Close (no problem here)
;*
;* Now after disassembling the IWLQ
;* driver, I found that the string to
;* return on the Read is as follows:
;* 5 to 8 bytes returned
;* string: $4c,$51,$31,<don't care>,
;* $XX,$XX,$XX
;* Where XX will cause a bit to get set:
;* $45 - bit $4 Multiple bins
;* $46 - bit $4 Multiple bins
;* $43 - bit $2 Color
;*
;* I've added this...
;*
;* Feb 13 1991 Dave Problem is that the same dialog came
;* up - after some debugging I found that
;* we are returning the bytes in the
;* wrong order (I fixed them to see it
;* work!)
;*
;* I tried the beta version of the DeskJet
;* printer drivers and they worked like a
;* charm!
;*
;*
;* Since I got the ImWr LQ printer driver
;* to work, it seemed like a good time to
;* generalize the printer identification
;* routines. I've also defined what to
;* expect/return from/to the ImageWriter LQ
;* and the ImageWriter printer drivers.
;*
;*
;* At this point in time the NULL port
;* driver is complete (YA HOO!)!!!
;*
;*
;***********************************************************************
case on Set case sensitivity in assembler
objcase on Set case sensitivity in object
gen off List generated code
trace off List all macro generation
mcopy port.macros Include the port driver macros
TRUE gequ 1 Define TRUE and FALSE
FALSE gequ 0
PT_Unknown gequ 0 Define the special types
PT_ImageWriter gequ 4 of printers (These printers
PT_ImageWriterLQ gequ 8 respond to a read after being
; sent a ID/status command)
;***********************************************************************
;*
StartOfDriver start
;*
;* Description:
;* Dispatch to each of the port driver support drivers.
;*
;* Note:
;* This routine must be the first in the port driver - the first two
;* words are used to determine what version port driver specification
;* is installed.
;*
;* History:
;* Most of this routine was provided by GS technote # 35.
;*
;***********************************************************************
using PortData
; Setup the header of the driver (as per the technote)
dc i2'0' ; version 3.0 style driver
dc i2'12' ; Supported # of port calls
; Set the data bank to our own, saving the previous one for later
phb ; Save data bank
phk
plb ; Set data bank to our own
; Increment a counter of port calls. This counter is used to
; determine the printer driver type (after an open, there is
; usually a write, followed by a read). If we can return the
; right string on the read then all of the options are enabled
; in the printer job dialog.
inc PortCallCounter
; Finally, lets dispatch to the port driver routine (X was preset,
; see the technote for details).
jmp (PrPortDrvList,x)
; Routine name Toolbox call #
PrPortDrvList dc a4'PrDevPrChanged' ; $1913
dc a4'PrDevStartUp' ; $1A13
dc a4'PrDevShutDown' ; $1B13
dc a4'PrDevOpen' ; $1C13
dc a4'PrDevRead' ; $1D13
dc a4'PrDevWrite' ; $1E13
dc a4'PrDevClose' ; $1F13
dc a4'PrDevStatus' ; $2013
dc a4'PrDevAsyncRead' ; $2113 (alias PrDevInitBack)
dc a4'PrDevWriteBackground' ; $2213 (alias PrDevFillBack)
dc a4'PrPortVer' ; $2413
dc a4'PrDevIsItSafe' ; $3013
end ; of StartOfDriver
;***********************************************************************
;*
PrDevPrChanged start
;*
;* Description:
;* The Print Manager makes this call every time the user accepts
;* this port driver in the Choose Printer dialog.
;*
;* Our version of this routine will set the printer type to Unknown
;*
;* Input: LONG printer name pointer
;*
;***********************************************************************
using PortData
port_subroutine (4:printername)
; Set the printer type to unknown
;
; Note: I refused to use stz because that will avoid the predefined
; constants - if I change Unknown to some other value, a STZ
; wouldn't work any more!
lda #PT_Unknown
sta PrinterType
port_return
rtl
end ; of PrDevPrChanged
;***********************************************************************
;*
PrDevStartUp start
;*
;* Description:
;* This call is not required to do anything. However, if your
;* driver needs to initialize itself by allocating memory or other
;* setup tasks, this is the place to do it. Network drivers should
;* copy the printer name to a local storage area for later use.
;*
;* Our version of this routine will do nothing.
;*
;* Input: LONG printer name pointer
;* LONG zone name pointer
;*
;***********************************************************************
port_subroutine (4:zonename,4:printername)
port_return
cmp #1
rtl
end ; of PrDevPrChanged
;***********************************************************************
;*
PrDevShutDown start
;*
;* Description:
;* This call, like PrDevStartUp, is not required to do anything.
;* However, if your driver performs other tasks when it starts,
;* from the normal (allocating memory) to the obscure (installing
;* heartbeat tasks), it should undo them here. If you allocate
;* anything when you start, you should deallocate it when you
;* shutdown. Note that this call may be made without a balancing
;* PrDevStartUp, so be prepared for this instance. For example, do
;* not try to blindly deallocate a handle that your PrDevStartUp
;* routine allocates and stores in local storage; if you have not
;* called PrDevStartUp, there is no telling what will be in your
;* local storage area.
;*
;* Our version of this routine will do nothing.
;*
;* Input: none
;*
;***********************************************************************
port_subroutine
port_return
rtl
end ; of PrDevShutDown
;***********************************************************************
;*
PrDevOpen start
;*
;* Description:
;* This call basically prepares the firmware for printing. It
;* must initialize the firmware for both input and output.
;* Input is required so the connected printer may be polled
;* for its status.
;*
;* Our version of this routine will display a dialog box (if we
;* haven't already opened a file) and open the specified file
;* for output. Since we don't really have a printer that could
;* respond, I suppose we can't really get it ready for input
;* (besides that, I don't believe all printer interfaces allow
;* input - a parallel interface doesn't have input wires from
;* the printer!)
;*
;* Note: We will have to JSL to the completion routine when we
;* are done! (or RTL if the completion pointer is NIL).
;*
;* Input: LONG completion routine pointer
;* LONG reserved long
;*
;***********************************************************************
using PortData
port_subroutine (4:reserved,4:completion_routine)
; Clear the port driver call counter (This counter is used to determine
; what type of printer driver is calling us).
stz PortCallCounter
; Now do the spooling code...
; if (channel_already_open? == NO)
; {
; Dialog_box()
; if Dialog_box answer == cancel
; set channel already open = CANCELLED;
; else
; {
; _allocate()
; (create file)
; open file
; set channel = channel
; }
; }
;
port_return 0:stump,completion_routine
cmp #1
rtl
end ; of PrDevOpen
;***********************************************************************
;*
PrDevRead start
;*
;* Description:
;* This call reads input from the printer.
;*
;* Our version of this routine will return a string based on
;* what we think the printer driver did:
;*
;* ImageWriter: Return Color option
;* ImageWriter LQ: Return Model ID, Multiple bins and Color options
;* Unknown: Return nothing (String of zero length)
;*
;*
;* Input: WORD space for result
;* LONG buffer pointer
;* WORD number of bytes to transfer
;*
;* Output: WORD number of bytes transferred
;*
;***********************************************************************
using PortData
port_subroutine (2:bytes_to_send,4:buffer,2:bytes_transfered)
; Dispatch to return the appropriate string (depending on the printer
; type - we determined the printer type from the last two commands...
; see the open/write routine comments for details)
ldx PrinterType
jmp (ReadDispatch,x)
; Routine name Printer type
ReadDispatch anop
dc a4'ReadUnknown' ; Unknown
dc a4'ReadIMWR' ; ImageWriter
dc a4'ReadIMWR_LQ' ; ImageWriter LQ
; For most printers, there aren't any bytes to be read. Return
; the standard zero length string.
ReadUnknown anop
lda #0
sta bytes_transfered
bra read_return
; Set the output buffer up for a ImageWriter returned string...
; (IE: Color)
ReadIMWR anop
lda ImWr_ReadLen
sta bytes_transfered
ldy ImWr_ReadLen
dey
ReadIMWR2 anop
dey
lda ImWr_Read,y
sta [buffer],y
cpy #0
bne ReadIMWR2
bra read_return
; Set the output buffer up for a ImageWriter LQ returned string...
; (IE: Multiple bins and Color)
ReadIMWR_LQ anop
lda ImWr_LQ_ReadLen
sta bytes_transfered
ldy ImWr_LQ_ReadLen
dey
ReadIMWR_LQ2 anop
dey
lda ImWr_LQ_Read,y
sta [buffer],y
cpy #0
bne ReadIMWR_LQ2
; Back to our caller we go...
read_return anop
port_return 2:bytes_transfered
rtl
end ; of PrDevRead
;***********************************************************************
;*
PrDevWrite start
;*
;* Description:
;* Writes the data in the buffer to the printer and calls
;* the completion routine.
;*
;* Our version of this routine will copy the information to
;* our buffer. Once the buffer is full (check before the copy
;* and if the copy would fill it then only copy what will fill
;* it). If the buffer is full then write it to the output
;* file. If there is still stuff to in the input buffer, then
;* loop to the beginning of this routine again.
;* Once we're done, its time to call the completion routine.
;*
;* Input: LONG write completion pointer
;* LONG buffer pointer
;* WORD buffer length
;*
;***********************************************************************
using PortData
port_subroutine (2:bytes_to_send,4:buffer,4:completion_routine)
; Lets see if we can determine the type of printer driver (for special
; printers). We only do this specialness on the first write after an
; open.
lda PortCallCounter
cmp #1
bne WriteNotSpecial
; Check for an ImageWriter (check length of buffer, then the buffer)
WriteIMWR anop
lda bytes_to_send
cmp ImWr_WriteLen
bne WriteIMWR_LQ
ldy ImWr_WriteLen
dey
WriteIMWR2 anop
dey
lda ImWr_Write,y
cmp [buffer],y
bne WriteIMWR_LQ
cpy #0
bne WriteIMWR2
; Looks like and ImageWrite status string to me.
; Set the special printer flag for later.
lda #PT_ImageWriter
sta PrinterType
bra WriteNotSpecial
; Check for an ImageWriter LQ (check length of buffer, then the buffer)
WriteIMWR_LQ anop
lda bytes_to_send
cmp ImWr_LQ_WriteLen
bne WriteNotSpecial
ldy ImWr_LQ_WriteLen
dey
WriteIMWR_LQ2 anop
dey
lda ImWr_LQ_Write,y
cmp [buffer],y
bne WriteNotSpecial
cpy #0
bne WriteIMWR_LQ2
; Looks like and ImageWrite LQ status string to me.
; Set the special printer flag for later.
lda #PT_ImageWriterLQ
sta PrinterType
; bra WriteNotSpecial
; Continue with the standard port write
WriteNotSpecial anop
; number_of_bytes_transferred = 0;
; if (out_buffer_size+in_buffer_size > out_buffer_space)
; {
; copy(out_buffer(out_buffer_free),
; in_buffer(0),
; out_buffer_space)
; in_buffer += out_buffer_space;
;
;. . . . blah blah blah . . . .
port_return 0:stump,completion_routine
cmp #1
rtl
end ; of PrDevWrite
;***********************************************************************
;*
PrDevClose start
;*
;* Description:
;*
;* This call is not required to do anything. However, if
;* you allocate any system resources with PrDevOpen, you
;* should deallocate them at this time. As with start and
;* shutdown, note that PrDevClose could be called without a
;* balancing PrDevOpen (the reverse is not true), and you
;* must be prepared for this if you try to deallocate
;* resources which were never allocated.
;*
;* Our version of this routine will close the file (if it
;* is open). If we find a CANCELLED flag, then we will
;* just reset the flag.
;*
;* Input: none
;*
;***********************************************************************
port_subroutine
; if (buffer allocated)
; deallocate()
;
; if (channel open)
; close (channel)
;
; if (CANCELLED flag)
; flag = OK;
port_return
rtl
end ; of PrDevClose
;***********************************************************************
;*
PrDevStatus start
;*
;* Description:
;*
;* This call performs differently for direct connect and
;* network drivers. For direct connect drivers, it currently
;* has no required function, although it may return the status
;* of the port in the future. For network drivers, it calls
;* an AppleTalk status routine, which returns a status string
;* in the buffer (normally a string like "Status: The print
;* server is spooling your document").
;*
;* Our version of this routine will do nothing.
;*
;* Input: LONG status buffer pointer
;*
;***********************************************************************
port_subroutine (4:status)
port_return
cmp #1
rtl
end ; of PrDevStatus
;***********************************************************************
;*
PrDevAsyncRead start
;*
;* Description:
;* Since PrDevRead cannot read asynchronously, this call is
;* provided for that task. Note that this does nothing for
;* direct connect drivers, and if the completion pointer is
;* NIL, it behaves for network drivers exactly as PrDevRead
;* does.
;*
;* Our version of this routine will do nothing.
;*
;* Input: WORD space for result
;* LONG completion pointer
;* WORD buffer length
;* LONG buffer pointer
;*
;* Output: WORD number of bytes transferred
;*
;***********************************************************************
port_subroutine (4:buffer,2:length,4:cmp_rtn,2:bytes_transfered)
lda #0
sta bytes_transfered
port_return 2:bytes_transfered,cmp_rtn
cmp #1
rtl
end ; of PrDevAsyncRead
;***********************************************************************
;*
PrDevWriteBackground start
;*
;* Description:
;* This routine is not implemented at this time.
;*
;* Our version of this routine will do nothing.
;*
;* Input: LONG completion procedure pointer
;* WORD buffer length
;* LONG buffer pointer
;*
;***********************************************************************
port_subroutine (4:buffer,2:length,4:completion_routine)
port_return 0:stump,completion_routine
cmp #1
rtl
end ; of PrDevWriteBackground
;***********************************************************************
;*
PrPortVer start
;*
;* Description:
;* Returns the version number of the currently installed
;* port driver.
;*
;* Our version of this routine will do nothing.
;*
;* Note: The internal version number is stored as a major
;* byte and a minor byte (i.e., $0103 represents version 1.3)
;*
;* Input: WORD space for result
;*
;* Output: WORD Port driver's version number
;*
;***********************************************************************
port_subroutine (2:version_number)
lda #$0401 ; Rev 4.1
sta version_number ; Save it
port_return 2:version_number
rtl
end ; of PrPortVer
;***********************************************************************
;*
PrDevIsItSafe start
;*
;* Description:
;* This call checks to see if the port or card which your
;* driver controls is enabled. It should check at least
;* the corresponding bit of $E0C02D, and checking the Battery
;* RAM settings wouldn't hurt any either.
;*
;* Our version of this routine will return TRUE - we don't
;* really drive any port, so we can't really check to see if
;* we are allowed to access the port/slot or not.
;*
;* Input: WORD space for result
;*
;* Output: WORD Boolean indicating if port
;* is enabled
;*
;***********************************************************************
port_subroutine (2:port_safe_flag)
lda #TRUE ; Its always safe...
sta port_safe_flag ; Save it
port_return 2:port_safe_flag
rtl
end ; of PrDevIsItSafe
;***********************************************************************
;*
PortData data
;*
;* File Port Driver Data Section
;*
;* Description:
;* This section is all of the data that the file port driver
;* requires (not very much really...).
;*
;***********************************************************************
; Special Printer Types
PrinterType ds 2
; Count of the Port calls made since an Open
PortCallCounter dc i2'0'
; ImageWriter model ID/status/options string (written)
ImWr_Write dc i1'$1b,$3f'
ImWr_WriteLen dc i2'*-ImWr_Write'
; ImageWriter model ID/status/options string (read)
ImWr_Read dc i1'$49,$57,$31,$30,$43'
ImWr_ReadLen dc i2'*-ImWr_Read'
; ImageWriter LQ model ID/status/options string (written)
ImWr_LQ_Write dc i1'$1b,$5a,$00,$02,$1b,$3f'
ImWr_LQ_WriteLen dc i2'*-ImWr_LQ_Write'
; ImageWriter LQ model ID/status/options string (read)
ImWr_LQ_Read dc i1'$4c,$51,$31,$45,$43'
ImWr_LQ_ReadLen dc i2'*-ImWr_LQ_Read'
end ; End of File Port Driver

View File

@ -0,0 +1,212 @@
;
; Copyright (C) Kopriha Software, 1990 - 1991
; All rights reserved.
; Licensed material -- property of Kopriha Software
;
; This software is made available solely pursuant to the terms
; of a Kopriha Software license agreement which governs its use.
;
;
; The following macros (port_routine/port_return) are support
; routines for IIGS port drivers.
;
;
; Macros: port_routine (<length>:<parm name>[,...])[,<work size>]
; - Enter a port driver routine
;
; port_return <length>:<return name>[,<completion routine>]
; - Exit a port driver routine
; - This macro must be followed by an RTL. By coding the
; macro this way you can customize the return (some, but
; not all port driver routines must return after a CMP #1.
; See the source to port.asm for the details).
;
;
; Note: These macros are derived from the csubroutine/creturn
; macros supplied with Orca/C (on the demos disk).
;
MACRO
&lab port_subroutine &parms,&work
&lab anop Places the label from macro invocation
aif c:&work,.a If there is a work parm goto .a
lclc &work Local define work a string
&work setc 0 Set work to zero
.a .a
gbla &totallen Global define totallen
gbla &worklen Global define worklen
gbla &PClen Global define length of PC
&worklen seta &work Set worklen = work (type conversion)
&totallen seta 0 Set totallen to zero
&PClen seta 8 Set PC length to 8 (6(rtnPC*2)+1(direct page)+1(data bank))
aif c:&parms=0,.e If there are no parms to routine then goto .e
lclc &len Local define char len
lclc &p Local define char p
lcla &i Local define int i
&i seta 1 i = 1
.b .b
&p setc &parms(&i) p = parms[i]
&len amid &p,2,1 len = substr(p,2,1)
aif "&len"=":",.c if len == ':' goto .c
&len amid &p,1,2 len = substr(p,1,2) {First 2 chars}
&p amid &p,4,l:&p-3 p = substr(p,4,strlen(p)-3) {get name}
ago .d goto .d
.c .c
&len amid &p,1,1 len = substr(p,1,1) {only first char}
&p amid &p,3,l:&p-2 p = substr(p,3,strlen(p)-2) {get name}
.d .d We have a name and its length
&p equ &totallen+&PClen+&work {name} equ totallen+PClen+work
&totallen seta &totallen+&len totallen = totallen+len (length of parm)
&i seta &i+1 i = i + 1
aif &i<=c:&parms,^b if i<#parms goto b (backwards goto)
.e .e All parms setup (equ'd)
tsc get stack pointer
aif &work=0,.f If you need work space...
sec add it onto the stack pointer
sbc #&work
tcs
.f Stack is setup by here...
phd Save the direct page
tcd Set direct page == stack ptr
mend Thus lda parm is a direct page reference...
MACRO
&lab port_return &returnparm,&comproutine
;
; Parse the return parameter (if defined).
;
&lab anop Place any label from macro invocation
lclc &len Local create len
aif c:&returnparm,.a If there is a parameter goto .a
lclc &returnparm Local create r (for parm length)
&returnparm setc 0 Set returnparm to zero
&len setc 0 Set len to zero
ago .h Goto skip arguement parsing
.a .a We have a parameter - parse it!
&len amid &returnparm,2,1 len = substr(r,2,1)
aif "&len"=":",.b if (len == ':') goto .b
&len amid &returnparm,1,2 len = substr(r,1,2)
&returnparm amid &returnparm,4,l:&returnparm-3 r = substr(r,4,strlen(r)-3)
ago .c goto .c
.b .b One character length...
&len amid &returnparm,1,1 len = substr(r,1,1)
&returnparm amid &returnparm,3,l:&returnparm-2 r = substr(3,1,strlen(r)-2)
;
; Get the return parameter - if we have something to
; return. The return parameter can be 2,4 or 10 bytes
; (IE: Word, Long or Sane #).
;
.c
aif &len=0,.h If len == 0 then skip this...
aif &len<>2,.d if len != 2 goto .d
ldy &returnparm LDY <parm name>
ago .h goto .h
.d .d Not length == 2
aif &len<>4,.e if length != 4 goto .e
ldx &returnparm+2 LDX <parm name>+2 (high byte)
ldy &returnparm LDY <parm name> (low byte)
ago .h goto .h
.e .e Not length == 4
aif &len<>10,.g if length != 10 (IE: Sane #) goto .g
ldx #^&returnparm LDX #^<parm name> (high byte)
ldy #&returnparm LDY #<parm name> (low byte)
&len setc 4 We're returning a pointer...len 4
ago .h goto .h
.g .g Not sane # (hehehe)
mnote 'Not a valid return length',16 Print error}
mexit Oops... stop here
;
; Setup the completion routine - if there is one.
;
.h
aif c:&comproutine=0,.m
;
; Ok, lets setup the completion routine JSR (but only if its not NIL)
;
stz cjmp&SYSCNT+1 Clear the completion routine address
stz cjmp&SYSCNT+2 (all three words of it...)
;
lda &comproutine
ora &comproutine+1 'OR' the other bits in...
beq compa&SYSCNT If its NIL, then return to our caller.
;
; Looks non-NIL to me. Setup the completion routine call and then do it.
; (Ug... self modifying code... Its the easy solution for now...)
;
lda &comproutine Get low 2 bytes
sta cjmp&SYSCNT+1 Save them in our JSR instruction
lda &comproutine+1 Get the high bytes (actually,
sta cjmp&SYSCNT+2 just the bank byte...)
compa&SYSCNT anop
;
; Setup the return parameters on the stack (if any)
;
.m
aif &len<>2,.k If return nothing, goto .j
sty &worklen+&totallen+&PClen-&len
.k
aif &len<>4,.j
stx &worklen+&totallen+&PClen-&len Store low byte
sty &worklen+&totallen+&PClen-&len+2 Store high byte
.j
;
; If the return PCs need to be moved, then lets move
; them... the determination is based on if we have
; to remove parameters from the stack.
; Note: The order of the moving these PCs is significant!
; We must move the PCs in the order coded... any other
; may cause the first store to overwrite part of the
; PCs before moving them.
;
aif &totallen=0,.i if no parms to port_routine, goto .i
aif &totallen-&len=0,.i No sense in moving PCs nowhere...
lda &worklen+6 Copy return PCs (both of them)
sta &worklen+&totallen+6-&len
lda &worklen+4
sta &worklen+&totallen+4-&len
lda &worklen+2
sta &worklen+&totallen+2-&len
.i
;
; If there is a possible completion routine, then
; generate the code to check if it actually exists
; and if it does then call it (jsl) - otherwise rtl.
;
aif c:&comproutine=0,.p
;
; Ok, lets go to the completion routine JSR (but only if its not NIL)
;
lda cjmp&SYSCNT+1 Is there a completion routine?
ora cjmp&SYSCNT+2 'OR' the rest of the address...
beq compb&SYSCNT If its NIL, then return to our caller.
.i
;
; Looks non-NIL to me. Setup the completion routine call and then do it.
; (Ug... self modifying code... Its the easy solution for now...)
;
clc Clear carry - no errors on this call
lda #0 (Also need zero in ac for no error!)
cjmp&SYSCNT jsr >123456 Jmp to the completion routine
compb&SYSCNT anop (Jsl would come back to a rtl, may as well just go there)
.p
;
; If we have to then it is time to adjust the stack pointer
; (also get the direct page/data bank restored for our caller)
;
pld Restore the direct page
plb Restore the data bank
aif &worklen+&totallen-&len=0,.o If we aren't changing the stack ptr
tsc Fix the stack pointer
clc ...
adc #&worklen+&totallen-&len ...
tcs ...
.o
clc Clear carry - no errors on this call
lda #0 (Also need zero in ac for no error!)
mend

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * AddFile.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_path_add_file - Append a filename (or partial filename) * * to a pathname - although you can pass any* * pait of GS/OS strings. * * * * History: Mar 24, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_path_add_file" KS_E_ERROR ks_file_path_add_file(GSString255Ptr path_ptr, GSString255Ptr file_ptr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ ROUTINE_ENTER(); /* ************************************************************** * * Append the filename to the pathname. * * ************************************************************** */ COPY_BYTES(&file_ptr->text, 0, &path_ptr->text[path_ptr->length], 0, file_ptr->length); path_ptr->length = path_ptr->length + file_ptr->length; /* ************************************************************** * * Return a success to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_path_add_file() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * ChangeAux.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_change_auxtype - Change the aux type of a file. * * * * History: March 24, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_change_auxtype" KS_E_ERROR ks_file_change_auxtype(GSString255Ptr GSPathPtr, LongWord new_auxtype) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * First get some information about the file... * * ************************************************************** */ KSf_pkts.fileinfoGSOS.pCount = 4; KSf_pkts.fileinfoGSOS.pathname = GSPathPtr; GetFileInfoGS(&KSf_pkts.fileinfoGSOS); if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; /* ************************************************************** * * Now set the file info (especially the new aux type)... * * ************************************************************** */ KSf_pkts.fileinfoGSOS.pCount = 4; KSf_pkts.fileinfoGSOS.auxType = new_auxtype; SetFileInfoGS(&KSf_pkts.fileinfoGSOS); if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; /* ************************************************************** * * Return the success back to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_change_auxtype() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Close.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_close - close an open file. * * * * History: Oct 13, 1990 Dave Created this routine * * ****************************************************************** */ #define ROUTINE_NAME "ks_file_close" KS_E_ERROR ks_file_close(KS_FILE_PTR file_ptr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Verify the structure ID passed in is the correct one. * * ************************************************************** */ if (file_ptr->struct_id != KS_FILE_ID) { KS_ERROR(KS_E_INVALID_STRUCT_ID, KS_FILE_ID); }; /* ************************************************************** * * Flush any remaining buffer to disk (if there is a buffer and * * we are writing to the file). * * ************************************************************** */ if (file_ptr->buffer_size != NULL) { if (file_ptr->access == KS_FILE_WRITE_ACCESS) { if (file_ptr->buffer_offset != 0) { /* ************************************************** * * We have something in a buffer - write the final * * buffer to disk. * * ************************************************** */ KSf_pkts.IO.pCount = 4; KSf_pkts.IO.refNum = file_ptr->refNum; KSf_pkts.IO.dataBuffer = TO_POINTER(file_ptr->buffer); KSf_pkts.IO.requestCount = file_ptr->buffer_offset; WriteGS(&KSf_pkts.IO); if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; }; /* End if there was something in the buffer */ }; /* End if we were writing to the file */ /* ********************************************************** * * We used buffered I/O on this file - now lets free the * * buffer back to free memory. * * ********************************************************** */ KS_MEMORY_DEALLOCATE(file_ptr->buffer_handle, error); }; /* End if we used buffered I/O to the file */ /* ************************************************************** * * Set up the close packet and close the file. * * ************************************************************** */ KSf_pkts.close.pCount = 1; KSf_pkts.close.refNum = file_ptr->refNum; CloseGS(&KSf_pkts.close); /* ************************************************************** * * Clear the FILE structure and give it back to free memory. * * ************************************************************** */ file_ptr->struct_id = 0; KS_MEMORY_DEALLOCATE(file_ptr->file_handle, error); /* ************************************************************** * * Return the success back to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_close() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Create.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_create - Create a particular type/auxtype file * * * * History: Mar 3, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_create" KS_E_ERROR ks_file_create(GSString255Ptr GSPathPtr, Word file_type, LongWord auxtype) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Create the file for our caller. * * * * Note: The access is setup such that the file is readable, * * writable, can be renamed and can be deleted. * * ************************************************************** */ KSf_pkts.create.pCount = 4; KSf_pkts.create.pathname = GSPathPtr; KSf_pkts.create.access = readWriteEnable | renameEnable | destroyEnable; KSf_pkts.create.fileType = file_type; KSf_pkts.create.auxType = auxtype; CreateGS(&KSf_pkts.create); /* ************************************************************** * * Return the success/error back to our caller. * * ************************************************************** */ if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; KS_SUCCESS(); } /* End of ks_file_create() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Data.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #pragma noroot #define FILEIO_DATA #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Delete.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_delete - Delete a file. * * * * History: March 24, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_delete" KS_E_ERROR ks_file_delete(GSString255Ptr GSPathPtr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Setup the delete packet and try to get rid of the file. * * Any errors are returned to our caller. * * ************************************************************** */ KSf_pkts.delete.pCount = 1; KSf_pkts.delete.pathname = GSPathPtr; DestroyGS(&KSf_pkts.delete); if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; /* ************************************************************** * * Return the success back to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_delete() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * GetBufSize.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_get_buffer_size - return the currently specified I/O * * buffer size. * * * * History: Mar 3, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_get_buffer_size" KS_E_ERROR ks_file_get_buffer_size(LongWord *buffer_size) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ ROUTINE_ENTER(); /* ************************************************************** * * Return the buffer size back to our caller. * * ************************************************************** */ *buffer_size = KSf_FileBufferSize; KS_SUCCESS(); } /* End of ks_file_get_buffer_size() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * GetVolume.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_get_volume - Return the volume name for the specified * * pathname. * * * * History: Mar 7, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_get_volume" KS_E_ERROR ks_file_get_volume(GSString255Ptr pathname_ptr, GSString255Ptr volume_ptr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ Word counter; /* Counts characters copied */ ROUTINE_ENTER(); /* ************************************************************** * * Copy the volume name out of the pathname. The volume name * * will start with a special delimitor, when we get to either * * the next delimitor or the end of the string then we have * * copied all of the volume name. * * ************************************************************** */ volume_ptr->text[0] = pathname_ptr->text[0]; for (counter = 1; ((counter < (pathname_ptr->length) ) && ((pathname_ptr->text[0]) != (pathname_ptr->text[counter]))); counter++) { volume_ptr->text[counter] = pathname_ptr->text[counter]; }; volume_ptr->length = counter; /* ************************************************************** * * Return a success to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_get_volume() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1991 * All Rights Reserved * * MSGReceive.CC * * Description: * This module is message center options from the menus.. * * * Table of Contents: * * retrieve_message . . Get message by name for our caller... * * History:April 23, 1991 Dave Created this file * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #include <string.h> #ifndef __LOCATOR__ #include <Locator.h> #endif #ifndef __MISCTOOL__ #include <MiscTool.h> #endif #ifndef _KS_DEFINES_ #include "KS.Defines.h" #endif #ifndef _KS_MEMORY_ #include "KS.Memory.H" #endif #ifndef _KS_SHARED_DATA_ #include "SharedData.H" #endif #pragma noroot /* ****************************************************************** * * receive_message() - Get a pointer to the port data to the message * * center by name... * * * * History: Apr 23, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "receive_message" void receive_message(KS_SHARED_DATA_HDL *data_hdl, ResultBuf255Hndl *path_hdl) { ResponseRecord response_rec; KS_NAMED_MESSAGE named_msg; KS_NAMED_MSG_PTR msg_rec_ptr; Word message_id; Handle msg_handle; KS_E_ERROR error; extern Word ProgramID; *data_hdl = NULL; *path_hdl = NULL; /* ************************************************************** * * Start by getting the message id for the named message * * ************************************************************** */ named_msg.blockLen = sizeof(KS_NAMED_MESSAGE); strcpy(named_msg.message_name, "Kopriha Software SpoolMaster"); named_msg.name_length = strlen(named_msg.message_name); response_rec = MessageByName(FALSE, (void *) &named_msg); if (GET_ERROR() != KS_E_SUCCESS) { return; }; message_id = (response_rec & 0xffff); /* ************************************************************** * * Get the complete message from the message center * * ************************************************************** */ KS_MEMORY_ALLOCATE(attrNoSpec + attrNoCross, sizeof(KS_NAMED_MESSAGE), /* could be anything */ ProgramID, msg_handle, error); if (error != KS_E_SUCCESS) { return; }; MessageCenter((Word) getMessage, (Word) message_id, (Handle) msg_handle); if (GET_ERROR() == KS_E_SUCCESS) { msg_rec_ptr = (KS_NAMED_MSG_PTR) &(((MessageRecPtr) *msg_handle)->messageData); *data_hdl = msg_rec_ptr->shared_data_handle; *path_hdl = (ResultBuf255Hndl) msg_rec_ptr->shared_path_handle; }; KS_MEMORY_DEALLOCATE(msg_handle, error); /* ************************************************************** * * Return to our caller. * * ************************************************************** */ return; } /* End of receive_message() */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
# # $Id: Makefile,v 1.1 1997/12/19 07:54:51 gdr Exp $ # LIB = libdvr ODIR = obj OBJS = \ $(ODIR)/AddPath.o \ $(ODIR)/ChangeAux.o \ $(ODIR)/Close.o \ $(ODIR)/Create.o \ $(ODIR)/Data.o \ $(ODIR)/Delete.o \ $(ODIR)/GetBufSize.o \ $(ODIR)/GetVolume.o \ $(ODIR)/Gnfn.o \ $(ODIR)/MSGReceive.o \ $(ODIR)/MSGSend.o \ $(ODIR)/Open.o \ $(ODIR)/Read.o \ $(ODIR)/Rename.o \ $(ODIR)/SetBufSize.o \ $(ODIR)/SetDir.o \ $(ODIR)/SetEOF.o \ $(ODIR)/Space.o \ $(ODIR)/Write.o INCL2 = ../includes HDRS = ks.fileio.h $(INCL2)/ks.fileio.e $(INCL2)/ks.memory.h \ $(INCL2)/ks.defines.h $(INCL2)/KS.CDEV.h $(INCL2)/KS.Routines.h \ $(INCL2)/Portable.C.h $(INCL2)/SharedData.h SEGMENT = -Slibdvr____ CFLAGS = $(SEGMENT) -I$(INCL2) -r -w -v -O78 build: $(LIB) $(ODIR): install -d $(ODIR) $(LIB): $(OBJS) $(RM) -f $@ makelib.apw -w -r -p -l $@ $(OBJS) $(ODIR)/%.o: %.c $(CC) -o $@ -c $(CFLAGS) $< $(ODIR)/AddPath.o:: $(HDRS) $(ODIR)/Write.o:: $(HDRS) $(ODIR)/Space.o:: $(HDRS) $(ODIR)/SetEOF.o:: $(HDRS) $(ODIR)/SetDir.o:: $(HDRS) $(ODIR)/SetBufSize.o:: $(HDRS) $(ODIR)/Rename.o:: $(HDRS) $(ODIR)/Read.o:: $(HDRS) $(ODIR)/Open.o:: $(HDRS) $(ODIR)/msgsend.o:: $(HDRS) $(ODIR)/msgreceive.o:: $(HDRS) $(ODIR)/gnfn.o:: $(HDRS) $(ODIR)/GetVolume.o:: $(HDRS) $(ODIR)/GetBufSize.o:: $(HDRS) $(ODIR)/Delete.o:: $(HDRS) $(ODIR)/Data.o:: $(HDRS) $(ODIR)/Create.o:: $(HDRS) $(ODIR)/Close.o:: $(HDRS) $(ODIR)/ChangeAux.o:: $(HDRS)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Rename.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Jun 30, 1991 Dave Created this file * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_rename - Change the name of a file (given complete * * pathnames of the source/destination). * * * * History: June 30, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_rename" KS_E_ERROR ks_file_rename(GSString255Ptr old_path, GSString255Ptr new_path) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Fill in the change path packet then issue the system call... * * ************************************************************** */ KSf_pkts.rename.pCount = 2; KSf_pkts.rename.pathname = old_path; KSf_pkts.rename.newPathname = new_path; ChangePathGS(&KSf_pkts.rename); if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; /* ************************************************************** * * Return the success back to our caller. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_rename() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * SetBufSize.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_set_buffer_size - set the specified I/O buffer size. * * * * Note: Any open files that are using buffering will NOT change * * their buffer sizes until they need to do I/O! * * * * History: Mar 3, 1990 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_set_buffer_size" KS_E_ERROR ks_file_set_buffer_size(LongWord buffer_size) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ ROUTINE_ENTER(); /* ************************************************************** * * Set the buffer size back to our caller. * * ************************************************************** */ KSf_FileBufferSize = buffer_size; KS_SUCCESS(); } /* End of ks_file_set_buffer_size() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * SetDir.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_set_directory - Set the current directory (actually, * * prefix 8). * * * * History: Mar 7, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_set_directory" KS_E_ERROR ks_file_set_directory(GSString255Ptr directory_ptr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Setup the packet to set prefix 8 then make the set prefix * * call. * * * * Note: We have to copy the prefix pathname into the buffer * * because of the way the GS/OS packet is set up. * * It would be nice to simply set a pointer... but we * * can't do that. * * ************************************************************** */ KSf_pkts.prefix.pCount = 2; KSf_pkts.prefix.prefixNum = 8; KSf_pkts.prefix.buffer.setPrefix = directory_ptr; SetPrefixGS(&KSf_pkts.prefix); /* ************************************************************** * * Return to our caller. * * ************************************************************** */ if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; KS_SUCCESS(); } /* End of ks_file_set_directory() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * SetEOF.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_set_eof - Set the end of file of an open file * * * * History: May 27, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_set_eof" KS_E_ERROR ks_file_set_eof(KS_FILE_PTR file_ptr, LongWord new_eof) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Setup the packet then make the set EOF call... * * ************************************************************** */ KSf_pkts.position.pCount = 3; KSf_pkts.position.refNum = file_ptr->refNum; KSf_pkts.position.base = startPlus; KSf_pkts.position.displacement = new_eof; SetEOFGS(&KSf_pkts.position); /* ************************************************************** * * Return to our caller. * * ************************************************************** */ if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; KS_SUCCESS(); } /* End of ks_file_set_eof() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Space.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_get_volume_space - Return the total/unused space of * * the specified volume * * * * History: Mar 13, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_get_volume_space" KS_E_ERROR ks_file_get_volume_space(GSString255Ptr volume_ptr, LongWord *unused_space, LongWord *total_space) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Now lets generate some code that just shouldn't work... * * * * According to all the reference manuals, GetFileInfo does not * * return valid information on volumes or directories. * * * * The means we have to go back to the ProDOS 16 GET_FILE_INFO * * call that does return the volume size and number of allocated * * blocks (even if the manuals seem to disagree with this). * * * * To do a ProDOS 16 call, you have to pass a pascal string... * * which is a length byte followed by the string. Now a GS/OS * * string is a length word followed by the string. We are going * * to cheat once more by making the GS/OS string a Pascal string * * for the duration of this call... * * * * I don't like doing things this way, but the alternative is * * very ugly (start by scanning all devices with DInfo, the * * get the volume name of each disk device, then compare names * * until you find the specified volume, and finally you have * * the information for a Volume call). * * * * We'll cheat now - this may need fixing in the future. * * ************************************************************** */ (((char *) volume_ptr)[1]) = (((char *) volume_ptr)[0]); KSf_pkts.fileinfo.pathname = &(((char *) volume_ptr)[1]); GET_FILE_INFO(&KSf_pkts.fileinfo); (((char *) volume_ptr)[1]) = '\0'; if ((error = GET_ERROR()) != KS_E_SUCCESS) { KS_ERROR(error, KS_FILE_ID); }; *unused_space = (KSf_pkts.fileinfo.auxType - KSf_pkts.fileinfo.blocksUsed) / 2; *total_space = (KSf_pkts.fileinfo.auxType) / 2; /* ************************************************************** * * We'll never reach this part of the code... However, if by * * some cosmic reason we do - let us return a success. * * ************************************************************** */ KS_SUCCESS(); } /* End of ks_file_get_volume_space() */

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * Gnfn.CC * * Description: * This module exists to abstract the data of the file I/O * primitives of GS/OS. * * * History:Oct 13, 1990 Dave Created this file * * Feb 25, 1991 Dave Added I/O buffering * * May 26, 1991 Dave Added set EOF * * Jun 07, 1991 Dave Broke the single source into lots * of small sources so we can build * a library to use... * */ /* * define DEBUG_CODE * - add # to define to create the local * debug code (IE:module) */ #ifndef _KS_FILEIO_ #include "ks.fileio.h" #endif #pragma noroot /* ****************************************************************** * * ks_file_get_next_file - Return the next filename in a directory. * * * * History: Mar 5, 1991 Dave Created this routine * * ****************************************************************** */ #undef ROUTINE_NAME #define ROUTINE_NAME "ks_file_get_next_file" KS_E_ERROR ks_file_get_next_file(KS_FILE_PTR file_ptr, DirEntryRecPtrGS dir_entry_ptr) { /* ************************************************************** * * Local declarations: * * ************************************************************** */ KS_E_ERROR error; /* Holds error codes for subroutines */ ROUTINE_ENTER(); /* ************************************************************** * * Set the parameters up and get the next directory entry. * * * * If we are at the end of the directory, then we have to do a * * special call to get the first entry - the open code will set * * the flag making it look like we're at the end of the directory* * for our first call. * * ************************************************************** */ dir_entry_ptr->pCount = 13; dir_entry_ptr->refNum = file_ptr->refNum; if (file_ptr->end_of_dir == TRUE) { dir_entry_ptr->base = 0; dir_entry_ptr->displacement = 0; file_ptr->end_of_dir = FALSE; } else { dir_entry_ptr->base = 1; dir_entry_ptr->displacement = 1; }; GetDirEntryGS(dir_entry_ptr); /* ************************************************************** * * Now check for errors. If we are at the end of the directory * * then send the end of directory flag. * * * * The last thing to do is to return to our caller. * * ************************************************************** */ if ((error = GET_ERROR()) != KS_E_SUCCESS) { if (error == endOfDir) { file_ptr->end_of_dir = TRUE; }; KS_ERROR(error, KS_FILE_ID); }; KS_SUCCESS(); } /* End of ks_file_get_next_file() */

View File

@ -0,0 +1 @@
/* * Copyright (c) Kopriha Software, 1990-1991 * All Rights Reserved * * ks.fileio.h * * Description: This include file contains all the generic file * support macros from Kopriha Software. * * * Table of contents: * * External Data Structures: * * Notes: * * History:Oct 13, 1990 Dave Created this file for basic * I/O (read/write) * * Feb 25, 1991 Dave Added buffer enhancements/create. * * Mar 5, 1991 Dave Added directory, file, path and * volume calls * * Mar 24, 1991 Dave Added delete and change aux type * */ #ifndef _KS_FILEIO_H_ #define _KS_FILEIO_H_ #ifndef _KS_FILEIO_E_ #include "ks.fileio.e" #endif #ifndef __GSOS__ #include <gsos.h> #endif #ifndef __PRODOS__ #include <ProDOS.h> #endif #ifndef __MEMORY__ #include <memory.h> #endif #ifndef _KS_MEMORY_ #include "ks.memory.h" #endif /* * Define all the external data referenced in this module: * * Note: The routines in this module minimize stack space usage, * which is why all the structures are external... */ /* ****************************************************************** * * KSf_Pkts - This is a union of all the GS/OS packets that are * * used by this module. Since multitasking isn't * * supported on a IIGS, we won't worry about needing * * seperate unions for each task (which is how we will * * solve this problem when multitasking does become * * available). * * * * Note: fileinfo is a ProDOS 16 structure - this is because GS/OS * * does not provide an easy method to determine the amount of * * space used on a volume. * * ****************************************************************** */ #ifdef FILEIO_DATA #ifdef EXTERNAL #undef EXTERNAL #define EXTERNAL #endif #endif #ifndef EXTERNAL #define EXTERNAL extern #endif EXTERNAL union { CreateRecGS create; OpenRecGS open; IORecGS IO; RefNumRecGS close; SetPositionRecGS position; PrefixRecGS prefix; FileRec fileinfo; FileInfoRecGS delete; FileInfoRecGS fileinfoGSOS; ChangePathRecGS rename; } KSf_pkts; /* ****************************************************************** * * KSf_pkts2 - This is the second unionized set of GS/OS packets. * * The reason for these packets is that the first packets* * sometimes have option fields that these packets must * * be used to fill in. * * * * optionList - this is the File System Translator specific * * area returned on the Open call. We don't do * * anything with this data. * * * * ****************************************************************** */ EXTERNAL union { Word optionList[20]; } KSf_pkts2; /* ****************************************************************** * * KSf_FileBufferSize - the specified size of the file buffers * * ****************************************************************** */ EXTERNAL Long KSf_FileBufferSize; #ifdef FILEIO_DATA #undef EXTERNAL #define EXTERNAL extern #endif #endif

View File

@ -0,0 +1 @@
# # --- Link Script --- # # Build the Support library echo echo Putting objects into the Support.LB echo rm -f Support.LB makelib Support.LB +Objects/Close.A +Objects/ChangeAux.A makelib Support.LB +Objects/Create.A +Objects/Delete.A +Objects/GetBufSize.A makelib Support.LB +Objects/Gnfn.A +Objects/GetVolume.A +Objects/Space.A makelib Support.LB +Objects/Open.A +Objects/AddPath.A +Objects/Read.A makelib Support.LB +Objects/SetBufSize.A +Objects/SetDir.A +Objects/SetEOF.A makelib Support.LB +Objects/Write.A +Objects/Rename.A +Objects/Data.A makelib Support.LB +Objects/MSGSend.A +Objects/MSGReceive.A