ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/util/win_netproc.c
Revision: 2.1
Committed: Mon Oct 27 10:32:06 2003 UTC (21 years, 1 month ago) by schorsch
Content type: text/plain
Branch: MAIN
Log Message:
Added simplistic win_netproc.c and various other compatibility fixes.

File Contents

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