# include "pcontrol.h"

static IDtype CurrentJobID  = 0;
static IDtype CurrentHostID = 0;

/* for now, no persistence : we could use the date/time to seed the upper byte(s) if needed */
void InitIDs () {
  CurrentJobID = 0;
  CurrentHostID = 0;
}

IDtype NextJobID () {

  IDtype ID;

  ID = CurrentJobID;
  CurrentJobID ++;
  return (ID);
}

IDtype NextHostID () {

  IDtype ID;

  ID = CurrentHostID;
  CurrentHostID ++;
  return (ID);
}

void PrintID (gpDest dest, IDtype ID) {

  unsigned short int word0, word1, word2, word3;

  word0 = 0xffff & ID;
  word1 = 0xffff & (ID >> 16);
  word2 = 0xffff & (ID >> 32);
  word3 = 0xffff & (ID >> 48);

  gprint (dest, "%x.%x.%x.%x", word3, word2, word1, word0);
}

