Esempio n. 1
0
/*
 * ReadConfig - read configuration information from the .ini file
 */
void ReadConfig( void ) {

    MemWndConfig        info;

    GetDefaults( &Config );
    LSortType = GetPrivateProfileInt( SECT_NAME, LSORT,
                                HEAPMENU_SORT_HANDLE, WATCOM_INI );
    GSortType = GetPrivateProfileInt( SECT_NAME, GSORT,
                                HEAPMENU_SORT_HANDLE, WATCOM_INI );
    HeapType = GetPrivateProfileInt( SECT_NAME, DISP_TYPE,
                                HEAPMENU_DISPLAY_ENTIRE, WATCOM_INI );
    Config.disp_res = GetPrivateProfileInt( SECT_NAME, DISP_RES,
                                        Config.disp_res, WATCOM_INI );
    Config.save_glob_pos = GetPrivateProfileInt( SECT_NAME, SAVE_GLOB_POS,
                                        Config.save_glob_pos, WATCOM_INI );
    Config.save_mem_pos = GetPrivateProfileInt( SECT_NAME, SAVE_MW_POS,
                                        Config.save_mem_pos, WATCOM_INI );
    Config.glob_xpos = GetPrivateProfileInt( SECT_NAME, GLOB_XPOS,
                                        Config.glob_xpos, WATCOM_INI );
    Config.glob_ypos = GetPrivateProfileInt( SECT_NAME, GLOB_YPOS,
                                        Config.glob_ypos, WATCOM_INI );
    Config.glob_xsize = GetPrivateProfileInt( SECT_NAME, GLOB_XSIZE,
                                        Config.glob_xsize, WATCOM_INI );
    Config.glob_ysize = GetPrivateProfileInt( SECT_NAME, GLOB_YSIZE,
                                        Config.glob_ysize, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, GSAVE, Config.gfname,
                        Config.gfname, _MAX_PATH, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, LSAVE, Config.lfname,
                        Config.lfname, _MAX_PATH, WATCOM_INI );

    /* read information about the memory window */

    GetMemWndConfig( &info );
    info.xpos = GetPrivateProfileInt( SECT_NAME, MW_XPOS,
                                        info.xpos, WATCOM_INI );
    info.ypos = GetPrivateProfileInt( SECT_NAME, MW_YPOS,
                                        info.ypos, WATCOM_INI );
    info.xsize = GetPrivateProfileInt( SECT_NAME, MW_XSIZE,
                                        info.xsize, WATCOM_INI );
    info.ysize = GetPrivateProfileInt( SECT_NAME, MW_YSIZE,
                                        info.ysize, WATCOM_INI );
    GetPrivateProfileString( SECT_NAME, MW_FNAME, info.fname, info.fname,
                                        _MAX_PATH, WATCOM_INI );
    info.maximized = GetPrivateProfileInt( SECT_NAME, MW_MAX,
                                        info.maximized, WATCOM_INI );
    info.disp_info = GetPrivateProfileInt( SECT_NAME, MW_DISP_INFO,
                                        info.disp_info, WATCOM_INI );
    info.autopos_info = GetPrivateProfileInt( SECT_NAME, MW_AUTOPOS,
                                        info.autopos_info, WATCOM_INI );
    info.forget_pos = GetPrivateProfileInt( SECT_NAME, MW_NO_UPDT,
                                        info.forget_pos, WATCOM_INI );
    info.allowmult = GetPrivateProfileInt( SECT_NAME, MW_1_WND,
                                        info.allowmult, WATCOM_INI );
    info.data_type = GetPrivateProfileInt( SECT_NAME, MW_DISP_TYPE,
                                        info.data_type, WATCOM_INI );
    info.code_type = GetPrivateProfileInt( SECT_NAME, MW_CODE_TYPE,
                                        info.code_type, WATCOM_INI );
    SetMemWndConfig( &info );
    InitMonoFont( SECT_NAME, WATCOM_INI, SYSTEM_FIXED_FONT, Instance );
} /* ReadConfig */
Esempio n. 2
0
bool
Fonts::Initialize()
{
  const auto default_settings = GetDefaults();

  return Load(default_settings);
}
Esempio n. 3
0
static void genericsetupscreen(RDArsrc *mainrsrc,char *modulx,char *name,
	short type,short length,char *desc,char *label)
{
	int typex,x=0;
	RDArsrc *genstprsrc=NULL;

	genstprsrc=RDArsrcNEW(module,"MAINTAIN GENERIC SETUP VARIABLE");
	addstdrsrc(genstprsrc,"MODULE",VARIABLETEXT,0,(modulx!=NULL ? modulx:""),
		TRUE);
	addstdrsrc(genstprsrc,"NAME",VARIABLETEXT,0,(name!=NULL ? name:""),
		TRUE);
	addsctrsrc(genstprsrc,"DESCRIPTION",0,(desc!=NULL ? desc:""),TRUE);
	addstdrsrc(genstprsrc,"LABEL",VARIABLETEXT,0,(label!=NULL ? label:""),
		TRUE);
	addstdrsrc(genstprsrc,"LENGTH",SHORTV,3,&length,TRUE);
	typex=type;
	if(ftypes!=NULL) freeapplib(ftypes);
	ftypes=APPlibNEW();
	for(x=0;x<28;++x) addAPPlib(ftypes,standardfieldtypes[x]);
	addlstrsrc(genstprsrc,"FIELD TYPES",&typex,TRUE,changeftype,
		ftypes->numlibs,&ftypes->libs,NULL);
	addrfcbrsrc(genstprsrc,"SAVE",TRUE,savegenericsetup,mainrsrc);
	addrfcbrsrc(genstprsrc,"QUIT",TRUE,quitgenericsetuptest,mainrsrc);
	addbtnrsrc(genstprsrc,"HELP",TRUE,screenhelp,NULL);
	addbtnrsrc(genstprsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL);
	genstpdefaults=GetDefaults(genstprsrc);
	APPmakescrn(genstprsrc,TRUE,quitgenericsetup,mainrsrc,FALSE);
}
Esempio n. 4
0
void CCrossDlg::RestoreDefaults()
{
	INFO	Info;
	GetDefaults(Info);
	SetInfo(Info);
	Play(FALSE);
}
Esempio n. 5
0
/*
 * Initialize syslog(), if running as daemon.
 */
void
CustmsgInit(
	int logMode_a,	/* Syslog message flag.  0 if not running as a demon. */
	void (*notifyFunc_a)	/* Notify function */
	(int priority, int msg_num, char *msg))
{
	notifyFunc = notifyFunc_a;
	samCatopen();
	logMode = logMode_a;
#ifdef sun
	defaults = (sam_defaults_t *)GetDefaults();
#endif	/* sun */
}
Esempio n. 6
0
static void valuescreen(RDArsrc *mtnrsrc,double from,double amount,double base,
	double rate,void (*savefunc)(...),void (*quitfunctest)(...))
{
	incrsrc=RDArsrcNEW(module,"MAINTAIN TABLE VALUES");
	addstdrsrc(incrsrc,"FROM",SDECIMALV,20,&from,FALSE);
	addstdrsrc(incrsrc,"TO",SDECIMALV,20,&amount,TRUE);
	addstdrsrc(incrsrc,"BASE",SDECIMALV,20,&base,TRUE);
	addstdrsrc(incrsrc,"RATE",SDECIMALV,20,&rate,TRUE);
	addrfcbrsrc(incrsrc,"SAVE",TRUE,savefunc,mtnrsrc);
	addrfcbrsrc(incrsrc,"QUIT",TRUE,quitfunctest,mtnrsrc);
	addbtnrsrc(incrsrc,"HELP",TRUE,screenhelp,NULL);
	addbtnrsrc(incrsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL);
	incdefaults=GetDefaults(incrsrc);
	APPmakescrn(incrsrc,TRUE,quit_value,mtnrsrc,FALSE);
	FINDRSCSETINPUTFOCUS(incrsrc,"TO");
}
Esempio n. 7
0
void
Fonts::SizeInfoboxFont(unsigned control_width)
{
  auto default_settings = GetDefaults();

  AutoSizeInfoBoxFonts(default_settings, control_width);

  infobox.Load(default_settings.infobox);
  infobox_small.Load(default_settings.infobox_small);
#ifndef GNAV
  infobox_units.Load(default_settings.infobox_units);
#endif

#ifdef HAVE_TEXT_CACHE
  TextCache::Flush();
#endif
}
ULONG ObtainDefaults(  INSTANCE   *ulpInstance)



{
 ULONG ulrc;

  if ( !(ulpInstance->ulFlags & OBTAINDEFAULTS ) )
     {
     ulrc = GetDefaults( ulpInstance->szDevParm, ulpInstance );

     if ( ulrc )
        {
        return ( ulrc );
        }

     SetWaveDeviceDefaults (ulpInstance );
     }
  ulpInstance->ulFlags |= OBTAINDEFAULTS;
  return ( MCIERR_SUCCESS );

} /* ObtainDefaults */
Esempio n. 9
0
static void TableScreen(RDArsrc *mainrsrc,char *mod,char *name,char *title1,
	char *title2,char *desc,char inclusive,int num,TABLEVALUE *tv)
{
	int typex,x=0;
	RDArsrc *mtnrsrc=NULL;

	mtnrsrc=RDArsrcNEW(module,"MAINTAIN TABLES");
	addstdrsrc(mtnrsrc,"MODULE",VARIABLETEXT,15,(mod!=NULL ? mod:""),
		TRUE);
	addstdrsrc(mtnrsrc,"NAME",VARIABLETEXT,80,(name!=NULL ? name:""),
		TRUE);
	addstdrsrc(mtnrsrc,"TITLE 1",VARIABLETEXT,0,(title1!=NULL ? 
		title1:""),TRUE);
	addstdrsrc(mtnrsrc,"TITLE 2",VARIABLETEXT,0,(title2!=NULL ?
		title2:""),TRUE);
	addstdrsrc(mtnrsrc,"INCLUSIVE",BOOLNS,1,&inclusive,TRUE);
	addsctrsrc(mtnrsrc,"DESCRIPTION",0,(desc!=NULL ? desc:""),TRUE);
	if(tablelist!=NULL) freeapplib(tablelist);
	tablelist=APPlibNEW();
	typex=0;
	addlstrsrc(mtnrsrc,"TABLE VALUES",&typex,TRUE,NULL,
		tablelist->numlibs,&tablelist->libs,NULL);
	addbtnrsrc(mtnrsrc,"ADD VALUE ABOVE",TRUE,add_value_above,NULL);
	addbtnrsrc(mtnrsrc,"ADD VALUE BELOW",TRUE,add_value_below,NULL);
	addbtnrsrc(mtnrsrc,"DELETE VALUE",TRUE,delete_value,NULL);
	addbtnrsrc(mtnrsrc,"SELECT VALUE",TRUE,edit_value,NULL);
	makevalueslist();
	x=0;
	FINDRSCLISTAPPlib(mtnrsrc,"TABLE VALUES",x,tablelist);
	addrfcbrsrc(mtnrsrc,"SAVE",TRUE,savetable,mainrsrc);
	addrfcbrsrc(mtnrsrc,"QUIT",TRUE,quittabletest,mainrsrc);
	addbtnrsrc(mtnrsrc,"HELP",TRUE,screenhelp,NULL);
	addbtnrsrc(mtnrsrc,"PRINT RESOURCES",TRUE,printrsrcs,NULL);
	virtdefaults=GetDefaults(mtnrsrc);
	APPmakescrn(mtnrsrc,TRUE,quittable,mainrsrc,FALSE);
}
Esempio n. 10
0
/*
 * get SAM system log information
 *
 * Information is a list of formatted strings
 *
 * name=name,
 * type=Log/Trace,
 * state=on/off,
 * path=filename,
 * flags=flags,
 * size=size,
 * modtime=last modified time (num of seconds since 1970)
 */
int
get_samlog_lst(
	sqm_lst_t **lst_log
)
{
	sam_defaults_t *sam_defaults = NULL;
	char *log_keyword = NULL;
	char *flags = NULL;
	FILE *fp = NULL;
	char linebuf[BUFSIZ];

	char buffer[4096];

	/* log facility from defaults is an int, convert to syslog facility */
	if ((sam_defaults = GetDefaults()) == NULL) {
		Trace(TR_ERR, "Could not get sam log config");
		return (-1);
	}
	log_keyword = ifacility2sfacility(sam_defaults->log_facility);
	if (log_keyword == NULL) {
		Trace(TR_ERR, "Unrecognized system facility for sam log");
		return (-1);
	}

	if ((fp = fopen(SYSLOG_CONF, "r")) == NULL) {
		return (-1);
	}
	*lst_log = lst_create();

	/*
	 * res_stream format:facility.level [ ; facility.level ]<tab>action
	 *
	 * there can be multiple lines with this facility
	 * e.g.
	 * local7.debug	/var/adm/sam-debug
	 * local7.warn	/var/adm/sam-warn
	 * local7.crit	/var/adm/sam-crit
	 */
	while (fgets(linebuf, BUFSIZ, fp)) {

		linebuf[BUFSIZ - 1] = '\0';

		char *lptr = linebuf;

		/* ignore whitespaces, empty lines and comments */
		lptr += strspn(lptr, WHITESPACE);
		if (lptr[0] == CHAR_POUND) {
			continue;
		}
		if (strstr(lptr, log_keyword) == NULL) {
			continue;
		}
		char *facility = NULL, *action = NULL, *lasts = NULL;
		if ((facility = strtok_r(lptr, WHITESPACE, &lasts)) != NULL) {
			action = strtok_r(NULL, WHITESPACE, &lasts);
		}
		if (facility == NULL || action == NULL) { /* ignore */
			continue;
		}
		Trace(TR_MISC, "facility=%s, action=%s", facility, action);
		char *keyword = NULL;
		flags = NULL;
		lasts = NULL;
		/* tokenize facility to get keyword and flag */
		if ((keyword = strtok_r(facility, COLON, &lasts)) != NULL) {
			flags = strtok_r(NULL, ":", &lasts);
			flags = (flags != NULL) ? flags : "";
		}
		free(keyword);

		struct stat statbuf;
		off_t size = 0; long age = 0;

		if (stat(action, &statbuf) == 0) {
			size = statbuf.st_size;
			age = statbuf.st_mtime;
		}
		snprintf(buffer, sizeof (buffer),
		    "%s=%s, %s=%s, %s=%s, %s=%s, %s=%s, %s=%ld, %s=%lu",
		    KEY_NAME,
		    GetCustMsg(SE_SYSTEM_LOG_DESC),
		    KEY_TYPE, GetCustMsg(SE_TYPE_LOG),
		    KEY_STATE, STATE_ON,
		    KEY_PATH, action,
		    KEY_FLAGS, flags,
		    KEY_SIZE, size,
		    KEY_MODTIME, age);

		lst_append(*lst_log, strdup(buffer));
		buffer[0] = '\0';
	}
	free(log_keyword);
	fclose(fp);
	Trace(TR_MISC, "SAM system log info obtained");
	return (0);

}
Esempio n. 11
0
int
main(int argc, char **argv)
{
	int			what_signal, i;
	char			*ent_pnt = "main";
	char			logname[20];
	char			*l_mess, *lc_mess;
	sigset_t		sigwait_set;
	struct sigaction	sig_action;
	dev_ptr_tbl_t		*dev_ptr_tbl;
	shm_ptr_tbl_t		*shm_ptr_tbl;
	sam_defaults_t		*defaults;

	if (argc != 4)
		exit(1);

	initialize_fatal_trap_processing(SOLARIS_THREADS, fatal_cleanup);

	CustmsgInit(1, NULL);

	library = (library_t *)malloc_wait(sizeof (library_t), 2, 0);
	(void) memset(library, 0, sizeof (library_t));

	/*
	 * Crack the arguments
	 */
	argv++;
	master_shm.shmid = atoi(*argv);
	argv++;
	preview_shm.shmid = atoi(*argv);
	argv++;
	library->eq = atoi(*argv);
	mypid = getpid();
	if ((master_shm.shared_memory = shmat(master_shm.shmid, NULL, 0774)) ==
	    (void *)-1)
		exit(2);

	shm_ptr_tbl = (shm_ptr_tbl_t *)master_shm.shared_memory;

	if ((preview_shm.shared_memory =
	    shmat(preview_shm.shmid, NULL, 0774)) == (void *)-1)
		exit(3);

	fifo_path = strdup(SHM_REF_ADDR(shm_ptr_tbl->fifo_path));

	sprintf(logname, "sony-%d", library->eq);
	defaults = GetDefaults();
	openlog(logname, LOG_PID | LOG_NOWAIT, defaults->log_facility);

	dev_ptr_tbl = (dev_ptr_tbl_t *)SHM_REF_ADDR(
	    ((shm_ptr_tbl_t *)master_shm.shared_memory)->dev_table);

	/* LINTED pointer cast may result in improper alignment */
	library->un = (dev_ent_t *)
	    SHM_REF_ADDR(dev_ptr_tbl->d_ent[library->eq]);
	/* LINTED pointer cast may result in improper alignment */
	library->help_msg = (sony_priv_mess_t *)
	    SHM_REF_ADDR(library->un->dt.rb.private);
	l_mess = library->un->dis_mes[DIS_MES_NORM];
	lc_mess = library->un->dis_mes[DIS_MES_CRIT];

	/* check if we should log sef data */
	(void) sef_status();

	if (DBG_LVL(SAM_DBG_RBDELAY)) {
		int ldk = 60;

		sam_syslog(LOG_DEBUG, "Waiting for 60 seconds.");
		while (ldk > 0 && DBG_LVL(SAM_DBG_RBDELAY)) {
			sprintf(lc_mess, "waiting for %d seconds pid %d",
			    ldk, mypid);
			sleep(10);
			ldk -= 10;
		}
		*lc_mess = '\0';
	}

	mutex_init(&library->mutex, USYNC_THREAD, NULL);

	/*
	 * Hold the lock until initialization is complete
	 */
	mutex_lock(&library->mutex);
	common_init(library->un);
	mutex_init(&library->help_msg->mutex, USYNC_PROCESS, NULL);
	cond_init(&library->help_msg->cond_i, USYNC_PROCESS, NULL);
	cond_init(&library->help_msg->cond_r, USYNC_PROCESS, NULL);
	library->help_msg->mtype = SONY_PRIV_VOID;

	/*
	 * Start the main threads
	 */
	if (thr_create(NULL, DF_THR_STK, monitor_msg, (void *)library,
	    (THR_BOUND | THR_NEW_LWP | THR_DETACHED),
	    &threads[SONY_MSG_THREAD])) {
		sam_syslog(LOG_ERR,
		    "Unable to start thread monitor_msg: %m.\n");
		thr_exit(NULL);
	}

	if (thr_create(NULL, MD_THR_STK, manage_list, (void *)library,
	    (THR_BOUND |THR_NEW_LWP | THR_DETACHED),
	    &threads[SONY_WORK_THREAD])) {
		sam_syslog(LOG_ERR,
		    "Unable to start thread manage_list: %m.\n");
		thr_kill(threads[SONY_MSG_THREAD], SIGINT);
		thr_exit(NULL);
	}

	mutex_lock(&library->un->mutex);
	library->un->dt.rb.process = getpid();
	library->un->status.b.ready = FALSE;
	library->un->status.b.present = FALSE;
	mutex_unlock(&library->un->mutex);

	/*
	 * Initialize the library. This will release the library mutex.
	 */
	memccpy(l_mess, catgets(catfd, SET, 9065, "initializing"),
	    '\0', DIS_MES_LEN);
	if (initialize(library, dev_ptr_tbl))
		thr_exit(NULL);

	/*
	 * Now let the other threads run
	 */
	thr_yield();

	mutex_lock(&library->mutex);
	i = 30;

	{
		char *MES_9155 = catgets(catfd, SET, 9155,
		    "waiting for %d drives to initialize");
		char *mes = (char *)malloc_wait(strlen(MES_9155) + 15, 5, 0);

		while (library->countdown && i-- > 0) {
			sprintf(mes, MES_9155, library->countdown);
			memccpy(l_mess, mes, '\0', DIS_MES_LEN);
			sam_syslog(LOG_INFO, catgets(catfd, SET, 9156,
			    "%s: Waiting for %d drives to initialize."),
			    ent_pnt, library->countdown);
			mutex_unlock(&library->mutex);
			sleep(10);
			mutex_lock(&library->mutex);
		}
		free(mes);
	}

	if (i <= 0)
		sam_syslog(LOG_INFO,
		    catgets(catfd, SET, 9157,
		    "%s: %d drive(s) did not initialize."),
		    ent_pnt, library->countdown);

	mutex_unlock(&library->mutex);
	memccpy(l_mess, "running", '\0', DIS_MES_LEN);
	mutex_lock(&library->un->mutex);
	library->un->status.b.audit = FALSE;
	library->un->status.b.requested = FALSE;
	library->un->status.b.mounted = TRUE;
	library->un->status.b.ready = TRUE;
	mutex_unlock(&library->un->mutex);

	/*
	 * Now that the daemon is fully initialized, the main thread is
	 * just used to monitor the thread state and an indication of shutdown.
	 * This is accomplished using the signals SIGALRM, SIGINT, and SIGTERM.
	 * This is not done with a signal handler, but using the sigwait() call.
	 */
	sigemptyset(&sigwait_set);
	sigaddset(&sigwait_set, SIGINT);
	sigaddset(&sigwait_set, SIGTERM);
	sigaddset(&sigwait_set, SIGALRM);

	/* want to restart system calls */
	sig_action.sa_handler = SIG_DFL;
	sigemptyset(&sig_action.sa_mask);
	sig_action.sa_flags = SA_RESTART;

	sigaction(SIGINT, &sig_action, NULL);
	sigaction(SIGTERM, &sig_action, NULL);
	sigaction(SIGALRM, &sig_action, NULL);
	for (;;) {
		alarm(20);
		what_signal = sigwait(&sigwait_set);
		switch (what_signal) {

			case SIGALRM:
				if ((threads[SONY_MSG_THREAD] ==
				    (thread_t)-1) ||
				    (threads[SONY_WORK_THREAD] ==
				    (thread_t)-1)) {
					/*
					 * If any of the processing threads
					 * have disappeared, log the
					 * fact, and take a core dump
					 */
					sam_syslog(LOG_INFO,
					    "%s: SIGALRM: Thread(s) gone.",
					    ent_pnt);
					abort();
				}
				break;

			/*
			 * For a normal shutdown of the robot daemon:
			 *  1) prevent the alarm from going off during
			 *    shutdown and causing a core dump
			 *  2) log the reason we are shutting down
			 *  3) kill the helper pid if there is one
			 *  4) terminate the connection to the catalog
			 *  5) terminate all of the processing threads
			 */
			case SIGINT:
			case SIGTERM:
				sigdelset(&sigwait_set, SIGALRM);
				sam_syslog(LOG_INFO,
				    "%s: Shutdown by signal %d",
				    ent_pnt, what_signal);
				if (library->helper_pid > 0) {
					kill(library->helper_pid, 9);
				}
				kill_off_threads(library);
				exit(0);
				break;

			default:
				break;
		}
	}
}
Esempio n. 12
0
/*
 * audit - start auditing
 *
 *
 */
void
audit(
	drive_state_t *drive,	/* drive state pointer */
	const uint_t slot,		/* slot to audit */
	const int audit_eod)
{				/* flag to find eod during audit */
	int		part, err;
	uint_t	   myslot = 0;
	dev_ent_t	*un;
	sam_defaults_t *defaults;
	struct CatalogEntry ced;
	struct CatalogEntry *ce = &ced;
	int		skip_audit_eod = 0;

	defaults = GetDefaults();

	SANITY_CHECK(drive != (drive_state_t *)0);
	SANITY_CHECK(drive->library != (library_t *)0);
	SANITY_CHECK(drive->library->un != (dev_ent_t *)0);
	SANITY_CHECK(drive->library->un != drive->un);
	un = drive->un;

	if ((slot == ROBOT_NO_SLOT) &&
	    IS_GENERIC_API(drive->library->un->type)) {
		DevLog(DL_ERR(6004));
		return;
	}
	mutex_lock(&drive->mutex);

	if (drive->status.b.full) {
		mutex_lock(&un->mutex);
		un->status.b.requested = TRUE;
		mutex_unlock(&un->mutex);
		if (clear_drive(drive)) {
			mutex_lock(&un->mutex);
			un->status.b.requested = TRUE;
			mutex_unlock(&un->mutex);
			mutex_unlock(&drive->mutex);
			return;
		}
		if (drive->open_fd >= 0) {
			mutex_lock(&un->mutex);
			close_unit(un, &drive->open_fd);
			DEC_OPEN(un);
			mutex_unlock(&un->mutex);
		}
	}
	mutex_unlock(&drive->mutex);

	mutex_lock(&un->mutex);
	un->status.b.requested = TRUE;
	un->status.b.labeled = FALSE;
	un->status.b.ready = FALSE;
	mutex_unlock(&un->mutex);

	if (slot == ROBOT_NO_SLOT) {
		mutex_lock(&drive->library->mutex);
		drive->library->countdown--;
		drive->library->drives_auditing++;
		mutex_unlock(&drive->library->mutex);

		/*
		 * ok not to lock here wait for all drives to clear
		 */
		while (drive->library->countdown > 0)
			sleep(4);
	}
	for (;;) {

		mutex_lock(&drive->mutex);
		if (slot == ROBOT_NO_SLOT) {
			/* get the next slot number (s) */
			mutex_lock(&drive->library->mutex);
			myslot = drive->library->audit_index;
			if (myslot <= drive->library->range.storage_count) {
				drive->library->audit_index++;
				mutex_unlock(&drive->library->mutex);
			} else {
				/* No more slots to audit */
				mutex_unlock(&drive->library->mutex);
				mutex_lock(&drive->library->un->mutex);
				drive->library->un->status.b.mounted = TRUE;
				drive->library->un->status.b.audit = FALSE;
				drive->library->un->status.b.ready = TRUE;
				mutex_unlock(&drive->library->un->mutex);
				if (drive->status.b.full) {
					clear_drive(drive);
					if (drive->open_fd >= 0)
						mutex_lock(&un->mutex);
					close_unit(un, &drive->open_fd);
					mutex_unlock(&un->mutex);
				}
				mutex_lock(&un->mutex);
				un->status.b.requested = FALSE;
				mutex_unlock(&un->mutex);
				mutex_unlock(&drive->mutex);
				return;
			}
		} else {
			/* get specific slot */
			myslot = slot;
		}

		/*
		 * Should we audit this media? (is occupied, not cleaning and
		 * is a sam tape)
		 */
		if (drive->library->status.b.two_sided) {
			part = 1;
		} else {
			part = 0;
		}
		ce = CatalogGetCeByLoc(drive->library->un->eq,
			    myslot, part, &ced);
		if (ce == NULL ||
		    (!(ce->CeStatus & CES_occupied)) ||
		    (ce->CeStatus & CES_cleaning) ||
		    (ce->CeStatus & CES_non_sam)) {

			mutex_unlock(&drive->mutex);
			if (slot != ROBOT_NO_SLOT) {	/* only one slot */
				mutex_lock(&un->mutex);
				un->status.b.requested = FALSE;
				mutex_unlock(&un->mutex);
				return;
			}
			continue;
		}
		/*
		 * The following lines of code get a tape mounted, or if
		 * two-sided media, mounts the "A" side.
		 */
		err = get_media(drive->library, drive, NULL, ce);

		if (err) {
			mutex_lock(&un->mutex);
			un->status.b.requested = FALSE;
			DEC_ACTIVE(un);
			mutex_unlock(&un->mutex);
			mutex_unlock(&drive->mutex);
			return;
		}
		mutex_lock(&un->mutex);
		un->status.b.scanning = TRUE;
		mutex_unlock(&un->mutex);
		if (spin_drive(drive, SPINUP, NOEJECT)) {

			mutex_lock(&drive->un->mutex);
			drive->un->status.b.scanning &= ~DVST_SCANNING;
			drive->un->status.bits &= ~DVST_REQUESTED;
			mutex_unlock(&drive->un->mutex);

			if (un->state > DEV_ON) {
				clear_drive(drive);
				mutex_lock(&un->mutex);
				clear_driver_idle(drive, drive->open_fd);
				DEC_ACTIVE(un);
				close_unit(un, &drive->open_fd);
				mutex_unlock(&un->mutex);
				mutex_unlock(&drive->mutex);
			} else {
				mutex_lock(&un->mutex);
				clear_driver_idle(drive, drive->open_fd);
				DEC_ACTIVE(un);
				close_unit(un, &drive->open_fd);
				mutex_unlock(&un->mutex);
				mutex_unlock(&drive->mutex);
			}
			SendCustMsg(HERE, 9348);
			DevLog(DL_ERR(5218));
			return;
		}
		un->status.bits |= DVST_AUDIT;

		un->mid = ce->CeMid;
		un->status.b.labeled = FALSE;
		un->i.ViPart = ce->CePart;
		scan_a_device(un, drive->open_fd);
		if (drive->status.b.bar_code) {
			(void) CatalogSetStringByLoc(drive->library->un->eq,
			ce->CeSlot, ce->CePart,
			CEF_BarCode, (char *)drive->bar_code);
		}
		/*
		 * If the cleaning light came on while scanning, leave the
		 * audit bit set and unload the drive.
		 */
		if (un->status.bits & DVST_CLEANING) {
			mutex_lock(&un->mutex);
			un->mtime = 0;
			DEC_ACTIVE(un);
			close_unit(un, &drive->open_fd);
			un->status.b.requested = FALSE;
			mutex_unlock(&un->mutex);
			clear_drive(drive);
			mutex_unlock(&drive->mutex);
			return;
		} else {
			un->status.bits &= ~DVST_AUDIT;
		}

		mutex_lock(&un->mutex);
		/*
		 * This next check keeps us from auditing media that is not
		 * really labeled (label lie). I'm not sure why the un->mutex
		 * is held for this.
		 */
		if (!un->status.b.labeled &&
		    (ce->CeStatus & CES_bar_code) &&
		    (defaults->flags & DF_LABEL_BARCODE)) {
			int tmp;

			if (IS_TAPE(un)) {
				tmp = LEN_TAPE_VSN;
			} else {
				tmp = LEN_OPTIC_VSN;
			}
			vsn_from_barcode(un->vsn, ce->CeBarCode, defaults, tmp);
			un->status.b.labeled = TRUE;
			un->space = un->capacity;
			skip_audit_eod = 1;
		}
		if (IS_TAPE(un)) {
			if (un->status.b.labeled &&
			    audit_eod && !skip_audit_eod) {
				DevLog(DL_DETAIL(5074), un->vsn);
				mutex_unlock(&un->mutex);
				mutex_lock(&un->io_mutex);
				tape_append(drive->open_fd, un, NULL);
				mutex_unlock(&un->io_mutex);
				mutex_lock(&un->mutex);
			} else {
				if (!un->status.b.labeled) {
					un->space = un->capacity;
				} else {
					un->space = ce->CeSpace;
				}
			}
		}
		UpdateCatalog(un, 0, CatalogVolumeLoaded);

		/*
		 * Now do the "B" side if this is optical media.
		 * flip_and_scan calls CatalogVolumeLoaded so it is not done
		 * here.
		 */
		if (drive->library->status.b.two_sided && (ce->CePart == 1)) {
			mutex_unlock(&un->mutex);
			if (flip_and_scan(ce->CePart, drive)) {
				clear_drive(drive);
				mutex_lock(&un->mutex);
				un->status.b.requested = FALSE;
				clear_driver_idle(drive, drive->open_fd);
				close_unit(un, &drive->open_fd);
				DEC_ACTIVE(un);
				mutex_unlock(&un->mutex);
				mutex_unlock(&drive->mutex);
				return;
			}
			mutex_unlock(&drive->mutex);
		} else {
			mutex_unlock(&un->mutex);
			mutex_unlock(&drive->mutex);
		}

		mutex_lock(&un->mutex);
		close_unit(un, &drive->open_fd);
		DEC_ACTIVE(un);
		un->status.b.requested = TRUE;
		mutex_unlock(&un->mutex);

		if (slot != ROBOT_NO_SLOT) {	/* only one slot */
			mutex_lock(&un->mutex);
			un->status.b.requested = FALSE;
			mutex_unlock(&un->mutex);
			mutex_lock(&drive->library->un->mutex);
			drive->library->un->status.b.mounted = TRUE;
			mutex_unlock(&drive->library->un->mutex);
			return;
		}
	}
}
Esempio n. 13
0
/*
 * ConfigDlgProc - handle messages from the configure dialog
 */
BOOL FAR PASCAL ConfigDlgProc( HWND hwnd, WORD msg, WORD wparam, DWORD lparam )
{
    MemWndConfig        info;
    HeapConfigInfo      heapdef;
    char                buf[_MAX_PATH];

    lparam = lparam;
    switch( msg ) {
    case WM_INITDIALOG:
        GetMemWndConfig( &info );
        SetupConfigDlg( &Config, &info, hwnd );
        break;
    case WM_SYSCOLORCHANGE:
        CvrCtl3dColorChange();
        break;
    case WM_COMMAND:
        switch( wparam ) {
        case CONFIG_GLOB_BROWSE:
            doFileBrowse( hwnd, CONFIG_GNAME );
            break;
        case CONFIG_LOCAL_BROWSE:
            doFileBrowse( hwnd, CONFIG_LNAME );
            break;
        case CONFIG_MEM_BROWSE:
            doFileBrowse( hwnd, CONFIG_MNAME );
            break;
        case CONFIG_DEFAULT:
            GetMemWndDefault( &info );
            GetDefaults( &heapdef );
            SetupConfigDlg( &heapdef, &info, hwnd );
            break;
        case CONFIG_OK:
            GetDlgItemText( hwnd, CONFIG_GNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_GLOB_FNAME,
                              buf, MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetDlgItemText( hwnd, CONFIG_LNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_LCL_FNAME, buf,
                            MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetDlgItemText( hwnd, CONFIG_MNAME, buf, _MAX_PATH );
            if( !ValidateFName( buf ) ) {
                GetWindowText( hwnd, buf, sizeof( buf ) );
                RCMessageBox( hwnd, STR_INVALID_MEM_FNAME, buf,
                            MB_OK | MB_ICONEXCLAMATION );
                break;
            }
            GetMemWndConfig( &info );
            info.autopos_info = IsDlgButtonChecked( hwnd, CONFIG_AUTOPOS );
            info.disp_info = IsDlgButtonChecked( hwnd, CONFIG_DISP_MEM_INFO );
            if( IsDlgButtonChecked( hwnd, CONFIG_MULT_MEM_WND ) ) {
                info.allowmult = WND_MULTI;
            } else {
                info.allowmult = WND_REPLACE;
            }
            Config.disp_res = IsDlgButtonChecked( hwnd, CONFIG_DISP_RES );
            Config.save_glob_pos = IsDlgButtonChecked( hwnd,
                                                       CONFIG_SAVE_MAIN_POS );
            Config.save_mem_pos = IsDlgButtonChecked( hwnd,
                                                       CONFIG_SAVE_MEM_POS );
            GetDlgItemText( hwnd, CONFIG_GNAME, Config.gfname, _MAX_PATH );
            GetDlgItemText( hwnd, CONFIG_LNAME, Config.lfname, _MAX_PATH );
            GetDlgItemText( hwnd, CONFIG_MNAME, info.fname, _MAX_PATH );
            SetMemWndConfig( &info );
            /* fall through */
        case CONFIG_CANCEL:
            EndDialog( hwnd, FALSE );
            break;
        default:
            return( FALSE );
        }
        break;
    case WM_CLOSE:
        EndDialog( hwnd, 0 );
        break;
    default:
        return( FALSE );
    }
    return( TRUE );
} /* ConfigDlgProc */
Esempio n. 14
0
/*
 * export media from a library
 *
 * Programming note:  The parameter passed in was malloc'ed, be sure
 * to free it before thr_exit.
 */
void *
fifo_cmd_export_media(
	void *vcmd)
{
	sam_cmd_fifo_t *command = (sam_cmd_fifo_t *)vcmd;
	sam_defaults_t *defaults;
	export_request_t *request;
	dev_ent_t *device;

	/* equipment was verified in the caller */
	device = DEV_ENT(command->eq);

	defaults = GetDefaults();

	/* Must be a member of a family set or an entire robot */
	if (device->fseq) {
		message_request_t *message;

		/* The command is always sent to the robot */
		device = DEV_ENT(device->fseq);
		message =
		    (message_request_t *)SHM_REF_ADDR(device->dt.rb.message);
		request = &message->message.param.export_request;

		if (IS_ROBOT(device) &&
		    (device->status.b.ready && device->status.b.present)) {
			boolean_t issue = TRUE;

			(void) mutex_lock(&message->mutex);
			while (message->mtype != MESS_MT_VOID) {
				cond_wait(&message->cond_i, &message->mutex);
			}
			memset(&message->message, 0, sizeof (sam_message_t));
			message->message.magic = MESSAGE_MAGIC;
			message->message.command = MESS_CMD_EXPORT;
			message->message.exit_id = command->exit_id;
			request->flags = command->flags;
			request->eq = command->eq;
			request->flags &= ~EXPORT_FLAG_MASK;
			switch (command->cmd) {
			case CMD_FIFO_REMOVE_V:
				memmove(&request->vsn, &command->vsn, 32);
				set_media_to_default(
				    (media_t *)&command->media, defaults);
				request->media = command->media;
				request->slot = (uint_t)ROBOT_NO_SLOT;
				request->flags |= EXPORT_BY_VSN;
				break;

			case CMD_FIFO_REMOVE_S:
				request->slot = command->slot;
				request->flags |= EXPORT_BY_SLOT;
				break;

			case CMD_FIFO_REMOVE_E:
				request->eq = command->eq;
				request->slot = (uint_t)ROBOT_NO_SLOT;
				request->flags |= EXPORT_BY_EQ;
				break;

			default:
				sam_syslog(LOG_ERR,
				    "fifo_cmd_export_media: unknown switch"
				    "(%#x): %s:%s\n",
				    command->cmd, __FILE__, __LINE__);
				issue = FALSE;
				break;
			}

			if (issue) {
				message->mtype = MESS_MT_NORMAL;
			} else {
				message->mtype = MESS_MT_VOID;
				message->message.exit_id.pid = 0;
			}

			cond_signal(&message->cond_r);
			mutex_unlock(&message->mutex);
		}
	}
	free(command);			/* free the command buffer */
	thr_exit(NULL);
/* LINTED Function has no return statement */
}
Esempio n. 15
0
/*
 * tell scanner to start label process.  Runs as a thread.
 *
 * Programming note:  The parameter passed in was malloc'ed, be sure
 * to free it before thr_exit.
 */
void *
scanner_label(
	void *vcmd)
{
	sam_cmd_fifo_t *command = (sam_cmd_fifo_t *)vcmd;
	sam_defaults_t *defaults;
	dev_ent_t *device;
	message_request_t *message;

	/* equipment was verified in the caller */
	device = DEV_ENT(command->eq);
	message = (message_request_t *)SHM_REF_ADDR
	    (((shm_ptr_tbl_t *)master_shm.shared_memory)->scan_mess);
	defaults = GetDefaults();

	set_media_to_default((media_t *)& command->media, defaults);

	if (!(device->status.bits & DVST_SCANNING) &&
	    (device->status.bits & (DVST_READY | DVST_PRESENT))) {
		DTB((uchar_t *)command->vsn, sizeof (vsn_t));

		(void) mutex_lock(&message->mutex);
		while (message->mtype != MESS_MT_VOID)
			cond_wait(&message->cond_i, &message->mutex);

		(void) memset(&message->message, 0, sizeof (sam_message_t));
		message->message.magic = MESSAGE_MAGIC;
		message->message.exit_id = command->exit_id;
		message->message.command = MESS_CMD_LABEL;
		message->message.param.label_request.flags = command->flags;
		message->message.param.label_request.slot = command->eq;
		message->message.param.label_request.part = command->part;
		message->message.param.label_request.media = command->media;
		message->message.param.label_request.block_size =
		    command->block_size;

		memmove(&(message->message.param.label_request.vsn),
		    &(command->vsn), sizeof (vsn_t));
		memmove(&(message->message.param.label_request.old_vsn),
		    &(command->old_vsn), sizeof (vsn_t));
		memmove(&(message->message.param.label_request.info),
		    &(command->info), 127);
		message->mtype = MESS_MT_NORMAL;
		cond_signal(&message->cond_r);	/* wake up robot */
		mutex_unlock(&message->mutex);
	} else {
		char *msg1, *msg2;
		int		 len;

		msg1 = catgets(catfd, SET, 20009,
		    "Device not ready for labeling (eq %d)");
		/* allow some room for the equipment number to expand */
		msg2 = (char *)malloc_wait((len = (strlen(msg1) + 20)), 4, 0);
		memset(msg2, 0, len);
		sprintf(msg2, msg1, device->eq);
		write_client_exit_string(&command->exit_id, EXIT_FAILED, msg2);
		sam_syslog(LOG_WARNING, msg2);
		free(msg2);
	}

	free(command);			/* free the command buffer */
	thr_exit(NULL);
/* LINTED Function has no return statement */
}