1 |
#ifndef lint |
2 |
static const char RCSid[] = "$Id: win_netproc.c,v 2.1 2003/10/27 10:32:06 schorsch Exp $"; |
3 |
#endif |
4 |
|
5 |
/* |
6 |
* Skeleton netproc for WIN32 |
7 |
*/ |
8 |
|
9 |
/* |
10 |
#include <windows.h> |
11 |
*/ |
12 |
#include <direct.h> |
13 |
|
14 |
#include <stdlib.h> |
15 |
#include <stdio.h> |
16 |
#include <malloc.h> |
17 |
#include <string.h> |
18 |
|
19 |
#include "rtprocess.h" |
20 |
#include "netproc.h" |
21 |
#include "paths.h" |
22 |
|
23 |
static int maxfd; |
24 |
static char ourdir[PATH_MAX]; |
25 |
static char ourhost[64]; |
26 |
static char *ourshell; |
27 |
static char ouruser[32]; |
28 |
PSERVER *pslist = NULL; |
29 |
|
30 |
PSERVER* addpserver(char* host, char* dir, char* usr, int np) { |
31 |
PSERVER* ps; |
32 |
if (np < 1) |
33 |
return(NULL); |
34 |
// For now |
35 |
if(strcmp(host, LHOSTNAME)) |
36 |
return(NULL); |
37 |
if((ps = (PSERVER *)malloc(sizeof(PSERVER)+(np-1)*sizeof(NETPROC))) == NULL) |
38 |
return(NULL); |
39 |
if (!ourhost[0]) { |
40 |
char dirtmp[PATH_MAX]; |
41 |
register char *cp; |
42 |
register int len; |
43 |
|
44 |
strcpy(ourhost, myhostname()); |
45 |
getcwd(dirtmp, sizeof(dirtmp)); |
46 |
if ((cp = getenv("HOME")) != NULL) { |
47 |
if (!strcmp(cp, dirtmp)) |
48 |
ourdir[0] = '\0'; |
49 |
else if (!strncmp(cp, dirtmp, len=strlen(cp)) && |
50 |
dirtmp[len] == '/') |
51 |
strcpy(ourdir, dirtmp+len+1); |
52 |
else |
53 |
strcpy(ourdir, dirtmp); |
54 |
} else |
55 |
strcpy(ourdir, dirtmp); |
56 |
if ((cp = getenv("USER")) != NULL) |
57 |
strcpy(ouruser, cp); |
58 |
if ((ourshell = getenv("SHELL")) == NULL) |
59 |
ourshell = "/bin/sh"; |
60 |
//FD_ZERO(&errdesc); |
61 |
maxfd = -1; |
62 |
} |
63 |
|
64 |
if (host == NULL || !strcmp(host, ourhost) || |
65 |
!strcmp(host, LHOSTNAME)) |
66 |
ps->hostname[0] = '\0'; |
67 |
else |
68 |
strcpy(ps->hostname, host); |
69 |
if (dir == NULL) |
70 |
strcpy(ps->directory, ourdir); |
71 |
else |
72 |
strcpy(ps->directory, dir); |
73 |
if (usr == NULL || !strcmp(usr, ouruser)) |
74 |
ps->username[0] = '\0'; |
75 |
else |
76 |
strcpy(ps->username, usr); |
77 |
ps->nprocs = np; |
78 |
while (np--) { |
79 |
ps->proc[np].com = NULL; |
80 |
ps->proc[np].pid = -1; |
81 |
ps->proc[np].efd = -1; |
82 |
ps->proc[np].errs = NULL; |
83 |
ps->proc[np].elen = 0; |
84 |
ps->proc[np].cf = NULL; |
85 |
} |
86 |
|
87 |
ps->next = pslist; |
88 |
pslist = ps; |
89 |
|
90 |
if (!pserverOK(ps)) { |
91 |
delpserver(ps); |
92 |
return(NULL); |
93 |
} |
94 |
return(ps); |
95 |
} |
96 |
|
97 |
void delpserver(PSERVER *ps) |
98 |
{ |
99 |
return; |
100 |
} |
101 |
|
102 |
PSERVER* findjob(int *pnp) |
103 |
{ |
104 |
static PSERVER ps; |
105 |
return &ps; |
106 |
} |
107 |
|
108 |
int |
109 |
kill(pid_t pid, int sig) |
110 |
{ |
111 |
return 0; |
112 |
} |
113 |
|
114 |
int startjob( |
115 |
PSERVER* pPS, |
116 |
char* command, |
117 |
pscompfunc *compf |
118 |
) |
119 |
{ |
120 |
return 0; |
121 |
} |
122 |
|
123 |
int wait4job(PSERVER* pPS, int pID) { |
124 |
if(pID == -1) |
125 |
return -1; |
126 |
return 0; |
127 |
} |