⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mkisofs.c

📁 刻录光盘的程序
💻 C
📖 第 1 页 / 共 4 页
字号:
      fprintf(stderr, "Using \"%s\"\n", filename);    }  /* OK, we got it.  Now read in the lines and parse them */  linum = 0;  while (fgets(linebuffer, sizeof(linebuffer), rcfile))    {      char *name;      char *name_end;      ++linum;      /* skip any leading white space */	pnt = linebuffer;      while (*pnt == ' ' || *pnt == '\t')	++pnt;      /* If we are looking at a # character, this line is a comment. */	if (*pnt == '#')	  continue;      /* The name should begin in the left margin.  Make sure it is in	 upper case.  Stop when we see white space or a comment. */	name = pnt;      while (*pnt && isalpha((unsigned char)*pnt))	{	  if(islower((unsigned char)*pnt))	    *pnt = toupper((unsigned char)*pnt);	  pnt++;	}      if (name == pnt)	{	  fprintf(stderr, "%s:%d: name required\n", filename, linum);	  continue;	}      name_end = pnt;      /* Skip past white space after the name */      while (*pnt == ' ' || *pnt == '\t')	pnt++;      /* silently ignore errors in the rc file. */      if (*pnt != '=')	{	  fprintf(stderr, "%s:%d: equals sign required\n", filename, linum);	  continue;	}      /* Skip pas the = sign, and any white space following it */      pnt++; /* Skip past '=' sign */      while (*pnt == ' ' || *pnt == '\t')	pnt++;      /* now it is safe to NUL terminate the name */	*name_end = 0;      /* Now get rid of trailing newline */      pnt1 = pnt;      while (*pnt1)	{	  if (*pnt1 == '\n')	    {	      *pnt1 = 0;	      break;	    }	  pnt1++;	};      /* OK, now figure out which option we have */      for(rco = rcopt; rco->tag; rco++) {	if(strcmp(rco->tag, name) == 0)	  {	    *rco->variable = strdup(pnt);	    break;	  };      }      if (rco->tag == NULL)	{	  fprintf(stderr, "%s:%d: field name \"%s\" unknown\n", filename, linum,		  name);	}     }  if (ferror(rcfile))#ifdef	USE_LIBSCHILY    errmsg("Read error on '%s'.\n", filename);#else    perror(filename);#endif  fclose(rcfile);}char * path_table_l = NULL;char * path_table_m = NULL;char * jpath_table_l = NULL;char * jpath_table_m = NULL;int goof = 0;#ifndef TRUE#define TRUE 1#endif#ifndef FALSE#define FALSE 0#endifvoid usage(excode)	int	excode;{  const char * program_name = "mkisofs";#if 0	fprintf(stderr,"Usage:\n");	fprintf(stderr,"mkisofs [-o outfile] [-R] [-V volid] [-v] [-a] \[-T]\n [-l] [-d] [-V] [-D] [-L] [-p preparer]""[-P publisher] [ -A app_id ] [-z] \n \[-b boot_image_name] [-c boot_catalog-name] \[-x path -x path ...] path\n");#endif  int i;/*  const char **targets, **pp;*/  fprintf (stderr, "Usage: %s [options] file...\n", program_name);  fprintf (stderr, "Options:\n");  for (i = 0; i < OPTION_COUNT; i++)    {      if (ld_options[i].doc != NULL)	{	  int comma;	  int len;	  int j;	  fprintf (stderr, "  ");	  comma = FALSE;	  len = 2;	  j = i;	  do	    {	      if (ld_options[j].shortopt != '\0'		  && ld_options[j].control != NO_HELP)		{		  fprintf (stderr, "%s-%c", comma ? ", " : "", ld_options[j].shortopt);		  len += (comma ? 2 : 0) + 2;		  if (ld_options[j].arg != NULL)		    {		      if (ld_options[j].opt.has_arg != optional_argument)			{			  fprintf (stderr, " ");			  ++len;			}		      fprintf (stderr, "%s", ld_options[j].arg);		      len += strlen (ld_options[j].arg);		    }		  comma = TRUE;		}	      ++j;	    }	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);	  j = i;	  do	    {	      if (ld_options[j].opt.name != NULL		  && ld_options[j].control != NO_HELP)		{		  fprintf (stderr, "%s-%s%s",			  comma ? ", " : "",			  ld_options[j].control == TWO_DASHES ? "-" : "",			  ld_options[j].opt.name);		  len += ((comma ? 2 : 0)			  + 1			  + (ld_options[j].control == TWO_DASHES ? 1 : 0)			  + strlen (ld_options[j].opt.name));		  if (ld_options[j].arg != NULL)		    {		      fprintf (stderr, " %s", ld_options[j].arg);		      len += 1 + strlen (ld_options[j].arg);		    }		  comma = TRUE;		}	      ++j;	    }	  while (j < OPTION_COUNT && ld_options[j].doc == NULL);	  if (len >= 30)	    {	      fprintf (stderr, "\n");	      len = 0;	    }	  for (; len < 30; len++)	    fputc (' ', stderr);	  fprintf (stderr, "%s\n", ld_options[i].doc);	}    }  exit(excode);}/*  * Fill in date in the iso9660 format  * * The standards  state that the timezone offset is in multiples of 15 * minutes, and is what you add to GMT to get the localtime.  The U.S. * is always at a negative offset, from -5h to -8h (can vary a little * with DST,  I guess).  The Linux iso9660 filesystem has had the sign * of this wrong for ages (mkisofs had it wrong too for the longest time). */int FDECL2(iso9660_date,char *, result, time_t, crtime){  struct tm *local;  local = localtime(&crtime);  result[0] = local->tm_year;  result[1] = local->tm_mon + 1;  result[2] = local->tm_mday;  result[3] = local->tm_hour;  result[4] = local->tm_min;  result[5] = local->tm_sec;  /*    * Must recalculate proper timezone offset each time,   * as some files use daylight savings time and some don't...    */  result[6] = local->tm_yday;	/* save yday 'cause gmtime zaps it */  local = gmtime(&crtime);  local->tm_year -= result[0];  local->tm_yday -= result[6];  local->tm_hour -= result[3];  local->tm_min -= result[4];  if (local->tm_year < 0)     {      local->tm_yday = -1;    }  else     {      if (local->tm_year > 0) local->tm_yday = 1;    }  result[6] = -(local->tm_min + 60*(local->tm_hour + 24*local->tm_yday)) / 15;  return 0;}/* hide "./rr_moved" if all its contents are hidden */static voidhide_reloc_dir(){	struct directory_entry * s_entry;	for (s_entry = reloc_dir->contents; s_entry; s_entry = s_entry->next) {	    if(strcmp(s_entry->name,".")==0 || strcmp(s_entry->name,"..")==0)		continue;	    if((s_entry->de_flags & INHIBIT_ISO9660_ENTRY) == 0)		return;	}	/* all entries are hidden, so hide this directory */	reloc_dir->dir_flags |= INHIBIT_ISO9660_ENTRY;	reloc_dir->self->de_flags |= INHIBIT_ISO9660_ENTRY;}/* get pathnames from the command line, and then from given file */static char *FDECL6(get_pnames, int, argc, char **, argv, int, opt, char *, pname, int, pnsize, FILE *, fp){	if (opt < argc)	    return (argv[opt]);	if (fp == NULL)	    return ((char *)0);	if (fgets(pname, pnsize, fp)) {		pname[strlen(pname)-1] = '\0';	/* Discard newline */		return (pname);	}	return ((char *)0);}extern char * cdrecord_data;int FDECL2(main, int, argc, char **, argv){  struct directory_entry de;#ifdef HAVE_SBRK  unsigned long mem_start;#endif  struct stat statbuf;  char * merge_image = NULL;  struct iso_directory_record * mrootp = NULL;  struct output_fragment * opnt;  int longind;  char shortopts[OPTION_COUNT * 3 + 2];  struct option longopts[OPTION_COUNT + 1];  int c;  char *log_file = 0;  char * node;  char *pathnames = 0;  FILE *pfp = NULL;  char pname[1024], *arg;  int no_path_names = 1;#ifdef __EMX__ 	/* This gives wildcard expansion with Non-Posix shells with EMX */ 	_wildcard(&argc, &argv); #endif 	save_args(argc, argv);   if (argc < 2) {#ifdef	USE_LIBSCHILY	errmsgno(EX_BAD, "Missing pathspec.\n");#endif	usage(1);  }  /* Get the defaults from the .mkisofsrc file */  read_rcfile(argv[0]);  outfile = NULL;  /*   * Copy long option initialization from GNU-ld.   */  /* Starting the short option string with '-' is for programs that     expect options and other ARGV-elements in any order and that care about     the ordering of the two.  We describe each non-option ARGV-element     as if it were the argument of an option with character code 1.  */  {    int i, is, il;    shortopts[0] = '-';    is = 1;    il = 0;    for (i = 0; i < OPTION_COUNT; i++)      {	if (ld_options[i].shortopt != '\0')	  {	    shortopts[is] = ld_options[i].shortopt;	    ++is;	    if (ld_options[i].opt.has_arg == required_argument		|| ld_options[i].opt.has_arg == optional_argument)	      {		shortopts[is] = ':';		++is;		if (ld_options[i].opt.has_arg == optional_argument)		  {		    shortopts[is] = ':';		    ++is;		  }	      }	  }	if (ld_options[i].opt.name != NULL)	  {	    longopts[il] = ld_options[i].opt;	    ++il;	  }      }    shortopts[is] = '\0';    longopts[il].name = NULL;  }  while ((c = getopt_long_only (argc, argv, shortopts, longopts, &longind)) != EOF)    switch (c)      {      case 1:	/*	 * A filename that we take as input.	 */	optind--;	goto parse_input_files;      case 'C':	/*	 * This is a temporary hack until cdrecord gets the proper hooks in	 * it.	 */	cdrecord_data = optarg;	break;      case OPTION_GUI:	gui++;	break;      case 'i':#ifdef	USE_LIBSCHILY	comerrno(EX_BAD, "-i option no longer supported.\n");#else	fprintf(stderr, "-i option no longer supported.\n");	exit(1);#endif	break;      case 'J':	use_Joliet++;	break;      case 'a':	all_files++;#ifdef	USE_LIBSCHILY	errmsgno(EX_BAD, "Option -a is obsolete. All files are included by default.\n");#else	fprintf(stderr, "Option -a is obsolete. All files are included by default.\n");#endif	break;      case OPTION_NOBAK:	all_files = 0;	break;      case 'b':	use_eltorito++;	boot_image = optarg;  /* pathname of the boot image on disk */	if (boot_image == NULL) {#ifdef	USE_LIBSCHILY	        comerrno(EX_BAD, "Required Eltorito boot image pathname missing\n");#else	        fprintf(stderr, "Required Eltorito boot image pathname missing\n");		exit(1);#endif	}	break;      case 'B':	use_sparcboot++;	scan_sparc_boot(optarg); /* list of pathnames of boot images */	break;      case 'G':	use_genboot++;	genboot_image = optarg;  /* pathname of the boot image on disk */	if (genboot_image == NULL) {#ifdef	USE_LIBSCHILY	        comerrno(EX_BAD, "Required generic boot image pathname missing\n");#else	        fprintf(stderr, "Required generic boot image pathname missing\n");		exit(1);#endif	}	break;      case OPTION_SPARCLABEL:	sparc_boot_label(optarg); /* Sun disk label string */	break;      case 'c':	use_eltorito++;	boot_catalog = optarg;  /* pathname of the boot image on cd */	if (boot_catalog == NULL) {#ifdef	USE_LIBSCHILY	        comerrno(EX_BAD, "Required boot catalog pathname missing\n");#else	        fprintf(stderr, "Required boot catalog pathname missing\n");		exit(1);#endif	}	break;      case OPTION_ABSTRACT:	abstract = optarg;	if(strlen(abstract) > 37) {#ifdef	USE_LIBSCHILY		comerrno(EX_BAD, "Abstract filename string too long\n");#else		fprintf(stderr, "Abstract filename string too long\n");		exit(1);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -