40#define PIPE_TIMEOUT 5000
48static char *_get_make_pipe_path(
void)
51 const char *prefix =
"c:/grass-";
52 char *whoami =
"mingw-anon-user";
60 len = strlen(prefix) + strlen(user) + 1;
62 sprintf(
path,
"%s%s", prefix, user);
68 if (!S_ISDIR(theStat.st_mode)) {
72 status = chmod(
path, S_IRWXU);
90char *G_pipe_get_fname(
char *
name)
98 dirpath = _get_make_pipe_path();
103 len = strlen(dirpath) + strlen(
name) + 2;
104 path = G_malloc(len);
105 sprintf(
path,
"%s/%s", dirpath,
name);
117int G_pipe_exists(
char *
name)
120 HANDLE hFile = hFile = CreateFile(
name,
125 FILE_ATTRIBUTE_NORMAL,
128 if (hFile != INVALID_HANDLE_VALUE) {
129 if (
name ==
NULL || (FILE_TYPE_PIPE != GetFileType(hFile))) {
148HANDLE G_pipe_bind(
char *
name)
155 if (G_pipe_exists(
name)) {
160 hPipe = CreateNamedPipe(
name,
163 PIPE_READMODE_MESSAGE |
165 PIPE_UNLIMITED_INSTANCES,
171 if (hPipe == INVALID_HANDLE_VALUE) {
183int G_pipe_listen(HANDLE hPipe,
unsigned int queue_len)
197HANDLE G_pipe_accept(HANDLE hPipe)
202 fConnected = ConnectNamedPipe(hPipe,
NULL) ?
203 TRUE : (GetLastError() == ERROR_PIPE_CONNECTED);
219HANDLE G_pipe_connect(
char *
name)
223 if (!G_pipe_exists(
name)) {
228 hPipe = CreateFile(
name,
236 if (hPipe != INVALID_HANDLE_VALUE) {
239 if (GetLastError() != ERROR_PIPE_BUSY) {
243 if (!WaitNamedPipe(
name, PIPE_TIMEOUT)) {
void G_free(void *buf)
Free allocated memory.
int G_mkdir(const char *path)
Creates a new directory.
int G_lstat(const char *file_name, struct stat *buf)
Get file status.
const char * G_whoami(void)
Gets user's name.