All pastes #465836 Raw Edit

Mine

public c v1 · immutable
#465836 ·published 2007-04-30 17:04 UTC
rendered paste body
#include <stdio.h>#include <sys/types.h>#include <signal.h>#include "../include/plugin.h"void on_keypress(struct hash *, struct hash *, int *);void on_songchange(struct hash *, struct hash *, int *);void reset_islastsong(struct hash *, struct hash *, int *);const struct hook hooks[] = {	{ "os_keypress", on_keypress, HOOK_KEYPRESS },	{ "os_songchange", on_songchange, HOOK_SONGCHANGE },	{ "os_reset", reset_islastsong, HOOK_DEADCHILD },	{ "os_reset", reset_islastsong, HOOK_RADIO },	{ NULL, NULL, -1 },};static int islastsong=0;extern pid_t playfork; /* bah. */void on_keypress(struct hash* track, struct hash* session, int* key) {    if (*key == '?') {        puts("o = Stop stream after this song");    }    else if ((*key == 'o') && (playfork)) {        islastsong = !islastsong;        if (islastsong)            puts("Will stop stream after this song.");        else            puts("Will keep playing after this song.");    }}void on_songchange(struct hash* track, struct hash* session, int* key) {    if (islastsong && playfork) {        kill(playfork, SIGKILL);        islastsong = 0;    }}void reset_islastsong(struct hash* track, struct hash* session, int* key) {    islastsong = 0;}