feat: minor changes

This commit is contained in:
2025-10-10 14:06:07 +03:00
parent 5dbe188b08
commit 1ecce31da4
3 changed files with 27 additions and 41 deletions

View File

@ -6,19 +6,12 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/msg.h>
#define MQ_KEY1 1234L
#define MQ_KEY2 2345L
#define MAXMESGDATA 4096
struct mymesg {
long mesg_len;
long mesg_type;
char mesg_data[MAXMESGDATA];
};
#include "common.h"
void client(int readid, int writeid);
ssize_t mesg_send(int id, struct mymesg *mptr);
ssize_t mesg_recv(int id, struct mymesg *mptr);
ssize_t mesg_send(int id, struct msg *mptr);
ssize_t mesg_recv(int id, struct msg *mptr);
int main(int argc,char **argv)
{
@ -57,7 +50,7 @@ void client(int readid, int writeid)
{
size_t len;
ssize_t n;
struct mymesg ourmesg;
struct msg ourmesg;
printf("Client:readid=%d writeid=%d\n",readid,writeid);
printf("Input file name, please\n");
@ -81,18 +74,18 @@ void client(int readid, int writeid)
write(1,ourmesg.mesg_data, n);
}
ssize_t mesg_send(int id, struct mymesg *mptr)
ssize_t mesg_send(int id, struct msg *mptr)
{
return(msgsnd(id, &(mptr->mesg_type),mptr->mesg_len, 0));
}
ssize_t mesg_recv(int id, struct mymesg *mptr)
ssize_t mesg_recv(int id, struct msg *mptr)
{
ssize_t n;
n=msgrcv(id, &(mptr->mesg_type),MAXMESGDATA,mptr->mesg_type, 0);
mptr->mesg_len=n;
printf("Client: n=%d\n",n);
printf("Client: n=%ld\n",n);
return(n);
}