示例#1
0
	FILETIME ArchiveSequence::const_input_iterator::mtime() const
	{
		return get_prop(kpidMTime).as_time();
	}
示例#2
0
	uint64_t ArchiveSequence::const_input_iterator::size() const
	{
		return get_prop(kpidSize).as_uint();
	}
示例#3
0
	size_t ArchiveSequence::const_input_iterator::attr() const
	{
		return get_prop(kpidAttrib).as_uint();
	}
示例#4
0
static void
output_prop (int prop_handle)
{
    char buffer[16];
    enum prop_type_t temp_type = get_prop (prop_handle)->type;

    buffer[0] = 't';
    buffer[1] = 't';

    if (is_handled_sgf (temp_type) && temp_type != PROP_COMMENT)
    {
        if (temp_type != last_output_type)
        {
            write_file (sgf_fd, prop_names[temp_type],
                        PROP_NAME_LEN (temp_type));
        }

        write_char (sgf_fd, '[');

        if (temp_type == PROP_HANDICAP)
        {
            rb->snprintf (buffer, sizeof (buffer), "%d",
                          get_prop (prop_handle)->data.number);
            write_file (sgf_fd, buffer, rb->strlen (buffer));
        }
        else if (temp_type == PROP_LABEL)
        {
            pos_to_sgf (get_prop (prop_handle)->data.position, buffer);
            buffer[2] = '\0';

            rb->snprintf (&buffer[2], sizeof (buffer) - 2, ":%c",
                          get_prop (prop_handle)->data.label_extra);

            write_file (sgf_fd, buffer, rb->strlen (buffer));
        }
        else
        {
            pos_to_sgf (get_prop (prop_handle)->data.position, buffer);

            write_file (sgf_fd, buffer, 2);
        }

        write_char (sgf_fd, ']');
    }
    else if (temp_type == PROP_ROOT_PROPS)
    {
        output_header_props ();
    }
    else if (temp_type == PROP_GENERIC_UNHANDLED || temp_type == PROP_COMMENT)
    {
        bool escaped = false;
        bool in_prop_value = false;
        int temp;
        bool done = false;

        rb->lseek (unhandled_fd, get_prop (prop_handle)->data.number,
                   SEEK_SET);

        while (!done)
        {
            temp = peek_char (unhandled_fd);

            switch (temp)
            {
            case ';':
                escaped = false;
                if (in_prop_value)
                {
                    break;
                }
                /* otherwise, fall through */
            case -1:
                done = true;
                break;

            case '\\':
                escaped = !escaped;
                break;

            case '[':
                escaped = false;
                in_prop_value = true;
                break;

            case ']':
                if (!escaped)
                {
                    in_prop_value = false;
                }
                escaped = false;
                break;

            default:
                escaped = false;
                break;
            };

            if (!done)
            {
                write_char (sgf_fd, temp);
                read_char (unhandled_fd);
            }
        }
    }

    last_output_type = temp_type;
}
示例#5
0
	ustring ArchiveSequence::const_input_iterator::path() const
	{
		return get_prop(kpidPath).as_str();
	}
示例#6
0
/*
 * Determine whether the interface was configured manually.
 */
static boolean_t
manual_if_init(void)
{
	boolean_t	ret = B_FALSE;
	char		*ncs;
	char		*devpath;
	di_node_t	node;
	int		instance;
	char		*drvname;
	char		ifname[IFNAMSIZ + 1];

	/*
	 * If net-config-strategy isn't "manual", don't go any further.
	 */
	if ((ncs = get_prop("chosen", BI_NET_CONFIG_STRATEGY, NULL)) == NULL ||
	    strcmp(ncs, "manual") != 0) {
		return (B_FALSE);
	}

	/*
	 * First check the 'bootpath' property of /chosen to see whether
	 * it specifies the path of a network device; if so, use this.
	 */
	if ((devpath = get_bootpath()) == NULL ||
	    (node = path2node(devpath)) == DI_NODE_NIL ||
	    !is_network_device(node)) {
		/*
		 * Must have been booted from CD-ROM or disk; attempt to
		 * use the path defined by the 'net' property of /aliases.
		 */
		free(devpath);
		if ((devpath = get_netalias()) == NULL ||
		    (node = path2node(devpath)) == DI_NODE_NIL ||
		    !is_network_device(node)) {
			goto cleanup;
		}
	}

	/*
	 * Get the driver name and instance number of this node.
	 * We may have to load the driver.
	 */
	if ((drvname = di_driver_name(node)) == NULL) {
		goto cleanup;
	}
	if ((instance = di_instance(node)) == -1) {
		di_node_t	tmp;

		/*
		 * Attempt to load the driver, create a new snapshot of the
		 * (possibly changed) device tree and re-compute our node.
		 */
		if ((tmp = di_init_driver(drvname, 0)) != DI_NODE_NIL) {
			di_fini(tmp);

			if (!snapshot_devtree() ||
			    (node = path2node(devpath)) == DI_NODE_NIL) {
				goto cleanup;
			}
		}
		instance = di_instance(node);
	}

	/*
	 * Construct the interface name.
	 */
	if (instance == -1) {
		(void) snprintf(ifname, sizeof (ifname),
		    "%s", di_driver_name(node));
	} else {
		(void) snprintf(ifname, sizeof (ifname),
		    "%s%d", di_driver_name(node), instance);
	}

	ret = netif_init(ifname, "manual");
cleanup:
	free(devpath);
	return (ret);
}
示例#7
0
static int get_tol(struct cmd_struct *cmd, struct arg_struct *arg)
{
	return get_prop(arg, TIPC_NLA_PROP_TOL);
}
示例#8
0
文件: merge.c 项目: vocho/openqnx
/* Detranslate a working copy file MERGE_TARGET to achieve the effect of:

   1. Detranslate
   2. Install new props
   3. Retranslate
   4. Detranslate

   in 1 pass to get a file which can be compared with the left and right
   files which were created with the 'new props' above.

   Property changes make this a little complex though. Changes in

   - svn:mime-type
   - svn:eol-style
   - svn:keywords
   - svn:special

   may change the way a file is translated.

   Effect for svn:mime-type:

     The value for svn:mime-type affects the translation wrt keywords
     and eol-style settings.

   I) both old and new mime-types are texty
      -> just do the translation dance (as lined out below)

   II) the old one is texty, the new one is binary
      -> detranslate with the old eol-style and keywords
         (the new re+detranslation is a no-op)

   III) the old one is binary, the new one texty
      -> detranslate with the new eol-style
         (the old detranslation is a no-op)

   IV) the old and new ones are binary
      -> don't detranslate, just make a straight copy


   Effect for svn:eol-style

   I) On add or change use the new value

   II) otherwise: use the old value (absent means 'no translation')


   Effect for svn:keywords

     Always use old settings (re+detranslation are no-op)


   Effect for svn:special

     Always use the old settings (same reasons as for svn:keywords)

*/
static svn_error_t *
detranslate_wc_file(const char **detranslated_file,
                    const char *merge_target,
                    svn_wc_adm_access_t *adm_access,
                    svn_boolean_t force_copy,
                    const apr_array_header_t *prop_diff,
                    apr_pool_t *pool)
{
  svn_boolean_t is_binary;
  const svn_prop_t *prop;
  svn_subst_eol_style_t style;
  const char *eol;
  apr_hash_t *keywords;
  svn_boolean_t special;

  /* Decide if the merge target currently is a text or binary file. */
  SVN_ERR(svn_wc_has_binary_prop(&is_binary,
                                 merge_target, adm_access, pool));


  /* See if we need to do a straight copy:
     - old and new mime-types are binary, or
     - old mime-type is binary and no new mime-type specified */
  if (is_binary
      && (((prop = get_prop(prop_diff, SVN_PROP_MIME_TYPE))
           && prop->value && svn_mime_type_is_binary(prop->value->data))
          || prop == NULL))
    {
      /* this is case IV above */
      keywords = NULL;
      special = FALSE;
      eol = NULL;
      style = svn_subst_eol_style_none;
    }
  else if ((!is_binary)
           && (prop = get_prop(prop_diff, SVN_PROP_MIME_TYPE))
           && prop->value && svn_mime_type_is_binary(prop->value->data))
    {
      /* Old props indicate texty, new props indicate binary:
         detranslate keywords and old eol-style */
      SVN_ERR(svn_wc__get_keywords(&keywords, merge_target,
                                   adm_access, NULL, pool));
      SVN_ERR(svn_wc__get_special(&special, merge_target, adm_access, pool));
    }
  else
    {
      /* New props indicate texty, regardless of old props */

      /* In case the file used to be special, detranslate specially */
      SVN_ERR(svn_wc__get_special(&special, merge_target, adm_access, pool));

      if (special)
        {
          keywords = NULL;
          eol = NULL;
          style = svn_subst_eol_style_none;
        }
      else
        {
          /* In case a new eol style was set, use that for detranslation */
          if ((prop = get_prop(prop_diff, SVN_PROP_EOL_STYLE)) && prop->value)
            {
              /* Value added or changed */
              svn_subst_eol_style_from_value(&style, &eol, prop->value->data);
            }
          else if (!is_binary)
            SVN_ERR(svn_wc__get_eol_style(&style, &eol, merge_target,
                                          adm_access, pool));
          else
            {
              eol = NULL;
              style = svn_subst_eol_style_none;
            }

          /* In case there were keywords, detranslate with keywords
             (iff we were texty) */
          if (!is_binary)
            SVN_ERR(svn_wc__get_keywords(&keywords, merge_target,
                                         adm_access, NULL, pool));
          else
            keywords = NULL;
        }
    }

  /* Now, detranslate with the settings we created above */

  if (force_copy || keywords || eol || special)
    {
      const char *detranslated;
      /* Force a copy into the temporary wc area to avoid having
         temporary files created below to appear in the actual wc. */

      SVN_ERR(svn_wc_create_tmp_file2
              (NULL, &detranslated,
               svn_wc_adm_access_path(adm_access),
               svn_io_file_del_none, pool));

      SVN_ERR(svn_subst_translate_to_normal_form(merge_target,
                                                 detranslated,
                                                 style,
                                                 eol, eol ? FALSE : TRUE,
                                                 keywords,
                                                 special,
                                                 pool));
      *detranslated_file = detranslated;
    }
  else
    *detranslated_file = merge_target;

  return SVN_NO_ERROR;
}
示例#9
0
文件: merge.c 项目: vocho/openqnx
/* Internal version of svn_wc_merge, also used to (loggily) merge updates
   from the repository.

   In the case of updating, the update can have sent new properties,
   which could affect the way the wc target is detranslated and
   compared with LEFT and RIGHT for merging.

   Property changes sent by the update are provided in PROP_DIFF.

   If COPYFROM_TEXT is non-null, the working text is taken from this
   file instead of from the actual version in the working copy (and
   the merge_target is allowed to not be under version control in this
   case).
 */
svn_error_t *
svn_wc__merge_internal(svn_stringbuf_t **log_accum,
                       enum svn_wc_merge_outcome_t *merge_outcome,
                       const char *left,
                       const char *right,
                       const char *merge_target,
                       const char *copyfrom_text,
                       svn_wc_adm_access_t *adm_access,
                       const char *left_label,
                       const char *right_label,
                       const char *target_label,
                       svn_boolean_t dry_run,
                       const char *diff3_cmd,
                       const apr_array_header_t *merge_options,
                       const apr_array_header_t *prop_diff,
                       svn_wc_conflict_resolver_func_t conflict_func,
                       void *conflict_baton,
                       apr_pool_t *pool)
{
  const char *tmp_target, *result_target, *working_text;
  const char *adm_path = svn_wc_adm_access_path(adm_access);
  apr_file_t *result_f;
  svn_boolean_t is_binary = FALSE;
  const svn_wc_entry_t *entry;
  svn_boolean_t contains_conflicts;
  const svn_prop_t *mimeprop;

  /* Sanity check:  the merge target must be under revision control (unless
     this is an add-with-history). */
  SVN_ERR(svn_wc_entry(&entry, merge_target, adm_access, FALSE, pool));
  if (! entry && ! copyfrom_text)
    {
      *merge_outcome = svn_wc_merge_no_merge;
      return SVN_NO_ERROR;
    }

  /* Decide if the merge target is a text or binary file. */
  if ((mimeprop = get_prop(prop_diff, SVN_PROP_MIME_TYPE))
      && mimeprop->value)
    is_binary = svn_mime_type_is_binary(mimeprop->value->data);
  else if (! copyfrom_text)
    SVN_ERR(svn_wc_has_binary_prop(&is_binary, merge_target, adm_access, pool));

  working_text = copyfrom_text ? copyfrom_text : merge_target;
  SVN_ERR(detranslate_wc_file(&tmp_target, working_text, adm_access,
                              (! is_binary) && diff3_cmd != NULL,
                              prop_diff, pool));

  /* We cannot depend on the left file to contain the same eols as the
     right file. If the merge target has mods, this will mark the entire
     file as conflicted, so we need to compensate. */
  SVN_ERR(maybe_update_target_eols(&left, left, adm_access, prop_diff, pool));

  if (! is_binary)              /* this is a text file */
    {
      /* Open a second temporary file for writing; this is where diff3
         will write the merged results. */
      SVN_ERR(svn_wc_create_tmp_file2(&result_f, &result_target,
                                      adm_path, svn_io_file_del_none,
                                      pool));

      /* Run an external merge if requested. */
      if (diff3_cmd)
        {
          int exit_code;

          SVN_ERR(svn_io_run_diff3_2(&exit_code, ".",
                                     tmp_target, left, right,
                                     target_label, left_label, right_label,
                                     result_f, diff3_cmd,
                                     merge_options, pool));

          contains_conflicts = exit_code == 1;
        }
      else
        {
          svn_diff_t *diff;
          const char *target_marker;
          const char *left_marker;
          const char *right_marker;
          svn_stream_t *ostream;
          svn_diff_file_options_t *options;

          ostream = svn_stream_from_aprfile(result_f, pool);
          options = svn_diff_file_options_create(pool);

          if (merge_options)
            SVN_ERR(svn_diff_file_options_parse(options, merge_options, pool));

          SVN_ERR(svn_diff_file_diff3_2(&diff,
                                        left, tmp_target, right,
                                        options, pool));

          /* Labels fall back to sensible defaults if not specified. */
          if (target_label)
            target_marker = apr_psprintf(pool, "<<<<<<< %s", target_label);
          else
            target_marker = "<<<<<<< .working";

          if (left_label)
            left_marker = apr_psprintf(pool, "||||||| %s", left_label);
          else
            left_marker = "||||||| .old";

          if (right_label)
            right_marker = apr_psprintf(pool, ">>>>>>> %s", right_label);
          else
            right_marker = ">>>>>>> .new";

          SVN_ERR(svn_diff_file_output_merge(ostream, diff,
                                             left, tmp_target, right,
                                             left_marker,
                                             target_marker,
                                             right_marker,
                                             "=======", /* seperator */
                                             FALSE, /* display original */
                                             FALSE, /* resolve conflicts */
                                             pool));
          SVN_ERR(svn_stream_close(ostream));

          contains_conflicts = svn_diff_contains_conflicts(diff);
        }

      /* Close the output file */
      SVN_ERR(svn_io_file_close(result_f, pool));

      if (contains_conflicts && ! dry_run)  /* got a conflict */
        {
          const char *left_copy, *right_copy, *target_copy;
          const char *tmp_left, *tmp_right, *tmp_target_copy;
          const char *parentt, *target_base;
          svn_wc_adm_access_t *parent_access;
          svn_wc_entry_t tmp_entry;

          /* Give the conflict resolution callback a chance to clean
             up the conflict before we mark the file 'conflicted' */
          if (conflict_func)
            {
              svn_wc_conflict_result_t *result = NULL;
              svn_wc_conflict_description_t cdesc;

              cdesc.path = merge_target;
              cdesc.node_kind = svn_node_file;
              cdesc.kind = svn_wc_conflict_kind_text;
              cdesc.is_binary = FALSE;
              cdesc.mime_type = (mimeprop && mimeprop->value)
                                  ? mimeprop->value->data : NULL;
              cdesc.access = adm_access;
              cdesc.action = svn_wc_conflict_action_edit;
              cdesc.reason = svn_wc_conflict_reason_edited;
              cdesc.base_file = left;
              cdesc.their_file = right;
              cdesc.my_file = tmp_target;
              cdesc.merged_file = result_target;
              cdesc.property_name = NULL;

              SVN_ERR(conflict_func(&result, &cdesc, conflict_baton, pool));
              if (result == NULL)
                return svn_error_create(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
                                        NULL, _("Conflict callback violated API:"
                                                " returned no results"));

              switch (result->choice)
                {
                  /* If the callback wants to use one of the fulltexts
                     to resolve the conflict, so be it.*/
                  case svn_wc_conflict_choose_base:
                    {
                      SVN_ERR(svn_wc__loggy_copy
                              (log_accum, NULL, adm_access,
                               svn_wc__copy_translate,
                               left, merge_target,
                               FALSE, pool));
                      *merge_outcome = svn_wc_merge_merged;
                      contains_conflicts = FALSE;
                      goto merge_complete;
                    }
                  case svn_wc_conflict_choose_theirs_full:
                    {
                      SVN_ERR(svn_wc__loggy_copy
                              (log_accum, NULL, adm_access,
                               svn_wc__copy_translate,
                               right, merge_target,
                               FALSE, pool));
                      *merge_outcome = svn_wc_merge_merged;
                      contains_conflicts = FALSE;
                      goto merge_complete;
                    }
                  case svn_wc_conflict_choose_mine_full:
                    {
                      /* Do nothing to merge_target, let it live untouched! */
                      *merge_outcome = svn_wc_merge_merged;
                      contains_conflicts = FALSE;
                      goto merge_complete;
                    }

                    /* For the case of 3-way file merging, we don't
                       really distinguish between these return values;
                       if the callback claims to have "generally
                       resolved" the situation, we still interpret
                       that as "OK, we'll assume the merged version is
                       good to use". */
                  case svn_wc_conflict_choose_merged:
                    {
                      SVN_ERR(svn_wc__loggy_copy
                              (log_accum, NULL, adm_access,
                               svn_wc__copy_translate,
                               /* Look for callback's own merged-file first: */
                               result->merged_file ?
                                  result->merged_file : result_target,
                               merge_target,
                               FALSE, pool));
                      *merge_outcome = svn_wc_merge_merged;
                      contains_conflicts = FALSE;
                      goto merge_complete;
                    }
                  case svn_wc_conflict_choose_postpone:
                  default:
                    {
                      /* Assume conflict remains, fall through to code below. */
                    }
                }
            }

          /* Preserve the three pre-merge files, and modify the
             entry (mark as conflicted, track the preserved files). */

          /* I miss Lisp. */

          SVN_ERR(svn_io_open_unique_file2(NULL,
                                           &left_copy,
                                           merge_target,
                                           left_label,
                                           svn_io_file_del_none,
                                           pool));

          /* Have I mentioned how much I miss Lisp? */

          SVN_ERR(svn_io_open_unique_file2(NULL,
                                           &right_copy,
                                           merge_target,
                                           right_label,
                                           svn_io_file_del_none,
                                           pool));

          /* Why, how much more pleasant to be forced to unroll my loops.
             If I'd been writing in Lisp, I might have mapped an inline
             lambda form over a list, or something equally disgusting.
             Thank goodness C was here to protect me! */

          SVN_ERR(svn_io_open_unique_file2(NULL,
                                           &target_copy,
                                           merge_target,
                                           target_label,
                                           svn_io_file_del_none,
                                           pool));

          /* We preserve all the files with keywords expanded and line
             endings in local (working) form. */

          svn_path_split(target_copy, &parentt, &target_base, pool);
          SVN_ERR(svn_wc_adm_retrieve(&parent_access, adm_access, parentt,
                                      pool));

          /* Log files require their paths to be in the subtree
             relative to the adm_access path they are executed in.

             Make our LEFT and RIGHT files 'local' if they aren't... */
          if (! svn_path_is_child(adm_path, left, pool))
            {
              SVN_ERR(svn_wc_create_tmp_file2
                      (NULL, &tmp_left,
                       adm_path, svn_io_file_del_none, pool));
              SVN_ERR(svn_io_copy_file(left, tmp_left, TRUE, pool));
            }
          else
            tmp_left = left;

          if (! svn_path_is_child(adm_path, right, pool))
            {
              SVN_ERR(svn_wc_create_tmp_file2
                      (NULL, &tmp_right,
                       adm_path, svn_io_file_del_none, pool));
              SVN_ERR(svn_io_copy_file(right, tmp_right, TRUE, pool));
            }
          else
            tmp_right = right;

          /* NOTE: Callers must ensure that the svn:eol-style and
             svn:keywords property values are correct in the currently
             installed props.  With 'svn merge', it's no big deal.  But
             when 'svn up' calls this routine, it needs to make sure that
             this routine is using the newest property values that may
             have been received *during* the update.  Since this routine
             will be run from within a log-command, merge_file()
             needs to make sure that a previous log-command to 'install
             latest props' has already executed first.  Ben and I just
             checked, and that is indeed the order in which the log items
             are written, so everything should be fine.  Really.  */

          /* Create LEFT and RIGHT backup files, in expanded form.
             We use merge_target's current properties to do the translation. */
          /* Derive the basenames of the 3 backup files. */
          SVN_ERR(svn_wc__loggy_translated_file(log_accum,
                                                adm_access,
                                                left_copy, tmp_left,
                                                merge_target, pool));
          SVN_ERR(svn_wc__loggy_translated_file(log_accum,
                                                adm_access,
                                                right_copy, tmp_right,
                                                merge_target, pool));

          /* Back up MERGE_TARGET through detranslation/retranslation:
             the new translation properties may not match the current ones */
          SVN_ERR(svn_wc_translated_file2(&tmp_target_copy,
                                          merge_target,
                                          merge_target,
                                          adm_access,
                                          SVN_WC_TRANSLATE_TO_NF
                                          | SVN_WC_TRANSLATE_NO_OUTPUT_CLEANUP,
                                          pool));
          SVN_ERR(svn_wc__loggy_translated_file
                  (log_accum, adm_access,
                   target_copy, tmp_target_copy, merge_target, pool));

          tmp_entry.conflict_old
            = svn_path_is_child(adm_path, left_copy, pool);
          tmp_entry.conflict_new
            = svn_path_is_child(adm_path, right_copy, pool);
          tmp_entry.conflict_wrk = target_base;

          /* Mark merge_target's entry as "Conflicted", and start tracking
             the backup files in the entry as well. */
          SVN_ERR(svn_wc__loggy_entry_modify
                  (log_accum, adm_access,
                   merge_target, &tmp_entry,
                   SVN_WC__ENTRY_MODIFY_CONFLICT_OLD
                   | SVN_WC__ENTRY_MODIFY_CONFLICT_NEW
                   | SVN_WC__ENTRY_MODIFY_CONFLICT_WRK,
                   pool));

          *merge_outcome = svn_wc_merge_conflict;
        }
      else if (contains_conflicts && dry_run)
        {
          *merge_outcome = svn_wc_merge_conflict;
        } /* end of conflict handling */
      else if (copyfrom_text)
        {
          *merge_outcome = svn_wc_merge_merged;
        }
      else
        {
          svn_boolean_t same, special;
          /* If 'special', then use the detranslated form of the
             target file.  This is so we don't try to follow symlinks,
             but the same treatment is probably also appropriate for
             whatever special file types we may invent in the future. */
          SVN_ERR(svn_wc__get_special(&special, merge_target,
                                      adm_access, pool));
          SVN_ERR(svn_io_files_contents_same_p(&same, result_target,
                                               (special ?
                                                  tmp_target : 
                                                  merge_target),
                                               pool));

          *merge_outcome = same ? svn_wc_merge_unchanged : svn_wc_merge_merged;
        }

      if (*merge_outcome != svn_wc_merge_unchanged && ! dry_run)
        /* replace MERGE_TARGET with the new merged file, expanding. */
        SVN_ERR(svn_wc__loggy_copy(log_accum, NULL,
                                   adm_access,
                                   svn_wc__copy_translate,
                                   result_target, merge_target,
                                   FALSE, pool));

    } /* end of merging for text files */

  else if (! dry_run) /* merging procedure for binary files */
    {
      /* ### when making the binary-file backups, should we be honoring
         keywords and eol stuff?   */

      const char *left_copy, *right_copy;
      const char *parentt, *left_base, *right_base;
      svn_wc_entry_t tmp_entry;

      /* Give the conflict resolution callback a chance to clean
         up the conflict before we mark the file 'conflicted' */
      if (conflict_func)
        {
          svn_wc_conflict_result_t *result = NULL;
          svn_wc_conflict_description_t cdesc;

          cdesc.path = merge_target;
          cdesc.node_kind = svn_node_file;
          cdesc.kind = svn_wc_conflict_kind_text;
          cdesc.is_binary = TRUE;
          cdesc.mime_type = (mimeprop && mimeprop->value)
                                ? mimeprop->value->data : NULL;
          cdesc.access = adm_access;
          cdesc.action = svn_wc_conflict_action_edit;
          cdesc.reason = svn_wc_conflict_reason_edited;
          cdesc.base_file = left;
          cdesc.their_file = right;
          cdesc.my_file = tmp_target;
          cdesc.merged_file = NULL;     /* notice there is NO merged file! */
          cdesc.property_name = NULL;

          SVN_ERR(conflict_func(&result, &cdesc, conflict_baton, pool));
          if (result == NULL)
            return svn_error_create(SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
                                    NULL, _("Conflict callback violated API:"
                                            " returned no results"));

          switch (result->choice)
            {
              /* For a binary file, there's no merged file to look at,
                 unless the conflict-callback did the merging itself. */
              case svn_wc_conflict_choose_base:
                {
                  SVN_ERR(svn_wc__loggy_copy
                          (log_accum, NULL, adm_access,
                           svn_wc__copy_translate,
                           left, merge_target,
                           FALSE, pool));
                  *merge_outcome = svn_wc_merge_merged;
                  contains_conflicts = FALSE;
                  goto merge_complete;
                }
              case svn_wc_conflict_choose_theirs_full:
                {
                  SVN_ERR(svn_wc__loggy_copy
                          (log_accum, NULL, adm_access,
                           svn_wc__copy_translate,
                           right, merge_target,
                           FALSE, pool));
                  *merge_outcome = svn_wc_merge_merged;
                  contains_conflicts = FALSE;
                  goto merge_complete;
                }
                /* For a binary file, if the response is to use the
                   user's file, we do nothing.  We also do nothing if
                   the response claims to have already resolved the
                   problem.*/
              case svn_wc_conflict_choose_mine_full:
                {
                  *merge_outcome = svn_wc_merge_merged;
                  contains_conflicts = FALSE;
                  goto merge_complete;
                }
              case svn_wc_conflict_choose_merged:
                {
                  if (! result->merged_file)
                    {
                      /* Callback asked us to choose its own
                         merged file, but didn't provide one! */
                      return svn_error_create
                          (SVN_ERR_WC_CONFLICT_RESOLVER_FAILURE,
                           NULL, _("Conflict callback violated API:"
                                   " returned no merged file"));
                    }
                  else
                    {
                      SVN_ERR(svn_wc__loggy_copy
                              (log_accum, NULL, adm_access,
                               svn_wc__copy_translate,
                               result->merged_file, merge_target,
                               FALSE, pool));
                      *merge_outcome = svn_wc_merge_merged;
                      contains_conflicts = FALSE;
                      goto merge_complete;
                    }
                }
              case svn_wc_conflict_choose_postpone:
              default:
                {
                  /* Assume conflict remains, fall through to code below. */
                }
            }
        }

      /* reserve names for backups of left and right fulltexts */
      SVN_ERR(svn_io_open_unique_file2(NULL,
                                       &left_copy,
                                       merge_target,
                                       left_label,
                                       svn_io_file_del_none,
                                       pool));

      SVN_ERR(svn_io_open_unique_file2(NULL,
                                       &right_copy,
                                       merge_target,
                                       right_label,
                                       svn_io_file_del_none,
                                       pool));

      /* create the backup files */
      SVN_ERR(svn_io_copy_file(left,
                               left_copy, TRUE, pool));
      SVN_ERR(svn_io_copy_file(right,
                               right_copy, TRUE, pool));

      /* Was the merge target detranslated? */
      if (merge_target != tmp_target)
        {
          /* Create a .mine file too */
          const char *mine_copy;

          SVN_ERR(svn_io_open_unique_file2(NULL,
                                           &mine_copy,
                                           merge_target,
                                           target_label,
                                           svn_io_file_del_none,
                                           pool));
          SVN_ERR(svn_wc__loggy_move(log_accum, NULL,
                                     adm_access,
                                     tmp_target,
                                     mine_copy,
                                     FALSE, pool));
          mine_copy = svn_path_is_child(adm_path, mine_copy, pool);
          tmp_entry.conflict_wrk = mine_copy;
        }
      else
        tmp_entry.conflict_wrk = NULL;

      /* Derive the basenames of the backup files. */
      svn_path_split(left_copy, &parentt, &left_base, pool);
      svn_path_split(right_copy, &parentt, &right_base, pool);

      /* Mark merge_target's entry as "Conflicted", and start tracking
         the backup files in the entry as well. */
      tmp_entry.conflict_old = left_base;
      tmp_entry.conflict_new = right_base;
      SVN_ERR(svn_wc__loggy_entry_modify
              (log_accum,
               adm_access, merge_target,
               &tmp_entry,
               SVN_WC__ENTRY_MODIFY_CONFLICT_OLD
               | SVN_WC__ENTRY_MODIFY_CONFLICT_NEW
               | SVN_WC__ENTRY_MODIFY_CONFLICT_WRK,
               pool));

      *merge_outcome = svn_wc_merge_conflict; /* a conflict happened */

    } /* end of binary conflict handling */
  else
    *merge_outcome = svn_wc_merge_conflict; /* dry_run for binary files. */

  merge_complete:
  /* Merging is complete.  Regardless of text or binariness, we might
     need to tweak the executable bit on the new working file.  */
  if (! dry_run)
    {
      SVN_ERR(svn_wc__loggy_maybe_set_executable(log_accum,
                                                 adm_access, merge_target,
                                                 pool));

      SVN_ERR(svn_wc__loggy_maybe_set_readonly(log_accum,
                                                adm_access, merge_target,
                                                pool));

    }

  return SVN_NO_ERROR;
}
示例#10
0
文件: xctrl.c 项目: ld-test/xctrl
XCTRL_API char*get_client_machine(Display *disp, Window win)
{
  return get_prop(disp, win, XA_STRING, "WM_CLIENT_MACHINE", NULL);
}
static int parse_xml_tree_to_cache(xmlNode *root, const char *cachepath, const char *cachefile)
{
	xmlNode *node, *node2, *node3, *node4 = NULL;
	char *name, *units, *value, *grid, *cluster, *host;
	FILE *f;
	char filenamebuf[PATH_MAX];
	int count;

	for (node = root->children; node; node = node->next) {
		if (!is_element(node, "GRID"))
			continue; /* skip non-element and non-cluster nodes */

		grid = get_prop(node, "NAME");
		debug("Found new grid: %s\n", grid);

		for (node2 = node->children; node2; node2 = node2->next) {
			if (!is_element(node2, "CLUSTER"))
				continue; /* skip non-element and non-cluster nodes */

			cluster = get_prop(node2, "NAME");
			debug("\tFound new cluster: %s\n", cluster);

			for (node3 = node2->children; node3; node3 = node3->next) {
				if (!is_element(node3, "HOST"))
					continue; /* skip non-element and non-host nodes */

				host = get_prop(node3, "NAME");
				if (config.short_name) {
					host = get_shortname(host);
				}

				debug("\t\tFound new host: %s\n", host);

				snprintf(filenamebuf, PATH_MAX, "%s/%s/%s/%s", cachepath, grid, cluster, host);
				if (config.short_name) {
					free(host);
				}

				if (create_abs_path(filenamebuf) < 0)
					return -1;

				count = 0;

				f = fopen(filenamebuf, "w");
				if (f == NULL)
					return -1;

				value = get_prop(node3, "REPORTED");
				fprintf(f, "#REPORTED, ,%s\n", value);

				for (node4 = node3->children; node4; node4 = node4->next) {
					if (!is_element(node4, "METRIC"))
						continue; /* skip non-element and non-metric nodes */

					name = get_prop(node4, "NAME");
					units = get_prop(node4, "UNITS");
					value = get_prop(node4, "VAL");

					debug("\t\t\tFound new metric: %s\n", name);

					fprintf(f, "%s,%s,%s\n", name, units, value);
					count++;
				}

				fclose(f);

				debug("\t\t\tWrote %d metrics to %s\n", count, filenamebuf);
			}
		}
	}

	return 0;
}
示例#12
0
文件: xctrl.c 项目: ld-test/xctrl
XCTRL_API Window get_active_window(Display *disp) {
  Window*win = (Window*)get_prop(disp, DefRootWin, XA_WINDOW, "_NET_ACTIVE_WINDOW", NULL);
  return (Window) ptr_to_ulong((ulong*)win,0);
}
示例#13
0
 inline value get_prop(HVM vm, value obj, const char* key)              { return get_prop(vm,obj,v_symbol(key)); }
示例#14
0
bool
output_sgf (const char *filename)
{
    int current = -1;
    union prop_data_t temp_data;
    int saved = current_node;

    sgf_fd = create_or_open_file (filename);

    if (sgf_fd < 0)
    {
        return false;
    }

    DEBUGF ("outputting to: %s (%d)\n", filename, sgf_fd);

    empty_stack (&parse_stack);

    rb->lseek (sgf_fd, 0, SEEK_SET);
    rb->ftruncate (sgf_fd, 0);

    if (sgf_fd < 0)
    {
        return false;
    }

    if (tree_head < 0)
    {
        close_file (&sgf_fd);
        return false;
    }

    push_int_stack (&parse_stack, tree_head);

    while (pop_int_stack (&parse_stack, &current))
    {
        int var_to_process = 0;
        int temp_prop =
            get_prop_sgf (current, PROP_VARIATION_TO_PROCESS, NULL);

        if (temp_prop >= 0)
        {
            var_to_process = get_prop (temp_prop)->data.number;
        }

        current_node = current;

        if (var_to_process > 0)
        {
            write_char (sgf_fd, ')');
        }

        if (var_to_process == stupid_num_variations ())
        {
            delete_prop_sgf (current, PROP_VARIATION_TO_PROCESS);

            continue;
        }
        else
        {
            write_char (sgf_fd, '\n');
            write_char (sgf_fd, '(');

            /* we need to do more processing on this branchpoint, either
               to do more variations or to output the ')' */
            push_int_stack (&parse_stack, current);

            /* increment the stored variation to process */
            temp_data.number = var_to_process + 1;
            add_or_set_prop_sgf (current,
                                 PROP_VARIATION_TO_PROCESS, temp_data);
        }

        rb->yield ();

        /* now we did the setup for sibling varaitions to be processed so
           do the actual outputting of a game tree branch */

        go_to_variation_sgf (var_to_process);
        output_gametree ();
    }

    current_node = saved;
    close_file (&sgf_fd);
    DEBUGF ("done outputting, file closed\n");
    return true;
}
示例#15
0
	bool ArchiveSequence::const_input_iterator::is_dir() const
	{
		return get_prop(kpidIsDir).as_bool();
	}
示例#16
0
static int
new_alias(disk_t *diskp, char *kernel_name, char *devlink_path,
    struct search_args *args)
{
	alias_t		*aliasp;
	char		alias[MAXPATHLEN];
	di_node_t	pnode;

	aliasp = malloc(sizeof (alias_t));
	if (aliasp == NULL) {
		return (ENOMEM);
	}

	aliasp->alias = NULL;
	aliasp->kstat_name = NULL;
	aliasp->wwn = NULL;
	aliasp->devpaths = NULL;
	aliasp->orig_paths = NULL;

	get_disk_name_from_path(devlink_path, alias, sizeof (alias));

	aliasp->alias = strdup(alias);
	if (aliasp->alias == NULL) {
		cache_free_alias(aliasp);
		return (ENOMEM);
	}

	if (kernel_name != NULL) {
		aliasp->kstat_name = strdup(kernel_name);
		if (aliasp->kstat_name == NULL) {
			cache_free_alias(aliasp);
			return (ENOMEM);
		}
	} else {
		aliasp->kstat_name = NULL;
	}

	aliasp->lun = get_prop(DM_LUN, args->node);
	aliasp->target = get_prop(DM_TARGET, args->node);
	aliasp->wwn = get_byte_prop(WWN_PROP, args->node);

	pnode = di_parent_node(args->node);
	if (pnode != DI_NODE_NIL) {
		char prop_name[MAXPROPLEN];

		(void) snprintf(prop_name, sizeof (prop_name),
		    "target%d-sync-speed", aliasp->target);
		diskp->sync_speed = get_prop(prop_name, pnode);
		(void) snprintf(prop_name, sizeof (prop_name), "target%d-wide",
		    aliasp->target);
		diskp->wide = get_prop(prop_name, pnode);
	}

	if (new_devpath(aliasp, devlink_path) != 0) {
		cache_free_alias(aliasp);
		return (ENOMEM);
	}

	aliasp->next = diskp->aliases;
	diskp->aliases = aliasp;

	return (0);
}
示例#17
0
static adr_data_t *
read_panel_path(rad_locale_t *rlocale, const char *path)
{
	xmlParserCtxt *ctx;
	xmlValidCtxt *vctx;
	xmlDoc *doc;
	adr_data_t *panel = NULL;

	ctx = xmlNewParserCtxt();
	vctx = xmlNewValidCtxt();
	if (vctx == NULL || ctx == NULL)
		return (NULL);

	doc = xmlCtxtReadFile(ctx, path, NULL, 0);
	if (doc == NULL) {
		xmlFreeValidCtxt(vctx);
		xmlFreeParserCtxt(ctx);
		rad_log(RL_WARN, "Empty/no such document: %s\n", path);
		return (NULL);
	}

	/*
	 * Validate against *our* DTD.
	 */
	if (xmlValidateDtd(vctx, doc, dtd) == 0) {
		rad_log(RL_WARN, "Invalid document: %s\n", path);
		goto out;
	}

	xmlNodePtr root = xmlDocGetRootElement(doc);
	if (root == NULL || strcmp((const char *)root->name, "panel") != 0) {
		rad_log(RL_WARN, "Not a panel definition: %s\n", path);
		goto out;
	}

	panel = adr_data_new_struct(&t__CustomPanel);
	adr_struct_set(panel, "locale",
	    adr_data_new_string(rlocale->locale, LT_COPY));

	adr_data_t *pname = get_prop(root, "name");
	adr_struct_set(panel, "name", pname);

	adr_data_t *farray =
	    adr_data_new_array(&t_array__ResourceDescriptor, 1);
	adr_struct_set(panel, "resourceDescriptors", farray);

	char *aroot = NULL;
	for (xmlNode *np = root->children; np != NULL; np = np->next) {
		if (np->type != XML_ELEMENT_NODE)
			continue;
		if (strcmp((const char *)np->name, "mainclass") == 0) {
			adr_data_t *mc = get_text(doc, np->children);
			adr_struct_set(panel, "panelDescriptorClassName", mc);
		} else if (strcmp((const char *)np->name, "approot") == 0) {
			if (aroot != NULL)
				continue;	/* schema violation */
			aroot = get_text_str(doc, np->children);
		} else if (strcmp((const char *)np->name, "file") == 0) {
			char *file = get_text_str(doc, np->children);
			if (file == NULL) {
				rad_log(RL_WARN,
				    "Empty <file> declaration within %s\n",
				    path);
				continue;
			}

			if (aroot == NULL) {
				rad_log(RL_WARN, "App root not specified\n");
				continue;
			}

			char full[PATH_MAX];
			(void) snprintf(full, RAD_COUNT(full), "%s/%s", aroot,
			    file);
			free(file);

			add_localized(rlocale, adr_data_to_string(pname),
			    farray, full);
		}
	}
	if (aroot != NULL)
		free(aroot);
out:
	xmlFreeValidCtxt(vctx);
	xmlFreeDoc(doc);
	xmlFreeParserCtxt(ctx);

	return (adr_data_purify_deep(panel));
}
示例#18
0
static controller_t *
add_controller(struct search_args *args, di_node_t node, di_minor_t minor)
{
	char		*devpath;
	controller_t	*cp;
	char		kstat_name[MAXPATHLEN];
	char		*c_type = DM_CTYPE_UNKNOWN;

	devpath = di_devfs_path(node);

	if ((cp = find_controller(args, devpath)) != NULL) {
		di_devfs_path_free((void *) devpath);
		return (cp);
	}

	/* Special handling for fp attachment node. */
	if (strcmp(di_node_name(node), "fp") == 0) {
		di_node_t pnode;

		pnode = di_parent_node(node);
		if (pnode != DI_NODE_NIL) {
			di_devfs_path_free((void *) devpath);
			devpath = di_devfs_path(pnode);

			if ((cp = find_controller(args, devpath)) != NULL) {
				di_devfs_path_free((void *) devpath);
				return (cp);
			}

			/* not in the list, create it */
			node = pnode;
			c_type = DM_CTYPE_FIBRE;
		}
	}

	if (dm_debug) {
		(void) fprintf(stderr, "INFO: add_controller %s\n", devpath);
	}

	cp = (controller_t *)calloc(1, sizeof (controller_t));
	if (cp == NULL) {
		return (NULL);
	}

	cp->name = strdup(devpath);
	di_devfs_path_free((void *) devpath);
	if (cp->name == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}

	if (strcmp(c_type, DM_CTYPE_UNKNOWN) == 0) {
		c_type = ctype(node, minor);
	}
	cp->ctype = c_type;

	(void) snprintf(kstat_name, sizeof (kstat_name), "%s%d",
	    di_node_name(node), di_instance(node));

	if ((cp->kstat_name = strdup(kstat_name)) == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}

	if (libdiskmgt_str_eq(cp->ctype, "scsi")) {
		cp->scsi_options = get_prop(SCSI_OPTIONS_PROP, node);
	}

	if (libdiskmgt_str_eq(di_node_name(node), "scsi_vhci")) {
		cp->multiplex = 1;
	} else {
		cp->multiplex = 0;
	}

	cp->freq = get_prom_int("clock-frequency", node, args->ph);

	cp->disks = (disk_t **)calloc(1, sizeof (disk_t *));
	if (cp->disks == NULL) {
		cache_free_controller(cp);
		return (NULL);
	}
	cp->disks[0] = NULL;

	cp->next = args->controller_listp;
	args->controller_listp = cp;

	cp->bus = add_bus(args, di_parent_node(node),
	    di_minor_next(di_parent_node(node), NULL), cp);

	return (cp);
}
示例#19
0
static int get_prio(struct cmd_struct *cmd, struct arg_struct *arg)
{
	return get_prop(arg, TIPC_NLA_PROP_PRIO);
}
示例#20
0
static disk_t *
create_disk(char *deviceid, char *kernel_name, struct search_args *args)
{
	disk_t	*diskp;
	char	*type;
	char	*prod_id;
	char	*vendor_id;

	if (dm_debug) {
		(void) fprintf(stderr, "INFO: create_disk %s\n", kernel_name);
	}

	diskp = calloc(1, sizeof (disk_t));
	if (diskp == NULL) {
		return (NULL);
	}

	diskp->controllers = (controller_t **)
	    calloc(1, sizeof (controller_t *));
	if (diskp->controllers == NULL) {
		cache_free_disk(diskp);
		return (NULL);
	}
	diskp->controllers[0] = NULL;

	diskp->devid = NULL;
	if (deviceid != NULL) {
		if ((diskp->device_id = strdup(deviceid)) == NULL) {
			cache_free_disk(diskp);
			return (NULL);
		}
		(void) devid_str_decode(deviceid, &(diskp->devid), NULL);
	}

	if (kernel_name != NULL) {
		diskp->kernel_name = strdup(kernel_name);
		if (diskp->kernel_name == NULL) {
			cache_free_disk(diskp);
			return (NULL);
		}
	}

	diskp->paths = NULL;
	diskp->aliases = NULL;

	diskp->cd_rom = 0;
	diskp->rpm = 0;
	diskp->solid_state = -1;
	type = di_minor_nodetype(args->minor);

	prod_id = get_str_prop(PROD_ID_PROP, args->node);
	if (prod_id != NULL) {
		if ((diskp->product_id = strdup(prod_id)) == NULL) {
			cache_free_disk(diskp);
			return (NULL);
		}
	} else {
		prod_id = get_str_prop(PROD_ID_USB_PROP, args->node);
		if (prod_id != NULL) {
			if ((diskp->product_id = strdup(prod_id)) == NULL) {
				cache_free_disk(diskp);
				return (NULL);
			}
		}
	}

	vendor_id = get_str_prop(VENDOR_ID_PROP, args->node);
	if (vendor_id != NULL) {
		if ((diskp->vendor_id = strdup(vendor_id)) == NULL) {
			cache_free_disk(diskp);
			return (NULL);
		}
	} else {
		vendor_id = get_str_prop(VENDOR_ID_USB_PROP, args->node);
		if (vendor_id != NULL) {
			if ((diskp->vendor_id = strdup(vendor_id)) == NULL) {
				cache_free_disk(diskp);
				return (NULL);
			}
		}
	}

	/*
	 * DVD, CD-ROM, CD-RW, MO, etc. are all reported as CD-ROMS.
	 * We try to use uscsi later to determine the real type.
	 * The cd_rom flag tells us that the kernel categorized the drive
	 * as a CD-ROM.  We leave the drv_type as UNKNOWN for now.
	 * The combination of the cd_rom flag being set with the drv_type of
	 * unknown is what triggers the uscsi probe in drive.c.
	 */
	if (disk_is_cdrom(type)) {
		diskp->drv_type = DM_DT_UNKNOWN;
		diskp->cd_rom = 1;
		diskp->removable = 1;
	} else if (libdiskmgt_str_eq(type, DDI_NT_FD)) {
		diskp->drv_type = DM_DT_FLOPPY;
		diskp->removable = 1;
	} else {
		/* not a CD-ROM or Floppy */
		diskp->removable = get_prop(REMOVABLE_PROP, args->node);

		if (diskp->removable == -1) {
			diskp->removable = 0;
			diskp->drv_type = DM_DT_FIXED;
		}
	}

	diskp->next = args->disk_listp;
	args->disk_listp = diskp;

	return (diskp);
}
示例#21
0
static int get_win(struct cmd_struct *cmd, struct arg_struct *arg)
{
	return get_prop(arg, TIPC_NLA_PROP_WIN);
}
示例#22
0
item atom_parser::parse_entry(xmlNode * entryNode) {
	item it;
	std::string summary;
	std::string summary_type;
	std::string updated;

	std::string base = get_prop(entryNode, "base", XML_URI);
	if (base == "")
		base = globalbase;

	for (xmlNode * node = entryNode->children; node != NULL; node = node->next) {
		if (node_is(node, "author", ns)) {
			for (xmlNode * authornode = node->children; authornode != NULL; authornode = authornode->next) {
				if (node_is(authornode, "name", ns)) {
					it.author = get_content(authornode);
				} // TODO: is there more?
			}
		} else if (node_is(node, "title", ns)) {
			it.title = get_content(node);
			it.title_type = get_prop(node, "type");
			if (it.title_type == "")
				it.title_type = "text";
		} else if (node_is(node, "content", ns)) {
			std::string mode = get_prop(node, "mode");
			std::string type = get_prop(node, "type");
			if (mode == "xml" || mode == "") {
				if (type == "html" || type == "text") {
					it.description = get_content(node);
				} else {
					it.description = get_xml_content(node);
				}
			} else if (mode == "escaped") {
				it.description = get_content(node);
			}
			it.description_type = type;
			if (it.description_type == "")
				it.description_type = "text";
			it.base = get_prop(node, "base", XML_URI);
		} else if (node_is(node, "id", ns)) {
			it.guid = get_content(node);
			it.guid_isPermaLink = false;
		} else if (node_is(node, "published", ns)) {
			it.pubDate = date::format(get_content(node));
		} else if (node_is(node, "updated", ns)) {
			updated = date::format(get_content(node));
		} else if (node_is(node, "link", ns)) {
			std::string rel = get_prop(node, "rel");
			if (rel == "" || rel == "alternate") {
				it.link = feedpp::utils::absolute_url(base, get_prop(node, "href"));
			} else if (rel == "enclosure") {
				it.enclosure_url = get_prop(node, "href");
				it.enclosure_type = get_prop(node, "type");
			}
		} else if (node_is(node, "summary", ns)) {
			std::string mode = get_prop(node, "mode");
			summary_type = get_prop(node, "type");
			if (mode == "xml" || mode == "") {
				if (summary_type == "html" || summary_type == "text") {
					summary = get_content(node);
				} else {
					summary = get_xml_content(node);
				}
			} else if (mode == "escaped") {
				summary = get_content(node);
			}
			if (summary_type == "")
				summary_type = "text";
		} else if (node_is(node, "category", ns) && get_prop(node, "scheme")=="http://www.google.com/reader/") {
			it.labels.push_back(get_prop(node, "label"));
		}
	} // for

	if (it.description == "") {
		it.description = summary;
		it.description_type = summary_type;
	}

	if (it.pubDate == "") {
		it.pubDate = updated;
	}

	return it;
}