File: cvsgui_process.h

package info (click to toggle)
gcvs 1.0final-17
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 12,248 kB
  • ctags: 10,629
  • sloc: ansic: 71,711; cpp: 39,785; sh: 18,434; makefile: 1,917; yacc: 1,299; tcl: 1,283; perl: 910; lex: 249; csh: 185; lisp: 7
file content (112 lines) | stat: -rwxr-xr-x 3,346 bytes parent folder | download | duplicates (3)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
** The cvsgui protocol used by WinCvs
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
** 
** This library 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
** Lesser General Public License for more details.
** 
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
*/

/*
 * plugin.h from the GIMP modified for the cvsgui project by :
 * Alexandre Parenteau <aubonbeurre@hotmail.com> --- November 1999
 */

#ifndef CVSGUI_PROCESS_H
#define CVSGUI_PROCESS_H

#include <sys/types.h>
#include "cvsgui_wire.h"

#define WRITE_BUFFER_SIZE  512

typedef struct _CvsProcess             CvsProcess;

typedef struct
{
	long (*consoleout)(char *txt, long len);	/* Get cvs stdout */
	long (*consoleerr)(char *txt, long len);	/* Get cvs stderr */
	const char *(*getenv)(char *name);				/* Ask about env. variable */
	void (*exit)(int code);						/* Tells the exit code */
} CvsProcessCallbacks;

struct _CvsProcess
{
	unsigned int open : 1;					/* Is the process open */
	unsigned int destroy : 1;				/* Should the process by destroyed */
#ifdef WIN32
	unsigned int starting : 1;	 			/* Is the process starting or not */
#endif
	pid_t pid;								/* process process id */
	char **args;							/* process command line arguments */
	int argc;

	pipe_t my_read, my_write;				/* Apps read and write file descriptors */
	pipe_t his_read, his_write;				/* process read and write file descriptors */
	pipe_t pstdin, pstdout, pstderr;		/* tty descriptors used by the child */

	char write_buffer[WRITE_BUFFER_SIZE];	/* Buffer for writing */
	int write_buffer_index;					/* Buffer index for writing */
	CvsProcessCallbacks *callbacks;			/* Jump table */
#ifdef WIN32
	HANDLE threads[4];
	DWORD threadsID[4];
#endif
};

#ifdef __cplusplus
extern "C" {
#endif

/* Open a process. This cause the process to run.
 * Optionnally, let the child have a TTY (console)
 */
CvsProcess *cvs_process_open (char *name, int argc, char **argv,
							  CvsProcessCallbacks *callbacks, int hasTty, const char* currentDirectory);

#ifdef _0_
	/* Open a process for testing '-cvsgui'. This cause the process 
 * to start and exit with '0' if supported.
 */
CvsProcess *cvs_process_test (char *name, int argc, char **argv, CvsProcessCallbacks *callbacks);
#endif
	
/* Close a process. This kills the process and releases
 *  its resources.
 */
void cvs_process_kill(CvsProcess *cvs_process);

/* Initialize initialize the protocol library (both for the
 * process and the application)
 */
void cvs_process_init (void);

/*
 * Called by the application to answer calls from the process.
 * Returns 1 if a message from cvs was handled, 0 otherwise
 */
int cvs_process_give_time(void);

/*
 * Tells if the process is still alive
 */
int cvs_process_is_active(CvsProcess *cvs_process);

/*
 * Kills the process
 */

#ifdef __cplusplus
}
#endif

#endif /* CVSGUI_PROCESS_H */