Exemple #1
0
void	push_waiting(t_file **tmp, char *dirname, t_waiting **waiting,
					t_command *command)
{
	if (has_option(command->options, 'R') && S_ISDIR((*tmp)->infos->st_mode)
			&& !ft_strequ((*tmp)->name, ".") && !ft_strequ((*tmp)->name, ".."))
	{
		if (!has_option(command->options, 'a') && (*tmp)->name[0] == '.')
		{
			*tmp = (*tmp)->next;
			return ;
		}
		add_waiting_last(waiting, new_waiting(
			ft_strjoin(ft_strjoin(dirname, "/"), (*tmp)->name)));
	}
}
Exemple #2
0
static gpg_error_t
cmd_sign (assuan_context_t ctx, char *line)
{
  ctrl_t ctrl = assuan_get_pointer (ctx);
  int inp_fd, out_fd;
  estream_t out_fp;
  int detached;
  int rc;

  inp_fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
  if (inp_fd == -1)
    return set_error (GPG_ERR_ASS_NO_INPUT, NULL);
  out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
  if (out_fd == -1)
    return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);

  detached = has_option (line, "--detached");

  out_fp = es_fdopen_nc (out_fd, "w");
  if (!out_fp)
    return set_error (GPG_ERR_ASS_GENERAL, "fdopen() failed");

  rc = start_audit_session (ctrl);
  if (!rc)
    rc = gpgsm_sign (assuan_get_pointer (ctx), ctrl->server_local->signerlist,
                     inp_fd, detached, out_fp);
  es_fclose (out_fp);

  /* close and reset the fd */
  close_message_fd (ctrl);
  assuan_close_input_fd (ctx);
  assuan_close_output_fd (ctx);

  return rc;
}
Exemple #3
0
t_file	*store_files(char *dirname, DIR *dirp, t_command *command)
{
	t_file			*files;
	struct stat 	*fileinfo;
	char			*fullname;
	struct dirent	*dir;

	files = NULL;
	fileinfo = NULL;
	while ((dir = readdir(dirp)))
	{
		if (!has_option(command->options, 'a') && dir->d_name[0] == '.')
			continue ;
		if (!(fullname = ft_strjoin(ft_strjoin(dirname, "/"), dir->d_name)))
			return (delete_files(&files));
		if (!(fileinfo = malloc(sizeof(*fileinfo))))
			return (delete_variables(&fileinfo, &fullname));
		if (lstat(fullname, fileinfo) == -1)
		{
			no_such_file_or_directory(fullname);
			delete_variables(&fileinfo, &fullname);
			continue ;
		}
		add_file_last(&files, new_file(dir->d_name, fileinfo));
		ft_strdel(&fullname);
	}
	set_file_order(files, command->options);
	return (files);
}
Exemple #4
0
static gpg_error_t
cmd_getauditlog (assuan_context_t ctx, char *line)
{
  ctrl_t ctrl = assuan_get_pointer (ctx);
  int  out_fd;
  estream_t out_stream;
  int opt_data, opt_html;
  int rc;

  opt_data = has_option (line, "--data");
  opt_html = has_option (line, "--html");
  line = skip_options (line);

  if (!ctrl->audit)
    return gpg_error (GPG_ERR_NO_DATA);

  if (opt_data)
    {
      out_stream = es_fopencookie (ctx, "w", data_line_cookie_functions);
      if (!out_stream)
        return set_error (GPG_ERR_ASS_GENERAL,
                          "error setting up a data stream");
    }
  else
    {
      out_fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
      if (out_fd == -1)
        return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);

      out_stream = es_fdopen_nc (out_fd, "w");
      if (!out_stream)
        {
          return set_error (GPG_ERR_ASS_GENERAL, "es_fdopen() failed");
        }
    }

  audit_print_result (ctrl->audit, out_stream, opt_html);
  rc = 0;

  es_fclose (out_stream);

  /* Close and reset the fd. */
  if (!opt_data)
    assuan_close_output_fd (ctx);
  return rc;
}
Exemple #5
0
char *
get_option_value(int argc, char **argv, char *option_id){
  int i;

  i = has_option(argc,argv,option_id);
  if ( i ){
    if ( i + 1 < argc )
      return argv[i+1];
  }
  return NULL;
}
Exemple #6
0
vespalib::string
Regexp::get_prefix(vespalib::stringref re)
{
    vespalib::string prefix;
    if ((re.size() > 0) && (re.data()[0] == '^') && !has_option(re)) {
        const char *end = re.data() + re.size();
        const char *pos = re.data() + 1;
        for (; (pos < end) && !is_special(*pos); ++pos) {
            prefix.push_back(*pos);
        }
        if ((pos < end) && maybe_none(*pos) && !prefix.empty()) {
            prefix.resize(prefix.size() - 1); // pop_back
        }
    }
    return prefix;
}
Exemple #7
0
static gpg_error_t
cmd_import (assuan_context_t ctx, char *line)
{
  ctrl_t ctrl = assuan_get_pointer (ctx);
  int rc;
  int fd = translate_sys2libc_fd (assuan_get_input_fd (ctx), 0);
  int reimport = has_option (line, "--re-import");

  (void)line;

  if (fd == -1)
    return set_error (GPG_ERR_ASS_NO_INPUT, NULL);

  rc = gpgsm_import (assuan_get_pointer (ctx), fd, reimport);

  /* close and reset the fd */
  close_message_fd (ctrl);
  assuan_close_input_fd (ctx);
  assuan_close_output_fd (ctx);

  return rc;
}
Exemple #8
0
char catch_options(char *param, int ac, char **av, int *k, int *index, char *options, char (*message)[100])
{
    unsigned int i;

    for (i = 1; i < strlen(param); i++) {
        if (!has_option(param[i], options)) {
            if (is_valid_option(param[i])) {
                options[*index] = param[i];
                if (param[i] == 'p' && (*k + 1) <= (ac - 1)) {
                    *k = *k + 1;
                    strcpy(message[0], av[*k]);
                }
                else if (param[i] == 'L' && (*k + 1) <= (ac - 1)) {
                    *k = *k + 1;
                    strcpy(message[1], av[*k]);
                }
                *index = *index + 1;
            }
            else
                return (param[i]);
        }
    }
    return (0);
}
Exemple #9
0
/*  RECIPIENT [--hidden] <userID>

   Set the recipient for the encryption.  <userID> should be the
   internal representation of the key; the server may accept any other
   way of specification.  If this is a valid and trusted recipient the
   server does respond with OK, otherwise the return is an ERR with
   the reason why the recipient can't be used, the encryption will
   then not be done for this recipient.  If the policy is not to
   encrypt at all if not all recipients are valid, the client has to
   take care of this.  All RECIPIENT commands are cumulative until a
   RESET or an successful ENCRYPT command.  */
static gpg_error_t
cmd_recipient (assuan_context_t ctx, char *line)
{
  ctrl_t ctrl = assuan_get_pointer (ctx);
  gpg_error_t err;
  int hidden;

  hidden = has_option (line,"--hidden");
  line = skip_options (line);

  /* FIXME: Expand groups
  if (opt.grouplist)
    remusr = expand_group (rcpts);
  else
    remusr = rcpts;
  */

  err = find_and_check_key (ctrl, line, PUBKEY_USAGE_ENC, hidden,
                            &ctrl->server_local->recplist);

  if (err)
    log_error ("command '%s' failed: %s\n", "RECIPIENT", gpg_strerror (err));
  return err;
}
Exemple #10
0
static gpg_error_t
cmd_export (assuan_context_t ctx, char *line)
{
  ctrl_t ctrl = assuan_get_pointer (ctx);
  char *p;
  strlist_t list, sl;
  int use_data;

  use_data = has_option (line, "--data");

  if (use_data)
    {
      /* We need to override any possible setting done by an OUTPUT command. */
      ctrl->create_pem = has_option (line, "--armor");
      ctrl->create_base64 = has_option (line, "--base64");
    }

  line = skip_options (line);

  /* Break the line down into an strlist_t. */
  list = NULL;
  for (p=line; *p; line = p)
    {
      while (*p && *p != ' ')
        p++;
      if (*p)
        *p++ = 0;
      if (*line)
        {
          sl = xtrymalloc (sizeof *sl + strlen (line));
          if (!sl)
            {
              free_strlist (list);
              return out_of_core ();
            }
          sl->flags = 0;
          strcpy_escaped_plus (sl->d, line);
          sl->next = list;
          list = sl;
        }
    }

  if (use_data)
    {
      estream_t stream;

      stream = es_fopencookie (ctx, "w", data_line_cookie_functions);
      if (!stream)
        {
          free_strlist (list);
          return set_error (GPG_ERR_ASS_GENERAL,
                            "error setting up a data stream");
        }
      gpgsm_export (ctrl, list, stream);
      es_fclose (stream);
    }
  else
    {
      int fd = translate_sys2libc_fd (assuan_get_output_fd (ctx), 1);
      estream_t out_fp;

      if (fd == -1)
        {
          free_strlist (list);
          return set_error (GPG_ERR_ASS_NO_OUTPUT, NULL);
        }
      out_fp = es_fdopen_nc (fd, "w");
      if (!out_fp)
        {
          free_strlist (list);
          return set_error (gpg_err_code_from_syserror (), "fdopen() failed");
        }

      gpgsm_export (ctrl, list, out_fp);
      es_fclose (out_fp);
    }

  free_strlist (list);
  /* Close and reset the fds. */
  close_message_fd (ctrl);
  assuan_close_input_fd (ctx);
  assuan_close_output_fd (ctx);
  return 0;
}
Exemple #11
0
 bool showcommand(void) const
 {
     return has_option(OPT_v);
 }
Exemple #12
0
void
modeline_parser_apply_modeline (GtkSourceView *view)
{
	ModelineOptions options;
	GtkTextBuffer *buffer;
	GtkTextIter iter, liter;
	gint line_count;
	GSettings *settings;

	options.language_id = NULL;
	options.set = MODELINE_SET_NONE;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	gtk_text_buffer_get_start_iter (buffer, &iter);

	line_count = gtk_text_buffer_get_line_count (buffer);

	/* Parse the modelines on the 10 first lines... */
	while ((gtk_text_iter_get_line (&iter) < 10) &&
	       !gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* ...and on the 10 last ones (modelines are not allowed in between) */
	if (!gtk_text_iter_is_end (&iter))
	{
		gint cur_line;
		guint remaining_lines;

		/* we are on the 11th line (count from 0) */
		cur_line = gtk_text_iter_get_line (&iter);
		/* g_assert (10 == cur_line); */

		remaining_lines = line_count - cur_line - 1;

		if (remaining_lines > 10)
		{
			gtk_text_buffer_get_end_iter (buffer, &iter);
			gtk_text_iter_backward_lines (&iter, 9);
		}
	}

	while (!gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* Try to set language */
	if (has_option (&options, MODELINE_SET_LANGUAGE) && options.language_id)
	{
		if (g_ascii_strcasecmp (options.language_id, "text") == 0)
		{
			gedit_document_set_language (GEDIT_DOCUMENT (buffer),
			                             NULL);
		}
		else
		{
		        GtkSourceLanguageManager *manager;
		        GtkSourceLanguage *language;

		        manager = gedit_get_language_manager ();

			language = gtk_source_language_manager_get_language
					(manager, options.language_id);
			if (language != NULL)
			{
				gedit_document_set_language (GEDIT_DOCUMENT (buffer),
				                             language);
			}
			else
			{
				gedit_debug_message (DEBUG_PLUGINS,
						     "Unknown language `%s'",
						     options.language_id);
			}
		}
	}

	ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer), 
	                                               MODELINE_OPTIONS_DATA_KEY);

	settings = g_settings_new ("org.gnome.gedit.preferences.editor");

	/* Apply the options we got from modelines and restore defaults if
	   we set them before */
	if (has_option (&options, MODELINE_SET_INSERT_SPACES))
	{
		gtk_source_view_set_insert_spaces_instead_of_tabs
							(view, options.insert_spaces);
	}
	else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES))
	{
		gboolean insert_spaces;
		
		insert_spaces = g_settings_get_boolean (settings, GEDIT_SETTINGS_INSERT_SPACES);
	
		gtk_source_view_set_insert_spaces_instead_of_tabs (view, insert_spaces);
	}
	
	if (has_option (&options, MODELINE_SET_TAB_WIDTH))
	{
		gtk_source_view_set_tab_width (view, options.tab_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
	{
		guint tab_width;
		
		g_settings_get (settings, GEDIT_SETTINGS_TABS_SIZE, "u", &tab_width);
	
		gtk_source_view_set_tab_width (view, tab_width);
	}
	
	if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, options.indent_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, -1);
	}
	
	if (has_option (&options, MODELINE_SET_WRAP_MODE))
	{
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode);
	}
	else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
	{
		GtkWrapMode mode;
		
		mode = g_settings_get_enum (settings,
					    GEDIT_SETTINGS_WRAP_MODE);
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), mode);
	}
	
	if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		gtk_source_view_set_right_margin_position (view, options.right_margin_position);
	}
	else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		guint right_margin_pos;
		
		g_settings_get (settings, GEDIT_SETTINGS_RIGHT_MARGIN_POSITION, "u",
				&right_margin_pos);
		gtk_source_view_set_right_margin_position (view, 
		                                           right_margin_pos);
	}
	
	if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gtk_source_view_set_show_right_margin (view, options.display_right_margin);
	}
	else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gboolean display_right_margin;
		
		display_right_margin = g_settings_get_boolean (settings,
							       GEDIT_SETTINGS_DISPLAY_RIGHT_MARGIN);
		gtk_source_view_set_show_right_margin (view, display_right_margin);
	}
	
	if (previous)
	{
		g_free (previous->language_id);
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
	}
	else
	{
		previous = g_slice_new (ModelineOptions);
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
		
		g_object_set_data_full (G_OBJECT (buffer), 
		                        MODELINE_OPTIONS_DATA_KEY, 
		                        previous,
		                        (GDestroyNotify)free_modeline_options);
	}

	g_object_unref (settings);
	g_free (options.language_id);
}
static int create_disk(
                const char *name,
                const char *device,
                const char *password,
                const char *options) {

        _cleanup_free_ char *p = NULL, *n = NULL, *d = NULL, *u = NULL, *from = NULL, *to = NULL, *e = NULL;
        _cleanup_fclose_ FILE *f = NULL;
        bool noauto, nofail, tmp, swap;

        assert(name);
        assert(device);

        noauto = has_option(options, "noauto");
        nofail = has_option(options, "nofail");
        tmp = has_option(options, "tmp");
        swap = has_option(options, "swap");

        if (tmp && swap) {
                log_error("Device '%s' cannot be both 'tmp' and 'swap'. Ignoring.", name);
                return -EINVAL;
        }

        n = unit_name_from_path_instance("systemd-cryptsetup", name, ".service");
        if (!n)
                return log_oom();

        p = strjoin(arg_dest, "/", n, NULL);
        if (!p)
                return log_oom();

        u = fstab_node_to_udev_node(device);
        if (!u)
                return log_oom();

        d = unit_name_from_path(u, ".device");
        if (!d)
                return log_oom();

        f = fopen(p, "wxe");
        if (!f) {
                log_error("Failed to create unit file %s: %m", p);
                return -errno;
        }

        fputs(
                "# Automatically generated by systemd-cryptsetup-generator\n\n"
                "[Unit]\n"
                "Description=Cryptography Setup for %I\n"
                "Documentation=man:[email protected](8) man:crypttab(5)\n"
                "SourcePath=/etc/crypttab\n"
                "Conflicts=umount.target\n"
                "DefaultDependencies=no\n"
                "BindsTo=dev-mapper-%i.device\n"
                "IgnoreOnIsolate=true\n"
                "After=systemd-readahead-collect.service systemd-readahead-replay.service\n",
                f);

        if (!nofail)
                fprintf(f,
                        "Before=cryptsetup.target\n");

        if (password) {
                if (streq(password, "/dev/urandom") ||
                    streq(password, "/dev/random") ||
                    streq(password, "/dev/hw_random"))
                        fputs("After=systemd-random-seed.service\n", f);
                else if (!streq(password, "-") &&
                         !streq(password, "none"))
                        fprintf(f,
                                "RequiresMountsFor=%s\n",
                                password);
        }

        if (is_device_path(u))
                fprintf(f,
                        "BindsTo=%s\n"
                        "After=%s\n"
                        "Before=umount.target\n",
                        d, d);
        else
                fprintf(f,
                        "RequiresMountsFor=%s\n",
                        u);

        fprintf(f,
                "\n[Service]\n"
                "Type=oneshot\n"
                "RemainAfterExit=yes\n"
                "TimeoutSec=0\n" /* the binary handles timeouts anyway */
                "ExecStart=" SYSTEMD_CRYPTSETUP_PATH " attach '%s' '%s' '%s' '%s'\n"
                "ExecStop=" SYSTEMD_CRYPTSETUP_PATH " detach '%s'\n",
                name, u, strempty(password), strempty(options),
                name);

        if (tmp)
                fprintf(f,
                        "ExecStartPost=/sbin/mke2fs '/dev/mapper/%s'\n",
                        name);

        if (swap)
                fprintf(f,
                        "ExecStartPost=/sbin/mkswap '/dev/mapper/%s'\n",
                        name);

        fflush(f);

        if (ferror(f)) {
                log_error("Failed to write file %s: %m", p);
                return -errno;
        }

        if (asprintf(&from, "../%s", n) < 0)
                return log_oom();

        if (!noauto) {

                to = strjoin(arg_dest, "/", d, ".wants/", n, NULL);
                if (!to)
                        return log_oom();

                mkdir_parents_label(to, 0755);
                if (symlink(from, to) < 0) {
                        log_error("Failed to create symlink %s: %m", to);
                        return -errno;
                }

                free(to);
                if (!nofail)
                        to = strjoin(arg_dest, "/cryptsetup.target.requires/", n, NULL);
                else
                        to = strjoin(arg_dest, "/cryptsetup.target.wants/", n, NULL);
                if (!to)
                        return log_oom();

                mkdir_parents_label(to, 0755);
                if (symlink(from, to) < 0) {
                        log_error("Failed to create symlink %s: %m", to);
                        return -errno;
                }
        }

        e = unit_name_escape(name);
        if (!e)
                return log_oom();

        free(to);
        to = strjoin(arg_dest, "/dev-mapper-", e, ".device.requires/", n, NULL);
        if (!to)
                return log_oom();

        mkdir_parents_label(to, 0755);
        if (symlink(from, to) < 0) {
                log_error("Failed to create symlink %s: %m", to);
                return -errno;
        }

        if (!noauto && !nofail) {
                int r;
                free(p);
                p = strjoin(arg_dest, "/dev-mapper-", e, ".device.d/50-job-timeout-sec-0.conf", NULL);
                if (!p)
                        return log_oom();

                mkdir_parents_label(p, 0755);

                r = write_string_file(p,
                                "# Automatically generated by systemd-cryptsetup-generator\n\n"
                                "[Unit]\n"
                                "JobTimeoutSec=0\n"); /* the binary handles timeouts anyway */
                if (r)
                        return r;
        }

        return 0;
}
Exemple #14
0
void
modeline_parser_apply_modeline (GtkSourceView *view)
{
	ModelineOptions options;
	GtkTextBuffer *buffer;
	GtkTextIter iter, liter;
	gint line_count;
	
	options.language_id = NULL;
	options.set = MODELINE_SET_NONE;

	buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW (view));
	gtk_text_buffer_get_start_iter (buffer, &iter);

	line_count = gtk_text_buffer_get_line_count (buffer);

	/* Parse the modelines on the 10 first lines... */
	while ((gtk_text_iter_get_line (&iter) < 10) &&
	       !gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* ...and on the 10 last ones (modelines are not allowed in between) */
	if (!gtk_text_iter_is_end (&iter))
	{
		gint cur_line;
		guint remaining_lines;

		/* we are on the 11th line (count from 0) */
		cur_line = gtk_text_iter_get_line (&iter);
		/* g_assert (10 == cur_line); */

		remaining_lines = line_count - cur_line - 1;

		if (remaining_lines > 10)
		{
			gtk_text_buffer_get_end_iter (buffer, &iter);
			gtk_text_iter_backward_lines (&iter, 9);
		}
	}

	while (!gtk_text_iter_is_end (&iter))
	{
		gchar *line;

		liter = iter;
		gtk_text_iter_forward_to_line_end (&iter);
		line = gtk_text_buffer_get_text (buffer, &liter, &iter, TRUE);

		parse_modeline (line,
				1 + gtk_text_iter_get_line (&iter),
				line_count,
				&options);

		gtk_text_iter_forward_line (&iter);

		g_free (line);
	}

	/* Try to set language */
	if (has_option (&options, MODELINE_SET_LANGUAGE) && options.language_id)
	{
		GtkSourceLanguageManager *manager;
		GtkSourceLanguage *language;

		manager = pluma_get_language_manager ();
		language = gtk_source_language_manager_get_language
				(manager, options.language_id);

		if (language != NULL)
		{
			gtk_source_buffer_set_language (GTK_SOURCE_BUFFER (buffer),
							language);
		}
	}

	ModelineOptions *previous = g_object_get_data (G_OBJECT (buffer), 
	                                               MODELINE_OPTIONS_DATA_KEY);

	/* Apply the options we got from modelines and restore defaults if
	   we set them before */
	if (has_option (&options, MODELINE_SET_INSERT_SPACES))
	{
		gtk_source_view_set_insert_spaces_instead_of_tabs
							(view, options.insert_spaces);
	}
	else if (check_previous (view, previous, MODELINE_SET_INSERT_SPACES))
	{
		gtk_source_view_set_insert_spaces_instead_of_tabs
							(view,
							 pluma_prefs_manager_get_insert_spaces ());
	}
	
	if (has_option (&options, MODELINE_SET_TAB_WIDTH))
	{
		gtk_source_view_set_tab_width (view, options.tab_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_TAB_WIDTH))
	{
		gtk_source_view_set_tab_width (view, 
		                               pluma_prefs_manager_get_tabs_size ());
	}
	
	if (has_option (&options, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, options.indent_width);
	}
	else if (check_previous (view, previous, MODELINE_SET_INDENT_WIDTH))
	{
		gtk_source_view_set_indent_width (view, -1);
	}
	
	if (has_option (&options, MODELINE_SET_WRAP_MODE))
	{
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), options.wrap_mode);
	}
	else if (check_previous (view, previous, MODELINE_SET_WRAP_MODE))
	{
		gtk_text_view_set_wrap_mode (GTK_TEXT_VIEW (view), 
		                             pluma_prefs_manager_get_wrap_mode ());
	}
	
	if (has_option (&options, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		gtk_source_view_set_right_margin_position (view, options.right_margin_position);
	}
	else if (check_previous (view, previous, MODELINE_SET_RIGHT_MARGIN_POSITION))
	{
		gtk_source_view_set_right_margin_position (view, 
		                                           pluma_prefs_manager_get_right_margin_position ());
	}
	
	if (has_option (&options, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gtk_source_view_set_show_right_margin (view, options.display_right_margin);
	}
	else if (check_previous (view, previous, MODELINE_SET_SHOW_RIGHT_MARGIN))
	{
		gtk_source_view_set_show_right_margin (view, 
		                                       pluma_prefs_manager_get_display_right_margin ());
	}
	
	if (previous)
	{
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
	}
	else
	{
		previous = g_slice_new (ModelineOptions);
		*previous = options;
		previous->language_id = g_strdup (options.language_id);
		
		g_object_set_data_full (G_OBJECT (buffer), 
		                        MODELINE_OPTIONS_DATA_KEY, 
		                        previous,
		                        (GDestroyNotify)free_modeline_options);
	}
	
	g_free (options.language_id);
}