39 #define PIPE_TIMEOUT 5000
47 static char *_get_make_pipe_path(
void)
50 const char *prefix =
"c:/grass-";
51 char *whoami =
"mingw-anon-user";
59 len = strlen(prefix) + strlen(user) + 1;
61 sprintf(
path,
"%s%s", prefix, user);
67 if (!S_ISDIR(theStat.st_mode)) {
71 status = chmod(
path, S_IRWXU);
88 char *G_pipe_get_fname(
char *
name)
96 dirpath = _get_make_pipe_path();
101 len = strlen(dirpath) + strlen(
name) + 2;
103 sprintf(
path,
"%s/%s", dirpath,
name);
114 int G_pipe_exists(
char *
name)
117 HANDLE hFile = hFile =
118 CreateFile(
name, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING,
119 FILE_ATTRIBUTE_NORMAL,
NULL);
121 if (hFile != INVALID_HANDLE_VALUE) {
122 if (
name ==
NULL || (FILE_TYPE_PIPE != GetFileType(hFile))) {
140 HANDLE G_pipe_bind(
char *
name)
147 if (G_pipe_exists(
name)) {
152 hPipe = CreateNamedPipe(
name,
155 PIPE_READMODE_MESSAGE |
157 PIPE_UNLIMITED_INSTANCES,
163 if (hPipe == INVALID_HANDLE_VALUE) {
174 int G_pipe_listen(HANDLE hPipe,
unsigned int queue_len)
188 HANDLE G_pipe_accept(HANDLE hPipe)
193 fConnected = ConnectNamedPipe(hPipe,
NULL)
195 : (GetLastError() == ERROR_PIPE_CONNECTED);
210 HANDLE G_pipe_connect(
char *
name)
214 if (!G_pipe_exists(
name)) {
219 hPipe = CreateFile(
name,
228 if (hPipe != INVALID_HANDLE_VALUE) {
231 if (GetLastError() != ERROR_PIPE_BUSY) {
235 if (!WaitNamedPipe(
name, PIPE_TIMEOUT)) {
void G_free(void *)
Free allocated memory.
const char * G_whoami(void)
Gets user's name.
int G_lstat(const char *, struct stat *)
Get file status.
int G_mkdir(const char *)
Creates a new directory.
int dummy_for_iso_compilers