コード例 #1
0
ファイル: query.c プロジェクト: chombourger/xCOM
xc_result_t
query_get_candidates (
   query_t *queryPtr,
   unsigned int *matchCountPtr
) {
   struct ProvidedPortsList *listPtr;
   port_t *providerPtr;
   import_t *importPtr;
   unsigned int count = 0;
   xc_result_t result = XC_OK;

   TRACE3 (("called"));
   assert (queryPtr != NULL);

   /* Get all the providers of the queried interface. */
   listPtr = provided_ports_ref (queryPtr->queriedInterface.name);
   if (listPtr != NULL) {
      /* Check matching providers and add them as candidates. */
      providerPtr = (port_t *) XC_CLIST_HEAD (&listPtr->ports);
      while (!XC_CLIST_END (&listPtr->ports, providerPtr)) {
         if (query_match_provider (queryPtr, providerPtr)) {
            importPtr = import_new (
               queryPtr->queryHandle,
               queryPtr->componentHandle,
               queryPtr->clientPortName,
               providerPtr
            );
            if (importPtr != NULL) {
               result = query_add_import (queryPtr, importPtr);
               if (result == XC_OK) {
                  count ++;
               }
               else {
                  TRACE1 (("failed to add import to query %u (%d)", queryPtr->queryHandle, result));
                  import_free (importPtr);
                  break;
               }
            }
            else {
               result = XC_ERR_NOMEM;
               break;
            }
         }
         providerPtr = XC_CLIST_NEXT (providerPtr);
      }
      provided_ports_unref (listPtr);
   }

   if (result == XC_OK) {
      TRACE4 (("%u providers of '%s' found!", count, queryPtr->queriedInterface.name));
      queryPtr->importPtr = queryPtr->firstImportPtr;
      assert ((count == 0) || (queryPtr->importPtr != NULL));
      if (matchCountPtr != NULL) {
         *matchCountPtr = count;
      }
   }

   TRACE3 (("exiting with result=%d", result));
   return result;
}
コード例 #2
0
ファイル: import.c プロジェクト: UNGLinux/Obase
void
cvs_import_local(struct cvs_file *cf)
{
	int isnew;
	struct stat st;
	char repo[MAXPATHLEN];

	cvs_log(LP_TRACE, "cvs_import_local(%s)", cf->file_path);

	cvs_file_classify(cf, cvs_directory_tag);

	if (cf->file_type == CVS_DIR) {
		if (!strcmp(cf->file_path, "."))
			return;

		if (verbosity > 1)
			cvs_log(LP_NOTICE, "Importing %s", cf->file_path);

		if (cvs_noexec == 1)
			return;

		if (mkdir(cf->file_rpath, 0755) == -1 && errno != EEXIST)
			fatal("cvs_import_local: %s: %s", cf->file_rpath,
			    strerror(errno));

		return;
	}

	isnew = 1;
	(void)xsnprintf(repo, sizeof(repo), "%s/%s/%s/%s%s",
	    current_cvsroot->cr_dir, cf->file_wd, CVS_PATH_ATTIC,
	    cf->file_name, RCS_FILE_EXT);

	if (cf->file_rcs != NULL || stat(repo, &st) != -1)
		isnew = 0;

	if (isnew == 1)
		import_new(cf);
	else
		import_update(cf);
}