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

C++ GetConsoleMode函数代码示例

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

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



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

示例1: rtStrmIsConsoleUnlocked

/**
 * Check if the stream is for a Window console.
 *
 * @returns true / false.
 * @param   pStream             The stream.
 * @param   phCon               Where to return the console handle.
 */
static bool rtStrmIsConsoleUnlocked(PRTSTREAM pStream, HANDLE *phCon)
{
    int fh = fileno(pStream->pFile);
    if (isatty(fh))
    {
        DWORD dwMode;
        HANDLE hCon = (HANDLE)_get_osfhandle(fh);
        if (GetConsoleMode(hCon, &dwMode))
        {
            *phCon = hCon;
            return true;
        }
    }
    return false;
}
开发者ID:eaas-framework,项目名称:virtualbox,代码行数:22,代码来源:stream.cpp


示例2: win_get_console_mode

CAMLprim value win_get_console_mode (value unit)
{
  DWORD mode;
  BOOL res;

  init_conin ();

  res = GetConsoleMode (conin, &mode);
  if (res == 0) {
    win32_maperr (GetLastError ());
    uerror("get_console_mode", Nothing);
  }

  return (Val_int (mode));
}
开发者ID:Phylliade,项目名称:Unison,代码行数:15,代码来源:system_win_stubs.c


示例3: SetFileApisToOEM

void TThreads::resume() {
   if (!inited) {
      SetFileApisToOEM();
      chandle[cnInput]  = GetStdHandle(STD_INPUT_HANDLE);
      chandle[cnOutput] = GetStdHandle(STD_OUTPUT_HANDLE);
      GetConsoleCursorInfo(chandle[cnOutput], &crInfo);
      GetConsoleScreenBufferInfo(chandle[cnOutput], &sbInfo);
      GetConsoleMode(chandle[cnInput],&consoleMode);
      consoleMode &= ~(ENABLE_LINE_INPUT|ENABLE_ECHO_INPUT|ENABLE_WINDOW_INPUT);
      SetConsoleMode(chandle[cnInput],consoleMode);

      evpending = 0;
      inited = 1;
   }
}
开发者ID:OS2World,项目名称:SYSTEM-LOADER-QSINIT,代码行数:15,代码来源:os2handl.cpp


示例4: OnPeekConsoleInputA

BOOL WINAPI OnPeekConsoleInputA(HANDLE hConsoleInput, PINPUT_RECORD lpBuffer, DWORD nLength, LPDWORD lpNumberOfEventsRead)
{
	//typedef BOOL (WINAPI* OnPeekConsoleInputA_t)(HANDLE,PINPUT_RECORD,DWORD,LPDWORD);
	SUPPRESSORIGINALSHOWCALL;
	ORIGINAL_KRNL(PeekConsoleInputA);
	//if (gpFarInfo && bMainThread)
	//	TouchReadPeekConsoleInputs(1);
	BOOL lbRc = FALSE;

	if (ph && ph->PreCallBack)
	{
		SETARGS4(&lbRc,hConsoleInput,lpBuffer,nLength,lpNumberOfEventsRead);

		// Если функция возвращает FALSE - реальное чтение не будет вызвано
		if (!ph->PreCallBack(&args))
			return lbRc;
	}

	PreReadConsoleInput(hConsoleInput, rcif_Ansi|rcif_Peek|rcif_LLInput);

	//#ifdef USE_INPUT_SEMAPHORE
	//DWORD nSemaphore = ghConInSemaphore ? WaitForSingleObject(ghConInSemaphore, INSEMTIMEOUT_READ) : 1;
	//_ASSERTE(nSemaphore<=1);
	//#endif

#if 0
	DWORD nMode = 0; GetConsoleMode(hConsoleInput, &nMode);
#endif

	lbRc = F(PeekConsoleInputA)(hConsoleInput, lpBuffer, nLength, lpNumberOfEventsRead);

	PostReadConsoleInput(hConsoleInput, rcif_Ansi|rcif_Peek|rcif_LLInput);

	//#ifdef USE_INPUT_SEMAPHORE
	//if ((nSemaphore == WAIT_OBJECT_0) && ghConInSemaphore) ReleaseSemaphore(ghConInSemaphore, 1, NULL);
	//#endif

	if (ph && ph->PostCallBack)
	{
		SETARGS4(&lbRc,hConsoleInput,lpBuffer,nLength,lpNumberOfEventsRead);
		ph->PostCallBack(&args);
	}

	if (lbRc && lpNumberOfEventsRead && *lpNumberOfEventsRead && lpBuffer)
		OnPeekReadConsoleInput('P', 'A', hConsoleInput, lpBuffer, *lpNumberOfEventsRead);

	return lbRc;
}
开发者ID:1833183060,项目名称:ConEmu,代码行数:48,代码来源:hkConsoleInput.cpp


示例5: CON_Init

/*
==================
CON_Init
==================
*/
void CON_Init( void )
{
	CONSOLE_CURSOR_INFO        curs;
	CONSOLE_SCREEN_BUFFER_INFO info;
	int                        i;

	// handle Ctrl-C or other console termination
	SetConsoleCtrlHandler( CON_CtrlHandler, TRUE );

	qconsole_hin = GetStdHandle( STD_INPUT_HANDLE );

	if ( qconsole_hin == INVALID_HANDLE_VALUE )
	{
		return;
	}

	qconsole_hout = GetStdHandle( STD_OUTPUT_HANDLE );

	if ( qconsole_hout == INVALID_HANDLE_VALUE )
	{
		return;
	}

	GetConsoleMode( qconsole_hin, &qconsole_orig_mode );

	// allow mouse wheel scrolling
	SetConsoleMode( qconsole_hin,
	                qconsole_orig_mode & ~ENABLE_MOUSE_INPUT );

	FlushConsoleInputBuffer( qconsole_hin );

	GetConsoleScreenBufferInfo( qconsole_hout, &info );
	qconsole_attrib = info.wAttributes;

	SetConsoleTitle( "Daemon Console" );

	// make cursor invisible
	GetConsoleCursorInfo( qconsole_hout, &qconsole_orig_cursorinfo );
	curs.dwSize = 1;
	curs.bVisible = FALSE;
	SetConsoleCursorInfo( qconsole_hout, &curs );

	// initialize history
	for ( i = 0; i < QCONSOLE_HISTORY; i++ )
	{
		qconsole_history[ i ][ 0 ] = '\0';
	}
}
开发者ID:Sixthly,项目名称:Unvanquished,代码行数:53,代码来源:con_win32.c


示例6: disable_quick_edit

static void
disable_quick_edit(void)
{
    DWORD mode = 0;
    HANDLE console = GetStdHandle(STD_INPUT_HANDLE);

    // Get current console mode
    if (console == NULL || !GetConsoleMode(console, &mode)) {
        return;
    }

    // Clear the quick edit bit in the mode flags
    mode &= ~ENABLE_QUICK_EDIT;
    mode |= ENABLE_EXTENDED_FLAGS;
    SetConsoleMode(console, mode);
}
开发者ID:SChen5-Quest,项目名称:simple-obfs,代码行数:16,代码来源:win32.c


示例7: GetStdHandle

ConsoleMedia::ConsoleMedia()
{
    m_bRedirectedToFile = true;

    m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
    if (m_hConsole == NULL)
    {
        if (!AllocConsole() //|| !SetConsoleTitle(_T("Log"))
            || (m_hConsole = GetStdHandle(STD_OUTPUT_HANDLE)) == NULL)
            return;
    }
    GetConsoleScreenBufferInfo(m_hConsole, &m_info);

    DWORD t;
    m_bRedirectedToFile = GetConsoleMode(m_hConsole, &t) == FALSE;
}
开发者ID:Blonder,项目名称:TortoiseGit,代码行数:16,代码来源:log.cpp


示例8: alloc_console

void alloc_console() {
	CONSOLE_SCREEN_BUFFER_INFO coninfo;
	HANDLE hStdin = GetStdHandle (STD_INPUT_HANDLE);
	DWORD lpMode;

	AllocConsole ();
	GetConsoleMode (hStdin, &lpMode);
	SetConsoleMode (hStdin, lpMode & (~ENABLE_MOUSE_INPUT | ENABLE_PROCESSED_INPUT));
	GetConsoleScreenBufferInfo (hStdin, &coninfo);
	coninfo.dwSize.Y = 4096;
	SetConsoleScreenBufferSize (hStdin, coninfo.dwSize);

	freopen ("conin$", "r", stdin);
	freopen ("conout$", "w", stdout);
	freopen ("conout$", "w", stderr);
}
开发者ID:aronsky,项目名称:radare2,代码行数:16,代码来源:libr2.c


示例9: GetConsoleWindow

void console_widget_NT_t::init_new_console()
{	
	allocated_console = false;

	saved_hwnd = GetConsoleWindow();
	if (saved_hwnd == (HWND)0) {
		AllocConsole();
		allocated_console = true;
		saved_hwnd = GetConsoleWindow();
	}

	saved_input = GetStdHandle(STD_INPUT_HANDLE);
	saved_output = GetStdHandle(STD_OUTPUT_HANDLE);
	GetConsoleCursorInfo(saved_output, &saved_cursor);
	GetConsoleMode(saved_input, &saved_mode);
}
开发者ID:matt81093,项目名称:Original-Colinux,代码行数:16,代码来源:widget.cpp


示例10: rktio_system_fd_is_terminal

int rktio_system_fd_is_terminal(rktio_t *rktio, intptr_t fd)
{
#ifdef RKTIO_SYSTEM_UNIX
  return isatty(fd);
#endif
#ifdef RKTIO_SYSTEM_WINDOWS
  if (GetFileType((HANDLE)fd) == FILE_TYPE_CHAR) {
    DWORD mode;
    if (GetConsoleMode((HANDLE)fd, &mode))
      return 1;
    else
      return 0;
  } else
    return 0;
#endif
}
开发者ID:97jaz,项目名称:racket,代码行数:16,代码来源:rktio_fd.c


示例11: SLMprintf

int
SLMprintf(
    WCHAR *szformat, ...)
{
    va_list marker;
    int iret = 0;
    int count;
    long cbWritten;
    DWORD dwMode;

    va_start(marker, szformat);
    count = vswprintf(szText, szformat, marker);

    if (!bUnicode) {
        memset (chBuf, 0, sizeof(chBuf));
#ifdef _WIN32
        WideCharToMultiByte (CP_ACP, 0, szText, count, chBuf, sizeof(chBuf), NULL, NULL);
#else
        wcstombs (chBuf, szText, sizeof(chBuf));
#endif
        iret = printf("%s", chBuf);
        if (fCkSum)
            CheckSum(chBuf, strlen(chBuf));
    }
    else {
#ifdef _WIN32
        if (GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdout)), &dwMode)) {
            WriteConsoleW ((HANDLE)_get_osfhandle(_fileno(stdout)),
                           szText,
                           count,
                           &cbWritten,
                           NULL);
            iret = cbWritten;
        }
        else
            iret = wprintf(szText);
#else
        iret = wprintf(szText);
#endif
        if (fCkSum)
            CheckSum((char *)szText, wcslen(szText) * sizeof(WCHAR));
    }

    va_end(marker);

    return (iret);
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:47,代码来源:slmdiff.c


示例12: csync_getpass

int csync_getpass(const char *prompt,
                char *buf,
                size_t len,
                int echo,
                int verify,
                void *userdata
               ) {
    /* unused variables */
    (void) userdata;

    HANDLE h;
    DWORD mode = 0;
    int ok;

    /* fgets needs at least len - 1 */
    if (prompt == NULL || buf == NULL || len < 2) {
        return -1;
    }

    /* get stdin and mode */
    h = GetStdHandle(STD_INPUT_HANDLE);
    if (!GetConsoleMode(h, &mode)) {
        return -1;
    }

    /* disable echo */
    if (!echo) {
        if (!SetConsoleMode(h, mode & ~ENABLE_ECHO_INPUT)) {
            return -1;
        }
    }

    ok = csync_gets(prompt, buf, len, verify);

    /* reset echo */
    SetConsoleMode(h, mode);

    if (!ok) {
        memset (buf, '\0', len);
        return -1;
    }

    /* force termination */
    buf[len - 1] = '\0';

    return 0;
}
开发者ID:OpenDataSpace,项目名称:ocsync,代码行数:47,代码来源:csync_auth.c


示例13: ChangeMode

/* ************************************
* VOID ChangeMode( HANDLE hStdin, HANDLE hStdout)
* 功能	改变控制台的模式,关闭ENABLE_LINE_INPUT和ENABLE_ECHO_INPUT
* 参数	HANDLE hStdin, HANDLE hStdout,句柄
**************************************/
VOID ChangeMode( HANDLE hStdin, HANDLE hStdout)
{
		LPSTR lpszPrompt = "Mode changeed Type any key, or q to quit: ";
		CHAR chBuffer[256];

	DWORD fdwMode, fdwOldMode;
	DWORD cRead,cWritten;
	// 获取当前模式
	if (! GetConsoleMode(hStdin, &fdwOldMode)) 
	{
		MessageBox(NULL, "GetConsoleMode", "Console Error", MB_OK); 
		return;
	}
	// 修改模式并重新设置
	fdwMode = fdwOldMode & 
		~(ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT); 
	if (! SetConsoleMode(hStdin, fdwMode)) 
	{
		MessageBox(NULL, "SetConsoleMode", "Console Error", MB_OK); 
		return;
	}
	// 换行
	NewLine();
	// 循环等待输入并处理
	while (1) 
	{ 
		if (! WriteFile( hStdout, 
			lpszPrompt,  lstrlen(lpszPrompt), 
			&cWritten, NULL) )
		{
			MyErrorExit("WriteFile");
			return;
		}

		if (! ReadFile(hStdin, chBuffer, 1, &cRead, NULL)) 
			break; 
		if (chBuffer[0] == '\r')
			NewLine();
		else if (! WriteFile(hStdout, chBuffer, cRead, 
			&cWritten, NULL)) break;
		else
			NewLine();
		if (chBuffer[0] == 'q') break; // 输入q,退出 
	} 
	// 恢复模式
	SetConsoleMode(hStdin, fdwOldMode);
}
开发者ID:Trietptm-on-Coding-Algorithms,项目名称:CodeLibrary,代码行数:52,代码来源:Console.c


示例14: r_line_new

R_API RCons *r_cons_new () {
	I.line = r_line_new ();
	I.event_interrupt = NULL;
	I.blankline = R_TRUE;
	I.heightfix = 0;
	I.widthfix = 0;
	I.event_resize = NULL;
	I.data = NULL;
	I.event_data = NULL;
	I.is_interactive = R_TRUE;
	I.noflush = R_FALSE;
	I.force_rows = 0;
	I.force_columns = 0;
	I.fdin = stdin;
	I.fdout = 1;
	I.breaked = R_FALSE;
	//I.lines = 0;
	I.buffer = NULL;
	I.buffer_sz = 0;
	I.buffer_len = 0;
	r_cons_get_size (NULL);
	I.num = NULL;
#if EMSCRIPTEN
	/* do nothing here :? */
#elif __UNIX__
	tcgetattr (0, &I.term_buf);
	memcpy (&I.term_raw, &I.term_buf, sizeof (I.term_raw));
	I.term_raw.c_iflag &= ~(BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
	I.term_raw.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
	I.term_raw.c_cflag &= ~(CSIZE|PARENB);
	I.term_raw.c_cflag |= CS8;
	I.term_raw.c_cc[VMIN] = 1; // Solaris stuff hehe
	signal (SIGWINCH, resize);
#elif __WINDOWS__
	h = GetStdHandle (STD_INPUT_HANDLE);
	GetConsoleMode (h, (PDWORD) &I.term_buf);
	I.term_raw = 0;
	if (!SetConsoleCtrlHandler ((PHANDLER_ROUTINE)__w32_control, TRUE))
		eprintf ("r_cons: Cannot set control console handler\n");
#endif
	I.pager = NULL; /* no pager by default */
	I.truecolor = 0;
	r_cons_pal_init (NULL);
	r_cons_rgb_init ();
	r_cons_reset ();
	return &I;
}
开发者ID:sstjohn,项目名称:radare2,代码行数:47,代码来源:cons.c


示例15: isatty

/* MS runtime's isatty returns non-zero for any character device,
   including the null device, which is not what we want.  */
int
isatty (int fd)
{
  HANDLE fh = (HANDLE) _get_osfhandle (fd);
  DWORD con_mode;

  if (fh == INVALID_HANDLE_VALUE)
    {
      errno = EBADF;
      return 0;
    }
  if (GetConsoleMode (fh, &con_mode))
    return 1;

  errno = ENOTTY;
  return 0;
}
开发者ID:mirror,项目名称:make,代码行数:19,代码来源:posixfcn.c


示例16: GetStdHandle

JNIEXPORT jint JNICALL Java_jline_WindowsTerminal_getConsoleMode
  (JNIEnv *env, jobject ob)
{
	DWORD mode;
	HANDLE hConsole = GetStdHandle (STD_INPUT_HANDLE);

	if (hConsole == INVALID_HANDLE_VALUE)
		return -1;

	if (!GetConsoleMode (hConsole, &mode))
		return -1;

	// CloseHandle (hConsole);

	// printf ("JNI get mode=%d\n", mode);
	return mode;
}
开发者ID:ChrisWongAtCUHK,项目名称:java,代码行数:17,代码来源:jline_WindowsTerminal.c


示例17: getpass

char *
getpass (const char * prompt)
{
  static char input[256];
  HANDLE in;
  HANDLE err;
  DWORD  count;

  in = GetStdHandle (STD_INPUT_HANDLE);
  err = GetStdHandle (STD_ERROR_HANDLE);

  if (in == INVALID_HANDLE_VALUE || err == INVALID_HANDLE_VALUE)
    return NULL;

  if (WriteFile (err, prompt, strlen (prompt), &count, NULL))
    {
      int istty = (GetFileType (in) == FILE_TYPE_CHAR);
      DWORD old_flags;
      int rc;

      if (istty)
	{
	  if (GetConsoleMode (in, &old_flags))
	    SetConsoleMode (in, ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
	  else
	    istty = 0;
	}
      rc = ReadFile (in, input, sizeof (input), &count, NULL);
      if (count >= 2 && input[count - 2] == '\r')
	input[count - 2] = '\0';
      else
	{
	  char buf[256];
	  while (ReadFile (in, buf, sizeof (buf), &count, NULL) > 0)
	    if (count >= 2 && buf[count - 2] == '\r')
	      break;
	}
      WriteFile (err, "\r\n", 2, &count, NULL);
      if (istty)
	SetConsoleMode (in, old_flags);
      if (rc)
	return input;
    }

  return NULL;
}
开发者ID:unofficial-opensource-apple,项目名称:emacs,代码行数:46,代码来源:ntlib.c


示例18: SLMprintfLn

int
SLMprintfLn(
    WCHAR *szLine)
{
    long cbWritten;
    WORD count;
    BYTE *lpBuf;
    DWORD dwMode;

    count = wcslen(szLine);

    if (!bUnicode) {
        lpBuf = pvAllocMem (count + 50);
        memset (lpBuf, 0, count + 50);
#ifdef _WIN32
        WideCharToMultiByte (CP_ACP, 0, szLine, count, lpBuf, count + 50, NULL, NULL);
#else
        wcstombs (lpBuf, szLine, count + 50);
#endif
        count = printf("%s", lpBuf);

        if (fCkSum)
            CheckSum(lpBuf, strlen(lpBuf));

        FreeMem (lpBuf);

        return (count);
    }
    else {
        if (fCkSum)
            CheckSum((char *)szLine, count * sizeof(WCHAR));

#ifdef _WIN32
        if (GetConsoleMode((HANDLE)_get_osfhandle(_fileno(stdout)), &dwMode))
            return (WriteConsoleW ((HANDLE)_get_osfhandle(_fileno(stdout)),
                                   szLine,
                                   wcslen(szLine),
                                   &cbWritten,
                                   NULL));
        else
            return (wprintf(L"%s", szLine));
#else
        return (wprintf(L"%s", szLine));
#endif
    }
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:46,代码来源:slmdiff.c


示例19: GetStdHandle

JNIEXPORT jint JNICALL Java_org_trafodion_ci_WCIUtils_getConsoleMode
   (JNIEnv *env, jobject ob)
{
   DWORD mode;
   HANDLE hConsole = GetStdHandle (STD_INPUT_HANDLE);

   if (hConsole == INVALID_HANDLE_VALUE)
      return -1;

   if (!GetConsoleMode (hConsole, &mode))
      return -1;

   // CloseHandle (hConsole);
   //printf ("JNI get mode=%d\n", mode);

   return mode;
}
开发者ID:AlexPeng19,项目名称:incubator-trafodion,代码行数:17,代码来源:CIUtils.cpp


示例20: enableRawMode

static int enableRawMode(int fd) {
#ifdef _WIN32
    if (!console_in) {
        console_in = GetStdHandle(STD_INPUT_HANDLE);
        console_out = GetStdHandle(STD_OUTPUT_HANDLE);

        GetConsoleMode(console_in, &oldMode);
        SetConsoleMode(console_in, oldMode & ~(ENABLE_LINE_INPUT | ENABLE_LINE_INPUT));
    }
    return 0;
#else
    struct termios raw;

    if (!isatty(STDIN_FILENO)) goto fatal;
    if (!atexit_registered) {
        atexit(linenoiseAtExit);
        atexit_registered = 1;
    }
    if (tcgetattr(fd,&orig_termios) == -1) goto fatal;

    raw = orig_termios;  /* modify the original mode */
    /* input modes: no break, no CR to NL, no parity check, no strip char,
     * no start/stop output control. */
    raw.c_iflag &= ~(BRKINT | ICRNL | INPCK | ISTRIP | IXON);
    /* output modes - disable post processing */
    raw.c_oflag &= ~(OPOST);
    /* control modes - set 8 bit chars */
    raw.c_cflag |= (CS8);
    /* local modes - choing off, canonical off, no extended functions,
     * no signal chars (^Z,^C) */
    raw.c_lflag &= ~(ECHO | ICANON | IEXTEN | ISIG);
    /* control chars - set return condition: min number of bytes and timer.
     * We want read to return every single byte, without timeout. */
    raw.c_cc[VMIN] = 1; raw.c_cc[VTIME] = 0; /* 1 byte, no timer */

    /* put terminal in raw mode after flushing */
    if (tcsetattr(fd,TCSAFLUSH,&raw) < 0) goto fatal;
    rawmode = 1;
    return 0;

fatal:
    errno = ENOTTY;
    return -1;
#endif
}
开发者ID:DumaGit,项目名称:mongo,代码行数:45,代码来源:linenoise.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ GetConsoleOutputCP函数代码示例发布时间:2022-05-30
下一篇:
C++ GetConsoleCursorInfo函数代码示例发布时间: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