// See if DOpus is already running void startup_check_duplicate() { Forbid(); if (FindPort(dopus_name)) { struct MsgPort *port; // Ask if we want to run another copy Permit(); if (SimpleRequest(0, dopus_name, GetString(&locale,MSG_ALREADY_RUNNING_BUTTONS), GetString(&locale,MSG_ALREADY_RUNNING),0,0,0,0)) { // Find port again (under Forbid) Forbid(); if ((port=FindPort(dopus_name))) { // Signal program to wake up Signal((struct Task *)port->mp_SigTask,IPCSIG_SHOW); } Permit(); // Quit this copy quit(0); } } Permit(); }
int sem_unlink (const char *__name) { unsigned char name[_PSEM_NAME_MAXLENGTH]; struct SignalSemaphore *ssem; psem_t *psem = NULL; if(strlen(__name) > (_PSEM_NAME_MAXLENGTH-20)) { errno = ENAMETOOLONG; return -1; } psem_name(__name,name,sizeof(name)-1); Forbid(); if((ssem = FindSemaphore((STRPTR)name))) { //if(((psem_t *)ssem)->magic == _PSEM_MAGIC) psem = (psem_t *)ssem; } Permit(); if(_PSEM_INVALID(psem)) { errno = ((ssem != NULL) ? EACCES:ENOENT); return -1; } Forbid(); if(psem_trywait(psem)==0) { psem_destroy(psem); } else { /** * Could a semaphore be unlinked by a process other * than the one who created it? if so, this lib will * require some rework... */ if(psem->owner == (unsigned)FindTask(NULL)) psem->flags |= SEMF_EXPUNGE; } Permit(); return 0; }
/* /// "usbReleaseInterfaceBinding()" */ void usbReleaseInterfaceBinding(struct NepHidBase *nh, struct NepClassHid *nch) { struct Library *ps; struct PsdConfig *pc; struct PsdDevice *pd; STRPTR devname; KPRINTF(1, ("nepHidReleaseInterfaceBinding(%08lx)\n", nch)); if((ps = OpenLibrary("poseidon.library", 4))) { Forbid(); nch->nch_ReadySignal = SIGB_SINGLE; nch->nch_ReadySigTask = FindTask(NULL); if(nch->nch_GUITask) { Signal(nch->nch_GUITask, SIGBREAKF_CTRL_C); } Permit(); while(nch->nch_GUITask) { Wait(1L<<nch->nch_ReadySignal); } Forbid(); if(nch->nch_Task) { Signal(nch->nch_Task, SIGBREAKF_CTRL_C); } Permit(); while(nch->nch_Task) { Wait(1L<<nch->nch_ReadySignal); } //FreeSignal(nch->nch_ReadySignal); psdGetAttrs(PGA_INTERFACE, nch->nch_Interface, IFA_Config, &pc, TAG_END); psdGetAttrs(PGA_CONFIG, pc, CA_Device, &pd, TAG_END); psdGetAttrs(PGA_DEVICE, pd, DA_ProductName, &devname, TAG_END); psdAddErrorMsg(RETURN_OK, (STRPTR) libname, "A cat ate my mouse '%s'!", devname); Forbid(); Remove(&nch->nch_Node); Permit(); psdFreeVec(nch->nch_CDC); psdFreeVec(nch); CloseLibrary(ps); } }
// Check for refresh message struct IntuiMessage *check_refresh_msg(struct Window *window,ULONG mask) { struct IntuiMessage *msg; // Valid window? if (!window) return 0; // Go through messages for (msg=(struct IntuiMessage *)window->UserPort->mp_MsgList.lh_Head; msg->ExecMessage.mn_Node.ln_Succ; msg=(struct IntuiMessage *)msg->ExecMessage.mn_Node.ln_Succ) { // Refresh? if (msg->Class&mask) { // Remove it Forbid(); Remove((struct Node *)msg); Permit(); // Return the message return msg; } } return 0; }
void RegisterARexxFunctionHost(int add) { struct RexxMsg *mess; struct MsgPort *rexxmastport; if(!(mess=(struct RexxMsg *)AllocMem(sizeof(struct RexxMsg), MEMF_CLEAR | MEMF_PUBLIC))) { cleanup(EXIT_ERROR, "Out of memory."); } mess->rm_Node.mn_Node.ln_Type = NT_MESSAGE; mess->rm_Node.mn_Length = sizeof(struct RexxMsg); mess->rm_Node.mn_ReplyPort=rexxport; mess->rm_Action = add ? RXADDFH : RXREMLIB; mess->rm_Args[0] = "NIKOMREXXHOST"; mess->rm_Args[1] = 0L; Forbid(); rexxmastport = (struct MsgPort *)FindPort("REXX"); if(rexxmastport) { PutMsg((struct MsgPort *)rexxmastport,(struct Message *)mess); } Permit(); if(rexxmastport == NULL) { FreeMem(mess, sizeof(struct RexxMsg)); if(add) { cleanup(EXIT_ERROR, "Can't find port 'REXX' (ARexx master server)"); } return; } WaitPort(rexxport); GetMsg(rexxport); FreeMem(mess, sizeof(struct RexxMsg)); }
struct AHI_AudioDatabase * LockDatabaseWrite(void) { struct AHI_AudioDatabase *audiodb; Forbid(); audiodb = (struct AHI_AudioDatabase *) FindSemaphore(ADB_NAME); if(audiodb != NULL) { ObtainSemaphore((struct SignalSemaphore *) audiodb); } else { audiodb = (struct AHI_AudioDatabase *) AllocVec(sizeof(struct AHI_AudioDatabase), MEMF_PUBLIC|MEMF_CLEAR); if(audiodb != NULL) { NewList( (struct List *) &audiodb->ahidb_AudioModes); audiodb->ahidb_Semaphore.ss_Link.ln_Name = audiodb->ahidb_Name; audiodb->ahidb_Semaphore.ss_Link.ln_Pri = 20; strcpy(audiodb->ahidb_Semaphore.ss_Link.ln_Name, ADB_NAME); AddSemaphore((struct SignalSemaphore *) audiodb); ObtainSemaphore((struct SignalSemaphore *) audiodb); } } Permit(); return audiodb; }
static void* AllocPages( size_t size, ULONG req ) { void* address; // FIXME: This shoule be non-cachable, DMA-able memory address = AllocMem( size + PAGE_SIZE - 1, req & ~MEMF_CLEAR ); if( address != NULL ) { Forbid(); FreeMem( address, size + PAGE_SIZE - 1 ); address = AllocAbs( size, (void*) ((ULONG) ( address + PAGE_SIZE - 1 ) & ~(PAGE_SIZE-1) ) ); Permit(); } if( address != NULL && ( req & MEMF_CLEAR ) ) { memset( address, 0, size ); } return address; }
int sem_post (sem_t *__sem) { psem_t *sem = sem2psem(__sem); ENTER(); POINTER(sem); if(_PSEM_INVALID(sem)) { DBG("Invalid sem_t provided, magic=%lx\n",((psem_t *)__sem)->magic); errno = EINVAL; return -1; } Forbid(); if((_SSEM(sem)->ss_QueueCount != -1) && ((_SSEM(sem)->ss_Owner == NULL) || (_SSEM(sem)->ss_Owner == FindTask(NULL)))) { ReleaseSemaphore(_SSEM(sem)); } if((sem->flags & SEMF_EXPUNGE) && (_SSEM(sem)->ss_QueueCount == -1)) { DBG("Delayed expunge will take action now...\n"); psem_destroy(sem); memset(__sem,_PSEM_ERASEDBIT,sizeof(*__sem)); } Permit(); LEAVE(); return 0; }
LIBFUNC2(APTR, AllocMem, ULONG, size, ULONG, flags, struct ExecBase *,SysBase) { struct MemHeader *mh; struct MemBlock *mb; ULONG realsize=size+sizeof(struct MemHeader); Forbid(); mb=(struct MemBlock *) GetHead(&SysBase->FreeMemList); if(!mb) return (NULL); while(mb->mb_Size<realsize) { mb=(struct MemBlock *) GetNext(mb); if(!mb) return (NULL); } realsize=realsize+(realsize%MEM_BLOCKSIZE); mb->mb_Size -= realsize; mh=(struct MemHeader *) (mb+mb->mb_Size); mh->mh_Node.mln_Prev = NULL; mh->mh_Node.mln_Next = NULL; mh->mh_Magic = MEMF_MAGIC; mh->mh_Size = realsize; Permit(); return ((APTR) mh); }
int main(int argc, char* argv[]) { int rc = RETURN_OK; if (argc != 2) { fprintf(stderr, "Usage: %s <audio mode id>\n", argv[0]); rc = RETURN_ERROR; } else { struct MsgPort* mp = CreateMsgPort(); if (mp != NULL) { struct AHIRequest* io = (struct AHIRequest *) CreateIORequest(mp, sizeof(struct AHIRequest)); if (io != NULL) { io->ahir_Version = 4; if (OpenDevice(AHINAME, AHI_NO_UNIT, (struct IORequest *) io, 0) == 0) { AHIBase = (struct Library *) io->ahir_Std.io_Device; BetterAudioID = atol(argv[1]); Forbid(); OldBestAudioIDA = (BestAudioIDA_proto*) SetFunction(AHIBase, _LVOAHI_BestAudioIDA, (ULONG (*)(void)) MyBestAudioIDA ); Wait(SIGBREAKF_CTRL_C); SetFunction(AHIBase, _LVOAHI_BestAudioIDA, (ULONG (*)(void)) OldBestAudioIDA ); rc = 0; Permit(); CloseDevice((struct IORequest *) io); } else { fprintf(stderr, "Unable to open '" AHINAME "' version 4.\n"); rc = RETURN_FAIL; } DeleteIORequest((struct IORequest *) io); } else { fprintf(stderr, "Unable to create IO request.\n"); rc = RETURN_FAIL; } DeleteMsgPort(mp); } else { fprintf(stderr, "Unable to create message port.\n"); rc = RETURN_FAIL; } } return rc; }
BOOL util_RemNamedObject(pUtility UtilBase, struct NamedObject *object, struct Message *message) { Forbid(); struct NameSpace *ns = SYSTEM(object)->no_Nos.nos_NameSpace; if (ns == NULL) { if (message != NULL) { message->mn_Node.ln_Name = NULL; ReplyMsg(message); } Permit(); return TRUE; } if (message == NULL) { if (SYSTEM(object)->no_Non.non_UseCount != 1) { Permit(); return TRUE; } } SYSTEM(object)->no_Nos.nos_NameSpace = NULL; ObtainSemaphore(&ns->ns_Semaphore); Remove(&SYSTEM(object)->no_Non.non_Node); if (message != NULL) { SYSTEM(object)->no_Nos.nos_RemoveMsg = message; message->mn_Node.ln_Name = (STRPTR)object; } ReleaseSemaphore(&ns->ns_Semaphore); Permit(); return ReleaseNamedObject(object); }
static BOOL AddAClass(struct List *opened, Class *cl, CONST_STRPTR name) { struct OpenedResourceNode *orn; if (NULL == cl) return TRUE; orn = get_orn(); if (!orn) { return FALSE; } Forbid(); orn->type = "Class"; if (NULL == name) name = cl->cl_ID; orn->name = StaticStrDup(name); orn->addr = cl; orn->count = cl->cl_ObjectCount; Permit(); Enqueue(opened, (struct Node *)orn); return TRUE; }
/************************************************************************************** ** Main *************************************************************************************** */ VOID main() { APTR oldfunct; APTR newfunct; if(!(AssemblyBase = OpenLibrary(ASSEMBLYNAME, ASSEMBLY_MINIMUM))) return(NULL); IntuitionBase = AssemblyBase->ab_IntuiBase; /* if(!(newfunct = AllocVec(1024,MEMF_FAST|MEMF_CLEAR))) { CloseLibrary(AssemblyBase); return(NULL); } CopyMemQuick(&MyRequest,newfunct,1024); */ Forbid(); /* oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,newfunct); */ oldfunct = SetFunction(IntuitionBase,_LVOEasyRequestArgs,&MyRequest); Permit(); return(NULL); }
static void entry(void) { struct MsgPort *port1,*port2; struct Message *msg; Forbid(); port1=FindPort("message test port"); Permit(); port2=CreateMsgPort(); if(port2!=NULL) { msg=(struct Message *)CreateIORequest(port2,sizeof(struct Message)); if(msg!=NULL) { int i; for(i=0;i<10;i++) { msg->mn_Node.ln_Name=(char *)i; PutMsg(port1,msg); WaitPort(port2); GetMsg(port2); } DeleteIORequest((struct IORequest *)msg); } DeleteMsgPort(port2); } Signal(port1->mp_SigTask,1<<port1->mp_SigBit); Wait(0);/* Let the parent remove me */ }
__stkargs void cleanup_timer(struct timerequest ** tr) { struct MsgPort *tp; struct timerequest *tmp; UBYTE pFlags; if (*tr) { tmp = *tr; tp = tmp->tr_node.io_Message.mn_ReplyPort; if (tp) { /* abort the current request */ pFlags = tp->mp_Flags; /* still needed for DeletePort */ tp->mp_Flags = PA_IGNORE; AbortIO((struct IORequest *) tmp); WaitIO((struct IORequest *) tmp); while (GetMsg(tp)); Forbid(); tp->mp_Flags = pFlags; DeletePort(tp); Permit(); } CloseDevice((struct IORequest *) tmp); DeleteExtIO((struct IORequest *) tmp); } *tr = NULL; }
static void* CreateConnectionData(DBusConnection* connection) { struct ConnectionData* c = AllocVec(sizeof(struct ConnectionData), MEMF_ANY|MEMF_CLEAR); kprintf("CreateConnectionData %08lx\n", c); if (c != NULL) { c->connection = connection; c->creator = FindTask(NULL); NewList((struct List*) &c->watches); Forbid(); kprintf("creating mainloop\n"); c->main = (struct Task*) CreateNewProcTags(NP_Entry, (ULONG) MainLoop, NP_Name, (ULONG) "dbus.library main loop", NP_Priority, 0, TAG_DONE); kprintf("created mainloop %08lx\n", c->main); if (c->main != NULL) { c->main->tc_UserData = c; } SetSignal(0, SIGF_SINGLE); Permit(); Wait(SIGF_SINGLE); if (c->main == NULL) { DeleteConnectionData(c); c = NULL; } } return c; }
static int bsdsocket_Cleanup(struct bsdsocketBase *SocketBase) { APTR HostLibBase = SocketBase->HostLibBase; D(bug("[socket] Cleanup, HostLibBase is 0x%p\n", HostLibBase)); if (!HostLibBase) return TRUE; if (SocketBase->ResIFace) { if (SocketBase->ctl) { int res; Forbid(); res = SocketBase->ResIFace->sock_shutdown(SocketBase->ctl); Permit(); if (res) return FALSE; } } if (SocketBase->WSIFace) HostLib_DropInterface((void **)SocketBase->WSIFace); if (SocketBase->winsock) HostLib_Close(SocketBase->winsock, NULL); return TRUE; }
/* /// "usbReleaseDeviceBinding()" */ void usbReleaseDeviceBinding(struct NepSerialBase *nh, struct NepClassSerial *ncp) { struct Library *ps; STRPTR devname; KPRINTF(1, ("nepSerialReleaseDeviceBinding(%08lx)\n", ncp)); if((ps = OpenLibrary("poseidon.library", 4))) { Forbid(); ncp->ncp_ReadySignal = SIGB_SINGLE; ncp->ncp_ReadySigTask = FindTask(NULL); if(ncp->ncp_Task) { Signal(ncp->ncp_Task, SIGBREAKF_CTRL_C); } Permit(); while(ncp->ncp_Task) { Wait(1L<<ncp->ncp_ReadySignal); } //FreeSignal(ncp->ncp_ReadySignal); psdGetAttrs(PGA_DEVICE, ncp->ncp_Device, DA_ProductName, &devname, TAG_END); psdAddErrorMsg(RETURN_OK, (STRPTR) libname, "'%s' annealed and broke off.", devname); /*psdFreeVec(ncp);*/ CloseLibrary(ps); } }
void rexx_exit (void) { if (ARexxPort) { struct RexxMsg *msg; gui_rexx_s *gui = &gui_rexx[ON_EXIT]; if (gui->port[0] && gui->cmd_on[0]) { if (ADDRESS(gui->port, gui->cmd_on) != RC_OK) { write_log ("%s:%s:%s\n", gui->port, gui->cmd_on, RESULT); } gui->port[0] = '\0'; } Forbid (); while ((msg = (struct RexxMsg*)GetMsg (ARexxPort))) { msg->rm_Result1 = RC_ERROR; msg->rm_Result2 = 0; ReplyMsg ((void*)msg); } DeletePort (ARexxPort); Permit (); ARexxPort = NULL; } #ifdef __amigaos4__ if (IRexxSys) { DropInterface ((struct Interface *)IRexxSys); IRexxSys = NULL; } #endif if (RexxSysBase) { CloseLibrary ((void*)RexxSysBase); RexxSysBase = NULL; } }
void lib_AddPort(SysBase *SysBase, struct MsgPort *msgPort) { msgPort->mp_Node.ln_Type = NT_MSGPORT; NewListType(&msgPort->mp_MsgList,NT_MSGPORT); Forbid(); Enqueue(&SysBase->PortList, &msgPort->mp_Node); Permit(); }
/************* * DESCRIPTION: save exit a subtask * INPUT: st subtask structure * stm SHUTDOWN message received from main task * OUTPUT: - *************/ void ExitSubTask(struct SubTask *st,struct SubTaskMsg *stm) { if(st->st_Port) DeleteMsgPort(st->st_Port); Forbid(); stm->stm_Result = FALSE; WARPOS_PPC_FUNC(ReplyMsg)((struct Message *)stm); }
BOOL IPC_PutMsg( struct MsgPort *destino, IPCACT_T action, APTR udata ) { struct MsgPort *replyport = NULL; BOOL error = TRUE; ENTER(); DBG_POINTER(destino); if(destino && (replyport = CreateMsgPort())) { struct IPCMsg ipcmsg; APTR xMsg; ipcmsg.ipc_msg.mn_ReplyPort = replyport; ipcmsg.ipc_msg.mn_Length = sizeof(struct IPCMsg); ipcmsg.ipc_ID = IPC_MAGIC; ipcmsg.ipc_action = action; ipcmsg.ipc_result = IPCR_ABORTED; ipcmsg.ipc_data = udata; DBG("Sending action '%ld' from %lx to %lx\n", action, replyport, destino); Forbid(); PutMsg( destino, &ipcmsg.ipc_msg); WaitPort(replyport); while((xMsg = GetMsg( replyport ))) { DBG("Got reply...\n"); switch(((struct IPCMsg *)xMsg)->ipc_result) { // TODO case IPCR_ABORTED: DBG("IPCR_ABORTED\n"); break; case IPCR_FAIL: DBG("IPCR_FAIL\n"); break; case IPCR_OK: DBG("IPCR_OK\n"); break; default: break; } } Permit(); DeleteMsgPort(replyport); error = FALSE; } LEAVE(); return !error; }
int main( void ) { struct Library* EMU10kxBase; struct EMU10kxAC97* EMU10kxAC97; ULONG value; EMU10kxBase = OpenLibrary( "DEVS:AHI/emu10kx.audio", VERSION ); if( EMU10kxBase == NULL ) { Printf( "Unable to open DEVS:AHI/emu10kx.audio version %ld.\n", VERSION ); return RETURN_FAIL; } Forbid(); EMU10kxAC97 = (struct EMU10kxAC97*) FindSemaphore( EMU10KX_AC97_SEMAPHORE ); if( EMU10kxAC97 != NULL ) { ObtainSemaphore( &EMU10kxAC97->Semaphore ); } Permit(); if( EMU10kxAC97 == NULL ) { CloseLibrary( EMU10kxBase ); Printf( "Unable to find semaphore '%s'.\n", (ULONG) EMU10KX_AC97_SEMAPHORE ); return RETURN_FAIL; } Printf( "%ld EMU10kx cards found.\n", EMU10kxAC97->Cards ); value = CallHook( &EMU10kxAC97->GetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL ); Printf( "CD volume on card 0 is 0x%04lx\n", value ); Printf( "Setting it to 0x0000.\n" ); CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, 0 ); Delay( 3 * 50 ); Printf( "Restoring it.\n" ); CallHook( &EMU10kxAC97->SetFunc, (Object*) EMU10kxBase, 0, AC97_CD_VOL, value ); Printf( "Exiting.\n" ); if( EMU10kxAC97 != NULL ) { ReleaseSemaphore( &EMU10kxAC97->Semaphore ); } CloseLibrary( EMU10kxBase ); return RETURN_OK; }
void _AHIsub_Disable( struct AHIAudioCtrlDrv* AudioCtrl, struct DriverBase* AHIsubBase ) { struct VoidBase* VoidBase = (struct VoidBase*) AHIsubBase; // V6 drivers do not have to preserve all registers Forbid(); }
void SAVEDS handler(void) { struct Process *me = (struct Process *)FindTask(NULL); struct startMsg *smsg; struct MsgPort *port; BOOL res = FALSE; ENTER(); WaitPort(&me->pr_MsgPort); smsg = (struct startMsg *)GetMsg(&me->pr_MsgPort); #if defined(__amigaos4__) port = AllocSysObject(ASOT_PORT, TAG_DONE); #else port = CreateMsgPort(); #endif if(port != NULL) res = localSendRexxMsg(port, smsg->port, smsg->cmd); smsg->res = res; ReplyMsg((struct Message *)smsg); if(res == TRUE) { struct RexxMsg *rxmsg; WaitPort(port); rxmsg = (struct RexxMsg *)GetMsg(port); DeleteArgstring((APTR)rxmsg->rm_Args[0]); DeleteRexxMsg(rxmsg); } if(port != NULL) { #if defined(__amigaos4__) FreeSysObject(ASOT_PORT, port); #else DeleteMsgPort(port); #endif } ObtainSemaphore(&OpenURLBase->libSem); OpenURLBase->rexx_use--; ReleaseSemaphore(&OpenURLBase->libSem); #if !defined(__amigaos4__) // all systems except OS4 should leave this function in forbidden state Forbid(); #endif LEAVE(); }
static void Sys_Thread_Trampoline() { struct SysThread *thread; thread = FindTask(0)->tc_UserData; thread->entrypoint(thread->argument); Forbid(); ReplyMsg(&thread->msg); }
// Someone pressed the help key void help_get_help(short x,short y,unsigned short qual) { struct Window *window=0; struct Layer *layer; IPCData *ipc=0; // Lock screen layer LockLayerInfo(&GUI->screen_pointer->LayerInfo); // Find which layer the mouse is over if ((layer=WhichLayer(&GUI->screen_pointer->LayerInfo,x,y))) { // Get window pointer window=layer->Window; // Get window ID if (GetWindowID(window)!=WINDOW_UNKNOWN) { // Forbid to get port Forbid(); // Get port if (!(ipc=(IPCData *)GetWindowAppPort(window))) Permit(); } } // Unlock layer UnlockLayerInfo(&GUI->screen_pointer->LayerInfo); // Got a port? if (ipc) { ULONG coords; // Convert coordinates to window-relative x-=window->LeftEdge; y-=window->TopEdge; // Pack into longword coords=((unsigned short)x<<16)|(unsigned short)y; // Send help command IPC_Command(ipc,IPC_HELP,qual,(APTR)coords,0,0); // Enable multitasking now that message has been sent Permit(); } // Otherwise, show generic help else help_show_help(HELP_MAIN,0); }
BOOL util_ReleaseNamedObject(pUtility UtilBase, struct NamedObject *object) { if (!object) return TRUE; Forbid(); SYSTEM(object)->no_Non.non_UseCount--; if (SYSTEM(object)->no_Non.non_UseCount == 0) { if (SYSTEM(object)->no_Nos.nos_RemoveMsg != NULL) ReplyMsg(SYSTEM(object)->no_Nos.nos_RemoveMsg); } Permit(); return TRUE; }
APTR lib_SetFunction(struct SysBase *SysBase, struct Library *library, INT32 funcOffset, APTR newFunction) { APTR ret; UINT32 *vecaddr; Forbid(); library->lib_Flags |= LIBF_CHANGED; vecaddr = (UINT32 *)((UINT32)library + funcOffset); ret = (APTR *)*(UINT32 *)(((UINT32)vecaddr)); *(UINT32 *)(((UINT32)vecaddr)) = (UINT32)newFunction; Permit(); //SumLibrary(library); return ret; }
int sag(void) { int vem,x; char *quick; struct SayString *pekare,*oldpekare=NULL,*allocpekare; quick = strchr(argument,','); if(quick) *quick++ = 0; if((vem=parsenamn(argument))==-3) { puttekn("\r\n\nSkriv : Säg <användare>[,<meddelande>]\r\n\n",-1); return(0); } if(vem==-1) { puttekn("\r\n\nFinns ingen som heter så eller har det numret!\r\n\n",-1); return(0); } for(x=0;x<MAXNOD;x++) if(Servermem->inloggad[x]==vem) break; if(x==MAXNOD) { puttekn("\r\n\nPersonen är inte inloggad!\r\n",-1); return(0); } if(!quick) { puttekn("\r\n\nVad vill du säga?\r\n",-1); if(getstring(EKO,MAXSAYTKN-1,NULL)) return(1); if(!inmat[0]) return(0); if(Servermem->inloggad[x]==-1) { puttekn("\r\n\nTyvärr, personen har loggat ut.\r\n",-1); return(0); } } pekare=Servermem->say[x]; if(pekare) sprintf(outbuffer,"\r\n%s har olästa meddelanden. Skickar meddelandet ändå.\r\n",getusername(vem)); else sprintf(outbuffer,"\r\n%s meddelad\r\n",getusername(vem)); puttekn(outbuffer,-1); Forbid(); while(pekare) { oldpekare=pekare; pekare=oldpekare->NextSay; } if(!(allocpekare=(struct SayString *)AllocMem(sizeof(struct SayString),MEMF_PUBLIC | MEMF_CLEAR))) { Permit(); puttekn("\r\n\nKunde inte allokera minne till meddelandet!\r\n\n",-1); return(0); } allocpekare->fromuser=inloggad; if(quick) strcpy(allocpekare->text,quick); else strcpy(allocpekare->text,inmat); if(Servermem->say[x]) oldpekare->NextSay=allocpekare; else Servermem->say[x]=allocpekare; Permit(); return(0); }