Example #1
0
RelocInfo *
FindRelocOffset(long offset, short hunkNo)
{
    RelocInfo *r = RelOffCache;

    if (r == NULL)
	r = GetHead(&RelList);

    while (r && r->ri_SrcOffset >= offset)
	r = GetPred((Node *)&r->ri_Node);

    if (r == NULL)
	r = GetHead(&RelList);

    while (r && r->ri_SrcOffset < offset)
	r = GetSucc((Node *)&r->ri_Node);

    while (r && r->ri_SrcHunk != hunkNo)
	r = GetSucc((Node *)&r->ri_Node);

    if (r)
	RelOffCache = r;

    return(r);
}
Example #2
0
int UnSelectAllObjects(piObject *w)
{
	piObject *o;
	struct List *l;
	ULONG sel,s=0;

	piGetAttr(w,WNOBJ_GadgetList,(ULONG *)&l);
	for(o=(piObject *)GetHead(l);GetSucc(o);o=(piObject *)GetSucc(o))
	{
		piGetAttr(o,OBJ_Select,(ULONG *)&sel);
		if(sel)
		{
			s=1;
			piSetAttrs(o,OBJ_Select,FALSE,TAG_DONE);
			piRenderObject(o);
		}
	}
	piGetAttr(w,WNOBJ_FrameList,(ULONG *)&l);
	for(o=(piObject *)GetHead(l);GetSucc(o);o=(piObject *)GetSucc(o))
	{
		piGetAttr(o,OBJ_Select,(ULONG *)&sel);
		if(sel)
		{
			s=1;
			piSetAttrs(o,OBJ_Select,FALSE,TAG_DONE);
			piRenderObject(o);
		}
	}
	return (int)s;
}
Example #3
0
piObject *piFindFrame(piObject *w,UWORD x,UWORD y)
{
	piObject *o;
	struct List *l;

	piGetAttr(w,WNOBJ_FrameList,(ULONG *)&l);

	for(o=(piObject *)GetHead(l);GetSucc(o);o=(piObject *)GetSucc(o))
		if(piDoMethod(o,OM_HITTEST,(ULONG)x,(ULONG)y)) return o;
	return NULL;
}
Example #4
0
piObject *piFindGadget(piObject *w,UWORD x,UWORD y)
{
	piObject *o;
	struct Node_Window *nw;

	piGetAttr(w,OBJ_Node,(ULONG *)&nw);

	for(o=(piObject *)GetHead(&nw->nw_List_Gadget);GetSucc(o);o=(piObject *)GetSucc(o))
		if(piDoMethod(o,OM_HITTEST,(ULONG)x,(ULONG)y)) return o;
	return NULL;
}
Example #5
0
static void ami_font_cache_cleanup(struct MinList *ami_font_cache_list)
{
	struct nsObject *node;
	struct nsObject *nnode;
	struct ami_font_cache_node *fnode;
	struct TimeVal curtime;

	if(IsMinListEmpty(ami_font_cache_list)) return;

	node = (struct nsObject *)GetHead((struct List *)ami_font_cache_list);

	do
	{
		nnode=(struct nsObject *)GetSucc((struct Node *)node);
		fnode = node->objstruct;
		GetSysTime(&curtime);
		SubTime(&curtime, &fnode->lastused);
		if(curtime.Seconds > 300)
		{
			LOG("Freeing %s not used for %ld seconds", node->dtz_Node.ln_Name, curtime.Seconds);
			DelObject(node);
		}
	} while((node=nnode));

	/* reschedule to run in five minutes */
	ami_schedule(300000, (void *)ami_font_cache_cleanup, ami_font_cache_list);
}
Example #6
0
RelocInfo *
FindRelocNext(RelocInfo *rel)
{
    RelocInfo *r;

    for (r = GetSucc((Node *)&rel->ri_Node); r && r->ri_SrcHunk != rel->ri_SrcHunk; r = GetSucc((Node *)&r->ri_Node));
    return(r);
}
Example #7
0
void SelectObjects(piObject *wo,UWORD x,UWORD y,UWORD w,UWORD h)
{
	struct List *l;
	piObject *o;
	ULONG x1,y1,w1,h1,f=TRUE;
	ULONG OffX,OffY;
	struct Node_Window *nw;

	piGetAttr(wo,OBJ_Node,(ULONG *)&nw);
	if(nw->nw_MyFlags&MYWA_DragToolVert)
		OffX=(8);
	else
		OffX=(Scr->WBorLeft);

	if(nw->nw_MyFlags&MYWA_DragToolVert)
		OffY=(Scr->WBorTop);
	else
	{
		if(nw->nw_MyFlags&MYWA_DragToolHoriz)
			OffY=(8);
		else
			OffY=(Scr->RastPort.TxHeight+Scr->WBorTop+1);
	}

	x-=OffX; y-=OffY;
	w-=OffX; h-=OffY;
	if(x>w) { x1=x; x=w; w=x1; }
	if(y>h) { y1=y; y=h; h=y1; }

	piGetAttr(wo,WNOBJ_GadgetList,(ULONG *)&l);
	for(o=(piObject *)GetHead(l);GetSucc(o);o=(piObject *)GetSucc(o))
	{
		piGetAttr(o,GA_Left,&x1);
		piGetAttr(o,GA_Top,&y1);
		piGetAttr(o,GA_Width,&w1);
		piGetAttr(o,GA_Height,&h1);
		if((x1>=x) && (y1>=y) && (x1+w1<=w) && (y1+h1<=h))
		{
			if(f) CurrentGadget=o;
			f=FALSE;
			piSetAttrs(o,OBJ_Select,TRUE,TAG_DONE);
		}
	}
}
Example #8
0
static void gui_download_window_done(struct gui_download_window *dw)
{
	struct dlnode *dln,*dln2 = NULL;
	struct browser_window *bw;
	bool queuedl = false;

	if(!dw) return;
	bw = dw->bw;

	if((nsoption_bool(download_notify)) && (dw->result == AMINS_DLOAD_OK))
	{
		Notify(ami_gui_get_app_id(), APPNOTIFY_Title, messages_get("amiDownloadComplete"),
				APPNOTIFY_PubScreenName, "FRONT",
				APPNOTIFY_BackMsg, dw->fname,
				APPNOTIFY_CloseOnDC, TRUE,
				APPNOTIFY_Text, dw->fname,
				TAG_DONE);
	}

	download_context_destroy(dw->ctx);

	if((dln = dw->dln))
	{
		dln2 = (struct dlnode *)GetSucc((struct Node *)dln);
		if((dln!=dln2) && (dln2)) queuedl = true;

		free(dln->filename);
		Remove((struct Node *)dln);
		FreeVec(dln);
	}

	FClose(dw->fh);
	SetComment(dw->fname, dw->url);

	downloads_in_progress--;

	DisposeObject(dw->objects[OID_MAIN]);
	DelObject(dw->node);
	if(queuedl) {
		nsurl *url;
		if (nsurl_create(dln2->node.ln_Name, &url) != NSERROR_OK) {
			amiga_warn_user("NoMemory", 0);
		} else {
			browser_window_navigate(bw,
				url,
				NULL,
				BW_NAVIGATE_DOWNLOAD,
				NULL,
				NULL,
				NULL);
			nsurl_unref(url);
		}
	}
	ami_try_quit(); /* In case the only window open was this download */
}
Example #9
0
unsigned            BasicBlock::dspSuccs(Compiler* compiler)
{
    unsigned numSuccs = NumSucc(compiler);
    unsigned count = 0;
    for (unsigned i = 0; i < numSuccs; i++)
    {
        printf("%s", (count == 0) ? "" : ",");        
        printf("BB%02u", GetSucc(i, compiler)->bbNum);
        count++;
    }
    return count;
}
Example #10
0
void free_browserlist(struct List *list)
{
    struct Node *node, *nextnode;

	if(IsListEmpty(list)) return;

    node = GetHead(list);

	do
    {
    	nextnode = GetSucc(node);
//		FreeVec(node->ln_Name);
        FreeListBrowserNode(node);
    } while(node = nextnode);
}
Example #11
0
void ami_free_download_list(struct List *dllist)
{
	struct dlnode *node;
	struct dlnode *nnode;

	if(!dllist) return;
	if(IsListEmpty(dllist)) return;

	node = (struct dlnode *)GetHead((struct List *)dllist);

	do
	{
		nnode=(struct dlnode *)GetSucc((struct Node *)node);
		free(node->node.ln_Name);
		free(node->filename);
		Remove((struct Node *)node);
		FreeVec((struct Node *)node);
	}while((node=nnode));
}
Example #12
0
void *ami_find_gwin_by_id(struct Window *win, int type)
{
	struct nsObject *node, *nnode;
	struct gui_window_2 *gwin;

	if(!IsMinListEmpty(window_list))
	{
		node = (struct nsObject *)GetHead((struct List *)window_list);

		do
		{
			nnode=(struct nsObject *)GetSucc((struct Node *)node);

			if(node->Type == type)
			{
				gwin = node->objstruct;
				if(win == gwin->win) return gwin;
			}
		} while(node = nnode);
	}
	return NULL;
}
Example #13
0
struct browser_window *ami_find_tab_gwin(struct gui_window_2 *gwin, int tab)
{
	int tabs = 0;
	struct Node *ctab;
	struct Node *ntab;
	struct browser_window *bw;

	if((tab == 0) || (gwin->tabs == 0)) return gwin->bw;

	ctab = GetHead(&gwin->tab_list);

	do
	{
		tabs++;
		ntab=GetSucc(ctab);
		GetClickTabNodeAttrs(ctab,
							TNA_UserData, &bw,
							TAG_DONE);
		if(tabs == tab) return bw;
	} while(ctab=ntab);

	return NULL;
}
Example #14
0
int ami_find_tab_bw(struct gui_window_2 *gwin, struct browser_window *bw)
{
	int tabs = 0;
	struct Node *ctab;
	struct Node *ntab;
	struct browser_window *tbw = NULL;

	if((bw == NULL) || (gwin->tabs == 0)) return 1;

	ctab = GetHead(&gwin->tab_list);

	do
	{
		tabs++;
		ntab=GetSucc(ctab);
		GetClickTabNodeAttrs(ctab,
							TNA_UserData, &tbw,
							TAG_DONE);
		if(tbw == bw) return tabs;
	} while(ctab=ntab);

	return 0;
}
Example #15
0
struct browser_window *ami_find_tab(int window, int tab)
{
	int windows = 0, tabs = 0;
	struct nsObject *node, *nnode;
	struct gui_window_2 *gwin;

	if(!IsMinListEmpty(window_list))
	{
		node = (struct nsObject *)GetHead((struct List *)window_list);

		do
		{
			nnode=(struct nsObject *)GetSucc((struct Node *)node);

			if(node->Type == AMINS_WINDOW)
			{
				windows++;
				if(windows == window)
					return ami_find_tab_gwin(node->objstruct, tab);
			}
		} while(node = nnode);
	}
	return NULL;
}
Example #16
0
static uint32 myStringSearch( Class *cl, Object *obj )
{
	struct myStringClassData *data;
	struct Window *win;
	struct Node *node;
	struct Node *n;
	uint32 found;
	uint32 bufpos;
	STRPTR searchString;
	STRPTR compString;

	found = 0;

	data = INST_DATA( cl, obj );

	win = data->Window;

	// Remove List and Free Nodes

    SetGadgetAttrs( (struct Gadget *)data->ListviewObject, win, NULL,
	    LISTBROWSER_Labels, ~0,
	    TAG_END
    );

	while(( node = RemHead( &data->ListviewHeader )))
	{
		FreeListBrowserNode( node );
	}

	GetAttr( STRINGA_BufferPos, obj, &bufpos );

	if ( bufpos == 0 )
	{
		goto bailout;
	}

//-------------

	searchString = strstr(data->SearchBuffer, "://");
	if(searchString)
	{
		searchString += 3;
		if (bufpos >= searchString - data->SearchBuffer)
			bufpos -= searchString - data->SearchBuffer;
	}
	else
		searchString = data->SearchBuffer;

	node = GetHead( data->SearchHeader );

	while( node )
	{
		uint32 srcpos;
		BOOL possible;

		possible = FALSE;
		srcpos = 0;

		compString = strstr(node->ln_Name, "://");
		if(compString)
			compString += 3;
		else
			compString = node->ln_Name;

		if( 0 == strncasecmp( compString, searchString, bufpos ) )
		{
			// found match after protocol
			possible = TRUE;
		}
		else
		{
			// no match after protocol, see if there's a match after www
			if( 0 == strncasecmp( compString, "www.", 4) ) {
				// got www, compare it!
				if( 0 == strncasecmp( &compString[4], searchString, bufpos ) )
					possible = TRUE;
			}
		}

		if ( possible == TRUE )
		{
			n = AllocListBrowserNode( 1,
				LBNA_Column,    0,
					LBNCA_CopyText, TRUE,
					LBNCA_Text,     node->ln_Name,
				TAG_END
			);

			if ( n )
			{
				AddTail( &data->ListviewHeader, n );
				found++;
			}
		}

		node = GetSucc( node );
	}

//-------------

bailout:

	data->ListviewCount = found;
	data->ListviewSelected = -1;

	// Add List Again

	RefreshSetGadgetAttrs( (struct Gadget *)data->ListviewObject, win, NULL,
	    LISTBROWSER_Labels, &data->ListviewHeader,
		LISTBROWSER_Selected, data->ListviewSelected,
		LISTBROWSER_MakeVisible, 0,
	    TAG_END
    );

	return( found );
}
Example #17
0
/// findDbgMallocNode
// find a given pointer in the tracking lists
static struct DbgMallocNode *findDbgMallocNode(const void *ptr)
{
  struct DbgMallocNode *result = NULL;
  struct Node *curNode;

  for(curNode = GetHead((struct List *)&DbgMallocList[ptr2hash(ptr)]); curNode != NULL; curNode = GetSucc(curNode))
  {
    struct DbgMallocNode *dmn = (struct DbgMallocNode *)curNode;

    if(dmn->memory == ptr)
    {
      result = dmn;
      break;
    }
  }

  return result;
}
Example #18
0
///
/// DumpDbgMalloc
// output all current allocations
void DumpDbgMalloc(void)
{
  ENTER();

  if(isFlagSet(debug_classes, DBC_MTRACK))
  {
    ULONG i;

    ObtainSemaphore(&DbgMallocListSema);

    D(DBF_ALWAYS, "%ld memory areas tracked", DbgMallocCount);
    for(i = 0; i < ARRAY_SIZE(DbgMallocList); i++)
    {
      struct Node *curNode;

      for(curNode = GetHead((struct List *)&DbgMallocList[i]); curNode != NULL; curNode = GetSucc(curNode))
      {
        struct DbgMallocNode *dmn = (struct DbgMallocNode *)curNode;

        _DPRINTF(DBC_MTRACK, DBF_ALWAYS, dmn->file, dmn->line, "memarea 0x%08lx, size/type %ld, func (%s)", dmn->memory, dmn->size, dmn->func);
      }
    }

    ReleaseSemaphore(&DbgMallocListSema);
  }

  LEAVE();
}
Example #19
0
void ami_fetch_file_poll(const char *scheme_ignored)
{
	struct nsObject *node;
	struct nsObject *nnode;
	struct ami_file_fetch_info *fetch;
	fetch_error_code errorcode;
	
	if(IsMinListEmpty(ami_file_fetcher_list)) return;

	node = (struct nsObject *)GetHead((struct List *)ami_file_fetcher_list);

	do
	{
		errorcode = FETCH_ERROR_NO_ERROR;
		nnode=(struct nsObject *)GetSucc((struct Node *)node);

		fetch = (struct ami_file_fetch_info *)node->objstruct;

		if(fetch->locked) continue;

		if(!fetch->aborted)
		{
			if(fetch->fh)
			{
				ULONG len;

				len = FRead(fetch->fh,ami_file_fetcher_buffer,1,1024);

				if (len == (ULONG)-1)
					errorcode = FETCH_ERROR_MISC;
				else if (len > 0)
					ami_fetch_file_send_callback(
							FETCH_DATA, fetch,
							ami_file_fetcher_buffer,
							len, errorcode);

				if((len<1024) && (!fetch->aborted))
				{
					ami_fetch_file_send_callback(FETCH_FINISHED,
						fetch, NULL, 0,
						errorcode);

					fetch->aborted = true;
				}
			}
			else
			{
				fetch->fh = FOpen(fetch->path,MODE_OLDFILE,0);

				if(fetch->fh)
				{
					char header[64];
					struct ExamineData *fib;
					if(fib = ExamineObjectTags(EX_FileHandleInput,fetch->fh,TAG_DONE))
					{
						fetch->len = fib->FileSize;
						FreeDosObject(DOS_EXAMINEDATA,fib);
					}

					fetch_set_http_code(fetch->fetch_handle,200);
					fetch->mimetype = fetch_mimetype(fetch->path);
					LOG(("mimetype %s len %ld",fetch->mimetype,fetch->len));

					snprintf(header, sizeof header,
							"Content-Type: %s",
							fetch->mimetype);
					ami_fetch_file_send_callback(FETCH_HEADER,
						fetch, header, strlen(header), errorcode);

					snprintf(header, sizeof header,
							"Content-Length: %ld",
							fetch->len);
					ami_fetch_file_send_callback(FETCH_HEADER,
						fetch, header, strlen(header), errorcode);

				}
				else
				{
					STRPTR errorstring;

					errorstring = ASPrintf("%s %s",messages_get("FileError"),fetch->path);
					fetch_set_http_code(fetch->fetch_handle,404);
					
					errorcode = FETCH_ERROR_HTTP_NOT2;
					ami_fetch_file_send_callback(FETCH_ERROR, fetch,
						errorstring, 0,
						errorcode);
					fetch->aborted = true;
					FreeVec(errorstring);
				}
			}
		}

		if(fetch && fetch->aborted)
		{
			fetch_remove_from_queues(fetch->fetch_handle);
			fetch_free(fetch->fetch_handle);
			return;
		}
	}while(node=nnode);
}