Example #1
0
int main(int argc, char *argv[])
{
  const char *prog_name = NULL;
  Ustr *s1 = USTR_NULL;
  Ustr *s2 = USTR_NULL;
  
  if (!argc)
    exit (EXIT_FAILURE);
  
  if ((prog_name = strrchr(argv[0], '/')))
    ++prog_name;
  else
    prog_name = argv[0];
  
  if (argc != 2)
    die(prog_name, "missing operand");

  if (!(s1 = ustr_dup_cstr(argv[1])))
    die(prog_name, strerror(errno));

  if (!(s2 = u_dirname(s1)))
    die(prog_name, strerror(errno));
  ustr_free(s1);
  
  if (!ustr_io_putfileline(&s2, stderr))
    die(prog_name, strerror(errno));

  USTR_CNTL_MALLOC_CHECK_END();
  
  exit (EXIT_SUCCESS);
}
Example #2
0
static int write_replacements(genhomedircon_settings_t * s, FILE * out,
			      const semanage_list_t * tpl,
			      const replacement_pair_t *repl)
{
	Ustr *line = USTR_NULL;

	for (; tpl; tpl = tpl->next) {
		line = replace_all(tpl->data, repl);
		if (!line)
			goto fail;
		if (check_line(s, line) == STATUS_SUCCESS) {
			if (!ustr_io_putfileline(&line, out))
				goto fail;
		}
		ustr_sc_free(&line);
	}
	return STATUS_SUCCESS;

      fail:
	ustr_sc_free(&line);
	return STATUS_ERR;
}