示例#1
0
/*
 * Outputs the component mnemonics for the product
 * matching the specified mnemonic and id.
 */
static void
lookup_components(const char *mnemonic, const char *id)
{
	if (mnemonic != NULL && id != NULL) {
		Reg_comp *comp_obj = _wsreg_comp_initialize();
		List *matches = get_matching_components(mnemonic, id);
		if (matches != NULL && matches->size(matches) != 0) {
			matches->reset_iterator(matches);
			if (matches->has_more_elements(matches)) {
				Wsreg_component *comp =
				    (Wsreg_component *)
				    matches->next_element(matches);
				Wsreg_component **children =
				    wsreg_get_child_components(comp);
				if (children != NULL) {
					int index = 0;
					while (children[index] != NULL) {
						output_text("%s ", 1,
						    wsreg_get_unique_name(
							    children[index]));
						index++;
					}
					output_text("\n", 0);
					comp_obj->free_array(children);
				}
			}
			matches->free(matches, (Free)wsreg_free_component);
		} else {
			(void) fprintf(stderr, PRODREG_NOT_REGISTERED,
			    mnemonic, id);
			(void) fprintf(stderr, "\n");
		}
	}
}   
示例#2
0
void ok_cb (GtkWidget *w, void *v)
{  
   gboolean edit=TRUE;
   GtkWidget *widget;
   GtkType type;
   GSList *current = widgets;
   
   while (current) {
      edit=TRUE;
      widget = (GtkWidget *)current->data;
      current = current->next;
      
      type = GTK_OBJECT_TYPE(widget);
      if (type == gtk_entry_get_type())
	output_entry(widget);
      if (type == gtk_text_get_type())
	output_text(widget,&edit);
      if (type == gtk_combo_get_type())
	output_combo(widget);
      if (type == gtk_check_button_get_type())
	output_check_button(widget);
      if (type == gtk_option_menu_get_type())
	output_option_menu(widget);
      
      /* if there are more widgets with output values, separate them */
      if (current && edit) {
	putchar ('\v');
      }
   }
   quit(RETURN_OK);
}
示例#3
0
/*
 * This function is called to fulfill the "lookupProducts"
 * prodreg command.
 *
 * Each mnemonic in the specified list for which there is
 * a component registered is printed on a single line of output.
 */
static void
lookup_products(List *mnemonics)
{
	if (mnemonics != NULL && mnemonics->size(mnemonics) > 0) {
		mnemonics->reset_iterator(mnemonics);
		while (mnemonics->has_more_elements(mnemonics)) {
			char *mnemonic =
			    (char *)mnemonics->next_element(mnemonics);
			List *matches = get_matching_components(mnemonic, NULL);
			if (matches != NULL && matches->size(matches) > 0) {
				output_text("%s ", 1, mnemonic);
				matches->free(matches,
				    (Free)wsreg_free_component);
			}
		}
	}
	output_text("\n", 0);
}
示例#4
0
static void
pt_token_visitor_visit_token (visitor_type *object, node_type const *node)
{
  SELF ();
  char const *text = pt_token_text (node);

  output_location (self, pt_node_location (node), text[0]);
  if (pt_token_token (node) != EOF)
    output_text (self, text);
}
示例#5
0
/*
 * This function supports the prodreg 2.0 "list" command.
 * The list command takes an attribute name to select on.
 * Any component that has data (any data other than NULL)
 * stored under the specified attribute name will be selected
 * for the list.
 *
 * The "fields" specifies attributes we want to list for each
 * selected component.  The output of this function is a
 * table of data, one line for each selected component.
 */
static void
list_articles(const char *selector, List *fields)
{
	Wsreg_component **components = wsreg_get_all();

	if (components != NULL) {
		int index = 0;
		while (components[index] != NULL) {
			Wsreg_component *comp = components[index];

			/*
			 * Select components based on the selector.  If
			 * the component has the specified information,
			 * a line of text containing the component's
			 * specified field values.
			 */
			if (get_component_attribute(comp, selector) != NULL) {
				/*
				 * We found a matching component.  Print out
				 * a line of text with our attributes.
				 */
				int field_index = 0;
				fields->reset_iterator(fields);
				while (fields->has_more_elements(fields)) {
					char *field = (char *)
					    fields->next_element(fields);
					char *value =
					    get_component_attribute(comp,
						field);
					if (field_index > 0) {
						output_text("\t", 0);
					}
					output_text("%s", 1,
					    value?value:"NULL");
					field_index++;
				}
				output_text("\n", 0);
			}
			index++;
		}
	}
}
示例#6
0
void print_triangle(int Level)
{
	//initialize value of i,j,k
	int i = 0, j = 0, k = 0;
	//print upper case
	for (i = 1; i <= Level; i++)
	{
		for (j = 1; j <= i; j++) { output_text(); }
		printf("\n");
	}
	//print midden case
	for (i = 1; i <= Level + 1; i++) {
		output_text();
	}
	printf("\n");
	//print lower case
	for (i = Level; i >= 1; i--) {
		for (k = 1; k <= i; k++) { output_text(); }
		printf("\n");
	}

}
示例#7
0
/*
 * Uninstall the product identified by the specified
 * mnemonic and other information.  The "other" can be one of:
 *
 * "other" can be: "-": wildcard - matches any Article registered
 *			with the specified mnemonic.  Seems
 *			dangerous, but that's the way the old prodreg works.
 *		 uninstaller directory
 *		 id (9-digit random number assigned to the article)
 *
 * This is not a good interface, but we cannot change
 * the functionality of the original product registry.  This method's
 * arguments come directly from the command line.
 */
static void
uninstall(char *mnemonic, char *other)
{
	Wsreg_component *comp = NULL;
	if (mnemonic == NULL || other == NULL) {
		/*
		 * Bad arguments passed in.  Log a message and exit.
		 */
		log_message("ERROR", "uninstall called with bad arguments "
		    "(%s, %s)\n", 2,
		    mnemonic?mnemonic:"NULL", other?other:"NULL");
		return;
	}
	comp = get_component_by_other(mnemonic, other);
	if (comp != NULL) {
		/*
		 * Found the correct
		 * component.  Now uninstall.
		 */
		char *uninstaller = wsreg_get_uninstaller(comp);
		if (uninstaller != NULL) {
			if (!system(uninstaller)) {
				output_text("%s\n", 1,
				    PRODREG_UNINSTALL_SUCCESS);
			} else {
				/*
				 * The uninstall call failed.
				 */
				(void) fprintf(stderr, PRODREG_BAD_SYSTEM_CALL,
				    uninstaller);
				(void) fprintf(stderr, "\n");
			}
		} else {
			/*
			 * This component has no uninstaller.
			 */
			(void) fprintf(stderr, PRODREG_NO_UNINSTALLER,
			    wsreg_get_display_name(comp, "en"));
			(void) fprintf(stderr, "\n");
		}
	} else {
		/*
		 * The component is not registered.
		 */
		(void) fprintf(stderr, PRODREG_NO_SUCH_COMPONENT,
		    mnemonic, other);
		(void) fprintf(stderr, "\n");
	}
}
示例#8
0
/*
 * Takes a mnemonic as an argument, if the
 * mnemonic (unique id) has been registered,
 * the output looks like this:
 *
 *   test 1.0.1
 * ID=534724607   mnemonic = test
 * installLocation = /tmp
 * versionVector = 1.0.1
 *
 */
static void
lookup(const char *mnemonic, const char *id)
{
	List *matches = get_matching_components(mnemonic, id);
	if (matches != NULL) {
		matches->reset_iterator(matches);
		while (matches->has_more_elements(matches)) {
			Wsreg_component *comp =
			    (Wsreg_component *)matches->next_element(matches);
			char *location = NULL;
			char *id = NULL;

			output_text("  %s", 1,
			    wsreg_get_display_name(comp, "en"));
			output_text(" %s\n", 1, wsreg_get_version(comp));

			id = wsreg_get_data(comp, "id");
			if (id == NULL) {
				/*
				 * If the component does not currently have
				 * an id, generate one and set it into
				 * the component.
				 */
				Article_id *article_id =
				    _wsreg_artid_initialize();
				id = article_id->create_id();
				wsreg_set_data(comp, "id", id);
			}
			output_text("ID=%s", 1, id);
			free(id);
			output_text("    mnemonic=%s", 1,
			    wsreg_get_unique_name(comp));
			location = wsreg_get_location(comp);
			if (location != NULL) {
				output_text("\ninstallLocation=%s", 1,
				    location);
			}
			output_text("\nversionVector=%s", 1,
			    wsreg_get_version(comp));
			output_text("\n\n", 0); /* from Registry.lookup() */
		}
		matches->free(matches, (Free)wsreg_free_component);
	}
}
示例#9
0
void
insert_file (FILE *file)
{
  static char buffer[COPY_BUFFER_SIZE];
  size_t length;

  /* Optimize out inserting into a sink.  */
  if (!output_diversion)
    return;

  /* Insert output by big chunks.  */
  while (1)
    {
      length = fread (buffer, 1, sizeof buffer, file);
      if (ferror (file))
        M4ERROR ((EXIT_FAILURE, errno, "error reading inserted file"));
      if (length == 0)
        break;
      output_text (buffer, length);
    }
}
示例#10
0
int wxbencode_test::OnRun()
{

	wxFileInputStream input_file(wxT("original.torrent"));
	wxFileOutputStream output_file(wxT("test_binary.torrent"));
	wxDataInputStream input_data(input_file);
	wxDataOutputStream output_data(output_file);
	wxTextOutputStream output_text(output_file);

	wxLogMessage(wxT("decoding torrent file"));
	wx_bdecode(input_file, input_data, e, 0);
	wxLogMessage(wxT("done decoding"));

	//wx_entry_print(e,0);

	wxLogMessage(wxT("encoding torrent file"));
	wx_bencode(output_data, output_text, e);
	wxLogMessage(wxT("done encoding"));

	return 0;
}
示例#11
0
void
shipout_text (struct obstack *obs, const char *text, int length, int line)
{
  static bool start_of_output_line = true;
  const char *cursor;

  /* If output goes to an obstack, merely add TEXT to it.  */

  if (obs != NULL)
    {
      obstack_grow (obs, text, length);
      return;
    }

  /* Do nothing if TEXT should be discarded.  */

  if (output_diversion == NULL)
    return;

  /* Output TEXT to a file, or in-memory diversion buffer.  */

  if (!sync_output)
    switch (length)
      {

        /* In-line short texts.  */

      case 8: OUTPUT_CHARACTER (*text); text++;
      case 7: OUTPUT_CHARACTER (*text); text++;
      case 6: OUTPUT_CHARACTER (*text); text++;
      case 5: OUTPUT_CHARACTER (*text); text++;
      case 4: OUTPUT_CHARACTER (*text); text++;
      case 3: OUTPUT_CHARACTER (*text); text++;
      case 2: OUTPUT_CHARACTER (*text); text++;
      case 1: OUTPUT_CHARACTER (*text);
      case 0:
        return;

        /* Optimize longer texts.  */

      default:
        output_text (text, length);
      }
  else
    {
      /* Check for syncline only at the start of a token.  Multiline
         tokens, and tokens that are out of sync but in the middle of
         the line, must wait until the next raw newline triggers a
         syncline.  */
      if (start_of_output_line)
        {
          start_of_output_line = false;
          output_current_line++;
#ifdef DEBUG_OUTPUT
          xfprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
                   line, current_line, output_current_line);
#endif

          /* Output a `#line NUM' synchronization directive if needed.
             If output_current_line was previously given a negative
             value (invalidated), output `#line NUM "FILE"' instead.  */

          if (output_current_line != line)
            {
              OUTPUT_CHARACTER ('#');
              OUTPUT_CHARACTER ('l');
              OUTPUT_CHARACTER ('i');
              OUTPUT_CHARACTER ('n');
              OUTPUT_CHARACTER ('e');
              OUTPUT_CHARACTER (' ');
              for (cursor = ntoa (line, 10); *cursor; cursor++)
                OUTPUT_CHARACTER (*cursor);
              if (output_current_line < 1 && current_file[0] != '\0')
                {
                  OUTPUT_CHARACTER (' ');
                  OUTPUT_CHARACTER ('"');
                  for (cursor = current_file; *cursor; cursor++)
                    OUTPUT_CHARACTER (*cursor);
                  OUTPUT_CHARACTER ('"');
                }
              OUTPUT_CHARACTER ('\n');
              output_current_line = line;
            }
        }

      /* Output the token, and track embedded newlines.  */
      for (; length-- > 0; text++)
        {
          if (start_of_output_line)
            {
              start_of_output_line = false;
              output_current_line++;
#ifdef DEBUG_OUTPUT
              xfprintf (stderr, "DEBUG: line %d, cur %d, cur out %d\n",
                       line, current_line, output_current_line);
#endif
            }
          OUTPUT_CHARACTER (*text);
          if (*text == '\n')
            start_of_output_line = true;
        }
    }
}
示例#12
0
int
main (int argc, char *argv[])
{
  int err;
  int verbose_mode = LSTOPO_VERBOSE_MODE_DEFAULT;
  hwloc_topology_t topology;
  const char *filename = NULL;
  unsigned long flags = HWLOC_TOPOLOGY_FLAG_IO_DEVICES | HWLOC_TOPOLOGY_FLAG_IO_BRIDGES | HWLOC_TOPOLOGY_FLAG_ICACHES;
  int merge = 0;
  int ignorecache = 0;
  char * callname;
  char * input = NULL;
  enum hwloc_utils_input_format input_format = HWLOC_UTILS_INPUT_DEFAULT;
  enum output_format output_format = LSTOPO_OUTPUT_DEFAULT;
  char *restrictstring = NULL;
  int opt;
  unsigned i;

  for(i=0; i<HWLOC_OBJ_TYPE_MAX; i++)
    force_orient[i] = LSTOPO_ORIENT_NONE;
  force_orient[HWLOC_OBJ_PU] = LSTOPO_ORIENT_HORIZ;
  force_orient[HWLOC_OBJ_CACHE] = LSTOPO_ORIENT_HORIZ;
  force_orient[HWLOC_OBJ_NODE] = LSTOPO_ORIENT_HORIZ;

  /* enable verbose backends */
  putenv("HWLOC_XML_VERBOSE=1");
  putenv("HWLOC_SYNTHETIC_VERBOSE=1");

#ifdef HAVE_SETLOCALE
  setlocale(LC_ALL, "");
#endif

  callname = strrchr(argv[0], '/');
  if (!callname)
    callname = argv[0];
  else
    callname++;
  /* skip argv[0], handle options */
  argc--;
  argv++;

  err = hwloc_topology_init (&topology);
  if (err)
    return EXIT_FAILURE;

  while (argc >= 1)
    {
      opt = 0;
      if (!strcmp (argv[0], "-v") || !strcmp (argv[0], "--verbose")) {
	verbose_mode++;
      } else if (!strcmp (argv[0], "-s") || !strcmp (argv[0], "--silent")) {
	verbose_mode--;
      } else if (!strcmp (argv[0], "-h") || !strcmp (argv[0], "--help")) {
	usage(callname, stdout);
        exit(EXIT_SUCCESS);
      } else if (!strcmp (argv[0], "-f") || !strcmp (argv[0], "--force"))
	overwrite = 1;
      else if (!strcmp (argv[0], "-l") || !strcmp (argv[0], "--logical"))
	logical = 1;
      else if (!strcmp (argv[0], "-p") || !strcmp (argv[0], "--physical"))
	logical = 0;
      else if (!strcmp (argv[0], "-c") || !strcmp (argv[0], "--cpuset"))
	lstopo_show_cpuset = 1;
      else if (!strcmp (argv[0], "-C") || !strcmp (argv[0], "--cpuset-only"))
	lstopo_show_cpuset = 2;
      else if (!strcmp (argv[0], "--taskset")) {
	lstopo_show_taskset = 1;
	if (!lstopo_show_cpuset)
	  lstopo_show_cpuset = 1;
      } else if (!strcmp (argv[0], "--only")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
        if (hwloc_obj_type_sscanf(argv[1], &lstopo_show_only, NULL, NULL, 0) < 0)
	  fprintf(stderr, "Unsupported type `%s' passed to --only, ignoring.\n", argv[1]);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--ignore")) {
	hwloc_obj_type_t type;
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	if (hwloc_obj_type_sscanf(argv[1], &type, NULL, NULL, 0) < 0)
	  fprintf(stderr, "Unsupported type `%s' passed to --ignore, ignoring.\n", argv[1]);
	else if (type == HWLOC_OBJ_PU)
	  lstopo_ignore_pus = 1;
	else
	  hwloc_topology_ignore_type(topology, type);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--no-caches"))
	ignorecache = 2;
      else if (!strcmp (argv[0], "--no-useless-caches"))
	ignorecache = 1;
      else if (!strcmp (argv[0], "--no-icaches"))
	flags &= ~HWLOC_TOPOLOGY_FLAG_ICACHES;
      else if (!strcmp (argv[0], "--whole-system"))
	flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_SYSTEM;
      else if (!strcmp (argv[0], "--no-io"))
	flags &= ~(HWLOC_TOPOLOGY_FLAG_IO_DEVICES | HWLOC_TOPOLOGY_FLAG_IO_BRIDGES);
      else if (!strcmp (argv[0], "--no-bridges"))
	flags &= ~(HWLOC_TOPOLOGY_FLAG_IO_BRIDGES);
      else if (!strcmp (argv[0], "--whole-io"))
	flags |= HWLOC_TOPOLOGY_FLAG_WHOLE_IO;
      else if (!strcmp (argv[0], "--merge"))
	merge = 1;
      else if (!strcmp (argv[0], "--thissystem"))
	flags |= HWLOC_TOPOLOGY_FLAG_IS_THISSYSTEM;
      else if (!strcmp (argv[0], "--restrict")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	restrictstring = strdup(argv[1]);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--export-synthetic-flags")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	lstopo_export_synthetic_flags = (unsigned long) strtoull(argv[1], NULL, 0);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--horiz"))
	for(i=0; i<HWLOC_OBJ_TYPE_MAX; i++)
	  force_orient[i] = LSTOPO_ORIENT_HORIZ;
      else if (!strcmp (argv[0], "--vert"))
	for(i=0; i<HWLOC_OBJ_TYPE_MAX; i++)
	  force_orient[i] = LSTOPO_ORIENT_VERT;
      else if (!strncmp (argv[0], "--horiz=", 8)
	       || !strncmp (argv[0], "--vert=", 7)) {
	enum lstopo_orient_e orient = (argv[0][2] == 'h') ? LSTOPO_ORIENT_HORIZ : LSTOPO_ORIENT_VERT;
	char *tmp = argv[0] + ((argv[0][2] == 'h') ? 8 : 7);
	while (tmp) {
	  char *end = strchr(tmp, ',');
	  hwloc_obj_type_t type;
	  if (end)
	    *end = '\0';
	  if (hwloc_obj_type_sscanf(tmp, &type, NULL, NULL, 0) < 0)
	    fprintf(stderr, "Unsupported type `%s' passed to %s, ignoring.\n", tmp, argv[0]);
	  else
	    force_orient[type] = orient;
	  if (!end)
	    break;
	  tmp = end+1;
        }
      }

      else if (!strcmp (argv[0], "--fontsize")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	fontsize = atoi(argv[1]);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--gridsize")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	gridsize = atoi(argv[1]);
	opt = 1;
      }
      else if (!strcmp (argv[0], "--no-legend")) {
	legend = 0;
      }
      else if (!strcmp (argv[0], "--append-legend")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	lstopo_append_legends = realloc(lstopo_append_legends, (lstopo_append_legends_nr+1) * sizeof(*lstopo_append_legends));
	lstopo_append_legends[lstopo_append_legends_nr] = strdup(argv[1]);
	lstopo_append_legends_nr++;
	opt = 1;
      }

      else if (hwloc_utils_lookup_input_option(argv, argc, &opt,
					       &input, &input_format,
					       callname)) {
	/* nothing to do anymore */

      } else if (!strcmp (argv[0], "--pid")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
	lstopo_pid_number = atoi(argv[1]); opt = 1;
      } else if (!strcmp (argv[0], "--ps") || !strcmp (argv[0], "--top"))
        top = 1;
      else if (!strcmp (argv[0], "--version")) {
          printf("%s %s\n", callname, HWLOC_VERSION);
          exit(EXIT_SUCCESS);
      } else if (!strcmp (argv[0], "--output-format") || !strcmp (argv[0], "--of")) {
	if (argc < 2) {
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	}
        output_format = parse_output_format(argv[1], callname);
        opt = 1;
      } else {
	if (filename) {
	  fprintf (stderr, "Unrecognized option: %s\n", argv[0]);
	  usage (callname, stderr);
	  exit(EXIT_FAILURE);
	} else
	  filename = argv[0];
      }
      argc -= opt+1;
      argv += opt+1;
    }

  if (lstopo_show_only != (hwloc_obj_type_t)-1)
    merge = 0;

  hwloc_topology_set_flags(topology, flags);

  if (ignorecache > 1) {
    hwloc_topology_ignore_type(topology, HWLOC_OBJ_CACHE);
  } else if (ignorecache) {
    hwloc_topology_ignore_type_keep_structure(topology, HWLOC_OBJ_CACHE);
  }
  if (merge)
    hwloc_topology_ignore_all_keep_structure(topology);

  if (input) {
    err = hwloc_utils_enable_input_format(topology, input, input_format, verbose_mode > 1, callname);
    if (err)
      return err;
  }

  if (lstopo_pid_number > 0) {
    lstopo_pid = hwloc_pid_from_number(lstopo_pid_number, 0);
    if (hwloc_topology_set_pid(topology, lstopo_pid)) {
      perror("Setting target pid");
      return EXIT_FAILURE;
    }
  }

  err = hwloc_topology_load (topology);
  if (err) {
    fprintf(stderr, "hwloc_topology_load() failed (%s).\n", strerror(errno));
    return EXIT_FAILURE;
  }

  if (top)
    add_process_objects(topology);

  if (restrictstring) {
    hwloc_bitmap_t restrictset = hwloc_bitmap_alloc();
    if (!strcmp (restrictstring, "binding")) {
      if (lstopo_pid_number > 0)
	hwloc_get_proc_cpubind(topology, lstopo_pid, restrictset, HWLOC_CPUBIND_PROCESS);
      else
	hwloc_get_cpubind(topology, restrictset, HWLOC_CPUBIND_PROCESS);
    } else {
      hwloc_bitmap_sscanf(restrictset, restrictstring);
    }
    err = hwloc_topology_restrict (topology, restrictset, 0);
    if (err) {
      perror("Restricting the topology");
      /* fallthrough */
    }
    hwloc_bitmap_free(restrictset);
    free(restrictstring);
  }

  /* if the output format wasn't enforced, look at the filename */
  if (filename && output_format == LSTOPO_OUTPUT_DEFAULT) {
    if (!strcmp(filename, "-")
	|| !strcmp(filename, "/dev/stdout")) {
      output_format = LSTOPO_OUTPUT_CONSOLE;
    } else {
      char *dot = strrchr(filename, '.');
      if (dot)
        output_format = parse_output_format(dot+1, callname);
      else {
	fprintf(stderr, "Cannot infer output type for file `%s' without any extension, using default output.\n", filename);
	filename = NULL;
      }
    }
  }

  /* if  the output format wasn't enforced, think a bit about what the user probably want */
  if (output_format == LSTOPO_OUTPUT_DEFAULT) {
    if (lstopo_show_cpuset
        || lstopo_show_only != (hwloc_obj_type_t)-1
        || verbose_mode != LSTOPO_VERBOSE_MODE_DEFAULT)
      output_format = LSTOPO_OUTPUT_CONSOLE;
  }

  if (logical == -1) {
    if (output_format == LSTOPO_OUTPUT_CONSOLE)
      logical = 1;
    else if (output_format != LSTOPO_OUTPUT_DEFAULT)
      logical = 0;
  }

  switch (output_format) {
    case LSTOPO_OUTPUT_DEFAULT:
#ifdef LSTOPO_HAVE_GRAPHICS
#if CAIRO_HAS_XLIB_SURFACE && defined HWLOC_HAVE_X11_KEYSYM
      if (getenv("DISPLAY")) {
        if (logical == -1)
          logical = 0;
        output_x11(topology, NULL, overwrite, logical, legend, verbose_mode);
      } else
#endif /* CAIRO_HAS_XLIB_SURFACE */
#ifdef HWLOC_WIN_SYS
      {
        if (logical == -1)
          logical = 0;
        output_windows(topology, NULL, overwrite, logical, legend, verbose_mode);
      }
#endif
#endif /* !LSTOPO_HAVE_GRAPHICS */
#if !defined HWLOC_WIN_SYS || !defined LSTOPO_HAVE_GRAPHICS
      {
        if (logical == -1)
          logical = 1;
        output_console(topology, NULL, overwrite, logical, legend, verbose_mode);
      }
#endif
      break;

    case LSTOPO_OUTPUT_CONSOLE:
      output_console(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
    case LSTOPO_OUTPUT_SYNTHETIC:
      output_synthetic(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
    case LSTOPO_OUTPUT_TEXT:
      output_text(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
    case LSTOPO_OUTPUT_FIG:
      output_fig(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
#ifdef LSTOPO_HAVE_GRAPHICS
# if CAIRO_HAS_PNG_FUNCTIONS
    case LSTOPO_OUTPUT_PNG:
      output_png(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
# endif /* CAIRO_HAS_PNG_FUNCTIONS */
# if CAIRO_HAS_PDF_SURFACE
    case LSTOPO_OUTPUT_PDF:
      output_pdf(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
# endif /* CAIRO_HAS_PDF_SURFACE */
# if CAIRO_HAS_PS_SURFACE
    case LSTOPO_OUTPUT_PS:
      output_ps(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
#endif /* CAIRO_HAS_PS_SURFACE */
#if CAIRO_HAS_SVG_SURFACE
    case LSTOPO_OUTPUT_SVG:
      output_svg(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
#endif /* CAIRO_HAS_SVG_SURFACE */
#endif /* LSTOPO_HAVE_GRAPHICS */
    case LSTOPO_OUTPUT_XML:
      output_xml(topology, filename, overwrite, logical, legend, verbose_mode);
      break;
    default:
      fprintf(stderr, "file format not supported\n");
      usage(callname, stderr);
      exit(EXIT_FAILURE);
  }

  hwloc_topology_destroy (topology);

  for(i=0; i<lstopo_append_legends_nr; i++)
    free(lstopo_append_legends[i]);
  free(lstopo_append_legends);

  return EXIT_SUCCESS;
}
示例#13
0
static void output_header(void *context, int header_class,
			          const HEADER_OPTS *header_info,
			          VSTRING *buf, off_t offset)
{
    SM_STATE *state = (SM_STATE *) context;
    TOK822 *tree;
    TOK822 **addr_list;
    TOK822 **tpp;
    ARGV   *rcpt;
    char   *start;
    char   *line;
    char   *next_line;
    ssize_t len;

    /*
     * Parse the header line, and save copies of recipient addresses in the
     * appropriate place.
     */
    if (header_class == MIME_HDR_PRIMARY
	&& header_info
	&& (header_info->flags & HDR_OPT_RECIP)
	&& (header_info->flags & HDR_OPT_EXTRACT)
	&& (state->resent == 0 || (header_info->flags & HDR_OPT_RR))) {
	if (header_info->flags & HDR_OPT_RR) {
	    rcpt = state->resent_recip;
	    if (state->resent == 0)
		state->resent = 1;
	} else
	    rcpt = state->recipients;
	tree = tok822_parse(STR(buf) + strlen(header_info->name) + 1);
	addr_list = tok822_grep(tree, TOK822_ADDR);
	for (tpp = addr_list; *tpp; tpp++) {
	    tok822_internalize(state->temp, tpp[0]->head, TOK822_STR_DEFL);
	    argv_add(rcpt, STR(state->temp), (char *) 0);
	}
	myfree((void *) addr_list);
	tok822_free_tree(tree);
    }

    /*
     * Pipe the unmodified message header through the header line folding
     * routine, and ensure that long lines are chopped appropriately.
     */
    for (line = start = STR(buf); line; line = next_line) {
	next_line = split_at(line, '\n');
	len = next_line ? next_line - line - 1 : strlen(line);
	do {
	    if (len > var_line_limit) {
		output_text(context, REC_TYPE_CONT, line, var_line_limit, offset);
		line += var_line_limit;
		len -= var_line_limit;
		offset += var_line_limit;
	    } else {
		output_text(context, REC_TYPE_NORM, line, len, offset);
		offset += len;
		break;
	    }
	} while (len > 0);
	offset += 1;
    }
}
示例#14
0
文件: task3.c 项目: tridcatov/publicc
int main(int argc, char ** argv) {
    text txt = input_text();
    process_text(txt);
    output_text(txt);
    return 0;
}
示例#15
0
static void uncrustify_file(const file_mem& fm, FILE *pfout,
                            const char *parsed_file)
{
   const deque<int>& data = fm.data;

   /* Save off the encoding and whether a BOM is required */
   cpd.bom = fm.bom;
   cpd.enc = fm.enc;
   if (cpd.settings[UO_utf8_force].b ||
       ((cpd.enc == ENC_BYTE) && cpd.settings[UO_utf8_byte].b))
   {
      cpd.enc = ENC_UTF8;
   }
   argval_t av;
   switch (cpd.enc)
   {
   case ENC_UTF8:
      av = cpd.settings[UO_utf8_bom].a;
      break;

   case ENC_UTF16_LE:
   case ENC_UTF16_BE:
      av = AV_FORCE;
      break;

   default:
      av = AV_IGNORE;
      break;
   }
   if (av == AV_REMOVE)
   {
      cpd.bom = false;
   }
   else if (av != AV_IGNORE)
   {
      cpd.bom = true;
   }

   /* Check for embedded 0's (represents a decoding failure or corrupt file) */
   for (int idx = 0; idx < (int)data.size() - 1; idx++)
   {
      if (data[idx] == 0)
      {
         LOG_FMT(LERR, "An embedded 0 was found in '%s'.\n", cpd.filename);
         LOG_FMT(LERR, "The file may be encoded in an unsupported Unicode format.\n");
         LOG_FMT(LERR, "Aborting.\n");
         cpd.error_count++;
         return;
      }
   }

   uncrustify_start(data);

   /**
    * Done with detection. Do the rest only if the file will go somewhere.
    * The detection code needs as few changes as possible.
    */
   if (pfout != NULL)
   {
      /**
       * Add comments before function defs and classes
       */
      if (cpd.func_hdr.data.size() > 0)
      {
         add_func_header(CT_FUNC_DEF, cpd.func_hdr);
      }
      if (cpd.class_hdr.data.size() > 0)
      {
         add_func_header(CT_CLASS, cpd.class_hdr);
      }
      if (cpd.oc_msg_hdr.data.size() > 0)
      {
         add_msg_header(CT_OC_MSG_DECL, cpd.oc_msg_hdr);
      }

      /**
       * Change virtual braces into real braces...
       */
      do_braces();

      /* Scrub extra semicolons */
      if (cpd.settings[UO_mod_remove_extra_semicolon].b)
      {
         remove_extra_semicolons();
      }

      /* Remove unnecessary returns */
      if (cpd.settings[UO_mod_remove_empty_return].b)
      {
         remove_extra_returns();
      }

      /**
       * Add parens
       */
      do_parens();

      /**
       * Modify line breaks as needed
       */
      bool first = true;
      int  old_changes;

      if (cpd.settings[UO_nl_remove_extra_newlines].n == 2)
      {
         newlines_remove_newlines();
      }
      cpd.pass_count = 3;
      do
      {
         old_changes = cpd.changes;

         LOG_FMT(LNEWLINE, "Newline loop start: %d\n", cpd.changes);

         newlines_cleanup_dup();
         newlines_cleanup_braces(first);
         if (cpd.settings[UO_nl_after_multiline_comment].b)
         {
            newline_after_multiline_comment();
         }
         newlines_insert_blank_lines();
         if (cpd.settings[UO_pos_bool].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_BOOL, cpd.settings[UO_pos_bool].tp);
         }
         if (cpd.settings[UO_pos_compare].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_COMPARE, cpd.settings[UO_pos_compare].tp);
         }
         if (cpd.settings[UO_pos_conditional].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_COND_COLON, cpd.settings[UO_pos_conditional].tp);
            newlines_chunk_pos(CT_QUESTION, cpd.settings[UO_pos_conditional].tp);
         }
         if (cpd.settings[UO_pos_comma].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_COMMA, cpd.settings[UO_pos_comma].tp);
         }
         if (cpd.settings[UO_pos_assign].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_ASSIGN, cpd.settings[UO_pos_assign].tp);
         }
         if (cpd.settings[UO_pos_arith].tp != TP_IGNORE)
         {
            newlines_chunk_pos(CT_ARITH, cpd.settings[UO_pos_arith].tp);
         }
         newlines_class_colon_pos();
         if (cpd.settings[UO_nl_squeeze_ifdef].b)
         {
            newlines_squeeze_ifdef();
         }
         do_blank_lines();
         newlines_eat_start_end();
         newlines_cleanup_dup();
         first = false;
      } while ((old_changes != cpd.changes) && (cpd.pass_count-- > 0));

      mark_comments();

      /**
       * Add balanced spaces around nested params
       */
      if (cpd.settings[UO_sp_balance_nested_parens].b)
      {
         space_text_balance_nested_parens();
      }

      /* Scrub certain added semicolons */
      if (((cpd.lang_flags & LANG_PAWN) != 0) &&
          cpd.settings[UO_mod_pawn_semicolon].b)
      {
         pawn_scrub_vsemi();
      }

      /* Sort imports/using/include */
      if (cpd.settings[UO_mod_sort_import].b ||
          cpd.settings[UO_mod_sort_include].b ||
          cpd.settings[UO_mod_sort_using].b)
      {
         sort_imports();
      }

      /**
       * Fix same-line inter-chunk spacing
       */
      space_text();

      /**
       * Do any aligning of preprocessors
       */
      if (cpd.settings[UO_align_pp_define_span].n > 0)
      {
         align_preprocessor();
      }

      /**
       * Indent the text
       */
      indent_preproc();
      indent_text();

      /* Insert trailing comments after certain close braces */
      if ((cpd.settings[UO_mod_add_long_switch_closebrace_comment].n > 0) ||
          (cpd.settings[UO_mod_add_long_function_closebrace_comment].n > 0))
      {
         add_long_closebrace_comment();
      }

      /* Insert trailing comments after certain preprocessor conditional blocks */
      if ((cpd.settings[UO_mod_add_long_ifdef_else_comment].n > 0) ||
          (cpd.settings[UO_mod_add_long_ifdef_endif_comment].n > 0))
      {
         add_long_preprocessor_conditional_block_comment();
      }

      /**
       * Align everything else, reindent and break at code_width
       */
      first          = true;
      cpd.pass_count = 3;
      do
      {
         align_all();
         indent_text();
         old_changes = cpd.changes;
         if (cpd.settings[UO_code_width].n > 0)
         {
            LOG_FMT(LNEWLINE, "Code_width loop start: %d\n", cpd.changes);

            do_code_width();
            if ((old_changes != cpd.changes) && first)
            {
               /* retry line breaks caused by splitting 1-liners */
               newlines_cleanup_braces(false);
               newlines_insert_blank_lines();
               first = false;
            }
         }
      } while ((old_changes != cpd.changes) && (cpd.pass_count-- > 0));

      /**
       * And finally, align the backslash newline stuff
       */
      align_right_comments();
      if (cpd.settings[UO_align_nl_cont].b)
      {
         align_backslash_newline();
      }

      /**
       * Now render it all to the output file
       */
      output_text(pfout);
   }

   /* Special hook for dumping parsed data for debugging */
   if (parsed_file != NULL)
   {
      FILE *p_file = fopen(parsed_file, "w");
      if (p_file != NULL)
      {
         output_parsed(p_file);
         fclose(p_file);
      }
      else
      {
         LOG_FMT(LERR, "%s: Failed to open '%s' for write: %s (%d)\n",
                 __func__, parsed_file, strerror(errno), errno);
      }
   }

   uncrustify_end();
}
示例#16
0
/*
 * The entry point for the prodreg legacy command line interface.  This
 * interface (the name of the binary and its options and arguments)
 * cannot change without breaking old clients.
 */
int
main(int argc, char **argv)
{
	/*
	 * Valid arguments:
	 *    <none> - launch sdtprodreg
	 *    "swing" - launch sdtprodreg -swing
	 *    "awt"   - launch sdtprodreg -awt
	 *    "register"
	 *    "list"
	 *    "lookup <mnemonic> [id]"
	 *    "lookupProducts <mnemonic>"
	 *    "lookupComponents <mnemonic> <id>"
	 *    "uninstall <mnemonic> <fslocation>" - launch sdtprodreg -uninstall
	 *    "unregister <mnemonic> <fslocation>"
	 */
	int index = 0;
	String_map *arg_map = _wsreg_stringmap_create(commands);

	setlocale(LC_ALL, "");
	textdomain(TEXT_DOMAIN);

	/*
	 * Set the alternate root from the environment variable.
	 * This may be overridden with a "-R" flag.
	 */
	alternate_root = getenv(ALTERNATE_ROOT_VARIABLE);
	if (alternate_root != NULL) {
		wsreg_set_alternate_root(alternate_root);
	} else {
		alternate_root = "";
	}

	debug_filename = getenv(DEBUG_ENV_VARIABLE);
	if (debug_filename != NULL) {
		debug_on = TRUE;
	}

	log_message("COMMAND", "prodreg ", 0);

	for (index = 1; index < argc; index++)
		log_message(NULL, "%s ", 1, argv[index]);
	log_message(NULL, "\n", 0);

	if (!(argc > 1)) {
		/*
		 * No arguments; launch the viewer.
		 */
		char *prodreg_args[] = {
			"-R",
			NULL,
			NULL};
		prodreg_args[1] = alternate_root;
		log_message("COMMAND", " < no arg>\n", 0);
		launch_sdtprodreg(prodreg_args);
	} else {
		index = 1;
		while (index < argc) {
			int command = arg_map->get_id(arg_map, argv[index]);
			switch (command) {
			case PRDRG_SWING:
			{
				char *prodreg_args[] = {
					"-R",
					NULL,
					"-swing",
					NULL};
				prodreg_args[1] = alternate_root;
				launch_sdtprodreg(prodreg_args);
				break;
			}

			case PRDRG_AWT:
			{
				char *prodreg_args[] = {
					"-R",
					NULL,
					"-awt",
					NULL};
				prodreg_args[1] = alternate_root;
				launch_sdtprodreg(prodreg_args);
				break;
			}

			case PRDRG_REGISTER:
			{
				List *arg_list = _wsreg_list_create();
				char *id = NULL;
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
					alternate_root);

				/*
				 * Make a list of the remaining
				 * arguments.
				 */
				if (argc > index + 1) {
					for (++index; index < argc;
						index++) {
						arg_list->add_element(
							arg_list,
							    argv[index]);
					}
				}
				switch (arg_list->size(arg_list)) {
				case 0:
					id =
					    register_articles(arg_list);
					output_text("\n", 0);
					break;

				case 2:
				case 4:
					id = register_articles(
						arg_list);
					output_text("%s\n", 1, id);
					break;

				default:
					syntax_error(argc, argv,
					    PRODREG_BAD_ARG_COUNT);
				}
				fflush(stdout);
				arg_list->free(arg_list, NULL);
				break;
			}

			case PRDRG_LIST: {
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
					alternate_root);

				if (argc > index + 3) {
					char *selector;
					List *fields =
					    _wsreg_list_create();

					index++;
					selector = argv[index];

					/*
					 * Build a list of fields we
					 * are interested in.
					 */
					for (++index; index < argc;
						++index) {
						fields->add_element(
							fields,
							    argv[index]);
					}

					/*
					 * list_articles will print
					 * the requested article
					 * information.
					 */
					list_articles(selector,
					    fields);
				} else {
					syntax_error(argc, argv,
					    PRODREG_BAD_LIST);
				}
				break;
			}

			case PRDRG_LOOKUP:
			{
				char *mnemonic = NULL;
				char *id = NULL;
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
					alternate_root);

				if (argc > index + 1)
					mnemonic = argv[++index];
				if (argc > index + 1)
					id = argv[++index];
				if (mnemonic == NULL) {
					syntax_error(argc, argv,
					    PRODREG_BAD_LOOKUP);
				} else {
					lookup(mnemonic, id);
				}
				break;
			}

			case PRDRG_LOOKUP_PRODUCTS:
			{
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
				    alternate_root);

				if (argc > index + 1) {
					List *mnemonics =
					    _wsreg_list_create();
					for (++index; index < argc;
						index++) {
						mnemonics->add_element(
							mnemonics,
							    argv[index]);
					}
					lookup_products(mnemonics);
					mnemonics->free(mnemonics,
					    NULL);
				} else {
					syntax_error(argc, argv,
					    PRODREG_BAD_LOOKUP_PROD);
				}
				break;
			}

			case PRDRG_LOOKUP_COMPONENTS:
			{
				char *mnemonic = NULL;
				char *id = NULL;
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
				    alternate_root);

				if (argc > index + 1)
					mnemonic = argv[++index];
				if (argc > index + 1)
					id = argv[++index];
				if (mnemonic == NULL || id == NULL) {
					syntax_error(argc, argv,
					    PRODREG_BAD_LOOKUP_COMP);
				} else {
					lookup_components(mnemonic, id);
				}
				break;
			}

			case PRDRG_UNINSTALL:
			{
				char *mnemonic = NULL;
				char *id = NULL;
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
				    alternate_root);

				if (argc > index + 1)
					mnemonic = argv[++index];
				if (argc > index + 1)
					id = argv[++index];
				if (mnemonic == NULL ||
				    id == NULL) {
					syntax_error(argc, argv,
					    PRODREG_BAD_UNINSTALL_ARGS);
				} else {
					uninstall(mnemonic, id);
				}
				break;
			}

			case PRDRG_UNREGISTER:
			{
				char *mnemonic = NULL;
				char *location = NULL;
				(void) wsreg_initialize(WSREG_INIT_NORMAL,
				    alternate_root);

				if (argc > index + 1)
					mnemonic = argv[++index];
				if (argc > index + 1)
					location = argv[++index];
				if (mnemonic == NULL ||
				    location == NULL) {
					/*
					 * Not enough information to perform
					 * the unregister.
					 */
					syntax_error(argc, argv,
					    PRODREG_BAD_UNREGISTER_ARGS);
				} else {
					unregister_articles(mnemonic, location);
				}
				break;
			}

			case PRDRG_VERSION:
				output_text("%s\n\n", 1,
				    PRODREG_INTERFACE_VERSION);
				fflush(stdout);
				break;

			case PRDRG_ALTERNATE_ROOT:
			{
				if (argc > index + 1) {
					/*
					 * The next argument is
					 * interpreted as the
					 * alternate root.  The
					 * command line overrides
					 * the environment variable.
					 */
					alternate_root = argv[++index];
					wsreg_set_alternate_root(
						alternate_root);
				}
				break;
			}

			case PRDRG_HELP:
				output_text(PRODREG_HELP, 0);
				break;

			default:
			{
				char *message = wsreg_malloc(sizeof (char) *
				    (strlen(PRODREG_BAD_SUBCOMMAND) +
					strlen(argv[index]) + 1));
				log_message("DEBUG", "bad command %s\n", 1,
				    argv[index]);
				(void) sprintf(message,
				    PRODREG_BAD_SUBCOMMAND,
				    argv[index]);
				syntax_error(argc, argv,
				    message);
				free(message);
				exit(1);
			}
			}
			index++;
		}
	}
	arg_map->free(arg_map);
	log_message("DEBUG", "prodreg exit\n", 0);
	return (0);
}
示例#17
0
static void
insert_diversion_helper (m4_diversion *diversion)
{
  /* Effectively undivert only if an output stream is active.  */
  if (output_diversion)
    {
      if (diversion->size)
        {
          if (!output_diversion->u.file)
            {
              /* Transferring diversion metadata is faster than
                 copying contents.  */
              assert (!output_diversion->used && output_diversion != &div0
                      && !output_file);
              output_diversion->u.buffer = diversion->u.buffer;
              output_diversion->size = diversion->size;
              output_cursor = diversion->u.buffer + diversion->used;
              output_unused = diversion->size - diversion->used;
              diversion->u.buffer = NULL;
            }
          else
            {
              /* Avoid double-charging the total in-memory size when
                 transferring from one in-memory diversion to
                 another.  */
              total_buffer_size -= diversion->size;
              output_text (diversion->u.buffer, diversion->used);
            }
        }
      else if (!output_diversion->u.file)
        {
          /* Transferring diversion metadata is faster than copying
             contents.  */
          assert (!output_diversion->used && output_diversion != &div0
                  && !output_file);
          output_diversion->u.file = m4_tmprename (diversion->divnum,
                                                   output_diversion->divnum);
          output_diversion->used = 1;
          output_file = output_diversion->u.file;
          diversion->u.file = NULL;
          diversion->size = 1;
        }
      else
        {
          if (!diversion->u.file)
            diversion->u.file = m4_tmpopen (diversion->divnum, true);
          insert_file (diversion->u.file);
        }

      output_current_line = -1;
    }

  /* Return all space used by the diversion.  */
  if (diversion->size)
    {
      if (!output_diversion)
        total_buffer_size -= diversion->size;
      free (diversion->u.buffer);
      diversion->size = 0;
    }
  else
    {
      if (diversion->u.file)
        {
          FILE *file = diversion->u.file;
          diversion->u.file = NULL;
          if (m4_tmpclose (file, diversion->divnum) != 0)
            m4_error (0, errno,
                      _("cannot clean temporary file for diversion"));
        }
      if (m4_tmpremove (diversion->divnum) != 0)
        M4ERROR ((0, errno, "cannot clean temporary file for diversion"));
    }
  diversion->used = 0;
  gl_oset_remove (diversion_table, diversion);
  diversion->u.next = free_list;
  free_list = diversion;
}
示例#18
0
static void uncrustify_file(const char *data, int data_len, FILE *pfout,
                            const char *parsed_file)
{
   uncrustify_start(data, data_len);

   /**
    * Done with detection. Do the rest only if the file will go somewhere.
    * The detection code needs as few changes as possible.
    */
   if (pfout != NULL)
   {
      /**
       * Add comments before function defs and classes
       */
      if (cpd.func_hdr.data != NULL)
      {
         add_func_header(CT_FUNC_DEF, cpd.func_hdr);
      }
      if (cpd.class_hdr.data != NULL)
      {
         add_func_header(CT_CLASS, cpd.class_hdr);
      }

      /**
       * Change virtual braces into real braces...
       */
      do_braces();

      /* Scrub extra semicolons */
      if (cpd.settings[UO_mod_remove_extra_semicolon].b)
      {
         remove_extra_semicolons();
      }

      /* Remove unnecessary returns */
      if (cpd.settings[UO_mod_remove_empty_return].b)
      {
         remove_extra_returns();
      }

      /**
       * Add parens
       */
      do_parens();

      /**
       * Insert line breaks as needed
       */
      do_blank_lines();
      newlines_cleanup_braces();
      if (cpd.settings[UO_nl_after_multiline_comment].b)
      {
         newline_after_multiline_comment();
      }
      newlines_insert_blank_lines();
      if (cpd.settings[UO_pos_bool].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_BOOL, cpd.settings[UO_pos_bool].tp);
      }
      if (cpd.settings[UO_pos_compare].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_COMPARE, cpd.settings[UO_pos_compare].tp);
      }
      if (cpd.settings[UO_pos_conditional].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_COND_COLON, cpd.settings[UO_pos_conditional].tp);
         newlines_chunk_pos(CT_QUESTION, cpd.settings[UO_pos_conditional].tp);
      }
      if (cpd.settings[UO_pos_comma].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_COMMA, cpd.settings[UO_pos_comma].tp);
      }
      if (cpd.settings[UO_pos_assign].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_ASSIGN, cpd.settings[UO_pos_assign].tp);
      }
      if (cpd.settings[UO_pos_arith].tp != TP_IGNORE)
      {
         newlines_chunk_pos(CT_ARITH, cpd.settings[UO_pos_arith].tp);
      }
      newlines_class_colon_pos();
      if (cpd.settings[UO_nl_squeeze_ifdef].b)
      {
         newlines_squeeze_ifdef();
      }
      newlines_eat_start_end();
      newlines_cleanup_dup();

      mark_comments();

      /**
       * Add balanced spaces around nested params
       */
      if (cpd.settings[UO_sp_balance_nested_parens].b)
      {
         space_text_balance_nested_parens();
      }

      /* Scrub certain added semicolons */
      if (((cpd.lang_flags & LANG_PAWN) != 0) &&
          cpd.settings[UO_mod_pawn_semicolon].b)
      {
         pawn_scrub_vsemi();
      }

      /* Sort imports/using/include */
      if (cpd.settings[UO_mod_sort_import].b ||
          cpd.settings[UO_mod_sort_include].b ||
          cpd.settings[UO_mod_sort_using].b)
      {
         sort_imports();
      }

      /**
       * Fix same-line inter-chunk spacing
       */
      space_text();

      /**
       * Do any aligning of preprocessors
       */
      if (cpd.settings[UO_align_pp_define_span].n > 0)
      {
         align_preprocessor();
      }

      /**
       * Indent the text
       */
      indent_preproc();
      indent_text();

      /* Insert trailing comments after certain close braces */
      if ((cpd.settings[UO_mod_add_long_switch_closebrace_comment].n > 0) ||
          (cpd.settings[UO_mod_add_long_function_closebrace_comment].n > 0))
      {
         add_long_closebrace_comment();
      }

      /* Insert trailing comments after certain preprocessor conditional blocks */
      if ((cpd.settings[UO_mod_add_long_ifdef_else_comment].n > 0) ||
          (cpd.settings[UO_mod_add_long_ifdef_endif_comment].n > 0))
      {
         add_long_preprocessor_conditional_block_comment();
      }

      /**
       * Aligning everything else and reindent
       */
      align_all();
      indent_text();

      if (cpd.settings[UO_code_width].n > 0)
      {
         int max_passes = 3;
         int prev_changes;
         do
         {
            prev_changes = cpd.changes;
            do_code_width();
            if (prev_changes != cpd.changes)
            {
               align_all();
               indent_text();
            }
         } while ((prev_changes != cpd.changes) && (--max_passes > 0));
      }

      /**
       * And finally, align the backslash newline stuff
       */
      align_right_comments();
      if (cpd.settings[UO_align_nl_cont].b)
      {
         align_backslash_newline();
      }

      /**
       * Now render it all to the output file
       */
      output_text(pfout);
   }

   /* Special hook for dumping parsed data for debugging */
   if (parsed_file != NULL)
   {
      FILE *p_file = fopen(parsed_file, "w");
      if (p_file != NULL)
      {
         output_parsed(p_file);
         fclose(p_file);
      }
      else
      {
         LOG_FMT(LERR, "%s: Failed to open '%s' for write: %s (%d)\n",
                 __func__, parsed_file, strerror(errno), errno);
      }
   }

   uncrustify_end();
}