/*************************************************************************** * cron_client.c * * Wed May 4 20:03:01 2005 * Copyright 2005 tw03d024 * Email tw03d024@technikum-wien.at ****************************************************************************/ #include #include #include #include #include #include #include #define KEY 0410257051 #define PERM 0666 #define MAX_DATA 255 typedef struct { long mType; char mText[MAX_DATA]; } message_t; int main(int argc, char *argv[]) { message_t msg; int msgid = -1; char command[MAX_DATA]; char time[5]; char *buffer; int i; if (argc < 2) { fprintf(stderr,"Usage: %s hh:mm program [arg1] [agr2...argn]\n",argv[0]); return EXIT_FAILURE; } for(i=2; i #include #include #include #include #include #include #include #define KEY 0410257051 #define PERM 0666 #define MAX_DATA 255 typedef struct { long mType; char mText[MAX_DATA]; } message_t; int main(int argc, char *argv[]) { message_t msg; int msgid = -1; time_t start, stop; double diff; start = time(NULL); if ( (msgid = msgget( KEY,PERM | IPC_CREAT | IPC_EXCL )) == -1 ) { fprintf(stderr, "%s: MessageQueue konnte nicht erzeugt werden!", argv[0]); return EXIT_FAILURE; } diff=difftime(stop=time(NULL),start); while(1) { fprintf(stdout, "Zeit: %d\n", (int)diff); fflush(stdout); while((diff=difftime(stop=time(NULL),start)) != 5); { if (msgrcv(msgid,&msg,sizeof(msg)-sizeof(long), msg.mType, 0) == -1) { fprintf(stderr, "%s: Fehler", argv[0]); return EXIT_FAILURE; } fprintf(stdout, "Nachricht: %s %d\n", msg.mText, (int)msg.mType); fflush (stdout); } } system("PAUSE"); return 0; }