示例#1
0
int OpenHandle(struct cmd_desc *cmddint, struct atom *atoms) {

unsigned int arg;
char *cd = NULL, *cv = NULL;
SLbHandle hnd = NULL;
SLbErr err;

   arg = cmddint->pa + 1;

   if (atoms == (struct atom *) VERBOSE_HELP) {
      printf("OpenHandle:[<device name> <revision>]\n");
      return arg;
   }

   if ((cntoph == 0) && (curoph == 0)) {
      bzero((void *) handles, (MAX_HANDLES * sizeof(SLbHandle)));
   }

   if (getenv("LD_LIBRARY_PATH") == NULL) {
      printf("OpenHandle:Warning:LD_LIBRARY_PATH not set\n");
   }

   if ((++atoms)->type == String) {
      cd = atoms->text;

      if ((++atoms)->type == String) {
	 cv = atoms->text;

	 hnd = FindOpenHandle(cd,cv);
	 if (hnd == NULL) {
	    err = SLbOpenHandle(&hnd,cd,cv);
	    if (err) {
	       fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
	       return arg;
	    }
	    if (InsertHandle(hnd) == 0) {
	       err = SLbCloseHandle(hnd);
	       if (err == SLbErrSUCCESS) err = SLbErrMEMORY;
	       fprintf(stderr,"OpenHandle:%s",SLbErrToStr(hnd,err));
	       return arg;
	    }
	 }
      } else {
	 fprintf(stderr,"OpenHandle:Missing version:%s\n",cd);
      }
   }
   ListHandles();
   return arg;
}
示例#2
0
文件: handledb.c 项目: mingpen/OpenNT
BOOLEAN
DeleteOpenHandle(
    PPROCESS_INFO Process,
    HANDLE Handle,
    ULONG Type
    )
{
    POPENHANDLE_INFO p;

    p = FindOpenHandle( Process, Handle, Type );
    if (p == NULL) {
        //
        // We will see lots of close calls for handles we dont care
        // about.  Ignore them quietly.
        //
        return FALSE;
        }

    RemoveEntryList( &p->Entry );
    FreeMem( &p->QueryName );
    FreeMem( &p );
    return TRUE;
}
示例#3
0
文件: handledb.c 项目: mingpen/OpenNT
BOOLEAN
AddOpenHandle(
    PPROCESS_INFO Process,
    HANDLE Handle,
    ULONG Type,
    PWSTR Name,
    BOOLEAN InheritHandle
    )
{
    POPENHANDLE_INFO p;

    if (Type == (ULONG)-1) {
        return FALSE;
        }

    if (FindOpenHandle( Process, Handle, Type ) != NULL) {
        return FALSE;
        }

    p = AllocMem( sizeof( *p ) );
    if (p == NULL) {
        return FALSE;
        }

    p->Handle = Handle;
    p->Type = (USHORT)Type;
    p->Inherit = InheritHandle;
    p->Name = Name;
    p->LengthOfName = (USHORT)(wcslen( Name ) * sizeof( WCHAR ));
    if (Type == HANDLE_TYPE_FILE && p->LengthOfName == (3 * sizeof( WCHAR ))) {
        p->RootDirectory = TRUE;
        }

    InsertHeadList( &Process->OpenHandleListHead, &p->Entry );

    return TRUE;
}