void alg2_common_t(Term a2) { List ct, l1,l2,l3,l4, ml, gct, vil=0; ct=NewList(); ml=CompoundArgN(a2,5); if(is_empty_list(ml) || (ListLength(ml)==1 && FAOutput==0) ) return; gct=CompoundArgN(ListFirst(ml),3); if(is_empty_list(gct)) return; if(FAOutput) { for(l1=CompoundArg1(a2);l1;l1=ListTail(l1)) if(CompoundName(CompoundArg2(ListFirst(l1)))==OPR_VECTOR || CompoundName(CompoundArg2(ListFirst(l1)))==OPR_SPINOR) vil=AppendLast(vil,ListFirst(CompoundArg1( CompoundArg2(ListFirst(l1))))); } l1=gct; while(!is_empty_list(l1)) { Term spt; spt=ListFirst(l1); if(FAOutput) { Term pr; if(CompoundName(spt)==A_MOMENT) goto cnt1; if((is_atom(CompoundArg1(spt))&& (pr=GetAtomProperty(CompoundArg1(spt),A_INFINITESIMAL)))) goto cnt1; if(CompoundName(spt)==OPR_SPECIAL) { l2=CompoundArg1(spt); if(l2==A_GAMMA||l2==A_GAMMA5||l2==A_GAMMAP||l2==A_GAMMAM) goto cnt1; } if(vil && CompoundName(spt)==OPR_SPECIAL && CompoundArg1(spt)==A_DELTA) { l2=CompoundArg2(spt); if(ListMember(vil,ListFirst(l2))) goto cnt1; if(ListMember(vil,ListFirst(ListTail(l2)))) goto cnt1; } } l2=ListTail(ml); while(!is_empty_list(l2)) { l3=CompoundArgN(ListFirst(l2),3); while(!is_empty_list(l3)) { if(EqualTerms(spt,ListFirst(l3))) break; l3=ListTail(l3); } if(is_empty_list(l3)) goto cnt1; l2=ListTail(l2); } ct=AppendLast(ct,CopyTerm(spt)); cnt1: l1=ListTail(l1); } if(is_empty_list(ct)) return; l1=ml; while(!is_empty_list(l1)) { Term m2; m2=ListFirst(l1); l2=ConsumeCompoundArg(m2,3); l3=ct; while(!is_empty_list(l3)) { Term rt; rt=ListFirst(l3); l4=l2; while(!is_empty_list(l4)) { if(EqualTerms(ListFirst(l4),rt)) { l2=CutFromList(l2,l4); goto cnt2; } l4=ListTail(l4); } puts("Internal error (a2ctf)."); cnt2: l3=ListTail(l3); } SetCompoundArg(m2,3,l2); l1=ListTail(l1); } SetCompoundArg(a2,4,ct); }
void alg2_common_n(Term a2) { List m2l,l,l1,nl,dl; int cnum,cden,ti; m2l=CompoundArgN(a2,5); nl=dl=NewList(); l=m2l; if(is_empty_list(l)) return; while(!is_empty_list(l)) { Term t; t=ConsumeCompoundArg(ListFirst(l),1); nl=AppendLast(nl,CompoundArg1(t)); dl=AppendLast(dl,CompoundArg2(t)); FreeAtomic(t); l=ListTail(l); } cnum=gcf_list(nl); cden=gcf_list(dl); if(IntegerValue(ListFirst(nl))<0) cnum*=-1; l=nl; l1=dl; while(!is_empty_list(l)) { ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/cnum)); ChangeList(l1,NewInteger(IntegerValue(ListFirst(l1))/cden)); l=ListTail(l); l1=ListTail(l1); } ti=mlt_list1(dl); l=nl; l1=dl; while(!is_empty_list(l)) { ChangeList(l, NewInteger(IntegerValue(ListFirst(l))*ti/IntegerValue(ListFirst(l1)))); l=ListTail(l); l1=ListTail(l1); } cden*=ti; ti=gcf_list(nl); cnum*=ti; l=nl; while(!is_empty_list(l)) { ChangeList(l,NewInteger(IntegerValue(ListFirst(l))/ti)); l=ListTail(l); } ti=gcf(cnum,cden); cnum/=ti; cden/=ti; RemoveList(dl); SetCompoundArg(a2,2,MakeCompound2(OPR_DIV,NewInteger(cnum),NewInteger(cden))); l=m2l; l1=nl; while(!is_empty_list(l)) { SetCompoundArg(ListFirst(l),1,ListFirst(l1)); l1=ListTail(l1); l=ListTail(l); } RemoveList(nl); return ; }
struct ISAPNPBase* ASMCALL initRoutine( REG( d0, struct ISAPNPBase* res ), REG( a0, APTR seglist ), REG( a6, struct ExecBase* sysbase ) ) { SysBase = sysbase; if( ! OpenLibs() ) { // No libraries? Req( "Failed to open required libraries." ); } else { ULONG actual; struct CurrentBinding current_binding; actual = GetCurrentBinding( ¤t_binding, sizeof( current_binding ) ); if( actual < sizeof( current_binding ) ) { // No legal CurrentBinding structure Req( "No legal CurrentBinding structure found." ); } else { struct ConfigDev* cd = current_binding.cb_ConfigDev; if( cd == NULL ) { // No card found Req( "No bridge card found." ); } else { if( cd->cd_Rom.er_Manufacturer != 2150 || cd->cd_Rom.er_Product != 1 ) { // Unsupported ISA bridge Req( "Unsupported ISA bridge: %ld/%ld.\n" "Only the GG2 Bus+ card is supported.", cd->cd_Rom.er_Manufacturer, cd->cd_Rom.er_Product ); } else { if( cd->cd_BoardAddr == NULL ) { // No board address? Req( "No board address?" ); } else { // Set up the ISAPNPBase structure res->m_Library.lib_Node.ln_Type = NT_RESOURCE; res->m_Library.lib_Node.ln_Name = (STRPTR) ResName; res->m_Library.lib_Flags = LIBF_SUMUSED | LIBF_CHANGED; res->m_Library.lib_Version = VERSION; res->m_Library.lib_Revision = REVISION; res->m_Library.lib_IdString = (STRPTR) IDString; NewList( &res->m_Cards ); res->m_Base = cd->cd_BoardAddr; res->m_RegReadData = 0x0000; res->m_ConfigDev = cd; if( ! ISAPNP_ScanCards( res ) ) { // No cards found Req( "No PnP ISA cards found." ); FreeISAPNPBase( res ); } else { struct ISAPNP_Card* card; card = ISAPNP_AllocCard( res ); if( card == NULL ) { Req( "Out of memory!" ); FreeISAPNPBase( res ); } else { static const char descr[] = "Non-PnP devices"; char* d; d = AllocVec( sizeof( descr ), MEMF_PUBLIC ); if( d != NULL ) { CopyMem( (void*) descr, d, sizeof( descr ) ); card->isapnpc_Node.ln_Name = d; } card->isapnpc_ID.isapnpid_Vendor[ 0 ] = '?'; card->isapnpc_ID.isapnpid_Vendor[ 1 ] = '?'; card->isapnpc_ID.isapnpid_Vendor[ 2 ] = '?'; card->isapnpc_SerialNumber = -1; // Add *first* AddHead( &res->m_Cards, (struct Node*) card ); // Let's see if we're to disable any cards or devices etc if( ! HandleToolTypes( current_binding.cb_ToolTypes, card, res ) ) { // Error requester already displayed. FreeISAPNPBase( res ); } else { if( ! ISAPNP_ConfigureCards( res ) ) { // Unable to configure cards Req( "Unable to configure the cards. This is most likely\n" "because of an unresolvable hardware conflict.\n\n" "Use the DISABLE_DEVICE tool type to disable one of\n" "the devices in conflict." ); FreeISAPNPBase( res ); } else { cd->cd_Flags &= ~CDF_CONFIGME; cd->cd_Driver = res; ISAPNPBase = res; } } } } } } } } } return ISAPNPBase; }
void Unix_GetInterfaceInfo(enum cfagenttype ag) { int fd, len, i, j, first_address = false, ipdefault = false; struct ifreq ifbuf[CF_IFREQ], ifr, *ifp; struct ifconf list; struct sockaddr_in *sin; struct hostent *hp; char *sp, workbuf[CF_BUFSIZE]; char ip[CF_MAXVARSIZE]; char name[CF_MAXVARSIZE]; char last_name[CF_BUFSIZE]; Rlist *interfaces = NULL, *hardware = NULL, *ips = NULL; CfDebug("Unix_GetInterfaceInfo()\n"); memset(ifbuf, 0, sizeof(ifbuf)); InitIgnoreInterfaces(); last_name[0] = '\0'; if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) == -1) { CfOut(cf_error, "socket", "Couldn't open socket"); exit(1); } list.ifc_len = sizeof(ifbuf); list.ifc_req = ifbuf; # ifdef SIOCGIFCONF if (ioctl(fd, SIOCGIFCONF, &list) == -1 || (list.ifc_len < (sizeof(struct ifreq)))) # else if (ioctl(fd, OSIOCGIFCONF, &list) == -1 || (list.ifc_len < (sizeof(struct ifreq)))) # endif { CfOut(cf_error, "ioctl", "Couldn't get interfaces - old kernel? Try setting CF_IFREQ to 1024"); exit(1); } last_name[0] = '\0'; for (j = 0, len = 0, ifp = list.ifc_req; len < list.ifc_len; len += SIZEOF_IFREQ(*ifp), j++, ifp = (struct ifreq *) ((char *) ifp + SIZEOF_IFREQ(*ifp))) { if (ifp->ifr_addr.sa_family == 0) { continue; } if (ifp->ifr_name == NULL || strlen(ifp->ifr_name) == 0) { continue; } /* Skip virtual network interfaces for Linux, which seems to be a problem */ if (IgnoreInterface(ifp->ifr_name)) { continue; } if (strstr(ifp->ifr_name, ":")) { if (VSYSTEMHARDCLASS == linuxx) { CfOut(cf_verbose, "", "Skipping apparent virtual interface %d: %s\n", j + 1, ifp->ifr_name); continue; } } else { CfOut(cf_verbose, "", "Interface %d: %s\n", j + 1, ifp->ifr_name); } // Ignore the loopback if (strcmp(ifp->ifr_name, "lo") == 0) { continue; } if (strncmp(last_name, ifp->ifr_name, sizeof(ifp->ifr_name)) == 0) { first_address = false; } else { strncpy(last_name, ifp->ifr_name, sizeof(ifp->ifr_name)); if (!first_address) { NewScalar("sys", "interface", last_name, cf_str); first_address = true; } } snprintf(workbuf, CF_BUFSIZE, "net_iface_%s", CanonifyName(ifp->ifr_name)); NewClass(workbuf); if (ifp->ifr_addr.sa_family == AF_INET) { strncpy(ifr.ifr_name, ifp->ifr_name, sizeof(ifp->ifr_name)); if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) { CfOut(cf_error, "ioctl", "No such network device"); //close(fd); //return; continue; } if ((ifr.ifr_flags & IFF_BROADCAST) && !(ifr.ifr_flags & IFF_LOOPBACK)) { sin = (struct sockaddr_in *) &ifp->ifr_addr; if (IgnoreJailInterface(j + 1, sin)) { CfOut(cf_verbose, "", "Ignoring interface %d", j + 1); continue; } CfDebug("Adding hostip %s..\n", inet_ntoa(sin->sin_addr)); NewClass(inet_ntoa(sin->sin_addr)); if ((hp = gethostbyaddr((char *) &(sin->sin_addr.s_addr), sizeof(sin->sin_addr.s_addr), AF_INET)) == NULL) { CfDebug("No hostinformation for %s not found\n", inet_ntoa(sin->sin_addr)); } else { if (hp->h_name != NULL) { CfDebug("Adding hostname %s..\n", hp->h_name); NewClass(hp->h_name); if (hp->h_aliases != NULL) { for (i = 0; hp->h_aliases[i] != NULL; i++) { CfOut(cf_verbose, "", "Adding alias %s..\n", hp->h_aliases[i]); NewClass(hp->h_aliases[i]); } } } } if (strcmp(inet_ntoa(sin->sin_addr), "0.0.0.0") == 0) { // Maybe we need to do something windows specific here? CfOut(cf_verbose, "", " !! Cannot discover hardware IP, using DNS value"); strcpy(ip, "ipv4_"); strcat(ip, VIPADDRESS); AppendItem(&IPADDRESSES, VIPADDRESS, ""); AppendRlist(&ips, VIPADDRESS, CF_SCALAR); for (sp = ip + strlen(ip) - 1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; NewClass(ip); } } strcpy(ip, VIPADDRESS); i = 3; for (sp = ip + strlen(ip) - 1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; snprintf(name, CF_MAXVARSIZE - 1, "ipv4_%d[%s]", i--, CanonifyName(VIPADDRESS)); NewScalar("sys", name, ip, cf_str); } } //close(fd); //return; continue; } strncpy(ip, "ipv4_", CF_MAXVARSIZE); strncat(ip, inet_ntoa(sin->sin_addr), CF_MAXVARSIZE - 6); NewClass(ip); if (!ipdefault) { ipdefault = true; NewScalar("sys", "ipv4", inet_ntoa(sin->sin_addr), cf_str); strcpy(VIPADDRESS, inet_ntoa(sin->sin_addr)); } AppendItem(&IPADDRESSES, inet_ntoa(sin->sin_addr), ""); AppendRlist(&ips, inet_ntoa(sin->sin_addr), CF_SCALAR); for (sp = ip + strlen(ip) - 1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; NewClass(ip); } } // Set the IPv4 on interface array strcpy(ip, inet_ntoa(sin->sin_addr)); if (ag != cf_know) { snprintf(name, CF_MAXVARSIZE - 1, "ipv4[%s]", CanonifyName(ifp->ifr_name)); } else { snprintf(name, CF_MAXVARSIZE - 1, "ipv4[interface_name]"); } NewScalar("sys", name, ip, cf_str); i = 3; for (sp = ip + strlen(ip) - 1; (sp > ip); sp--) { if (*sp == '.') { *sp = '\0'; if (ag != cf_know) { snprintf(name, CF_MAXVARSIZE - 1, "ipv4_%d[%s]", i--, CanonifyName(ifp->ifr_name)); } else { snprintf(name, CF_MAXVARSIZE - 1, "ipv4_%d[interface_name]", i--); } NewScalar("sys", name, ip, cf_str); } } } // Set the hardware/mac address array Unix_GetMacAddress(ag, fd, &ifr, ifp, &interfaces, &hardware); } } close(fd); NewList("sys", "interfaces", interfaces, cf_slist); NewList("sys", "hardware_addresses", hardware, cf_slist); NewList("sys", "ip_addresses", ips, cf_slist); }
int main () { int customers, purchases, inputTest, i, j, k, s; ListHndl* booksPurchased; char inputFileName[1024]; FILE* dataFile; fprintf (stdout, "Please input the name of a properly formatted data file\n"); fgets (inputFileName, 1024, stdin); for(j = 0; j < 1024; j++) { if (inputFileName[j] == '\n') { inputFileName[j] = '\0'; break; } } dataFile = fopen (inputFileName, "r"); if (dataFile == NULL) { fprintf (stdout, "Invalid filename\n"); return 1; } inputTest = fscanf (dataFile, "%d", &customers); if (inputTest != 1) { fprintf (stderr, "Improperly formatted file\n"); fclose (dataFile); return 1; } if (customers < 1) { fprintf (stderr, "Invalid input\n"); fprintf (stderr, "Number of customers cannot be less than 1\n"); fclose (dataFile); return 1; } booksPurchased = (ListHndl*)malloc ( (sizeof (ListHndl)) * customers ); inputTest = fscanf (dataFile, "%d", &purchases); if (inputTest != 1) { fprintf (stderr, "Improperly formatted file\n"); fclose (dataFile); free (booksPurchased); return 1; } if (purchases < 0) { fprintf (stderr, "Invalid input\n"); fprintf (stderr, "Number of purchases cannot be negative\n"); fclose (dataFile); free (booksPurchased); return 1; } for (i = 0; i < customers; i++) { booksPurchased[i] = NewList (); } for (k = 0; k < purchases; k++) { int customerNumber; long bookNumber; inputTest = fscanf (dataFile, "%d%ld", &customerNumber, &bookNumber); if (inputTest != 2) { fprintf (stderr, "Improperly formatted file\n"); fclose (dataFile); for (s = 0; s < customers; s++) { FreeList (booksPurchased[s]); } free (booksPurchased); return 1; } if (customerNumber < 1 || customerNumber > customers) { fprintf (stderr, "Invalid customer number\n"); } else { if (IsEmpty (booksPurchased[customerNumber - 1])) { InsertAtFront (booksPurchased[customerNumber - 1], bookNumber); } else { InsertionSort (booksPurchased[customerNumber - 1], bookNumber); } } } fprintf (stdout, "customer# books purchased\n"); for (s = 0; s < customers; s++) { fprintf (stdout, "%d ", (s + 1)); if(!IsEmpty (booksPurchased[s])) { MoveFirst (booksPurchased[s]); } while (!OffEnd(booksPurchased[s])) { fprintf (stdout, " "); PrintCurrent (stdout, booksPurchased[s]); MoveNext (booksPurchased[s]); } fprintf (stdout, "\n"); FreeList (booksPurchased[s]); } fclose (dataFile); free (booksPurchased); return 0; }
// Create Cedar object CEDAR *NewCedar(X *server_x, K *server_k) { CEDAR *c; char tmp[MAX_SIZE]; char tmp2[MAX_SIZE]; char *beta_str; CedarForceLink(); c = ZeroMalloc(sizeof(CEDAR)); c->CurrentActiveLinks = NewCounter(); c->AcceptingSockets = NewCounter(); c->CedarSuperLock = NewLock(); c->CurrentRegionLock = NewLock(); StrCpy(c->OpenVPNDefaultClientOption, sizeof(c->OpenVPNDefaultClientOption), OVPN_DEF_CLIENT_OPTION_STRING); #ifdef BETA_NUMBER c->Beta = BETA_NUMBER; #endif // BETA_NUMBER InitNoSslList(c); c->AssignedBridgeLicense = NewCounter(); c->AssignedClientLicense = NewCounter(); c->CurrentTcpQueueSizeLock = NewLock(); c->QueueBudgetLock = NewLock(); c->FifoBudgetLock = NewLock(); Rand(c->UniqueId, sizeof(c->UniqueId)); c->CreatedTick = Tick64(); c->lock = NewLock(); c->ref = NewRef(); c->OpenVPNPublicPortsLock = NewLock(); c->CurrentTcpConnections = GetNumTcpConnectionsCounter(); c->ListenerList = NewList(CompareListener); c->UDPEntryList = NewList(CompareUDPEntry); c->HubList = NewList(CompareHub); c->ConnectionList = NewList(CompareConnection); c->ConnectionIncrement = NewCounter(); c->CurrentSessions = NewCounter(); if (server_k && server_x) { c->ServerK = CloneK(server_k); c->ServerX = CloneX(server_x); } c->Version = CEDAR_VER; c->Build = CEDAR_BUILD; c->ServerStr = CopyStr(CEDAR_SERVER_STR); GetMachineName(tmp, sizeof(tmp)); c->MachineName = CopyStr(tmp); c->HttpUserAgent = CopyStr(DEFAULT_USER_AGENT); c->HttpAccept = CopyStr(DEFAULT_ACCEPT); c->HttpAcceptLanguage = CopyStr("ja"); c->HttpAcceptEncoding = CopyStr(DEFAULT_ENCODING); c->Traffic = NewTraffic(); c->TrafficLock = NewLock(); c->CaList = NewList(CompareCert); c->TrafficDiffList = NewList(NULL); SetCedarCipherList(c, SERVER_DEFAULT_CIPHER_NAME); c->ClientId = _II("CLIENT_ID"); c->UdpPortList = NewIntList(false); InitNetSvcList(c); InitLocalBridgeList(c); InitCedarLayer3(c); c->WebUI = WuNewWebUI(c); #ifdef ALPHA_VERSION beta_str = "Alpha"; #else // ALPHA_VERSION #ifndef RELEASE_CANDIDATE beta_str = "Beta"; #else // RELEASE_CANDIDATE beta_str = "Release Candidate"; #endif // RELEASE_CANDIDATE #endif // ALPHA_VERSION ToStr(tmp2, c->Beta); Format(tmp, sizeof(tmp), "Version %u.%02u Build %u %s %s (%s)", CEDAR_VER / 100, CEDAR_VER - (CEDAR_VER / 100) * 100, CEDAR_BUILD, c->Beta == 0 ? "" : beta_str, c->Beta == 0 ? "" : tmp2, _SS("LANGSTR")); Trim(tmp); if (true) { SYSTEMTIME st; Zero(&st, sizeof(st)); st.wYear = BUILD_DATE_Y; st.wMonth = BUILD_DATE_M; st.wDay = BUILD_DATE_D; c->BuiltDate = SystemToUINT64(&st); } c->VerString = CopyStr(tmp); Format(tmp, sizeof(tmp), "Compiled %04u/%02u/%02u %02u:%02u:%02u by %s at %s", BUILD_DATE_Y, BUILD_DATE_M, BUILD_DATE_D, BUILD_DATE_HO, BUILD_DATE_MI, BUILD_DATE_SE, BUILDER_NAME, BUILD_PLACE); c->BuildInfo = CopyStr(tmp); return c; }
Term ProcImPrt(Term t, Term ind) { int spin, col, anti; Atom n, an; Term prt; Atom pcomm=0, ptname=0; if(!is_compound(t) || CompoundArity(t)<3 || CompoundArity(t)>5 || !is_integer(CompoundArg1(t)) || !is_integer(CompoundArg2(t)) || !is_integer(CompoundArgN(t,3)) || (CompoundArity(t)>3 && !is_atom(CompoundArgN(t,4))) || (CompoundArity(t)>4 && !is_atom(CompoundArgN(t,5))) ) { ErrorInfo(502); printf("AuxPrt: bad arguments ");WriteTerm(t);puts(""); return 0; } spin=IntegerValue(CompoundArg1(t)); col= IntegerValue(CompoundArg2(t)); anti=IntegerValue(CompoundArgN(t,3)); if(CompoundArity(t)>3) pcomm=CompoundArgN(t,4); if(CompoundArity(t)>4) ptname=CompoundArgN(t,5); FreeAtomic(t); n=NewName(); if(anti) an=NewName(); else an=n; if(1) { prt=MakeCompound(OPR_PARTICLE,8); SetCompoundArg(prt,1,n); SetCompoundArg(prt,2,an); SetCompoundArg(prt,3,pcomm?pcomm:NewAtom("im particle",0)); SetCompoundArg(prt,4,NewInteger(spin?2:0)); SetCompoundArg(prt,5,spin==2?0:NewAtom("Maux",0)); if(spin<2) SetCompoundArg(prt,7,OPR_MLT); else SetCompoundArg(prt,7,A_GAUGE); if(col>1) { Term cl; if(col==8) cl=MakeCompound2(A_COLOR,NewAtom("c8",0),NewAtom("c8",0)); else cl=MakeCompound2(A_COLOR,NewAtom("c3",0),NewAtom("c3b",0)); SetCompoundArg(prt,8,AppendFirst(NewList(),cl)); } AddIMParticle(prt); if(ptname) { char bbb[64]; SetAtomProperty(n,A_TEXNAME,ptname); sprintf(bbb,"{\\bar{%s}}",AtomValue(ptname)); SetAtomProperty(an,A_TEXNAME,NewAtom(bbb,0)); } } if(spin<2) { if(!intr_param) { Term t1,t2,t3; t1=NewCompound(NewFunctor(OPR_PARAMETER,1)); t2=NewCompound(NewFunctor(OPR_EQSIGN,2)); t3=NewCompound(NewFunctor(OPR_COLON,2)); SetCompoundArg(t1,1,t2); SetCompoundArg(t2,1,NewAtom("Maux",0)); SetCompoundArg(t2,2,t3); SetCompoundArg(t3,1,NewInteger(1)); SetCompoundArg(t3,2,NewAtom("mass of aux particles",0)); ProcessParameter(t1,0); intr_param=1; } return n; } sprintf(nnbuf,"%s.t",AtomValue(n)); n=NewAtom(nnbuf,0); return n; }
// Management port Listen thread void NiListenThread(THREAD *thread, void *param) { NAT *n = (NAT *)param; SOCK *a; UINT i; bool b = false; // Validate arguments if (thread == NULL || param == NULL) { return; } // Initialize the management list n->AdminList = NewList(NULL); while (true) { a = Listen(DEFAULT_NAT_ADMIN_PORT); if (b == false) { b = true; NoticeThreadInit(thread); } if (a != NULL) { break; } Wait(n->HaltEvent, NAT_ADMIN_PORT_LISTEN_INTERVAL); if (n->Halt) { return; } } n->AdminListenSock = a; AddRef(a->ref); // Waiting while (true) { SOCK *s = Accept(a); THREAD *t; NAT_ADMIN *admin; if (s == NULL) { break; } if (n->Halt) { ReleaseSock(s); break; } admin = ZeroMalloc(sizeof(NAT_ADMIN)); admin->Nat = n; admin->Sock = s; t = NewThread(NiAdminThread, admin); WaitThreadInit(t); ReleaseThread(t); } // Disconnect all management connections LockList(n->AdminList); { for (i = 0;i < LIST_NUM(n->AdminList);i++) { NAT_ADMIN *a = LIST_DATA(n->AdminList, i); Disconnect(a->Sock); WaitThread(a->Thread, INFINITE); ReleaseThread(a->Thread); ReleaseSock(a->Sock); Free(a); } } UnlockList(n->AdminList); ReleaseList(n->AdminList); ReleaseSock(a); }
// Sort selected entries to the top of the list void buffer_sort_selected(DirBuffer *buffer) { struct MinList temp; DirEntry *entry,*first_file=0,*first_pos=0; // Lock buffer buffer_lock(buffer,TRUE); // Initialise temporary list NewList((struct List *)&temp); // Go through entries for (entry=(DirEntry *)buffer->entry_list.mlh_Head; entry->de_Node.dn_Succ;) { DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ; // File? if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_FILE) { // Remove and add to temporary if selected if (entry->de_Flags&ENTF_SELECTED) { // Remember first position if (!first_pos) first_pos=(DirEntry *)entry->de_Node.dn_Pred; // Remove and re-add Remove((struct Node *)entry); AddTail((struct List *)&temp,(struct Node *)entry); } // Remember if the first file else if (!first_file) first_file=entry; } // Get next entry=next; } // Something in the temporary list? if (!(IsListEmpty((struct List *)&temp))) { // If we have a first file, get its predecessor if (first_file) first_pos=(DirEntry *)first_file->de_Node.dn_Pred; // Go through temporary list, add after first position for (entry=(DirEntry *)temp.mlh_Head; entry->de_Node.dn_Succ;) { DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ; // Remove and add after last one Remove((struct Node *)entry); Insert((struct List *)&buffer->entry_list,(struct Node *)entry,(struct Node *)first_pos); // Bump next position first_pos=(DirEntry *)entry; // Get next entry=next; } } // Unlock buffer buffer_unlock(buffer); }
List mk_im_field(int col, int spin, int ch, List hint) { Atom n, an, spp; int checked_hint=0; Term prt; n=0; check_hint(col, spin, ch, hint, &n, &an); if(n) checked_hint=1; if(n==0) { n=NewName(); if(ch) an=NewName(); else an=n; } sprintf(nnbuf,"%s%s%s%s",AtomValue(CompoundArg1(ListFirst(hint))), AtomValue(CompoundArg1(ListNth(hint,2))), AtomValue(CompoundArg1(ListNth(hint,3))), AtomValue(CompoundArg1(ListNth(hint,4)))); spp=NewAtom(nnbuf,0); used_fields=AppendLast(used_fields, MakeCompound2(OPR_MINUS, spp, MakeCompound2(OPR_DIV, n, an))); if(verb_imprt) { printf("Intermediate field %s/%s for vertex ",AtomValue(n), AtomValue(an)); WriteVertex(hint); printf(".\n"); } if(!checked_hint || spin<2) { char bbb[64]; prt=MakeCompound(OPR_PARTICLE,8); SetCompoundArg(prt,1,n); SetCompoundArg(prt,2,an); sprintf(bbb,"%s",AtomValue(spp)); SetCompoundArg(prt,3,NewAtom(bbb,0)); SetCompoundArg(prt,4,NewInteger(spin?2:0)); SetCompoundArg(prt,5,spin==2?0:NewAtom("Maux",0)); if(spin<2) SetCompoundArg(prt,7,OPR_MLT); else SetCompoundArg(prt,7,A_GAUGE); if(col) { Term cl; if(col==3) cl=MakeCompound2(A_COLOR,NewAtom("c8",0),NewAtom("c8",0)); else cl=MakeCompound2(A_COLOR,NewAtom("c3",0),NewAtom("c3b",0)); SetCompoundArg(prt,8,AppendFirst(NewList(),cl)); } AddIMParticle(prt); } if(spin<2) { if(!intr_param) { Term t1,t2,t3; t1=NewCompound(NewFunctor(OPR_PARAMETER,1)); t2=NewCompound(NewFunctor(OPR_EQSIGN,2)); t3=NewCompound(NewFunctor(OPR_COLON,2)); SetCompoundArg(t1,1,t2); SetCompoundArg(t2,1,NewAtom("Maux",0)); SetCompoundArg(t2,2,t3); SetCompoundArg(t3,1,NewInteger(1)); SetCompoundArg(t3,2,NewAtom("mass of im particles",0)); ProcessParameter(t1,0); intr_param=1; } return MakeList2(an,n); } sprintf(nnbuf,"%s.t",AtomValue(n)); n=NewAtom(nnbuf,0); sprintf(nnbuf,"%s.t",AtomValue(an)); an=NewAtom(nnbuf,0); return MakeList2(an,n); }
// Change the reverse or separation state of a buffer (must be already sorted) void buffer_sort_reversesep(DirBuffer *buffer,BOOL do_reverse) { ListFormat *format; struct MinList temp; DirEntry *entry; // Get sort format format=&buffer->buf_ListFormat; // Copy list pointers temp=buffer->entry_list; temp.mlh_TailPred->mln_Succ=(struct MinNode *)&temp.mlh_Tail; temp.mlh_Head->mln_Pred=(struct MinNode *)&temp.mlh_Head; // Clear buffer entry pointers NewList((struct List *)&buffer->entry_list); buffer->first_file=0; buffer->first_dir=0; // Sort directories and files separately? if (format->sort.separation==SEPARATE_DIRSFIRST || format->sort.separation==SEPARATE_FILESFIRST) { struct MinList file_list,dir_list; // Initialise temporary lists NewList((struct List *)&file_list); NewList((struct List *)&dir_list); // Go through entries for (entry=(DirEntry *)temp.mlh_Head; entry->de_Node.dn_Succ;) { DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ; // File? if (ENTRYTYPE(entry->de_Node.dn_Type)==ENTRY_FILE) { // Add to file list if (do_reverse) AddHead((struct List *)&file_list,(struct Node *)entry); else AddTail((struct List *)&file_list,(struct Node *)entry); } // Directory else if (do_reverse) AddHead((struct List *)&dir_list,(struct Node *)entry); else AddTail((struct List *)&dir_list,(struct Node *)entry); // Get next entry=next; } // Get first file and directory pointers if (!(IsListEmpty((struct List *)&file_list))) buffer->first_file=(DirEntry *)file_list.mlh_Head; if (!(IsListEmpty((struct List *)&dir_list))) buffer->first_dir=(DirEntry *)dir_list.mlh_Head; // Directories first (or no files) if ((format->sort.separation==SEPARATE_DIRSFIRST && !(IsListEmpty((struct List *)&dir_list))) || IsListEmpty((struct List *)&file_list)) { // Patch directory list in buffer->entry_list.mlh_Head=dir_list.mlh_Head; dir_list.mlh_Head->mln_Pred=(struct MinNode *)&buffer->entry_list.mlh_Head; // Anything in file list? if (!(IsListEmpty((struct List *)&file_list))) { // Patch file list in; link the two lists together dir_list.mlh_TailPred->mln_Succ=file_list.mlh_Head; file_list.mlh_Head->mln_Pred=dir_list.mlh_TailPred; // Set tail pointer buffer->entry_list.mlh_TailPred=file_list.mlh_TailPred; } // Otherwise, set tail else buffer->entry_list.mlh_TailPred=dir_list.mlh_TailPred; } // Files first, or no directories else if (!(IsListEmpty((struct List *)&file_list))) { // Patch file list in buffer->entry_list.mlh_Head=file_list.mlh_Head; file_list.mlh_Head->mln_Pred=(struct MinNode *)&buffer->entry_list.mlh_Head; // Anything in directory list? if (!(IsListEmpty((struct List *)&dir_list))) { // Patch dir list in; link the two lists together file_list.mlh_TailPred->mln_Succ=dir_list.mlh_Head; dir_list.mlh_Head->mln_Pred=file_list.mlh_TailPred; // Set tail pointer buffer->entry_list.mlh_TailPred=dir_list.mlh_TailPred; } // Otherwise, set tail else buffer->entry_list.mlh_TailPred=file_list.mlh_TailPred; } // Fix tail pointer buffer->entry_list.mlh_TailPred->mln_Succ=(struct MinNode *)&buffer->entry_list.mlh_Tail; } // Mix files and directories else { // Go through entries for (entry=(DirEntry *)temp.mlh_Head; entry->de_Node.dn_Succ;) { DirEntry *next=(DirEntry *)entry->de_Node.dn_Succ; // Add to main list if (do_reverse) AddHead((struct List *)&buffer->entry_list,(struct Node *)entry); else AddTail((struct List *)&buffer->entry_list,(struct Node *)entry); // Get next entry=next; } } }
int main(int argc, char **argv) { local_exceptions_init(); // example is too fast/boring with caches on, so don't //mmu_simple_init(); video_init(1280, 1024); rp = graphics_init(FBADDR, WIDTH, HEIGHT, BM_RGB16); omap_attach_framebuffer(0, rp->drawable.bitmap); // also set it to the tv out (top-left corner of same data) omap_attach_framebuffer(VID_VID2 | VID_TVOUT, rp->drawable.bitmap); moveTo(rp, 0, 0); setColour(rp, 0x3e31a2); drawRect(rp, WIDTH, HEIGHT); // setup tasks to run int i; NewList(&tasks); dprintf("tasks %08x, Head=%08x Tail=%08x TailPred=%08x\n", &tasks, tasks.Head, tasks.Tail, tasks.TailPred); for (i=0;taskinit[i];i++ ){ struct task *t = taskinit[i]; // set initial pc and proc state t->tcb.pc = (uint32_t)task; // runs in user mode t->tcb.spsr = 0x10; // initial argument 0 in reg 0 t->tcb.regs[0] = i; t->id = i; int j; for (j=1;j<10;j++) t->tcb.regs[j] = j; // initial stack - 4K each, before 32K of master stack t->tcb.regs[13] = 0x88000000 - 32768 - i*4096; AddTail((struct List *)&tasks, &t->Node); dprintf("adding task %d = %08x pc=%08x sp=%08x\n", i, t, t->tcb.pc, t->tcb.regs[13]); } dprintf("tasks %08x, Head=%08x Tail=%08x TailPred=%08x\n", &tasks, tasks.Head, tasks.Tail, tasks.TailPred); // set task 0 to `execute first' (it's actually us) thistask = &t1; irq_new_task(tcb_to_sp(&thistask->tcb)); // // Setup timer interrupt via GPTIMER1 // // timer off reg32s(GPTIMER1_BASE, GPT_TCLR, 1, 0); // Sets true 1Khz rate w/ 32768Hz clock: S 16.2.4.3 TRM D reg32w(GPTIMER1_BASE, GPT_TPIR, 232000); reg32w(GPTIMER1_BASE, GPT_TNIR, -768000); reg32w(GPTIMER1_BASE, GPT_TLDR, 0xffffffe0); reg32w(GPTIMER1_BASE, GPT_TCRR, 0xffffffe0); // clear int status bits reg32w(GPTIMER1_BASE, GPT_TISR, ~0); // enable overflow int reg32w(GPTIMER1_BASE, GPT_TIER, OVF_IT_FLAG); // dividisor = 100 -> 10Hz so it's visible reg32w(GPTIMER1_BASE, GPT_TOCR, 0); reg32w(GPTIMER1_BASE, GPT_TOWR, 100); irq_set_handler(INTC_GPT1_IRQ, gptimer1_handler); irq_set_mask(INTC_GPT1_IRQ, 1); // force 32K clock reg32s(0x48004c00, 0x40, 1, 0); // turn timer back on reg32s(GPTIMER1_BASE, GPT_TCLR, 1|2|(2<<10), ~0); dprintf("enabling interrupts\n"); // data barrier for previous register writes asm volatile("dsb"); // turn on irq's, which enables task switching irq_enable(); // jump to user mode - we are now 'task 0' asm volatile("cps #0x10"); asm volatile("ldr sp,=0x88000000 - 32768"); task(0); return 0; }
void DoChangeDir(char *dir) { char *p; char ndir[PATH_MAX]; if (browse_up) { strcpy(ndir, cur_browse_dir); } else if (file_up) { strcpy(ndir, cur_file_dir); } else if (export_up) { strcpy(ndir, cur_export_dir); } if (dir != NULL && dir[0] != '/') { /* relative path, prepend current dir */ if (dir[strlen(dir) - 1] == '/') dir[strlen(dir) - 1] = '\0'; if (strcmp(dir, "..")==0) { /* Parent directory. */ if (*ndir == '\0') return; /* no current directory, */ /* can't do anything unless absolute path */ p = strrchr(ndir, '/'); *p = EOS; if (ndir[0] == EOS) strcpy(ndir, "/"); } else if (strcmp(dir, ".")!=0) { if (strcmp(ndir, "/")) /* At the root already */ strcat(ndir, "/"); strcat(ndir, dir); } } else { strcpy(ndir, dir); /* abs path copy to ndir */ } if (change_directory(ndir) != 0 ) { return; /* some problem, return */ } else if (MakeFileList(ndir, dirmask, &dirlist, &filelist) == False) { file_msg("Unable to list directory %s", ndir); return; } FirstArg(XtNstring, ndir); /* update the current directory and file/dir list widgets */ if (browse_up) { SetValues(browse_dir); strcpy(cur_browse_dir,ndir); /* update global var */ XawTextSetInsertionPoint(browse_dir, strlen(ndir)); NewList(browse_flist, filelist); NewList(browse_dlist, dirlist); } else if (file_up) { SetValues(file_dir); strcpy(cur_file_dir,ndir); /* update global var */ strcpy(cur_export_dir,ndir); /* set export directory to file directory */ XawTextSetInsertionPoint(file_dir, strlen(ndir)); NewList(file_flist,filelist); NewList(file_dlist,dirlist); } else if (export_up) { SetValues(exp_dir); strcpy(cur_export_dir,ndir); /* update global var */ XawTextSetInsertionPoint(exp_dir, strlen(ndir)); NewList(exp_flist, filelist); NewList(exp_dlist, dirlist); } CurrentSelectionName[0] = '\0'; }
int main(int argc, char **argv) { local_exceptions_init(); // example is too fast/boring with caches on, so don't //mmu_simple_init(); video_init(1280, 1024); rp = graphics_init(FBADDR, WIDTH, HEIGHT, BM_RGB16); omap_attach_framebuffer(0, rp->drawable.bitmap); // also set it to the tv out (top-left corner of same data) omap_attach_framebuffer(VID_VID2 | VID_TVOUT, rp->drawable.bitmap); moveTo(rp, 0, 0); setColour(rp, 0x3e31a2); drawRect(rp, WIDTH, HEIGHT); // setup tasks to run int i; NewList(&tasks); dprintf("tasks %08x, Head=%08x Tail=%08x TailPred=%08x\n", &tasks, tasks.Head, tasks.Tail, tasks.TailPred); for (i=0;taskinit[i];i++ ){ struct task *t = taskinit[i]; // set initial pc and proc state t->tcb.pc = taskpc[i]; // runs in user mode t->tcb.spsr = 0x10; // initial argument 0 in reg 0 t->tcb.regs[0] = i; t->id = i; int j; for (j=1;j<10;j++) t->tcb.regs[j] = j; // initial stack - 4K each, before 32K of master stack t->tcb.regs[13] = 0x88000000 - 32768 - i*4096; AddTail((struct List *)&tasks, &t->Node); dprintf("adding task %d = %08x pc=%08x sp=%08x\n", i, t, t->tcb.pc, t->tcb.regs[13]); } dprintf("tasks %08x, Head=%08x Tail=%08x TailPred=%08x\n", &tasks, tasks.Head, tasks.Tail, tasks.TailPred); // set task 0 to `execute first' (it's actually us) thistask = &t1; fptask = 0; irq_new_task(tcb_to_sp(&thistask->tcb)); // add an irq handler for the vsync interrupt (lcd display?) irq_set_handler(INTC_DSS_IRQ, dispc_handler); irq_set_mask(INTC_DSS_IRQ, 1); // disable all but vsync reg32w(DISPC_BASE, DISPC_IRQENABLE, DISPC_VSYNC); reg32w(DISPC_BASE, DISPC_IRQSTATUS, ~0); // dss intterrupt can also receive DSI, so disable those too reg32w(DSI_BASE, DSI_IRQENABLE, 0); reg32w(DSI_BASE, DSI_IRQSTATUS, ~0); dprintf("enabling interrupts\n"); // data barrier for previous register writes asm volatile("dsb"); // turn on irq's, which enables task switching irq_enable(); // jump to user mode - we are now 'task 0' asm volatile("cps #0x10"); asm volatile("ldr sp,=0x88000000 - 32768"); task1(0); return 0; }
///ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground() IPTR ImageBackFill__MUIM_IconWindow_BackFill_ProcessBackground ( Class *CLASS, Object *self, struct MUIP_IconWindow_BackFill_ProcessBackground *message ) { LONG Depth = 0; Object *_IconWindows_PrefsObj = NULL, *_IconWindows_WindowObj = NULL; Object *_IconWindows_IconListObj = NULL; BOOL options_changed = FALSE; IPTR prefs_processing = 0; IPTR BackGround_Attrib = 0, BackGround_Base = 0, BackGround_RenderMode = 0, BackGround_TileMode = 0, BackGround_XOffset = 0, BackGround_YOffset = 0; struct BackFillInfo *this_BFI =(struct BackFillInfo *) message->BackFill_Data; UBYTE *this_bgtype; char *this_ImageName; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground()\n")); GET(_app(self), MUIA_Wanderer_Prefs, &_IconWindows_PrefsObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: PrefsObj @ %x\n", _IconWindows_PrefsObj)); GET(self, MUIA_IconWindow_Window, &_IconWindows_WindowObj); GET(self, MUIA_IconWindow_IconList, &_IconWindows_IconListObj); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: MUIA_IconWindow_Window = %x\n", _IconWindows_WindowObj)); if ((_IconWindows_PrefsObj == NULL) || (_IconWindows_WindowObj == NULL) || (_IconWindows_IconListObj == NULL)) return FALSE; GET(_IconWindows_PrefsObj, MUIA_WandererPrefs_Processing, &prefs_processing); #if defined(DEBUG) if (prefs_processing) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderer Prefs (re)loading detected\n")); } #endif GET(_IconWindows_WindowObj, MUIA_IconWindow_BackgroundAttrib, &BackGround_Attrib); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background Attrib = '%s'\n", BackGround_Attrib)); if (BackGround_Attrib == (IPTR) NULL) return FALSE; if ((BackGround_Base = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_Background)) == -1) return FALSE; if ((BackGround_RenderMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGRenderMode)) == -1) BackGround_RenderMode = IconWindowExt_ImageBackFill_RenderMode_Tiled; this_bgtype = (UBYTE *)BackGround_Base; this_ImageName = (char *)(BackGround_Base + 2); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo @ %x\n", this_BFI)); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background '%s', mode %d\n", BackGround_Base, BackGround_RenderMode)); if ((this_bgtype[0] - 48) != 5) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Background is NOT an image - letting our windoclass handle it ..\n")); goto pb_cleanup_buffer; } GET(self, MUIA_Window_Screen, &this_BFI->bfi_Screen); GET(_IconWindows_IconListObj, MUIA_IconList_BufferRastport, &this_BFI->bfi_RastPort); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Wanderers Screen @ %x, Using RastPort @ %x\n", this_BFI->bfi_Screen, this_BFI->bfi_RastPort)); if (this_BFI->bfi_Source) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: BackFillInfo has existing source record @ %x\n", this_BFI->bfi_Source)); if ((strcmp(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName) == 0) && (this_BFI->bfi_Source->bfsir_BackGroundRenderMode == BackGround_RenderMode)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: existing BackFillInfo Using the same background / mode\n")); goto check_imagebuffer; } else { if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } } if (!(this_BFI->bfi_Source)) this_BFI->bfi_Source = ImageBackFill_FindSourceRecord(this_ImageName, BackGround_RenderMode); if (!(this_BFI->bfi_Source)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Creating NEW ImageSource Record\n")); if (!(this_BFI->bfi_Source = AllocMem(sizeof(struct BackFillSourceImageRecord), MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source record!\n")); return FALSE; } if (!(this_BFI->bfi_Source->bfsir_SourceImage = AllocVec(strlen(this_ImageName) +1, MEMF_CLEAR|MEMF_PUBLIC))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Couldnt allocate enough mem for source image name store\n")); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); return FALSE; } strcpy(this_BFI->bfi_Source->bfsir_SourceImage, this_ImageName); if ((this_BFI->bfi_Source->bfsir_DTPictureObject = NewDTObject(this_BFI->bfi_Source->bfsir_SourceImage, DTA_SourceType, DTST_FILE, DTA_GroupID, GID_PICTURE, PDTA_DestMode, PMODE_V43, PDTA_Remap, TRUE, PDTA_Screen, this_BFI->bfi_Screen, PDTA_FreeSourceBitMap, TRUE, OBP_Precision, PRECISION_IMAGE, TAG_DONE))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Opened Datatype Object @ %x for image '%s'\n", this_BFI->bfi_Source->bfsir_DTPictureObject, this_BFI->bfi_Source->bfsir_SourceImage)); if (DoMethod(this_BFI->bfi_Source->bfsir_DTPictureObject, DTM_PROCLAYOUT, NULL, 1)) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Caused Datatype Object LAYOUT\n")); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMapHeader, &this_BFI->bfi_Source->bfsir_DTBitMapHeader, TAG_DONE); GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_DestBitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (!this_BFI->bfi_Source->bfsir_DTBitMap) GetDTAttrs(this_BFI->bfi_Source->bfsir_DTPictureObject, PDTA_BitMap, &this_BFI->bfi_Source->bfsir_DTBitMap, TAG_DONE); if (this_BFI->bfi_Source->bfsir_DTBitMap) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Datatype Object BitMap @ %x\n", this_BFI->bfi_Source->bfsir_DTBitMap)); if ((this_BFI->bfi_Source->bfsir_DTRastPort = CreateRastPort())) { this_BFI->bfi_Source->bfsir_DTRastPort->BitMap = this_BFI->bfi_Source->bfsir_DTBitMap; this_BFI->bfi_Source->bfsir_BackGroundRenderMode = BackGround_RenderMode; this_BFI->bfi_Source->bfsir_OpenerCount = 0x01; NewList(&this_BFI->bfi_Source->bfsir_Buffers); AddTail(&image_backfill_images, &this_BFI->bfi_Source->bfsir_Node); goto check_imagebuffer; } } /* Failed to obtain datatype object's BM */ } /* Failed to Layout datatype object */ } /* Failed to open datatype object */ #if defined(DEBUG) if (!this_BFI->bfi_Source->bfsir_DTRastPort) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource RastPort\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTBitMap) { FreeBitMap(this_BFI->bfi_Source->bfsir_DTBitMap); this_BFI->bfi_Source->bfsir_DTBitMap = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource BitMap\n")); } #endif if (this_BFI->bfi_Source->bfsir_DTPictureObject) { DisposeDTObject(this_BFI->bfi_Source->bfsir_DTPictureObject); this_BFI->bfi_Source->bfsir_DTPictureObject = NULL; } #if defined(DEBUG) else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Datatype Object\n")); } #endif D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create ImageSource Record\n")); if (this_BFI->bfi_Source->bfsir_SourceImage) FreeVec(this_BFI->bfi_Source->bfsir_SourceImage); FreeMem(this_BFI->bfi_Source, sizeof(struct BackFillSourceImageRecord)); this_BFI->bfi_Source = NULL; return FALSE; } else { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Using existing ImageSource Record\n")); this_BFI->bfi_Source->bfsir_OpenerCount += 1; } check_imagebuffer: Depth = GetBitMapAttr(this_BFI->bfi_Source->bfsir_DTBitMap, BMA_DEPTH); this_BFI->bfi_CopyWidth = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width; this_BFI->bfi_CopyHeight = this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height; switch (BackGround_RenderMode) { case IconWindowExt_ImageBackFill_RenderMode_Scale: { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED mode\n")); this_BFI->bfi_Options.bfo_TileMode = IconWindowExt_ImageBackFill_TileMode_Fixed; SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, TRUE); if ((BOOL)XGET(self, MUIA_IconWindow_IsRoot)) { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Root Window = TRUE!\n")); this_BFI->bfi_CopyWidth = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_WIDTH); this_BFI->bfi_CopyHeight = GetBitMapAttr(this_BFI->bfi_Screen->RastPort.BitMap, BMA_HEIGHT); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Base Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!((BOOL)XGET(self, MUIA_IconWindow_IsBackdrop))) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Adjusting for window border Dimensions ..\n")); D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - WBorTop %d, WBorLeft %d, WBorRight %d, WBorBottom %d\n", this_BFI->bfi_Screen->WBorTop, this_BFI->bfi_Screen->WBorLeft, this_BFI->bfi_Screen->WBorRight, this_BFI->bfi_Screen->WBorBottom)); this_BFI->bfi_CopyWidth -= (this_BFI->bfi_Screen->WBorLeft + this_BFI->bfi_Screen->WBorRight); this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->WBorTop + this_BFI->bfi_Screen->WBorBottom);; } this_BFI->bfi_CopyHeight -= (this_BFI->bfi_Screen->BarHeight + 1); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Failed to create RastPort for BackFill BitMap\n")); break; } if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Scale Dimensions (%d x %d)\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyScaledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } // We arent the "ROOT" (desktop) window so only tile ... D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: SCALED - Drawer window scaling unsupported ...\n")); } default: { struct BackFillSourceImageBuffer *this_Buffer; D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED mode\n")); if ((BackGround_TileMode = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGTileMode)) == -1) BackGround_TileMode = IconWindowExt_ImageBackFill_TileMode_Float; if ((BackGround_XOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGXOffset)) == -1) BackGround_XOffset = 0; if ((BackGround_YOffset = DoMethod(_IconWindows_PrefsObj, MUIM_WandererPrefs_ViewSettings_GetAttribute, BackGround_Attrib, MUIA_IconWindowExt_ImageBackFill_BGYOffset)) == -1) this_BFI->bfi_Options.bfo_OffsetY = 0; if (this_BFI->bfi_Options.bfo_TileMode != BackGround_TileMode) { this_BFI->bfi_Options.bfo_TileMode = BackGround_TileMode; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetX != BackGround_XOffset) { this_BFI->bfi_Options.bfo_OffsetX = BackGround_XOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_OffsetY != BackGround_YOffset) { this_BFI->bfi_Options.bfo_OffsetY = BackGround_YOffset; options_changed = TRUE; } if (this_BFI->bfi_Options.bfo_TileMode == IconWindowExt_ImageBackFill_TileMode_Float) SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, FALSE); else SET(_IconWindows_IconListObj, MUIA_IconListview_FixedBackground, TRUE); SET(_IconWindows_IconListObj, MUIA_IconListview_ScaledBackground, FALSE); this_Buffer = NULL; if (this_BFI->bfi_Buffer) { if ((this_BFI->bfi_Buffer->bfsib_BitMapWidth == this_BFI->bfi_CopyWidth) && (this_BFI->bfi_Buffer->bfsib_BitMapHeight == this_BFI->bfi_CopyHeight)) { goto pb_backfillsetup_complete; } else { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Dimensions Width %d, Height %d\n", this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight)); if (!(this_Buffer = ImageBackFill_FindBufferRecord(this_BFI->bfi_Source, this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight))) { this_Buffer = AllocMem(sizeof(struct BackFillSourceImageBuffer), MEMF_CLEAR|MEMF_PUBLIC); this_Buffer->bfsib_BitMapWidth = this_BFI->bfi_CopyWidth; this_Buffer->bfsib_BitMapHeight = this_BFI->bfi_CopyHeight; if ((this_Buffer->bfsib_BitMap = AllocBitMap(this_BFI->bfi_CopyWidth, this_BFI->bfi_CopyHeight, Depth, Depth == 8 ? BMF_MINPLANES : 0L, this_BFI->bfi_Screen->RastPort.BitMap))) { struct Rectangle CopyBounds; if (!(this_Buffer->bfsib_BitMapRastPort = CreateRastPort())) { D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: TILED - Failed to create RastPort for BackFill BitMap\n")); break; } this_Buffer->bfsib_BitMapRastPort->BitMap = this_Buffer->bfsib_BitMap; this_BFI->bfi_Buffer = this_Buffer; CopyBounds.MinX = 0; CopyBounds.MinY = 0; CopyBounds.MaxX = this_BFI->bfi_CopyWidth - 1; CopyBounds.MaxY = this_BFI->bfi_CopyHeight - 1; ImageBackFill_CopyTiledBitMap(this_BFI->bfi_Source->bfsir_DTRastPort, 0, 0, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Width, this_BFI->bfi_Source->bfsir_DTBitMapHeader->bmh_Height, this_BFI->bfi_Buffer->bfsib_BitMapRastPort, &CopyBounds, &CopyBounds, blit_MODE_Blit); this_Buffer->bfsib_OpenerCount = 0x01; AddTail(&this_BFI->bfi_Source->bfsir_Buffers, &this_BFI->bfi_Buffer->bfsib_Node); goto pb_backfillsetup_complete; } break; } else { this_BFI->bfi_Buffer = this_Buffer; this_Buffer->bfsib_OpenerCount += 1; goto pb_backfillsetup_complete; } } } D(bug("[IconWindow.ImageBackFill] MUIM_IconWindow_BackFill_ProcessBackground: Failed to create image datatype object\n")); return FALSE; pb_cleanup_buffer: if (this_BFI->bfi_Buffer) { ImageBackFill_CloseSourceBuffer(this_BFI->bfi_Source, this_BFI->bfi_Buffer); this_BFI->bfi_Buffer = NULL; } pb_cleanup_source: if (this_BFI->bfi_Source) { ImageBackFill_CloseSourceRecord(this_BFI->bfi_Source); this_BFI->bfi_Source = NULL; } return FALSE; pb_backfillsetup_complete: if ((prefs_processing) && (options_changed)) SET(self, MUIA_IconWindow_Changed, TRUE); return TRUE; }
void main(int argc, char **argv) { int going=TRUE,forsok=2,car=1; long tid; char tellstr[100],*tmppscreen, titel[80]; UBYTE tillftkn; NewList((struct List *)&aliaslist); NewList((struct List *)&edit_list); if(!(IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0))) cleanup(ERROR,"Kunde inte öppna intuition.library\n"); if(!(UtilityBase=OpenLibrary("utility.library",37L))) cleanup(ERROR,"Kunde inte öppna utility.library\n"); if(!(NiKomBase=OpenLibrary("nikom.library",0L))) cleanup(ERROR,"Kunde inte öppna nikom.linbrary"); getnodeconfig("NiKom:Datocfg/ConNode.cfg"); if(!(initnode(NODCON))) cleanup(ERROR,"Kunde inte registrera noden i Servern\n"); if(!(nikomnodeport = CreateMsgPort())) cleanup(ERROR,"Kunde inte skapa NiKomNode-porten"); sprintf(nikomnodeportnamn,"NiKomNode%d",nodnr); nikomnodeport->mp_Node.ln_Name = nikomnodeportnamn; nikomnodeport->mp_Node.ln_Pri = 1; AddPort(nikomnodeport); sprintf(rexxportnamn,"NiKomRexx%d",nodnr); if(!(rexxport=(struct MsgPort *)CreateMsgPort())) cleanup(ERROR,"Kunde inte öppna RexxPort\n"); rexxport->mp_Node.ln_Name=rexxportnamn; rexxport->mp_Node.ln_Pri=50; AddPort(rexxport); if(!(RexxSysBase=(struct RsxLib *)OpenLibrary("rexxsyslib.library",0L))) cleanup(ERROR,"Kunde inte öppna rexxsyslib.library\n"); if(pubscreen[0]=='-') tmppscreen=NULL; else tmppscreen=pubscreen; if(!(NiKwind=(struct Window *)OpenWindowTags(NULL,WA_Left,xpos, WA_Top,ypos, WA_Width,xsize, WA_Height,ysize, WA_IDCMP,IDCMP_CLOSEWINDOW, WA_MinWidth,50, WA_MinHeight,10, WA_MaxWidth,~0, WA_MaxHeight,~0, WA_SizeGadget,TRUE, WA_SizeBBottom, TRUE, WA_DragBar,TRUE, WA_DepthGadget,TRUE, WA_CloseGadget,TRUE, WA_SimpleRefresh,TRUE, WA_ScreenTitle,"NiKom © Tomas Kärki 1996-1998", WA_AutoAdjust,TRUE, WA_PubScreenName,tmppscreen, TAG_DONE))) cleanup(ERROR,"Kunde inte öppna fönstret\n"); if(!OpenIO(NiKwind)) cleanup(ERROR,"Kunde inte öppna IO\n"); if(!getkeyfile()) cleanup(ERROR,"Korrupt nyckelfil\n"); strcpy(Servermem->nodid[nodnr],nodid); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); Servermem->connectbps[nodnr] = -1; conreqtkn(); do { memset(commandhistory,0,1024); Servermem->inne[nodnr].rader=0; sendfile("NiKom:Texter/Inlogg.txt"); if(Servermem->cfg.ar.preinlogg) sendrexx(Servermem->cfg.ar.preinlogg); going=TRUE; while(going) { puttekn("\r\nNamn: ",-1); getstring(EKO,40,NULL); if(!stricmp(inmat,Servermem->cfg.ny)) { /* if(!reggadnamn[0] && ((struct ShortUser *)Servermem->user_list.mlh_TailPred)->nummer >= 4) puttekn("\n\n\rDenna demoversion av NiKom kan hantera maximalt 5 användare.\n\r",-1); else { Versionen är nu obegränsad 970930! */ if((car=nyanv())==2) goto panik; going=FALSE; /* } */ } else if((inloggad=parsenamn(inmat))>=0) { readuser(inloggad,&Servermem->inne[nodnr]); forsok=2; while(forsok) { puttekn("\r\nLösen: ",-1); if(Servermem->inne[nodnr].flaggor & STAREKOFLAG) getstring(STAREKO,15,NULL); else getstring(EJEKO,15,NULL); if(CheckPassword(inloggad, inmat)) { forsok=FALSE; going=FALSE; } else forsok--; } } else if(inloggad==-1) puttekn("\r\nHittar ej namnet\r\n",-1); } sprintf(titel,"Nod #%d CON: %s #%d",nodnr,Servermem->inne[nodnr].namn,inloggad); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); readuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); Servermem->inloggad[nodnr]=inloggad; Servermem->idletime[nodnr] = time(NULL); if(getft("NiKom:Texter/Bulletin.txt")>Servermem->inne[nodnr].senast_in) sendfile("NiKom:Texter/Bulletin.txt"); connection(); if(Servermem->cfg.logmask & LOG_UTLOGG) { sprintf(outbuffer,"%s loggar ut från nod %d",getusername(inloggad),nodnr); logevent(outbuffer); } if(Servermem->say[nodnr]) displaysay(); if(Servermem->cfg.ar.utlogg) sendrexx(Servermem->cfg.ar.utlogg); sendfile("NiKom:Texter/Utlogg.txt"); sprintf(titel,"Nod #%d CON: <Ingen inloggad>",nodnr); SetWindowTitles(NiKwind,titel,(UBYTE *)-1L); SaveProgramCategory(inloggad); Servermem->inloggad[nodnr]=-1; Servermem->action[nodnr]=0; Servermem->inne[nodnr].textpek=textpek; time(&tid); Servermem->inne[nodnr].senast_in=tid; Servermem->inne[nodnr].tot_tid+=(tid-logintime); Servermem->inne[nodnr].loggin++; Servermem->info.inloggningar++; Servermem->inne[nodnr].defarea=area2; writeuser(inloggad,&Servermem->inne[nodnr]); writeuserbitmap(inloggad,Servermem->bitmaps[nodnr],0,temppek); writesenaste(); freealiasmem(); sprintf(tellstr,"loggade just ut från nod %d",nodnr); tellallnodes(tellstr); panik: puttekn("\r\n\nEn inloggning till? (J/n)",-1); } while((tillftkn=gettekn())!='n' && tillftkn!='N'); cleanup(OK,""); }
List *Swig_name_namewarn_list() { if (!namewarn_list) namewarn_list = NewList(); return namewarn_list; }
// Convert keywords hashes to // a keyword list. BOOL KeywordEdit::Hash2List( LPKEYLIST pKeyList, LPPARSER pParser ) { BOOL bAdded = FALSE; // Initialize the list. NewList(( LPLIST )pKeyList ); // Iterate the hashes. for ( int i = 0; i < 256; i++ ) { LPKEYHASH pHash, pNext; for ( pHash = pParser->aKeywords[ i ]; pHash; pHash = pNext ) { // Save next pointer. pNext = pHash->lpNext; // See if this color has // already been added? LPKEYWORDS pKey; for ( pKey = pKeyList->lpFirst; pKey->lpNext; pKey = pKey->lpNext ) { // Are the colors the same as the // new keyword colors? if ( pKey->crColor == pHash->crColor && pKey->crBgColor == pHash->crBkColor ) { // Yes. Simply add the keyword string to the // array of this color. if ( AddKeyword2Node( pKey, pHash->pszKeyword ) == FALSE ) { // Error. FreeKeyList( pKeyList ); return FALSE; } // Added keyword. bAdded = TRUE; break; } } // Added keyword? if ( bAdded == FALSE ) { // Allocate a new keyword node. if (( pKey = ( LPKEYWORDS )::AllocPooled( pParserPool, sizeof( KEYWORDS ))) != NULL ) { // Create a keyword array. if (( pKey->lpaKeywords = ::ArrayCreate( 0, 500, sizeof( LPTSTR * ))) != NULL ) { // Setup the node colors. pKey->crColor = pHash->crColor; pKey->crBgColor = pHash->crBkColor; // Add to the list. AddTail(( LPLIST )pKeyList, ( LPNODE )pKey ); // Add the keyword. if ( AddKeyword2Node( pKey, pHash->pszKeyword ) == FALSE ) { // Error. FreeKeyList( pKeyList ); return FALSE; } } else { // Error. ::FreePooled( pParserPool, pKey ); FreeKeyList( pKeyList ); return FALSE; } } else { // Error. FreeKeyList( pKeyList ); return FALSE; } } // Clear added flag. bAdded = FALSE; } } // Sort the arrays. for ( LPKEYWORDS pKey = pKeyList->lpFirst; pKey->lpNext; pKey = pKey->lpNext ) ::ArraySort( pKey->lpaKeywords, ( COMPFUNC )CompareKeywords ); return TRUE; }
List *Swig_name_rename_list() { if (!rename_list) rename_list = NewList(); return rename_list; }
static IPTR mStorePrefs(struct IClass *cl, Object *obj, struct MUIP_Win_StorePrefs *msg) { struct data *data = INST_DATA(cl,obj); struct URL_Prefs up; ULONG i; set(_app(obj),MUIA_Application_Sleep,TRUE); /* Copy settings from gadgets into structure */ up.up_Version = PREFS_VERSION; NewList((struct List *)&up.up_BrowserList); NewList((struct List *)&up.up_MailerList); NewList((struct List *)&up.up_FTPList); /* Browsers */ for (i = 0; ; i++) { struct URL_BrowserNode *bn; DoMethod(data->browserList,MUIM_List_GetEntry,i,(IPTR)&bn); if (!bn) break; if(isFlagClear(bn->ubn_Flags, UNF_NEW)) AddTail((struct List *)&up.up_BrowserList,(struct Node *)bn); } /* Mailers */ for (i = 0; ; i++) { struct URL_MailerNode *mn; DoMethod(data->mailerList,MUIM_List_GetEntry,i,(IPTR)&mn); if (!mn) break; if(isFlagClear(mn->umn_Flags, UNF_NEW)) AddTail((struct List *)&up.up_MailerList,(struct Node *)mn); } /* FTPs */ for (i = 0; ; i++) { struct URL_FTPNode *fn; DoMethod(data->FTPList,MUIM_List_GetEntry,i,(IPTR)&fn); if (!fn) break; if(isFlagClear(fn->ufn_Flags, UNF_NEW)) AddTail((struct List *)&up.up_FTPList,(struct Node *)fn); } /* Miscellaneous */ if (xget(data->prepend,MUIA_Selected)) SET_FLAG(up.up_Flags, UPF_PREPENDHTTP); else CLEAR_FLAG(up.up_Flags, UPF_PREPENDHTTP); if (xget(data->mailto,MUIA_Selected)) SET_FLAG(up.up_Flags, UPF_DOMAILTO); else CLEAR_FLAG(up.up_Flags, UPF_DOMAILTO); if (xget(data->useFTP,MUIA_Selected)) SET_FLAG(up.up_Flags, UPF_DOFTP); else CLEAR_FLAG(up.up_Flags, UPF_DOFTP); up.up_DefShow = (ULONG)xget(data->show,MUIA_Selected); up.up_DefBringToFront = (ULONG)xget(data->toFront,MUIA_Selected); up.up_DefNewWindow = (ULONG)xget(data->newWin,MUIA_Selected); up.up_DefLaunch = (ULONG)xget(data->launch,MUIA_Selected); /* Save to disk */ if (!URL_SetPrefs(&up,URL_SetPrefs_Save,msg->How==MUIV_Win_StorePrefs_Save,TAG_DONE)) MUI_RequestA(_app(obj),obj,0,getString(MSG_ErrReqTitle),getString(MSG_ErrReqGadget),getString(MSG_Err_FailedSave),NULL); set(_app(obj),MUIA_Application_Sleep,FALSE); /* Quit */ if (msg->How!=MUIV_Win_StorePrefs_Apply) DoMethod(_app(obj),MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit); return TRUE; }
struct Window *lister_open_window(Lister *lister,struct Screen *screen) { struct Gadget *gadget,*lock_gad; struct IBox *dims; ULONG mode; // If lister is already open, return if (!lister || lister->window) return lister->window; // Is lister meant to be iconified? if (lister->flags&LISTERF_ICONIFIED) return 0; // Is lister iconified? if (lister->appicon) { // Update icon position lister_update_icon(lister); // Remove AppIcon RemoveAppIcon(lister->appicon); lister->appicon=0; // Free icon if (lister->appicon_icon) { FreeDiskObjectCopy(lister->appicon_icon); lister->appicon_icon=0; } } // If lister was zoomed, swap dimensions around if ((lister->dimensions.wd_Flags&(WDF_VALID|WDF_ZOOMED))==(WDF_VALID|WDF_ZOOMED)) { struct IBox temp; // Swap dimensions temp=lister->dimensions.wd_Zoomed; lister->dimensions.wd_Zoomed=lister->dimensions.wd_Normal; lister->dimensions.wd_Normal=temp; // Clear zoomed flag lister->dimensions.wd_Flags&=~WDF_ZOOMED; } // Get dimensions pointer dims=&lister->dimensions.wd_Normal; // Get screen font AskFont(&screen->RastPort,&lister->screen_font); // Calculate minimum size lister_calc_limits(lister,screen); // Check lister size against minimums if (dims->Width<lister->win_limits.Left) dims->Width=lister->win_limits.Left; if (dims->Height<lister->win_limits.Top) dims->Height=lister->win_limits.Top; // Initialise backfill pattern #if defined(__MORPHOS__) lister->pattern.hook.h_Entry = (HOOKFUNC)HookEntry; lister->pattern.hook.h_SubEntry=(ULONG (*)())PatternBackfill; #else lister->pattern.hook.h_Entry=(ULONG (*)())PatternBackfill; #endif lister->pattern.hook.h_Data=lister->backdrop_info; lister->pattern.pattern=&GUI->pattern[PATTERN_LISTER]; // Is pattern initially enabled? if (lister->flags&LISTERF_VIEW_ICONS) lister->pattern.disabled=FALSE; else lister->pattern.disabled=TRUE; // Get refresh mode if (environment->env->lister_options&LISTEROPTF_SIMPLE) mode=WA_SimpleRefresh; else mode=WA_SmartRefresh; // Initialise boopsi list NewList(&lister->backdrop_info->boopsi_list); // Create iconify gadget gadget= create_iconify_gadget( screen, &lister->backdrop_info->boopsi_list, (lister->flags&LISTERF_LOCK_POS)?TRUE:FALSE); // Create lock gadget if (!(GUI->flags2&GUIF2_NO_PADLOCK) && (lock_gad= CreateTitleGadget( screen, &lister->backdrop_info->boopsi_list, (lister->flags&LISTERF_LOCK_POS)?TRUE:FALSE, (gadget)?-gadget->Width+TBGADGETOFFSET:0, IM_LOCK, GAD_LOCK))) { // Chain gadgets if (gadget) gadget->NextGadget=lock_gad; else gadget=lock_gad; // Fix selection flags lock_gad->Activation|=GACT_TOGGLESELECT; if (lister->more_flags&LISTERF_LOCK_FORMAT) lock_gad->Flags|=GFLG_SELECTED; } // Open lister window if (!(lister->window=OpenWindowTags(0, WA_Left,dims->Left, WA_Top,dims->Top, WA_Width,dims->Width, WA_Height,dims->Height, WA_MinWidth,lister->win_limits.Left, WA_MinHeight,lister->win_limits.Top, WA_MaxWidth,(ULONG)~0, WA_MaxHeight,(ULONG)~0, (lister->dimensions.wd_Flags&WDF_VALID)?WA_Zoom:TAG_IGNORE,(ULONG)&lister->dimensions.wd_Zoomed, WA_IDCMP, IDCMP_ACTIVEWINDOW| IDCMP_CHANGEWINDOW| IDCMP_CLOSEWINDOW| IDCMP_GADGETDOWN| IDCMP_GADGETUP| IDCMP_INACTIVEWINDOW| IDCMP_MENUHELP| IDCMP_MENUPICK| IDCMP_MENUVERIFY| IDCMP_MOUSEBUTTONS| IDCMP_MOUSEMOVE| #ifdef __amigaos4__ IDCMP_EXTENDEDMOUSE| #endif IDCMP_NEWSIZE| IDCMP_REFRESHWINDOW| IDCMP_RAWKEY, WA_AutoAdjust,TRUE, WA_CloseGadget,!(lister->flags&LISTERF_LOCK_POS), WA_DragBar,!(lister->flags&LISTERF_LOCK_POS), WA_DepthGadget,TRUE, WA_MenuHelp,TRUE, WA_NewLookMenus,TRUE, WA_SizeGadget,TRUE, WA_SizeBRight,TRUE, WA_SizeBBottom,TRUE, WA_CustomScreen,screen, WA_ScreenTitle,GUI->screen_title, WA_WindowName, DOPUS_WIN_NAME, WA_Gadgets,gadget, mode,TRUE, (lister->flags&LISTERF_LOCK_POS)?WA_Title:TAG_IGNORE,"", WA_BackFill,&lister->pattern, TAG_END))) return 0; // Fix title gadgets FixTitleGadgets(lister->window); // Save left border lister->old_border_left=lister->window->BorderLeft; // Initialise ID SetWindowID(lister->window,&lister->id,WINDOW_LISTER,(struct MsgPort *)lister->ipc); // Initialise dimensions InitWindowDims(lister->window,&lister->dimensions); // Close existing font if (lister->font) CloseFont(lister->font); // Clear proportional font flag lister->more_flags&=~LISTERF_PROP_FONT; // Open font if ((lister->font=OpenDiskFont(&lister->lister_font))) { // Proportional font? if (lister->font->tf_Flags&FPF_PROPORTIONAL) { lister->more_flags|=LISTERF_PROP_FONT; } } // Got a font? if (lister->font) { // Set font in window and text area SetFont(lister->window->RPort,lister->font); SetFont(&lister->text_area.rast,lister->font); } // Otherwise, get info on default font else { // Get font info AskFont(lister->window->RPort,&lister->lister_font); } // Get DrawInfo lister->drawinfo=GetScreenDrawInfo(lister->window->WScreen); // Set menus display_get_menu(lister->window); display_fix_menu( lister->window, (lister->flags&LISTERF_VIEW_ICONS)?WINDOW_LISTER_ICONS:WINDOW_LISTER, lister); lister_fix_menus(lister,0); // Initialise backdrop info backdrop_init_info(lister->backdrop_info,lister->window,0); // Turn on gauge if needed lister_set_gauge(lister,FALSE); // Fill out size covering gadget if ((gadget=FindGadgetType(lister->window->FirstGadget,GTYP_SIZING))) { // Copy size gadget fill_out_cover_gadget(gadget,&lister->size_cover_gadget); // Clear image in original gadget if lister is locked if (lister->flags&LISTERF_LOCK_POS) { gadget->Flags&=~GFLG_GADGIMAGE; gadget->GadgetRender=0; } } // Fill out zoom covering gadget if ((gadget=FindGadgetType(lister->window->FirstGadget,GTYP_WZOOM))) { // Copy zoom gadget fill_out_cover_gadget(gadget,&lister->zoom_cover_gadget); // Clear image in original gadget if lister is locked if (lister->flags&LISTERF_LOCK_POS) { // Clear image in original gadget gadget->Flags&=~GFLG_GADGIMAGE; gadget->GadgetRender=0; } // Otherwise, change gadget type else { // Clear zoom flag, set ID gadget->GadgetType&=~(GTYP_SYSTYPEMASK|GTYP_SYSGADGET); gadget->GadgetID=GAD_ZOOM; } } // Is lister locked? if (lister->flags&LISTERF_LOCK_POS) { // Add to window lister->size_cover_gadget.NextGadget=0; AddGList(lister->window,&lister->size_cover_gadget,0,1,0); RefreshWindowFrame(lister->window); } // Fix next pointer else lister->size_cover_gadget.NextGadget=&lister->zoom_cover_gadget; // Create edit hook lister->path_edit_hook= GetEditHookTags( 0, OBJECTF_NO_SELECT_NEXT, GTCustom_History,lister->path_history, TAG_END); // Create path field if (!(lister->path_field=(struct Gadget *) NewObject(0,"dopusstrgclass", GA_ID,GAD_PATH, GA_Left,lister->window->BorderLeft, GA_RelBottom,-(lister->window->BorderBottom+FIELD_FONT->tf_YSize+4), GA_RelWidth,-(lister->window->BorderLeft+lister->window->BorderRight), GA_Height,FIELD_FONT->tf_YSize+4, GA_RelVerify,TRUE, GA_Immediate,TRUE, GTCustom_ThinBorders,TRUE, GTCustom_NoGhost,TRUE, STRINGA_TextVal,(lister->cur_buffer)?lister->cur_buffer->buf_Path:"", STRINGA_MaxChars,511, STRINGA_Buffer,lister->path_buffer, STRINGA_UndoBuffer,GUI->global_undo_buffer, STRINGA_WorkBuffer,GUI->global_undo_buffer+512, STRINGA_Font,FIELD_FONT, STRINGA_EditHook,lister->path_edit_hook, TAG_END))) { lister_close(lister,0); return 0; } DoMethod((Object *)lister->path_field,OM_ADDTAIL,&lister->backdrop_info->boopsi_list); // Initialise side parent button lister->parent_button.NextGadget=lister->path_field; lister->parent_button.TopEdge=lister->window->BorderTop; lister->parent_button.Width=lister->window->BorderLeft; lister->parent_button.Height=-(lister->window->BorderTop+lister->window->BorderBottom); lister->parent_button.Flags=GFLG_GADGHCOMP|GFLG_RELHEIGHT; lister->parent_button.Activation=GACT_RELVERIFY; lister->parent_button.GadgetType=GTYP_BOOLGADGET; lister->parent_button.GadgetID=GAD_PARENT; // Try to add AppWindow lister->appwindow=AddAppWindowA( WINDOW_LISTER, (ULONG)lister, lister->window, lister->app_port,0); // Is lister busy? if (lister->flags&LISTERF_BUSY || lister->old_flags&LISTERF_BUSY) { lister->flags&=~(LISTERF_BUSY|LISTERF_LOCK|LISTERF_LOCKED); lister_busy(lister,0); } else if (lister->flags&LISTERF_LOCKED || lister->old_flags&LISTERF_LOCKED) { lister->flags&=~(LISTERF_BUSY|LISTERF_LOCK|LISTERF_LOCKED); lister_busy(lister,1); } // Initialise lister flags lister->flags&= LISTERF_LOCK_POS|LISTERF_BUSY| LISTERF_LOCK|LISTERF_LOCKED| LISTERF_VIEW_ICONS|LISTERF_SHOW_ALL|LISTERF_PATH_FIELD| LISTERF_STORED_SOURCE|LISTERF_STORED_DEST|LISTERF_ICON_ACTION| LISTERF_FIRST_TIME; lister->more_flags&=~LISTERF_TITLEBARRED; // Update selection count if in icon mode if (lister->flags&LISTERF_ICON_ACTION) backdrop_fix_count(lister->backdrop_info,0); // Initialise cursor setting lister->cursor_line=-1; lister->edit_type=-1; // Setup lister display lister_init_display(lister); lister_refresh(lister,LREFRESH_FULL); lister_refresh_name(lister); // Clear old flags lister->old_flags=0; // Is this our first time open? if (lister->flags&LISTERF_FIRST_TIME) { char buf[16]; // Build handle string lsprintf(buf,"%ld",lister); // Launch script RunScript(SCRIPT_OPEN_LISTER,buf); } // If busy, show progress window if (lister->progress_window) ShowProgressWindow(lister->progress_window,0,lister->window); // Fix current directory lister_fix_cd(lister); // Initialise things lister->title_click=-1; // Return window pointer return lister->window; }
static struct AHIDevUnit * InitUnit ( ULONG unit, struct AHIBase *AHIBase ) { struct AHIDevUnit *iounit; if( unit == AHI_NO_UNIT ) { ReadConfig(NULL,AHIBase); return NULL; } else if(!AHIBase->ahib_DevUnits[unit]) { if((iounit = AllocVec(sizeof(struct AHIDevUnit), MEMF_CLEAR|MEMF_PUBLIC))) { NewList(&iounit->Unit.unit_MsgPort.mp_MsgList); iounit->Unit.unit_MsgPort.mp_Node.ln_Type = NT_MSGPORT; iounit->Unit.unit_MsgPort.mp_Flags = PA_IGNORE; iounit->Unit.unit_MsgPort.mp_Node.ln_Name = AHINAME " Unit"; iounit->UnitNum = unit; InitSemaphore(&iounit->ListLock); NewList((struct List *)&iounit->ReadList); NewList((struct List *)&iounit->PlayingList); NewList((struct List *)&iounit->SilentList); NewList((struct List *)&iounit->WaitingList); NewList((struct List *)&iounit->RequestQueue); if(ReadConfig(iounit,AHIBase)) { if((iounit->Voices = AllocVec( sizeof(struct Voice)*iounit->Channels,MEMF_PUBLIC|MEMF_CLEAR))) { int i; struct Voice *v = iounit->Voices; struct MsgPort *replyport; // Mark all channels as free for(i = 0 ; i < iounit->Channels; i++) { v->NextOffset = FREE; v++; } replyport = CreateMsgPort(); if( replyport != NULL ) { struct StartupMessage sm = { { { NULL, NULL, NT_UNKNOWN, 0, NULL }, replyport, sizeof(struct StartupMessage), }, iounit }; iounit->Process = CreateNewProcTags( NP_Entry, (ULONG) &DevProc, NP_Name, (ULONG) AHINAME " Unit Process", NP_Priority, AHI_PRI, TAG_DONE ); if( iounit->Process != NULL ) { PutMsg( &iounit->Process->pr_MsgPort, &sm.Msg ); WaitPort(replyport); GetMsg(replyport); } DeleteMsgPort(replyport); } } } if(!iounit->Process) FreeVec(iounit); else AHIBase->ahib_DevUnits[unit] = iounit; } } return AHIBase->ahib_DevUnits[unit]; }
// Save page/parser contents. BOOL SyntaxPage::SavePage( ClsStdioFile *pFile, LPPARSER pParser ) { try { // Write colors comment. pFile->PrintF( ClsString( MAKEINTRESOURCE( IDS_COMMENT_COLORS ))); // Write colors. SaveColor( pFile, pParser, _T( "TextRGB=" ), CF_DEFAULT_TEXT, CARR_TEXT ); SaveColor( pFile, pParser, _T( "BackgroundRGB=" ), CF_DEFAULT_BACKGROUND, CARR_BACKGROUND ); SaveColor( pFile, pParser, _T( "BackgroundReadOnlyRGB=" ), CF_DEFAULT_BACKGROUND_RO, CARR_BACKGROUND_READONLY ); SaveColor( pFile, pParser, _T( "MarginRGB=" ), CF_DEFAULT_MARGIN, CARR_SELECTION_MARGIN ); SaveColor( pFile, pParser, _T( "NumberRGB=" ), CF_DEFAULT_NUMBER, CARR_NUMBER ); SaveColor( pFile, pParser, _T( "DelimiterRGB=" ), CF_DEFAULT_DELIMITER, CARR_DELIMITER ); SaveColor( pFile, pParser, _T( "SelectedTextRGB=" ), CF_DEFAULT_SELECTED_TEXT, CARR_SELECTED_TEXT ); SaveColor( pFile, pParser, _T( "SelectedBackgroundRGB=" ), CF_DEFAULT_SELECTED_BKGND, CARR_SELECTED_BKGND ); SaveColor( pFile, pParser, _T( "LineNumberRGB=" ), CF_DEFAULT_LINE_NUMBERS, CARR_LINE_NUMBERS ); SaveColor( pFile, pParser, _T( "BkgndLineNumberRGB=" ), CF_DEFAULT_LINE_NUMBERS_BKGND, CARR_BACKGROUND_LINE_NUMBERS ); SaveColor( pFile, pParser, _T( "BkgndNumberRGB="), CF_DEFAULT_BACKGROUND_NUMBER, CARR_BACKGROUND_NUMBER ); SaveColor( pFile, pParser, _T( "BkgndDelimiterRGB="), CF_DEFAULT_BACKGROUND_DELIMITER, CARR_BACKGROUND_DELIMITER ); SaveColor( pFile, pParser, _T( "BracketMatchRGB="), CF_DEFAULT_BRACKET_MATCH, CARR_BRACKET_MATCH ); SaveColor( pFile, pParser, _T( "HyperlinkRGB="), CF_DEFAULT_HYPERLINK, CARR_HYPERLINK ); SaveColor( pFile, pParser, _T( "BkgndHyperlinkRGB="), CF_DEFAULT_BACKGROUND_HYPERLINK, CARR_BACKGROUND_HYPERLINK ); SaveColor( pFile, pParser, _T( "ColumnOverflowRGB="), CF_DEFAULT_COLUMN_OVERFLOW, CARR_COLUMN_OVERFLOW ); // Write the screen and printer // fonts. pFile->PrintF( _T( "ScreenFont=%s,%ld,%ld,%ld,%ld,%ld\n" ), pParser->lfScreenFont.lfFaceName, pParser->lfScreenFont.lfHeight, pParser->lfScreenFont.lfWeight, pParser->lfScreenFont.lfCharSet, pParser->lfScreenFont.lfItalic, pParser->lfScreenFont.lfUnderline ); // Write general syntax coloring comment. pFile->PrintF( ClsString( MAKEINTRESOURCE( IDS_COMMENT_SYNTAXGENERAL ))); // Save general syntax coloring settings. if ( pParser->cEscape ) pFile->PrintF( _T( "Escape=%lc\n" ), pParser->cEscape ); pFile->PrintF( _T( "SyntaxColoring=%lc\n" ), pParser->bSyntaxColoring ? _T( 'Y' ) : _T( 'N' )); pFile->PrintF( _T( "Case=%lc\n" ), pParser->bCaseOn ? _T( 'Y' ) : _T( 'N' )); // Write blocks comment. pFile->PrintF( ClsString( MAKEINTRESOURCE( IDS_COMMENT_BLOCKS ))); // Write blocks. for ( int i = 0; i < ::ArrayGetSize( pParser->lpaBlocks ); i++ ) { // Get block. LPBLOCK lpBlock = ( LPBLOCK )::ArrayGetAt( pParser->lpaBlocks, i ); // Write block opening. if ( lpBlock->pszName ) pFile->PrintF( _T( "Block=%s\n" ), lpBlock->pszName ); else pFile->PrintF( _T( "Block\n" )); // Write color commands. pFile->PrintF( _T( "\tRGB=%ld,%ld,%ld\n" ), GetRValue( lpBlock->crColor ), GetGValue( lpBlock->crColor ), GetBValue( lpBlock->crColor )); if ( lpBlock->crBgColor == CLR_DEFAULT ) pFile->PrintF( _T( "\tBkRGB=*\n" )); else pFile->PrintF( _T( "\tBkRGB=%ld,%ld,%ld\n" ), GetRValue( lpBlock->crBgColor ), GetGValue( lpBlock->crBgColor ), GetBValue( lpBlock->crBgColor )); // Write start command. pFile->PrintF( _T( "\tStart=%s\n" ), lpBlock->pszStart ); // At the start of the line? if ( lpBlock->bStartOfLine ) pFile->PrintF( _T( "\tStartOfLine=Y\n" )); // Suppress escaping? pFile->PrintF( _T( "\tSuppressEscape=%lc\n" ), lpBlock->bSuppressEscape ? _T( 'Y' ) : _T( 'N' )); // Write end command. if ( lpBlock->pszEnd ) pFile->PrintF( _T( "\tEnd=%s\n" ), lpBlock->pszEnd == END_OF_LINE ? _T( "\\n" ) : lpBlock->pszEnd ); else pFile->PrintF( _T( ";\tEnd=\n" )); // Write block terminator. pFile->PrintF( _T( "EndBlock\n\n" )); } // Write keywords comment. pFile->PrintF( ClsString( MAKEINTRESOURCE( IDS_COMMENT_KEYWORDS ))); // Initialize buffer list. KEYLIST kl; BOOL bKeywords = FALSE; NewList(( LPLIST )&kl ); // Convert hashes. if ( KeywordEdit::Hash2List( &kl, pParser )) { // Iterate nodes. LPKEYWORDS pKW; for ( pKW = kl.lpFirst; pKW->lpNext; pKW = pKW->lpNext ) { // Keywords command written? if ( bKeywords == FALSE ) { // Write keywords command. pFile->PrintF( _T( "Keywords\n" )); bKeywords = TRUE; } // Write color values. pFile->PrintF( _T( "RGB=%ld,%ld,%ld\n" ), GetRValue( pKW->crColor ), GetGValue( pKW->crColor ), GetBValue( pKW->crColor )); if ( pKW->crBgColor == CLR_DEFAULT ) pFile->PrintF( "BkRGB=*\n" ); else pFile->PrintF( _T( "BkRGB=%ld,%ld,%ld\n" ), GetRValue( pKW->crBgColor ), GetGValue( pKW->crBgColor ), GetBValue( pKW->crBgColor )); // Write keywords from this group. for ( int i = 0; i < ::ArrayGetSize( pKW->lpaKeywords ); i++ ) pFile->PrintF( _T( "%s\n" ), *(( LPCTSTR * )::ArrayGetAt( pKW->lpaKeywords, i ))); } // Free the converted list. KeywordEdit::FreeKeyList( &kl ); } else return FALSE; // Write endkeywords command. if ( bKeywords ) pFile->PrintF( _T( "EndKeywords\n" )); } catch ( ClsException& e ) { // Error... UNREFERENCED_PARAMETER( e ); return FALSE; } return TRUE; }