Esempio n. 1
0
//
//	Login
//
//	Returns  0 if okay
//	Returns -1 if USER failed
//	Returns -2 if PASS failed
//
int login( struct ftp_info *info, int (*updatefn)(void *,int,char *), void *updateinfo, char *user, char *passwd )
{
BOOL retval = 0;
int  reply;

// Clear previous error text
*info->fi_serverr = 0;

_ftpa( info, FTPFLAG_ASYNCH, "USER %s", user );
reply = _getreply( info, 0, updatefn, updateinfo ) / 100;

if	(reply != CONTINUE && reply != COMPLETE)
	{
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );
	retval = -1;
	}

if	(reply == CONTINUE)
	{
	_ftpa( info, FTPFLAG_ASYNCH, "PASS %s", passwd );
	reply = _getreply( info, 0, updatefn, updateinfo ) / 100;

	if	(reply != COMPLETE)
		{
		stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );
		retval = -2;
		}
	}

return retval;
}
Esempio n. 2
0
int redoinpb(short hand,GRECT box)
{
int xy[4];
char *point;
short junk2;
char temps[2048];
if(hand==-1)return 0;
xy[0]=box.g_x;xy[1]=box.g_y;xy[2]=box.g_x+box.g_w-1;xy[3]=box.g_y+box.g_h-1;
vs_clip(ws.handle,1,xy);
clearwin(box.g_x,box.g_y,box.g_w,box.g_h,col[CINPBACK]);
writeinpinfo(hand);
point=wn[hand].inp+strlen(wn[hand].inp);
vst_font(ws.handle,(WORD)inpfont);
vst_point(ws.handle,(WORD)inppoint,&junk2,&junk2,&junk2,&junk2);
vst_color(ws.handle,col[CINPTEXT]);
point=point-wn[hand].ihc[wn[hand].cvof];
stccpy(temps,point,wn[hand].ihc[wn[hand].cvof]+1);
vswr_mode(ws.handle,MD_TRANS);
v_gtext(ws.handle,wn[hand].wwa.g_x,wn[hand].wwa.g_y+wn[hand].wwa.g_h-1,temps);
if(wn[hand].cvof>0){
point=point-wn[hand].ihc[wn[hand].cvof-1];
stccpy(temps,point,wn[hand].ihc[wn[hand].cvof-1]+1);
v_gtext(ws.handle,wn[hand].wwa.g_x,wn[hand].wwa.g_y+wn[hand].wwa.g_h-ith-1,temps);
}
docursor(hand);
vs_clip(ws.handle,0,NULL);
return 0;
}
Esempio n. 3
0
// Add PopUp extensions
void add_popup_ext(char *menu,Att_List *type_list,char *command,ULONG flags)
{
	Att_Node *node;

	// Go through menu list
	for (node=(Att_Node *)type_list->list.lh_Head;
		node->node.ln_Succ;
		node=(Att_Node *)node->node.ln_Succ)
	{
		Cfg_Filetype *ftype=0;
		ULONG type=0;
		short a;

		// No name?
		if (!node->node.ln_Name) continue;

		// Special type?
		for (a=0;icon_types[a];a++)
		{
			// Compare string
			if (stricmp(node->node.ln_Name,icon_types[a])==0)
			{
				// All?
				if (a==0) type=POPUP_ALL;
				else type=a;
				break;
			}
		}

		// Search filetypes?
		if (!type)
		{
			// Try to find filetype
			if (!(ftype=filetype_find(node->node.ln_Name,1)))
				ftype=filetype_find(node->node.ln_Name,0);
		}

		// Got something to match on?
		if (type || ftype)
		{
			PopUpExt *ext;

			// Allocate PopUpExtension
			if ((ext=AllocMemH(global_memory_pool,sizeof(PopUpExt))))
			{
				// Fill it out
				ext->pe_Type=type;
				if (ftype) stccpy(ext->pe_FileType,ftype->type.name,sizeof(ext->pe_FileType));
				stccpy(ext->pe_Command,command,40);
				stccpy(ext->pe_Menu,menu,40);
				ext->pe_Flags=flags;

				// Lock list and add new entry
				lock_listlock(&GUI->popupext_list,TRUE);
				AddTail(&GUI->popupext_list.list,(struct Node *)ext);
				unlock_listlock(&GUI->popupext_list);
			}
		}
	}
}
// Show list of status bar options
void _config_env_status_list(ObjectList *objlist,ULONG id,long first,long last)
{
	Att_List *list;
	short a,b;
	char name[80];

	// Build list
	if (!(list=Att_NewList(0))) return;
	for (a=first;a<=((last)?last:32767);a++)
	{
		stccpy(name,GetString(locale,a),sizeof(name));
		if (name[0]=='-' && name[1]==0)
			break;
		for (b=0;name[b] && name[b]!='\t';b++)
			if (name[b]=='*') name[b]='%';
		Att_NewNode(list,name,0,0);
	}

	// Make window busy
	SetWindowBusy(objlist->window);

	// Display selection list
	a=SelectionList(list,objlist->window,0,
		GetString(locale,MSG_ENVIRONMENT_LISTER_SELECT_STATUS),
		-1,
		0,
		0,
		GetString(locale,MSG_OKAY),
		GetString(locale,MSG_CANCEL),0,0);

	// Clear busy
	ClearWindowBusy(objlist->window);

	// Selection?
	if (a!=-1)
	{
		Att_Node *node;

		// Get node
		if ((node=Att_FindNode(list,a)))
		{
			char *ptr,buf[10];

			// Get string pointer
			ptr=strchr(node->node.ln_Name,'\t');
			if (ptr) stccpy(buf,node->node.ln_Name,(ptr-node->node.ln_Name)+1);
			else stccpy(buf,node->node.ln_Name,sizeof(buf));

			// Insert into gadget
			funced_edit_insertstring(objlist,id,buf,DOpusBase,(struct Library *)IntuitionBase);
		}
	}

	// Free list
	Att_RemList(list,0);
}
// Display mode support
void _config_env_screenmode_init(config_env_data *data,BOOL refresh)
{
	struct NameInfo nameinfo;
	int sel;

	// Get current mode
	switch (data->config->screen_mode)
	{
		case MODE_WORKBENCHUSE:
			stccpy(
				data->mode_name,
				GetString(locale,MSG_ENVIRONMENT_SCREENMODE_WB_USE),
				sizeof(data->mode_name));
			break;

		case MODE_WORKBENCHCLONE:
			stccpy(
				data->mode_name,
				GetString(locale,MSG_ENVIRONMENT_SCREENMODE_WB_CLONE),
				sizeof(data->mode_name));
			break;

		case MODE_PUBLICSCREEN:
			lsprintf(data->mode_name,"%s:%s",
				data->config->pubscreen_name,
				GetString(locale,MSG_USE));
			break;

		default:
			// Get mode name (if available)
			if (GetDisplayInfoData(
				0,
				(char *)&nameinfo,
				sizeof(nameinfo),
				DTAG_NAME,
				data->config->screen_mode))
			{
				stccpy(data->mode_name,nameinfo.Name,sizeof(data->mode_name));
			}
			else
			{
				data->mode_name[0]=0;
			}
			break;
	}

	// Set current mode selection
	if (refresh)
	{
		sel=Att_NodeNumber(data->mode_list,data->mode_name);
		SetGadgetValue(data->option_list,GAD_ENVIRONMENT_SCREENMODE_MODE,sel);
	}

	// Initialise mode data
	_config_env_screenmode_init_mode(data,refresh);
}
Esempio n. 6
0
// Open a progress window
ProgressWindow *__asm __saveds L_OpenProgressWindow(
	register __a0 struct TagItem *tags,
	register __a6 struct MyLibrary *lib)
{
	ProgressWindow *prog;
	char *ptr;

	// Allocate control structure
	if (!(prog=AllocVec(sizeof(ProgressWindow),MEMF_CLEAR)))
		return 0;

	// Fill out control parameters
	prog->pw_Screen=(struct Screen *)GetTagData(PW_Screen,0,tags);
	prog->pw_OwnerWindow=(struct Window *)GetTagData(PW_Window,0,tags);
	if (ptr=(char *)GetTagData(PW_Title,0,tags)) stccpy(prog->pw_Title,ptr,39);
	if (ptr=(char *)GetTagData(PW_Info,0,tags)) stccpy(prog->pw_Information,ptr,79);
	if (ptr=(char *)GetTagData(PW_Info2,0,tags)) stccpy(prog->pw_Information2,ptr,79);
	if (ptr=(char *)GetTagData(PW_Info3,0,tags)) stccpy(prog->pw_Information3,ptr,79);
	prog->pw_SigTask=(struct Task *)GetTagData(PW_SigTask,0,tags);
	prog->pw_SigBit=GetTagData(PW_SigBit,0,tags);
	prog->pw_Flags=GetTagData(PW_Flags,0,tags);
	prog->pw_FileCount=GetTagData(PW_FileCount,0,tags);
	prog->pw_FileSize=GetTagData(PW_FileSize,0,tags);
	if (ptr=(char *)GetTagData(PW_FileName,0,tags)) stccpy(prog->pw_FileName,ptr,79);

	// If we have both size and the bar set, we swap them around
	if (prog->pw_Flags&PWF_FILESIZE && prog->pw_Flags&PWF_GRAPH)
		prog->pw_Flags|=PWF_SWAP;

	// Save A4 and library pointer
	prog->pw_A4=getreg(REG_A4);
	prog->pw_Lib=lib;

	// Initialise task name
	strcpy(prog->pw_TaskName,"dopus_progressbar");

	// Launch progress task
	L_IPC_Launch(
		0,&prog->pw_IPC,
		prog->pw_TaskName,
		(ULONG)progress_task,
		STACK_DEFAULT,
		(ULONG)prog,
		(struct Library *)DOSBase,lib);

	// Failed?
	if (!prog->pw_IPC)
	{
		FreeVec(prog);
		return 0;
	}

	// Return pointer
	return prog;
}
// Decompile function string into list of functions
void funced_decompile(FuncEdData *data)
{
	FunctionEntry *entry;
	Cfg_Instruction *ins;

	// Clear list
	Att_RemList(data->function_list,REMLIST_SAVELIST|REMLIST_FREEDATA);

	// Copy to function entry list
	for (ins=(Cfg_Instruction *)data->function->instructions.mlh_Head;
		ins->node.mln_Succ;
		ins=(Cfg_Instruction *)ins->node.mln_Succ)
	{
		// Label?
		if (ins->type==INST_LABEL)
		{
			// Store label
			stccpy(data->label,ins->string,79);
			continue;
		}

		// Allocate function entry
		if ((entry=AllocVec(sizeof(FunctionEntry),MEMF_CLEAR)))
		{
			// Store function data
			entry->type=ins->type;
			if (ins->string) strcpy(entry->buffer,ins->string);

			// Add entry to list
			if (!(entry->node=Att_NewNode(data->function_list,0,(ULONG)entry,0)))
				FreeVec(entry);
		}
	}
}
Esempio n. 8
0
// Send PORT command
int ftp_port( struct ftp_info *info, unsigned long flags, struct sockaddr_in *addr )
{
	int reply;
	int ip1, ip2, ip3, ip4, p1, p2, port;

	if (!addr)
		return 0;

	if	(!(flags & PORT_QUIET))
		*info->fi_serverr = 0;

	if (sscanf(Inet_NtoA(addr->sin_addr.s_addr), "%d.%d.%d.%d", &ip1, &ip2, &ip3, &ip4) != 4)
		return 0;

	port = ntohs(addr->sin_port);
	p1 = port / 256;
	p2 = port % 256;

	reply = _ftpa( info, flags, "PORT %d,%d,%d,%d,%d,%d", ip1, ip2, ip3, ip4, p1, p2 );

	if	(!(flags & PORT_QUIET) && reply / 100 != COMPLETE)
		stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

	return reply;
}
void _config_env_screenmode_set_mode(config_env_data *data,Att_Node *node)
{
	// Get mode ID
	data->config->screen_mode=node->data;

	// If this is a public screen use, get public screen name
	if (data->config->screen_mode==MODE_PUBLICSCREEN)
	{
		int a;

		// Copy to pubscreen name buffer
		stccpy(data->config->pubscreen_name,node->node.ln_Name,sizeof(data->config->pubscreen_name));

		// Remove :Use
		for (a=strlen(data->config->pubscreen_name);a>=0;a--)
		{
			if (data->config->pubscreen_name[a]==':')
			{
				data->config->pubscreen_name[a]=0;
				break;
			}
		}
	}

	// Initialise settings
	_config_env_screenmode_init(data,0);
}
Esempio n. 10
0
/* send a command line to the server on connection cn */
int	news_send_command(int cn, char *command)
{
	int rc;
	char temp[80];

	if (log_cmd=='Y') {
		stccpy(temp,command,75);
		if (log_mask_pswds=='Y') {
			if ((memcmp(temp,"pass",4)==0)||(memcmp(temp,"PASS",4)==0)) {
				for (rc=5;rc<80;rc++) {
					if (temp[rc]=='\0') break;
					temp[rc]='*';
				}
			}
			if (memcmp(temp,"authinfo pass",13)==0) {
				for (rc=14;rc<80;rc++) {
					if (temp[rc]=='\0') break;
					temp[rc]='*';
				}
			}
		}
		fprintf( log, "-> %s\n", temp );  fflush(log);
	}
	rc = news_send( cn, command );
	return(rc);
}
Esempio n. 11
0
int updinpak()
{
char *point;
char temps[2048];
startupdate();
point=wn[cwin].inp+findcurpos()-1;
stccpy(temps,point,wn[cwin].ihc[wn[cwin].cvof]-wn[cwin].cx);
vswr_mode(ws.handle,MD_TRANS);
v_gtext(ws.handle,wn[cwin].wwa.g_x+fdtc(),wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-1,temps);
finishupdate();
return 0;
}
Esempio n. 12
0
// Send an ARexx command
long __asm __saveds HookRexxCommand(
	register __a0 char *command,
	register __a1 char *result,
	register __d0 long length,
	register __a2 struct MsgPort *replyport,
	register __d1 ULONG flags)
{
	struct MsgPort *rexx,*reply;
	struct RexxMsg *msg;
	long rc=-1;

	// Clear result
	if (result) *result=0;

	// Get rexx port
	if (!GUI->rexx_proc || !(rexx=(struct MsgPort *)IPCDATA(GUI->rexx_proc)))
		return -1;

	// Create reply port if needed
	if ((reply=replyport) || (reply=CreateMsgPort()))
	{
		// Create message
		if (msg=BuildRexxMsgExTags(
					reply,
					".dopus5",
					rexx->mp_Node.ln_Name,
					RexxTag_Arg0,command,
					TAG_END))
		{
			// Initialise message
			msg->rm_Action|=1|RXCOMM;
			if (result) msg->rm_Action|=RXFF_RESULT;

			// Send the message and wait for reply
			PutMsg(rexx,(struct Message *)msg);
			WaitPort(reply);
			GetMsg(reply);

			// String reply?
			if (msg->rm_Result2 && result)
				stccpy(result,(char *)msg->rm_Result2,length);
			rc=msg->rm_Result1;

			// Free message
			FreeRexxMsgEx(msg);
		}

		// Free message port
		if (reply!=replyport) DeleteMsgPort(reply);
	}

	return rc;
}
Esempio n. 13
0
// Rename file or dir
int ftp_rename( struct ftp_info *info, char *oldname, char *newname )
{
int  reply;

*info->fi_serverr = 0;

// Can TIMEOUT
reply = ftpa( info, "RNFR %s", oldname );

if	(reply / 100 != CONTINUE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );
else
	{
	// Can TIMEOUT
	reply = ftpa( info, "RNTO %s", newname );

	if	(reply / 100 != COMPLETE)
		stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );
	}

return reply;
}
Esempio n. 14
0
// Remove directory
int ftp_rmd( struct ftp_info *info, char *name )
{
int reply;

*info->fi_serverr = 0;

reply = ftpa( info, "RMD %s", name );

if	(reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 15
0
int fdtc()
{
short blah,ret;
short xy[8];
char temps[1024];
vst_font(ws.handle,(WORD)inpfont);
vst_point(ws.handle,(WORD)inppoint,&ret,&ret,&ret,&ret);
blah=findcurpos()-wn[cwin].cx;
strcpy(temps,"\0");
stccpy(temps,wn[cwin].inp+blah,wn[cwin].cx+1);
vqt_extent(ws.handle,temps,xy);
blah=xy[2]-xy[0];
return blah;
}
Esempio n. 16
0
// Change dir
int ftp_cwd( struct ftp_info *info, int (*updatefn)(void *,int,char *), void *updateinfo, char *path )
{
int reply;

*info->fi_serverr = 0;

_ftpa( info, FTPFLAG_ASYNCH, "CWD %s", path );
reply = _getreply( info, 0, updatefn, updateinfo );

if	(reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 17
0
// Change file modes
int ftp_chmod( struct ftp_info *info, unsigned int mode, char *name )
{
int reply;

*info->fi_serverr = 0;

reply = ftpa( info, "SITE CHMOD %o %s", mode, name );

if	(reply == 500 || reply == 502)
	info->fi_flags |= FTP_NO_CHMOD;
else if	(reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 18
0
// Return file size
int ftp_size( struct ftp_info *info, char *name )
{
int reply;

*info->fi_serverr = 0;

reply = ftpa( info, "SIZE %s", name );

if	(reply >= 500 && reply <= 502)
	info->fi_flags |= FTP_NO_SIZE;
else if	(reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 19
0
// Restart next transfer at this offset
int ftp_rest( struct ftp_info *info, unsigned int offset )
{
int reply;

*info->fi_serverr = 0;

reply = ftpa( info, "REST %lu", offset );

// Microsoft servers always say, "504 Reply marker must be 0."
if	((reply >= 500 && reply <= 502) || reply == 504)
	info->fi_flags |= FTP_NO_REST;
else if	(reply / 100 != CONTINUE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 20
0
//
//	Request data port details to connect to.
//
//	Note: This is also used to break data connections
//	in site-site transfers.
//
int ftp_pasv( struct ftp_info *info )
{
int reply;

*info->fi_serverr = 0;

reply = ftp( info, "PASV\r\n" );

if	(reply >= 500 && reply <= 502)
	{
	D(bug( "** setting NO_PASV\n" ));
	info->fi_flags |= FTP_NO_PASV;
	}
else if	(reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 21
0
int ftp_port( struct ftp_info *info, unsigned long flags, unsigned char *host, unsigned char *port )
{
int reply;

if (!port || !host)
	return 0;

if	(!(flags & PORT_QUIET))
	*info->fi_serverr = 0;

reply = _ftpa( info, flags, "PORT %d,%d,%d,%d,%d,%d",
	*host++, *host++, *host++, *host,
	*port++, *port );

if	(!(flags & PORT_QUIET) && reply / 100 != COMPLETE)
	stccpy( info->fi_serverr, info->fi_iobuf, IOBUFSIZE + 1 );

return reply;
}
Esempio n. 22
0
HOOKPROTONH(AppMessageCode, VOID, Object* htmlview, struct MUIP_AppMessage *args)
{
    if(args->appmsg->am_NumArgs)
    {
      char dir[256+8];

      #if defined(__MORPHOS__)
      stccpy(dir, "file://", sizeof(dir));
      #else
      strlcpy(dir, "file://", sizeof(dir));
      #endif

        if(NameFromLock(args->appmsg->am_ArgList[0].wa_Lock, dir+7, 256))
        {
            AddPart(dir+7, args->appmsg->am_ArgList[0].wa_Name, 256);
            DoMethod(htmlview, MUIM_HTMLview_GotoURL, (ULONG)dir, NULL);
        }
    }
}
Esempio n. 23
0
// Check if a volume/path is available
BOOL VolumePresent(DirBuffer *buffer)
{
	D_S(struct InfoData, info)
	struct DosList *dos;
	char volume[32];

	// Valid path?
	if (!buffer->buf_Path[0]) return 0;

	// Get current disk info
	if (!(GetDiskInfo(buffer->buf_Path,info)) ||
		!(dos=(struct DosList *)BADDR(info->id_VolumeNode))) return 0;

	// Valid dos list?
	if (!dos || !dos->dol_Name) return 0;

	// Is volume mounted?
	if (info->id_DiskType==ID_NO_DISK_PRESENT || info->id_DiskType==ID_UNREADABLE_DISK)
		return 0;

	// Get current disk name
	if (dos->dol_Name) 	BtoCStr(dos->dol_Name,volume,32);
	else
	{
		char *ptr;
		stccpy(volume,buffer->buf_ExpandedPath,32);
		if ((ptr=strchr(volume,':'))) *ptr=0;
	}

	// Compare disk name
	if (strcmp(volume,buffer->buf_VolumeLabel)!=0) return 0;

	// Compare date stamp
	if (CompareDates(&dos->dol_misc.dol_volume.dol_VolumeDate,&buffer->buf_VolumeDate)!=0)
		return 0;

	// Volume is available
	return 1;
}
Esempio n. 24
0
// Allocate a new object
BackdropObject *backdrop_new_object(
	BackdropInfo *info,
	char *name,
	char *extra,
	short type)
{
	BackdropObject *object;
	short len=0;

	// Extra space?
	if (extra)
	{
		if (!*extra) extra=0;
		else len=strlen(extra)+1;
	}

	// Allocate object
	if (!(object=AllocMemH(info->memory,sizeof(BackdropObject)+len)))
		return 0;

	// Set name
	object->node.ln_Name=object->name;
	if (name) stccpy(object->name,name,31);

	// Set type
	object->type=type;

	// Any extra?
	if (extra)
	{
		// Copy extra
		object->device_name=(char *)(object+1);
		strcpy(object->device_name,extra);
	}

	return object;
}
Esempio n. 25
0
word do_menu(char *title, word width, word height, char *list[],
             word *result, bool(*reload)(char*, word*), char *preload )
{
    word i;
    word ev,key,mx,my;
    word currenty,currentx;
    word visible;
    word num;
    struct ws *menuw;
    char menu_so_far[MAXMENUWIDTH+1];		/* can, in theory, recurse */
    word numlist;

    if (preload==NULL)
        menu_so_far[0]=0;
    else
    {
        stccpy(menu_so_far,preload,MAXMENUWIDTH);
        strupr(menu_so_far);
    }
    currentx=strlen(menu_so_far);
    (reload)(menu_so_far,&numlist);		/* initial value */
    if (numlist==0)
    {
        *result=-1;
        return 0;
    }
    if ( (num=spare_window())==-1)
        return ERRM_NOSPARE;

    if (width>MAXMENUWIDTH)
        width=MAXMENUWIDTH;

    menuw=wlist[num];

    /* centered on screen */
    menuw->x=(maxw-width-2)/2;
    menuw->y=(maxh-height-2)/2;
    menuw->w=width+2;
    menuw->h=height+2;

    menuw->open=TRUE;
    menuw->number=num;
    menuw->type=WTYPE_DIALOG;
    menuw->magic=NULL;

    add_wlist(menuw);


    /* mark us on the screen, carefully as we are not in the wlist */
    window_cls(menuw);
    window_title2(menuw,title,FALSE);
    recalcw(menuw);
    update_rectangle(menuw->x,menuw->y,menuw->w,menuw->h);

    for (;;)
    {
p:
        visible=min(height,numlist);
        currenty=0;
        /* print the entries */
        for (i=0; i<visible; i++)
        {
            menuw->xpos=DLOGX;
            menuw->ypos=i+1;
            wprint_str(list[i]);
        }
k:
        if (visible)
            light_line(currenty,(word)(currentx+1),(word)(width-currentx-1));
        else
            light_line(currenty,1,(word)(width-1));

        ev=get_event(&key,&mx,&my);

        if (visible)
            light_line(currenty,(word)(currentx+1),(word)(width-currentx-1));
        else
            light_line(currenty,1,(word)(width-1));

        if (ev&EV_CLICK)
        {
            word w;
            ubyte edge;
            if (visible)
            {
                w=which_window(&mx,&my,&edge);
                if ( (w==num) && (edge==0) && (my<=visible) )
                {
                    if (key)
                    {   /* a double-click */
                        key=KEY_RETURN;
                        break;
                    }
                    currenty=--my;
                    goto k;
                }
            }
        }
        if (ev&EV_KEY)
        {
            if ( (key==KEY_UP) && (currenty) && visible )
            {
                currenty--;
                goto k;
            }
            if ( (key==KEY_DOWN) && visible && (currenty<(visible-1)) )
            {
                currenty++;
                goto k;
            }
            if ( (key==KEY_RETURN) || (key==KEY_ENTER) || (key==KEY_ESC) )
                break;
            if (reload)
            {
                if (key==KEY_BACKSPACE)
                {
                    if (currentx)
                        menu_so_far[--currentx]=0;
                }
                else if (key==KEY_CLEAR)
                {
                    menu_so_far[currentx=0]=0;
                }
                else if (key&0xFF)
                {
                    if (currentx<MAXMENUWIDTH)
                        menu_so_far[currentx++]=upper((char)key);
                    menu_so_far[currentx]=0;
                }
                else
                    goto k;
                if ( (reload)(menu_so_far,&numlist) )
                {
                    window_cls(menuw);
                    update_contents(menuw);
                    goto p;
                }
                else
                    goto k;
            }
        }
        goto k;
    }
    /* like close_dialog */
    remove_wlist(menuw);
    menuw->open=FALSE;

    /* restore correct view of world */
    recalc_frontback();
    /* and redraw this new place */
    update_rectangle(menuw->x, menuw->y, (word)(menuw->x+menuw->w),
                     (word)(menuw->y+menuw->h) );

    *result=( (key==KEY_ESC) || (visible==0) )
            ? -2 : currenty;
    return 0;
}
Esempio n. 26
0
ULONG
GetAudioAttrsA( ULONG                    id,
                struct AHIPrivAudioCtrl* actrl,
                struct TagItem*          tags,
                struct AHIBase*          AHIBase )
{
  struct AHI_AudioDatabase *audiodb;
  struct TagItem *dbtags,*tag1,*tag2,*tstate=tags;
  ULONG *ptr;
  ULONG stringlen;
  struct Library *AHIsubBase=NULL;
  struct AHIAudioCtrlDrv *audioctrl=NULL;
  BOOL rc=TRUE; // TRUE == _everything_ went well
  struct TagItem idtag[2] = { {AHIA_AudioID, 0} , {TAG_DONE, 0} };

  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH)
  {
    Debug_GetAudioAttrsA(id, actrl, tags);
  }

  if((audiodb=LockDatabase()))
  {
    if(id == AHI_INVALID_ID)
    {
      if(!(audioctrl= (struct AHIAudioCtrlDrv*) actrl))
        rc=FALSE;
      else
        idtag[0].ti_Data=((struct AHIPrivAudioCtrl *)actrl)->ahiac_AudioID;
    }
    else
    {
      idtag[0].ti_Data = (id == AHI_DEFAULT_ID ? AHIBase->ahib_AudioMode : id);
      audioctrl=(struct AHIAudioCtrlDrv *)CreateAudioCtrl(idtag);
    }

    if(audioctrl && rc )
    {
      if((dbtags=GetDBTagList(audiodb, idtag[0].ti_Data)))
      {
        stringlen=GetTagData(AHIDB_BufferLen,0,tags);
        if((AHIsubBase=OpenLibrary(((struct AHIPrivAudioCtrl *)audioctrl)->ahiac_DriverName,DriverVersion)))
        {
          while((tag1=NextTagItem(&tstate)))
          {
            ptr=(ULONG *)tag1->ti_Data;
            switch(tag1->ti_Tag)
            {
            case AHIDB_Driver:
            case AHIDB_Name:
              if((tag2=FindTagItem(tag1->ti_Tag,dbtags)))
                stccpy((char *)tag1->ti_Data,(char *)tag2->ti_Data,stringlen);
              break;
// Skip these!
            case AHIDB_FrequencyArg:
            case AHIDB_IndexArg:
            case AHIDB_InputArg:
            case AHIDB_OutputArg:
              break;
// Strings
            case AHIDB_Author:
            case AHIDB_Copyright:
            case AHIDB_Version:
            case AHIDB_Annotation:
              stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag,0,(ULONG)"",dbtags,audioctrl),stringlen);
              break;
// Input & Output strings
            case AHIDB_Input:
              stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag,
                  GetTagData(AHIDB_InputArg,0,tags),
                  (ULONG) GetahiString(msgDefault),dbtags,audioctrl),stringlen);
              break;
            case AHIDB_Output:
              stccpy((char *)tag1->ti_Data,(char *)AHIsub_GetAttr(tag1->ti_Tag,
                  GetTagData(AHIDB_OutputArg,0,tags),
                  (ULONG) GetahiString(msgDefault),dbtags,audioctrl),stringlen);
              break;
// Other
            case AHIDB_Bits:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl);
              break;
            case AHIDB_MaxChannels:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,128,dbtags,audioctrl);
              break;
            case AHIDB_MinMixFreq:
              *ptr=AHIsub_GetAttr(AHIDB_Frequency,0,0,dbtags,audioctrl);
              break;
            case AHIDB_MaxMixFreq:
              *ptr=AHIsub_GetAttr(AHIDB_Frequency,(AHIsub_GetAttr(AHIDB_Frequencies,1,0,dbtags,audioctrl)-1),0,dbtags,audioctrl);
              break;
            case AHIDB_Frequencies:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,1,dbtags,audioctrl);
              break;
            case AHIDB_Frequency:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,GetTagData(AHIDB_FrequencyArg,0,tags),0,dbtags,audioctrl);
              break;
            case AHIDB_Index:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,GetTagData(AHIDB_IndexArg,0,tags),0,dbtags,audioctrl);
              break;
            case AHIDB_MaxPlaySamples:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,audioctrl->ahiac_MaxBuffSamples,dbtags,audioctrl);
              break;
            case AHIDB_MaxRecordSamples:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl);
              break;
            case AHIDB_MinMonitorVolume:
            case AHIDB_MaxMonitorVolume:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0x00000,dbtags,audioctrl);
              break;
            case AHIDB_MinInputGain:
            case AHIDB_MaxInputGain:
            case AHIDB_MinOutputVolume:
            case AHIDB_MaxOutputVolume:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0x10000,dbtags,audioctrl);
              break;
            case AHIDB_Inputs:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,0,dbtags,audioctrl);
              break;
            case AHIDB_Outputs:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,1,dbtags,audioctrl);
              break;
// Booleans that defaults to FALSE
            case AHIDB_Realtime:
            case AHIDB_Record:
            case AHIDB_FullDuplex:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,FALSE,dbtags,audioctrl);
              break;
// Booleans that defaults to TRUE
            case AHIDB_PingPong:
              *ptr=AHIsub_GetAttr(tag1->ti_Tag,0,TRUE,dbtags,audioctrl);
              break;
// Tags from the database.
            default:
              if((tag2=FindTagItem(tag1->ti_Tag,dbtags)))
                *ptr=tag2->ti_Data;
              break;
            }
          }
        }
        else // no AHIsubBase
          rc=FALSE;
      }
      else // no database taglist
        rc=FALSE;
    }
    else // no valid audioctrl
       rc=FALSE;
    if(id != AHI_INVALID_ID)
      AHIFreeVec(audioctrl);
    if(AHIsubBase)
      CloseLibrary(AHIsubBase);
    UnlockDatabase(audiodb);
  }
  else // unable to lock database
    rc=FALSE;

  if(AHIBase->ahib_DebugLevel >= AHI_DEBUG_HIGH)
  {
    KPrintF("=>%s\n", rc ? "TRUE" : "FALSE" );
  }

  return (ULONG) rc;
}
Esempio n. 27
0
// Display a buffer in a lister
// Called from LISTER PROCESS
void lister_show_buffer(Lister *lister,DirBuffer *buffer,int show,BOOL active)
{
	// Different to current buffer?
	if (lister->cur_buffer!=buffer)
	{
		// End a direct edit
		lister_end_edit(lister,0);

		// Clear lock pointer in current buffer
		buffer_clear_lock(lister->cur_buffer,0);

		// Free icons
		backdrop_free_list(lister->backdrop_info);

		// Store new buffer pointer
		lister->cur_buffer=buffer;
		buffer->buf_CurrentLister=lister;

		// Remove buffer and add to head of list
		Remove(&buffer->node);
		AddHead(&GUI->buffer_list.list,&buffer->node);

		// See if buffer needs to be resorted
		lister_resort(lister,0);

		// Clear save status flag
		lister->flags&=~LISTERF_SAVE_STATUS;

		// Does new buffer have a custom handler?
		if (lister->cur_buffer->buf_CustomHandler[0] && active)
		{
			// Send active message
			buffer_active(lister->cur_buffer,0);
		}

		// Add to history list
		lister_add_history(lister);
	}

	// Initialise path field
	if (show && lister_valid_window(lister))
	{
		// Is volume present?
		if (!lister->cur_buffer->buf_CustomHandler[0] &&
			VolumePresent(buffer))
		{
			BPTR lock;
			struct FileInfoBlock __aligned fib;

			// Lock path
			if (lock=Lock(buffer->buf_Path,ACCESS_READ))
			{
				// Store full path
				NameFromLock(lock,buffer->buf_ExpandedPath,512);
				AddPart(buffer->buf_ExpandedPath,"",512);

				// Examine object
				Examine(lock,&fib);
				UnLock(lock);

				// Save object name
				if (fib.fib_FileName[0])
					strcpy(buffer->buf_ObjectName,fib.fib_FileName);
				else
				{
					if (buffer->flags&DWF_ROOT)
					{
						char *ptr;

						stccpy(buffer->buf_ObjectName,buffer->buf_ExpandedPath,GUI->def_filename_length-1);
						if (ptr=strchr(buffer->buf_ObjectName,':')) *ptr=0;
					}
					else stccpy(buffer->buf_ObjectName,FilePart(buffer->buf_ExpandedPath),GUI->def_filename_length-1);
				}
			}

			// Failed to lock
			else strcpy(buffer->buf_ExpandedPath,buffer->buf_Path);

			// Update disk name and size
			lister_update_name(lister);
		}

		// No, refresh disk name from buffer
		else lister_show_name(lister);

		// Not showing icons?
		if (!(lister->flags&LISTERF_VIEW_ICONS) || lister->flags&LISTERF_ICON_ACTION)
		{
			// Update path field
			lister_update_pathfield(lister);

			// Refresh window
			lister_refresh_display(lister,REFRESHF_SLIDERS|REFRESHF_STATUS|REFRESHF_CLEAR_ICONS);

			// Show selection information
			select_show_info(lister,1);
		}
	}
}
Esempio n. 28
0
void FiletypeEditor(void)
{
	filetype_ed_data *data=0;
	IPCData *ipc;
	short success=0,pending_quit=0;
	BOOL change_flag=0;

	// Do startup
	if (!(ipc=Local_IPC_ProcStartup((ULONG *)&data, (APTR)&_filetypeed_init)))
		return;

	// Create App stuff
	if ((data->app_port=CreateMsgPort()))
	{
		data->app_window=AddAppWindowA(0,0,data->window,data->app_port,0);
	}

	// Get icon image
	if (data->type->icon_path)
	{
#ifdef USE_DRAWICONSTATE
		{
			char *path_copy;
			data->icon_image=NULL;
			if ((path_copy=AllocMemH(0,strlen(data->type->icon_path)+1)))
			{
				// icon_path is guaranteed to have a .info at the end
				stccpy(path_copy,data->type->icon_path,strlen(data->type->icon_path)-4);
				data->icon_image=GetCachedDiskObject(path_copy,0);
				FreeMemH(path_copy);
			}
		}
#else
		data->icon_image=OpenImage(data->type->icon_path,0);
#endif
		// Show icon image
		filetypeed_show_icon(data);
	}

	// Launch class editor immediately?
	if (data->edit_flag) filetypeed_edit_definition(data);

	// Message loop
	FOREVER
	{
		IPCMessage *msg;
		struct IntuiMessage *imsg;
		short break_flag=0;

		// Check drag
		if (config_drag_check(&data->drag))
		{
			// End drag
			filetypeed_end_drag(data,0);
		}

		// Task message?
		while ((msg=(IPCMessage *)GetMsg(ipc->command_port)))
		{
			switch (msg->command)
			{
				// Close message?
				case IPC_QUIT:
					if (!pending_quit)
					{
						success=msg->flags;
						break_flag=1;
					}
					break;


				// Activate
				case IPC_ACTIVATE:
					if (data->window)
					{
						WindowToFront(data->window);
						ActivateWindow(data->window);
					}
					break;


				// Editor saying goodbye
				case IPC_GOODBYE:
					{
						ULONG which;

						// What's just gone?
						which=IPC_GetGoodbye(msg);

						// Class editor?
						if (which==(ULONG)-1) data->class_editor=0;

						// Icon menu editor?
						else
						if (which>15)
						{
							Att_Node *node;

							// Go through icon list
							for (node=(Att_Node *)data->icon_list->list.lh_Head;
								node->node.ln_Succ;
								node=(Att_Node *)node->node.ln_Succ)
							{
								// Match function
								if (((func_node *)node->data)->func==(Cfg_Function *)which)
								{
									// Clear editor pointer
									((func_node *)node->data)->editor=0;

									// Check for invalid function
									if (filetypeed_check_iconmenu(data,node,FALSE))
										change_flag=1;
									break;
								}
							}
						}

						// Normal filetype editor
						else data->editor[which]=0;
					}
					break;


				// Editor returning a function
				case FUNCTIONEDIT_RETURN:
					{
						short ret;

						if ((ret=filetypeed_receive_edit(
							data,
							(FunctionReturn *)msg->data)))
						{
							change_flag=1;
							filetypeed_update_actions(data);
							if (ret==2) filetypeed_update_iconmenu(data);
						}
					}
					break;


				// Class editor returning
				case CLASSEDIT_RETURN:
					filetypeed_receive_class(data,(Cfg_Filetype *)msg->data);
					change_flag=1;
					break;


				// Get a copy of a button
				case BUTTONEDIT_CLIP_BUTTON:

					// Handle this button
					if (filetypeed_get_button(data,(Cfg_Button *)msg->data,(Point *)msg->data_free))
						change_flag=1;
					break;
			}

			// Reply the message
			IPC_Reply(msg);
		}

		// Intuimessage
		if (data->window)
		{
			while ((imsg=GetWindowMsg(data->window->UserPort)))
			{
				struct IntuiMessage msg_copy;
				struct Gadget *gadget;
				struct TagItem *tags;

				// Copy message
				msg_copy=*imsg;

				// Don't reply to IDCMPUPDATE messages just yet
				if (imsg->Class!=IDCMP_IDCMPUPDATE)
				{
					ReplyWindowMsg(imsg);
					imsg=0;
				}

				// Get gadget and tag pointers
				gadget=(struct Gadget *)msg_copy.IAddress;
				tags=(struct TagItem *)gadget;

				// Look at message
				switch (msg_copy.Class)
				{
					// Close window
					case IDCMP_CLOSEWINDOW:
						if (!pending_quit) break_flag=1;
						break;


					// Gadget
					case IDCMP_GADGETUP:
						switch (gadget->GadgetID)
						{
							// Use
							case GAD_FILETYPEED_USE:
								success=1;

							// Cancel
							case GAD_FILETYPEED_CANCEL:
								if (!pending_quit) break_flag=1;
								break;


							// Select a function
							case GAD_FILETYPEED_ACTION_LIST:
								{
									Att_Node *node;

									// Get selected node
									if (!(node=Att_FindNode(data->action_list,msg_copy.Code)))
										break;

									// Enable edit action button
									DisableObject(data->objlist,GAD_FILETYPES_EDIT_ACTION,FALSE);

									// Double-click?
									if (!(DoubleClick(data->last_sec,data->last_mic,msg_copy.Seconds,msg_copy.Micros)) ||
										node!=data->last_sel)
									{
										data->last_sec=msg_copy.Seconds;
										data->last_mic=msg_copy.Micros;
										data->last_sel=node;
										data->last_icon=0;
										break;
									}
								}

								// Fall through

							case GAD_FILETYPES_EDIT_ACTION:

								// No current selection?
								if (!data->last_sel) break;

								// Is editor already up for this action?	
								if (data->editor[data->last_sel->data])
									IPC_Command(data->editor[data->last_sel->data],IPC_ACTIVATE,0,0,0,0);

								// Need to launch editor
								else filetypeed_edit_action(data,data->last_sel->data,data->last_sel->node.ln_Name);
								break;


							// Delete action
							case GAD_FILETYPES_DEL_ACTION:

								// No current selection?
								if (!data->last_sel) break;

								// Is editor up for this action?	
								if (data->editor[data->last_sel->data])
									IPC_Command(data->editor[data->last_sel->data],IPC_QUIT,0,0,0,0);

								// Delete it
								if (filetypeed_del_action(data,data->last_sel->data))
									change_flag=1;
								break;


							// Edit filetype definition
							case GAD_FILETYPEED_EDIT_CLASS:

								// Is class editor already up for this action?	
								if (data->class_editor)
									IPC_Command(data->class_editor,IPC_ACTIVATE,0,0,0,0);

								// Need to launch editor
								else filetypeed_edit_definition(data);
								break;


							// Select icon
							case GAD_FILETYPEED_SELECT_ICON:
								if (filetypeed_pick_icon(data))
									change_flag=1;
								break;


							// Add to icon menu
							case GAD_FILETYPES_ADD_ICON_MENU:
								filetypeed_add_iconmenu(data);
								break;


							// Select an icon menu
							case GAD_FILETYPES_ICON_MENU:
								{
									Att_Node *last=data->last_icon;

									// Handle selection
									if (!(filetypeed_sel_icon(data,msg_copy.Code))) break;

									// Double-click?
									if (data->last_icon!=last ||
										!(DoubleClick(
											data->last_sec,
											data->last_mic,
											msg_copy.Seconds,
											msg_copy.Micros)))
									{
										data->last_sec=msg_copy.Seconds;
										data->last_mic=msg_copy.Micros;
										data->last_sel=0;
										break;
									}
								}

								// Fall through

							case GAD_FILETYPES_EDIT_ICON_MENU:

								// No current selection?
								if (!data->last_icon) break;

								// Edit it
								filetypeed_edit_iconmenu(data,data->last_icon);
								break;


							// Delete from icon menu
							case GAD_FILETYPES_DEL_ICON_MENU:

								// No current selection?
								if (!data->last_icon) break;

								// Delete function
								if (filetypeed_check_iconmenu(data,data->last_icon,TRUE))
									change_flag=1;
								break;
						}
						break;


					// BOOPSI message
					case IDCMP_IDCMPUPDATE:
						{
							short item;

							// Icon list?
							if (GetTagData(GA_ID,0,tags)!=GAD_FILETYPES_ICON_MENU) break;

							// Get item
							if ((item=GetTagData(DLV_DragNotify,-1,tags))!=-1)
							{
								// Handle selection
								filetypeed_sel_icon(data,item);

								// Start the drag
								config_drag_start(&data->drag,data->icon_list,item,tags,TRUE);
							}
						}
						break;


					// Ticks
					case IDCMP_INTUITICKS:
						++data->drag.tick_count;
						break;


					// Mouse move
					case IDCMP_MOUSEMOVE:

						// Handle drag move
						config_drag_move(&data->drag);
						break;


					// Mouse buttons
					case IDCMP_MOUSEBUTTONS:

						// Valid drag info?
						if (data->drag.drag)
						{
							short ok=-1;

							// Dropped ok?
							if (msg_copy.Code==SELECTUP)
							{
								// Remember last position
								data->drag.drag_x=data->window->WScreen->MouseX;
								data->drag.drag_y=data->window->WScreen->MouseY;
								ok=1;
							}

							// Aborted
							else
							if (msg_copy.Code==MENUDOWN) ok=0;

							// End drag?
							if (ok!=-1 && filetypeed_end_drag(data,ok)) change_flag=1;
						}
						break;


					// Key press
					case IDCMP_RAWKEY:

						// Help?
						if (msg_copy.Code==0x5f &&
							!(msg_copy.Qualifier&VALID_QUALIFIERS))
						{
							// Set busy pointer
							SetWindowBusy(data->window);

							// Send help command
							IPC_Command(data->func_startup.main_owner,IPC_HELP,(1<<31),"File Type Editor",0,REPLY_NO_PORT);

							// Clear busy pointer
							ClearWindowBusy(data->window);
						}
						break;
				}

				// Reply to outstanding messages
				if (imsg) ReplyWindowMsg(imsg);
			}

			// Check break flag
			if (break_flag || pending_quit)
			{
				// See if all the editors are gone
				if (IsListEmpty(&data->proc_list.list))
					break;

				// Send quit?
				if (break_flag)
				{
					IPC_ListQuit(&data->proc_list,0,success,FALSE);
					SetWindowBusy(data->window);
				}
				pending_quit=1;
			}
		}

		// AppMessage
		if (data->app_window)
		{
			struct AppMessage *msg;

			while ((msg=(struct AppMessage *)GetMsg(data->app_port)))
			{
				// Got an argument?
				if (msg->am_NumArgs>0)
				{
					char name[256];
					short len;
					APTR image;

					// Get full name
					NameFromLock(msg->am_ArgList[0].wa_Lock,name,256);
					if (msg->am_ArgList[0].wa_Name &&
						*msg->am_ArgList[0].wa_Name)
						AddPart(name,msg->am_ArgList[0].wa_Name,256);

					// Add .info
					if ((len=strlen(name))<6 ||
						stricmp(name+len-5,".info")!=0) strcat(name,".info");

					// Try to get image
#ifdef USE_DRAWICONSTATE
					{
						char *path_copy;
						image=NULL;
						if ((path_copy=AllocMemH(0,strlen(name)+1)))
						{
							// icon_path is guaranteed to have a .info at the end
							stccpy(path_copy,name,strlen(name)-4);
							image=GetCachedDiskObject(path_copy,0);
							FreeMemH(path_copy);
						}
					}
#else
					image=OpenImage(name,0);
#endif

					if (image)
					{
						// Store path
						FreeMemH(data->type->icon_path);
						if ((data->type->icon_path=AllocMemH(0,strlen(name)+1)))
							strcpy(data->type->icon_path,name);

						// Free existing image
#ifdef USE_DRAWICONSTATE
						FreeCachedDiskObject(data->icon_image);
#else
						CloseImage(data->icon_image);
#endif
						data->icon_image=image;

						// Show new image
						filetypeed_show_icon(data);
						change_flag=1;
					}
				}

				// Reply message
				ReplyMsg((struct Message *)msg);
			}
		}

		Wait(1<<ipc->command_port->mp_SigBit|
			1<<data->drag.timer->port->mp_SigBit|
			((data->window)?(1<<data->window->UserPort->mp_SigBit):0)|
			((data->app_window)?(1<<data->app_port->mp_SigBit):0));
	}

	// End any drag in progress
	filetypeed_end_drag(data,0);

	// Need to send button back?
	if (success==1 && change_flag)
	{
		if (IPC_Command(
			data->owner_ipc,
			FILETYPEEDIT_RETURN,
			(ULONG)data->type,
			data->node,
			0,
			REPLY_NO_PORT))
		{
			data->node=0;
		}
	}

	// Free edit filetype
	FreeFiletype(data->type);

	// Remove AppWindow
	RemoveAppWindow(data->app_window);

	// Close window
	CloseConfigWindow(data->window);

	// Close app port
	if (data->app_port)
	{
		struct Message *msg;
		while ((msg=GetMsg(data->app_port)))
			ReplyMsg(msg);
		DeleteMsgPort(data->app_port);
	}

	// Say goodbye
	IPC_Goodbye(ipc,data->owner_ipc,(success==-1)?0:(ULONG)data->node);

	// Free icon image
#ifdef USE_DRAWICONSTATE
	FreeCachedDiskObject(data->icon_image);
#else
	CloseImage(data->icon_image);
#endif

	// Close timer
	FreeTimer(data->drag.timer);

	// Free data
	IPC_Free(ipc);
	Att_RemList(data->action_list,0);
	Att_RemList(data->icon_list,REMLIST_FREEDATA);
	FreeVec(data);
}
Esempio n. 29
0
int wtib(char *point,char aflag)
{
short junk2,blunk,blunk2,rfoff=0,cellw;
short soff=0,lcount=0,wl;
char *dp;
char temps[2048];
if(cwin==-1)return 0;
wl=wn[cwin].cvof;
if((strlen(wn[cwin].inp)+strlen(point))>511){*(point+(511-strlen(wn[cwin].inp)))=0;}
vst_font(ws.handle,(WORD)inpfont);
vst_point(ws.handle,(WORD)inppoint,&junk2,&junk2,&junk2,&junk2);
if(amatend()){
blunk=findcurpos();
strcat(wn[cwin].inp,point);
}else{
aflag=1;
blunk=findcurpos();
strcpy(temps,"\0");
if(blunk!=0){
stccpy(temps,wn[cwin].inp,blunk+1);
}
strcat(temps,point);
strcat(temps,wn[cwin].inp+blunk);
strcpy(wn[cwin].inp,temps);
}
junk2=wn[cwin].cvof-1;
while(junk2>-1){
rfoff=rfoff+wn[cwin].ihc[junk2];
junk2--;
}
dp=wn[cwin].inp+rfoff;
aflag=FALSE;
blunk2=wn[cwin].iof[wl];
while(rfoff<strlen(wn[cwin].inp)){
vqt_width(ws.handle,*(dp+lcount),&cellw,&junk2,&junk2);
if(soff+cellw>wn[cwin].wwa.g_w){
wn[cwin].ihc[wl]=lcount;
wn[cwin].iof[wl]=soff;
dp=dp+lcount-1;
lcount=0;
soff=0;
wl++;
soff=soff+cellw;
cellw=0;
aflag=TRUE;
}
soff=soff+cellw;
lcount++;
if(rfoff==blunk+strlen(point)-1){wn[cwin].cvof=wl;wn[cwin].cx=lcount;}
rfoff++;
}
if(lcount){
wn[cwin].ihc[wl]=lcount;
wn[cwin].iof[wl]=soff;
}
if(!aflag){
startupdate();
clchar();
clcursor();
vst_color(ws.handle,col[CINPTEXT]);
vswr_mode(ws.handle,MD_TRANS);
v_gtext(ws.handle,wn[cwin].wwa.g_x+blunk2,wn[cwin].wwa.g_y+wn[cwin].wwa.g_h-1,point);
finishupdate();
}
if(aflag)ipbredraw(cwin);
return 0;
}
Esempio n. 30
0
int inputprocess(){
int junk,junk2,cellw,rfoff=0,lcount=0,wl;
char aflag=FALSE;
char *dp;
int sff=0;
char temps[2048];
	if(cwin==-1)return 0;
	wind_get(wn[cwin].hand,WF_TOP,&junk,&junk2,&junk2,&junk2);
	if(cwin!=-1 && wn[cwin].stat!=WMDONTWRITE && junk==wn[cwin].hand){
	strcpy(chinp,"\0");
	sprintf(chinp,"%c",kreturn);
	if(wn[cwin].scb){sbvslid(1000);wn[cwin].scb=0;}
	
	if(!strncmp("\b",chinp,1) && inpbcontents()){
	vst_font(ws.handle,(WORD)inpfont);
	vst_point(ws.handle,(WORD)inppoint,&junk2,&junk2,&junk2,&junk2);

	clcursor(cwin);
	junk2=findcurpos();
	stccpy(temps,wn[cwin].inp,junk2);
	strcat(temps,wn[cwin].inp+junk2);
	strcpy(wn[cwin].inp,temps);
	if(wn[cwin].cx>0){wn[cwin].cx--;}
	else{
	if(wn[cwin].cvof!=0){
	wn[cwin].cvof--;wn[cwin].cx=wn[cwin].ihc[wn[cwin].cvof]-1;}
	}
	
wl=wn[cwin].cvof;
junk2=wn[cwin].cvof-1;
while(junk2>-1){
rfoff=rfoff+wn[cwin].ihc[junk2];
junk2--;
}
dp=wn[cwin].inp+rfoff;
if(rfoff==strlen(wn[cwin].inp)){wn[cwin].ihc[wl]=0;
wn[cwin].iof[wl]=0;
}
else{
while(rfoff<strlen(wn[cwin].inp)){
vqt_width(ws.handle,*(dp+lcount),&cellw,&junk2,&junk2);
if(sff+cellw>wn[cwin].wwa.g_w){
wn[cwin].ihc[wl]=lcount;
wn[cwin].iof[wl]=sff;
dp=dp+lcount;
lcount=-1;
sff=0;
wl++;
cellw=0;
}
sff=sff+cellw;
lcount++;
rfoff++;
}

wn[cwin].ihc[wl]=lcount;
wn[cwin].iof[wl]=sff;
}
ipbredraw(cwin);
strcpy(chinp,"\0");
	aflag=TRUE;
	}

	if(!strncmp("\b",chinp,1) && !inpbcontents()){
	strcpy(chinp,"\0");
	aflag=TRUE;
	}
	
	if(strlen(wn[cwin].inp)>511){flag=TRUE;}
	
	if(!strncmp("\r",chinp,1)){
	aflag=TRUE;
	strcpy(chinp,"\0");
	gotcmd();
	clearipb(cwin);
	docursor(cwin);
	}
	
	if(!aflag){
	clcursor(cwin);
	wtib(chinp,aflag);
	docursor(cwin);
	strcpy(chinp,"\0");
	}
	
	}
	return 0;
}