summaryrefslogtreecommitdiffstats
path: root/kdecore/tests/kprocesstest.h
blob: 3e5d989ec7363d8ec762abd5b1f980e99d42e844 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
//
//  DUMMY -- A dummy class with a slot to demonstrate KProcess signals
//
//  version 0.2, Aug 2nd 1997
//
//  (C) Christian Czezatke
//  e9025461@student.tuwien.ac.at
//


#ifndef __DUMMY_H__
#define __DUMMY_H__

#include <stdio.h>
#include <tqobject.h>
#include "kprocess.h"

class Dummy : public QObject
{
 Q_OBJECT

 public slots:
   void printMessage(KProcess *proc)
   {
     printf("Process %d exited!\n", (int)proc->getPid()); 
   } 
 
   void gotOutput(KProcess*, char *buffer, int len)
   {
    char result[1025];             // this is ugly since it relys on the internal buffer size of KProcess,
    memcpy(result, buffer, len);   // NEVER do that in your own application... ;-) 
    result[len] = '\0';
    printf("OUTPUT>>%s", result);
   }

   void outputDone(KProcess *proc)
     /*
       Slot Procedure for the "sort" example. -- If it is indicated that the "sort" command has
       absorbed all its input, we send an "EOF" to it to indicate that there is no more
       data to be processed. 
      */
   {
       proc->closeStdin();
   }

};

#endif