コード例 #1
0
int
main(int argc, char **argv)
{
    time_t now;
    char time_buffer[32];

    if (argc < 2) {
        (void) fprintf(stderr, "Usage: %s <command> ...\n", argv[0]);
        exit(1);
    }

    rotate_logs();
    redirect_output();
    disable_cores();
    dump_privs();
    dump_args(argc, argv);

    /* get the current time for the log */
    time(&now);
    cftime(time_buffer, "%Y-%m-%dT%H:%M:%SZ", &now);

    /* print the header for the output from the program we exec (pre-flush) */
    (void) printf("=== OUTPUT (%s) ===\n", time_buffer);

    /* flush before next cmd takes over */
    (void) fflush(stdout);
    (void) fflush(stderr);

    exec_next(argc, argv);

    /* if we got here, we failed */
    (void) fprintf(stderr, "FATAL: execvp() failed.\n");
    exit(1);
}
コード例 #2
0
ファイル: acctcon.c プロジェクト: 0xffea/illumos-gate
static void
printrep()
{
	int i;

	freopen(report, "w", stdout);
	cftime(time_buf, DATE_FMT, &firstime);
	printf("from %s", time_buf);
	cftime(time_buf, DATE_FMT, &lastime);
	printf("to   %s", time_buf);
	if (ndates)
		printf("%d\tdate change%c\n", ndates, (ndates > 1 ? 's' :
		    '\0'));
	for (i = 0; i < nsys; i++)
		printf("%d\t%.*s\n", sy[i].snum,
		    sizeof (sy[i].sname), sy[i].sname);
}
コード例 #3
0
ファイル: trace.c プロジェクト: MattDooner/freebsd-west
static char *
ts(time_t secs) {
	static char s[20];

	secs += epoch.tv_sec;
#ifdef sgi
	(void)cftime(s, "%T", &secs);
#else
	memcpy(s, ctime(&secs)+11, 8);
	s[8] = '\0';
#endif
	return s;
}
コード例 #4
0
ファイル: mount.c プロジェクト: glasspelican/illumos-joyent
void
print_mnttab(int vflg, int pflg)
{
	FILE	*fd;
	FILE	*rfp;			/* this will be NULL if fopen fails */
	int	ret;
	char	time_buf[TIME_MAX];	/* array to hold date and time */
	struct extmnttab	mget;
	time_t	ltime;

	if ((fd = fopen(mnttab, "r")) == NULL) {
		fprintf(stderr, gettext("%s: Cannot open mnttab\n"), myname);
		exit(1);
	}
	rfp = fopen(REMOTE, "r");
	while ((ret = getextmntent(fd, &mget, sizeof (struct extmnttab)))
	    == 0) {
		if (ignore(mget.mnt_mntopts))
			continue;
		if (mget.mnt_special && mget.mnt_mountp &&
		    mget.mnt_fstype && mget.mnt_time) {
			ltime = atol(mget.mnt_time);
			cftime(time_buf, FORMAT, &ltime);
			if (pflg) {
				elide_dev(mget.mnt_mntopts);
				printf("%s - %s %s - no %s\n",
				    mget.mnt_special,
				    mget.mnt_mountp,
				    mget.mnt_fstype,
				    mget.mnt_mntopts != NULL ?
				    mget.mnt_mntopts : "-");
			} else if (vflg) {
				printf("%s on %s type %s %s%s on %s",
				    mget.mnt_special,
				    mget.mnt_mountp,
				    mget.mnt_fstype,
				    remote(mget.mnt_fstype, rfp),
				    flags(mget.mnt_mntopts, NEW),
				    time_buf);
			} else
				printf("%s on %s %s%s on %s",
				    mget.mnt_mountp,
				    mget.mnt_special,
				    remote(mget.mnt_fstype, rfp),
				    flags(mget.mnt_mntopts, OLD),
				    time_buf);
		}
	}
	if (ret > 0)
		mnterror(ret);
}
コード例 #5
0
ファイル: pr.c プロジェクト: drscream/illumos-joyent
static	char *
GETDATE()	/* return date file was last modified */
{
	static	char	*now = NULL;
	static	struct	stat	sbuf;
	static	struct	stat	nbuf;

	if (Nfiles > 1 || Files->f_name == nulls) {
		if (now == NULL) {
			(void) time(&nbuf.st_mtime);
			(void) cftime(time_buf,
				dcgettext(NULL, FORMAT, LC_TIME),
			    &nbuf.st_mtime);
			now = time_buf;
		}
		return (now);
	} else {
		(void) stat(Files->f_name, &sbuf);
		(void) cftime(time_buf, dcgettext(NULL, FORMAT, LC_TIME),
			&sbuf.st_mtime);
		return (time_buf);
	}
}
コード例 #6
0
ファイル: acctcon.c プロジェクト: 0xffea/illumos-gate
static void
fixup(FILE *stream)
{
	fprintf(stream, "bad wtmpx: offset %lu.\n", ftell(stdin)-sizeof (wb));
	fprintf(stream, "bad record is:  %.*s\t%.*s\t%lu",
	    sizeof (wb.ut_line),
	    wb.ut_line,
	    sizeof (wb.ut_name),
	    wb.ut_name,
	    wb.ut_xtime);
	cftime(time_buf, DATE_FMT, &wb.ut_xtime);
	fprintf(stream, "\t%s", time_buf);
	exitcode = 1;
}
コード例 #7
0
ファイル: acctcon.c プロジェクト: 0xffea/illumos-gate
static void
loop()
{
	int timediff;
	struct tbuf *tp;

	if (wb.ut_line[0] == '\0')	/* It's an init admin process */
		return;			/* no connect accounting data here */
	switch (wb.ut_type) {
	case OLD_TIME:
		datetime = wb.ut_xtime;
		return;
	case NEW_TIME:
		if (datetime == 0)
			return;
		timediff = wb.ut_xtime - datetime;
		for (tp = tbuf; tp <= &tbuf[tsize]; tp++)
			tp->ttime += timediff;
		datetime = 0;
		ndates++;
		return;
	case DOWN_TIME:
		return;
	case BOOT_TIME:
		upall();
	case ACCOUNTING:
	case RUN_LVL:
		lastime = wb.ut_xtime;
		bootshut();
		return;
	case USER_PROCESS:
	case LOGIN_PROCESS:
	case INIT_PROCESS:
	case DEAD_PROCESS:	/* WHCC mod 3/86  */
		update(&tbuf[iline()]);
		return;
	case EMPTY:
		return;
	default:
		cftime(time_buf, DATE_FMT, &wb.ut_xtime);
		fprintf(stderr, "acctcon: invalid type %d for %s %s %s",
			wb.ut_type,
			wb.ut_name,
			wb.ut_line,
			time_buf);
	}
}
コード例 #8
0
ファイル: fsm.c プロジェクト: elambert/honeycomb
static void error(conn_t* conn, const char* msg)
{
    char time_buf[30];
    char err_buf[100];
    time_t now = time(0);

    *err_buf = 0;
    if (errno != 0)
        strerror_r(errno, err_buf, sizeof(err_buf));
    cftime(time_buf, "%F %T %Z", &now);

    fprintf(stderr, "%s C.%d: [%s] \"%s\" (%ld) -- %s\n",
            time_buf, conn->index, err_buf,
            state_names[conn->state], conn->n_written,
            msg);

    errno = 0;
}
コード例 #9
0
ファイル: file_menu.c プロジェクト: ma-tech/MAPaint
void file_menu_init(
  Widget	topl)
{
  Widget	rc, form, toggle;
  Visual	*visual;
  Arg		arg[1];
  char		fileStr[128];
  FILE 		*fp;
  WlzEffFormat	image_type=WLZEFF_FORMAT_WLZ;

  /* set the top-level title */
  set_topl_title(NULL);

  /* get the visual explicitly */
  visual = HGU_XmWidgetToVisual(topl);
  XtSetArg(arg[0], XmNvisual, visual);

  /* create the read-model file selection dialog */
  read_model_dialog = XmCreateFileSelectionDialog(topl,
						  "read_model_dialog", arg, 1);
  XtAddCallback(read_model_dialog, XmNokCallback,
		read_reference_object_cb, (XtPointer) WLZEFF_FORMAT_WLZ);
  XtAddCallback(read_model_dialog, XmNokCallback, PopdownCallback, NULL);
  XtAddCallback( read_model_dialog, XmNcancelCallback, 
		PopdownCallback, NULL);
  XtAddCallback(read_model_dialog, XmNmapCallback,
		FSBPopupCallback, NULL);
  XtManageChild( read_model_dialog );

  /* create the read-obj file selection dialog */
  read_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "read_obj_dialog",
					      read_reference_object_cb, NULL);
  if((rc = XtNameToWidget(read_obj_dialog, "*.formatFormRC"))){

    /* add a form to include file type and fill-blanks toggle */
    form = XtVaCreateManagedWidget("read_file_form", xmFormWidgetClass,
				   rc,
				   XmNborderWidth,	0,
				   NULL);

    /* add a fill-blanks toggles */
    toggle = XtVaCreateManagedWidget("fill_blanks", xmToggleButtonGadgetClass,
				     form,
				     XmNindicatorOn, 	True,
				     XmNindicatorType,	XmN_OF_MANY,
				     XmNset,		False,
				     XmNtopAttachment,	XmATTACH_FORM,
				     XmNleftAttachment,	XmATTACH_FORM,
				     NULL);

    toggle = XtVaCreateManagedWidget("min_domain", xmToggleButtonGadgetClass,
				     form,
				     XmNindicatorOn, 	True,
				     XmNindicatorType,	XmN_OF_MANY,
				     XmNset,		True,
				     XmNtopAttachment,	XmATTACH_FORM,
				     XmNleftAttachment,	XmATTACH_WIDGET,
				     XmNleftWidget,	toggle,
				     NULL);
  }

  HGU_XmExtFFObjectFSBSetType(read_obj_dialog, WLZEFF_FORMAT_WLZ);
  XtManageChild( read_obj_dialog );

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( read_obj_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  /* create the write-obj file selection dialog */
  write_obj_dialog = HGU_XmCreateExtFFObjectFSB(topl, "write_obj_dialog",
					       write_reference_object_cb,
					       NULL);
  HGU_XmExtFFObjectFSBSetType(write_obj_dialog, WLZEFF_FORMAT_WLZ);


  /* initialise the reference file list pulldown */
  if( !globals.sectViewFlg ){
    Widget	cascade;

    if((cascade = XtNameToWidget(globals.topl,
				 "*file_menu*_pulldown*Recent"))){
      globals.resourceFile = (String) 
	AlcMalloc(sizeof(char) * (strlen(getenv("HOME")) + 16));
      sprintf(globals.resourceFile, "%s/%s", getenv("HOME"), ".maRecentFiles");
      globals.fileList = HGU_XmFileListCreateList(globals.resourceFile, NULL);
      HGU_XmFileListResetMenu(globals.fileList, cascade, referenceFileListCb);
    }
  }

  /* add to the save restore list */
  HGU_XmSaveRestoreAddWidget( write_obj_dialog, HGU_XmFSD_SaveFunc,
			     (XtPointer) XtName(topl), NULL, NULL );

  /* create the object properties dialog */
  obj_props_dialog_init( topl );

  globals.file      = NULL;
  globals.obj       = NULL;
  globals.orig_obj  = NULL;
  globals.fb_obj    = NULL;
  globals.origObjExtType = image_type;

  /* setup the theiler directory and menu item - check for stage */
  XtGetApplicationResources(topl, &globals, set_att_res,
			    XtNumber(set_att_res), NULL, 0);

  /* check the logfile */
  if( globals.logfile ){
    if( (globals.logfileFp = fopen(globals.logfile, "w")) == NULL ){
      fprintf(stderr,
	      "MAPaint: something wrong with the logfile %s\n"
	      "Please check name and permissions\n"
	      "Logging not enabled\n\007", globals.logfile);
    }
    else {
      char		timeBuf[16];
      struct hostent 	*hstnt;
      fprintf(stderr, "MAPaint: logging enabled to %s\n", globals.logfile);
      MAPaintLogData("Filename", globals.logfile, 0, NULL);
      MAPaintLogData("User", getenv("USER"), 0, NULL);
#if defined (LINUX2) || defined (DARWIN)
      strcpy(timeBuf, "00/00/00");
#else
      tmpTime = time(NULL);
      cftime(timeBuf, "%d/%m/%Y", &tmpTime);
#endif /* LINUX2 */
      MAPaintLogData("Date", timeBuf, 0, NULL);
#if defined (LINUX2) || defined (DARWIN)
      strcpy(timeBuf, "00.00");
#else
      cftime(timeBuf, "%H.%M", &tmpTime);
#endif /* LINUX2 */
      MAPaintLogData("Time", timeBuf, 0, NULL);
      hstnt = gethostbyname(getenv("HOST"));
      MAPaintLogData("Host", getenv("HOST"), 0, NULL);
      MAPaintLogData("Hostname", hstnt->h_name, 0, NULL);
    }
  }
  else {
    globals.logfileFp = NULL;
  }

  /* check base directory - if the string has come from the resources then
     we need to duplicate it to allow it to be freed
     possibly some memory leakage here */
  /* note: only non-NULL if set by the user, if NULL then attempt to find
     the cdrom or copied data */
  if( globals.base_theiler_dir ){
    globals.base_theiler_dir = AlcStrDup( globals.base_theiler_dir );
  }
/*  else {
    FILE	*pp;*/
    
    /* search for the Theiler mode directory as per the CDROM 
       should search local disc first */
/*#if defined (LINUX2)
    if((pp = popen("find /mnt -maxdepth 4 -name Models", "r"))){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#elif defined (DARWIN)
    if( (pp = popen("find /Volumes -maxdepth 4 -name Models", "r")) ){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#elif defined (SUNOS4) || defined (SUNOS5)
    if( pp = popen("find /cdrom -maxdepth 4 -name Models", "r") ){
      while( fscanf(pp, "%s", fileStr) != EOF ){
	if( strstr(fileStr, "Models") ){
	  globals.base_theiler_dir = AlcStrDup(fileStr);
	  break;
	}
      }
      pclose(pp);
    }
#else
    globals.base_theiler_dir = NULL;
#endif
  }*/
  if( globals.theiler_stage ){
    char *tStr;
    if((tStr = theilerString(globals.theiler_stage))){
      globals.theiler_stage = AlcStrDup(tStr);
    }
    else {
      globals.theiler_stage = NULL;
    }
  }
  theiler_menu_init( topl );

  /* check for an initial reference file else check Theiler stage */
  if( initial_reference_file != NULL ){
    WlzObject 	*obj;

    /* open the reference object file and install */
    if( (fp = fopen(initial_reference_file, "r")) ){
      HGU_XmSetHourGlassCursor(topl);
      if((obj = WlzReadObj( fp, NULL ))){
        WlzDomain	domain;
        WlzValues	values;
        WlzObject	*newObj;
	switch( obj->type ){

	case WLZ_2D_DOMAINOBJ:
	  domain.p = WlzMakePlaneDomain(WLZ_PLANEDOMAIN_DOMAIN, 0, 0,
					obj->domain.i->line1,
					obj->domain.i->lastln,
					obj->domain.i->kol1,
					obj->domain.i->lastkl,
					NULL);
	  domain.p->domains[0] = WlzAssignDomain(obj->domain, NULL);
	  values.vox = WlzMakeVoxelValueTb(WLZ_VOXELVALUETABLE_GREY,
					   0, 0, WlzGetBackground(obj, NULL),
					   NULL, NULL);
	  values.vox->values[0] = WlzAssignValues(obj->values, NULL);
	  newObj = WlzMakeMain(WLZ_3D_DOMAINOBJ, domain, values,
			       NULL, NULL, NULL);
	  WlzFreeObj(obj);
	  obj = newObj;
	  globals.origObjType = WLZ_2D_DOMAINOBJ;
	  break;

	case WLZ_3D_DOMAINOBJ:
	  globals.origObjType = WLZ_3D_DOMAINOBJ;
	  break;

	default:
	  HGU_XmUserError(globals.topl,
			  "Read Reference Object:\n"
			  "    The reference object must be a 2- or 3-D woolz\n"
			  "    grey-level image. Please select an alternate\n"
			  "    object",
			  XmDIALOG_FULL_APPLICATION_MODAL);
	  WlzFreeObj( obj );
	  /* set hour glass cursor */
	  HGU_XmUnsetHourGlassCursor(globals.topl);
	  return;

	}
	HGU_XmFileListAddFile(globals.fileList, initial_reference_file,
			      image_type);
	HGU_XmFileListWriteResourceFile(globals.fileList,
					globals.resourceFile);
	MAPaintLogData("ReferenceFile", initial_reference_file, 0, NULL);
	install_paint_reference_object( obj );

	/* set the globals reference file */
	globals.file = initial_reference_file;

	/* set the title of the top-level window */
	set_topl_title(globals.file);
      }
      else {
	/* if it fails to read, check the file name
	   or the file content for special options */
	if( strstr(initial_reference_file, "MAPaint") ){
	  /* standard MAPaint startup */
	  globals.app_name = "MAPaint";
	  /* set the title of the top-level window */
	  set_topl_title(globals.file);
	}
	else if( strstr(initial_reference_file, "SectionView") ){
	  /* restricted section view startup */
	  globals.app_name = "SectionView";
	  globals.sectViewFlg = 1;
	  /* set the title of the top-level window */
	  set_topl_title(globals.file);
	}
	else if( theilerString(initial_reference_file) ){
	  /* load in theiler stage anatomy etc. */
	  globals.app_name = "SectionView";
	  globals.sectViewFlg = 1;
	  set_theiler_stage_cb(topl, theilerString(initial_reference_file),
			       NULL);
	}
	else {
	  char	strBuf[33];
	  /* check the content */
	  rewind(fp);
	  fscanf(fp, "%32s", strBuf);
	  if( strstr(strBuf, "MAPaint") ){
	    /* standard MAPaint startup */
	    globals.app_name = "MAPaint";
	    /* set the title of the top-level window */
	    set_topl_title(globals.file);
	  }
	  else if( strstr(strBuf, "SectionView") ){
	    /* restricted section view startup */
	    globals.app_name = "SectionView";
	    globals.sectViewFlg = 1;
	    /* set the title of the top-level window */
	    set_topl_title(globals.file);
	  }
	  else if( theilerString(strBuf) ){
	    /* load in theiler stage anatomy etc. */
	    globals.app_name = "SectionView";
	    globals.sectViewFlg = 1;
	    set_theiler_stage_cb(topl,
				 theilerString(strBuf),
				 NULL);
	  }
	}

	/* set the globals reference file */
	globals.file = NULL;
      }
      (void) fclose( fp );

      HGU_XmUnsetHourGlassCursor(topl);
    }
  }
  else if( globals.theiler_stage ){
    globals.app_name = "MAPaint";
    set_theiler_stage_cb(topl, theilerString(globals.theiler_stage), NULL);
  }

  /* reset the colormap */
  if( globals.sectViewFlg == 1 ){
    init_paint_cmapstruct(globals.topl);
  }

  /* check for an initial domain file */
  if( initial_domain_file != NULL ){
    WlzObject 	*obj;

    /* open the domain object file and put it in as a 3D feedback option */
    if( (fp = fopen(initial_domain_file, "rb")) ){
      HGU_XmSetHourGlassCursor(topl);
      if((obj = WlzReadObj( fp, NULL ))){
	if( globals.fb_obj ){
	  WlzFreeObj(globals.fb_obj);
	}
	globals.fb_obj = WlzAssignObject(obj, NULL);
	setup_ref_display_list_cb(read_obj_dialog, NULL, NULL);
      }
      (void) fclose( fp );
      HGU_XmUnsetHourGlassCursor(topl);
    }
  }

  return;
}
コード例 #10
0
ファイル: mount.c プロジェクト: alhazred/onarm
void
print_mnttab(int vflg, int pflg)
{
	FILE	*fd;
	FILE	*rfp;			/* this will be NULL if fopen fails */
	int	ret;
	char	time_buf[TIME_MAX];	/* array to hold date and time */
	struct extmnttab	mget;
	time_t	ltime;
#ifdef MNTFS_DISABLE
	struct mnttab	gmtab;
#endif	/* MNTFS_DISABLE */

	if ((fd = fopen(mnttab, "r")) == NULL) {
		fprintf(stderr, gettext("%s: Cannot open mnttab\n"), myname);
		exit(1);
	}
	rfp = fopen(REMOTE, "r");
#ifndef MNTFS_DISABLE
	while ((ret = getextmntent(fd, &mget, sizeof (struct extmnttab)))
	    == 0) {
#else
	while ((ret = getmntent(fd, &gmtab)) == 0) {
		struct stat64 msb;

		if (stat64(gmtab.mnt_mountp, &msb) == -1) {
			fprintf(stderr,
			    gettext("%s: Cannot stat mnttab\n"), myname);
			exit(2);
		}
		mget.mnt_special = gmtab.mnt_special;
		mget.mnt_mountp = gmtab.mnt_mountp;
		mget.mnt_fstype = gmtab.mnt_fstype;
		mget.mnt_mntopts = gmtab.mnt_mntopts;
		mget.mnt_time = gmtab.mnt_time;
		mget.mnt_major = (uint_t) major(msb.st_dev);
		mget.mnt_minor = (uint_t) minor(msb.st_dev);

#endif	/* MNTFS_DISABLE */
		if (ignore(mget.mnt_mntopts))
			continue;
		if (mget.mnt_special && mget.mnt_mountp &&
		    mget.mnt_fstype && mget.mnt_time) {
			ltime = atol(mget.mnt_time);
			cftime(time_buf, FORMAT, &ltime);
			if (pflg) {
				elide_dev(mget.mnt_mntopts);
				printf("%s - %s %s - no %s\n",
				    mget.mnt_special,
				    mget.mnt_mountp,
				    mget.mnt_fstype,
				    mget.mnt_mntopts != NULL ?
				    mget.mnt_mntopts : "-");
			} else if (vflg) {
				printf("%s on %s type %s %s%s on %s",
				    mget.mnt_special,
				    mget.mnt_mountp,
				    mget.mnt_fstype,
				    remote(mget.mnt_fstype, rfp),
				    flags(mget.mnt_mntopts, NEW),
				    time_buf);
			} else
				printf("%s on %s %s%s on %s",
				    mget.mnt_mountp,
				    mget.mnt_special,
				    remote(mget.mnt_fstype, rfp),
				    flags(mget.mnt_mntopts, OLD),
				    time_buf);
		}
	}
	if (ret > 0)
		mnterror(ret);
}

char	*
flags(char *mntopts, int flag)
{
	char	opts[sizeof (mntflags)];
	char	*value;
	int	rdwr = 1;
	int	suid = 1;
	int	devices = 1;
	int	setuid = 1;

	if (mntopts == NULL || *mntopts == '\0')
		return ("read/write/setuid/devices");

	strcpy(opts, "");
	while (*mntopts != '\0')  {
		switch (getsubopt(&mntopts, myopts, &value)) {
		case READONLY:
			rdwr = 0;
			break;
		case READWRITE:
			rdwr = 1;
			break;
		case SUID:
			suid = 1;
			break;
		case NOSUID:
			suid = 0;
			break;
		case SETUID:
			setuid = 1;
			break;
		case NOSETUID:
			setuid = 0;
			break;
		case DEVICES:
			devices = 1;
			break;
		case NODEVICES:
			devices = 0;
			break;
		default:
			/* cat '/' separator to mntflags */
			if (*opts != '\0' && value != NULL)
				strcat(opts, "/");
			strcat(opts, value);
			break;
		}
	}

	strcpy(mntflags, "");
	if (rdwr)
		strcat(mntflags, "read/write");
	else if (flag == OLD)
		strcat(mntflags, "read only");
	else
		strcat(mntflags, "read-only");
	if (suid) {
		if (setuid)
			strcat(mntflags, "/setuid");
		else
			strcat(mntflags, "/nosetuid");
		if (devices)
			strcat(mntflags, "/devices");
		else
			strcat(mntflags, "/nodevices");
	} else {
		strcat(mntflags, "/nosetuid/nodevices");
	}
	if (*opts != '\0') {
		strcat(mntflags, "/");
		strcat(mntflags, opts);
	}

	/*
	 * The assumed assertion
	 * 	assert (strlen(mntflags) < sizeof mntflags);
	 * is valid at this point in the code. Note that a call to "assert"
	 * is not appropriate in production code since it halts the program.
	 */
	return (mntflags);
}
コード例 #11
0
ファイル: srchmsg_lib.c プロジェクト: lanian09/mysource
int CheckPara(SRCH_INFO *pSRCHINFO, char *szResultBuf)
{
    int             arg_val;
    char            *ptr;
    int             iRet = 0;
	char			starttime[256];
	char			endtime[256];

	memset(starttime, 0x00, 256);
	memset(endtime, 0x00, 256);
    /* 필수 파라미터 컴사 */
    PASS_EXCEPTION(pSRCHINFO->ucViewF == 0 , MANDATORY_PARA_ERR);

    /* 파일 검색조건이 입력되어있는지 검사 : 파일명 또는 시간*/
    /* 조건이 없는 경우 */
    PASS_EXCEPTION(pSRCHINFO->ucSearchFileF == 0 && pSRCHINFO->ucStartF == 0 && pSRCHINFO->ucEndF == 0, 
        TIME_OR_FILE_NOT_FOUND);

    /* 파일명과 시간 조건이 모두 입력된 경우 */
    PASS_EXCEPTION(pSRCHINFO->ucSearchFileF == 1 && (pSRCHINFO->ucStartF == 1 || pSRCHINFO->ucEndF == 1), 
        TIME_AND_FILE_ALL_FOUND);

    /* 파일 검색 조건이 시간일 경우 시작과 종료 시간이 입력되었는지 검사*/
    PASS_EXCEPTION((pSRCHINFO->ucStartF == 1 || pSRCHINFO->ucEndF == 1) 
        && ((pSRCHINFO->ucStartF + pSRCHINFO->ucEndF) != 2),
            START_OR_END_TIME_NOT_FOUND);

    if (pSRCHINFO->ucSearchFileF == 1) 
    {
        pSRCHINFO->srchtype = SRCHTYPE_FILE;
	}
    else
    {
        pSRCHINFO->srchtype = SRCHTYPE_TIME;
		iRet = cftime(starttime, "%Y%m%d%H%M", (time_t *)&pSRCHINFO->starttime);
		iRet = cftime(endtime, "%Y%m%d%H%M", (time_t *)&pSRCHINFO->endtime);
    }
    /* 가입자 검색 조건 MSID */

    PASS_EXCEPTION(pSRCHINFO->ucImsiF != 1 && pSRCHINFO->ucSearchFileF != 1 
        && pSRCHINFO->ucUdrSeqF != 1, NO_IMSI_NUM);

    if( pSRCHINFO->ucImsiF == 1 )
    {
        pSRCHINFO->numtype = NUMTYPE_IMSI;
    }
    if( pSRCHINFO->ucUdrSeqF == 1 )
    {
        pSRCHINFO->numtype = NUMTYPE_UDRSEQ;
    }
    /* 출력 파일명이 입력되지 않았을경우
       default파일명을 지정 */
    if (pSRCHINFO->ucOutfileF == 0)
    {
        if (pSRCHINFO->ucSearchFileF != 1)
        {
            if( pSRCHINFO->ucImsiF == 1 )
            {
                sprintf(pSRCHINFO->outfile, "%s/SRCHMSG_%s_%s_%s_IMSI%s.DUMP",
                    RESULT_PATH,VIEWTYPE_NAME[pSRCHINFO->viewtype],
                    starttime,endtime,
                    pSRCHINFO->imsi);
            }
            else if( pSRCHINFO->ucUdrSeqF == 1 )
            {
                sprintf(pSRCHINFO->outfile, "%s/SRCHMSG_%s_%s_%s_SEQ%d.DUMP",
                    RESULT_PATH,VIEWTYPE_NAME[pSRCHINFO->viewtype],
                    starttime, endtime,
                    pSRCHINFO->uiUdrSeq);
            }
        }
        else
        {
            if ((ptr=strrchr(pSRCHINFO->filename,'/')) == NULL)
                ptr = pSRCHINFO->filename;    /* logical file path */
            else
                ptr += 1;

            sprintf(pSRCHINFO->outfile,"%s/SRCHMSG_%s_%s.DUMP",
                RESULT_PATH,VIEWTYPE_NAME[pSRCHINFO->viewtype],
                ptr);

        }


    }
    sprintf(szResultBuf,"==========================================================================\n"
						"    RESULT FILE  = %s\n",pSRCHINFO->outfile);
    strcpy(pSRCHINFO->errfile, pSRCHINFO->outfile);
    strcat(pSRCHINFO->errfile,".RESULT");
//    strcat(pSRCHINFO->errfile,".ERROR");
	
	iRet = 0;
    PASS_CATCH(GET_START_TIME_ERR)
    fprintf(stderr,"ERROR: invalid STARTTIME(%s)!!!\n",optarg);
    iRet = -1;
    
    PASS_CATCH(GET_END_TIME_ERR)
    fprintf(stderr,"ERROR: invalid ENDTIME(%s)!!!\n",optarg);
    iRet = -1;
    
    PASS_CATCH(FILENAME_LEN_ERR)
    fprintf(stderr,"ERROR: too long filename(%s)!!!\n",optarg);
    iRet = -1;
    
    PASS_CATCH(IMSI_LEN_ERR)
    fprintf(stderr,"ERROR: invalid IMSI(%s)!!!\n",optarg);
    iRet = -1;
    
    
    PASS_CATCH(UNKNOWN_MSG_TYPE)
    fprintf(stderr,"ERROR: invalid MSGTYPE(%s)!!!\n",optarg);
    iRet = -1;
                    
    PASS_CATCH(UNKNOWN_VIEW_TYPE)
    fprintf(stderr,"ERROR: invalid VIEWTYPE(%s)!!!\n",optarg);
    iRet = -1;
                
    PASS_CATCH(MAX_FILENAME_ERR)
    fprintf(stderr,"ERROR: too long outfile(%s)!!!\n",optarg);
    iRet = -1;
                
    
    PASS_CATCH(MANDATORY_PARA_ERR)
    fprintf(stderr,"ERROR: mandatory parameter missed!!!\n");
    iRet = -1;
    
    PASS_CATCH(TIME_OR_FILE_NOT_FOUND)
    fprintf(stderr,"ERROR: time or file not specified!!!\n");
    iRet = -1;
    
    PASS_CATCH(TIME_AND_FILE_ALL_FOUND)
    fprintf(stderr,"ERROR: time and file used at the same time!!!\n");
    iRet = -1;
    
    PASS_CATCH(START_OR_END_TIME_NOT_FOUND)
    fprintf(stderr,"ERROR: start and end time not specified at the same time!!!\n");
    iRet = -1;
    
    PASS_CATCH(DUAL_SEARCH_OPT)
    fprintf(stderr,"ERROR: IMSI and MSISDN used at the same time!!!\n");
    iRet = -1;
    
    PASS_CATCH(NO_IMSI_NUM)
    fprintf(stderr,"ERROR: IMSI Is Not Exist !!!\n");
    iRet = -1;

    PASS_CATCH(SEQ_LEN_ERR)
    fprintf(stderr,"ERROR: Sequence Is Not Number !!!\n");
    iRet = -1;
    
    PASS_CATCH_END;

    return iRet;
}
コード例 #12
0
ファイル: nukeold.c プロジェクト: nawglan/ShadowWind
int main(int argc, char *argv[])
{

  DIR *dirp; /* Directory pointer used to read the directory */
  struct dirent *idirent; /* Entry struct in the directory */
  struct stat filestat; /* contains information about the file */
  char filename[1024]; /* used to store the filename in the directory */
  time_t currtime; /* holds the current time */

  /* ensure that the minimum number of parameters have been supplied */
  if (argc < 2) {
    fprintf(stderr, "Usage: %s <in dir>\n", argv[0]);
    exit(1);
  }

  fileext[0] = '\0';
  newext[0] = '\0';

  /* ensure that we can read from the directory */
  if ((dirp = opendir(argv[1])) == NULL) {
    fprintf(stderr, "Error opening directory: %s\n", argv[1]);
    exit(1);
  }

  /* make the output directory if it does not exist */
  if (stat(argv[2], &filestat)) {
    if (mkdir(argv[2], 00777) == -1) {
      fprintf(stderr, "Unable to create directory %s\n", argv[2]);
      exit(1);
    }
  }

  /* get today's date */
  currtime = time(NULL);
  cftime(cdate, "%Y%m%d", &currtime);

  /* read the directory */
  while ((idirent = readdir(dirp))) {
    /* skip . and .. and anything with a null name */
    if ((strcmp(idirent->d_name, ".") == 0) || (strcmp(idirent->d_name, "..") == 0) || idirent->d_name[0] == '\0')
      continue;

    sprintf(filename, "%s/%s", argv[1], idirent->d_name);

    /* retrieve the information on the file */
    stat(filename, &filestat);

    /* format the modified time for a YYYYMMDD string */
    cftime(fdate, "%Y%m%d", &filestat.st_mtime);

    /* check if this file has the correct modified date, if dates match */
    /* copy the file to the archive directory */

    if (strcmp(fdate, cdate) == 0) {
      sprintf(systemcmd, "cp %s/%s %s/", argv[1], idirent->d_name, argv[2]);

      /* replace the extention with the new extention */
      if (argc == 4) {
        strcpy(filename, idirent->d_name);
        p = strrchr(filename, fileext[0]);
        if (strcmp(p, fileext) == 0)
          strcpy(p, newext);
        sprintf(systemcmd, "%s%s", systemcmd, filename);
      } else {
        sprintf(systemcmd, "%s%s", systemcmd, idirent->d_name);
      }

      /* issue the cp command */
      system(systemcmd);
    }
  }

  closedir(dirp);
  return 0;
}
コード例 #13
0
ファイル: kwarnd_send.c プロジェクト: olbohlen/illumos-gate
int
warn_send(char *receipient, char *msg)
{
    register struct utmpx *ubuf;
    static char rterminal[] = "/dev/\0 2345678901";
    extern FILE *fp;
    time_t tod;
    char time_buf[40];
    register int bad = 0;
    char	*rcp1, *rcp2, *rcp3;

    (void) setlocale(LC_ALL, "");
#if !defined(TEXT_DOMAIN)
#define	TEXT_DOMAIN "SYS_TEST"
#endif
    (void) textdomain(TEXT_DOMAIN);


    /*	Set "rterm" to location where receipient's terminal will go.	*/

    rterm = &rterminal[sizeof ("/dev/") - 1];

    /*
     * strip any realm or instance from principal so we can match against unix
     * userid.
     */
    rcp1 = strdup(receipient);
    rcp2 = strtok(rcp1, "@");
    rcp3 = strtok(rcp2, "/");

    /*
     *	Scan through the "utmpx" file for the
     *	entry for the person we want to send to.
     */

    setutxent();
    while ((ubuf = getutxent()) != NULL) {
        if (ubuf->ut_type == USER_PROCESS) {
            if (strncmp(rcp3, ubuf->ut_user,
                        sizeof (ubuf->ut_user)) == 0) {
                strncpy(rterm, &ubuf->ut_line[0],
                        sizeof (ubuf->ut_line)+1);

                /*	Try to open up the line to the receipient's terminal.		*/

                signal(SIGALRM, openfail);
                alarm(5);
                fp = fopen(&rterminal[0], "w");
                alarm(0);

                /*	Catch signals SIGHUP, SIGINT, SIGQUIT, and SIGTERM, and send	*/
                /*	<EOT> message to receipient.			*/

                setsignals(eof);

                /*	Get the time of day, convert it to a string and throw away the	*/
                /*	year information at the end of the string.			*/

                time(&tod);
                cftime(time_buf, "%c", &tod);
                (void) fprintf(fp, gettext(
                                   "\r\n\007\007\007\tMessage from %s@%s [ %s ] ...\r\n"),
                               progname, myhostname, time_buf);
                sleep(1);
                fprintf(fp, gettext("\r\nMessage to %s"), msg);
                fflush(fp);

                /*	Since "end of file" received, send <EOT> message to receipient.	*/

                eof();
                fclose(fp);
            }
        }
    }
    free(rcp1);


    /*	Did we find a place to talk to?  If we were looking for a */
    /*	specific spot and didn't find it, complain and log it. */

    if (*rterm == '\0')
        if (bad > 0) {
            (void) syslog(LOG_ERR, gettext("no place to send.\n"));
            return (1);
        }

    endutxent();
    return (0);
}
コード例 #14
0
ファイル: iofuncs.c プロジェクト: timburrow/ovj3
int lan_sockrxrdy(int sock, int milliseconds)
{
    int timerExpired = 0, secondsLeft;
    time_t orig_t, exp_t;
    struct timeval tmVal;
    fd_set rdFds;
#ifndef LINUX
    time_t t;
    char tbuf[48], orig_tbuf[48];
#endif
    int result, seconds = milliseconds / 1000;

    orig_t = time(0);
    exp_t = orig_t + seconds;
    secondsLeft = ((seconds <= 0) ? 1 : seconds);
    DPRINT1(1, "read_lan_timed: seconds=%d\r\n", secondsLeft);

    while (!timerExpired) {

        FD_ZERO(&rdFds);
        FD_SET(sock, &rdFds);

        memset(&tmVal, 0, sizeof(tmVal));
        tmVal.tv_sec = secondsLeft;
        tmVal.tv_usec = 0;

        result = select(FD_SETSIZE, &rdFds, NULL, NULL, &tmVal);

        if ((result > 0) && (FD_ISSET(sock, &rdFds))) {
            /* Data is pending at the socket */
            return result;
        }

        else if (result < 0) {
            if (errno == EINTR) {
                secondsLeft = exp_t - time(0);
                if (secondsLeft <= 0)
                    timerExpired = 1;
                else if ((AbortRobo == 1) && !as_lan)
                    timerExpired = 1;
            }
            else {
                DPRINT2(1, "Robot Read Error: result=%d errno=%d\r\n",
                    result, errno);
                return result;
            }
        }
        else {
            DPRINT(1, "Robot Read Error TIMEOUT\r\n");
            timerExpired = 1;
        }
    }

#ifdef DEBUG
#ifndef LINUX
    t = time(0);
    cftime(tbuf, "%T", &t);
    cftime(orig_tbuf, "%T", &orig_t);

    if (AbortRobo == 1) {
        DPRINT2(1, "Robot Read ABORTED, %s...%s\r\n",
                orig_tbuf, tbuf);
    }
    else {
        DPRINT2(1, "Robot Read Error TIMEOUT, %s...%s\r\n",
                orig_tbuf, tbuf);
    }
#endif
#endif
    return 0; /* timeout */
}
コード例 #15
0
ファイル: acctcon.c プロジェクト: 0xffea/illumos-gate
/*
 * update tbuf with new time, write ctmp record for end of session
 */
static void
update(struct tbuf *tp)
{
	time_t	told,	/* last time for tbuf record */
		tnew;	/* time of this record */
			/* Difference is connect time */

	told = tp->ttime;
	tnew = wb.ut_xtime;
	if (told > tnew) {
		cftime(time_buf, DATE_FMT, &told);
		fprintf(stderr, "acctcon: bad times: old: %s", time_buf);
		cftime(time_buf, DATE_FMT, &tnew);
		fprintf(stderr, "new: %s", time_buf);
		exitcode = 1;
		tp->ttime = tnew;
		return;
	}
	tp->ttime = tnew;
	switch (wb.ut_type) {
	case USER_PROCESS:
		tp->tlsess++;
		/*
		 * Someone logged in without logging off. Put out record.
		 */
		if (tp->tname[0] != '\0') {
			cb.ct_tty = tp->tdev;
			CPYN(cb.ct_name, tp->tname);
			cb.ct_uid = namtouid(cb.ct_name);
			cb.ct_start = told;
			if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told),
			    cb.ct_con) == 0) {
				fprintf(stderr, "acctcon: could not calculate "
				    "prime/non-prime hours\n");
				exit(1);
			}
			enter(&cb);
			tp->ttotal += tnew-told;
		} else	/* Someone just logged in */
			tp->tlon++;
		CPYN(tp->tname, wb.ut_name);
		break;
	case DEAD_PROCESS:
		tp->tloff++;
		if (tp->tname[0] != '\0') { /* Someone logged off */
			/* Set up and print ctmp record */
			cb.ct_tty = tp->tdev;
			CPYN(cb.ct_name, tp->tname);
			cb.ct_uid = namtouid(cb.ct_name);
			cb.ct_start = told;
			if (pnpsplit(cb.ct_start, (ulong_t)(tnew-told),
			    cb.ct_con) == 0) {
				fprintf(stderr, "acctcon: could not calculate "
				    "prime/non-prime hours\n");
				exit(1);
			}
			enter(&cb);
			tp->ttotal += tnew-told;
			tp->tname[0] = '\0';
		}
	}
}
コード例 #16
0
ファイル: main.c プロジェクト: belenix/belenixold
int
main(int argc, char *argv[])
{
	struct utsname utsbuf;
	struct statvfs64 svfsb;
	struct cfent	**eptlist;
	FILE	*fp;
	VFP_T	*vfp;
	int	i, c, n, eptnum, found,
		part, nparts, npkgs, objects;
	char	buf[MAX_PKG_PARAM_LENGTH];
	char	temp[MAX_PKG_PARAM_LENGTH];
	char	param[MAX_PKG_PARAM_LENGTH];
	char	*pt, *value, *pkginst, *tmpdir, *abi_sym_ptr,
		**cmdparam;
	char	*pkgname;
	char	*pkgvers;
	char	*pkgarch;
	char	*pkgcat;
	void	(*func)();
	time_t	clock;
	fsblkcnt_t	bsize = 0;
	fsblkcnt_t	frsize = 0;
	struct cl_attr	**allclass = NULL;
	struct cl_attr	**order;

	/* initialize locale environment */

	(void) setlocale(LC_ALL, "");

#if !defined(TEXT_DOMAIN)	/* Should be defined by cc -D */
#define	TEXT_DOMAIN "SYS_TEST"
#endif
	(void) textdomain(TEXT_DOMAIN);

	/* initialize program name */

	(void) set_prog_name(argv[0]);

	/* tell spmi zones interface how to access package output functions */

	z_set_output_functions(echo, echoDebug, progerr);

	func = sigset(SIGINT, trap);
	if (func != SIG_DFL)
		func = sigset(SIGINT, func);
	func = sigset(SIGHUP, trap);
	setmapmode(MAPBUILD);	/* variable binding */
	if (func != SIG_DFL)
		func = sigset(SIGHUP, func);

	environ = NULL;
	while ((c = getopt(argc, argv, "osnp:l:r:b:d:f:a:v:?")) != EOF) {
		switch (c) {
		    case 'n':
			nflag++;
			break;

		    case 's':
			sflag++;
			break;

		    case 'o':
			overwrite++;
			break;

		    case 'p':
			putparam("PSTAMP", optarg);
			break;

		    case 'l':
			llimit = atol(optarg);
			break;

		    case 'r':
			pt = strtok(optarg, " \t\n, ");
			n = 0;
			do {
				rootlist[n++] = flex_device(pt, 0);
				if (n >= NROOT) {
					progerr(gettext(ERR_NROOT), NROOT);
					quit(1);
				}
			} while (pt = strtok(NULL, " \t\n, "));
			rootlist[n] = NULL;
			break;

		    case 'b':
			basedir = optarg;
			break;

		    case 'f':
			protofile = optarg;
			break;

		    case 'd':
			device = flex_device(optarg, 1);
			break;

		    case 'a':
			putparam("ARCH", optarg);
			break;

		    case 'v':
			putparam("VERSION", optarg);
			break;

		    default:
			usage();
		}
	}

	/*
	 * Store command line variable assignments for later
	 * incorporation into the environment.
	 */
	cmdparam = &argv[optind];

	/* Skip past equates. */
	while (argv[optind] && strchr(argv[optind], '='))
		optind++;

	/* Confirm that the instance name is valid */
	if ((pkginst = argv[optind]) != NULL) {
		if (pkgnmchk(pkginst, "all", 0)) {
			progerr(gettext(ERR_PKGINST), pkginst);
			quit(1);
		}
		argv[optind++] = NULL;
	}
	if (optind != argc)
		usage();

	tmpdir = getenv("TMPDIR");
	if (tmpdir == NULL)
		tmpdir = P_tmpdir;

	/* bug id 4244631, not ABI compliant */
	abi_sym_ptr = getenv("PKG_NONABI_SYMLINKS");
	if (abi_sym_ptr && (strncasecmp(abi_sym_ptr, "TRUE", 4) == 0)) {
		set_nonABI_symlinks();
	}

	if (device == NULL) {
		device = devattr(SPOOLDEV, "pathname");
		if (device == NULL) {
			progerr(gettext(ERR_DEVICE), SPOOLDEV);
			exit(99);
		}
	}

	if (protofile == NULL) {
		if (access("prototype", 0) == 0)
			protofile = "prototype";
		else if (access("Prototype", 0) == 0)
			protofile = "Prototype";
		else {
			progerr(gettext(ERR_PROTOTYPE));
			quit(1);
		}
	}

	if (devtype(device, &pkgdev)) {
		progerr(gettext(ERR_BADDEV), device);
		quit(1);
	}
	if (pkgdev.norewind) {
		/* initialize datastream */
		progerr(gettext(ERR_DSTREAM), device);
		quit(1);
	}
	if (pkgdev.mount) {
		if (n = pkgmount(&pkgdev, NULL, 0, 0, 1))
			quit(n);
	}

	/*
	 * convert prototype file to a pkgmap, while locating
	 * package objects in the current environment
	 */
	t_pkgmap = tempnam(tmpdir, "tmpmap");
	if (t_pkgmap == NULL) {
		progerr(gettext(ERR_TEMP), errno);
		exit(99);
	}

	(void) fprintf(stderr, gettext(MSG_PROTOTYPE));
	if (n = mkpkgmap(t_pkgmap, protofile, cmdparam)) {
		progerr(gettext(ERR_BUILD));
		quit(1);
	}

	setmapmode(MAPNONE);	/* All appropriate variables are now bound */

	if (vfpOpen(&vfp, t_pkgmap, "r", VFP_NEEDNOW) != 0) {
		progerr(gettext(ERR_TEMP), errno);
		quit(99);
	}

	eptlist = procmap(vfp, 0, NULL);

	if (eptlist == NULL) {
		quit(1);
	}

	(void) vfpClose(&vfp);

	/* Validate the zone attributes in pkginfo, before creation */
	if (!valid_zone_attr(eptlist)) {
		progerr(ERR_PKGINFO_INVALID_OPTION_COMB);
		quit(1);
	}

	(void) fprintf(stderr, gettext(MSG_PKGINFO));
	pt = NULL;
	for (i = 0; eptlist[i]; i++) {
		ckmissing(eptlist[i]->path, eptlist[i]->ftype);
		if (eptlist[i]->ftype != 'i')
			continue;
		if (strcmp(eptlist[i]->path, "pkginfo") == 0)
			svept = eptlist[i];
	}
	if (svept == NULL) {
		progerr(gettext(ERR_NOPKGINFO));
		quit(99);
	}
	eptnum = i;

	/*
	 * process all parameters from the pkginfo file
	 * and place them in the execution environment
	 */

	if ((fp = fopen(svept->ainfo.local, "r")) == NULL) {
		progerr(gettext(ERR_RDPKGINFO), svept->ainfo.local);
		quit(99);
	}
	param[0] = '\0';
	while (value = fpkgparam(fp, param)) {
		if (getenv(param) == NULL)
			putparam(param, value);
		free((void *)value);
		param[0] = '\0';
	}
	(void) fclose(fp);

	/* add command line variables */
	while (*cmdparam && (value = strchr(*cmdparam, '=')) != NULL) {
		*value = NULL;	/* terminate the parameter */
		value++;	/* value is now the value (not '=') */
		putparam(*cmdparam++, value);  /* store it in environ */
	}

	/* make sure parameters are valid */
	(void) time(&clock);
	if (pt = getenv("PKG")) {
		if (pkgnmchk(pt, NULL, 0) || strchr(pt, '.')) {
			progerr(gettext(ERR_PKGABRV), pt);
			quit(1);
		}
		if (pkginst == NULL)
			pkginst = pt;
	} else {
		progerr(gettext(ERR_NOPARAM), "PKG", svept->path);
		quit(1);
	}
	/*
	 * verify consistency between PKG parameter and pkginst
	 */
	(void) snprintf(param, sizeof (param), "%s.*", pt);
	if (pkgnmchk(pkginst, param, 0)) {
		progerr(gettext(ERR_PKGMTCH), pt, pkginst);
		quit(1);
	}

	/*
	 * *********************************************************************
	 * this feature is removed starting with Solaris 10 - there is no built
	 * in list of packages that should be run "the old way"
	 * *********************************************************************
	 */

#ifdef	ALLOW_EXCEPTION_PKG_LIST
	/* Until 2.9, set it from the execption list */
	if (exception_pkg(pkginst, LINK))
		set_nonABI_symlinks();
#endif

	if ((pkgname = getenv("NAME")) == NULL) {
		progerr(gettext(ERR_NOPARAM), "NAME", svept->path);
		quit(1);
	}
	if (ckparam("NAME", pkgname))
		quit(1);
	if ((pkgvers = getenv("VERSION")) == NULL) {
		/* XXX - I18n */
		/* LINTED do not use cftime(); use strftime instead */
		(void) cftime(buf, "\045m/\045d/\045Y", &clock);
		(void) snprintf(temp, sizeof (temp),
			gettext("Dev Release %s"), buf);
		putparam("VERSION", temp);
		pkgvers = getenv("VERSION");
		logerr(gettext(WRN_SETPARAM), "VERSION", temp);
	}
	if (ckparam("VERSION", pkgvers))
		quit(1);
	if ((pkgarch = getenv("ARCH")) == NULL) {
		(void) uname(&utsbuf);
		putparam("ARCH", utsbuf.machine);
		pkgarch = getenv("ARCH");
		logerr(gettext(WRN_SETPARAM), "ARCH", utsbuf.machine);
	}
	if (ckparam("ARCH", pkgarch))
		quit(1);
	if (getenv("PSTAMP") == NULL) {
		/* use octal value of '%' to fight sccs expansion */
		/* XXX - I18n */
		/* LINTED do not use cftime(); use strftime instead */
		(void) cftime(buf, "\045Y\045m\045d\045H\045M\045S", &clock);
		(void) uname(&utsbuf);
		(void) snprintf(temp, sizeof (temp), "%s%s",
			utsbuf.nodename, buf);
		putparam("PSTAMP", temp);
		logerr(gettext(WRN_SETPARAM), "PSTAMP", temp);
	}
	if ((pkgcat = getenv("CATEGORY")) == NULL) {
		progerr(gettext(ERR_NOPARAM), "CATEGORY", svept->path);
		quit(1);
	}
	if (ckparam("CATEGORY", pkgcat))
		quit(1);

	/*
	 * warn user of classes listed in package which do
	 * not appear in CLASSES variable in pkginfo file
	 */
	objects = 0;
	for (i = 0; eptlist[i]; i++) {
		if (eptlist[i]->ftype != 'i') {
			objects++;
			addlist(&allclass, eptlist[i]->pkg_class);
		}
	}

	if ((pt = getenv("CLASSES")) == NULL) {
		if (allclass && *allclass) {
			cl_setl(allclass);
			cl_putl("CLASSES", allclass);
			logerr(gettext(WRN_SETPARAM), "CLASSES",
			    getenv("CLASSES"));
		}
	} else {
		cl_sets(qstrdup(pt));
		if (allclass && *allclass) {
			for (i = 0; allclass[i]; i++) {
				found = 0;
				if (cl_idx(allclass[i]->name) != -1) {
					found++;
					break;
				}
				if (!found) {
					logerr(gettext(WRN_CLASSES),
					    (char *)allclass[i]);
				}
			}
		}
	}

	(void) fprintf(stderr, gettext(MSG_VOLUMIZE), objects);
	order = (struct cl_attr **)0;
	if (pt = getenv("ORDER")) {
		pt = qstrdup(pt);
		(void) setlist(&order, pt);
		cl_putl("ORDER", order);
	}

	/* stat the intended output filesystem to get blocking information */
	if (pkgdev.dirname == NULL) {
		progerr(gettext(ERR_WHATVFS), device);
		quit(99);
	}
	if (statvfs64(pkgdev.dirname, &svfsb)) {
		progerr(gettext(ERR_STATVFS), pkgdev.dirname);
		quit(99);
	}

	if (bsize == 0) {
		bsize = svfsb.f_bsize;
	}
	if (frsize == 0) {
		frsize = svfsb.f_frsize;
	}
	if (limit == 0)
		/*
		 * bavail is in terms of fragment size blocks - change
		 * to 512 byte blocks
		 */
		limit = (((long)frsize > 0) ?
			howmany(frsize, DEV_BSIZE) :
			howmany(bsize, DEV_BSIZE)) * svfsb.f_bavail;
	if (ilimit == 0) {
		ilimit = (svfsb.f_favail > 0) ?
		    svfsb.f_favail : svfsb.f_ffree;
	}

	nparts = splpkgmap(eptlist, eptnum, (char **)order, bsize, frsize,
	    &limit, &ilimit, &llimit);

	if (nparts <= 0) {
		progerr(gettext(ERR_SPLIT));
		quit(1);
	}

	if (nflag) {
		for (i = 0; eptlist[i]; i++)
			(void) ppkgmap(eptlist[i], stdout);
		exit(0);
		/*NOTREACHED*/
	}

	(void) snprintf(pkgloc, sizeof (pkgloc), "%s/%s",
			pkgdev.dirname, pkginst);
	if (!isdir(pkgloc) && !overwrite) {
		progerr(gettext(ERR_OVERWRITE), pkgloc);
		quit(1);
	}

	/* output all environment install parameters */
	t_pkginfo = tempnam(tmpdir, "pkginfo");
	if ((fp = fopen(t_pkginfo, "w")) == NULL) {
		progerr(gettext(ERR_TEMP), errno);
		exit(99);
	}
	for (i = 0; environ[i]; i++) {
		if (isupper(*environ[i])) {
			(void) fputs(environ[i], fp);
			(void) fputc('\n', fp);
		}
	}
	(void) fclose(fp);

	started++;
	(void) rrmdir(pkgloc);
	if (mkdir(pkgloc, 0755)) {
		progerr(gettext(ERR_MKDIR), pkgloc);
		quit(1);
	}

	/* determine how many packages already reside on the medium */
	pkgdir = pkgdev.dirname;
	npkgs = 0;
	while (pt = fpkginst("all", NULL, NULL))
		npkgs++;
	(void) fpkginst(NULL); /* free resource usage */

	if (nparts > 1) {
		if (pkgdev.mount && npkgs) {
			progerr(gettext(ERR_ONEVOL));
			quit(1);
		}
	}

	/*
	 *  update pkgmap entry for pkginfo file, since it may
	 *  have changed due to command line or failure to
	 *  specify all neccessary parameters
	 */
	for (i = 0; eptlist[i]; i++) {
		if (eptlist[i]->ftype != 'i')
			continue;
		if (strcmp(eptlist[i]->path, "pkginfo") == 0) {
			svept = eptlist[i];
			svept->ftype = '?';
			svept->ainfo.local = t_pkginfo;
			(void) cverify(0, &svept->ftype, t_pkginfo,
				&svept->cinfo, 1);
			svept->ftype = 'i';
			break;
		}
	}

	if (nparts > 1)
		(void) fprintf(stderr, gettext(MSG_PACKAGEM), nparts);
	else
		(void) fprintf(stderr, gettext(MSG_PACKAGE1));

	for (part = 1; part <= nparts; part++) {
		if ((part > 1) && pkgdev.mount) {
			if (pkgumount(&pkgdev)) {
				progerr(gettext(ERR_UMOUNT), pkgdev.mount);
				quit(99);
			}
			if (n = pkgmount(&pkgdev, NULL, part, nparts, 1))
				quit(n);
			(void) rrmdir(pkgloc);
			if (mkdir(pkgloc, 0555)) {
				progerr(gettext(ERR_MKDIR), pkgloc);
				quit(99);
			}
		}
		outvol(eptlist, eptnum, part, nparts);

		/* Validate (as much as possible) the control scripts. */
		if (part == 1) {
			char inst_path[PATH_MAX];

			(void) fprintf(stderr, gettext(MSG_VALSCRIPTS));
			(void) snprintf(inst_path, sizeof (inst_path),
					"%s/install", pkgloc);
			checkscripts(inst_path, 0);
		}
	}

	quit(0);
	/*NOTREACHED*/
}