• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ INT2PTR函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中INT2PTR函数的典型用法代码示例。如果您正苦于以下问题:C++ INT2PTR函数的具体用法?C++ INT2PTR怎么用?C++ INT2PTR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了INT2PTR函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: Tk_InternAtom

Atom
Tk_InternAtom(
    Tk_Window tkwin,		/* Window token; map name to atom for this
				 * window's display. */
    const char *name)		/* Name to turn into atom. */
{
    TkDisplay *dispPtr;
    Tcl_HashEntry *hPtr;
    int isNew;

    dispPtr = ((TkWindow *) tkwin)->dispPtr;
    if (!dispPtr->atomInit) {
	AtomInit(dispPtr);
    }

    hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
    if (isNew) {
	Tcl_HashEntry *hPtr2;
	Atom atom;

	atom = XInternAtom(dispPtr->display, name, False);
	Tcl_SetHashValue(hPtr, INT2PTR(atom));
	hPtr2 = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
	Tcl_SetHashValue(hPtr2, Tcl_GetHashKey(&dispPtr->nameTable, hPtr));
    }
    return (Atom)PTR2INT(Tcl_GetHashValue(hPtr));
}
开发者ID:tcltk,项目名称:tk,代码行数:27,代码来源:tkAtom.c


示例2: AtomInit

static void
AtomInit(
    TkDisplay *dispPtr)/* Display to initialize. */
{
    Tcl_HashEntry *hPtr;
    Atom atom;

    dispPtr->atomInit = 1;
    Tcl_InitHashTable(&dispPtr->nameTable, TCL_STRING_KEYS);
    Tcl_InitHashTable(&dispPtr->atomTable, TCL_ONE_WORD_KEYS);

    for (atom = 1; atom <= XA_LAST_PREDEFINED; atom++) {
	const char *name;
	int isNew;

	hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, INT2PTR(atom));
	if (hPtr != NULL) {
	    continue;
	}

	name = atomNameArray[atom - 1];
	hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
	Tcl_SetHashValue(hPtr, INT2PTR(atom));
	name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
	hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
	Tcl_SetHashValue(hPtr, (char *)name);
    }
}
开发者ID:tcltk,项目名称:tk,代码行数:28,代码来源:tkAtom.c


示例3: main

int main(int argc, char **argv) {
	int i, key, inmap, insert, data;
	void *datap;
	struct hashmap_t *map = hashmap_new(5);
	srandom(0);
	for (i=0; i<10000; i++) {
		key = rand()%DATASET_SIZE;
		insert = rand()%2;
		inmap = test_status[key];
		data = test_data[key];
		if (inmap && insert) { 
			/* update */
			data++;
			hashmap_upsert(map, &key, sizeof(int), INT2PTR(data),  &datap);
			assert((intptr_t)datap == (intptr_t)test_data[key]);
			test_data[key] = data;
		} else if ( !inmap && insert) {
			/* insert */
			hashmap_upsert(map, &key, sizeof(int), INT2PTR(data),  &datap);
			assert( (intptr_t)datap == 0);
			test_status[key] = 1;
		} else if (inmap && !insert) {
			/* delete */
			hashmap_delete(map, &key, sizeof(int), &datap);
			assert((intptr_t)datap == (intptr_t)test_data[key]);
			test_status[key] = 0;
		} else if (!inmap && !insert) {
			/* nothing to be deleted */
			hashmap_delete(map, &key, sizeof(int), &datap);
			assert((intptr_t)datap == 0);
		}
	}
	return 0;
}
开发者ID:sillyousu,项目名称:csocks,代码行数:34,代码来源:hashmap_test.c


示例4: TestgetwindowinfoObjCmd

static int
TestgetwindowinfoObjCmd(
    ClientData clientData,
    Tcl_Interp *interp,
    int objc,
    Tcl_Obj *const objv[])
{
    long hwnd;
    Tcl_Obj *dictObj = NULL, *classObj = NULL, *textObj = NULL;
    Tcl_Obj *childrenObj = NULL;
    TCHAR buf[512];
    int cch, cchBuf = 256;

    if (objc != 2) {
	Tcl_WrongNumArgs(interp, 1, objv, "hwnd");
	return TCL_ERROR;
    }

    if (Tcl_GetLongFromObj(interp, objv[1], &hwnd) != TCL_OK)
	return TCL_ERROR;

    cch = GetClassName(INT2PTR(hwnd), buf, cchBuf);
    if (cch == 0) {
    	Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to get class name: ", -1));
    	AppendSystemError(interp, GetLastError());
    	return TCL_ERROR;
    } else {
	Tcl_DString ds;
	Tcl_WinTCharToUtf(buf, -1, &ds);
	classObj = Tcl_NewStringObj(Tcl_DStringValue(&ds), Tcl_DStringLength(&ds));
	Tcl_DStringFree(&ds);
    }

    dictObj = Tcl_NewDictObj();
    Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("class", 5), classObj);
    Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("id", 2),
	Tcl_NewLongObj(GetWindowLongA(INT2PTR(hwnd), GWL_ID)));

    cch = GetWindowText(INT2PTR(hwnd), (LPTSTR)buf, cchBuf);
    textObj = Tcl_NewUnicodeObj((LPCWSTR)buf, cch);

    Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("text", 4), textObj);
    Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("parent", 6),
	Tcl_NewLongObj(PTR2INT(GetParent((INT2PTR(hwnd))))));

    childrenObj = Tcl_NewListObj(0, NULL);
    EnumChildWindows(INT2PTR(hwnd), EnumChildrenProc, (LPARAM)childrenObj);
    Tcl_DictObjPut(interp, dictObj, Tcl_NewStringObj("children", -1), childrenObj);

    Tcl_SetObjResult(interp, dictObj);
    return TCL_OK;
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:52,代码来源:tkWinTest.c


示例5: GetMenuIndicatorGeometry

static void
GetMenuIndicatorGeometry(
    TkMenu *menuPtr,		/* The menu we are drawing. */
    TkMenuEntry *mePtr,		/* The entry we are interested in. */
    Tk_Font tkfont,		/* The precalculated font */
    const Tk_FontMetrics *fmPtr,/* The precalculated metrics */
    int *widthPtr,		/* The resulting width */
    int *heightPtr)		/* The resulting height */
{
    int borderWidth;

    if ((mePtr->type == CHECK_BUTTON_ENTRY)
	    || (mePtr->type == RADIO_BUTTON_ENTRY)) {
	if (!mePtr->hideMargin && mePtr->indicatorOn) {
	    if ((mePtr->image != NULL) || (mePtr->bitmapPtr != NULL)) {
		*widthPtr = (14 * mePtr->height) / 10;
		*heightPtr = mePtr->height;
		if (mePtr->type == CHECK_BUTTON_ENTRY) {
		    mePtr->platformEntryData = (TkMenuPlatformEntryData)
			    INT2PTR((65 * mePtr->height) / 100);
		} else {
		    mePtr->platformEntryData = (TkMenuPlatformEntryData)
			    INT2PTR((75 * mePtr->height) / 100);
		}
	    } else {
		*widthPtr = *heightPtr = mePtr->height;
		if (mePtr->type == CHECK_BUTTON_ENTRY) {
		    mePtr->platformEntryData = (TkMenuPlatformEntryData)
			    INT2PTR((80 * mePtr->height) / 100);
		} else {
		    mePtr->platformEntryData = (TkMenuPlatformEntryData)
			    INT2PTR(mePtr->height);
		}
	    }
	} else {
	    Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
		    &borderWidth);
	    *heightPtr = 0;
	    *widthPtr = borderWidth;
	}
    } else {
	Tk_GetPixelsFromObj(NULL, menuPtr->tkwin, menuPtr->borderWidthPtr,
		&borderWidth);
	*heightPtr = 0;
	*widthPtr = borderWidth;
    }
}
开发者ID:das,项目名称:tcltk,代码行数:47,代码来源:tkUnixMenu.c


示例6: ui_bridge_put

static void ui_bridge_put(UI *b, uint8_t *text, size_t size)
{
  uint8_t *t = NULL;
  if (text) {
    t = xmalloc(sizeof(((UCell *)0)->data));
    memcpy(t, text, size);
  }
  UI_CALL(b, put, 3, b, t, INT2PTR(size));
}
开发者ID:WalkingCookie,项目名称:neovim,代码行数:9,代码来源:ui_bridge.c


示例7: PipeGetHandleProc

static int
PipeGetHandleProc(
    ClientData instanceData,	/* The pipe state. */
    int direction,		/* TCL_READABLE or TCL_WRITABLE */
    ClientData *handlePtr)	/* Where to store the handle. */
{
    PipeState *psPtr = (PipeState *) instanceData;

    if (direction == TCL_READABLE && psPtr->inFile) {
	*handlePtr = (ClientData) INT2PTR(GetFd(psPtr->inFile));
	return TCL_OK;
    }
    if (direction == TCL_WRITABLE && psPtr->outFile) {
	*handlePtr = (ClientData) INT2PTR(GetFd(psPtr->outFile));
	return TCL_OK;
    }
    return TCL_ERROR;
}
开发者ID:LeifAndersen,项目名称:TuxRider,代码行数:18,代码来源:tclUnixPipe.c


示例8: TcpGetHandleProc

	/* ARGSUSED */
static int
TcpGetHandleProc(
    ClientData instanceData,	/* The socket state. */
    int direction,		/* Not used. */
    ClientData *handlePtr)	/* Where to store the handle. */
{
    TcpState *statePtr = instanceData;

    *handlePtr = INT2PTR(statePtr->fds.fd);
    return TCL_OK;
}
开发者ID:AlexShiLucky,项目名称:bitkeeper,代码行数:12,代码来源:tclUnixSock.c


示例9: chat_kickchat

/*==========================================
 * チャットルームから蹴り出す
 *------------------------------------------
 */
void chat_kickchat(struct map_session_data *sd, const char *kickusername)
{
	struct chat_data *cd;
	int i;

	nullpo_retv(sd);

	cd = map_id2cd(sd->chatID);
	if(cd == NULL || &sd->bl != (*cd->owner))
		return;

	for(i = 0; i < cd->users; i++) {
		if(strncmp(cd->usersd[i]->status.name, kickusername, 24) == 0) {
			linkdb_insert(&cd->ban_list, INT2PTR(cd->usersd[i]->status.char_id), INT2PTR(1));
			chat_leavechat(cd->usersd[i], 1);
			break;
		}
	}

	return;
}
开发者ID:AurigaProject,项目名称:root,代码行数:25,代码来源:chat.c


示例10: Tk_GetAtomName

const char *
Tk_GetAtomName(
    Tk_Window tkwin,		/* Window token; map atom to name relative to
				 * this window's display. */
    Atom atom)			/* Atom whose name is wanted. */
{
    TkDisplay *dispPtr;
    Tcl_HashEntry *hPtr;

    dispPtr = ((TkWindow *) tkwin)->dispPtr;
    if (!dispPtr->atomInit) {
	AtomInit(dispPtr);
    }

    hPtr = Tcl_FindHashEntry(&dispPtr->atomTable, INT2PTR(atom));
    if (hPtr == NULL) {
	const char *name;
	Tk_ErrorHandler handler;
	int isNew;
	char *mustFree = NULL;

	handler = Tk_CreateErrorHandler(dispPtr->display, BadAtom, -1, -1,
		NULL, NULL);
	name = mustFree = XGetAtomName(dispPtr->display, atom);
	if (name == NULL) {
	    name = "?bad atom?";
	}
	Tk_DeleteErrorHandler(handler);
	hPtr = Tcl_CreateHashEntry(&dispPtr->nameTable, name, &isNew);
	Tcl_SetHashValue(hPtr, INT2PTR(atom));
	if (mustFree) {
	    XFree(mustFree);
	}
	name = Tcl_GetHashKey(&dispPtr->nameTable, hPtr);
	hPtr = Tcl_CreateHashEntry(&dispPtr->atomTable, INT2PTR(atom), &isNew);
	Tcl_SetHashValue(hPtr, (char *)name);
    }
    return Tcl_GetHashValue(hPtr);
}
开发者ID:tcltk,项目名称:tk,代码行数:39,代码来源:tkAtom.c


示例11: FileGetHandleProc

static int
FileGetHandleProc(
    ClientData instanceData,	/* The file state. */
    int direction,		/* TCL_READABLE or TCL_WRITABLE */
    ClientData *handlePtr)	/* Where to store the handle. */
{
    FileState *fsPtr = instanceData;

    if (direction & fsPtr->validMask) {
	*handlePtr = INT2PTR(fsPtr->fd);
	return TCL_OK;
    }
    return TCL_ERROR;
}
开发者ID:smh377,项目名称:tcl,代码行数:14,代码来源:tclUnixChan.c


示例12: Tcl_CreatePipe

/*
 *----------------------------------------------------------------------
 *
 * Tcl_CreatePipe --
 *
 *	System dependent interface to create a pipe for the [chan pipe]
 *	command. Stolen from TclX.
 *
 * Parameters:
 *   o interp - Errors returned in result.
 *   o rchan, wchan - Returned read and write side.
 *   o flags - Reserved for future use.
 * Results:
 *   TCL_OK or TCL_ERROR.
 *
 *----------------------------------------------------------------------
 */
int
Tcl_CreatePipe(
    Tcl_Interp *interp,
    Tcl_Channel *rchan,
    Tcl_Channel *wchan,
    int flags)
{
    int fileNums[2];

    if (pipe(fileNums) < 0) {
	Tcl_AppendResult(interp, "pipe creation failed: ",
		Tcl_PosixError(interp), NULL);
	return TCL_ERROR;
    }

    *rchan = Tcl_MakeFileChannel((ClientData) INT2PTR(fileNums[0]),
	    TCL_READABLE);
    Tcl_RegisterChannel(interp, *rchan);
    *wchan = Tcl_MakeFileChannel((ClientData) INT2PTR(fileNums[1]),
	    TCL_WRITABLE);
    Tcl_RegisterChannel(interp, *wchan);

    return TCL_OK;
}
开发者ID:LeifAndersen,项目名称:TuxRider,代码行数:41,代码来源:tclUnixPipe.c


示例13: AsmInstructionArgvSet

/*
 *----------------------------------------------------------------------
 * AsmInstructionArgvSet --
 *
 *    Set argument to be passed to an instruction of the assemble
 *    code.
 *
 *----------------------------------------------------------------------
 */
static void 
AsmInstructionArgvSet(Tcl_Interp *interp, int from, int to, int currentArg,
	       AsmInstruction *inst, AsmCompiledProc *asmProc,
	       Tcl_Obj **wordOv, int verbose) {
  int j;

  for (j = from; j < to; j += 2, currentArg++) {
    int argIndex, intValue;
	  
    Tcl_GetIndexFromObj(interp, wordOv[j], asmStatementArgType, "asm cmd arg type", 0, &argIndex);
    Tcl_GetIntFromObj(interp, wordOv[j+1], &intValue);

    if (verbose != 0) {
      fprintf(stderr, "AsmInstructionArgvSet (type %d) arg[%d] := %s[%s]\n", 
	      argIndex, currentArg, ObjStr(wordOv[j]), ObjStr(wordOv[j+1]));
    }
	  
    switch (argIndex) {
    case asmStatementArgTypeObjIdx: 
      inst->argv[currentArg] = asmProc->slots[intValue];
      break;
	    
    case asmStatementArgTypeArgIdx:
      AsmArgSet(asmProc, intValue, &inst->argv[currentArg]);
      break;
	    
    case asmStatementArgTypeResultIdx: 
      inst->argv[currentArg] = NULL;
      break;

    case asmStatementArgTypeSlotIdx:
    case asmStatementArgTypeInstructionIdx:
    case asmStatementArgTypeIntIdx:
      inst->argv[currentArg] = INT2PTR(intValue);
      break;

    case asmStatementArgTypeVarIdx:
      fprintf(stderr, ".... var set [%d] = %s\n", currentArg, ObjStr(wordOv[j+1]));
      inst->argv[currentArg] = wordOv[j+1];
      Tcl_IncrRefCount(inst->argv[currentArg]); // TODO: DECR missing
      break;

    }
    /*fprintf(stderr, "[%d] inst %p name %s arg[%d] %s\n", currentAsmInstruction,
      inst, ObjStr(inst->argv[0]), currentArg, 
      inst->argv[currentArg] ? ObjStr(inst->argv[currentArg]) : "NULL");*/
  }
}
开发者ID:mrcalvin,项目名称:nsf,代码行数:57,代码来源:nsfAssemble.c


示例14: rdpAllocatePixmapPrivate

rdpDevPrivateKey
rdpAllocatePixmapPrivate(ScreenPtr pScreen, int bytes)
{
    rdpDevPrivateKey rv;

#if XRDP_PRI == 1
    rv = INT2PTR(AllocatePixmapPrivateIndex());
    AllocatePixmapPrivate(pScreen, PTR2INT(rv), bytes);
#elif XRDP_PRI == 2
    dixRequestPrivate(&g_privateKeyRecPixmap, bytes);
    rv = &g_privateKeyRecPixmap;
#else
    dixRegisterPrivateKey(&g_privateKeyRecPixmap, PRIVATE_PIXMAP, bytes);
    rv = &g_privateKeyRecPixmap;
#endif
    return rv;
}
开发者ID:Hanchao-Wang,项目名称:xrdp,代码行数:17,代码来源:rdpPri.c


示例15: centernode_connect

//Connect to the remote host
cnaccess_t * centernode_connect (centernode_t *cn, const char *host, uint16_t port, 
        cnaccess_t *a, int type, int isp)
{
    int fd = 0;
    struct sockaddr_in server;

    if ((fd = socket(PF_INET, SOCK_STREAM, 0)) == -1) 
    {
#ifdef CDNDEBUG
        LOG("ER", "create sock-(%d)%s.\n", errno, strerror(errno));
#endif
        return 0;
    }
    //nonblocking connect call
    fcntl(fd, F_SETFL, O_NONBLOCK | fcntl(fd, F_GETFL, 0));
    memset((uint8_t *)&server, 0, sizeof(server));
    server.sin_family = PF_INET;
    server.sin_port = htons(port);
    server.sin_addr.s_addr = inet_addr(host);
    int r = connect(fd, (struct sockaddr *) &server, sizeof(server));
    if (r == -1  &&  errno != EINPROGRESS) 
    {
#ifdef CDNDEBUG
        LOG("ER", "conn to %s.%d-(%d)%s.\n", host, port, errno, strerror(errno));
#endif
        return (close(fd), NULL);
    }
    cnaccess_t *ca = a;
    if (ca) { /* reconnect */
        ca->fd = fd; 
        ca->interaction = time(0);
        strncpy(ca->host,host,strlen(host));
        ca->port = port;    
    } else ca = cnaccess_create(cn, fd, host, port, type, isp);
    if (r == -1 && ++ca->retry > 4)
        ca->retry = 1;
    ca->status = r ? NS_CONNECTING: NS_NORMAL;
    printf("cat %d\n", ca->status);
    pthread_mutex_lock(&cn->objlock), /* add it to sesstion table */
        gdsl_hash_insert(cn->accesses, ca);
    pthread_mutex_unlock(&cn->objlock);
    pthread_mutex_lock(&cn->reglock), /* register it to libevent */
        gdsl_queue_insert(cn->registration, INT2PTR(ca->fd)),
        pthread_mutex_unlock(&cn->reglock);
    return ca;
}
开发者ID:RinCelery,项目名称:hdyt.com,代码行数:47,代码来源:centernode.c


示例16: rdpAllocateWindowPrivate

rdpDevPrivateKey
rdpAllocateWindowPrivate(ScreenPtr pScreen, int bytes)
{
    rdpDevPrivateKey rv;

#if XRDP_PRI == 1
    rv = INT2PTR(AllocateWindowPrivateIndex());
    AllocateWindowPrivate(pScreen, PTR2INT(rv), bytes);
#elif XRDP_PRI == 2
    dixRequestPrivate(&g_privateKeyRecWindow, bytes);
    rv = &g_privateKeyRecWindow;
#else
    dixRegisterPrivateKey(&g_privateKeyRecWindow, PRIVATE_WINDOW, bytes);
    rv = &g_privateKeyRecWindow;
#endif
    return rv;
}
开发者ID:Hanchao-Wang,项目名称:xrdp,代码行数:17,代码来源:rdpPri.c


示例17: centernode_server

//create TCP server
cnaccess_t * centernode_server (centernode_t *cn, const char *host, uint16_t port, uint32_t type, int isp)
{
    int fd = 0;
    struct sockaddr_in self;
    printf("Host %s port %u\n", host, port);
    //Create listen socket
    if ((fd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
    {
#ifdef CDNDEBUG
        LOG("WR", "ct sock(%d)%s.\n", errno, strerror(errno));
#endif
        return 0;
    }
    memset((uint8_t *)&self, 0, sizeof(self));
    self.sin_family = PF_INET;
    self.sin_port = htons(port);
    self.sin_addr.s_addr = inet_addr(host);
    int val = 1;
    if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&val, sizeof(val)) == -1)
    {
#ifdef CDNDEBUG
        LOG("WR", "set SO_REUSEADDR option - (%d) %s.\n", errno, strerror(errno));
#endif
        return (close(fd), NULL);
    }
    if (bind(fd, (struct sockaddr *)&self, sizeof(self)) == -1)
    {
#ifdef CDNDEBUG
        LOG("WR", "bind the address %s.%d - (%d) %s.\n", host, port, 
                errno, strerror(errno));
#endif
        return (close(fd), NULL);
    }
    if (listen(fd, 200) < 0)
    {
#ifdef CDNDEBUG
        LOG("WR", "listen on %s.%d - (%d) %s.\n", host, port, errno, strerror(errno));
#endif
        return (close(fd), NULL);
    }
    cnaccess_t *ca = cnaccess_create(cn, fd, host, port, type, isp);
    gdsl_hash_insert(cn->accesses, ca);
    gdsl_queue_insert(cn->registration, INT2PTR(ca->fd));
    return ca;
}
开发者ID:RinCelery,项目名称:hdyt.com,代码行数:46,代码来源:centernode.c


示例18: srl_path_set

void
srl_path_set(pTHX_ srl_path_t *path, SV *src)
{
    path->expr = NULL;
    CLEAR_RESULTS(path);
    CLEAR_ITERATOR(path);

    if (sv_isobject(src) && sv_isa(src, "Sereal::Path::Iterator")) {
        path->iter = INT2PTR(srl_iterator_ptr, SvIV((SV*) SvRV(src)));
        path->i_own_iterator = 0;
    } else if (SvPOK(src)) {
        path->iter = srl_build_iterator_struct(aTHX_ NULL);
        path->i_own_iterator = 1;
        srl_iterator_set(aTHX_ path->iter, src);
    } else {
        croak("Sereal::Path: input should be either Sereal::Path::Iterator object or encoded Sereal document");
    }
}
开发者ID:ab5tract,项目名称:Sereal,代码行数:18,代码来源:srl_path.c


示例19: TclCreateAbsoluteTimerHandler

Tcl_TimerToken
TclCreateAbsoluteTimerHandler(
    Tcl_Time *timePtr,
    Tcl_TimerProc *proc,
    ClientData clientData)
{
    register TimerHandler *timerHandlerPtr, *tPtr2, *prevPtr;
    ThreadSpecificData *tsdPtr;

    tsdPtr = InitTimer();
    timerHandlerPtr = (TimerHandler *) ckalloc(sizeof(TimerHandler));

    /*
     * Fill in fields for the event.
     */

    memcpy((void *)&timerHandlerPtr->time, (void *)timePtr, sizeof(Tcl_Time));
    timerHandlerPtr->proc = proc;
    timerHandlerPtr->clientData = clientData;
    tsdPtr->lastTimerId++;
    timerHandlerPtr->token = (Tcl_TimerToken) INT2PTR(tsdPtr->lastTimerId);

    /*
     * Add the event to the queue in the correct position
     * (ordered by event firing time).
     */

    for (tPtr2 = tsdPtr->firstTimerHandlerPtr, prevPtr = NULL; tPtr2 != NULL;
	    prevPtr = tPtr2, tPtr2 = tPtr2->nextPtr) {
	if (TCL_TIME_BEFORE(timerHandlerPtr->time, tPtr2->time)) {
	    break;
	}
    }
    timerHandlerPtr->nextPtr = tPtr2;
    if (prevPtr == NULL) {
	tsdPtr->firstTimerHandlerPtr = timerHandlerPtr;
    } else {
	prevPtr->nextPtr = timerHandlerPtr;
    }

    TimerSetupProc(NULL, TCL_ALL_EVENTS);

    return timerHandlerPtr->token;
}
开发者ID:aosm,项目名称:tcl,代码行数:44,代码来源:tclTimer.c


示例20: Tcl_MakeFileChannel

Tcl_Channel
Tcl_MakeFileChannel(
    ClientData handle,		/* OS level handle. */
    int mode)			/* ORed combination of TCL_READABLE and
				 * TCL_WRITABLE to indicate file mode. */
{
    FileState *fsPtr;
    char channelName[16 + TCL_INTEGER_SPACE];
    int fd = PTR2INT(handle);
    const Tcl_ChannelType *channelTypePtr;
    struct sockaddr sockaddr;
    socklen_t sockaddrLen = sizeof(sockaddr);

    if (mode == 0) {
	return NULL;
    }

    sockaddr.sa_family = AF_UNSPEC;

#ifdef SUPPORTS_TTY
    if (isatty(fd)) {
	channelTypePtr = &ttyChannelType;
	sprintf(channelName, "serial%d", fd);
    } else
#endif /* SUPPORTS_TTY */
    if ((getsockname(fd, (struct sockaddr *)&sockaddr, &sockaddrLen) == 0)
	&& (sockaddrLen > 0)
	&& (sockaddr.sa_family == AF_INET || sockaddr.sa_family == AF_INET6)) {
	return TclpMakeTcpClientChannelMode(INT2PTR(fd), mode);
    } else {
	channelTypePtr = &fileChannelType;
	sprintf(channelName, "file%d", fd);
    }

    fsPtr = ckalloc(sizeof(FileState));
    fsPtr->fd = fd;
    fsPtr->validMask = mode | TCL_EXCEPTION;
    fsPtr->channel = Tcl_CreateChannel(channelTypePtr, channelName,
	    fsPtr, mode);

    return fsPtr->channel;
}
开发者ID:smh377,项目名称:tcl,代码行数:42,代码来源:tclUnixChan.c



注:本文中的INT2PTR函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ INT32_C函数代码示例发布时间:2022-05-30
下一篇:
C++ INT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap