[monkey-bubble: 22/753] Game scorekeeping stuff. gnome-string namespace cleanups. More mailman work. and misc.
- From: Sven Herzberg <herzi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [monkey-bubble: 22/753] Game scorekeeping stuff. gnome-string namespace cleanups. More mailman work. and misc.
- Date: Wed, 14 Jul 2010 21:57:32 +0000 (UTC)
commit c47d7bbe31453fd84387f142e8f1b4665e17ef55
Author: Elliot Lee <sopwith src gnome org>
Date: Thu Dec 25 22:23:07 1997 +0000
Game scorekeeping stuff.
gnome-string namespace cleanups.
More mailman work.
and misc.
libgnome/.cvsignore | 6 -
libgnome/Makefile.am | 46 ---
libgnome/gnome-config.c | 767 ------------------------------------------
libgnome/gnome-config.h | 62 ----
libgnome/gnome-defs.h | 7 -
libgnome/gnome-dentry.c | 199 -----------
libgnome/gnome-dentry.h | 30 --
libgnome/gnome-dns.c | 517 ----------------------------
libgnome/gnome-dns.h | 80 -----
libgnome/gnome-fileconvert.c | 99 ------
libgnome/gnome-fileconvert.h | 15 -
libgnome/gnome-history.c | 105 ------
libgnome/gnome-history.h | 24 --
libgnome/gnome-hook.c | 85 -----
libgnome/gnome-hook.h | 22 --
libgnome/gnome-i18n.h | 32 --
libgnome/gnome-init.c | 36 --
libgnome/gnome-mime.c | 273 ---------------
libgnome/gnome-mime.h | 34 --
libgnome/gnome-score.c | 86 +++++
libgnome/gnome-score.h | 17 +
libgnome/gnome-string.c | 116 -------
libgnome/gnome-string.h | 13 -
libgnome/gnome-triggers.c | 362 --------------------
libgnome/gnome-triggers.h | 49 ---
libgnome/gnome-util.c | 231 -------------
libgnome/gnome-util.h | 25 --
libgnome/gnomelib-init.c | 36 --
libgnome/libgnome.h | 19 -
29 files changed, 103 insertions(+), 3290 deletions(-)
---
diff --git a/libgnome/gnome-score.c b/libgnome/gnome-score.c
new file mode 100644
index 0000000..ea20af7
--- /dev/null
+++ b/libgnome/gnome-score.c
@@ -0,0 +1,86 @@
+#include <unistd.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <stdio.h>
+#include <glib.h>
+
+#include "gnome-defs.h"
+#include "gnome-score.h"
+
+#define GNOME_SCORE_C 1
+#include "gnome-score-helper.c"
+#undef GNOME_SCORE_C
+
+gboolean /* Returns TRUE if it was a notable (top ten) score */
+gnome_score_log(gfloat score)
+{
+ int exitstatus;
+ char buf[64];
+ pid_t childpid = fork();
+
+ if(childpid == 0)
+ {
+ /* We are the child */
+ snprintf(buf, sizeof(buf), "%f", score);
+ execlp("gnome-score-helper", "gnome-score-helper",
+ buf, NULL);
+ exit(99);
+ }
+
+ waitpid(childpid, &exitstatus, 0);
+ if(WIFEXITED(exitstatus))
+ return (WEXITSTATUS(exitstatus)==0)?TRUE:FALSE;
+ else
+ {
+ g_warning("Scorekeeping failed\n");
+ return FALSE;
+ }
+}
+
+gint
+gnome_score_get_notable(gchar *gamename,
+ gchar ***names,
+ gfloat **scores,
+ time_t **scoretimes)
+{
+ gchar *realname, buf[512];
+ FILE *infile;
+ gint retval;
+
+ g_return_val_if_fail(names != NULL, 0);
+ g_return_val_if_fail(scores != NULL, 0);
+
+ if(realname == NULL)
+ realname = gnome_get_program_name(getpid());
+ else
+ realname = g_strdup(gamename);
+ if(!realname)
+ return 0;
+
+ snprintf(buf, sizeof(buf), "%s/%s.scores", SCORE_PATH, realname);
+
+ infile = fopen(buf, "r");
+ if(infile)
+ {
+ for(retval = 0, *names = NULL, *scores = NULL;
+ fgets(buf, sizeof(buf), infile); retval++) {
+ *names = g_realloc(*names, retval * sizeof(gchar *));
+ *scores = g_realloc(*scores, retval * sizeof(gfloat));
+ *scoretimes = g_realloc(*scores, retval * sizeof(time_t));
+ sscanf(buf, "%f %d %a",
+ &((*scores)[retval]),
+ &((*scoretimes)[retval]),
+ &((*names)[retval]));
+ }
+ fclose(infile);
+ }
+ else
+ {
+ *names = NULL;
+ *scores = NULL;
+ retval = 0;
+ }
+
+ g_free(realname);
+ return retval;
+}
diff --git a/libgnome/gnome-score.h b/libgnome/gnome-score.h
new file mode 100644
index 0000000..9f271f8
--- /dev/null
+++ b/libgnome/gnome-score.h
@@ -0,0 +1,17 @@
+#ifndef __GNOME_SCORE_H__
+#define __GNOME_SCORE_H__ 1
+
+#include <time.h>
+
+BEGIN_GNOME_DECLS
+gboolean /* Returns TRUE if it was a notable (top ten) score */
+gnome_score_log(gfloat score);
+
+gint /* Returns number of items in the arrays */
+gnome_score_get_notable(gchar *gamename, /* Will be auto-determined if NULL */
+ gchar ***names,
+ gfloat **scores,
+ time_t **scoretimes);
+END_GNOME_DECLS
+
+#endif /* __GNOME_SCORE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]