Commit 765bcabe authored by Bruno Coudoin's avatar Bruno Coudoin

added 2008 copyright GCompris wide.

svn path=/branches/gcomprixogoo/; revision=3345
parent 16001977
/*
Platypus - create MacOS X application bundles that execute scripts
This is the executable that goes into Platypus apps
Copyright (C) 2003 Sveinbjorn Thordarson <sveinbt@hi.is>
Copyright (C) 2003, 2008 Sveinbjorn Thordarson <sveinbt@hi.is>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -23,7 +23,7 @@
///////////////////////////////////////
// Includes
///////////////////////////////////////
///////////////////////////////////////
#pragma mark Includes
// Apple stuff
......@@ -38,7 +38,7 @@
///////////////////////////////////////
// Definitions
///////////////////////////////////////
///////////////////////////////////////
#pragma mark Definitions
// name length limits
......@@ -52,12 +52,12 @@
#define kEventClassRedFatalAlert 911
#define kEventKindX11Failed 911
//maximum arguments the script accepts
//maximum arguments the script accepts
#define kMaxArgumentsToScript 252
///////////////////////////////////////
// Prototypes
///////////////////////////////////////
///////////////////////////////////////
#pragma mark Prototypes
static void *Execute(void *arg);
......@@ -85,7 +85,7 @@ static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
///////////////////////////////////////
// Globals
///////////////////////////////////////
///////////////////////////////////////
#pragma mark Globals
// process id of forked process
......@@ -141,13 +141,13 @@ int main(int argc, char* argv[])
//create the menu bar
if ((err = LoadMenuBar(NULL))) RedFatalAlert("\pInitialization Error",
"\pError loading MenuBar.nib.");
GetParameters(); //load data from files containing exec settings
RunApplicationEventLoop(); //Run the event loop
return 0;
}
#pragma mark -
///////////////////////////////////
......@@ -156,7 +156,7 @@ int main(int argc, char* argv[])
static void *Execute (void *arg)
{
EventRef event;
taskDone = false;
if (ExecuteScript(scriptPath, &pid) == (OSErr)11) {
CreateEvent(NULL, kEventClassRedFatalAlert, kEventKindX11Failed, 0,
......@@ -183,16 +183,16 @@ static OSErr ExecuteScript (char *script, pid_t *pid)
{
pid_t wpid = 0, p = 0;
int status, i;
if (! pid) pid = &p;
// Generate the array of argument strings before we do any executing
arguments[0] = script;
for (i = 0; i < numArgs; i++) arguments[i + 1] = fileArgs[i];
arguments[i + 1] = NULL;
*pid = fork(); //open fork
if (*pid == (pid_t)-1) exit(13); //error
else if (*pid == 0) { //child process started
execve(arguments[0], arguments, environ);
......@@ -200,7 +200,7 @@ static OSErr ExecuteScript (char *script, pid_t *pid)
}
wpid = waitpid(*pid, &status, 0); //wait while child process finishes
if (wpid == (pid_t)-1) return wpid;
return (OSErr)WEXITSTATUS(status);
}
......@@ -218,7 +218,7 @@ static void GetParameters (void)
RedFatalAlert("\pInitialization Error",
"\pError getting script from application bundle.");
strcpy((char *)&scriptPath, str);
if (! (str = (char *)GetOpenDoc())) //get path to openDoc
RedFatalAlert("\pInitialization Error",
"\pError getting openDoc from application bundle.");
......@@ -244,23 +244,23 @@ static char* GetScript (void)
return NULL;
if (! (scriptFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
NULL))) return NULL;
//Get file reference from Core Foundation URL
if (! CFURLGetFSRef(scriptFileURL, &fileRef)) return NULL;
//dispose of the CF variables
CFRelease(scriptFileURL);
CFRelease(fileName);
//convert FSRef to FSSpec
if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec,
NULL)) return NULL;
//create path string
if (! (path = malloc(kMaxPathLength))) return NULL;
if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL;
if (! DoesFileExist(path)) return NULL;
return path;
}
......@@ -275,7 +275,7 @@ static char* GetOpenDoc (void)
FSRef fileRef;
FSSpec fileSpec;
char *path;
//get CF URL for openDoc
if (! (appBundle = CFBundleGetMainBundle())) return NULL;
if (! (fileName = CFStringCreateWithCString(NULL, kOpenDocFileName,
......@@ -283,14 +283,14 @@ static char* GetOpenDoc (void)
return NULL;
if (! (openDocFileURL = CFBundleCopyResourceURL(appBundle, fileName, NULL,
NULL))) return NULL;
//Get file reference from Core Foundation URL
if (! CFURLGetFSRef( openDocFileURL, &fileRef )) return NULL;
//dispose of the CF variables
CFRelease(openDocFileURL);
CFRelease(fileName);
//convert FSRef to FSSpec
if (FSGetCatalogInfo(&fileRef, kFSCatInfoNone, NULL, NULL, &fileSpec,
NULL)) return NULL;
......@@ -299,7 +299,7 @@ static char* GetOpenDoc (void)
if (! (path = malloc(kMaxPathLength))) return NULL;
if (FSMakePath(fileSpec, path, kMaxPathLength)) return NULL;
if (! DoesFileExist(path)) return NULL;
return path;
}
......@@ -312,7 +312,7 @@ OSErr LoadMenuBar (char *appName)
{
OSErr err;
IBNibRef nibRef;
if ((err = CreateNibReference(CFSTR("MenuBar"), &nibRef))) return err;
if ((err = SetMenuBarFromNib(nibRef, CFSTR("MenuBar")))) return err;
DisposeNibReference(nibRef);
......@@ -352,7 +352,7 @@ static void RedFatalAlert (Str255 errorString, Str255 expStr)
static short DoesFileExist (char *path)
{
if (access(path, F_OK) == -1) return false;
return true;
return true;
}
#pragma mark -
......@@ -367,17 +367,17 @@ static OSErr AppQuitAEHandler(const AppleEvent *theAppleEvent,
#pragma unused (reply, refCon, theAppleEvent)
while (numArgs > 0) free(fileArgs[numArgs--]);
if (! taskDone && pid) { //kill the script process brutally
kill(pid, 9);
printf("Platypus App: PID %d killed brutally\n", pid);
}
pthread_cancel(tid);
if (odtid) pthread_cancel(odtid);
ExitToShell();
return noErr;
}
......@@ -388,26 +388,26 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent,
AppleEvent *reply, long refCon)
{
#pragma unused (reply, refCon)
OSErr err = noErr;
AEDescList fileSpecList;
AEKeyword keyword;
DescType type;
short i;
long count, actualSize;
FSSpec fileSpec;
char path[kMaxPathLength];
while (numArgs > 0) free(fileArgs[numArgs--]);
//Read the AppleEvent
err = AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList,
&fileSpecList);
err = AECountItems(&fileSpecList, &count); //Count number of files
for (i = 1; i <= count; i++) { //iteratively process each file
//get fsspec from apple event
if (! (err = AEGetNthPtr(&fileSpecList, i, typeFSS, &keyword, &type,
......@@ -416,7 +416,7 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent,
//get path from file spec
if ((err = FSMakePath(fileSpec, path,
kMaxPathLength))) return err;
if (numArgs == kMaxArgumentsToScript) break;
if (! (fileArgs[numArgs] = malloc(kMaxPathLength))) return true;
......@@ -425,10 +425,10 @@ static OSErr AppOpenDocAEHandler(const AppleEvent *theAppleEvent,
}
else return err;
}
if (! taskDone) pthread_create(&odtid, NULL, OpenDoc, NULL);
else pthread_create(&tid, NULL, Execute, NULL);
return err;
}
......@@ -439,17 +439,17 @@ static OSErr AppOpenAppAEHandler(const AppleEvent *theAppleEvent,
AppleEvent *reply, long refCon)
{
#pragma unused (reply, refCon, theAppleEvent)
// the app has been opened without any items dragged on to it
pthread_create(&tid, NULL, Execute, NULL);
return noErr;
}
//////////////////////////////////
// Handler for when X11 fails to start
//////////////////////////////////
static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
static OSStatus X11FailedHandler(EventHandlerCallRef theHandlerCall,
EventRef theEvent, void *userData)
{
#pragma unused(theHanderCall, theEvent, userData)
......
# gcompris - board_list.py
#
# Copyright (C) 2005 Yves Combe
# Copyright (C) 2005, 2008 Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - class_edit.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - class_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - constants.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - group_edit.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - group_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - group_user_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - log_list.py
#
# Copyright (C) 2007 Bruno Coudoin
# Copyright (C) 2007, 2008 Bruno Coudoin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module_boards.py
#
# Copyright (C) 2005 Yves Combe
# Copyright (C) 2005, 2008 Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module_groups.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module_profiles.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module_reports
#
# Copyright (C) 2007 Bruno Coudoin
# Copyright (C) 2007, 2008 Bruno Coudoin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - module_users
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - profile_edit.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - profile_group_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - profile_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - user_edit.py
#
# Copyright (C) 2005 Bruno Coudoin
# Copyright (C) 2005, 2008 Bruno Coudoin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - user_list.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - board_list.py
#
# Copyright (C) 2005 Yves Combe
# Copyright (C) 2005, 2008 Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - administration.py
#
# Copyright (C) 2005 Bruno Coudoin and Yves Combe
# Copyright (C) 2005, 2008 Bruno Coudoin and Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
/* gcompris - advanced_colors.c
*
* Copyright (C) 2002 Pascal Georges
* Copyright (C) 2002, 2008 Pascal Georges
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - algebra.c
*
* Copyright (C) 2000 Bruno Coudoin
* Copyright (C) 2000, 2008 Bruno Coudoin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - algebra_guesscount.c
*
* Copyright (C) 2001 Pascal Georges
* Copyright (C) 2001, 2008 Pascal Georges
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
# gcompris - algorithm
#
# Copyright (C) 2004 Christof Petig and Ingo Konrad
# Copyright (C) 2004, 2008 Christof Petig and Ingo Konrad
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - anim
#
# Copyright (C) 2003 Bruno Coudoin (redraw code), 2004 Yves Combe (anim code)
# Copyright (C) 2003, 2008 Bruno Coudoin (redraw code), 2004 Yves Combe (anim code)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
/*
* gcompris - awele.c
*
* Copyright (C) 2005 Frederic Mazzarol
* Copyright (C) 2005, 2008 Frederic Mazzarol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/*
* gcompris - awele.h Copyright (C) 2005 Frederic Mazzarol
* gcompris - awele.h
*
* Copyright (C) 2005, 2008 Frederic Mazzarol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/*
* gcompris - awele.c
* Copyright (C) 2005 Frederic Mazzarol
* Copyright (C) 2005, 2008 Frederic Mazzarol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/*
* gcompris - awele.c
*
* Copyright (C) 2005 Frederic Mazzarol
* Copyright (C) 2005, 2008 Frederic Mazzarol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/*
* gcompris - awele.c Copyright (C) 2005 Frederic Mazzarol
* gcompris - awele.c
*
* Copyright (C) 2005, 2008 Frederic Mazzarol
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - shapegame.c
*
* Copyright (C) 2000,2008 Bruno Coudoin
* Copyright (C) 2000, 2008 Bruno Coudoin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
# gcompris - ballcatch.py
#
# Copyright (C) 2003 Bruno Coudoin
# Copyright (C) 2003, 2008 Bruno Coudoin
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
# gcompris - BarGame
#
# Copyright (C) 2004 Yves Combe
# Copyright (C) 2004, 2008 Yves Combe
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......
/* gcompris - billard.c
*
* Copyright (C) 2001 Bruno Coudoin
* Copyright (C) 2001, 2008 Bruno Coudoin
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - menu2.c
*
* Copyright (C) 2000 Bruno Coudoin, Yves Combe
* Copyright (C) 2000, 2008 Bruno Coudoin, Yves Combe
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-gcompris-board.h
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-gcompris-profile.h
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-properties.h
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
/* gcompris - py-mod-gcompris.c
*
* Copyright (C) 2003 Olivier Samyn <osamyn@ulb.ac.be>
* Copyright (C) 2003, 2008 Olivier Samyn <osamyn@ulb.ac.be>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......