/**CFile***********************************************************************

  FileName    [def.h]

  Synopsis    [Client: Passes an input file that is given as the first argument
  					during starting the program. The file contents is passed via a 
					message queue apporach.
					]					

  Description []

  Authors     [Ralf Seepold]

******************************************************************************/
#ifndef DEF_H
#define DEF_H


#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/msg.h>
#include <errno.h>

#ifdef SEMAPHORE
  #include "my_semaphore.h"
#endif

#define SENDKEY 10001234				// this a number; a fixed the message queue name for sending
												// only digits are allowed
#define RETURNKEY (2*SENDKEY)			// name of queue for receiving result of type long

/* Remember:
   The macros SENDKEY and RETURNKEY must not be used in def.c
*/

#define MAX_STR_SIZE 500								// buffer size
#define SEND_SIZE (sizeof(mymesg)-sizeof(long))	// for msgsnd
#define RETURN_SIZE (sizeof(myretmesg)-sizeof(long)) // for msgsnd
#define EOF_TYPE 99						// message type for EOF token
#define LINE_LENGTH 200					// max. length for a single code line
#define PERMISSION "rb"					// read-only


   struct mymesg {		// data type for client to server communication
      long mtype; 		// message type
      long mnumber;		// the odd line number's contents
      char mtext[MAX_STR_SIZE+1];	// strings + end of string
   };
	
   struct myretmesg {	// data type for server to client communication
      long mtype; 		// message type
      long msum;			// sum of all mnumbers received
      int mlines;			// total number of lines
   };
	
   
   typedef struct mymesg mymesg;
   typedef struct myretmesg myretmesg;
	
	
   	
   int createQueue ( long );    
      	
   int removeQueue ( long );
    
   int writeQueue ( int, mymesg*, size_t );
			
   int readQueueRet ( int, myretmesg* );

   int passfile ( const char*, int );

#endif /* DEF_H  */


