#include <stdio.h>
#include <string.h>
#include <sys/types.h>		/* for opendir(), etc. */
#include <dirent.h>
#include <sys/stat.h>		/* for stat() */
#include <unistd.h>
#include <fcntl.h>		/* for mkdir() */

#include "../global.h"


/* returns the integer read from the group file in the 
** user's clipboard directory, or -1 if group file can't 
** be read
*/

int
clipboard_group (const char *username, const char *course_path, SESSION *user)
{
  FILE *fp;
  char clipboard_dir[MAX_PATH + 1], inf_path[MAX_PATH + 1];
  CLIPBOARD_INFO clipboard_info;

  snprintf (clipboard_dir, MAX_PATH + 1, "%s%s/", CLIPBOARD_PATH, user->id);
  snprintf (inf_path, MAX_PATH + 1, "%s%s", clipboard_dir,
	    CLIPBOARD_INF_FNAME);
  fp = fopen (inf_path, "r");
  if (!fp)
    return (-1);
  if (fread (&clipboard_info, sizeof (CLIPBOARD_INFO), 1, fp) != 1)
    return -1;
  return (clipboard_info.group);
}



int
clipboard_empty (const char *username, const char *course_path, SESSION *user)
{
  return (clipboard_group (username, course_path, user) == -1);
}





