Ejemplo n.º 1
0
STATIC_ROUTINE int MdsLoginVMS(SOCKET sock, char *username, char *password)
{
  struct descrip loginget_arg;
  struct descrip loginpwd_arg;
  struct descrip pwd_arg;
  struct descrip ansarg;
  int status;
  ansarg.ptr = 0;
  status = MdsValue(sock, LOGINREQUEST, MakeDescrip(&loginget_arg,DTYPE_CSTRING,0,0,LOGINGETP1), &ansarg, NULL);
  if (status & 1)
  {
    if (ansarg.ptr && ansarg.dtype == DTYPE_CHAR)
    {
      char alg = *(char *)ansarg.ptr;
      free(ansarg.ptr);
      status = MdsValue(sock, LOGINREQUEST, MakeDescrip(&loginget_arg,DTYPE_CSTRING,0,0,LOGINGETP2), &ansarg, NULL);
      if (status & 1)
      {
        if (ansarg.ptr && ansarg.dtype == DTYPE_SHORT)
        {
          struct dscr { short length; char dtype; char class; void *pointer;};
          int hash[2];
          int i;
          struct dscr hashd = {8, 9, 1, 0};
          struct dscr pwdd = {0,14,1,0};
          struct dscr userd = {0,14,1,0};
          short salt = *(short *)ansarg.ptr;
          free(ansarg.ptr);
          ansarg.ptr = 0;
          hashd.pointer = hash;
          pwdd.length = strlen(password);
          pwdd.pointer = strcpy((char *)malloc(pwdd.length+1),password);
          userd.length = strlen(username);
          userd.pointer = strcpy((char *)malloc(userd.length+1),username);
          for (i=0;i<pwdd.length;i++)
            ((char *)pwdd.pointer)[i] = __toupper(((char *)pwdd.pointer)[i]);
          for (i=0;i<userd.length;i++)
            ((char *)userd.pointer)[i] = __toupper(((char *)userd.pointer)[i]);
          status = Lgihpwd(&hashd,&pwdd,alg,salt,&userd);
          if (status & 1)
          {
            int two = 2;
            status = MdsValue(sock, LOGINREQUEST, MakeDescrip(&loginpwd_arg,DTYPE_CSTRING,0,0,LOGINPWD),
                                                  MakeDescrip(&pwd_arg,DTYPE_LONG,1,&two,hash), &ansarg, NULL);
          }
          else
            printf("Login error: Error checking password\n");
        }
        else
        {
          if (ansarg.ptr)
          {
            free(ansarg.ptr);
            ansarg.ptr = 0;
          }
          printf("Login error: Unrecognized response from server\n");
          status = 0;
        }
      }
Ejemplo n.º 2
0
int  MdsOpen(SOCKET sock, char *tree, int shot)
{
  struct descrip treearg;
  struct descrip shotarg;
  struct descrip ansarg;
  STATIC_CONSTANT char *expression = "TreeOpen($,$)";
  int status = MdsValue(sock, expression, MakeDescrip((struct descrip *)&treearg,DTYPE_CSTRING,0,0,tree), 
			      MakeDescrip((struct descrip *)&shotarg,DTYPE_LONG,0,0,&shot),
			      (struct descrip *)&ansarg, (struct descrip *)NULL);
  if ((status & 1) && (ansarg.dtype == DTYPE_LONG)) status = *(int *)ansarg.ptr;
  if (ansarg.ptr) free(ansarg.ptr);
  return status;
}
Ejemplo n.º 3
0
int  MdsSetDefault(SOCKET sock, char *node)
{
  struct descrip nodearg;
  struct descrip ansarg;
  STATIC_CONSTANT char *expression = "TreeSetDefault($)";
  int status = MdsValue(sock, expression, MakeDescrip(&nodearg,DTYPE_CSTRING,0,0,node), &ansarg, NULL);
  if ((status & 1) && (ansarg.dtype == DTYPE_LONG)) status = *(int *)ansarg.ptr;
  if (ansarg.ptr) free(ansarg.ptr);
  return status;
}
Ejemplo n.º 4
0
static void EventRegisterRemote(char *eventName)
{
	int i, status;
	struct descrip evNameDsc, thisIpDsc, resDsc;

	struct ClientEventDescriptor *currEventDescr, *prevEventDescr;
	char thisIp[512];
	strncpy(thisIp, getenv("REVENT_THIS_MDSIP"), 511);
	configure();
	if(!thisIp || !*thisIp || numClientIpDescriptors == 0)
		return;  //Missing information for managing rempte events

	MakeDescrip(&thisIpDsc, DTYPE_CSTRING, 0, 0, thisIp);
	MakeDescrip(&evNameDsc, DTYPE_CSTRING, 0, 0, eventName);
	lock();
	prevEventDescr = currEventDescr = clientEventDescrHead;
	while(currEventDescr && strcmp(currEventDescr->eventName, eventName))
	{
		prevEventDescr = currEventDescr;
		currEventDescr = currEventDescr->nxt;
	}
	if(!currEventDescr)
	{
		currEventDescr = (struct ClientEventDescriptor *)malloc(sizeof(struct ClientEventDescriptor));
		currEventDescr->eventName = malloc(strlen(eventName) + 1);
		strcpy(currEventDescr->eventName, eventName);
		currEventDescr->refCount = 1;
		for(i = 0; i < numClientIpDescriptors; i++)
		{
			status = MdsValue(clientIpDescriptors[i].id, "RtEventsShr->EventRegisterExecute($1,$2)", &evNameDsc, &thisIpDsc, &resDsc, NULL);
			if(!(status & 1))
				printf("Error sending event: %s\n", MdsGetMsg(status));
		}
		if(prevEventDescr)
			prevEventDescr->nxt = currEventDescr;
		else
			clientEventDescrHead = currEventDescr;
	}
	else //already found: someone already registered fior this event on this machine
		currEventDescr->refCount++;
	unlock();
}
Ejemplo n.º 5
0
static void eventHandler(char *evName, char *buf, int size, void *arg)
{
	int i, status;
	struct descrip evNameDsc, bufDsc, resDsc;
	struct descrip bufSizeDsc;

	struct ServerEventDescriptor *currEventDescr;

printf("event handler %s\n", evName);

	lock();
	currEventDescr= (struct ServerEventDescriptor *)arg;
	if(currEventDescr->busy)
		return; //Do not propagate events received from outside
	unlock();

	MakeDescrip(&evNameDsc,DTYPE_CSTRING,0,0,evName);
	MakeDescrip(&bufDsc, DTYPE_UCHAR, 1, &size, buf);
	MakeDescrip(&bufSizeDsc, DTYPE_LONG, 0,0, (char *)&size);
	for(i = 0; i < currEventDescr->numIp; i++)
		if(currEventDescr->clients[i]->id != -1)
			status = MdsValue(currEventDescr->clients[i]->id, "RtEventsShr->EventTriggerExecute($1,$2,$3)", &evNameDsc, &bufDsc, &bufSizeDsc, &resDsc, NULL);
}