// An object to scroll some text inside a string gadget
function ScrollingStringGadget(gad, length, str, delay, indent) {
// Copyright (C) Mikko Koivunalho 1999
// gad, the string gadget in which to do the scrolling
// length, the length of the string gadget (which was given in the HTML source)
// Unfortunately the length seems to vary. Sometimes it's exactly what you
// specified in the source, sometimes it's that + 1, and when the client uses proportional fonts, oh dear!
// This object does not modify the value you give.
// str, the whole string which to scroll
// delay, the scrolling delay (speed) in milliseconds
// indent, the amount of space left of string in first round
this.gadget = gad;
this.gadgetLength = length;
this.string = new String(str);
this.scrollDelay = delay;
this.firstTimeIndent = indent;
this.thisObjectName = new String(""); // !! Use must give this property a value
// The value is the string representation of the object you have created
// like this: scroller = new ScrollingStringGadget(abc,0,"",0,0);
// scroller.thisObjectName = "scroller";
// Unfortunately this seems to be necessary for window.setTimeout().
// Damn inconvenient, though!
// Don't change below this point -- For internal use only!!
this.left = 0; // How much of the string has already disappeared to the left
this.firstTime = 0; // The amount of space on the left of string during the first round
this.tempString = new String(""); // a temporary string to make the gadget contents into
this.timeoutId = null;
}
new ScrollingStringGadget(null, 0, "", 0, 0); // Needed to create the prototypes
function ScrollingStringGadget_doScroll() {
if((this.left + this.gadgetLength) <= this.string.length) {
// The string has not yet reached the end
if(this.firstTime > 0) {
// This is the first time doing the scroll round
// meaning we must add space before the string
this.tempString = "";
for(var i = 1; i <= this.firstTime; i++) {
this.tempString = this.tempString + " ";
}
this.tempString = this.tempString + this.string.substring(0,
(this.gadgetLength - this.firstTime));
this.firstTime--;
}
else {
this.tempString = this.string.substring(this.left, (this.left + this.gadgetLength));
this.left++;
}
}
else {
// The string has reached the end and now we have to attach
// part of the beginning to the end
if(this.left <= this.string.length - 1) {
// Atleast one character left in the end (beginning of the string gadget
// temp variables could be used here, but I optimized instead:
// var do_scrolling_takefromend = this.string.length - this.left;
// var do_scrolling_takefrombegin = this.gadgetLength - do_scrolling_takefromend;
this.tempString = this.string.substring(this.left, this.string.length);
this.tempString = this.tempString + this.string.substring(0,
this.gadgetLength - (this.string.length - this.left)); //or do_scrolling_takefrombegin
this.left++;
}
else {
// Here the whole string has gone to the left of the gadget!
this.left = 0;
this.tempString = this.string.substring(this.left, (this.left + this.gadgetLength));
this.left++;
}
}
this.gadget.value = this.tempString;
this.timeoutId = window.setTimeout(this.thisObjectName + ".doScroll()", this.scrollDelay); // Repeat this function
return 0;
}
function ScrollingStringGadget_begin() {
this.firstTime = this.firstTimeIndent;
this.doScroll();
}
function ScrollingStringGadget_stop() {
window.clearTimeout(this.timeoutId);
}
function ScrollingStringGadget_resume() {
this.doScroll();
}
ScrollingStringGadget.prototype.doScroll = ScrollingStringGadget_doScroll;
// Public functions below!!
ScrollingStringGadget.prototype.begin = ScrollingStringGadget_begin;
// Begin scrolling
ScrollingStringGadget.prototype.stop = ScrollingStringGadget_stop;
// Stop scrolling
ScrollingStringGadget.prototype.resume = ScrollingStringGadget_resume;
// Resume scrolling
// An object to pingpong scroll some text inside a string gadget
// i.e. make the string go from left to right and vice versa and
// "bounce" from the "walls" (gadget edges).
function PingpongStringGadget(gad, length, str, delay) {
// Copyright (C) 1999 Mikko Koivunalho
// gad, the string gadget in which to do the scrolling
// length, the length of the string gadget (which was given in the HTML source)
// Unfortunately the length seems to vary. Sometimes it's exactly what you
// specified in the source, sometimes it's that + 1, and when the client uses proportional fonts, oh dear!
// This object does not modify the value you give.
// str, the whole string which to scroll
// delay, the scrolling delay (speed) in milliseconds
this.gadget = gad;
this.gadgetLength = length;
this.string = new String(str);
this.scrollDelay = delay;
this.thisObjectName = new String(""); // !! Use must give this property a value!!
// The value is the string representation of the object you have created
// like this: scroller = new ScrollingStringGadget(abc,0,"",0,0);
// scroller.thisObjectName = "scroller";
// Unfortunately this seems to be necessary for window.setTimeout().
// Damn inconvenient, though!
// Don't change below this point -- For internal use only!!
this.whiteSpaces = 0; // The amount of space on the left side of string
this.dirToLeft = new Boolean(false); // Is the string going leftwards? User preferences!
this.tempString = new String(""); // a temporary string to make the gadget contents into
this.timeoutId = null;
}
new PingpongStringGadget(null, 0, "", 0); // Needed to create the prototypes
function PingpongStringGadget_doScroll() {
this.tempString = "";
if(this.dirToLeft == true) {
this.whiteSpaces--;
if(this.whiteSpaces <= 0) {
this.dirToLeft = false;
}
}
else { // this.dirToLeft == false -> "dirToRight"
this.whiteSpaces++;
if((this.whiteSpaces + this.string.length) >= this.gadgetLength) {
this.dirToLeft = true;
}
}
if(this.whiteSpaces >= 0) { // Normal situation!! ;-)
for(var i = 1; i <= this.whiteSpaces; i++) {
this.tempString = this.tempString + " ";
}
this.tempString = this.tempString + this.string;
}
else { // The string is entering through the left edge; therefore special arrangements.
var showChars = this.whiteSpaces + this.string.length;
this.tempString = this.string.substring(this.string.length - showChars,
this.string.length); // We cut the end part of the string
}
this.gadget.value = this.tempString;
this.timeoutId = window.setTimeout(this.thisObjectName + ".doScroll()", this.scrollDelay); // Repeat this function
}
// A function to set the place and scroll direction of the string
// before starting to pingpong scroll it.
function PingpongStringGadget_startPlace(place,dir) {
// place, either a number or a string; users choices:
// users choices: center, left, right, enter_left, enter_right
// dir, direction to which scroll
if(typeof place == "string") {
// place can be center, left, right, enter_left or enter_right
if(place == "center") {
this.whiteSpaces = Math.floor((this.gadgetLength - this.string.length) / 2);
if(typeof dir == "string") {
if(dir == "left") {
this.dirToLeft = true;
}
if(dir == "right") {
this.dirToLeft = false;
}
}
}
if(place == "left") {
this.whiteSpaces = -1;
// - 1 because in doScroll() the string gets moved one step forward before showing it
this.dirToLeft = false;
}
if(place == "right") { // Places the string in the right edge
this.whiteSpaces = (this.gadgetLength - this.string.length) + 1;
// + 1 because in doScroll() the string gets moved one step backward before showing it
this.dirToLeft = true;
/*alert("string.length: " + this.string.length + " whiteSpaces: " + this.whiteSpaces +
"\nstring: " + this.string + "\ngadgetlength: " + this.gadgetLength);*/
}
if(place == "enter_left") { // The string enters from the left edge
this.whiteSpaces = -this.string.length - 1;
this.dirToLeft = false;
}
if(place == "enter_right") { // The string enters from the right edge
this.whiteSpaces = this.gadgetLength + 1;
this.dirToLeft = true;
}
}
else { // place == "number"
this.whiteSpaces = place;
if(typeof dir == "string") {
if(dir == "left") {
this.dirToLeft = true;
}
if(dir == "right") {
this.dirToLeft = false;
}
}
}
}
function PingpongStringGadget_begin() {
this.doScroll();
}
function PingpongStringGadget_stop() {
window.clearTimeout(this.timeoutId);
}
function PingpongStringGadget_resume() {
this.doScroll();
}
PingpongStringGadget.prototype.doScroll = PingpongStringGadget_doScroll;
// Public functions below!!
PingpongStringGadget.prototype.startPlace = PingpongStringGadget_startPlace;
// From where to start the scrolling
PingpongStringGadget.prototype.begin = PingpongStringGadget_begin;
// Begin pingponging
PingpongStringGadget.prototype.stop = PingpongStringGadget_stop;
// stop pingponging
PingpongStringGadget.prototype.resume = PingpongStringGadget_resume;
// resume pingponging
class VIITENUMERO
creation
make
feature -- Version
versionstring: STRING is "\0$VER: Viitenumero 1.0 (12.09.02) Copyright (C) 2002 Mikko Koivunalho"
-- Amiga specific version string.
feature -- Creation
make is
-- Muodosta viitenumero siitä luvusta, joka on annettu argumenttina
-- komennolla ja tulosta se.
local
version_of_program: STRING -- This is needed to include the version string into the code.
tarkisteluku, summa: INTEGER
i, kertoluvut_index: INTEGER
kertoluvut: ARRAY[INTEGER]
valmis: STRING
do
!!version_of_program.make_from_string(versionstring) -- This is needed to include the version string into the code.
if argument_count = 1
then
debug
io.put_string("Argumentti on %"")
io.put_string(argument(1))
io.put_string("%".%N")
end
if not argument(1).is_empty and then is_viitenumero(argument(1))
then
from
kertoluvut := << 7, 3, 1 >>
kertoluvut_index := 1
summa := 0
i := argument(1).upper
invariant
argument(1).lower - 1 <= i and
i <= argument(1).upper
variant
argument(1).lower - 1 + i
until i = argument(1).lower - 1
loop
summa := argument(1).item(i).decimal_value * kertoluvut.item(kertoluvut_index) + summa
if kertoluvut_index = 3
then
kertoluvut_index := 1
else
kertoluvut_index := kertoluvut_index + 1
end
i := i - 1
debug
io.put_string("Summa on %"")
io.put_string(summa.to_string)
io.put_string("%".%N")
end
end
if summa \\ 10 = 0
then
tarkisteluku := 0
debug
io.put_string("Tarkisteluku on %"0%".%N")
end
else
tarkisteluku := ((summa / 10).floor + 1) * 10 - summa
debug
io.put_string("Tarkisteluku on %"")
io.put_string(tarkisteluku.to_string)
io.put_string("%".%N")
end
end
check tarkisteluku.in_range(0, 9) end
-- jaetaan viiden numeron sarjoihin oikealta luettuna.
debug
io.put_string("Seuraavaksi koostetaan valmis viitenumero 5 numeron sarjoihin.%N")
end
from
!!valmis.make_empty
i := argument(1).count
valmis.append(tarkisteluku.to_string)
debug
io.put_string("Valmiina on %"")
io.put_string(valmis)
io.put_string("%", i on %"")
io.put_string(i.to_string)
io.put_string("%".%N")
end
invariant
i.in_range(0, argument(1).count)
until
i = 0
loop
if valmis.count = 5 or valmis.count = 11 or valmis.count = 17
then
valmis.insert_character(' ', 1)
else
valmis.insert_character(argument(1).item(i), 1)
i := i - 1
end
debug
io.put_string("Valmiina on %"")
io.put_string(valmis)
io.put_string("%", i on %"")
io.put_string(i.to_string)
io.put_string("%".%N")
end
end
io.put_string(valmis)
io.put_string("%N")
else -- Komentoriviargumentti ei ole kunnollinen viitenumero
io.put_string("ERROR: %"")
io.put_string(argument(1))
io.put_string("%" ei ole viitenumero.%N")
end
else
io.put_string("ERROR: Vain yksi argumentti: viitenumero.%N")
end
end
feature -- Helping routines
is_viitenumero(ehdotelma_s: STRING): BOOLEAN is
-- Tarkista onko ehdotelma_s kelvollinen viitenumeroksi.
require
not_empty: not ehdotelma_s.is_empty
local
i: INTEGER
do
if ehdotelma_s.count <= 19
then
from
i := ehdotelma_s.lower
invariant
ehdotelma_s.lower <= i and
i <= ehdotelma_s.upper + 1
variant
ehdotelma_s.upper + 1 - i
until
i = ehdotelma_s.upper + 1 or else not ehdotelma_s.item(i).is_digit
loop
i := i + 1
end
Result := (i = ehdotelma_s.upper + 1)
else
Result := False
end
ensure
end
invariant -- Class invariant
end -- class VIITENUMERO
/*
** This file is free software according to the GNU Public license
** Viite-Handler Copyright (C) 2002 Mikko Koivunalho
*/
#define __USE_SYSBASE
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include "viitenumero.h"
/*
** Program Version
*/
static char VersionTag[] = "\0$VER: Viite-Handler 1.0 (12.09.02) Copyright (C) 2002 Mikko Koivunalho";
extern struct ExecBase *__far AbsExecBase;
struct ExecBase *SysBase;
struct DosLibrary *DosBase;
static void replypkt1(struct DosPacket *, LONG);
static void replypkt2(struct DosPacket *, LONG, LONG);
#define MAX_VIITENUMERO_PITUUS 24 /* 20 numbers + 3 spaces + '\0' */
#define MAX_VIITENUMERO_EHDOTUS_PITUUS 20 /* 19 numbers + '\0' */
struct OpenFile {
char of_FileContents[MAX_VIITENUMERO_PITUUS]; /* viitenumero (20 chars) + '\0' */
char *of_PointerInFile; /* The position of read pointer, a POINTER pointing somewhere in of_FileContents */
};
struct OpenFileNode {
struct MinNode ofn_MinNode;
struct OpenFile ofn_OpenFile;
};
void __saveds start(void)
{
struct MsgPort *mp;
struct DosPacket *dp;
struct DeviceNode *dn;
struct Message *mn;
BOOL error, remove_handler, nosplit;
char file_name[256] = "", merkki2;
char *merkki3_p, *file_name_p;
struct FileHandle *fh;
struct MinList *openfilelist;
struct OpenFileNode *workopenfilenode;
#ifdef DEBUG
DPutStr("Just started the handler.\n");
#endif
SysBase = AbsExecBase;
DosBase = (struct DosLibrary *) OpenLibrary("dos.library", 37);
if(DosBase != NULL)
{
mp = &((struct Process *)FindTask(NULL))->pr_MsgPort;
(void)WaitPort(mp);
dp = (struct DosPacket *)GetMsg(mp)->mn_Node.ln_Name; /*Startup msg*/
error = TRUE;
dn = BADDR(dp->dp_Arg3);
dn->dn_Task = mp;
replypkt1(dp, DOSTRUE); /*Answer Startup msg*/
#ifdef DEBUG
DPutStr("Startup packet done with.\n");
#endif
if(openfilelist = AllocMem(sizeof(struct MinList), MEMF_CLEAR))
{
NewList((struct List *) openfilelist); /* Important: prepare header for use */
error = FALSE;
remove_handler = FALSE;
do
{
#ifdef DEBUG
DPutStr("Now entering the main loop.\n");
#endif
(void)WaitPort(mp);
while((mn = GetMsg(mp)) != NULL)
{
dp = (struct DosPacket *)mn->mn_Node.ln_Name;
switch(dp->dp_Type)
{
case ACTION_FINDINPUT: /*Open file for reading read-only*/
#ifdef DEBUG
DPutStr("Received packet ACTION_FINDINPUT.\n");
#endif
merkki3_p = BADDR(dp->dp_Arg3);
#ifdef DEBUG
DPutChar(merkki3_p[1]);
#endif
merkki3_p = BADDR(dp->dp_Arg3);
merkki2 = merkki3_p[0]; /* The length of the BSTR */
merkki3_p = BADDR(dp->dp_Arg3);
merkki3_p = &merkki3_p[1];
file_name[0] = '\0';
strncat(file_name, merkki3_p, (size_t) merkki2);
#ifdef DEBUG
DPutStr("Tiedoston nimi polkuineen: ");
DPutStr(file_name);
DPutStr("\n");
#endif
if(strchr(file_name, ':'))
{
file_name_p = strchr(file_name, ':') + 1;
/* Now we find out if the filename has a /NOSPLIT suffix. */
if(strchr(file_name_p, '/') && stricmp(strchr(file_name_p, '/'), "/NOSPLIT") == 0 )
{
nosplit = TRUE;
*strchr(file_name_p, '/') = '\0';
}
else { nosplit = FALSE; }
#ifdef DEBUG
DPutStr("ViiteTiedoston nimi: ");
DPutStr(file_name_p);
DPutStr("\n");
#endif
if(is_good_for_viitenumero(file_name_p))
{
#ifdef DEBUG
DPutStr("ViiteTiedoston nimi on OK viitenumeron muodostamiseen!\n");
#endif
if(workopenfilenode = AllocMem(sizeof(struct OpenFileNode), MEMF_CLEAR))
{
viitenumero(file_name_p, workopenfilenode->ofn_OpenFile.of_FileContents);
if(!nosplit) split_into_series(workopenfilenode->ofn_OpenFile.of_FileContents, 5);
workopenfilenode->ofn_OpenFile.of_PointerInFile = workopenfilenode->ofn_OpenFile.of_FileContents;
AddTail((struct List *) openfilelist, (struct Node *) workopenfilenode);
#ifdef DEBUG
DPutStr("Tiedosto lisätty listaan.\n");
#endif
#ifdef DEBUG
DPutStr("workopenfilenode->ofn_OpenFile.of_FileContents: ");
DPutStr(workopenfilenode->ofn_OpenFile.of_FileContents);
DPutStr("\n");
#endif
fh = BADDR(dp->dp_Arg1);
fh->fh_Arg1 = (LONG) workopenfilenode; /* Pointer to a handlers internal reference system. */
replypkt1(dp, DOSTRUE);
}
else
{
replypkt2(dp, DOSFALSE, ERROR_NO_FREE_STORE);
}
}
else
{
#ifdef DEBUG
DPutStr("ViiteTiedoston nimi ei ole OK viitenumeron muodostamiseen!\n");
#endif
replypkt2(dp, DOSFALSE, ERROR_OBJECT_NOT_FOUND);
}
}
else
{
replypkt2(dp, DOSFALSE, ERROR_OBJECT_NOT_FOUND);
}
break;
case ACTION_READ: /*read file*/
#ifdef DEBUG
DPutStr("Received packet ACTION_READ.\n");
#endif
workopenfilenode = (struct OpenFileNode *) dp->dp_Arg1;
#ifdef DEBUG
DPutStr("workopenfilenode->ofn_OpenFile.of_FileContents:n sisältö on ");
DPutStr(workopenfilenode->ofn_OpenFile.of_FileContents);
DPutStr("\n");
#endif
/* workopenfilenode->ofn_OpenFile.of_PointerInFile is a pointer !!! */
if(strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile) > 0)
{ /* There is something yet in workopenfilenode->ofn_OpenFile.of_FileContents */
#ifdef DEBUG
DPutStr("There is something yet in workopenfilenode->ofn_OpenFile.of_FileContents.\n");
#endif
if(strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile) > dp->dp_Arg3)
{ /* We only read as much as requested. */
#ifdef DEBUG
DPutStr("We only read as much as requested..\n");
#endif
CopyMem(workopenfilenode->ofn_OpenFile.of_FileContents, (APTR) dp->dp_Arg2, dp->dp_Arg3);
replypkt1(dp, dp->dp_Arg3);
workopenfilenode->ofn_OpenFile.of_PointerInFile = workopenfilenode->ofn_OpenFile.of_PointerInFile + dp->dp_Arg3;
}
else
{ /* We read all that is left of the file but not as much as is requested.*/
#ifdef DEBUG
DPutStr("We read all that is left of the file but not as much as is requested.\n");
#endif
CopyMem(workopenfilenode->ofn_OpenFile.of_FileContents, (APTR) dp->dp_Arg2, (ULONG) strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile));
replypkt1(dp, (LONG) strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile));
workopenfilenode->ofn_OpenFile.of_PointerInFile = workopenfilenode->ofn_OpenFile.of_PointerInFile + strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile);
}
}
else
{ /* strlen(workopenfilenode->ofn_OpenFile.of_PointerInFile) == 0 ==> EOF */
#ifdef DEBUG
DPutStr("This file is in EOF state.\n");
#endif
/* workopenfilenode->ofn_OpenFile.of_PointerInFile == '\0' */
CopyMem("\0", (APTR) dp->dp_Arg2, 1);
/*dp->dp_Arg2 = '\0';*/
replypkt1(dp, 0);
}
break;
case ACTION_END: /* Close file*/
#ifdef DEBUG
DPutStr("Received packet ACTION_END.\n");
#endif
workopenfilenode = (struct OpenFileNode *) dp->dp_Arg1;
#ifdef DEBUG
DPutStr("workopenfilenode->ofn_OpenFile.of_PointerInFile: ");
DPutStr(workopenfilenode->ofn_OpenFile.of_PointerInFile);
DPutStr("\n");
#endif
Remove((struct Node *) workopenfilenode);
FreeMem(workopenfilenode, sizeof(struct OpenFileNode));
replypkt1(dp, DOSTRUE);
break;
case ACTION_DIE:
#ifdef DEBUG
DPutStr("Received packet ACTION_END.\n");
#endif
remove_handler = TRUE;
replypkt1(dp, DOSTRUE);
break;
default:
replypkt2(dp, DOSFALSE, ERROR_ACTION_NOT_KNOWN);
break;
}
}
}
while(remove_handler != TRUE);
#ifdef DEBUG
DPutStr("Now out of main loop.\n");
#endif
FreeMem((struct List *) openfilelist, sizeof(struct MinList)); /* Free list header */
}
dn->dn_Task = NULL;
/*Delay( 30 * TICKS_PER_SECOND); DONT USE!! THIS IS A TASK!!!*/
CloseLibrary((struct Library *) DosBase);
} /* END: If DosLibrary V 37*/
else
{ /* DosLibrary below 37, Should report before quitting, maybe intuition requester*/
}
#ifdef DEBUG
DPutStr("Now ending the handler.\n\n\n\n");
#endif
}
static void replypkt1(
struct DosPacket *dp,
LONG res1)
{
struct MsgPort *mp;
struct Message *mn;
mp = dp->dp_Port;
mn = dp->dp_Link;
mn->mn_Node.ln_Name = (char *)dp;
dp->dp_Port = &((struct Process *)FindTask(NULL))->pr_MsgPort;
dp->dp_Res1 =res1;
PutMsg(mp, mn);
}
static void replypkt2(
struct DosPacket *dp,
LONG res1,
LONG res2)
{
dp->dp_Res2 = res2;
replypkt1(dp, res1);
}
/*
** This file is free software according to the GNU Public license
** Viite-Handler Copyright (C) 2002 Mikko Koivunalho
** Header file for functions to create viitenumeros.
** Functions to create viitenumeros.
*/
#include
#include
#include
/* Function returns 1 if the string ehdotelma_p is suitable
** to be modified to a viitenumero, 0 otherwise. */
int is_good_for_viitenumero(const char *ehdotelma_p)
{
int i;
if(0 < strlen(ehdotelma_p) && strlen(ehdotelma_p) < 20)
{
/* There are 1-19 characters in ehdotelma_p. */
for(i = 0; i < strlen(ehdotelma_p); i++)
{
if(isdigit(ehdotelma_p[i]) == 0)
{
return 0;
} /* If anything unsuitable is found, we break the
** loop and return right away. */
}
/* i == strlen(ehdotelma_p) + 1 */
return 1;
}
else
{
return 0;
}
}
/* Make a viitenumero from string alkunumero_p.
** alkunumero_p must be suitable for this purpose,
** i.e. is must pass is_good_for_viitenumero().
** If it does not, the return of this function
** is not defined. You have been warned!
**
** The buffer valmisnumero_p must be atleast of size
** strlen(alkunumero_p) + 1 + 1 ('\0'). Return value undefined.
*/
int viitenumero(const char *alkunumero_p, char *valmisnumero_p)
{
int tarkisteluku, summa, kertoluvut_index, i;
char temp_s[2] = {0, '\0'};
int kertoluvut[3] = {7, 3, 1};
for(kertoluvut_index = 0, summa = 0, i = strlen(alkunumero_p) - 1; i >= 0; i--)
{
temp_s[0] = alkunumero_p[i];
summa = atoi(temp_s) * kertoluvut[kertoluvut_index] + summa;
if(kertoluvut_index == 2) { kertoluvut_index = 0;}
else { kertoluvut_index = kertoluvut_index + 1; }
}
if(summa % 10 == 0) {tarkisteluku = 0;}
else { tarkisteluku = (summa / 10 + 1) * 10 - summa; }
strcpy(valmisnumero_p, alkunumero_p);
temp_s[0] = 48 + tarkisteluku;
strcat(valmisnumero_p, temp_s);
return 1;
}
/* Split the string jaksotettava_p into series of jakson_pituus
** beginning from the end of the string.
** Eg. 12345678901 => 1 23456 78901
** The buffer jaksotettava_p length must be atleast
** strlen(jaksotettava_p) / jakson_pituus + 1 ('\0').
** Return value undefined. Do not set jakson_pituus <= 0
*/
int split_into_series(char *jaksotettava_p, int jakson_pituus)
{
int i, alkup_i;
if(strlen(jaksotettava_p) > jakson_pituus && jakson_pituus > 0)
{
alkup_i = strlen(jaksotettava_p);
if(alkup_i % jakson_pituus == 0) {i = jakson_pituus + 1; }
else {i = alkup_i % jakson_pituus + 1; }
while(i < alkup_i + alkup_i / jakson_pituus)
{
strins(&jaksotettava_p[i-1], " ");
i = i + jakson_pituus + 1;
}
return 1;
}
else
{ /* No processing needed, strlen(jaksotettava_p) <= jakson_pituus.*/
return 1;
}
}
/*
** This file is free software according to the GNU Public license
** Viite-Handler Copyright (C) 2002 Mikko Koivunalho
** Header file for functions to create viitenumeros.
*/
#ifndef VIITENUMERO_H
#define VIITENUMERO_H 1
extern int is_good_for_viitenumero(const char *ehdotelma_p);
extern int viitenumero(const char *alkunumero_p, char *valmisnumero_p);
extern int split_into_series(char *jaksotettava_p, int jakson_pituus);
#endif
// File Society_Member.cxx
// Entry of a member
#ifndef SOCIETY_MEMBER_CXX
#define SOCIETY_MEMBER_CXX
#include
#include
#include
#include "Society_Member.h"
void Society_Member::Put_IDnumber(const int number)
{
member_IDnumber = number;
}
void Society_Member::Put_member_class(const int m_class)
{
member_member_class = m_class;
}
void Society_Member::Put_surname(const char* surname)
{
delete member_surname;
member_surname = new strstream();
*member_surname << surname << ends;
}
void Society_Member::Put_forenames(const char* forenames)
{
delete member_forenames;
member_forenames = new strstream();
*member_forenames << forenames << ends;
}
void Society_Member::Put_address(const char* address)
{
delete member_address;
member_address = new strstream();
*member_address << address << ends;
}
void Society_Member::Add_association_number(const int number)
{
int i;
for(i = 0; (i < MAX_ASSOCIATIONS) && (member_associations[i] != 0); i++)
{ ; }
if (i < MAX_ASSOCIATIONS)
{
member_associations[i] = number;
}
}
void Society_Member::Add_membership_year(const int year)
{
int i;
for(i = 0; ((i < MAX_MEMBERSHIP_PAID_YEARS) && (member_membership_years[i] != 0)); i++)
{ ; }
if (i < MAX_MEMBERSHIP_PAID_YEARS)
{
member_membership_years[i] = year;
}
}
int* Society_Member::Get_association_numbers(int* how_many)
{
int i;
for(i = 0; (i < MAX_ASSOCIATIONS) && (member_associations[i] != 0); i++)
{ ; }
*how_many = i;
return &member_associations[0];
}
int* Society_Member::Get_membership_years(int* how_many)
{
int i;
for(i = 0; ((i < MAX_MEMBERSHIP_PAID_YEARS) && (member_membership_years[i] != 0)); i++)
{ ; }
*how_many = i;
return &member_membership_years[0];
}
void Society_Member::Add_other_info(const char* info_name, const char* info_content)
{
if(member_other_info_count < MAX_OTHER_INFO)
{
member_other_info_name[member_other_info_count] = new strstream();
member_other_info_content[member_other_info_count] = new strstream();
*member_other_info_name[member_other_info_count] << info_name << ends;
*member_other_info_content[member_other_info_count] << info_content << ends;
member_other_info_count++;
}
}
int Society_Member::Get_other_infos(char* info_name[], char* info_content[])
{
int i;
strstream* string;
for(i = 0; i < member_other_info_count; i++)
{
string = member_other_info_name[i];
//*info_name[i] = (member_other_info_name[i])->str();
info_name[i] = string->str();
string = member_other_info_content[i];
//*info_content[i] = (member_other_info_content[i])->str();
info_content[i] = string->str();
}
return member_other_info_count;
}
void Society_Member::Empty_all()
{
int i;
delete member_surname;
delete member_forenames;
delete member_address;
member_IDnumber = 0;
member_member_class = 0;
member_surname = new strstream();
member_forenames = new strstream();
member_address = new strstream();
for(i = 0; i < MAX_ASSOCIATIONS; i++)
{ member_associations[i] = 0; }
for(i = 0; i < MAX_MEMBERSHIP_PAID_YEARS; i++)
{ member_membership_years[i] = 0; }
member_other_info_count = 0;
for(i = 0; i < member_other_info_count; i++)
{
delete member_other_info_name[i];
delete member_other_info_content[i];
}
member_other_info_count = 0;
}
Society_Member::Society_Member()
{
int i;
member_surname = new strstream();
member_forenames = new strstream();
member_address = new strstream();
for(i = 0; i < MAX_ASSOCIATIONS; i++)
{ member_associations[i] = 0; }
for(i = 0; i < MAX_MEMBERSHIP_PAID_YEARS; i++)
{ member_membership_years[i] = 0; }
member_other_info_count = 0;
}
Society_Member::~Society_Member()
{
int i;
delete member_surname;
delete member_forenames;
delete member_address;
for(i = 0; i < member_other_info_count; i++)
{
delete member_other_info_name[i];
delete member_other_info_content[i];
}
}
#endif
// File Society_Member.h
// Entry of a member
#ifndef SOCIETY_MEMBER_H
#define SOCIETY_MEMBER_H
/*#define MAX_ADDRESS_LINES 5*/
#define MAX_ASSOCIATIONS 10
#define MAX_MEMBERSHIP_PAID_YEARS 20
#define MAX_OTHER_INFO 3
#include
class Society_Member {
int member_IDnumber; // An ID number of some sort of a member
int member_member_class; // e.g. full member or restricted member
strstream* member_surname;
strstream* member_forenames;
strstream* member_address;
int member_associations[MAX_ASSOCIATIONS]; // other member IDnumbers
int member_membership_years[MAX_MEMBERSHIP_PAID_YEARS]; // For which years membership is paid for
strstream* member_other_info_name[MAX_OTHER_INFO];
strstream* member_other_info_content[MAX_OTHER_INFO];
int member_other_info_count;
public:
Society_Member();
~Society_Member();
void Empty_all();
void Put_IDnumber(const int number);
void Put_member_class(const int m_class);
void Put_surname(const char* surname);
void Put_forenames(const char* forenames);
void Put_address(const char* address);
void Add_association_number(const int number);
void Add_membership_year(const int year);
void Add_other_info(const char* info_name, const char* info_content);
int Get_IDnumber();
int Get_member_class();
char* Get_surname();
char* Get_forenames();
char* Get_address();
int* Get_association_numbers(int* how_many);
int* Get_membership_years(int* how_many);
char* Get_other_info_content(const char* info_name);
int Get_other_infos(char* info_name[], char* info_content[]);
int Get_other_info_count();
};
inline int Society_Member::Get_IDnumber()
{
return member_IDnumber;
}
inline int Society_Member::Get_member_class()
{
return member_member_class;
}
inline char* Society_Member::Get_surname()
{
return member_surname->str();
}
inline char* Society_Member::Get_forenames()
{
return member_forenames->str();
}
inline char* Society_Member::Get_address()
{
return member_address->str();
}
inline int Society_Member::Get_other_info_count()
{
return member_other_info_count;
}
#endif
#!/opt/bin/perl
sub haesanatulo {
$hakusana = shift @_;
local $kokotulo_os = shift @_;
open( TULOPUTKI, "lynx -source http://www.mofile.fi/cgi-bin/mofind.exe/xr1?word=$hakusana |" );
while( ) {
push @$kokotulo_os, $_;
}
close( TULOPUTKI );
}
sub erottelesanat {
$hakusana = shift @_;
local $raakasanat_os = shift @_;
local $sanalista_os = shift @_;
@_ = @$raakasanat_os;
while( ($rivi = shift @_) ne "" ) {
chomp;
if( $rivi =~ /(Key|Word): <b><i>$hakusana<\/i><\/b>/i ) {
push @sanataulukko, $rivi;
do {
$rivi = shift @_;
push @sanataulukko, $rivi;
}
until ( ( $rivi =~ "" ) ||
( $rivi =~ "