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