Back to index

radiance  4R0+20100331
win_netproc.c
Go to the documentation of this file.
00001 #ifndef lint
00002 static const char RCSid[] = "$Id: win_netproc.c,v 2.4 2004/10/23 18:55:53 schorsch Exp $";
00003 #endif
00004 
00005 /*
00006  * Skeleton netproc for WIN32
00007  */
00008 
00009 /*
00010 #include <windows.h>
00011 */
00012 #include <direct.h>
00013 
00014 #include <stdlib.h>
00015 #include <stdio.h>
00016 #include <malloc.h>
00017 #include <string.h>
00018 
00019 #include "rtprocess.h"
00020 #include "netproc.h"
00021 #include "paths.h"
00022 
00023 static int maxfd;
00024 static char   ourdir[PATH_MAX];
00025 static char   ourhost[64];
00026 static char   *ourshell;
00027 static char   ouruser[32];
00028 PSERVER       *pslist = NULL;
00029 
00030 PSERVER*
00031 addpserver(
00032        char* host,
00033        char* dir,
00034        char* usr,
00035        int np
00036 )
00037 {
00038        PSERVER* ps;
00039        if (np < 1)
00040               return(NULL);
00041        // For now
00042        if(strcmp(host, LHOSTNAME))
00043               return(NULL);
00044        if((ps = (PSERVER *)malloc(sizeof(PSERVER)+(np-1)*sizeof(NETPROC))) == NULL)
00045               return(NULL);
00046        if (!ourhost[0]) {
00047               char   dirtmp[PATH_MAX];
00048               register char *cp;
00049               register int  len;
00050 
00051               strcpy(ourhost, myhostname());
00052               getcwd(dirtmp, sizeof(dirtmp));
00053               if ((cp = getenv("HOME")) != NULL) {
00054                      if (!strcmp(cp, dirtmp))
00055                             ourdir[0] = '\0';
00056                      else if (!strncmp(cp, dirtmp, len=strlen(cp)) &&
00057                                    dirtmp[len] == '/')
00058                             strcpy(ourdir, dirtmp+len+1);
00059                      else
00060                             strcpy(ourdir, dirtmp);
00061               } else
00062                      strcpy(ourdir, dirtmp);
00063               if ((cp = getenv("USER")) != NULL)
00064                      strcpy(ouruser, cp);
00065               if ((ourshell = getenv("SHELL")) == NULL)
00066                      ourshell = "/bin/sh";
00067               //FD_ZERO(&errdesc);
00068               maxfd = -1;
00069        }
00070 
00071        if (host == NULL || !strcmp(host, ourhost) ||
00072                      !strcmp(host, LHOSTNAME))
00073               ps->hostname[0] = '\0';
00074        else
00075               strcpy(ps->hostname, host);
00076        if (dir == NULL)
00077               strcpy(ps->directory, ourdir);
00078        else
00079               strcpy(ps->directory, dir);
00080        if (usr == NULL || !strcmp(usr, ouruser))
00081               ps->username[0] = '\0';
00082        else
00083               strcpy(ps->username, usr);
00084        ps->nprocs = np;
00085        while (np--) {
00086               ps->proc[np].com = NULL;
00087               ps->proc[np].pid = -1;
00088               ps->proc[np].efd = -1;
00089               ps->proc[np].errs = NULL;
00090               ps->proc[np].elen = 0;
00091               ps->proc[np].cf = NULL;
00092        }
00093        
00094        ps->next = pslist;
00095        pslist = ps;
00096        
00097        if (!pserverOK(ps)) {
00098               delpserver(ps);
00099               return(NULL);
00100        }
00101        return(ps);
00102 }
00103 
00104 void delpserver(PSERVER *ps)
00105 {
00106        return;
00107 }
00108 
00109 PSERVER* findjob(int *pnp)
00110 {
00111        static PSERVER ps;
00112        return &ps;
00113 }
00114 
00115 
00116 int startjob(
00117        PSERVER* pPS,
00118        char* command,
00119        pscompfunc *compf
00120 )
00121 {
00122        return 0;
00123 }
00124 
00125 int wait4job(PSERVER* pPS, int pID) {
00126        if(pID == -1)
00127               return -1;
00128        return 0;
00129 }