Browse Source

Imported Upstream version 0.7.2

tags/upstream/0.7.2^0
Laurent Bigonville 7 years ago
parent
commit
b1edc032bd
53 changed files with 1548 additions and 1417 deletions
  1. +10
    -10
      configure
  2. +1
    -1
      configure.ac
  3. +2
    -1
      scripts/Makefile.am
  4. +2
    -1
      scripts/Makefile.in
  5. +24
    -0
      scripts/plymouth-generate-initrd
  6. +27
    -20
      scripts/plymouth-populate-initrd.in
  7. +0
    -2
      src/Makefile.am
  8. +1
    -20
      src/Makefile.in
  9. +1
    -2
      src/libply/ply-event-loop.c
  10. +2
    -0
      src/libply/ply-event-loop.h
  11. +30
    -1
      src/libply/ply-progress.c
  12. +1
    -0
      src/libply/ply-progress.h
  13. +22
    -0
      src/libply/ply-utils.c
  14. +2
    -0
      src/libply/ply-utils.h
  15. +15
    -3
      src/libplybootsplash/Makefile.am
  16. +27
    -14
      src/libplybootsplash/Makefile.in
  17. +2
    -0
      src/libplybootsplash/ply-boot-splash-plugin.h
  18. +0
    -0
      src/libplybootsplash/ply-boot-splash.c
  19. +0
    -0
      src/libplybootsplash/ply-boot-splash.h
  20. +1
    -1
      src/libplybootsplash/ply-entry.c
  21. +0
    -213
      src/libplybootsplash/ply-text-pulser.c
  22. +0
    -51
      src/libplybootsplash/ply-text-pulser.h
  23. +26
    -41
      src/main.c
  24. +2
    -0
      src/plugins/splash/script/Makefile.am
  25. +13
    -1
      src/plugins/splash/script/Makefile.in
  26. +2
    -1
      src/plugins/splash/script/plugin.c
  27. +71
    -0
      src/plugins/splash/script/script-debug.c
  28. +39
    -0
      src/plugins/splash/script/script-debug.h
  29. +181
    -94
      src/plugins/splash/script/script-execute.c
  30. +5
    -4
      src/plugins/splash/script/script-execute.h
  31. +23
    -33
      src/plugins/splash/script/script-lib-image.c
  32. +3
    -3
      src/plugins/splash/script/script-lib-image.h
  33. +47
    -1
      src/plugins/splash/script/script-lib-image.script
  34. +42
    -50
      src/plugins/splash/script/script-lib-math.c
  35. +3
    -3
      src/plugins/splash/script/script-lib-math.h
  36. +35
    -18
      src/plugins/splash/script/script-lib-math.script
  37. +132
    -129
      src/plugins/splash/script/script-lib-plymouth.c
  38. +19
    -16
      src/plugins/splash/script/script-lib-plymouth.h
  39. +12
    -1
      src/plugins/splash/script/script-lib-plymouth.script
  40. +41
    -51
      src/plugins/splash/script/script-lib-sprite.c
  41. +5
    -5
      src/plugins/splash/script/script-lib-sprite.h
  42. +77
    -5
      src/plugins/splash/script/script-lib-sprite.script
  43. +168
    -265
      src/plugins/splash/script/script-object.c
  44. +20
    -17
      src/plugins/splash/script/script-object.h
  45. +244
    -185
      src/plugins/splash/script/script-parse.c
  46. +5
    -4
      src/plugins/splash/script/script-parse.h
  47. +34
    -29
      src/plugins/splash/script/script-scan.c
  48. +25
    -23
      src/plugins/splash/script/script-scan.h
  49. +19
    -15
      src/plugins/splash/script/script.c
  50. +22
    -15
      src/plugins/splash/script/script.h
  51. +12
    -11
      src/tests/Makefile.in
  52. +2
    -2
      src/tests/ply-boot-splash-test.am
  53. +49
    -55
      themes/script/script.script

+ 10
- 10
configure View File

@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.63 for plymouth 0.7.1.
# Generated by GNU Autoconf 2.63 for plymouth 0.7.2.
#
# Report bugs to <"halfline@gmail.com">.
#
@@ -745,8 +745,8 @@ SHELL=${CONFIG_SHELL-/bin/sh}
# Identity of this package.
PACKAGE_NAME='plymouth'
PACKAGE_TARNAME='plymouth'
PACKAGE_VERSION='0.7.1'
PACKAGE_STRING='plymouth 0.7.1'
PACKAGE_VERSION='0.7.2'
PACKAGE_STRING='plymouth 0.7.2'
PACKAGE_BUGREPORT='"halfline@gmail.com"'

ac_unique_file="src/main.c"
@@ -1530,7 +1530,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
\`configure' configures plymouth 0.7.1 to adapt to many kinds of systems.
\`configure' configures plymouth 0.7.2 to adapt to many kinds of systems.

Usage: $0 [OPTION]... [VAR=VALUE]...

@@ -1600,7 +1600,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of plymouth 0.7.1:";;
short | recursive ) echo "Configuration of plymouth 0.7.2:";;
esac
cat <<\_ACEOF

@@ -1736,7 +1736,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
plymouth configure 0.7.1
plymouth configure 0.7.2
generated by GNU Autoconf 2.63

Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
@@ -1750,7 +1750,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.

It was created by plymouth $as_me 0.7.1, which was
It was created by plymouth $as_me 0.7.2, which was
generated by GNU Autoconf 2.63. Invocation command line was

$ $0 $@
@@ -5556,7 +5556,7 @@ fi

# Define the identity of the package.
PACKAGE='plymouth'
VERSION='0.7.1'
VERSION='0.7.2'


cat >>confdefs.h <<_ACEOF
@@ -13903,7 +13903,7 @@ exec 6>&1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by plymouth $as_me 0.7.1, which was
This file was extended by plymouth $as_me 0.7.2, which was
generated by GNU Autoconf 2.63. Invocation command line was

CONFIG_FILES = $CONFIG_FILES
@@ -13966,7 +13966,7 @@ Report bugs to <bug-autoconf@gnu.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
plymouth config.status 0.7.1
plymouth config.status 0.7.2
configured by $0, generated by GNU Autoconf 2.63,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"



+ 1
- 1
configure.ac View File

@@ -1,4 +1,4 @@
AC_INIT(plymouth, 0.7.1, "halfline@gmail.com")
AC_INIT(plymouth, 0.7.2, "halfline@gmail.com")
AC_CONFIG_SRCDIR(src/main.c)
AC_CONFIG_HEADER(config.h)
AC_CONFIG_AUX_DIR(build-tools)


+ 2
- 1
scripts/Makefile.am View File

@@ -1,7 +1,7 @@
noinst_SCRIPTS = new-object.sh

initrdscriptdir = $(libexecdir)/plymouth
initrdscript_SCRIPTS = plymouth-update-initrd plymouth-populate-initrd
initrdscript_SCRIPTS = plymouth-update-initrd plymouth-generate-initrd plymouth-populate-initrd

sbinscriptsdir = $(sbindir)
sbinscripts_SCRIPTS = plymouth-set-default-theme
@@ -20,6 +20,7 @@ plymouth-set-default-theme: $(srcdir)/plymouth-set-default-theme.in
$(srcdir)/plymouth-set-default-theme.in > plymouth-set-default-theme

EXTRA_DIST= plymouth-update-initrd \
plymouth-generate-initrd \
plymouth-populate-initrd.in \
plymouth-set-default-theme.in \
$(noinst_SCRIPTS) \


+ 2
- 1
scripts/Makefile.in View File

@@ -215,10 +215,11 @@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
noinst_SCRIPTS = new-object.sh
initrdscriptdir = $(libexecdir)/plymouth
initrdscript_SCRIPTS = plymouth-update-initrd plymouth-populate-initrd
initrdscript_SCRIPTS = plymouth-update-initrd plymouth-generate-initrd plymouth-populate-initrd
sbinscriptsdir = $(sbindir)
sbinscripts_SCRIPTS = plymouth-set-default-theme
EXTRA_DIST = plymouth-update-initrd \
plymouth-generate-initrd \
plymouth-populate-initrd.in \
plymouth-set-default-theme.in \
$(noinst_SCRIPTS) \


+ 24
- 0
scripts/plymouth-generate-initrd View File

@@ -0,0 +1,24 @@
#!/bin/bash

[ -z "$DESTDIR" ] || exit 0

[ -z "$PLYMOUTH_LIBEXECDIR" ] && PLYMOUTH_LIBEXECDIR="/usr/libexec"
[ -z "$PLYMOUTH_DATADIR" ] && PLYMOUTH_DATADIR="/usr/share"
[ -z "$PLYMOUTH_POPULATE_INITRD" ] && PLYMOUTH_POPULATE_INITRD="$PLYMOUTH_LIBEXECDIR/plymouth/plymouth-populate-initrd"
[ -z "$PLYMOUTH_DESTDIR" ] && PLYMOUTH_DESTDIR="/boot"
[ -z "$PLYMOUTH_IMAGE_FILE" ] && PLYMOUTH_IMAGE_FILE="$PLYMOUTH_DESTDIR/initrd-plymouth.img"

PLYMOUTH_INITRD_DIR="$(mktemp --tmpdir -d plymouth-XXXXXXX)"

$PLYMOUTH_POPULATE_INITRD -t "$PLYMOUTH_INITRD_DIR"

if [ $? -eq 0 ]; then
(cd $PLYMOUTH_INITRD_DIR;
# FIXME: might make sense to add a flag to plymouth-populate-initrd to
# skip these from the start
rm -f lib*/{ld*,libc*,libdl*,libm*,libz*,libpthread*}
find | cpio -Hnewc -o | gzip -9 > $PLYMOUTH_IMAGE_FILE
)
fi

rm -rf $PLYMOUTH_INITRD_DIR

+ 27
- 20
scripts/plymouth-populate-initrd.in View File

@@ -4,27 +4,34 @@

[ -z "$LIBEXECDIR" ] && LIBEXECDIR="/usr/libexec"
[ -z "$DATADIR" ] && DATADIR="/usr/share"
[ -z "$SYSTEMMAP" ] && SYSTEM_MAP="/boot/System.map-$(/bin/uname -r)"
if [ -z "$LIB" ]; then
if $(echo nash-showelfinterp /proc/$$/exe | /sbin/nash --forcequiet | grep -q lib64); then
LIB="lib64"
else
LIB="lib"
fi
fi
[ -z "$LIBDIR" ] && LIBDIR="/usr/$LIB"
[ -z "$BINDIR" ] && BINDIR="/usr/bin"
[ -z "$GRUB_MENU_TITLE" ] && GRUB_MENU_TITLE="Graphical Bootup"
[ -z "$PLYMOUTH_PLUGIN_PATH" ] && PLYMOUTH_PLUGIN_PATH="$(plymouth --get-splash-plugin-path)"
[ -z "$PLYMOUTH_LOGO_FILE" ] && PLYMOUTH_LOGO_FILE="@logofile@"
[ -z "$PLYMOUTH_THEME_NAME" ] && PLYMOUTH_THEME_NAME=$(plymouth-set-default-theme)

if [ -f "${LIBEXECDIR}/initrd-functions" ]; then
. "${LIBEXECDIR}/initrd-functions"
else
echo "Couldn't import initrd functions." > /dev/stderr
if [ -z "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then

if [ -f "${LIBEXECDIR}/initrd-functions" ]; then
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="${LIBEXECDIR}/initrd-functions"
fi

if [ -f "${DATADIR}/dracut/dracut-functions" ]; then
PLYMOUTH_POPULATE_SOURCE_FUNCTIONS="${DATADIR}/dracut/dracut-functions"
fi
fi

if [ -n "$PLYMOUTH_POPULATE_SOURCE_FUNCTIONS" ]; then
source $PLYMOUTH_POPULATE_SOURCE_FUNCTIONS
fi

if [ " $(type -t inst) " != " function " ]; then
echo "Need 'inst' function, try setting PLYMOUTH_POPULATE_SOURCE_FUNCTIONS to a file that defines it" 1>&2
exit 1
fi

if [ " $(type -t set_verbose) " != " function " ]; then
function set_verbose { true; }
fi

function usage() {
local output="/dev/stdout"
local rc=0
@@ -58,7 +65,7 @@ while [ $# -gt 0 ]; do
esac
shift
done
set_verbose $verbose
set_verbose $verbose || :

[ -z "$INITRDDIR" ] && usage error

@@ -66,9 +73,9 @@ mkdir -p ${INITRDDIR}${DATADIR}/plymouth/themes
inst /sbin/plymouthd $INITRDDIR /bin/plymouthd
inst /bin/plymouth $INITRDDIR
inst ${DATADIR}/plymouth/themes/text/text.plymouth $INITRDDIR
inst ${LIBDIR}/plymouth/text.so $INITRDDIR
inst ${PLYMOUTH_PLUGIN_PATH}/text.so $INITRDDIR
inst ${DATADIR}/plymouth/themes/details/details.plymouth $INITRDDIR
inst ${LIBDIR}/plymouth/details.so $INITRDDIR
inst ${PLYMOUTH_PLUGIN_PATH}/details.so $INITRDDIR
inst ${PLYMOUTH_LOGO_FILE} $INITRDDIR
inst @RELEASE_FILE@ $INITRDDIR

@@ -79,12 +86,12 @@ fi

PLYMOUTH_MODULE_NAME=$(grep "ModuleName *= *" ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/${PLYMOUTH_THEME_NAME}.plymouth | sed 's/ModuleName *= *//')

if [ ! -f ${LIBDIR}/plymouth/${PLYMOUTH_MODULE_NAME}.so ]; then
if [ ! -f ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so ]; then
echo "The default plymouth plugin (${PLYMOUTH_MODULE_NAME}) doesn't exist" > /dev/stderr
exit 1
fi

inst ${LIBDIR}/plymouth/${PLYMOUTH_MODULE_NAME}.so $INITRDDIR
inst ${PLYMOUTH_PLUGIN_PATH}/${PLYMOUTH_MODULE_NAME}.so $INITRDDIR

if [ -d ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME} ]; then
for x in ${DATADIR}/plymouth/themes/${PLYMOUTH_THEME_NAME}/* ; do


+ 0
- 2
src/Makefile.am View File

@@ -19,8 +19,6 @@ plymouthd_SOURCES = \
ply-boot-protocol.h \
ply-boot-server.h \
ply-boot-server.c \
ply-boot-splash.h \
ply-boot-splash.c \
main.c

plymouthdrundir = $(localstatedir)/run/plymouth


+ 1
- 20
src/Makefile.in View File

@@ -52,7 +52,7 @@ am__installdirs = "$(DESTDIR)$(plymouthdbindir)" \
"$(DESTDIR)$(pkgconfigdir)"
PROGRAMS = $(plymouthdbin_PROGRAMS)
am_plymouthd_OBJECTS = plymouthd-ply-boot-server.$(OBJEXT) \
plymouthd-ply-boot-splash.$(OBJEXT) plymouthd-main.$(OBJEXT)
plymouthd-main.$(OBJEXT)
plymouthd_OBJECTS = $(am_plymouthd_OBJECTS)
am__DEPENDENCIES_1 =
plymouthd_DEPENDENCIES = $(am__DEPENDENCIES_1) libply/libply.la \
@@ -308,8 +308,6 @@ plymouthd_SOURCES = \
ply-boot-protocol.h \
ply-boot-server.h \
ply-boot-server.c \
ply-boot-splash.h \
ply-boot-splash.c \
main.c

plymouthdrundir = $(localstatedir)/run/plymouth
@@ -410,7 +408,6 @@ distclean-compile:

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plymouthd-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plymouthd-ply-boot-server.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/plymouthd-ply-boot-splash.Po@am__quote@

.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -452,22 +449,6 @@ plymouthd-ply-boot-server.obj: ply-boot-server.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -c -o plymouthd-ply-boot-server.obj `if test -f 'ply-boot-server.c'; then $(CYGPATH_W) 'ply-boot-server.c'; else $(CYGPATH_W) '$(srcdir)/ply-boot-server.c'; fi`

plymouthd-ply-boot-splash.o: ply-boot-splash.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -MT plymouthd-ply-boot-splash.o -MD -MP -MF $(DEPDIR)/plymouthd-ply-boot-splash.Tpo -c -o plymouthd-ply-boot-splash.o `test -f 'ply-boot-splash.c' || echo '$(srcdir)/'`ply-boot-splash.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/plymouthd-ply-boot-splash.Tpo $(DEPDIR)/plymouthd-ply-boot-splash.Po
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ply-boot-splash.c' object='plymouthd-ply-boot-splash.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -c -o plymouthd-ply-boot-splash.o `test -f 'ply-boot-splash.c' || echo '$(srcdir)/'`ply-boot-splash.c

plymouthd-ply-boot-splash.obj: ply-boot-splash.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -MT plymouthd-ply-boot-splash.obj -MD -MP -MF $(DEPDIR)/plymouthd-ply-boot-splash.Tpo -c -o plymouthd-ply-boot-splash.obj `if test -f 'ply-boot-splash.c'; then $(CYGPATH_W) 'ply-boot-splash.c'; else $(CYGPATH_W) '$(srcdir)/ply-boot-splash.c'; fi`
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/plymouthd-ply-boot-splash.Tpo $(DEPDIR)/plymouthd-ply-boot-splash.Po
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ply-boot-splash.c' object='plymouthd-ply-boot-splash.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -c -o plymouthd-ply-boot-splash.obj `if test -f 'ply-boot-splash.c'; then $(CYGPATH_W) 'ply-boot-splash.c'; else $(CYGPATH_W) '$(srcdir)/ply-boot-splash.c'; fi`

plymouthd-main.o: main.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(plymouthd_CFLAGS) $(CFLAGS) -MT plymouthd-main.o -MD -MP -MF $(DEPDIR)/plymouthd-main.Tpo -c -o plymouthd-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/plymouthd-main.Tpo $(DEPDIR)/plymouthd-main.Po


+ 1
- 2
src/libply/ply-event-loop.c View File

@@ -118,7 +118,6 @@ struct _ply_event_loop
uint32_t should_exit : 1;
};

static void ply_event_loop_process_pending_events (ply_event_loop_t *loop);
static void ply_event_loop_remove_source (ply_event_loop_t *loop,
ply_event_source_t *source);
static ply_list_node_t *ply_event_loop_find_source_node (ply_event_loop_t *loop,
@@ -1209,7 +1208,7 @@ ply_event_loop_handle_timeouts (ply_event_loop_t *loop)

}

static void
void
ply_event_loop_process_pending_events (ply_event_loop_t *loop)
{
int number_of_received_events, i;


+ 2
- 0
src/libply/ply-event-loop.h View File

@@ -81,6 +81,8 @@ void ply_event_loop_stop_watching_for_timeout (ply_event_loop_t *loop,
int ply_event_loop_run (ply_event_loop_t *loop);
void ply_event_loop_exit (ply_event_loop_t *loop,
int exit_code);
void
ply_event_loop_process_pending_events (ply_event_loop_t *loop);
#endif

#endif


+ 30
- 1
src/libply/ply-progress.c View File

@@ -80,7 +80,7 @@ ply_progress_new (void)
progress->last_percentage=0.0;
progress->last_percentage_time=0.0;
progress->dead_time=0.0;
progress->next_message_percentage=1.0;
progress->next_message_percentage=0.25;
progress->current_message_list = ply_list_new ();
progress->previous_message_list = ply_list_new ();
progress->paused = false;
@@ -256,6 +256,14 @@ ply_progress_get_percentage (ply_progress_t* progress)
return percentage;
}

void
ply_progress_set_percentage (ply_progress_t* progress, double percentage)
{
progress->next_message_percentage = 1;
progress->scalar += percentage / (ply_progress_get_time(progress)-progress->dead_time);
progress->scalar /= 2;
return;
}

double
ply_progress_get_time (ply_progress_t* progress)
@@ -361,6 +369,27 @@ main (int argc,
printf("Save and free cache\n");
ply_progress_save_cache (progress, PLYMOUTH_TIME_DIRECTORY "/boot-duration");
ply_progress_free(progress);

printf("\nManual set percentage run\n\n");

progress = ply_progress_new ();
progress->scalar = 1.0/5; /* Original time estimate is 5 sec*/

percent = ply_progress_get_percentage (progress);
time = ply_progress_get_time (progress);
printf("Time:%f \t Percentage: %f%%\n", time, percent*100);
srand ((int) ply_get_timestamp ());

for (i=0; i<12; i++)
{
ply_progress_set_percentage (progress, (double)i/12);
usleep ((rand () % slowness+slowness));
percent = ply_progress_get_percentage (progress);
time = ply_progress_get_time (progress);
printf("Time:%f \t Percentage: %f%% (%f%%)\tScalar:%f\n", time, percent*100, (double)i/12*100, progress->scalar);
}
ply_progress_free(progress);

return 0;
}



+ 1
- 0
src/libply/ply-progress.h View File

@@ -31,6 +31,7 @@ ply_progress_t *ply_progress_new (void);
void ply_progress_free (ply_progress_t* progress);
void ply_progress_load_cache (ply_progress_t* progress, const char *filename);
double ply_progress_get_percentage (ply_progress_t* progress);
void ply_progress_set_percentage (ply_progress_t* progress, double percentage);
double ply_progress_get_time (ply_progress_t* progress);
void ply_progress_pause (ply_progress_t* progress);
void ply_progress_unpause (ply_progress_t* progress);


+ 22
- 0
src/libply/ply-utils.c View File

@@ -42,6 +42,7 @@
#include <sys/un.h>
#include <time.h>
#include <linux/fs.h>
#include <linux/vt.h>

#include <dlfcn.h>

@@ -893,4 +894,25 @@ ply_utf8_string_get_length (const char *string,
return count;
}

void
ply_switch_to_vt (int vt_number)
{
int fd;

fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);

if (fd < 0)
return;

if (ioctl (fd, VT_ACTIVATE, vt_number) < 0)
{
close (fd);
return;
}

ioctl (fd, VT_WAITACTIVE, vt_number);
close (fd);
}


/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */

+ 2
- 0
src/libply/ply-utils.h View File

@@ -104,6 +104,8 @@ int ply_utf8_character_get_size (const char *string,
int ply_utf8_string_get_length (const char *string,
size_t n);

void ply_switch_to_vt (int vt_number);

#endif

#endif /* PLY_UTILS_H */


+ 15
- 3
src/libplybootsplash/Makefile.am View File

@@ -6,7 +6,19 @@ INCLUDES = -I$(top_srcdir) \
lib_LTLIBRARIES = libplybootsplash.la

libplybootsplashdir = $(includedir)/plymouth-1/plybootsplash
libplybootsplash_HEADERS = ply-entry.h ply-image.h ply-progress-bar.h ply-text-progress-bar.h ply-text-pulser.h ply-throbber.h ply-animation.h ply-progress-animation.h ply-window.h ply-label.h ply-boot-splash-plugin.h ply-label-plugin.h
libplybootsplash_HEADERS = \
ply-animation.h \
ply-boot-splash.h \
ply-boot-splash-plugin.h \
ply-entry.h \
ply-image.h \
ply-label.h \
ply-label-plugin.h \
ply-progress-animation.h \
ply-progress-bar.h \
ply-text-progress-bar.h \
ply-throbber.h \
ply-window.h

libplybootsplash_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
$(IMAGE_CFLAGS) \
@@ -28,7 +40,7 @@ libplybootsplash_la_SOURCES = \
ply-animation.c \
ply-progress-animation.c \
ply-text-progress-bar.c \
ply-text-pulser.c \
ply-window.c
ply-window.c \
ply-boot-splash.c

MAINTAINERCLEANFILES = Makefile.in

+ 27
- 14
src/libplybootsplash/Makefile.in View File

@@ -84,8 +84,8 @@ am_libplybootsplash_la_OBJECTS = $(am__objects_1) \
libplybootsplash_la-ply-animation.lo \
libplybootsplash_la-ply-progress-animation.lo \
libplybootsplash_la-ply-text-progress-bar.lo \
libplybootsplash_la-ply-text-pulser.lo \
libplybootsplash_la-ply-window.lo
libplybootsplash_la-ply-window.lo \
libplybootsplash_la-ply-boot-splash.lo
libplybootsplash_la_OBJECTS = $(am_libplybootsplash_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
@@ -267,7 +267,20 @@ INCLUDES = -I$(top_srcdir) \

lib_LTLIBRARIES = libplybootsplash.la
libplybootsplashdir = $(includedir)/plymouth-1/plybootsplash
libplybootsplash_HEADERS = ply-entry.h ply-image.h ply-progress-bar.h ply-text-progress-bar.h ply-text-pulser.h ply-throbber.h ply-animation.h ply-progress-animation.h ply-window.h ply-label.h ply-boot-splash-plugin.h ply-label-plugin.h
libplybootsplash_HEADERS = \
ply-animation.h \
ply-boot-splash.h \
ply-boot-splash-plugin.h \
ply-entry.h \
ply-image.h \
ply-label.h \
ply-label-plugin.h \
ply-progress-animation.h \
ply-progress-bar.h \
ply-text-progress-bar.h \
ply-throbber.h \
ply-window.h

libplybootsplash_la_CFLAGS = $(PLYMOUTH_CFLAGS) \
$(IMAGE_CFLAGS) \
-DPLYMOUTH_BACKGROUND_COLOR=$(background_color) \
@@ -290,8 +303,8 @@ libplybootsplash_la_SOURCES = \
ply-animation.c \
ply-progress-animation.c \
ply-text-progress-bar.c \
ply-text-pulser.c \
ply-window.c
ply-window.c \
ply-boot-splash.c

MAINTAINERCLEANFILES = Makefile.in
all: all-am
@@ -369,13 +382,13 @@ distclean-compile:
-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-animation.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-boot-splash.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-entry.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-image.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-label.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-progress-animation.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-progress-bar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-text-progress-bar.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-text-pulser.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-throbber.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libplybootsplash_la-ply-window.Plo@am__quote@

@@ -467,14 +480,6 @@ libplybootsplash_la-ply-text-progress-bar.lo: ply-text-progress-bar.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -c -o libplybootsplash_la-ply-text-progress-bar.lo `test -f 'ply-text-progress-bar.c' || echo '$(srcdir)/'`ply-text-progress-bar.c

libplybootsplash_la-ply-text-pulser.lo: ply-text-pulser.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -MT libplybootsplash_la-ply-text-pulser.lo -MD -MP -MF $(DEPDIR)/libplybootsplash_la-ply-text-pulser.Tpo -c -o libplybootsplash_la-ply-text-pulser.lo `test -f 'ply-text-pulser.c' || echo '$(srcdir)/'`ply-text-pulser.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libplybootsplash_la-ply-text-pulser.Tpo $(DEPDIR)/libplybootsplash_la-ply-text-pulser.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ply-text-pulser.c' object='libplybootsplash_la-ply-text-pulser.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -c -o libplybootsplash_la-ply-text-pulser.lo `test -f 'ply-text-pulser.c' || echo '$(srcdir)/'`ply-text-pulser.c

libplybootsplash_la-ply-window.lo: ply-window.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -MT libplybootsplash_la-ply-window.lo -MD -MP -MF $(DEPDIR)/libplybootsplash_la-ply-window.Tpo -c -o libplybootsplash_la-ply-window.lo `test -f 'ply-window.c' || echo '$(srcdir)/'`ply-window.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libplybootsplash_la-ply-window.Tpo $(DEPDIR)/libplybootsplash_la-ply-window.Plo
@@ -483,6 +488,14 @@ libplybootsplash_la-ply-window.lo: ply-window.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -c -o libplybootsplash_la-ply-window.lo `test -f 'ply-window.c' || echo '$(srcdir)/'`ply-window.c

libplybootsplash_la-ply-boot-splash.lo: ply-boot-splash.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -MT libplybootsplash_la-ply-boot-splash.lo -MD -MP -MF $(DEPDIR)/libplybootsplash_la-ply-boot-splash.Tpo -c -o libplybootsplash_la-ply-boot-splash.lo `test -f 'ply-boot-splash.c' || echo '$(srcdir)/'`ply-boot-splash.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libplybootsplash_la-ply-boot-splash.Tpo $(DEPDIR)/libplybootsplash_la-ply-boot-splash.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='ply-boot-splash.c' object='libplybootsplash_la-ply-boot-splash.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libplybootsplash_la_CFLAGS) $(CFLAGS) -c -o libplybootsplash_la-ply-boot-splash.lo `test -f 'ply-boot-splash.c' || echo '$(srcdir)/'`ply-boot-splash.c

mostlyclean-libtool:
-rm -f *.lo



+ 2
- 0
src/libplybootsplash/ply-boot-splash-plugin.h View File

@@ -36,6 +36,8 @@ typedef enum
{
PLY_BOOT_SPLASH_MODE_BOOT_UP,
PLY_BOOT_SPLASH_MODE_SHUTDOWN,
PLY_BOOT_SPLASH_MODE_SUSPEND,
PLY_BOOT_SPLASH_MODE_RESUME,
} ply_boot_splash_mode_t;

typedef struct _ply_boot_splash_plugin ply_boot_splash_plugin_t;


src/ply-boot-splash.c → src/libplybootsplash/ply-boot-splash.c View File


src/ply-boot-splash.h → src/libplybootsplash/ply-boot-splash.h View File


+ 1
- 1
src/libplybootsplash/ply-entry.c View File

@@ -126,7 +126,7 @@ get_max_number_of_visible_bullets (ply_entry_t *entry)
bullet_width = ply_image_get_width (entry->bullet_image);
text_field_width = ply_image_get_width (entry->text_field_image);

return (int) (text_field_width / bullet_width);
return (int) (text_field_width / bullet_width) - ((text_field_width % bullet_width) < (bullet_width / 2)? 1 : 0);
}

bool


+ 0
- 213
src/libplybootsplash/ply-text-pulser.c View File

@@ -1,213 +0,0 @@
/* ply-text-pulser.c - simple text based pulsing animation
*
* Copyright (C) 2008 Red Hat, Inc.
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by: Ray Strode <rstrode@redhat.com>
*/
#include "config.h"

#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <math.h>
#include <signal.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
#include <values.h>
#include <unistd.h>
#include <wchar.h>

#include "ply-text-pulser.h"
#include "ply-event-loop.h"
#include "ply-array.h"
#include "ply-logger.h"
#include "ply-utils.h"
#include "ply-window.h"

#include <linux/kd.h>

#ifndef FRAMES_PER_SECOND
#define FRAMES_PER_SECOND 10
#endif

#define NUMBER_OF_INDICATOR_COLUMNS 6

struct _ply_text_pulser
{
ply_event_loop_t *loop;

ply_window_t *window;

int column, row;
int number_of_rows;
int number_of_columns;
int spinner_position;
double start_time, now;
};

ply_text_pulser_t *
ply_text_pulser_new (void)
{
ply_text_pulser_t *pulser;

pulser = calloc (1, sizeof (ply_text_pulser_t));

pulser->number_of_rows = 0;
pulser->number_of_columns = 0;
pulser->row = 0;
pulser->column = 0;
pulser->spinner_position = 0;
pulser->number_of_columns = 40;
pulser->number_of_rows = 1;

return pulser;
}

void
ply_text_pulser_free (ply_text_pulser_t *pulser)
{
if (pulser == NULL)
return;

free (pulser);
}

static void
draw_trough (ply_text_pulser_t *pulser,
int column,
int row)
{
char *bytes;

ply_window_set_text_cursor_position (pulser->window,
column,
row);
ply_window_set_background_color (pulser->window, PLY_WINDOW_COLOR_BROWN);
bytes = malloc (pulser->number_of_columns);
memset (bytes, ' ', pulser->number_of_columns);
write (STDOUT_FILENO, bytes, pulser->number_of_columns);
free (bytes);
}

static void
animate_at_time (ply_text_pulser_t *pulser,
double time)
{
ply_window_set_mode (pulser->window, PLY_WINDOW_MODE_TEXT);

draw_trough (pulser, pulser->column, pulser->row);

ply_window_set_text_cursor_position (pulser->window,
pulser->column + pulser->spinner_position,
pulser->row);
pulser->spinner_position = (pulser->number_of_columns - strlen (" ") + 1) * (.5 * sin (time) + .5);
ply_window_set_text_cursor_position (pulser->window,
pulser->column + pulser->spinner_position,
pulser->row);

ply_window_set_background_color (pulser->window, PLY_WINDOW_COLOR_GREEN);
write (STDOUT_FILENO, " ", strlen (" "));
ply_window_set_background_color (pulser->window, PLY_WINDOW_COLOR_DEFAULT);
}

static void
on_timeout (ply_text_pulser_t *pulser)
{
double sleep_time;
pulser->now = ply_get_timestamp ();

#ifdef REAL_TIME_ANIMATION
animate_at_time (pulser,
pulser->now - pulser->start_time);
#else
static double time = 0.0;
time += 1.0 / FRAMES_PER_SECOND;
animate_at_time (pulser, time);
#endif

sleep_time = 1.0 / FRAMES_PER_SECOND;
sleep_time = MAX (sleep_time - (ply_get_timestamp () - pulser->now),
0.005);

ply_event_loop_watch_for_timeout (pulser->loop,
sleep_time,
(ply_event_loop_timeout_handler_t)
on_timeout, pulser);
}

bool
ply_text_pulser_start (ply_text_pulser_t *pulser,
ply_event_loop_t *loop,
ply_window_t *window,
int column,
int row)
{
assert (pulser != NULL);
assert (pulser->loop == NULL);

pulser->loop = loop;
pulser->window = window;

pulser->row = row;
pulser->column = column;

pulser->start_time = ply_get_timestamp ();

ply_event_loop_watch_for_timeout (pulser->loop,
1.0 / FRAMES_PER_SECOND,
(ply_event_loop_timeout_handler_t)
on_timeout, pulser);

return true;
}

void
ply_text_pulser_stop (ply_text_pulser_t *pulser)
{
pulser->window = NULL;

if (pulser->loop != NULL)
{
ply_event_loop_stop_watching_for_timeout (pulser->loop,
(ply_event_loop_timeout_handler_t)
on_timeout, pulser);
pulser->loop = NULL;
}
}

int
ply_text_pulser_get_number_of_columns (ply_text_pulser_t *pulser)
{
return pulser->number_of_columns;
}

int
ply_text_pulser_get_number_of_rows (ply_text_pulser_t *pulser)
{
return pulser->number_of_rows;
}

/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */

+ 0
- 51
src/libplybootsplash/ply-text-pulser.h View File

@@ -1,51 +0,0 @@
/* ply-text-pulser.h - simple text based pulsing animation
*
* Copyright (C) 2008 Red Hat, Inc.
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written By: Ray Strode <rstrode@redhat.com>
*/
#ifndef PLY_TEXT_PULSER_H
#define PLY_TEXT_PULSER_H

#include <stdbool.h>
#include <stdint.h>
#include <unistd.h>

#include "ply-event-loop.h"
#include "ply-window.h"

typedef struct _ply_text_pulser ply_text_pulser_t;

#ifndef PLY_HIDE_FUNCTION_DECLARATIONS
ply_text_pulser_t *ply_text_pulser_new (void);
void ply_text_pulser_free (ply_text_pulser_t *pulser);

bool ply_text_pulser_load (ply_text_pulser_t *pulser);
bool ply_text_pulser_start (ply_text_pulser_t *pulser,
ply_event_loop_t *loop,
ply_window_t *window,
int column,
int row);
void ply_text_pulser_stop (ply_text_pulser_t *pulser);

int ply_text_pulser_get_number_of_rows (ply_text_pulser_t *pulser);
int ply_text_pulser_get_number_of_columns (ply_text_pulser_t *pulser);
#endif

#endif /* PLY_TEXT_PULSER_H */
/* vim: set ts=4 sw=4 expandtab autoindent cindent cino={.5s,(0: */

+ 26
- 41
src/main.c View File

@@ -102,7 +102,7 @@ typedef struct
uint32_t should_be_attached : 1;
uint32_t should_retain_splash : 1;

char *console;
char *kernel_console_tty;
char *override_splash_path;

int number_of_errors;
@@ -123,27 +123,7 @@ static void on_error_message (ply_buffer_t *debug_buffer,
const void *bytes,
size_t number_of_bytes);
static ply_buffer_t *debug_buffer;
static char *debug_buffer_path;

static void
switch_to_vt (int vt_number)
{
int fd;

fd = open ("/dev/tty0", O_RDWR | O_NOCTTY);

if (fd < 0)
return;

if (ioctl (fd, VT_ACTIVATE, vt_number) < 0)
{
close (fd);
return;
}

ioctl (fd, VT_WAITACTIVE, vt_number);
close (fd);
}
static char *debug_buffer_path = NULL;

static void
on_session_output (state_t *state,
@@ -534,13 +514,16 @@ plymouth_should_show_default_splash (state_t *state)
ply_trace ("checking if plymouth should show default splash");

const char const *strings[] = {
" single ", " single", "^single ",
" 1 ", " 1", "^1 ",
" single ", " single\n", "^single ",
" 1 ", " 1\n", "^1 ",
" s ", " s\n", "^s ",
" S ", " S\n", "^S ",
" -s ", " -s\n", "^-s ",
NULL
};
int i;

if (state->console != NULL)
if (state->kernel_console_tty != NULL)
return false;

if (!has_open_window (state))
@@ -562,7 +545,7 @@ plymouth_should_show_default_splash (state_t *state)
}
}

return strstr (state->kernel_command_line, "rhgb") != NULL || strstr (state->kernel_command_line, "splash") != NULL;
return strstr (state->kernel_command_line, "rhgb") != NULL || (strstr (state->kernel_command_line, "splash") != NULL && strstr(state->kernel_command_line, "splash=verbose") == NULL);
}

static void
@@ -900,7 +883,7 @@ on_keyboard_input (state_t *state,
}
}

void
static void
on_backspace (state_t *state)
{
ssize_t bytes_to_remove;
@@ -926,7 +909,7 @@ on_backspace (state_t *state)
update_display (state);
}

void
static void
on_enter (state_t *state,
const char *line)
{
@@ -1130,7 +1113,7 @@ check_verbosity (state_t *state)
if (!ply_is_tracing ())
ply_toggle_tracing ();

if (path != NULL)
if (path != NULL && debug_buffer_path == NULL)
{
char *end;

@@ -1144,7 +1127,7 @@ check_verbosity (state_t *state)
debug_buffer_path = path;
}

if (debug_buffer != NULL)
if (debug_buffer == NULL)
debug_buffer = ply_buffer_new ();

#ifdef LOG_TO_DEBUG_FILE
@@ -1202,26 +1185,26 @@ check_for_consoles (state_t *state,
char *end;
ply_trace ("serial console found!");

free (state->console);
state->console = strdup (console_key + strlen (" console="));
free (state->kernel_console_tty);
state->kernel_console_tty = strdup (console_key + strlen (" console="));

remaining_command_line = console_key + strlen (" console=");

end = strpbrk (state->console, " \n\t\v,");
end = strpbrk (state->kernel_console_tty, " \n\t\v,");

if (end != NULL)
{
*end = '\0';
remaining_command_line += end - state->console;
remaining_command_line += end - state->kernel_console_tty;
}

if (strcmp (state->console, "tty0") == 0 || strcmp (state->console, "/dev/tty0") == 0)
if (strcmp (state->kernel_console_tty, "tty0") == 0 || strcmp (state->kernel_console_tty, "/dev/tty0") == 0)
{
free (state->console);
state->console = strdup (default_tty);
free (state->kernel_console_tty);
state->kernel_console_tty = strdup (default_tty);
}

ply_list_append_data (state->windows, create_window (state, state->console));
ply_list_append_data (state->windows, create_window (state, state->kernel_console_tty));
}

if (ply_list_get_length (state->windows) == 0)
@@ -1277,15 +1260,15 @@ initialize_environment (state_t *state)
if (state->mode == PLY_MODE_SHUTDOWN)
{
default_tty = "tty63";
switch_to_vt (63);
ply_switch_to_vt (63);
}
else
default_tty = "tty1";

check_for_consoles (state, default_tty);

if (state->console != NULL)
redirect_standard_io_to_device (state->console);
if (state->kernel_console_tty != NULL)
redirect_standard_io_to_device (state->kernel_console_tty);
else
redirect_standard_io_to_device (default_tty);

@@ -1383,6 +1366,7 @@ main (int argc,
"attach-to-session", "Redirect console messages from screen to log", PLY_COMMAND_OPTION_TYPE_FLAG,
"no-daemon", "Do not daemonize", PLY_COMMAND_OPTION_TYPE_FLAG,
"debug", "Output debugging information", PLY_COMMAND_OPTION_TYPE_FLAG,
"debug-file", "File to output debugging information to", PLY_COMMAND_OPTION_TYPE_STRING,
"mode", "Mode is one of: boot, shutdown", PLY_COMMAND_OPTION_TYPE_STRING,
NULL);

@@ -1404,6 +1388,7 @@ main (int argc,
"mode", &mode_string,
"no-daemon", &no_daemon,
"debug", &debug,
"debug-file", &debug_buffer_path,
NULL);

if (should_help)


+ 2
- 0
src/plugins/splash/script/Makefile.am View File

@@ -31,6 +31,8 @@ script_la_SOURCES = $(srcdir)/plugin.c \
$(srcdir)/script-execute.h \
$(srcdir)/script-object.c \
$(srcdir)/script-object.h \
$(srcdir)/script-debug.c \
$(srcdir)/script-debug.h \
$(srcdir)/script-lib-image.c \
$(srcdir)/script-lib-image.h \
$(srcdir)/script-lib-image.script \


+ 13
- 1
src/plugins/splash/script/Makefile.in View File

@@ -75,7 +75,8 @@ script_la_DEPENDENCIES = $(am__DEPENDENCIES_1) \
am_script_la_OBJECTS = script_la-plugin.lo script_la-script.lo \
script_la-script-scan.lo script_la-script-parse.lo \
script_la-script-execute.lo script_la-script-object.lo \
script_la-script-lib-image.lo script_la-script-lib-sprite.lo \
script_la-script-debug.lo script_la-script-lib-image.lo \
script_la-script-lib-sprite.lo \
script_la-script-lib-plymouth.lo script_la-script-lib-math.lo
script_la_OBJECTS = $(am_script_la_OBJECTS)
AM_V_lt = $(am__v_lt_$(V))
@@ -283,6 +284,8 @@ script_la_SOURCES = $(srcdir)/plugin.c \
$(srcdir)/script-execute.h \
$(srcdir)/script-object.c \
$(srcdir)/script-object.h \
$(srcdir)/script-debug.c \
$(srcdir)/script-debug.h \
$(srcdir)/script-lib-image.c \
$(srcdir)/script-lib-image.h \
$(srcdir)/script-lib-image.script \
@@ -375,6 +378,7 @@ distclean-compile:
-rm -f *.tab.c

@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_la-plugin.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_la-script-debug.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_la-script-execute.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_la-script-lib-image.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/script_la-script-lib-math.Plo@am__quote@
@@ -457,6 +461,14 @@ script_la-script-object.lo: $(srcdir)/script-object.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(script_la_CFLAGS) $(CFLAGS) -c -o script_la-script-object.lo `test -f '$(srcdir)/script-object.c' || echo '$(srcdir)/'`$(srcdir)/script-object.c

script_la-script-debug.lo: $(srcdir)/script-debug.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(script_la_CFLAGS) $(CFLAGS) -MT script_la-script-debug.lo -MD -MP -MF $(DEPDIR)/script_la-script-debug.Tpo -c -o script_la-script-debug.lo `test -f '$(srcdir)/script-debug.c' || echo '$(srcdir)/'`$(srcdir)/script-debug.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/script_la-script-debug.Tpo $(DEPDIR)/script_la-script-debug.Plo
@am__fastdepCC_FALSE@ $(AM_V_CC) @AM_BACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$(srcdir)/script-debug.c' object='script_la-script-debug.lo' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(script_la_CFLAGS) $(CFLAGS) -c -o script_la-script-debug.lo `test -f '$(srcdir)/script-debug.c' || echo '$(srcdir)/'`$(srcdir)/script-debug.c

script_la-script-lib-image.lo: $(srcdir)/script-lib-image.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(script_la_CFLAGS) $(CFLAGS) -MT script_la-script-lib-image.lo -MD -MP -MF $(DEPDIR)/script_la-script-lib-image.Tpo -c -o script_la-script-lib-image.lo `test -f '$(srcdir)/script-lib-image.c' || echo '$(srcdir)/'`$(srcdir)/script-lib-image.c
@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/script_la-script-lib-image.Tpo $(DEPDIR)/script_la-script-lib-image.Plo


+ 2
- 1
src/plugins/splash/script/plugin.c View File

@@ -177,7 +177,8 @@ start_animation (ply_boot_splash_plugin_t *plugin)
plugin->image_dir);
plugin->script_sprite_lib = script_lib_sprite_setup (plugin->script_state,
plugin->window);
plugin->script_plymouth_lib = script_lib_plymouth_setup (plugin->script_state);
plugin->script_plymouth_lib = script_lib_plymouth_setup (plugin->script_state,
plugin->mode);
plugin->script_math_lib = script_lib_math_setup (plugin->script_state);

ply_trace ("executing script file");


+ 71
- 0
src/plugins/splash/script/script-debug.c View File

@@ -0,0 +1,71 @@
/* script-debug.h - Debug handling matching memory loaded data to source locations
*
* Copyright (C) 2009 Charlie Brej <cbrej@cs.man.ac.uk>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by: Charlie Brej <cbrej@cs.man.ac.uk>
*/
#include "ply-hashtable.h"
#include <stdlib.h>
#include <string.h>

#include "script-debug.h"

static ply_hashtable_t *script_debug_location_hash = NULL;
static ply_hashtable_t *script_debug_name_hash = NULL;

static void script_debug_setup (void)
{
if (!script_debug_location_hash)
{
script_debug_location_hash = ply_hashtable_new(NULL, NULL);
script_debug_name_hash = ply_hashtable_new(ply_hashtable_string_hash,
ply_hashtable_string_compare);
}
}

void script_debug_add_element (void *element,
script_debug_location_t *location)
{
script_debug_setup();
script_debug_location_t *new_location = malloc (sizeof(script_debug_location_t));
new_location->line_index = location->line_index;
new_location->column_index = location->column_index;
new_location->name = ply_hashtable_lookup (script_debug_name_hash, location->name);
if (!new_location->name)
{
new_location->name = strdup(location->name);
ply_hashtable_insert (script_debug_name_hash, new_location->name, new_location->name);
}
ply_hashtable_insert (script_debug_location_hash, element, new_location);
}

void script_debug_remove_element (void *element)
{
script_debug_setup();
script_debug_location_t *old_location = ply_hashtable_remove (script_debug_location_hash,
element);
free(old_location);
}

script_debug_location_t *script_debug_lookup_element (void *element)
{
script_debug_setup();
script_debug_location_t *location = ply_hashtable_lookup (script_debug_location_hash,
element);
return location;
}

+ 39
- 0
src/plugins/splash/script/script-debug.h View File

@@ -0,0 +1,39 @@
/* script-debug.h - Debug handling matching memory loaded data to source locations
*
* Copyright (C) 2009 Charlie Brej <cbrej@cs.man.ac.uk>
*
* 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
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* Written by: Charlie Brej <cbrej@cs.man.ac.uk>
*/
#ifndef SCRIPT_DEBUG_H
#define SCRIPT_DEBUG_H


typedef struct
{
int line_index;
int column_index;
char* name;
} script_debug_location_t;


void script_debug_add_element (void *element,
script_debug_location_t *location);
void script_debug_remove_element (void *element);
script_debug_location_t *script_debug_lookup_element (void *element);

#endif /* SCRIPT_DEBUG_H */

+ 181
- 94
src/plugins/splash/script/script-execute.c View File

@@ -22,6 +22,7 @@
#define _GNU_SOURCE
#include "ply-hashtable.h"
#include "ply-list.h"
#include "ply-logger.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -33,6 +34,7 @@
#include <math.h>

#include "script.h"
#include "script-debug.h"
#include "script-execute.h"
#include "script-object.h"

@@ -40,8 +42,25 @@ static script_obj_t *script_evaluate (script_state_t *state,
script_exp_t *exp);
static script_return_t script_execute_function_with_parlist (script_state_t *state,
script_function_t *function,
script_obj_t *this,
ply_list_t *parameter_data);


static void script_execute_error (void *element,
const char *message)
{
script_debug_location_t *location = script_debug_lookup_element (element);
if (location)
ply_error ("Execution error \"%s\" L:%d C:%d : %s\n",
location->name,
location->line_index,
location->column_index,
message);
else
ply_error ("Execution error: %s\n", message);
}


static script_obj_t *script_evaluate_apply_function (script_state_t *state,
script_exp_t *exp,
script_obj_t *(*function)(script_obj_t *, script_obj_t *))
@@ -96,31 +115,13 @@ static script_obj_t *script_evaluate_var (script_state_t *state,
script_exp_t *exp)
{
char *name = exp->data.string;
script_obj_t *obj;

script_obj_deref (&state->global);
script_obj_deref (&state->local);
assert (state->global->type == SCRIPT_OBJ_TYPE_HASH); /*FIXME use script-object functions */
assert (state->local->type == SCRIPT_OBJ_TYPE_HASH);

script_variable_t *variable = ply_hashtable_lookup (state->local->data.hash,
name);
if (!variable)
variable = ply_hashtable_lookup (state->global->data.hash, name);
if (variable)
{
obj = variable->object;
script_obj_ref (obj);
return obj;
}
obj = script_obj_new_null ();

variable = malloc (sizeof (script_variable_t));
variable->name = strdup (name);
variable->object = obj;

ply_hashtable_insert (state->local->data.hash, variable->name, variable);
script_obj_ref (obj);
script_obj_t *obj = script_obj_hash_peek_element (state->local, name);
if (obj) return obj;
obj = script_obj_hash_peek_element (state->this, name);
if (obj) return obj;
obj = script_obj_hash_peek_element (state->global, name);
if (obj) return obj;
obj = script_obj_hash_get_element (state->local, name);
return obj;
}

@@ -147,8 +148,8 @@ static script_obj_t *script_evaluate_cmp (script_state_t *state,
script_obj_unref (script_obj_b);
if (cmp_result & condition)
return script_obj_new_int (1);
return script_obj_new_int (0);
return script_obj_new_number (1);
return script_obj_new_number (0);
}

static script_obj_t *script_evaluate_logic (script_state_t *state,
@@ -173,7 +174,7 @@ static script_obj_t *script_evaluate_unary (script_state_t *state,

if (exp->type == SCRIPT_EXP_TYPE_NOT)
{
new_obj = script_obj_new_int (!script_obj_as_bool (obj));
new_obj = script_obj_new_number (!script_obj_as_bool (obj));
script_obj_unref (obj);
return new_obj;
}
@@ -181,57 +182,127 @@ static script_obj_t *script_evaluate_unary (script_state_t *state,
return obj; /* Does nothing, maybe just remove at parse stage */
if (exp->type == SCRIPT_EXP_TYPE_NEG)
{
if (script_obj_is_int(obj))
new_obj = script_obj_new_int (-script_obj_as_int (obj));
else if (script_obj_is_float(obj))
new_obj = script_obj_new_float (-script_obj_as_float (obj));
else new_obj = script_obj_new_null ();
if (script_obj_is_number(obj))
new_obj = script_obj_new_number (-script_obj_as_number (obj));
else
{
script_execute_error(exp, "Cannot negate non number objects");
new_obj = script_obj_new_null ();
}
script_obj_unref (obj);
return new_obj;
}
int change_pre = 0;
int change_post;
int change = -1;

if ((exp->type == SCRIPT_EXP_TYPE_PRE_INC) ||
(exp->type == SCRIPT_EXP_TYPE_POST_INC))
change_post = 1;
else
change_post = -1;
if (exp->type == SCRIPT_EXP_TYPE_PRE_INC)
change = 1;
if ((exp->type == SCRIPT_EXP_TYPE_PRE_INC) ||
(exp->type == SCRIPT_EXP_TYPE_PRE_DEC))
change_pre = 1;
else if (exp->type == SCRIPT_EXP_TYPE_PRE_DEC)
change_pre = -1;
if (script_obj_is_int(obj))
{
new_obj = script_obj_new_int (script_obj_as_int(obj) + change_pre);
obj->data.integer += change_post; /* FIXME direct access */
}
else if (script_obj_is_float(obj))

if (script_obj_is_number(obj))
{
new_obj = script_obj_new_float (script_obj_as_float(obj) + change_pre);
obj->data.floatpoint += change_post;
if (change_pre)
{
new_obj = script_obj_new_number (script_obj_as_number(obj) + change);
script_obj_assign (obj, new_obj);
}
else
{
new_obj = script_obj_deref_direct (obj);
script_obj_ref (new_obj);
script_obj_t *new_obj2 = script_obj_new_number (script_obj_as_number(obj) + change);
script_obj_assign (obj, new_obj2);
script_obj_unref (new_obj2);
}
}
else
{
script_execute_error(exp, "Cannot increment/decrement non number objects");
new_obj = script_obj_new_null (); /* If performeing something like a=hash++; a and hash become NULL */
script_obj_reset (obj);
}
script_obj_unref (obj);
return new_obj;
}
typedef struct
{
script_state_t *state;
script_obj_t *this;
ply_list_t *parameter_data;
} script_obj_execute_data_t;

static void *script_obj_execute (script_obj_t *obj,
void *user_data)
{
script_obj_execute_data_t *execute_data = user_data;
if (obj->type == SCRIPT_OBJ_TYPE_FUNCTION){
script_function_t *function = obj->data.function;
script_return_t reply = script_execute_function_with_parlist (execute_data->state,
function,
execute_data->this,
execute_data->parameter_data);
if (reply.type != SCRIPT_RETURN_TYPE_FAIL)
return reply.object ? reply.object : script_obj_new_null ();
}
return NULL;
}

static script_return_t script_execute_object_with_parlist (script_state_t *state,
script_obj_t *obj,
script_obj_t *this,
ply_list_t *parameter_data)
{
script_obj_execute_data_t execute_data;
execute_data.state = state;
execute_data.this = this;
execute_data.parameter_data = parameter_data;

obj = script_obj_as_custom (obj, script_obj_execute, &execute_data);

if (obj) return script_return_obj(obj);
return script_return_fail();
}

static script_obj_t *script_evaluate_func (script_state_t *state,
script_exp_t *exp)
{
script_obj_t *func_obj = script_evaluate (state, exp->data.function_exe.name);
script_obj_t *obj = NULL;
script_function_t *function = script_obj_as_function (func_obj);

if (!function)
script_obj_t *this_obj = NULL; ;
script_obj_t *func_obj;
script_exp_t *name_exp = exp->data.function_exe.name;
if (name_exp->type == SCRIPT_EXP_TYPE_HASH)
{
script_obj_unref (func_obj);
return script_obj_new_null ();
script_obj_t *this_key = script_evaluate (state, name_exp->data.dual.sub_b);
this_obj = script_evaluate (state, name_exp->data.dual.sub_a);
char *this_key_name = script_obj_as_string (this_key);
script_obj_unref (this_key);
func_obj = script_obj_hash_get_element (this_obj, this_key_name);
free(this_key_name);
}
else if (name_exp->type == SCRIPT_EXP_TYPE_TERM_VAR)
{
char *name = name_exp->data.string;
func_obj = script_obj_hash_peek_element (state->local, name);
if (!func_obj)
{
func_obj = script_obj_hash_peek_element (state->this, name);
if (func_obj)
this_obj = state->this;
else
{
func_obj = script_obj_hash_peek_element (state->global, name);
if (!func_obj) func_obj = script_obj_new_null ();
}
}
}
else
{
func_obj = script_evaluate (state, exp->data.function_exe.name);
}
ply_list_t *parameter_expressions = exp->data.function_exe.parameters;
ply_list_t *parameter_data = ply_list_new ();

@@ -244,13 +315,9 @@ static script_obj_t *script_evaluate_func (script_state_t *state,
node_expression = ply_list_get_next_node (parameter_expressions,
node_expression);
}
script_return_t reply = script_execute_function_with_parlist (state,
function,
parameter_data);
if (reply.type == SCRIPT_RETURN_TYPE_RETURN)
obj = reply.object;
else
obj = script_obj_new_null ();

script_return_t reply = script_execute_object_with_parlist (state, func_obj, this_obj, parameter_data);
ply_list_node_t *node_data = ply_list_get_first_node (parameter_data);
while (node_data)
{
@@ -261,8 +328,9 @@ static script_obj_t *script_evaluate_func (script_state_t *state,
ply_list_free (parameter_data);

script_obj_unref (func_obj);
if (this_obj) script_obj_unref (this_obj);

return obj;
return reply.object ? reply.object : script_obj_new_null ();
}

static script_obj_t *script_evaluate (script_state_t *state,
@@ -327,6 +395,11 @@ static script_obj_t *script_evaluate (script_state_t *state,
return script_evaluate_logic (state, exp);
}

case SCRIPT_EXP_TYPE_EXTEND:
{
return script_evaluate_apply_function (state, exp, script_obj_new_extend);
}

case SCRIPT_EXP_TYPE_NOT:
case SCRIPT_EXP_TYPE_POS:
case SCRIPT_EXP_TYPE_NEG:
@@ -338,14 +411,9 @@ static script_obj_t *script_evaluate (script_state_t *state,
return script_evaluate_unary (state, exp);
}

case SCRIPT_EXP_TYPE_TERM_INT:
{
return script_obj_new_int (exp->data.integer);
}

case SCRIPT_EXP_TYPE_TERM_FLOAT:
case SCRIPT_EXP_TYPE_TERM_NUMBER:
{
return script_obj_new_float (exp->data.floatpoint);
return script_obj_new_number (exp->data.number);
}

case SCRIPT_EXP_TYPE_TERM_STRING:
@@ -370,6 +438,12 @@ static script_obj_t *script_evaluate (script_state_t *state,
return state->global;
}

case SCRIPT_EXP_TYPE_TERM_THIS:
{
script_obj_ref (state->this);
return state->this;
}

case SCRIPT_EXP_TYPE_TERM_VAR:
{
return script_evaluate_var (state, exp);
@@ -415,6 +489,13 @@ static script_obj_t *script_evaluate (script_state_t *state,
script_obj_mod);
}

case SCRIPT_EXP_TYPE_ASSIGN_EXTEND:
{
return script_evaluate_apply_function_and_assign (state,
exp,
script_obj_new_extend);
}

case SCRIPT_EXP_TYPE_HASH:
{
return script_evaluate_hash (state, exp);
@@ -443,13 +524,14 @@ static script_return_t script_execute_list (script_state_t *state,
node = ply_list_get_next_node (op_list, node))
{
script_op_t *op = ply_list_node_get_data (node);
script_obj_unref (reply.object);
reply = script_execute (state, op);
switch (reply.type)
{
case SCRIPT_RETURN_TYPE_NORMAL:
break;

case SCRIPT_RETURN_TYPE_RETURN:
case SCRIPT_RETURN_TYPE_FAIL:
case SCRIPT_RETURN_TYPE_BREAK:
case SCRIPT_RETURN_TYPE_CONTINUE:
return reply;
@@ -461,9 +543,10 @@ static script_return_t script_execute_list (script_state_t *state,
/* parameter_data list should be freed by caller */
static script_return_t script_execute_function_with_parlist (script_state_t *state,
script_function_t *function,
script_obj_t *this,
ply_list_t *parameter_data)
{
script_state_t *sub_state = script_state_init_sub (state);
script_state_t *sub_state = script_state_init_sub (state, this);
ply_list_t *parameter_names = function->parameters;
ply_list_node_t *node_name = ply_list_get_first_node (parameter_names);
ply_list_node_t *node_data = ply_list_get_first_node (parameter_data);
@@ -488,12 +571,15 @@ static script_return_t script_execute_function_with_parlist (script_state_t *
node_data = ply_list_get_next_node (parameter_data, node_data);
}

script_obj_t *count_obj = script_obj_new_int (index);
script_obj_t *count_obj = script_obj_new_number (index);
script_obj_hash_add_element (arg_obj, count_obj, "count");
script_obj_hash_add_element (sub_state->local, arg_obj, "_args");
script_obj_unref (count_obj);
script_obj_unref (arg_obj);

if (this)
script_obj_hash_add_element (sub_state->local, this, "this");

script_return_t reply;
switch (function->type)
{
@@ -510,15 +596,17 @@ static script_return_t script_execute_function_with_parlist (script_state_t *
break;
}
}

script_state_destroy (sub_state);
if (reply.type != SCRIPT_RETURN_TYPE_FAIL)
reply.type = SCRIPT_RETURN_TYPE_RETURN;
return reply;
}

script_return_t script_execute_function (script_state_t *state,
script_function_t *function,
script_obj_t *first_arg,
...)
script_return_t script_execute_object (script_state_t *state,
script_obj_t *function,
script_obj_t *this,
script_obj_t *first_arg,
...)
{
script_return_t reply;
va_list args;
@@ -534,7 +622,7 @@ script_return_t script_execute_function (script_state_t *state,
}
va_end (args);

reply = script_execute_function_with_parlist (state, function, parameter_data);
reply = script_execute_object_with_parlist (state, function, this, parameter_data);
ply_list_free (parameter_data);

return reply;
@@ -544,21 +632,18 @@ script_return_t script_execute (script_state_t *state,
script_op_t *op)
{
script_return_t reply = script_return_normal ();

if (!op) return reply;
switch (op->type)
{
case SCRIPT_OP_TYPE_EXPRESSION:
{
script_obj_t *obj = script_evaluate (state, op->data.exp);
script_obj_unref (obj); /* there is always a reply from all expressions (even assigns) which we chuck away */
reply.object = script_evaluate (state, op->data.exp);
break;
}

case SCRIPT_OP_TYPE_OP_BLOCK:
{
reply = script_execute_list (state, op->data.list);
/* FIXME blocks should normall reply a NULL , but if they replied something else then that was a return */
break;
}

@@ -582,6 +667,7 @@ script_return_t script_execute (script_state_t *state,
obj = script_evaluate (state, op->data.cond_op.cond);
if (script_obj_as_bool (obj))
{
script_obj_unref (reply.object);
reply = script_execute (state, op->data.cond_op.op1);
script_obj_unref (obj);
switch (reply.type)
@@ -590,6 +676,7 @@ script_return_t script_execute (script_state_t *state,
break;

case SCRIPT_RETURN_TYPE_RETURN:
case SCRIPT_RETURN_TYPE_FAIL:
return reply;

case SCRIPT_RETURN_TYPE_BREAK:
@@ -598,7 +685,11 @@ script_return_t script_execute (script_state_t *state,
case SCRIPT_RETURN_TYPE_CONTINUE:
break;
}
script_execute (state, op->data.cond_op.op2);
if (op->data.cond_op.op2)
{
script_obj_unref (reply.object);
reply = script_execute (state, op->data.cond_op.op2);
}
}
else
{
@@ -609,16 +700,6 @@ script_return_t script_execute (script_state_t *state,
break;
}

case SCRIPT_OP_TYPE_FUNCTION_DEF:
{
script_obj_t *obj = script_evaluate (state, op->data.function_def.name);
script_obj_t *function_obj = script_obj_new_function(op->data.function_def.function);
script_obj_assign (obj, function_obj);
script_obj_unref (function_obj);
script_obj_unref (obj);
break;
}

case SCRIPT_OP_TYPE_RETURN:
{
script_obj_t *obj;
@@ -628,6 +709,12 @@ script_return_t script_execute (script_state_t *state,
break;
}

case SCRIPT_OP_TYPE_FAIL:
{
reply = script_return_fail ();
break;
}

case SCRIPT_OP_TYPE_BREAK:
{
reply = script_return_break ();


+ 5
- 4
src/plugins/splash/script/script-execute.h View File

@@ -26,9 +26,10 @@

script_return_t script_execute (script_state_t *state,
script_op_t *op);
script_return_t script_execute_function (script_state_t *state,
script_function_t *function,
script_obj_t *first_arg,
...);
script_return_t script_execute_object (script_state_t *state,
script_obj_t *function,
script_obj_t *this,
script_obj_t *first_arg,
...);

#endif /* SCRIPT_EXECUTE_H */

+ 23
- 33
src/plugins/splash/script/script-lib-image.c View File

@@ -85,11 +85,9 @@ static script_return_t image_get_width (script_state_t *state,
void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
"image",
data->class);
ply_image_t *image = script_obj_as_native_of_class (state->this, data->class);
if (image)
return script_return_obj (script_obj_new_int (ply_image_get_width (image)));
return script_return_obj (script_obj_new_number (ply_image_get_width (image)));
return script_return_obj_null ();
}

@@ -97,11 +95,9 @@ static script_return_t image_get_height (script_state_t *state,
void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
"image",
data->class);
ply_image_t *image = script_obj_as_native_of_class (state->this, data->class);
if (image)
return script_return_obj (script_obj_new_int (ply_image_get_height (image)));
return script_return_obj (script_obj_new_number (ply_image_get_height (image)));
return script_return_obj_null ();
}

@@ -109,10 +105,8 @@ static script_return_t image_rotate (script_state_t *state,
void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
"image",
data->class);
float angle = script_obj_hash_get_float (state->local, "angle");
ply_image_t *image = script_obj_as_native_of_class (state->this, data->class);
float angle = script_obj_hash_get_number (state->local, "angle");

if (image)
{
@@ -129,11 +123,9 @@ static script_return_t image_scale (script_state_t *state,
void *user_data)
{
script_lib_image_data_t *data = user_data;
ply_image_t *image = script_obj_hash_get_native_of_class (state->local,
"image",
data->class);
int width = script_obj_hash_get_int (state->local, "width");
int height = script_obj_hash_get_int (state->local, "height");
ply_image_t *image = script_obj_as_native_of_class (state->this, data->class);
int width = script_obj_hash_get_number (state->local, "width");
int height = script_obj_hash_get_number (state->local, "height");

if (image)
{
@@ -151,44 +143,42 @@ script_lib_image_data_t *script_lib_image_setup (script_state_t *state,
data->class = script_obj_native_class_new (image_free, "image", data);
data->image_dir = strdup (image_dir);

script_add_native_function (state->global,
"ImageNew",
script_obj_t *image_hash = script_obj_hash_get_element (state->global, "Image");
script_add_native_function (image_hash,
"_New",
image_new,
data,
"filename",
NULL);
script_add_native_function (state->global,
"ImageRotate",
script_add_native_function (image_hash,
"_Rotate",
image_rotate,
data,
"image",
"angle",
NULL);
script_add_native_function (state->global,
"ImageScale",
script_add_native_function (image_hash,
"_Scale",
image_scale,
data,
"image",
"width",
"height",
NULL);
script_add_native_function (state->global,
"ImageGetWidth",
script_add_native_function (image_hash,
"GetWidth",
image_get_width,
data,
"image",
NULL);
script_add_native_function (state->global,
"ImageGetHeight",
script_add_native_function (image_hash,
"GetHeight",
image_get_height,
data,
"image",
NULL);

data->script_main_op = script_parse_string (script_lib_image_string);
script_obj_unref (image_hash);
data->script_main_op = script_parse_string (script_lib_image_string, "script-lib-image.script");
script_return_t ret = script_execute (state, data->script_main_op);
script_obj_unref (ret.object);

return data;
}



+ 3
- 3
src/plugins/splash/script/script-lib-image.h View File

@@ -19,8 +19,8 @@
*
* Written by: Charlie Brej <cbrej@cs.man.ac.uk>
*/
#ifndef SCRIPT_LIB_IMAGE
#define SCRIPT_LIB_IMAGE
#ifndef SCRIPT_LIB_IMAGE_H
#define SCRIPT_LIB_IMAGE_H

#include "script.h"

@@ -35,4 +35,4 @@ script_lib_image_data_t *script_lib_image_setup (script_state_t *state,
char *image_dir);
void script_lib_image_destroy (script_lib_image_data_t *data);

#endif /* SCRIPT_LIB_IMAGE */
#endif /* SCRIPT_LIB_IMAGE_H */

+ 47
- 1
src/plugins/splash/script/script-lib-image.script View File

@@ -1 +1,47 @@
Image.Adopt = fun( raw_image)
{
if (raw_image) return raw_image | Image;
else return NULL;
};

Image.Rotate = fun (angle)
{
return Image.Adopt (this._Rotate(angle));
};

Image.Scale = fun (width, height)
{
return Image.Adopt (this._Scale(width, height));
};

Image |= fun (filename)
{
return Image.Adopt (Image._New(filename));
};