(file) Return to set_history.c CVS log (file) (dir) Up to [Development] / JSOC / proj / globalhs / apps

File: [Development] / JSOC / proj / globalhs / apps / set_history.c (download)
Revision: 1.3, Sun Apr 28 06:59:17 2013 UTC (5 years, 5 months ago) by tplarson
Branch: MAIN
CVS Tags: globalhs_version_9, globalhs_version_8, globalhs_version_7, globalhs_version_6, globalhs_version_5, globalhs_version_4, globalhs_version_3, globalhs_version_2, globalhs_version_19, globalhs_version_18, globalhs_version_17, globalhs_version_16, globalhs_version_15, globalhs_version_14, globalhs_version_13, globalhs_version_12, globalhs_version_11, globalhs_version_10, globalhs_version_1, globalhs_version_0, Ver_LATEST, Ver_9-2, Ver_9-1, Ver_9-0, Ver_8-8, Ver_8-7, Ver_8-6, Ver_8-5, Ver_8-4, Ver_8-3, Ver_8-2, Ver_8-12, Ver_8-11, Ver_8-10, Ver_8-1, HEAD
Changes since 1.2: +8 -3 lines
got rid of HEADER, now use CVSTAG

#include <unistd.h>
#ifndef CVSTAG
#define CVSTAG "undefined"
#endif

char *cvsinfo_set_history = "cvsinfo: $Header: /home/cvsuser/cvsroot/JSOC/proj/globalhs/apps/set_history.c,v 1.3 2013/04/28 07:59:17 tplarson Exp $";

long long set_history(DRMS_Link_t *histlink)
{
  int status=0;
  int len;
  long long hold;
  TIME tnow, UNIX_epoch = -220924792.000; /* 1970.01.01_00:00:00_UTC */
  char path[DRMS_MAXPATHLEN+1];
  DRMS_Record_t *histrec = drms_create_record(drms_env, 
                                              histlink->info->target_series,
                                              DRMS_PERMANENT, 
                                              &status);

  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: could not open a record in history dataseries %s, status = %d\n", histlink->info->target_series, status);
    return -1;
  }

  if ((len=readlink("/proc/self/exe", path, DRMS_MAXPATHLEN)) == -1)
  {
    fprintf(stderr, "ERROR: cannot locate binary\n");
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }
  else
    path[len]='\0';

  status = drms_setkey_string(histrec, "MODPATH", path);
  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: problem writing keyword MODPATH in history dataseries, status = %d\n", status);
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }
  status = drms_setkey_string(histrec, "MODNAME", cmdparams.argv[0]);
  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: problem writing keyword MODNAME in history dataseries, status = %d\n", status);
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }
  status = drms_setkey_string(histrec, "ARGSUSED", savestr);
  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: problem writing keyword ARGSUSED in history dataseries, status = %d\n", status);
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }
  status = drms_setkey_string(histrec, "CVSTAG", CVSTAG);
  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: problem writing keyword CVSTAG in history dataseries, status = %d\n", status);
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }
  tnow = (double)time(NULL);
  tnow += UNIX_epoch;
  status = drms_setkey_time(histrec, "DATE", tnow);
  if (status != DRMS_SUCCESS)
  {
    fprintf(stderr,"ERROR: problem writing keyword DATE in history dataseries, status = %d\n", status);
    drms_close_record(histrec, DRMS_FREE_RECORD);
    return -1;
  }

  hold=histrec->recnum;
  drms_close_record(histrec, DRMS_INSERT_RECORD);
  return hold;
}

Karen Tian
Powered by
ViewCVS 0.9.4