Exemple #1
0
void	conversion_s(t_printf *t)
{
	char	*s;

	if (t->flags.is_long && !t->flags.is_long_double)
		return (conversion_big_s(t));
	s = arg_get_string(t);
	if (s == NULL)
		to_string(t, ft_strdup("(null)"));
	else
		to_string(t, ft_strdup(s));
}
Exemple #2
0
int main(int argc, char* argv[])
{
  int i,j;

  int   interactive  = 0;
  char* outfile      = 0;
  char* defaultfile  = 0;
  char* module       = 0;

  /* we set up the defaults */

  for (j=0; modules[j].name; j++)
    modules[j].state = modules[j].inc_exc;

  for (i=1; i<argc; i++) {

    /*fprintf(stderr,"argv[%d]\n",i);*/

    if (arg_get_boolean(argv[i],"help"       ,&j /*dummy*/ )) {
      fprintf(stderr,"  \n");
      fprintf(stderr,"usage: %s [options]\n",argv[0]);
      fprintf(stderr,"\n");
      fprintf(stderr,"  This program builds a makefile and a configuration\n");
      fprintf(stderr,"  include file for %s according to a selection\n",prefix);
      fprintf(stderr,"  of modules.\n");
      fprintf(stderr,"  With no options, it builds a configuration according\n");
      fprintf(stderr,"  to built-in default rules. The options are:\n");
      fprintf(stderr,"  variant=<name>        an OSTYPE variant\n");
      /*
      fprintf(stderr,"  makefile=<filename>   overrides the built-in name (%s)\n",makefile);
      fprintf(stderr,"  configfile=<filename> overrides the built-in name (%s)\n",configfile);
      */
      fprintf(stderr,"  win32                 builds a makefile for nmake\n");
      fprintf(stderr,"                        (otherwise to unix/GNU makes)\n");
      fprintf(stderr,"  interactive           asks the users which modules to select\n");
      fprintf(stderr,"  in=<filename>         module selection taken from a file\n");
      fprintf(stderr,"  out=<filename>        module selection stored to a file\n");
      fprintf(stderr,"  module=<modulename>   selects a module\n");
      fprintf(stderr,"  module=!<modulename>  de-selects a module\n");
      fprintf(stderr,"  \n");
      fprintf(stderr,"  There can be several module= options, and they should\n");
      fprintf(stderr,"  normally follow in= options; the module= options can\n");
      fprintf(stderr,"  then override selections that the file makes.\n");
      fprintf(stderr,"  \n");
      fprintf(stderr,"  Configuration files have the following structure:\n");
      fprintf(stderr,"  ...\n");
      fprintf(stderr,"  %s_CONFIG_BEGIN\n",prefix);
      fprintf(stderr,"  %s_CONFIG_DEFAULT [ON/OFF]\n",prefix);
      fprintf(stderr,"  %s_CONFIG_MODULE SOME_MODULE\n",prefix);
      fprintf(stderr,"  %s_CONFIG_MODULE !ANOTHER_MODULE\n",prefix);
      fprintf(stderr,"  %s_CONFIG_MODULE A_THIRD_MODULE\n",prefix);
      fprintf(stderr,"  %s_CONFIG_END\n",prefix);
      fprintf(stderr,"  ...\n");
      fprintf(stderr,"  These lines can be embedded in C comments, etc, but\n");
      fprintf(stderr,"  they must begin at the beginnig of lines. The second\n");
      fprintf(stderr,"  line in the example allows you to select or deselct\n");
      fprintf(stderr,"  all the modules together.\n");
      fprintf(stderr,"  \n");
      fprintf(stderr,"  The list of modules (and whether they are included in\n");
      fprintf(stderr,"  the default configuration is:\n");
      fprintf(stderr,"  \n");
      for (j=0; modules[j].name; j++)
      fprintf(stderr,"  %-20s %s\n",modules[j].name,
	     modules[j].inc_exc ? "included" : "excluded");
      fprintf(stderr,"  \n");
      exit(0);
     }

    if (arg_get_string (argv[i],"variant="   ,&variant     )) continue;
    /*
    if (arg_get_string (argv[i],"makefile="  ,&makefile    )) continue;
    if (arg_get_string (argv[i],"configfile=",&configfile  )) continue;
    */
    if (arg_get_string (argv[i],"out="       ,&outfile     )) continue;

    if (arg_get_boolean(argv[i],"win32"      ,&win32       )) {
      if (win32) pathsep = '\\';
      continue;
    }

    if (arg_get_boolean(argv[i],"interactive",&interactive )) {
      continue;
    }

    if (arg_get_string (argv[i],"in="        ,&defaultfile )) {
      parse_infile(defaultfile);
      mark_dependants();
      continue;
    }

    if (arg_get_string (argv[i],"module="    ,&module      )) {
      parse_modulename(module);
      mark_dependants();
      continue;
    }

    fprintf(stderr,"error: command line argument <%s> is invalid\n",argv[i]);
    exit(1);
  }

  ostype = getenv("OSTYPE");
  if (!ostype) {
    fprintf(stderr,"error: the environment variable OSTYPE is not set\n");
    exit(1);
  }

  if (interactive) user_input();

  for (i=0; modules[i].name; i++)
    if (modules[i].state)
      build_flags |= modules[i].build_flags;

  map_sources_to_targets();

  emit_configfile(get_configuration_name(defaultfile));

  emit_makefile(get_configuration_name(defaultfile));

  if (outfile)
    emit_outfile(outfile);

  printf("%s%s\n",ostype,variant?variant:"");

  return 0;
}