Esempio n. 1
0
/*
 *	dismount_media - unload a volser
 *
 */
req_comp_t
dismount_media(
	library_t *library,
	drive_state_t *drive)
{
	req_comp_t 	err;
	ibm_req_info_t 	*ibm_info;
	xport_state_t 	*transport;
	robo_event_t 	*dismount, *tmp;

	ibm_info = malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->drive_id = drive->drive_id;
	sprintf((void *)&ibm_info->volser, "%-8.8s", drive->bar_code);

	/* Build transport thread request */

	dismount = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(dismount, 0, sizeof (robo_event_t));

	dismount->request.internal.command = ROBOT_INTRL_DISMOUNT_MEDIA;
	dismount->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "dismount_media: from %s.",
		    drive->un->name);

	dismount->type = EVENT_TYPE_INTERNAL;
	dismount->status.bits = REST_SIGNAL;
	dismount->completion = REQUEST_NOT_COMPLETE;

	transport = library->transports;
	mutex_lock(&dismount->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = dismount;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, dismount);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the unload */
	while (dismount->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&dismount->condit, &dismount->mutex);
	mutex_unlock(&dismount->mutex);

	/* Check the dismount request/helper status */
	err = (req_comp_t)dismount->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "Return from transport dismount (%#x).",
		    dismount->completion);
	free(ibm_info);
	mutex_destroy(&dismount->mutex);
	free(dismount);
	return (err);
}
Esempio n. 2
0
/*
 *	force_media - unload a drive. Issued as a delayed request.
 *
 */
req_comp_t
force_media(
	library_t *library,
	drive_state_t *drive)
{
	req_comp_t 	err;
	ibm_req_info_t 	*ibm_info;
	robo_event_t 	*force, *tmp;
	xport_state_t 	*transport;

	ibm_info = (ibm_req_info_t *)malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->drive_id = drive->drive_id;

	/* Build transport thread request */

	force = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(force, 0, sizeof (robo_event_t));

	force->request.internal.command = ROBOT_INTRL_FORCE_MEDIA;
	force->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "force_media: from %s.", drive->un->name);

	force->type = EVENT_TYPE_INTERNAL;
	force->status.bits = REST_SIGNAL;
	force->completion = REQUEST_NOT_COMPLETE;

	transport = library->transports;
	mutex_lock(&force->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = force;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, force);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the unload */
	while (force->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&force->condit, &force->mutex);
	mutex_unlock(&force->mutex);

	err = (req_comp_t)force->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG,
		    "Return from transport force (%#x).", force->completion);

	free(ibm_info);
	mutex_destroy(&force->mutex);
	free(force);
	return (err);
}
Esempio n. 3
0
P1(PUBLIC pascal trap, void, LDispose, ListHandle, list)	/* IMIV-271 */
{
  if (list)
    {
      LISTDECL();
      LISTBEGIN(list);
      LISTCALL(lCloseMsg, FALSE, (Rect *)0, * (Cell *) &HxX(list, clikLoc), 0,
	       0, list);
      LISTEND(list);

      DisposHandle((Handle) HxP(list, cells));
      if (HxP(list, hScroll))
	DisposeControl(HxP(list, hScroll));
      if (HxP(list, vScroll))
	DisposeControl(HxP(list, vScroll));
    }
#if defined (LIST_DEBUG)
  delete_list (list);
#endif  
}
Esempio n. 4
0
/*
 *	set_media_category - change the category of media.
 */
req_comp_t
set_media_category(
	library_t *library,
	char *volser,
	ushort_t src_cat,	/* source category */
	ushort_t targ_cat)
{
	req_comp_t	err;
	ibm_req_info_t 	*ibm_info;
	xport_state_t 	*transport;
	robo_event_t 	*set, *tmp;

	ibm_info = malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->targ_cat = targ_cat;
	ibm_info->src_cat = src_cat;
	sprintf((void *)&ibm_info->volser, "%-8.8s", volser);

	/* Build transport thread request */
	set = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(set, 0, sizeof (robo_event_t));
	set->request.internal.command = ROBOT_INTRL_SET_CATEGORY;
	set->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG,
		    "set_media_category: %s %#x->%#x.", volser, src_cat,
		    targ_cat);

	set->type = EVENT_TYPE_INTERNAL;
	set->status.bits = REST_SIGNAL;
	set->completion = REQUEST_NOT_COMPLETE;
	transport = library->transports;

	mutex_lock(&set->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = set;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, set);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the request */
	while (set->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&set->condit, &set->mutex);
	mutex_unlock(&set->mutex);

	err = (req_comp_t)set->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "Return from set (%#x).",
		    set->completion);

	free(ibm_info);
	mutex_destroy(&set->mutex);
	free(set);
	return (err);
}
Esempio n. 5
0
/*
 *	query_library - send the supplied query to the library.
 */
req_comp_t
query_library(
	library_t *library,
	int seqno,		/* starting-1 sequence number */
	int sub_cmd,		/* what query */
	void **ret_data,	/* return data */
	ushort_t category)
{
	req_comp_t 	err;
	ibm_req_info_t 	*ibm_info;
	xport_state_t 	*transport;
	robo_event_t 	*view, *tmp;

	ibm_info = malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->sub_cmd = sub_cmd;
	ibm_info->src_cat = category;
	ibm_info->seqno = seqno;
	memset(&ibm_info->volser[0], ' ', 8);

	/* Build transport thread request */
	view = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(view, 0, sizeof (robo_event_t));
	view->request.internal.command = ROBOT_INTRL_QUERY_LIBRARY;
	view->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "query_library: %#x.", sub_cmd);

	view->type = EVENT_TYPE_INTERNAL;
	view->status.bits = REST_SIGNAL;
	view->completion = REQUEST_NOT_COMPLETE;
	transport = library->transports;

	mutex_lock(&view->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = view;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, view);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the request */
	while (view->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&view->condit, &view->mutex);
	mutex_unlock(&view->mutex);

	err = (req_comp_t)view->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "Return from query_library (%#x).",
		    view->completion);
	if (!err) {
		*ret_data = malloc_wait(sizeof (IBM_query_info_t), 2, 0);
		memcpy(*ret_data, ibm_info->ret_data,
		    sizeof (IBM_query_info_t));
	} else
		*ret_data = NULL;

	free(ibm_info);
	mutex_destroy(&view->mutex);
	free(view);
	return (err);
}
Esempio n. 6
0
/*
 *	view_media - view a database entry
 */
req_comp_t
view_media(
	library_t *library,
	char *vsn,
	void **ret_data)
{
	req_comp_t 	err;
	ibm_req_info_t 	*ibm_info;
	xport_state_t 	*transport;
	robo_event_t 	*view, *tmp;

	ibm_info = malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->sub_cmd = MT_QEVD;	/* view a single data base entry */
	sprintf((void *)&ibm_info->volser, "%-8.8s", vsn);

	/* Build transport thread request */
	view = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(view, 0, sizeof (robo_event_t));
	view->request.internal.command = ROBOT_INTRL_VIEW_DATABASE;
	view->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "view_media: %s.", vsn);

	view->type = EVENT_TYPE_INTERNAL;
	view->status.bits = REST_SIGNAL;
	view->completion = REQUEST_NOT_COMPLETE;

	transport = library->transports;

	mutex_lock(&view->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = view;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, view);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the request */
	while (view->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&view->condit, &view->mutex);
	mutex_unlock(&view->mutex);

	err = (req_comp_t)view->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG, "Return from view (%#x).",
		    view->completion);

	if (!err) {
		*ret_data = malloc_wait(sizeof (IBM_query_info_t), 2, 0);
		memcpy(*ret_data, ibm_info->ret_data,
		    sizeof (IBM_query_info_t));
	} else
		*ret_data = NULL;

	free(ibm_info);
	mutex_destroy(&view->mutex);
	free(view);
	return (err);
}
Esempio n. 7
0
/*
 *	load_media - load media into a drive
 *
 */
req_comp_t
load_media(
	library_t *library,
	drive_state_t *drive,
	struct CatalogEntry *ce,
	ushort_t category)
{
	req_comp_t 	err;
	xport_state_t 	*transport;
	robo_event_t 	*load, *tmp;
	ibm_req_info_t 	*ibm_info;

	ibm_info = malloc_wait(sizeof (ibm_req_info_t), 2, 0);
	memset(ibm_info, 0, sizeof (ibm_req_info_t));
	ibm_info->drive_id = drive->drive_id;
	ibm_info->src_cat = category;

	if (ce != NULL)
		memcpy((void *)&drive->bar_code, ce->CeBarCode, 8);
	else {
		memset((void *)&drive->bar_code, 0, 8);
		memset((void *)&drive->bar_code, ' ', 6);
	}

	sprintf((void *)&ibm_info->volser, "%-8.8s", drive->bar_code);

	/* Build transport thread request */
	load = malloc_wait(sizeof (robo_event_t), 5, 0);
	(void) memset(load, 0, sizeof (robo_event_t));
	load->request.internal.command = ROBOT_INTRL_LOAD_MEDIA;
	load->request.internal.address = (void *)ibm_info;

	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG,
		    "load_media(%d): from %s to %s.", LIBEQ, drive->bar_code,
		    drive->un->name);

	load->type = EVENT_TYPE_INTERNAL;
	load->status.bits = REST_SIGNAL;
	load->completion = REQUEST_NOT_COMPLETE;

	transport = library->transports;
	mutex_lock(&load->mutex);
	mutex_lock(&transport->list_mutex);
	if (transport->active_count == 0)
		transport->first = load;
	else {
		LISTEND(transport, tmp);
		append_list(tmp, load);
	}
	transport->active_count++;
	cond_signal(&transport->list_condit);
	mutex_unlock(&transport->list_mutex);

	/* Wait for the transport to do the unload */
	while (load->completion == REQUEST_NOT_COMPLETE)
		cond_wait(&load->condit, &load->mutex);
	mutex_unlock(&load->mutex);

	err = (req_comp_t)load->completion;
	if (DBG_LVL(SAM_DBG_TMOVE))
		sam_syslog(LOG_DEBUG,
		    "Return from transport load (%#x).", load->completion);

	free(ibm_info);
	mutex_destroy(&load->mutex);
	free(load);
	return (err);
}
Esempio n. 8
0
P9(PUBLIC pascal trap, ListHandle,  LNew, Rect *, rview,	/* IMIV-270 */
	    Rect *, bounds, Point, csize, INTEGER, proc, WindowPtr, wind,
	      BOOLEAN, draw, BOOLEAN, grow, BOOLEAN, scrollh, BOOLEAN, scrollv)
{
    ListHandle retval;
    ListPtr lp;
    INTEGER noffs, min, max;
    INTEGER *ip;
    Rect r;
    int i;
    DataHandle tempdatah;
    Handle temph;
    LISTDECL();

    noffs = (CW(bounds->right) - CW(bounds->left)) *
				     (CW(bounds->bottom) - CW(bounds->top)) +1;
    retval = (ListHandle) NewHandle(sizeof(ListRec) -
	         sizeof(HxX(retval, cellArray)) + (noffs+1) * sizeof(INTEGER));
    if (!retval)
/*-->*/	return 0;	/* couldn't allocate memory */

    temph = RM(GetResource(TICK("LDEF"), proc));
    if (!(HxX(retval, listDefProc) = temph)) {
	DisposHandle((Handle) retval);
/*-->*/	return 0;	/* spooey list definition proc */
    }

    TRAPBEGIN();
    tempdatah = RM((DataHandle) NewHandle(0));
    HxX(retval, cells) = tempdatah;
    HLock((Handle) retval);
    lp = STARH(retval);

    lp->dataBounds  = *bounds;
    lp->rView       = *rview;
    lp->port        = RM(wind);
    lp->indent.h    = 0;
    lp->indent.v    = 0;
    lp->selFlags    = 0;
#if defined (STEF_lActivefix)
    lp->lActive     = TRUE;
#else
    lp->lActive     = FrontWindow() == wind;
#endif
    lp->lReserved   = 0;
    lp->clikTime    = 0;
    lp->clikLoc.h   = CWC(-32768);
    lp->clikLoc.v   = CWC(-32768);
    lp->mouseLoc.h  = -1;
    lp->mouseLoc.v  = -1;
    lp->lClikLoop   = 0;
    lp->lastClick.h = -1;
    lp->lastClick.v = -1;
    lp->refCon      = 0;
    lp->userHandle  = (Handle) 0;
    lp->maxIndex    = -1;	/* What is this anyway? */
    ip = (INTEGER *) lp->cellArray;
    for (i = 0; i <= noffs; i++)
        *ip++ = 0;

    lp->visible.top  = bounds->top;
    lp->visible.left = bounds->left;
    lp->vScroll = 0;
    lp->hScroll = 0;
    C_LCellSize(csize, retval);	/* sets cellSize and visible */

    lp->listFlags = draw ? DODRAW : 0;
    if (scrollv) {
	r = lp->rView;
	r.top = CW(CW(r.top) - 1);
	r.left = r.right;
	r.right = CW(CW(r.right) + (16));
	r.bottom = CW(CW(r.bottom) + 1);
	ROMlib_vminmax(&min, &max, lp);
	lp->vScroll = RM(NewControl((WindowPtr) wind, &r, (StringPtr) "",
	       draw && lp->lActive, min, min, max, scrollBarProc, (LONGINT) 0));
	STARH(MR(lp->vScroll))->contrlRfCon = RM((LONGINT) (long) retval);
	lp->listFlags |= lDoVAutoscroll;
    }

    if (scrollh) {
	r = lp->rView;
	r.left = CW(CW(r.left) - 1);
	r.top = r.bottom;
	r.bottom = CW(CW(r.bottom) + (16));
	r.right = CW(CW(r.right) + 1);
	ROMlib_hminmax(&min, &max, lp);
	lp->hScroll = RM(NewControl((WindowPtr) wind, &r, (StringPtr) "",
	       draw && lp->lActive, min, min, max, scrollBarProc, (LONGINT) 0));
	STARH(MR(lp->hScroll))->contrlRfCon = RM((LONGINT) (long) retval);
	lp->listFlags |= lDoHAutoscroll;
    }

    HUnlock((Handle) retval);
    LISTBEGIN(retval);
    LISTCALL(lInitMsg, FALSE, (Rect *)0, * (Cell *)&lp->clikLoc, 0, 0, retval);
    LISTEND(retval);
    TRAPEND();
#if defined (LIST_DEBUG)
    add_list (retval);
#endif
    return retval;
}