|
|
1.1 ! root 1: static char SCCSID[] = "@(#)dkxenviron.c 2.1 DKHOST 84/08/10"; ! 2: ! 3: #include <stdio.h> ! 4: #include <string.h> ! 5: ! 6: char *getenv(); ! 7: ! 8: /* ! 9: * Transmit environment variables to a remote host ! 10: * ! 11: * The environment variables to be sent are listed, separated by commas, ! 12: * in the environment variable DKEXPORT. They are all sent as a series of ! 13: * null-terminated strings using the dkxqt protocol. ! 14: * ! 15: * netfd = file descriptor of an open connection to the remote host ! 16: * return = >0 : write successful ! 17: * | <0 : write failed ! 18: */ ! 19: ! 20: dkxenviron(netfd) ! 21: { ! 22: register char *envlist, *envnext, *ap, *ep; ! 23: short len; ! 24: char envarray[2048]; ! 25: ! 26: if(!(envlist = getenv("DKEXPORT"))) ! 27: envlist = ""; ! 28: ! 29: ap = envarray; ! 30: ! 31: do{ ! 32: if(envnext = strchr(envlist, ',')) ! 33: *envnext = '\0'; ! 34: ! 35: if(ep = getenv(envlist)){ ! 36: sprintf(ap, "%s=%s", envlist, ep); ! 37: ! 38: ap += strlen(ap) + 1; ! 39: } ! 40: ! 41: if(envnext) ! 42: *envnext++ = ','; ! 43: }while(envlist = envnext); ! 44: ! 45: len = ap - envarray; ! 46: ! 47: return(dkxlwrite(netfd, envarray, len)); ! 48: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.