input에서 http 또는 https 링크를 찾아서 a tag를 붙여주는 python script
import re
re_href= re.compile('(\b(http|https)://([-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]))')
output = re_href.sub(r'<a href="\1" target="_self">\1</a>', input)
input에서 http 또는 https 링크를 찾아서 a tag를 붙여주는 python script
import re
re_href= re.compile('(\b(http|https)://([-A-Za-z0-9+&@#/%?=~_()|!:,.;]*[-A-Za-z0-9+&@#/%=~_()|]))')
output = re_href.sub(r'<a href="\1" target="_self">\1</a>', input)
int WINAPI _tWinMain(HINSTANCE hinstExe, HINSTANCE, PTSTR pszCmdLine, int) {
// Create our events for event logging notification as well as our event for ending the notification thread
g_evtNewEventLogRecord = CreateEvent(NULL, TRUE, FALSE, NULL);
HANDLE hThread = chBEGINTHREADEX(NULL, 0, EventNotifyThread, NULL, 0, NULL);
DialogBox(hinstExe, MAKEINTRESOURCE(IDD_EVENTMONITOR), NULL, Dlg_Proc);
// Clean up
QueueUserAPC(DoNothingAPC, hThread, NULL);
WaitForSingleObject(hThread, INFINITE);
CloseHandle(g_evtNewEventLogRecord);
CloseHandle(hThread);
return(0);
}
///////////////////////////////////////////////////////////////////////////////
DWORD WINAPI EventNotifyThread(PVOID pvParam) {
// Note that this is not the thread that called NotifyChangeEventLog.
// The main thread does this in response to the WM_INITDIALOG message.
// If the main thread were to terminate before this thread, then
// notifications would cease to function. However, since it will always
// terminate after this thread, then we can count on the notification event
// working properly.
// Wait for an event notification or for APC altering this thread to termiante.
while (WaitForSingleObjectEx(g_evtNewEventLogRecord, INFINITE, TRUE) != WAIT_IO_COMPLETION) {
FORWARD_WM_USERNOTIFYUPDATE(g_hwnd, PostMessage);
}
// We got an APC, this thread should terminate
return(0);
}
DWORD dwConnectionTypes;
if(InternetGetConnectedState(&dwConnectionTypes, 0)) // 정상적으로 검사됨
{
if((dwConnectionTypes & INTERNET_CONNECTION_MODEM) != 0)
printf("Internet connection using modem");
if((dwConnectionTypes & INTERNET_CONNECTION_LAN) != 0)
printf("Internet connection using LAN");
if((dwConnectionTypes & INTERNET_CONNECTION_PROXY) != 0)
printf("Internet connection using Proxy");
if((dwConnectionTypes & INTERNET_CONNECTION_MODEM_BUSY) != 0)
printf("Modem is busy");
if((dwConnectionTypes & INTERNET_RAS_INSTALLED) != 0)
printf("RAS is installed");
if((dwConnectionTypes & INTERNET_CONNECTION_OFFLINE) != 0)
printf("Offline");
}
else
printf("InternetGetConnectedState() API is failed!");
int f_lockwrite(char* szMsg, int iFileDesc)
{
struct flock *stFlock;
int n;
stFlock = (struct flock*)malloc(sizeof(struct flock));
stFlock->l_type = F_WRLCK;
fcntl(iFileDesc, F_SETLKW, stFlock);
if ((n = write(iFileDesc, szMsg, 1)) <= 0)
{
return -1;
}
stFlock.l_type = F_UNLCK;
fcntl(iFileDesc, F_SETLK, stFlock);
free(stFlock);
return 1;
}