"Fossies" - the Fresh Open Source Software Archive

Member "modutils-2.4.27/kerneld/GOODIES/kdsound.c" (5 Jan 2001, 1775 Bytes) of package /linux/misc/old/modutils-2.4.27.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "kdsound.c" see the Fossies "Dox" file reference documentation.

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <unistd.h>
    4 #include <sys/types.h>
    5 #include <sys/ipc.h>
    6 #include <sys/msg.h>
    7 #define CONFIG_KERNELD
    8 #include <linux/kerneld.h>
    9 
   10 #define MSIZE 1024
   11 #define KERNELD_SOUND 300
   12 
   13 /*
   14  * Copyright (C) 1995, 1996  Bjorn Ekwall <bj0rn@blox.se>
   15  *
   16  * See the file "COPYING" for your rights (GPL).
   17  *
   18  * This is an extra kerneld that just listens for sound requests,
   19  * i.e. message type 300.
   20  * This number was randomly chosen, as being a round number > 255.
   21  *
   22  * That means that it can run concurrently with the "normal" kerneld,
   23  * so that we can test the funtionality before folding it in with
   24  * the other kerneld requests.
   25  *
   26  * Start "kdsound" as: "/sbin/kdsound &"
   27  */
   28 
   29 int
   30 main(argc, argv)
   31 int argc;
   32 char **argv;
   33 {
   34     struct kerneld_msg *msgp;
   35     int status;
   36     int qid;
   37     char *soundparam;
   38 
   39     qid = msgget(IPC_PRIVATE, 0600 | IPC_KERNELD);
   40     if (qid < 0) {
   41         perror("kdsound");
   42         exit(1);
   43     }
   44 
   45     msgp = (struct kerneld_msg *)malloc(sizeof(struct kerneld_msg) + MSIZE);
   46 
   47     while (1) {
   48         status = msgrcv(qid, (struct msgbuf *)msgp,
   49             sizeof(long) + MSIZE, KERNELD_SOUND, MSG_NOERROR);
   50         if (status > 0) {
   51 #ifdef NEW_KERNELD_PROTOCOL /* using new extended kerneld message format */
   52             struct oldkerneld_msg {
   53                 long mtype;
   54                 long id;
   55                 char text[1];
   56             };
   57 
   58             if (msgp->version == 2) {
   59                 if (msgp->pid != 0) {
   60                     char triggerpid[30];
   61                     sprintf(triggerpid, "KERNELD_TRIGGER=%d", msgp->pid);
   62                     putenv(triggerpid);
   63                 }
   64                 soundparam = msgp->text;
   65             }
   66             else
   67                 soundparam = ((struct oldkerneld_msg *)msgp)->text;
   68 #else
   69             soundparam = msgp->text;
   70 #endif
   71             if (sound_pid > 0) {
   72                 kill(
   73             }
   74             if ((sound_pid = fork()) == 0) {
   75                 execlp("/bin/sh", "sh", "/sbin/do_sound",
   76                     soundparam, 0);
   77                 exit(0);
   78             }
   79         }
   80     }
   81 }