Ejemplo n.º 1
0
	void ThrowsExceptionFailTest
		()
	{
		unsigned long line = 0;

		try
		{
			line = __LINE__; THROWS_EXCEPTION( NonThrower(), std::exception );
			FAILED( "THROWS_EXCEPTION( \"\";, std::exception ) failed" );
		}
		catch( const TestFailure& e )
		{
			IS_EQUAL( "Failed to throw std::exception", e.Failure() );
			IS_EQUAL( line, e.Line() );
			IS_EQUAL( filename, e.File() );
		}
	}
Ejemplo n.º 2
0
	void DoesNotThrowExceptionFailTest
		()
	{
		unsigned long line = 0;

		try
		{
			line = __LINE__; DOES_NOT_THROW_EXCEPTION( Thrower< std::exception >() );
			FAILED( "DOES_NOT_THROW_EXCEPTION( throw std::bad_alloc(); ) failed" );
		}
		catch( const TestFailure& e )
		{
			IS_EQUAL( "Exception Thrown", e.Failure() );
			IS_EQUAL( line, e.Line() );
			IS_EQUAL( filename, e.File() );
		}
	}
Ejemplo n.º 3
0
	void ThrowsExceptionWrongExceptionTest
		()
	{
		unsigned long line = 0;

		try
		{
			line = __LINE__; THROWS_EXCEPTION( Thrower< std::exception >(), std::bad_alloc );
			FAILED( "THROWS_EXCEPTION( Thrower< std::exception >(), std::bad_alloc ) failed" );
		}
		catch( const TestFailure& e )
		{
			IS_EQUAL( "Threw wrong exception: not std::bad_alloc", e.Failure() );
			IS_EQUAL( line, e.Line() );
			IS_EQUAL( filename, e.File() );
		}
	}
Ejemplo n.º 4
0
void IS_EQUAL(
    const std::vector<arma::Col<arma::uword>>& actual,
    const std::vector<arma::Col<arma::uword>>& expected) {
  REQUIRE(actual.size() == expected.size());

  for (arma::uword n = 0; n < actual.size(); ++n) {
    IS_EQUAL(actual.at(n), expected.at(n));
  }
}
Ejemplo n.º 5
0
_boolean_t
Object::IsEqualZinClassName
(
    const Object & object1,
    const Object & object2
)
{
    return IS_EQUAL(typeid(object1), typeid(object2));
}
Ejemplo n.º 6
0
void KSceneEditorRiver::OnEnKillfocusEditDepth()
{
	if(!m_lpRiverMgr)
		return;
	UpdateData(TRUE);
	IS_EQUAL(m_nLastRiverDepth,m_nRiverDepth);
	m_nLastRiverDepth = m_nRiverDepth;
	m_lpRiverMgr->SetCurrentRiverDepth((float)m_nRiverDepth);
	
}
Ejemplo n.º 7
0
/**
 * gst_video_colorimetry_matches:
 * @cinfo: a #GstVideoInfo
 * @color: a colorimetry string
 *
 * Check if the colorimetry information in @info matches that of the
 * string @color.
 *
 * Returns: #TRUE if @color conveys the same colorimetry info as the color
 * information in @info.
 */
gboolean
gst_video_colorimetry_matches (GstVideoColorimetry * cinfo, const gchar * color)
{
  const ColorimetryInfo *ci;

  if ((ci = gst_video_get_colorimetry (color)))
    return IS_EQUAL (ci, cinfo);

  return FALSE;
}
Ejemplo n.º 8
0
void KSceneEditorRiver::OnNMReleasedcaptureSliderK(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: Add your control notification handler code here
	*pResult = 0;
	
	if (!m_lpRiverMgr)
		return;
	IS_EQUAL(m_nLastModulusK,m_nModulusK);
	m_nLastModulusK = m_nModulusK;
	float K = m_nModulusK * 0.1f;
	m_lpRiverMgr->SetCurSerModulusK(K);
	//m_lpRiverMgr->RefreshCurrentRoad();	
}
Ejemplo n.º 9
0
void IS_EQUAL(
    const std::vector<std::pair<arma::Col<double>, double>>& actual,
    const std::vector<std::pair<arma::Col<double>, double>>& expected) {
  REQUIRE(actual.size() == expected.size());

  for (arma::uword n = 0; n < actual.size(); ++n) {
    const std::pair<arma::Col<double>, double> actualSample = actual.at(n);
    const std::pair<arma::Col<double>, double> expectedSample = actual.at(n);

    IS_EQUAL(actualSample.first, expectedSample.first);
    CHECK(actualSample.second == Approx(expectedSample.second));
  }
}
Ejemplo n.º 10
0
void KSceneEditorRiver::OnEnKillfocusEditWidth()
{
	if(!m_lpRiverMgr)
		return;
	UpdateData(TRUE);
	if(m_nRiverWidth > 50000)
	{
		m_nRiverWidth = 50000;
		UpdateData(FALSE);
	}
	IS_EQUAL(m_nLastRiverWidth,m_nRiverWidth);
	m_nLastRiverWidth = m_nRiverWidth;
	m_lpRiverMgr->SetCurSerWidth((float)m_nRiverWidth);
}
Ejemplo n.º 11
0
int main(int argc, char* argv[]) {
  if (argc < 2) {
    fprintf(stderr, "Too few arguments. "
            "please run \"benchmark help\" for help.\n");
    exit(1);
  }
  if (IS_EQUAL(argv[1], "help")) {
    show_help();
    exit(0);
  }
  benchmark_t *bm = benchmarks;
  while (bm->func != 0) {
    if (IS_EQUAL(argv[1], bm->name)) {
      rdtsc();
      bm->func();
      exit(0);
    }
    bm++;
  }
  fprintf(stderr, "No such benchmark. "
          "please run \"benchmark help\" for help.\n");
  exit(1);
  return 0;
}
Ejemplo n.º 12
0
/**
 * Prueft ob der Strahl ray die Ebene, welche durch das Dreieck
 * triangle definiert ist, schneidet.
 * @param ray Zu testender Strahl
 * @param triangle Dreieck das die Ebene beschreibt
 * @param result Ergebnisvektor: Schneidet der Strahl die Ebene
 * liegt das Ergebnis in result vor
 * @pre result Muss auf ein existierendes Vektor-Objekt zeigen
 */
bool Triangle::rayIntersectsPlane(const Ray &ray,
                                  const Triangle &triangle,
                                  Vector3D *result) const
{
    bool bResult = false;

    // Zwei Seiten des Dreieck fuer die Normalenvektorberechnung
    Vector3D ab(triangle[1] - triangle[0]);
    Vector3D ac(triangle[2] - triangle[0]);
    // Normalenvektor der Ebene, Kreuzprodukt ab x ac
    Vector3D n(ab.crossProduct(ac));
    // Konstante aus der Ebenengleichung in Normalform
    // e: n * (x,y,z) + c = 0
    VTYPE c = n * triangle.A();

    // Ortsvektor des Strahls
    Vector3D o(ray.point);
    // Richtungsvektor des Strahls
    Vector3D d(ray.dir);

    // Geradenparameter t erhaelt man durch Einsetzen der
    // Geradengleichung in die Ebenengleichung(Normalform)
    VTYPE t_denominator = n[0]*d[0] + n[1]*d[1] + n[2]*d[2];

    // Der Nenner muss gueltig(!=0) sein
    if (!IS_EQUAL(t_denominator, 0))
    {
        // Minuszeichen extrahiert, um Gleitkommazahlenungenauigkeit durch
        // Subtraktionen zu verhinden
        VTYPE t_numerator = n[0]*o[0] + n[1]*o[1] + n[2]*o[2] - c;
        VTYPE t = t_numerator / t_denominator;

        // Das extrahierte Minuszeichen wird hier durch Umkehren des
        // > Operators beruecksichtigt. Statt t>=0, also -t<=0.
        // Da jedoch bei rekursivem Raytracing die Strahlen ihren Ursprung auf Objekt-
        // oberflachen haben, muss t != 0 sein, da ansonsten sofort wieder ein
        // Schnittpunkt im Strahlenursprung festgestellt werden wuerde.
        if (IS_SMALLER(t,0)) // Ebene darf nicht hinter dem Strahl liegen
        {
            // Schnittpunkt durch Einsetzen von t in Geradengleichung
            // Auch hier muss wieder das extrahierte Minuszeichen beachtet werden
            *result = o + d * -t;
            bResult = true;
        }
    }

    return bResult;
}
Ejemplo n.º 13
0
/**
 * gst_video_colorimetry_to_string:
 * @cinfo: a #GstVideoColorimetry
 *
 * Make a string representation of @cinfo.
 *
 * Returns: a string representation of @cinfo.
 */
gchar *
gst_video_colorimetry_to_string (GstVideoColorimetry * cinfo)
{
  gint i;

  for (i = 0; colorimetry[i].name; i++) {
    if (IS_EQUAL (&colorimetry[i], cinfo)) {
      return g_strdup (colorimetry[i].name);
    }
  }
  if (!IS_UNKNOWN (cinfo)) {
    return g_strdup_printf ("%d:%d:%d:%d", cinfo->range, cinfo->matrix,
        cinfo->transfer, cinfo->primaries);
  }
  return NULL;
}
Ejemplo n.º 14
0
static
int define_level(dsets_t *pfi, int nlev)
{
  int zaxisID = -1;
  int nz;

  nz = pfi->dnum[2];

  if ( nz )
    {
      double *zvals = NULL;

      zvals = (double*) malloc(nz*sizeof(double));

      get_dim_vals(pfi, zvals, nz, 2);

      if ( nz == 1 && IS_EQUAL(zvals[0], 0) )
	zaxisID = zaxisCreate(ZAXIS_SURFACE, nz);
      else
	{
	  if ( nlev > 0 && nlev < nz ) nz = nlev;
	  if ( pfi->zrflg ) rev_vals(zvals, nz);
	  zaxisID = zaxisCreate(ZAXIS_GENERIC, nz);
	}
      zaxisDefLevels(zaxisID, zvals);

      free(zvals);
    }
  else
    {
      double level = 0;
      nz = 1;

      zaxisID = zaxisCreate(ZAXIS_SURFACE, nz);
      zaxisDefLevels(zaxisID, &level);
    }

  return (zaxisID);
}
Ejemplo n.º 15
0
/*
 * interface, not static 
 */
void init_filter_tree(int argc) {
  char * exp;
  int exp_num = 0;
  
  init_op_stack(argc);


  filter_list_size = argc;
  filter_list_len = 0;
  filter_list = (Filter **)(malloc(sizeof(Filter) * argc));

  while((exp = get_exp()) != NULL) {
    exp_num++;
    char * optarg;
    //all the exps
    if (IS_EQUAL(exp, "-name")) {
      optarg = _get_arg("-name");
      init_fnmatch(optarg, true);
    } else if (IS_EQUAL(exp, "-iname")) {
      optarg = _get_arg("-iname");
      init_fnmatch(optarg, false);
    } else if (IS_EQUAL(exp, "-user")) {
      optarg = _get_arg("-user");
      init_user(optarg);
    } else if (IS_EQUAL(exp, "-group")) {
      optarg = _get_arg("-group");
      init_group(optarg);
    } else if (IS_EQUAL(exp, "-perm")) {
      optarg = _get_arg("-perm");
      init_perm(optarg);
    } else if (IS_EQUAL(exp, "-regex")) {
      optarg = _get_arg("-regex");
      init_reg(optarg);
    } else if (IS_EQUAL(exp, "-amin")) {
      optarg = _get_arg("-amin");
      init_time(AMIN, optarg);
    } else if (IS_EQUAL(exp, "-atime")) {
      optarg = _get_arg("-atime");
      init_time(ATIME, optarg);
    } else if (IS_EQUAL(exp, "-anewer")) {
      optarg = _get_arg("-anewer");
      init_time(ANEWER, optarg);
    } else if (IS_EQUAL(exp, "-cnewer")) {
      optarg = _get_arg("-cnewer");
      init_time(CNEWER, optarg);
    } else if (IS_EQUAL(exp, "-cmin")) {
      optarg = _get_arg("-cmin");
      init_time(CMIN, optarg);
    } else if (IS_EQUAL(exp, "-ctime")) {
      optarg = _get_arg("-ctime");
      init_time(CTIME, optarg);
    } else if (IS_EQUAL(exp, "-mtime")) {
      optarg = _get_arg("-mtime");
      init_time(MMIN, optarg);
    } else if (IS_EQUAL(exp, "-mnewer")) {
      optarg = _get_arg("-mnewer");
      init_time(MNEWER, optarg);
    } else if (IS_EQUAL(exp, "-type")) {
      optarg = _get_arg("-type");
      init_filetype(optarg);
    } else if (IS_EQUAL(exp, "-size")) {
      optarg = _get_arg("-size");
      init_filesize(optarg);
    } else if (IS_EQUAL(exp, "-not")) {
#ifdef DEBUG
      fprintf(stderr, "filter not adapter\n");
#endif
      filter_not();
    } else if (IS_EQUAL(exp, "-and")) {
#ifdef DEBUG
      fprintf(stderr, "filter and\n");
#endif
      filter_and();
    } else if (IS_EQUAL(exp, "-or")) {
#ifdef DEBUG
      fprintf(stderr, "filter or\n");
#endif
      filter_or();
    } else {
      //TODO
    }
  }
  if (exp_num == 0) {
    init_true(); 
  }
  filter_tree.passed = op_stack[0];
  free_op_stack();
}
Ejemplo n.º 16
0
/*
***************************************************************************
** Converts a compound rate from one frequency to another.
** Can also convert between ACT-style day count conventions.
***************************************************************************
*/
int JpmcdsConvertCompoundRate 
(double  inRate,
 double  inBasis,
 long    inDayCountConv,
 double  outBasis,
 long    outDayCountConv,
 double *outRate)
{
    static char routine[] = "JpmcdsConvertCompoundRate";
    int         status    = FAILURE;

    double      ccRate;

    /* this routine is a hotspot and was taking too long for the case where we
       do nothing */

    if (IS_EQUAL(inBasis,outBasis))
    {
        if (inDayCountConv == outDayCountConv)
        {
            *outRate = inRate;
        }
        else if (inDayCountConv == JPMCDS_ACT_365F && outDayCountConv == JPMCDS_ACT_360)
        {
            *outRate = inRate * 360.0/365.0;
        }
        else if (inDayCountConv == JPMCDS_ACT_360 && outDayCountConv == JPMCDS_ACT_365F)
        {
            *outRate = inRate * 365.0/360.0;
        }
        else
        {
            JpmcdsErrMsg ("%s: Can only convert between ACT/360 and ACT/365F day count "
                       "conventions\n", routine);
            goto done;
        }
    }
    else
    {
        double dayFactor;

        if (inDayCountConv == outDayCountConv)
        {
            dayFactor = 1.0;
        }
        else if (inDayCountConv == JPMCDS_ACT_365F && outDayCountConv == JPMCDS_ACT_360)
        {
            dayFactor = 360.0/365.0;
        }
        else if (inDayCountConv == JPMCDS_ACT_360 && outDayCountConv == JPMCDS_ACT_365F)
        {
            dayFactor = 365.0/360.0;
        }
        else
        {
            JpmcdsErrMsg ("%s: Can only convert between ACT/360 and ACT/365F day count "
                       "conventions\n", routine);
            goto done;
        }

        /* convert inRate to ccRate, then convert to outRate */
        if (IS_EQUAL(inBasis, JPMCDS_CONTINUOUS_BASIS))
        {
            ccRate = inRate * dayFactor;
        }
        else if (inBasis >= 1.0 && inBasis <= 365.0)
        {
            ccRate = dayFactor * inBasis * log (1.0 + inRate / inBasis);
        }
        else
        {
            JpmcdsErrMsg ("%s: Input basis %f is not a compounding frequency\n",
                     routine, inBasis);
            goto done;
        }

        if (IS_EQUAL(outBasis, JPMCDS_CONTINUOUS_BASIS))
        {
            *outRate = ccRate;
        }
        else if (outBasis >= 1.0 && outBasis <= 365.0)
        {
            *outRate = outBasis * (exp (ccRate/outBasis) - 1.0);
        }
        else
        {
            JpmcdsErrMsg ("%s: Output basis %f is not a compounding frequency\n",
                     routine, outBasis);
            goto done;
        }
    }
    status = SUCCESS;

 done:

    if (status != SUCCESS)
        JpmcdsErrMsgFailure (routine);

    return status;
}
Ejemplo n.º 17
0
/*
 * RFC 3261            SIP: Session Initiation Protocol           June 2002
 * 19.1.4 URI Comparison

   Some operations in this specification require determining whether two
   SIP or SIPS URIs are equivalent.  In this specification, registrars
   need to compare bindings in Contact URIs in REGISTER requests (see
   Section 10.3.).  SIP and SIPS URIs are compared for equality
   according to the following rules:
*/
int belle_sip_uri_equals(const belle_sip_uri_t* uri_a,const belle_sip_uri_t* uri_b) {
	const belle_sip_list_t *	params;
	const char* b_param;
	const char* a_param;
/*
      o  A SIP and SIPS URI are never equivalent.
*/
	if (belle_sip_uri_is_secure(uri_a)!=belle_sip_uri_is_secure(uri_b)) {
		return 0;
	}
/*
	o  Comparison of the userinfo of SIP and SIPS URIs is case-
         sensitive.  This includes userinfo containing passwords or
         formatted as telephone-subscribers.  Comparison of all other
         components of the URI is case-insensitive unless explicitly
         defined otherwise.
*/
	if (uri_a->user && uri_b->user) {
		if (IS_EQUAL(uri_a->user,uri_b->user)) return 0;
	} else if (uri_a->user != uri_a->user) {
		return 0;
	}
/*
      o  The ordering of parameters and header fields is not significant
         in comparing SIP and SIPS URIs.

      o  Characters other than those in the "reserved" set (see RFC 2396
         [5]) are equivalent to their ""%" HEX HEX" encoding.

      o  An IP address that is the result of a DNS lookup of a host name
         does not match that host name.

      o  For two URIs to be equal, the user, password, host, and port
         components must match.
*/
		if (!uri_a->host || !uri_b->host) {
			return 0;
		} else if  (IS_EQUAL_CASE(uri_a->host,uri_b->host)) {
			return 0;
		}
		if (uri_a->port !=uri_b->port) return 0;
/*
         A URI omitting the user component will not match a URI that
         includes one.  A URI omitting the password component will not
         match a URI that includes one.

         A URI omitting any component with a default value will not
         match a URI explicitly containing that component with its
         default value.  For instance, a URI omitting the optional port
         component will not match a URI explicitly declaring port 5060.
         The same is true for the transport-parameter, ttl-parameter,
         user-parameter, and method components.

            Defining sip:user@host to not be equivalent to
            sip:user@host:5060 is a change from RFC 2543.  When deriving
            addresses from URIs, equivalent addresses are expected from
            equivalent URIs.  The URI sip:user@host:5060 will always
            resolve to port 5060.  The URI sip:user@host may resolve to
            other ports through the DNS SRV mechanisms detailed in [4].

      o  URI uri-parameter components are compared as follows:

         -  Any uri-parameter appearing in both URIs must match.
*/
/*
 *         -  A user, ttl, or method uri-parameter appearing in only one
            URI never matches, even if it contains the default value.
           -  A URI that includes an maddr parameter will not match a URI
            that contains no maddr parameter.
 * */
		PARAM_CASE_CMP(uri_a,uri_b,"transport")
		PARAM_CASE_CMP(uri_a,uri_b,"user")
		PARAM_CASE_CMP(uri_a,uri_b,"ttl")
		PARAM_CASE_CMP(uri_a,uri_b,"method")
		PARAM_CASE_CMP(uri_a,uri_b,"maddr")


		for(params=belle_sip_parameters_get_parameters((belle_sip_parameters_t*) uri_a);params!=NULL;params=params->next) {
			if ((b_param=belle_sip_parameters_get_parameter((belle_sip_parameters_t*) uri_b,(const char*)params->data)) !=NULL) {
				if (IS_EQUAL_CASE(b_param,(const char*)params->data)) return 0;
			}

		}

 /*


         -  All other uri-parameters appearing in only one URI are
            ignored when comparing the URIs.
*/
/* *fixme ignored for now*/
/*
      o  URI header components are never ignored.  Any present header
         component MUST be present in both URIs and match for the URIs
         to match.  The matching rules are defined for each header field
         in Section 20.
 */
	return 1;
}
Ejemplo n.º 18
0
static bool upgrade_v2_to_v3_check_subkeylist(struct db_context *db,
					      const char *key,
					      const char *subkey)
{
	static uint32_t zero = 0;
	static TDB_DATA empty_subkey_list = {
		.dptr = (unsigned char*)&zero,
		.dsize = sizeof(uint32_t),
	};
	bool success = false;
	char *path = talloc_asprintf(talloc_tos(), "%s\\%s", key, subkey);
	strupper_m(path);

	if (!dbwrap_exists(db, string_term_tdb_data(path))) {
		NTSTATUS status;

		DEBUG(10, ("regdb_upgrade_v2_to_v3: writing subkey list [%s]\n",
			   path));

		status = dbwrap_store_bystring(db, path, empty_subkey_list,
					       TDB_INSERT);
		if (!NT_STATUS_IS_OK(status)) {
			DEBUG(0, ("regdb_upgrade_v2_to_v3: writing subkey list "
				  "[%s] failed\n", path));
			goto done;
		}
	}
	success = true;
done:
	talloc_free(path);
	return success;
}

static bool upgrade_v2_to_v3_check_parent(struct db_context *db,
					  const char *key)
{
	const char *sep = strrchr_m(key, '\\');
	if (sep != NULL) {
		char *pkey = talloc_strndup(talloc_tos(), key, sep-key);
		if (!dbwrap_exists(db, string_term_tdb_data(pkey))) {
			DEBUG(0, ("regdb_upgrade_v2_to_v3: missing subkey list "
				  "[%s]\nrun \"net registry check\"\n", pkey));
		}
		talloc_free(pkey);
	}
	return true;
}


#define IS_EQUAL(d,s) (((d).dsize == strlen(s)+1) &&	\
		       (strcmp((char*)(d).dptr, (s)) == 0))
#define STARTS_WITH(d,s) (((d).dsize > strlen(s)) &&			\
			  (strncmp((char*)(d).dptr, (s), strlen(s)) == 0))
#define SSTR(d) (int)(d).dsize , (char*)(d).dptr


static int regdb_upgrade_v2_to_v3_fn(struct db_record *rec, void *private_data)
{
	struct db_context *db = (struct db_context *)private_data;
	TDB_DATA key = dbwrap_record_get_key(rec);
	TDB_DATA val = dbwrap_record_get_value(rec);

	if (tdb_data_is_empty(key)) {
		return 0;
	}

	if (db == NULL) {
		DEBUG(0, ("regdb_upgrade_v2_to_v3_fn: ERROR: "
			  "NULL db context handed in via private_data\n"));
		return 1;
	}

	if (IS_EQUAL(key, REGDB_VERSION_KEYNAME) ||
	    STARTS_WITH(key, REG_VALUE_PREFIX) ||
	    STARTS_WITH(key, REG_SECDESC_PREFIX))
	{
		DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping [%.*s]\n",
			   SSTR(key)));
		return 0;
	}

	if (STARTS_WITH(key, REG_SORTED_SUBKEYS_PREFIX)) {
		NTSTATUS status;
		/* Delete the deprecated sorted subkeys cache. */

		DEBUG(10, ("regdb_upgrade_v2_to_v3: deleting [%.*s]\n",
			   SSTR(key)));

		status = dbwrap_record_delete(rec);
		if (!NT_STATUS_IS_OK(status)) {
			DEBUG(0, ("regdb_upgrade_v2_to_v3: deleting [%.*s] "
				  "failed!\n", SSTR(key)));
			return 1;
		}

		return 0;
	}

	if ( tdb_data_is_cstr(key) &&
	     hive_info((char*)key.dptr) != NULL )
	{
		/*
		 * Found a regular subkey list record.
		 * Walk the list and create the list record for those
		 * subkeys that don't already have one.
		 */
		TDB_DATA pos = val;
		char *subkey, *path = (char*)key.dptr;
		uint32_t num_items, found_items = 0;


		DEBUG(10, ("regdb_upgrade_v2_to_v3: scanning subkeylist of "
			   "[%s]\n", path));

		if (!tdb_data_read_uint32(&pos, &num_items)) {
			/* invalid or empty - skip */
			return 0;
		}

		while (tdb_data_read_cstr(&pos, &subkey)) {
			found_items++;

			if (!upgrade_v2_to_v3_check_subkeylist(db, path, subkey))
			{
				return 1;
			}

			if (!upgrade_v2_to_v3_check_parent(db, path)) {
				return 1;
			}
		}
		if (found_items != num_items) {
			DEBUG(0, ("regdb_upgrade_v2_to_v3: inconsistent subkey "
				  "list [%s]\nrun \"net registry check\"\n",
				  path));
		}
	} else {
		DEBUG(10, ("regdb_upgrade_v2_to_v3: skipping invalid [%.*s]\n"
			   "run \"net registry check\"\n", SSTR(key)));
	}

	return 0;
}

static WERROR regdb_upgrade_v2_to_v3(struct db_context *db)
{
	NTSTATUS status;
	WERROR werr;

	status = dbwrap_traverse(db, regdb_upgrade_v2_to_v3_fn, db, NULL);
	if (!NT_STATUS_IS_OK(status)) {
		werr = WERR_REG_IO_FAILURE;
		goto done;
	}

	werr = regdb_store_regdb_version(db, REGDB_VERSION_V3);

done:
	return werr;
}
Ejemplo n.º 19
0
Archivo: Merge.c Proyecto: AZed/cdo
static
void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
{
  char vname1[CDI_MAX_NAME], vname2[CDI_MAX_NAME];
  int k;
  int gridID1, gridID2;
  int zaxisID1, zaxisID2;
  int varID1, varID2;
  int param1, param2;
  int ztype1, ztype2;
  int gtype1, gtype2;
  int nlev1,  nlev2;
  int gsize1, gsize2;
  int mlev1 = 0, mlev2 = 0;
  double *lev1 = NULL, *lev2 = NULL;

  int nvars1 = vlistNvars(vlistID1);
  int nvars2 = vlistNvars(vlistID2);

  for ( varID1 = 0; varID1 < nvars1; ++varID1 )
    {
      vlistInqVarName(vlistID1, varID1, vname1);
      param1   = vlistInqVarParam(vlistID1, varID1);
      gridID1  = vlistInqVarGrid(vlistID1, varID1);
      zaxisID1 = vlistInqVarZaxis(vlistID1, varID1);
      gtype1   = gridInqType(gridID1);
      gsize1   = gridInqSize(gridID1);
      ztype1   = zaxisInqType(zaxisID1);
      nlev1    = zaxisInqSize(zaxisID1);
      if ( nlev1 > mlev1 )
	{
	  mlev1 = nlev1;
	  lev1 = (double*) realloc(lev1, mlev1*sizeof(double));
	}
      zaxisInqLevels(zaxisID1, lev1);

      for ( varID2 = 0; varID2 < nvars2; ++varID2 )
	{
	  vlistInqVarName(vlistID2, varID2, vname2);
	  param2   = vlistInqVarParam(vlistID2, varID2);
	  gridID2  = vlistInqVarGrid(vlistID2, varID2);
	  zaxisID2 = vlistInqVarZaxis(vlistID2, varID2);
	  gtype2   = gridInqType(gridID2);
	  gsize2   = gridInqSize(gridID2);
	  ztype2   = zaxisInqType(zaxisID2);
	  nlev2    = zaxisInqSize(zaxisID2);
	  if ( gtype1 == gtype2 && gsize1 == gsize2 && ztype1 == ztype2 && nlev1 == nlev2 )
	    {
	      if ( nlev2 > mlev2 )
		{
		  mlev2 = nlev2;
		  lev2 = (double*) realloc(lev2, mlev2*sizeof(double));
		}
	      zaxisInqLevels(zaxisID2, lev2);

	      for ( k = 0; k < nlev2; ++k )
		if ( !IS_EQUAL(lev1[k], lev2[k]) ) break;

	      if ( k == nlev2 )
		{
		  if ( param1 < 0 || param2 < 0 )
		    {
		      if ( strcmp(vname1, vname2) == 0 )
			{
			  cdoWarning("Duplicate entry of parameter %s in %s!", vname2, filename);
			}
		    }
		  else
		    {
		      if ( param1 == param2 )
			{
			  char paramstr[32];
			  cdiParamToString(param2, paramstr, sizeof(paramstr));
			  cdoWarning("Duplicate entry of parameter %s in %s!", paramstr, filename);
			}
		    }
		}
	    }
	}
    }

  if ( lev1 ) free(lev1);
  if ( lev2 ) free(lev2);
}