#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#define ROZ 512
struct some_data
{
long mtype; /* rodzaj komunikatu, musi by� > 0 */
char mtext[ROZ]; /* przekazywane dane */
};
int main(int argc, char *argv[])
{
int msg_id;
char tab[20];
char bufor[ROZ];
struct msgbuf some_data;
int run=1;
msg_id=msgget(45821,0666|IPC_CREAT);
if(msg_id==-1)
{
fprintf(stderr,"blad shmget %d %s\n",errno,strerror(errno));
exit(1);
}
printf("Kolejka %d\n", msg_id);
sprintf(tab,"ipcs -q -i %d",msg_id);
system(tab);
int i=0;
while(run)
{
for(i;i<100;i++){
printf("Wprowadz tekst: ");
fgets(bufor,ROZ,stdin);
some_data.mtype = 1;
strcpy(some_data.mtext, bufor);
printf("%s", some_data.mtext);
if(msgrcv()(msg_id, (void *)&some_data == -1)
{
fprintf(stderr, "msgrcv zawiodl blad %d - %s\n",errno, strerror(errno));
exit(EXIT_FAILURE);
}
if(strncmp(bufor,"koniec",3) == 0)
run = 0;
}
}
system("ipcs -q");
exit(0);
}
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}