30 #include <sys/types.h> 36 #include <lib$routines.h> 64 name =
new char[strlen(mbxname)+1];
75 sprintf(buf,
"could not write mailbox=%s\n",mbxname);
76 ret =
::write(1,buf,strlen(buf));
78 sprintf(buf,
"you have to run this program as root !!!\n");
79 ret =
::write(1,buf,strlen(buf));
83 fchmod(fileno(fp),0x0fff);
92 key = ftok(
name,
'b');
98 chanid = msgget(key, 0600 | IPC_CREAT);
105 struct dsc$descriptor_s dmbxname;
109 name =
new char[strlen(mbxname)+1];
110 strcpy(
name,mbxname);
111 dmbxname.dsc$w_length = strlen(
name);
112 dmbxname.dsc$a_pointer =
name;
113 dmbxname.dsc$b_dtype = DSC$K_DTYPE_T;
114 dmbxname.dsc$b_class = DSC$K_CLASS_S;
115 ret = sys$crembx((
char)1,
122 if(ret == SS$_NORMAL) {
chanid = chan_id;
return; }
129 name =
new char[strlen(mbxname)+1];
130 strcpy(
name,mbxname);
141 sys$dassgn((
short)
chanid);
145 CloseHandle((HANDLE)
chanid);
155 unsigned char *message =
new unsigned char [
sizeof(long) + len];
156 long *lptr = (
long *) message;
158 memcpy(&message[
sizeof(
long)],buf,len);
159 retlen = msgsnd(
chanid,(
struct msgbuf *) message, len, 0);
169 IO$_WRITEVBLK | IO$M_NOW | IO$M_NORSWAIT,
182 unsigned long numWritten;
188 strcpy(mbxname,
"\\\\.\\mailslot\\"); strcat(mbxname,
name);
191 GENERIC_READ | GENERIC_WRITE,
192 FILE_SHARE_READ | FILE_SHARE_WRITE,
195 FILE_ATTRIBUTE_NORMAL,
198 if(h == INVALID_HANDLE_VALUE)
216 CloseHandle((HANDLE)
chanid);
232 unsigned char *message =
new unsigned char [
sizeof(long) + maxlen];
233 if(wait ==
WAIT ) len = msgrcv(
chanid,(
struct msgbuf *) message, maxlen,0,0);
234 else len = msgrcv(
chanid,(
struct msgbuf *) message, maxlen,0,IPC_NOWAIT);
235 if(len < maxlen && len >= 0)
237 memcpy(buf,&message[
sizeof(
long)],len);
255 IO$_READVBLK | IO$M_NOW,
272 if(len < maxlen && len >= 0) cbuf[len] =
'\0';
273 if (ret == SS$_NORMAL && iosb.
iostat == SS$_NORMAL)
return len;
275 else if(ret == SS$_NORMAL)
286 unsigned long lenRead;
291 strcpy(mbxname,
"\\\\.\\mailslot\\"); strcat(mbxname,
name);
295 MAILSLOT_WAIT_FOREVER,
300 bret2 = SetMailslotInfo((HANDLE)
chanid, MAILSLOT_WAIT_FOREVER);
307 bret2 = SetMailslotInfo((HANDLE)
chanid, 0);
316 bret2 = SetMailslotInfo((HANDLE)
chanid, MAILSLOT_WAIT_FOREVER);
319 if((
int) lenRead < maxlen && (
int) lenRead >= 0) cbuf[lenRead] =
'\0';
332 if((
int) lenRead < maxlen && (
int) lenRead >= 0) cbuf[lenRead] =
'\0';
353 if(ret < 0)
return ret;
354 return write(message,strlen(message));
373 if(ret < 0)
buffer[0] =
'\0';
379 return write(message,strlen(message)+1);
int setReadBufferSize(int size)
int printf(const char *format,...)
int rlvsnprintf(char *text, int len, const char *format, va_list ap)
rlMailbox(const char *name)
int read(void *buf, int maxlen, int wait=WAIT)
int write(const void *buf, int len)
wait parameter for read()