本文整理汇总了C++中Permit函数的典型用法代码示例。如果您正苦于以下问题:C++ Permit函数的具体用法?C++ Permit怎么用?C++ Permit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Permit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: startup_check_duplicate
// 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();
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:30,代码来源:main.c
示例2: util_RemNamedObject
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);
}
开发者ID:cycl0ne,项目名称:poweros_x86,代码行数:35,代码来源:name.c
示例3: help_get_help
// 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);
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:53,代码来源:help.c
示例4: sag
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);
}
开发者ID:dblarsson,项目名称:NiKom,代码行数:50,代码来源:NiKFuncs3.c
示例5: sem_unlink
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;
}
开发者ID:blubberdiblub,项目名称:libnix,代码行数:48,代码来源:sem_unlink.c
示例6: bsdsocket_Cleanup
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;
}
开发者ID:michalsc,项目名称:AROS,代码行数:31,代码来源:bsdsocket_init.c
示例7: Forbid
// 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;
}
开发者ID:timofonic,项目名称:dopus5allamigas,代码行数:28,代码来源:misc.c
示例8: main
/**************************************************************************************
** 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);
}
开发者ID:gfazioli,项目名称:Assembly-Library,代码行数:33,代码来源:SETPATCH.C
示例9: sem_post
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;
}
开发者ID:blubberdiblub,项目名称:libnix,代码行数:31,代码来源:sem_post.c
示例10: main
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;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:60,代码来源:BetterAudioID.c
示例11: LockDatabaseWrite
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;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:35,代码来源:database.c
示例12: cleanup_timer
__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;
}
开发者ID:DailyR,项目名称:mudos,代码行数:26,代码来源:signal.c
示例13: LIBFUNC2
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);
}
开发者ID:AlexisBerger,项目名称:novaos,代码行数:27,代码来源:allocmem.c
示例14: AllocPages
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;
}
开发者ID:BackupTheBerlios,项目名称:arp2-svn,代码行数:25,代码来源:linuxsupport.c
示例15: rexx_exit
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;
}
}
开发者ID:diablodiab,项目名称:libretro-uae,代码行数:35,代码来源:ami-rexx.c
示例16: CreateConnectionData
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;
}
开发者ID:michalsc,项目名称:AROS,代码行数:34,代码来源:dbus-amiga.c
示例17: RegisterARexxFunctionHost
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));
}
开发者ID:punktniklas,项目名称:NiKom,代码行数:30,代码来源:Startup.c
示例18: usbReleaseDeviceBinding
/* /// "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);
}
}
开发者ID:michalsc,项目名称:AROS,代码行数:30,代码来源:palmpda.class.c
示例19: lib_AddPort
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();
}
开发者ID:cycl0ne,项目名称:poweros_x86,代码行数:8,代码来源:ports.c
示例20: IPC_PutMsg
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;
}
开发者ID:diegocr,项目名称:AmiNZB,代码行数:57,代码来源:ipc.c
注:本文中的Permit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论