예제 #1
0
REGERR su_UninstallProcessItem(char *component_path)
{
    int refcount;
    int err;
    char filepath[MAXREGPATHLEN];
    nsCOMPtr<nsILocalFile> nsLFPath;
    nsCOMPtr<nsIFile> nsFPath;

    err = VR_GetPath(component_path, sizeof(filepath), filepath);
    if ( err == REGERR_OK )
    {
        NS_NewNativeLocalFile(nsDependentCString(filepath), PR_TRUE, getter_AddRefs(nsLFPath));
        nsFPath = nsLFPath;
        err = VR_GetRefCount(component_path, &refcount);  
        if ( err == REGERR_OK )
        {
            --refcount;
            if (refcount > 0)
                err = VR_SetRefCount(component_path, refcount);  
            else 
            {
                err = VR_Remove(component_path);
                DeleteFileNowOrSchedule(nsFPath);
            }
        }
        else
        {
            /* delete node and file */
            err = VR_Remove(component_path);
            DeleteFileNowOrSchedule(nsFPath);
        }
    }
    return err;
}
예제 #2
0
void vFind(char *cmd)
{

	VERSION ver;
	char path[MAXREGPATHLEN];

	if (error("VR_GetVersion", VR_GetVersion(cmd, &ver)) == REGERR_OK)
	{
		if (error("VR_GetPath", VR_GetPath(cmd, sizeof(path), path)) == REGERR_OK)
		{
			printf("%s found: ver=%d.%d.%d.%d, check=0x%04x, path=%s\n", 
				cmd, ver.major, ver.minor, ver.release, ver.build, ver.check,
				path);
			return;
		}
	}

	printf("%s not found.\n", cmd);
	return;

}	// vFind
예제 #3
0
파일: VerReg.c 프로젝트: ahadzi/celtx
VR_INTERFACE(REGERR) VR_ValidateComponent(char *component_path)
{
    REGERR err;
    RKEY key;
    char path[MAXREGPATHLEN];
    HREG hreg;


#ifdef USE_CHECKSUM
    char buf[MAXREGNAMELEN];
    long calculatedCheck;
    int storedCheck;
#endif

    err = vr_Init();
    if (err != REGERR_OK)
        return err;

    err = vr_FindKey( component_path, &hreg, &key );
    if ( err != REGERR_OK )
        return err;

    err = VR_GetPath( component_path, sizeof(path), path );
    if ( err != REGERR_OK ) {
        if ( err == REGERR_NOFIND ) {
            err = REGERR_NOPATH;
        }
        return err;
    }

    {
        uint32 len;
        struct stat  statStruct;

        /* directories are stored with a trailing separator -- if we */
        /* have one of these we have to remove it for stat to work */
        len = strlen(path);
        if ( path[len-1] == VR_FILE_SEP )
            path[len-1] = 0;

        if ( stat ( path, &statStruct ) != 0 ) {
            err = REGERR_NOFILE;
        }
    }
    if (err != REGERR_OK)
        return err;


#if defined(USE_CHECKSUM) && !defined(XP_UNIX)
    err = NR_RegGetEntryString( vreg, key, CHKSTR, buf, sizeof(buf) );
    if (err != REGERR_OK)
        return err;

    storedCheck = atoi(buf);

    err = vr_GetCheck(filepath, &calculatedCheck);
    if (err != REGERR_OK)
        return err;

    if (storedCheck != calculatedCheck)
    {
        return REGERR_BADCHECK;
    }
#endif /* USE_CHECKSUM */

    return REGERR_OK;

}   /* CheckEntry */
예제 #4
0
static const char *
xfe_netcaster_path(void)

/*
 * description:
 *	Determine a path to tab.htm, which is
 *	loaded into a browser window to start
 *	Netcaster by checking
 *	the following locations in order:
 *		$HOME/.netscape/netcast/tab.htm
 *		$MOZILLA_HOME/netcast/tab.htm
 *		Version Registry via VR_GetPath()
 *		fe_GetProgramDirectory()/netcast/tab.htm
 *
 *  The reason for precedence is as follows:
 *		$HOME first. Preferences set in a user's
 *		$HOME override everything else.
 *		This allows users some chance of running in
 *		the case where the system admin won't install
 *		Netcaster in globally accessible location.
 *		This can also be useful for debugging purposes.
 *
 *		$MOZILLA_HOME is now recommended as the standard
 *		for finding Communicator and related components.
 *		It comes next.
 *
 *		The registry should get set correctly during ASD install.
 *		However the registry's role in tracking versions has
 *		been emphasized over its role in tracking location.
 *		(although you can't have the former without the latter).
 *		Rumor also has it that some people are in the habit
 *		of deleting the registry to fix problems, so it
 *		may not always be available.
 *
 *		Last resort is to do our best effort at determining
 *		where Communicator was invoked by getting the program directory
 *		by looking at the invocation path.
 *
 * returns:
 *	On success returns a path to tab.htm
 *	On failure returns NULL
 *
 ****************************************/
{
  const char * result = 0;
  char * home;
  REGERR code;

  if (!private_xfe_netcaster_path)
	{
	  private_xfe_netcaster_path = (char*)XP_ALLOC(MAXPATHLEN);
	  if (private_xfe_netcaster_path)
		private_xfe_netcaster_path[0] = '\0';
	  else
		return result;
	}

  if (private_xfe_netcaster_path[0])
	{
	  result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
		  printf("DEBUG_rodt: Netcaster path a %s\n",result);
#endif
	  return result;
	}


  //
  // CHECK $HOME/.netscape
  //
  home = getenv("HOME");
  if (home)
	{
	  XP_STRCPY(private_xfe_netcaster_path, home);
	  if (xfe_last_character(private_xfe_netcaster_path) != '/')
		XP_STRCAT(private_xfe_netcaster_path,"/");
	  XP_STRCAT(private_xfe_netcaster_path,".netscape/");
	  XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath);
	  if (xfe_path_exists(private_xfe_netcaster_path))
		{
		  result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
		  printf("DEBUG_rodt: Netcaster path b %s\n",result);
#endif
		  return result;
		}
	}


  //
  // CHECK $MOZILLA_HOME
  //
  home = getenv("MOZILLA_HOME");
  if (home)
	{
	  XP_STRCPY(private_xfe_netcaster_path, home);
	  if (xfe_last_character(private_xfe_netcaster_path) != '/')
		XP_STRCAT(private_xfe_netcaster_path,"/");
	  XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath);
	  if (xfe_path_exists(private_xfe_netcaster_path))
		{
		  result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
		  printf("DEBUG_rodt: Netcaster path c %s\n",result);
#endif
		  return result;
		}
	}

  //
  // CHECK THE REGISTRY
  //
  // Could also call VR_InRegistry("Netcaster") but it would be redundant
  // Note that VR_ValidateComponent also calls VR_GetPath() but it doesn't
  // return any path information
  //
  code = VR_GetPath(netcasterTabHtmlRegistryNode, sizeof(private_xfe_netcaster_path)-1, private_xfe_netcaster_path);
  if (code == REGERR_OK)
	{
	  code = VR_ValidateComponent(netcasterTabHtmlRegistryNode);
	  if (code == REGERR_OK
		  && xfe_path_exists(private_xfe_netcaster_path))  // extra check
		{
		  result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
		  printf("DEBUG_rodt: Netcaster path d %s\n",result);
#endif
		  return result;
		}
	}
  private_xfe_netcaster_path[0] = '\0';

  //
  // CHECK THE PROGRAM DIRECTORY
  //
  fe_GetProgramDirectory(private_xfe_netcaster_path, MAXPATHLEN - 1);
  if (private_xfe_netcaster_path[0])
	{
	  if (xfe_last_character(private_xfe_netcaster_path) != '/')
		XP_STRCAT(private_xfe_netcaster_path,"/");
	  XP_STRCAT(private_xfe_netcaster_path,netcasterTabHtmlPath);
	  if (xfe_path_exists(private_xfe_netcaster_path))
		{
		  result = private_xfe_netcaster_path;
#ifdef DEBUG_rodt
		  printf("DEBUG_rodt: Netcaster path e %s\n",result);
#endif
		  return result;
		}
	}

  private_xfe_netcaster_path[0] = '\0';
#ifdef DEBUG_rodt
  printf("DEBUG_rodt: Netcaster path not found\n");
#endif
  return result;
}