/* shm.h
 * PSR 3shm assignment
 * DO NOT MODIFY
 */

#ifndef PSR3SHM_H
#define PSR3SHM_H

#include <sys/mman.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/stat.h>
#include <semLib.h>
#include <fcntl.h>

struct company {
    char name[20];
    int work_done;
};

struct company_registry {
    struct company companies[50];
};

/* Pointer to the shared registry. */
extern struct company_registry *registry;

/* Lock for protecting shared registry. */
extern SEM_ID lock;

/*
 * init_shm()
 *  : (char*) company_name -- Name of the company to be registered.
 *
 *  This function should initialize the shared memory and make it
 *  accessible to the rest of the program. In addition, when executed
 *  from a company, it should register this company into the registry
 *  and return a pointer to the registered company struct.
 *
 *  See assignment page for a sample code.
 */
struct company* init_shm(char* company_name);

#endif