示例#1
0
static struct IntuiText *displayalert_makebody(STRPTR string, struct TextAttr *font)
{
    struct IntuiText *res;
    char *s = string;
    unsigned int lines = 0;
    unsigned int i;

    /* First count number of lines */
    do
    {
        s += 3;		/* Skip coordinates			      */
	while (*s++);	/* Skip text bytes including NULL terminator  */
	lines++;
    } while (*s++);	/* This automatically skips continuation byte */

    res = AllocVec(sizeof(struct IntuiText) * lines, MEMF_ANY);
    if (!res)
	return NULL;

    s = string;
    for (i = 0; i < lines; i++)
    {
	res[i].FrontPen = 1;
	res[i].BackPen  = 0;
	res[i].DrawMode = JAM2;
	res[i].LeftEdge = AROS_BE2WORD(*((UWORD *)s));
	s += 2;
	res[i].TopEdge  = *s++ - TOPAZ_8_BASELINE;
	res[i].ITextFont = font;
	res[i].IText = s;
	while(*s++);
	res[i].NextText = *s++ ? &res[i+1] : NULL;
    }

    return res;
}
示例#2
0
static Att_List *do_read_sites_iff(struct opusftp_globals *og,char *filename,LONG *diskerr)
{
APTR iff;
BOOL err=FALSE;
Att_List *list;

D(bug("read sites\n"));

if	(!(list=Att_NewList(LISTF_POOL)))
	return(NULL);

	// Open IFF file
if	((iff=IFFOpen(filename,IFF_READ,ID_OPUS)))
	{
	struct site_entry *e;
	ULONG chunk;

	while	(!err && (chunk=IFFNextChunk(iff,0)))
		{
		if	((e=AllocVec(sizeof(struct site_entry),MEMF_CLEAR)))
			{
			int size;
			int chunksize = 0;

			if	(chunk==ID_FTPSITE_SHORT)
				size=SMALL_SIZE;

			else if (chunk==ID_FTPSITE_LONG)
				size=LARGE_SIZE;
			else
				{
				*diskerr=212;
				err=TRUE;
				FreeVec(e);
				break;
				}

			// Adjustment for changed ListFormat size
			chunksize = (int)IFFChunkSize(iff);
			if ((chunksize < size) && (size - chunksize == 84))
			{
				if (!(err=(chunksize!=IFFReadChunkBytes(iff,(char *)e,chunksize))));
				{
					char patterns[82] = {'\0'};
					int i = 0;

					CopyMem(e->se_listformat.show_pattern_p, patterns, 80);
					memset(e->se_listformat.show_pattern_p, 0, 160);
					for (i = 0; i < 40; i++)
					{
						e->se_listformat.show_pattern_p[i] = patterns[i];
						e->se_listformat.hide_pattern_p[i] = patterns[i+40];
					}
				}
			}
			else
				err=(size!=IFFReadChunkBytes(iff,(char *)e,size));

			if	(!err)
				{
#ifdef __AROS__
				e->se_anon = AROS_BE2WORD(e->se_anon);
				e->se_port = AROS_BE2LONG(e->se_port);
				e->se_has_custom_env = AROS_BE2WORD(e->se_has_custom_env);
				if (size == LARGE_SIZE)
				{
					e->se_env_private.e_retry_count = AROS_BE2LONG(e->se_env_private.e_retry_count);
					e->se_env_private.e_retry_delay = AROS_BE2LONG(e->se_env_private.e_retry_delay);
					e->se_env_private.e_list_update = AROS_BE2LONG(e->se_env_private.e_list_update);
					e->se_env_private.e_timeout = AROS_BE2LONG(e->se_env_private.e_timeout);
					e->se_env_private.e_script_time = AROS_BE2LONG(e->se_env_private.e_script_time);
					e->se_env_private.e_indexsize = AROS_BE2LONG(e->se_env_private.e_indexsize);

					e->se_env_private.bitfield1 = AROS_BE2LONG(e->se_env_private.bitfield1);
					e->se_env_private.bitfield2 = AROS_BE2LONG(e->se_env_private.bitfield2);
				}
#endif

				//  adjust ptrs for environment
				// if custom env then set ptr to internal private copy
				// else set it to point to global ftp default
				if	(e->se_has_custom_env)
					e->se_env=&e->se_env_private;
				else
					e->se_env=&og->og_oc.oc_env;


				Att_NewNode(list, e->se_name ,(ULONG)e ,0 );
				}
			else
				FreeVec(e);

			}
		else
			err=TRUE;
		}

	// Close file
	IFFClose(iff);


	if	(!err)
		return(list);
	}


Att_RemList(list,REMLIST_FREEDATA);

if	(!*diskerr)
	*diskerr=IoErr();

return(NULL);
}