Exemplo n.º 1
0
static sAttribute *
findAttribute (
  sObject	*op,
  pwr_sAttrRef	*aref,
  pwr_tClassId	cid
)
{
  LstLink(sAttribute) *al;
  sAttribute *ap = NULL;

  for (al = LstFir(&op->attr_l); al != LstEnd(&op->attr_l); al = LstNex(al)) {
    if (aref->Offset == LstObj(al)->aref.Offset) {
      ap = LstObj(al);
      break;
    }
  }

  if (ap == NULL) {
    ap = (sAttribute *)calloc(1, sizeof(*ap));
    if (ap == NULL) exit(2);

    LstIni(&ap->attr_l);
    LstIni(&ap->sup_l);
    (void)LstIns(&op->attr_l, ap, attr_l);
    op->attr_c++;
    ap->cid = cid;
    ap->aref = *aref;
  }
  return ap;
}
Exemplo n.º 2
0
static void
init (
)
{
  pwr_sClass_ASup *asp;
  pwr_sClass_DSup *dsp; 
  pwr_tStatus sts;
  sAttribute *ap;
  sObject *op;
  sSupObject *sp;
  pwr_tObjid oid;

  ltp = tree_CreateTable(&sts, sizeof(pwr_tObjid), offsetof(sObject, oid),
    sizeof(sObject), 200, tree_Comp_oid);

  sts = gdh_GetClassList(pwr_cClass_ASup, &oid);
  while (ODD(sts)) {
    sts = gdh_ObjidToPointer(oid, (void **)&asp);
    op = tree_Find(&sts, ltp, &asp->Attribute.Objid);
    if (op == NULL) {
      op = tree_Insert(&sts, ltp, &asp->Attribute.Objid);
      LstIni(&op->attr_l);
    }

    ap = findAttribute(op, &asp->Attribute, pwr_cClass_ASup);
    
    sp = calloc(1, sizeof(*sp));
    (void)LstIns(LstEnd(&ap->sup_l), sp, sup_l); 
    sp->oid = oid;
    sp->p = asp;
    op->sup_c++;
    ap->sup_c++;

    sts = gdh_GetNextObject(oid, &oid);
  }

  sts = gdh_GetClassList(pwr_cClass_DSup, &oid);
  while (ODD(sts)) {
    sts = gdh_ObjidToPointer(oid, (void **)&dsp);
    op = tree_Find(&sts, ltp, &dsp->Attribute.Objid);
    if (op == NULL) {
      op = tree_Insert(&sts, ltp, &dsp->Attribute.Objid);
      LstIni(&op->attr_l);
    }

    ap = findAttribute(op, &dsp->Attribute, pwr_cClass_DSup);
    
    sp = calloc(1, sizeof(*sp));
    (void)LstIns(LstEnd(&ap->sup_l), sp, sup_l); 
    sp->oid = oid;
    sp->p = dsp;
    op->sup_c++;
    ap->sup_c++;

    sts = gdh_GetNextObject(oid, &oid);
  }

}
Exemplo n.º 3
0
void lex_FacName(const char *FacName)
{
  sFacilityCB *facp = (sFacilityCB *)calloc(1, sizeof(sFacilityCB));

  LstIni(&facp->MsgH);
  facp->f.FacName = MSG_NEW_STRING(FacName);

  LstIns(&lFacH, facp, FacL);

}
Exemplo n.º 4
0
int main(int argc, char **argv) 
{
  extern FILE *yyin;
  extern int yylex();

  FILE *cfp = NULL;
  int bmsg = 0;
  char *branch = NULL;
  int inFile;
  int outFile;
  
  if (argc < 3) 
      usage();
    
  if (argv[1][0] == '-') {
    if (argv[1][1] == 'b') {
      branch = argv[2];
      bmsg = 1;
    }
    else 
      usage();
    if (argc != 5)
      usage(); 
  } else if (argc != 3)
    usage();

  inFile = bmsg ? 3 : 1; 
  outFile = inFile + 1;

  if (!(yyin = fopen(argv[inFile], "r"))) {
      printf("Can't open input file: %s", argv[inFile]);
      exit(1);
  }

  LstIni(&lFacH);
  SyntaxError = 0;
  lineno = 1;    
  
  yylex();

  if (!SyntaxError) {
    if (!(cfp = fopen(argv[outFile], "w+"))) {
	printf("Can't open output file: %s", argv[outFile]);
	exit(1);
    }  

    rewind(yyin);
    WriteIncludes(cfp);
    CopyFile(yyin, cfp);
    WriteFacility(cfp, branch);
  }

  fclose(yyin);
  fclose(cfp);

#if defined OS_VMS || defined OS_ELN
  exit(1);
#elif defined OS_POSIX
  exit(EXIT_SUCCESS);
#endif
}
Exemplo n.º 5
0
/*
* Main
*/
int main(int argc, char **argv)
{
  extern FILE *yyin;
  extern int yylex();

  FILE *cfp = NULL;
  FILE *hfp = NULL;


  if (argc != 4) {
      printf("Usage: co_msg2cmsg msg-file c_msg-file h_file\n");
      exit(2);
  }

  if (!(yyin = fopen(argv[1], "r"))) {
      printf("Can't open input file: %s\n", argv[1]);
      exit(2);
  }

  if (!(cfp = fopen(argv[2], "w"))) {
      printf("Can't open c_msg-output file: %s\n", argv[2]);
      fclose(yyin);
      exit(2);
  }

  if (!(hfp = fopen(argv[3], "w"))) {
      printf("Can't open h-output file: %s\n", argv[3]);
      fclose(yyin);
      fclose(cfp);
      exit(2);
  }


  LstIni(&lFacH);
  SyntaxError = 0;
  lineno = 1;
  yylex();

  if (!SyntaxError) {
    char fname[256];
    char *p;

#if defined OS_VMS || defined OS_ELN
    p = strpbrk(argv[2], "]>");
    if (!p)
      p = strchr(argv[2], ':');
    else {
      char *p2;
      while(p2 = strpbrk(p + 1, "]>"))
	p = p2;
    }
    if (p)
      for (i = 0; p[i+1]; i++)
	fname[i] = tolower(p[i+1]);
    else
      for (i = 0; argv[2][i]; i++)
	fname[i] = tolower(argv[2][i]);
    fname[i] = '\0';
#else
    if ((p = strrchr(argv[2], '/')))
      strncpy(fname, p+1, sizeof(fname));
    else
      strncpy(fname, argv[2], sizeof(fname));
    
#endif

    if ((p = strchr(fname, '.')))
      *p = '\0';

    WriteFiles(fname, cfp, hfp);
  }

  fclose(yyin);
  fclose(cfp);
  fclose(hfp);

#if defined OS_VMS || defined OS_ELN
  exit(1);
#elif defined OS_POSIX
  exit(EXIT_SUCCESS);
#endif
}
Exemplo n.º 6
0
int main (int argc, char ** argv)
{
  pwr_tStatus	sts;
  qcom_sQid	my_q = qcom_cNQid;
  qcom_sGet	get;

  errh_Init("pwr_linksup", errh_eAnix_linksup);
  errh_SetStatus( PWR__SRVSTARTUP);

  if (!qcom_Init(&sts, NULL, "pwr_linksup")) {
    errh_Error("qcom_Init, %m", sts);
    errh_SetStatus( PWR__SRVTERM);
    exit(sts);
  }

  sts = gdh_Init("pwr_linksup");
  if (EVEN(sts)) {
    errh_Fatal("gdh_Init, %m", sts);
    errh_SetStatus( PWR__SRVTERM);
    exit(sts);
  }

  if (!qcom_CreateQ(&sts, &my_q, NULL, "events")) {
    errh_Fatal("qcom_CreateQ, %m", sts);
    errh_SetStatus( PWR__SRVTERM);
    exit(sts);
  }
  if (!qcom_Bind(&sts, &my_q, &qcom_cQini)) {
    errh_Fatal("qcom_Bind(Qini), %m", sts);
    errh_SetStatus( PWR__SRVTERM);
    exit(-1);
  }

  /* Wait for local nethandler to start */

  while (EVEN(gdh_NethandlerRunning()))
    sleep(1);   

  plc_UtlWaitForPlc();

  LstIni(&node_l);
  LstIni(&timer_l);

  init_nodes();
  if (!LstEmp(&node_l)) {
    list_state = eListState_Scan;
  } else {
    errh_Info("No nodes to supervise, exiting");
    errh_SetStatus( pwr_cNStatus);
    exit(0);
  }

  errh_SetStatus( PWR__SRUN);

  for (;;) {
    scan_timers();
    scan_nodes();
    get.data = NULL;
    if (qcom_Get(&sts, &my_q, &get, cTimerTimeScan) != NULL) {
      if (get.type.b == qcom_eBtype_event) {
	event(&get);
      } else {
	errh_Info("unexpected message type, type: %d", get.type.b);
      }
      qcom_Free(&sts, get.data);
    }
    aproc_TimeStamp(((float)cTimerTimeScan)/1000, 5);
  }
}