정리

WinHTTP Equivalents to WinINet Functions

저장소/VC++

일부 시스템에서 WinINet의 InternetOpen API 사용시 Apllication Hang 발생 현상으로 인해서

이것 저것 원인 찾다가 괜찮길래 야무지게 긁어옴. 벗어난 영역은 애교.

문제 원인이나 찾을 것이지... ㅡㅜ




출처 : MSDN (http://msdn.microsoft.com/en-us/library/aa384068(VS.85).aspx)



Porting WinINet Applications to WinHTTP

5 out of 6 rated this helpful Rate this topic

Microsoft Windows HTTP Services (WinHTTP) is targeted at middle-tier and back-end server applications that require access to an HTTP client stack.Microsoft Windows Internet (WinINet) provides an HTTP client stack for client applications, as well as access to the File Transfer Protocol (FTP), SOCKSv4, and Gopher protocols. This overview can help determine whether porting your WinINet applications to WinHTTP would be beneficial. It also describes specific conversion requirements.

Things to Consider Before Porting Your WinINet Application

Consider porting your WinINet application to WinHTTP if your application would benefit from:

  • A server-safe HTTP client stack.
  • Minimized stack usage.
  • The scalability of a server application.
  • Fewer dependencies on platform-related APIs.
  • Support for thread impersonation.
  • A service-friendly HTTP stack.
  • Access to the scriptable WinHttpRequest object.

Do not consider porting your WinINet application to WinHTTP if it must support one or more of the following:

  • The FTP or Gopher protocol from the HTTP stack.
  • Support for SOCKSv4 protocol for communicating with SOCKS proxies.
  • Automatic dial-up services.

If you decide to port your application to WinHTTP, the following sections guide you through the conversion process.

For a sample application for both WinINet and WinHTTP, compare the AsyncDemo sample for WinINet with the AsyncDemo sample for WinHTTP.

WinHTTP Equivalents to WinINet Functions

The following table lists WinINet functions related to the HTTP client stack together with the WinHTTP equivalents.

If your application requires WinINet functions that are not listed, do not port your application to WinHTTP.

WinINet functionWinHTTP equivalentNotable changes
HttpAddRequestHeadersWinHttpAddRequestHeadersNone.
HttpEndRequestWinHttpReceiveResponseThe context value is set with WinHttpSendRequest
or WinHttpSetOption. Request options are set with
 WinHttpOpenRequestWinHttpReceiveResponse
 must be called after sending a request.
HttpOpenRequestWinHttpOpenRequestThe context value is set with WinHttpSendRequest or WinHttpSetOption.
HttpQueryInfoWinHttpQueryHeadersNone.
HttpSendRequestWinHttpSendRequestThe context value can be set with WinHttpSendRequest.
HttpSendRequestExWinHttpSendRequestBuffers cannot be provided.
InternetCanonicalizeUrlNo equivalentURLs are now put in canonical form in WinHttpOpenRequest.
InternetCheckConnectionNo equivalentNot implemented in WinHTTP.
InternetCloseHandleWinHttpCloseHandleClosing a parent handle in WinHTTP does not recursively close child handles.
InternetCombineUrlNo equivalentURLs can be assembled with the WinHttpCreateUrl function.
InternetConfirmZoneCrossingNo equivalentNot implemented in WinHTTP.
InternetConnectWinHttpConnectThe context value is set with WinHttpSendRequest or WinHttpSetOption. Request options are set with WinHttpOpenRequest. User credentials are set withWinHttpSetCredentials.
InternetCrackUrlWinHttpCrackUrlOpposite behavior of the ICU_ESCAPE flag: with
 InternetCrackUrl, this flag causes escape
 sequences (%xx) to be converted to characters,
 but with WinHttpCrackUrl, it causes characters that
 must be escaped from in an HTTP request to be converted
 to escape sequences.
InternetCreateUrlWinHttpCreateUrlNone.
InternetErrorDlgNo equivalentBecause WinHTTP is targeted at server-side applications, it does not implement any user interface.
InternetGetCookieNo equivalentWinHTTP does not persist data between sessions and cannot access WinINet cookies.
InternetOpenWinHttpOpenNone.
InternetOpenUrlWinHttpConnect,
WinHttpOpenRequest,
WinHttpSendRequest,
WinHttpReceiveResponse
This functionality is available in the WinHTTP functions listed.
InternetQueryDataAvailableWinHttpQueryDataAvailableNo reserved parameters.
InternetQueryOptionWinHttpQueryOptionWinHTTP offers a different set of options from WinINet.
 For more information and options offered by WinHTTP, see Option Flags.
InternetReadFileWinHttpReadDataNone.
InternetReadFileExWinHttpReadDataRather than a structure, the buffer is a region of
 memory addressed with a pointer.
InternetSetOptionWinHttpSetOptionNone.
InternetSetStatusCallbackWinHttpSetStatusCallbackFor more information, see "Different Handling of
 Asynchronous Requests" in this topic.
InternetTimeFromSystemTimeWinHttpTimeFromSystemTimeNone.
InternetTimeToSystemTimeWinHttpTimeToSystemTimeNone.
InternetWriteFileWinHttpWriteDataNone.

 

Different Handling of Asynchronous Requests

Be aware that in WinINet and WinHTTP, some functions can complete asynchronous requests either synchronously or asynchronously. Your application must handle either situation. There are significant differences in how WinINet and WinHTTP handle these potentially asynchronous functions.

WinINet

  • Synchronous completion: If a potentially asynchronous WinINet function call completes synchronously, the OUT parameters of the function return the results of the operation. When an error occurs, retrieve the error code by calling GetLastError after the WinINet function call.

  • Asynchronous completion: If a potentially asynchronous function call completes asynchronously, the results of the operation, and any errors, are accessible in the callback function. The callback function is executed on a worker thread, not on the thread that made the initial function call.

In other words, your application must duplicate logic to handle the results of such operations in two places: both immediately after the function call and in the callback function.

WinHTTP simplifies this model by enabling you to implement the operational logic only in the callback function, which receives a completion notification regardless of whether the operation completed synchronously or asynchronously. When asynchronous operation is enabled, the OUT parameters of WinHTTP functions do not return meaningful data and must be set to NULL.

The only significant difference between asynchronous and synchronous completion in WinHTTP, from the application perspective, is in where the callback function is executed.

WinHTTP

  • Synchronous completion: When an operation completes synchronously, the results are returned in a callback function that executes in the same thread as the original function call.

  • Asynchronous completion: When an operation completes asynchronously, the results are returned in a callback function that executes in a worker thread.

Although most errors can also be handled entirely within the callback function, WinHTTP applications must still be prepared for a function to return FALSEbecause of an ERROR_INVALID_PARAMETER or other similar error retrieved by calling GetLastError.

Unlike WinINet, which can execute multiple asynchronous operations simultaneously, WinHTTP enforces a policy of one pending asynchronous operation per request handle. If one operation is pending and another WinHTTP function is called, the second function fails and GetLastError returns ERROR_INVALID_OPERATION.

WinHTTP simplifies this model by enabling you to implement the operational logic only in the callback function, which receives a completion notification regardless of whether the operation completed synchronously or asynchronously. When asynchronous operation is enabled, the OUT parameters of WinHTTP functions do not return meaningful data and must be set to NULL.

Differences in WinHTTP Callback Notifications

The status callback function receives updates on the status of operations through notification flags. In WinHTTP, notifications are selected using thedwNotificationFlags parameter of the WinHttpSetStatusCallback function. Use the WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS flag to be notified of all status updates.

Notifications that indicate a particular operation is complete are called completion notifications, or just completions. In WinINet, each time the callback function receives a completion, the lpvStatusInformation parameter contains an INTERNET_ASYNC_RESULT structure. In WinHTTP, this structure is not available for all completions. It is important to review the reference page for WINHTTP_STATUS_CALLBACK, which contains information about notifications and what type of data can be expected for each.

In WinHTTP, a single completion, WINHTTP_CALLBACK_STATUS_REQUEST_ERROR, indicates that an operation failed. All other completions indicate a successful operation.

Both WinINet and WinHTTP use a user-defined context value to pass information from the main thread to the status callback function, which can be executed on a worker thread. In WinINet, the context value used by the status callback function is set by calling one of several functions. In WinHTTP, the context value is set only with WinHttpSendRequest or WinHttpSetOption. Because of this, it is possible in WinHTTP for a notification to occur before a context value is set. If the callback function receives a notification before the context value is set, the application must be prepared to receive NULL in the dwContextparameter of the callback function.

Authentication Differences

In WinINet, user credentials are set by calling the InternetSetOption function, using code similar to that provided in the following code example.

// Use the WinINet InternetSetOption function to set the 
// user credentials to the user name contained in strUsername 
// and the password to the contents of strPassword.
       
InternetSetOption( hRequest, INTERNET_OPTION_PROXY_USERNAME, 
                   strUsername, strlen(strUsername) + 1 );

InternetSetOption( hRequest, INTERNET_OPTION_PROXY_PASSWORD, 
                   strPassword, strlen(strPassword) + 1 );

For compatibility, user credentials can similarly be set in WinHTTP using the WinHttpSetOption function, but this is not recommended because it can pose a security vulnerability.

Instead, when an application receives a 401 status code in WinHTTP, the recommended method of setting credentials is first to identify an authentication scheme using WinHttpQueryAuthSchemes and, second, set the credentials using WinHttpSetCredentials. The following code example shows how to do this.

DWORD dwSupportedSchemes;
DWORD dwPrefered;
DWORD dwTarget;

// Obtain the supported and first schemes.
WinHttpQueryAuthSchemes( hRequest, &dwSupportedSchemes, &dwPrefered, &dwTarget );

// Set the credentials before resending the request.
WinHttpSetCredentials( hRequest, dwTarget, dwPrefered, strUsername, strPassword, NULL );

Because there is no equivalent to InternetErrorDlg in WinHTTP, applications that obtain credentials through a user interface must provide their own interface.

Unlike WinINet, WinHTTP does not cache passwords. Valid user credentials must be supplied for each request.

WinHTTP does not support the Distributed Password Authentication (DPA) scheme supported by WinINet. WinHTTP does, however, support Microsoft Passport 1.4. For more information about using Passport authentication in WinHTTP, see Passport Authentication in WinHTTP.

WinHTTP does not rely on Internet Explorer settings to determine the automatic logon policy. Instead, the auto-logon policy is set with WinHttpSetOption. For more information about authentication in WinHTTP, including the auto-logon policy, see Authentication in WinHTTP.

Differences in Secure HTTP Transactions

In WinINet, initiate a secure session using either HttpOpenRequest or InternetConnect, but in WinHTTP, you must call WinHttpOpenRequest using theWINHTTP_FLAG_SECURE flag.

In a secure HTTP transaction, server certificates can be used to authenticate a server to the client. In WinINet, if a server certificate contains errors,HttpSendRequest fails and provides details about the certificate errors.

In WinHttp, server certificate errors are handled according to the version as follows:

  • Starting with WinHttp 5.1, if a server certificate fails or contains errors, the call to WinHttpSendRequest reports aWINHTTP_CALLBACK_STATUS_SECURE_FAILURE in the callback function. If the error generated by WinHttpSendRequest is ignored, subsequent calls to WinHttpReceiveResponse fail with an ERROR_WINHTTP_OPERATION_CANCELLED error.
  • In WinHTTP 5.0, errors in server certificates do not, by default, cause a request to fail. Instead, the errors are reported in the callback function with theWINHTTP_CALLBACK_STATUS_SECURE_FAILURE notification.

On some earlier platforms, WinINet supported the Private Communication Technology (PCT) and/or Fortezza protocols, although not on Windows XP.

WinHTTP does not support the PCT and Fortezza protocols on any platform, and instead relies on Secure Sockets Layer (SSL) 2.0, SSL 3.0, or Transport Layer Security (TLS) 1.0.

Command Line Build : VCBuild와 MSBuild 그리고 devenv

저장소/VC++

VS2008에서 C/C++ 프로젝트를 빌드할 때 vcbuild.exe를 사용했었는데 이거 VS2010부터 없어졌다 한다. 맘이 아푸다 ㅠㅠ

대신 MSBuild에서 C/C++ 프로젝트를 빌드 할 수 있다고 한다.

MSBuild는 C:\Windows\Microsoft.NET\Framework 아래 있다. 한참 찾았다.

근데 난 devenv.exe로 빌드하는 것도 편한 것 같다.

devenv에서 msbuild를 이용해 빌드한다고 하는데 devenv의 command line 명령어가 눈에 잘 들어온다.


명령어 구성은 다음과 같으니 종종 보자.




2012년 분야별 최고의 오픈소스 소프트웨어 124선

저장소/잡다한거

2012년 분야별 최고의 오픈소스 소프트웨어 124선

IT World  : http://www.itworld.co.kr/news/78082



Bossies 2012: The Best of Open Source Software Awards

Info World : http://www.infoworld.com/d/open-source-software/bossies-2012-the-best-of-open-source-software-awards-202465



2012년 최고의 오픈소스 소프트웨어 : 애플리케이션 부문 (24개)
블로깅 시스템 Movable Type http://www.movabletype.com/
블로깅 플랫폼 WordPress http://www.wordpress.com/
콘텐츠 관리 시스템 Plone http://plone.org/
블로깅 시스템 Joomla http://www.joomla.org/
블로깅 플랫폼 Drupal http://drupal.org/
콘텐츠 관리 시스템 Typo3 http://typo3.org/
기업용 콘텐츠 관리 시스템 Alfresco http://www.alfresco.com/
이미지 관리 툴 Gallery http://gallery.menalto.com/
고객관계관리 솔루션 SugarCRM http://www.sugarcrm.com/
고객관계관리 솔루션 vTiger https://www.vtiger.com/crm/
전자상거래 솔루션 Magento http://www.magentocommerce.com/
전자상거래 플랫폼 Spree http://spreecommerce.com/
중소기업용 회계 프로그램 FrontAccounting http://frontaccounting.com/wb3/
업무용 협업 툴 Feng Office http://www.fengoffice.com/web/
개인과 중소기업용 회계 툴 Gnucash http://www.gnucash.org/
전사자원관리 애플리케이션 OpenERP http://www.openerp.com/
전사자원관리 애플리케이션 Openbravo http://www.openbravo.com/
중소기업을 위한 맥용 전사자원관리 애플리케이션 xTuple http://www.xtuple.com/
인사관리 애플리케이션 OrangeHRM http://www.orangehrm.com/
소규모 의원과 병원을 위한 헬스케어 애플리케이션 OpenEMR http://www.open-emr.org/
비즈니스 인텔리전스 애플리케이션 Pentaho http://www.pentaho.com/
비즈니스 프로세스 관리 애플리케이션 Bonita Open Solution http://www.bonitasoft.com/
웹 포탈 시스템 Liferay Portal http://www.liferay.com/
소셜 네트워크 서비스 애플리케이션 Diaspora http://diasporaproject.org/
 
2012년 최고의 오픈소스 소프트웨어 : 애플리케이션 개발툴 부문 (18개)
네트워크 애플리케이션 개발 플랫폼 Node.js http://nodejs.org/
멀티 플랫폼 모마일 앱 개발환경 PhoneGap http://phonegap.com/
네이티브 앱 개발툴 Titanium http://www.appcelerator.com/
애플리케이션 개발 툴 Sencha Touch http://www.sencha.com/
다양한 스마트폰 OS를 지원하는 개발 프레임워크 Rhodeshttp://www.motorola.com/Business/US-EN/RhoMobile+Suite/Rhodes
오픈소스 브라우저 엔진 WebKit http://www.webkit.org/
가상화 플랫폼 VirtualBox https://www.virtualbox.org/
웹용 3D 그래픽 구현 툴 Three.js http://mrdoob.github.com/three.js/
웹 개발 프레임워크 Bootstrap http://twitter.github.com/bootstrap/
소스코드 관리 툴 Git http://git-scm.com/
애플리케이션 개발 관리 툴 Jenkins http://jenkins-ci.org/
텍스트 에디터 jEdit http://www.jedit.org/
오픈소스 통합개발 환경 Code::Blocks http://www.codeblocks.org/
윈도우부터 맥, 아이폰 등을 지원하는 GUI 플랫폼 wxWidgets http://www.wxwidgets.org/
크로스 플랫폼 애플리케이션 개발 툴 Qt http://qt-project.org/
C++ 소스 라이브러리 Boost http://www.boost.org/
LLVM 컴파일러용 C언어 프론트엔드 Clang http://clang.llvm.org/
자바 애플리케이션 버그 분석기FindBugs http://findbugs.sourceforge.net/

2012년 최고의 오픈소스 소프트웨어 : 데이터센터와 클라우드 부문 (16개)
클라우드 구축 플랫폼 OpenStack http://www.openstack.org/
가상화 네트워크 구축, 관리 솔루션 CloudStack http://www.cloudstack.org/
클라우드 서비스 플랫폼 Eucalyptus http://www.eucalyptus.com/
소규모 가상화 네트워크 관리 툴 Ganeti http://code.google.com/p/ganeti/
가상화 관리 솔루션 Open vSwitch http://openvswitch.org/
클라우드 플랫폼 서비스 솔루션 Cloud Foundry http://www.cloudfoundry.com/
웹 애플리케이션 서버 소프트웨어 JBoss AS7 http://www.jboss.org/as7
클라우드 서비스 지원 라이브러리 Jclouds http://www.jclouds.org/
서버 관리 소프트웨어 Puppet http://docs.puppetlabs.com/
인프라 설정관리 솔루션 Chef http://wiki.opscode.com/display/chef/Home
클라우드 인프라 관리 솔루션 Juju http://juju.ubuntu.com/
분산 파일 시스템 GlusterFS http://www.gluster.org/
분산 파일 시스템 Ceph http://ceph.com/community/
프리BSD 기반의 스토리지 플랫폼 FreeNAS http://www.freenas.org/
리눅스와 LVM 기반의 스토리지 플랫폼 Openfiler http://www.openfiler.com/
프리BSD 기반의 스토리지 플랫폼 NAS4Free http://www.nas4free.org/
 
2012년 최고의 오픈소스 소프트웨어 : 데이터베이스 부문 (11개)
빅데이터 솔루션 Hadoop http://hadoop.apache.org/
자바 기반 데이터 처리 솔루션 Cascading and Scalding http://www.cascading.org/
오픈소스 데이터베이스 솔루션 PostgreSQL http://www.postgresql.org/
오픈소스 데이터베이스 솔루션 MySQL and MariaDB http://www.mysql.com/
데이터베이스 관리 툴 Adminer http://www.adminer.org/
빅데이터 기반의 키값 데이터베이스 Cassandra http://cassandra.apache.org/
오픈소스 NoSQL 데이터베이스 MongoDB http://www.mongodb.org/
오픈소스 NoSQL 데이터베이스Couchbase http://www.couchbase.com/
오픈소스 NoSQL 그래프 데이터베이스 Neo4j http://neo4j.org/
오픈소스 분산 데이터베이스 Riak http://wiki.basho.com/
데이터 구조까지 저장할 수 있는 NoSQL 데이터베이스 Redis http://redis.io/
 
2012년 최고의 오픈소스 소프트웨어 : 데스트톱 애플리케이션 부문 (16개)
PC용 리눅스 운영체제 Ubuntu http://www.ubuntu.com/
오피스 프로그램 LibreOffice http://www.libreoffice.org/
오피스 프로그램 OpenOffice http://www.openoffice.org/
오픈오피스 사용자들이 만든 수많은 템플릿들 OpenOffice Templateshttp://templates.services.openoffice.org/
워드프로세싱 프로그램 AbiWord http://www.abisource.com/
데스크톱 출판 프로그램 Scribus http://www.scribus.net/
웹 브라우저 소프트웨어 Chromium http://www.chromium.org/
웹 브라우저 소프트웨어 Firefox http://www.firefox.com/
이미지 에디터 GIMP http://www.gimp.org/
일러스트레이터 프로그램 Inkscape http://inkscape.org/
화면 캡처 프로그램 CamStudio http://camstudio.org/    
오디오 녹음, 편집 프로그램 Audacity http://audacity.sourceforge.net/   
동영상 플레이어 VLC http://www.videolan.org/
암호관리 프로그램 KeePass http://www.keepass.info/
압축 프로그램 7-Zip http://www.7-zip.org/
하드 디스크 관리 프로그램 WinDirStat http://windirstat.info/
 
2012년 최고의 오픈소스 소프트웨어 : 네트워크와 보안 부문 (27개)
리눅스 기반의 라우터, 펌웨어 시스템 DD-WRT http://www.dd-wrt.com/
파이어폭스, 구글크롬용 보안 확장기능 HTTPS Everywhere https://www.eff.org/https-everywhere/
디스크 암호화 소프트웨어 TrueCrypt http://www.truecrypt.org/
디스크, 파일 암호화 소프트웨어 FreeOTFE http://www.freeotfe.org/
파일 삭제 프로그램 Eraser http://eraser.heidi.ie/    
파일 삭제 프로그램 Darik's Boot and Nuke http://www.dban.org/
리눅스 기반 라우터, 펌웨어 시스템 Vyatta http://www.vyatta.org/
가상화 관리 솔루션 Open vSwitch http://openvswitch.org/
UC 솔루션 Elastix http://www.elastix.org/
스팸 차단 소프트웨어 Anti-Spam SMTP Proxy Server http://sourceforge.net/projects/assp
비디오 카메라 모니터링 소프트웨어 iSpy http://www.ispyconnect.com/
네트워크 관리 솔루션 OpenNMS http://www.opennms.org/
네트워크 관리 솔루션 Cacti http://cacti.net/index.php
네트워크 트래픽 분석 소프트웨어 Wireshark http://www.wireshark.org/
침입탐지 시스템 Snort http://www.snort.org/
보안 관리 소프트웨어 Sagan http://sagan.softwink.com/
차세대 침입탐지 시스템 Suricata http://www.openinfosecfoundation.org/index.php/download-suricata
네트워크 관리용 그래픽 인터페이스 Snorby http://www.snorby.org/
네트워크 보안 스캐너 Nmap http://nmap.org/
네트워크 취약점 탐지 솔루션 Metasploit http://www.metasploit.com/download/
리눅스 기반 침입 테스트 소프트웨어 BackTrack http://www.backtrack-linux.org/
웹 애플리케이션 보안 테스트 솔루션 Burp Suite http://www.portswigger.net/burp/
디스크 이미징 툴 dc3dd http://sourceforge.net/projects/dc3dd/
윈도우 암호 해독기 Ophcrack http://ophcrack.sourceforge.net/
암호 해독 소프트웨어 John the Ripper http://www.openwall.com/john/
보안 커뮤니케이션 툴 GnuPG http://www.gnupg.org/
자바 애플리케이션 버그 분석기 FindBugs http://findbugs.sourceforge.net/
 
2012년 최고의 오픈소스 소프트웨어 : 새로운 부문 (12개)
홈오토메이션 솔루션 OpenRemote http://www.openremote.org/display/HOME/OpenRemote
실시간 전략 시뮬레이션 게임 0 A.D. http://www.wildfiregames.com/0ad/
미디어센터 소프트웨어 XBMC http://xbmc.org/
게임 에뮬레이터 Stella http://stella.sourceforge.net/
3D 탱크 슈팅 게임 BZFlag http://bzflag.org/
e북 콘텐츠 관리 소프트웨어 Calibre http://calibre-ebook.com/
오픈소스 싱글보드 컴퓨터 Arduino http://www.arduino.cc/
1인칭 슈팅게임 AssaultCube http://assault.cubers.net/
전략 시뮬레이션 게임 Freeciv http://freeciv.wikia.com/wiki/Main_Page
실시간 전략 게임 Warzone 2100 http://wz2100.net/
2D 우주무역 게임 Naev http://blog.naev.org/
동영상 편집 소프트웨어 Lightworks http://www.lwks.com


'저장소 > 잡다한거' 카테고리의 다른 글

서명 도구 : signtool.exe  (0) 2013.05.02
VCS의 branch, tag, trunk  (0) 2013.04.17
버전 관리 시스템 : SVN에서 Git으로.. 왜?  (0) 2013.04.16
정규표현식(Regular Expressions) 문법  (0) 2013.04.02
TortoiseSVN Commands  (0) 2013.03.19

버전 관리 시스템 : SVN에서 Git으로.. 왜?

저장소/잡다한거

요즈음 버전 관리 시스템의 추세는 중앙 집중식 버전 관리 시스템(CVS, SVN)에서 분산형 버전 관리 시스템(Git 외 다수)으로 바뀌고 있다고 한다.

대충 봤는데 와~!! 이건 꼭 써야해! 할 정도로 공감되지는 않더라. SVN 쓰는데 불편함이 없어서 말이지.


암튼 자세한 설명은 링크를 따라간다. 귀찮다.

내용 정리가 잘 되어있당.


Git에 대한 친절한 설명. 굿!

http://dogfeet.github.io/progit/progit.ko.html



Pro Git

http://dogfeet.github.io/articles/2012/progit.html


progit





'저장소 > 잡다한거' 카테고리의 다른 글

VCS의 branch, tag, trunk  (0) 2013.04.17
2012년 분야별 최고의 오픈소스 소프트웨어 124선  (0) 2013.04.16
정규표현식(Regular Expressions) 문법  (0) 2013.04.02
TortoiseSVN Commands  (0) 2013.03.19
Stack Overflow 사례  (0) 2013.02.20

정규표현식(Regular Expressions) 문법

저장소/잡다한거

정규표현식 책 추천 -> 손에 잡히는 정규표현식



정규표현식(Regular Expressions) 문법 정리


기본 메타 문자 

.

모든 문자와 일치 

|

왼쪽 혹은 오른쪽과 일치 

[] 

문자 집합 구성원 중 하나와 일치 

[^]

문자 집합 구성원을 제외하고 일치

-

범위 정의 ( [A-Z]와 같은 형태 )

\

다음에 오는 문자를 이스케이프

 수량자

*

문자가 없는 경우나 하나 이상 연속하는 문자 찾기

*?

게으른 * 문자

+

문자 하나 이상 찾기

+?

게으른 + 문자

?

문자가 없거나 하나인 문자 찾기

{n}

정확히 요소와 n번 일치

{m,n} 

요소와 m에서 n번 일치

{n,}

요소와 n번 이상 일치

{n,}?

게으른 {n,}

위치 지정 

^

문자열의 시작과 일치

\A

문자열의 시작과 일치

$

문자열의 끝과 일치

\Z

문자열의 끝과 일치

\<

단어의 시작과 일치

\>

단어의 끝과 일치

\b

단어 경계와 일치

\B

\b 와 반대로 일치

특수한 문자

[\b]

역스페이스 

\c

제어문자와 일치

\d

모든 숫자와 일치

\D

\d 와 반대

\f

페이지 넘기기(form feed)

\n

줄바꿈

\r

캐리지 리턴

\s

공백 문자와 일치

\S

\s 와 반대로 일치

\t

\v

수직 탭

\w

영숫자 문자나 밑줄과 일치

\W

\w 와 반대로 일치

\x

16진수 숫자와 일치

\0

8진수 숫자와 일치

역참조와 전후방 탐색

()

하위 표현식 정의

\1

첫 번째 일치한 하위 표현식. 두번째 일치한 하위 표현식은 \2 로 표기하는 방식

?=

전방탐색

?<=

후방탐색

?!

부정형 전방탐색

?<!

부정형 후방탐색

?(backreference)true

조건 지정

?(backreference)true|false

else 표현식 조건 지정

 대소문자 변환

\E 

\L 혹은 \U 변환을 끝냄

\l

다음에 오는 글자를 소문자로 변환

\L

\E 를 만날 때까지 모든 문자를 소문자로 변환

\u

다음에 오는 글자를 대문자로 변환

\U

\E 를 만날 때까지 모든 문자를 대문자로 변환

변경자

(?m) 

다중행 모드


Visual Studio 원격 디버깅(Remote Debugger)

저장소/VC++

Visual Studio 원격 디버깅 방법



정리는 조금 천천히




VirtualBox로의 원격 디버깅을 하기 위한 네트워크 설정은 다음과 같이 한다.


1. VirtualBox Manager의 메뉴 중 '파일'->'환경설정'->'네트워크' 에서 '호스트 전용 네트워크 정보' 확인

'어댑터'와 'DHCP 서버' 설정의 IP 대역을 확인한다.


2. OS 이미지의 설정의 네트워크 항목에서 어댑터1은 NAT로, 어댑터2를 추가(네트워크 어댑터 사용하기 체크)하여 호스트 전용 어댑터로 설정한 뒤 구동한다.


3. Remote Debugger를 구동할 때 command line 명령을 이용하여 호스트명을 명시적으로 지정한다.

호스트 전용 어댑터의 IP를 설정하면 된다. 명령은 다음과 같다.


msvsmon.exe /hostname 192.168.56.101 /noauth /anyuser


이렇게 하면 디버깅 대상 PC의 설정은 끝이다.

다음은 Visual Studio를 이용해 디버깅을 할 PC의 설정이다....


역시 정리는 나중에.. 귀찮;

네트워크 프로그래밍 할 때 종종 보는 에러들 정리

저장소/VC++

IOCP를 사용한 네트워크 프로그래밍에서 종종 보이는 에러들, 자주 보이는 순서대로 정리.

수신 대기 중 발생되는 에러 원인 찾다가 잘 정리된 내용 복사복사.


내용 출처 :

네이버, 구글 검색

내가 테스트 해본 것도 포함

http://javawork.egloos.com/2265358

http://cafe.naver.com/ongameserver/3758

http://newworlds.tistory.com/1178

http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=50&MAEULNo=20&no=345120&ref=336795

http://blog.naver.com/ddinggill/100110486640


http://coderoid.tistory.com/46

http://www.gpgstudy.com/forum/viewtopic.php?p=41368

http://mindsteeper.tistory.com/188




ERROR_SEM_TIMEOUT (121)

The semaphore timeout period has expired.

장비(방화벽 또는 라우터) 이상 또는 제한으로 인한 네트워크 단절(랜선을 뽑는 경우도 포함)이 발생했을 때

(어느쪽? 서버? 클라?)


ERROR_NETNAME_DELETED (64)

The specified network name is no longer available.

보통 IOCP에서 소켓 끊어짐의 상징은 0 byte read 입니다.

0 byte read가 통보되는 시점은 상대방 소켓에서 closesocket() 혹은 shutdown() 함수를 호출한 시점입니다.

즉, 상대방이 closesocket() 혹은 shutdown() 을 호출하지 않고 종료해버리면 일반적으로 0 byte read는 발생하지 않습니다.

이렇게 0 byte read가 발생하지 않은 상태에서 read() 혹은 write()를 시도하면 상대는 이미 종료 되었으므로

ERROR_NETNAME_DELETED 에러가 나게 됩니다. 이러한 경우를 우아한 종료와는 반대되는 개념으로 HardClose라고 합니다.


WSAENOTSOCK (10054)

An operation was attempted on something that is not a socket.

지정한 소켓은 정상 적이지 않습니다(INVALID_SOCKET). 별도의 종료처리없이 소켓을 닫으면 나옵니다. 


ERROR_IO_PENDING (997)

Overlapped I/O operation is in progress.

이건 더 수신(송신)할 내용이 있을 때 확인되는 값으로 에러로 보기 어렵다.

수신중이었다면 마저 수신처리 하면 된다.

데이터 수신량 확인 시 0 byte면 종료로 봐야하나.

아닌가? 모르겠다. 이건 볼 때마다 모르겠다. 뭐야 이거;; 무서워

허나 GetQueuedCompletionStatus 호출 후 결과는 성공인데 transferred bytes가 0 일 경우에도 이 에러가 확인 된다.

임의로 0 byte를 보내지 않는 이상 보편적으로 transferred bytes가 0 이면 연결이 끊긴 것으로 간주한다.

이럴 땐 transferred bytes의 값을 보고 판단하는게 맞는 것 같다.


ERROR_OPERATION_ABORTED (995)

The I/O operation has been aborted because of either a thread exit or an application request.

1. 작업이 취소된 사례. CreateIoCompletionPort에 추가한 핸들(소켓)이 닫혔을 때.

 클라이언트가 연결된 상태에서 서버가 먼저 종료하면 발생.(server socket이 close되어서)

2. 동시에 송수신할 때

 CreateIoCompletionPort에 핸들(소켓)을 추가하기 전에

 WSADuplicateSocket 이나 DuplicateHandle 를 이용해 핸들을 복사하여 분리해서 추가해주면 된다고 한다.(정말?? 진짜??)




TortoiseSVN Commands

저장소/잡다한거

나는 한다 복사를, TortoiseSVN 도움말에서.


TortoiseSVN Commands


Since all commands for TortoiseSVN are controlled through command line parameters, you can automate it with batch scripts or start specific commands and dialogs from other programs (e.g. your favourite text editor).


Important

Remember that TortoiseSVN is a GUI client, and this automation guide shows you how to make the TortoiseSVN dialogs appear to collect user input. If you want to write a script which requires no input, you should use the official Subversion command line client instead.

D.1. TortoiseSVN Commands

The TortoiseSVN GUI program is called TortoiseProc.exe. All commands are specified with the parameter /command:abcd where abcd is the required command name. Most of these commands need at least one path argument, which is given with /path:"some\path". In the following table the command refers to the /command:abcd parameter and the path refers to the /path:"some\path" parameter.

Since some of the commands can take a list of target paths (e.g. committing several specific files) the /path parameter can take several paths, separated by a * character.

You can also specify a file which contains a list of paths, separated by newlines. The file must be in UTF-16 format, without a BOM. If you pass such a file, use /pathfile instead of /path. To have TortoiseProc delete that file after the command is finished, you can pass the parameter /deletepathfile.

The progress dialog which is used for commits, updates and many more commands usually stays open after the command has finished until the user presses the OK button. This can be changed by checking the corresponding option in the settings dialog. But using that setting will close the progress dialog, no matter if you start the command from your batch file or from the TortoiseSVN context menu.

To specify a different location of the configuration file, use the parameter /configdir:"path\to\config\directory". This will override the default path, including any registry setting.

To close the progress dialog at the end of a command automatically without using the permanent setting you can pass the /closeonend parameter.  음.. Log Dialog는 안 된다;; 당연한가.. Progress Dialog만 된다. 이건 잘 된다.

  • /closeonend:0 don't close the dialog automatically

  • /closeonend:1 auto close if no errors

  • /closeonend:2 auto close if no errors and conflicts

  • /closeonend:3 auto close if no errors, conflicts and merges


    ex) C:\Users\Administrator>TortoiseProc /command:update /path:"d:\MyRepo" /closeonend:1

To close the progress dialog for local operations if there were no errors or conflicts, pass the /closeforlocal parameter.

The table below lists all the commands which can be accessed using the TortoiseProc.exe command line. As described above, these should be used in the form /command:abcd. In the table, the /command prefix is omitted to save space.

Table D.1. List of available commands and options

Command Description
:about Shows the about dialog. This is also shown if no command is given.
:log Opens the log dialog. The /path specifies the file or folder for which the log should be shown. Additional options can be set: /startrev:xxx, /endrev:xxx, /strict enables the 'stop-on-copy' checkbox, /merge enables the 'include merged revisions' checkbox, /findstring:"filterstring" fills in the filter text, /findtext forces the filter to use text, not regex, or /findregex forces the filter to use regex, not simple text search, and /findtype:X with X being a number between 0 and 511. The numbers are the sum of the following options:
  • /findtype:0 filter by everything

  • /findtype:1 filter by messages

  • /findtype:2 filter by path

  • /findtype:4 filter by authors

  • /findtype:8 filter by revisions

  • /findtype:16 not used

  • /findtype:32 filter by bug ID

  • /findtype:64 not used

  • /findtype:128 filter by date

  • /findtype:256 filter by date range

If /outfile:path\to\file is specified, the selected revisions are written to that file when the log dialog is closed. The revisions are written in the same format as is used to specify revisions in the merge dialog.
:checkout Opens the checkout dialog. The /path specifies the target directory and the /url specifies the URL to checkout from. If you specify the key /blockpathadjustments, the automatic checkout path adjustments are blocked. The /revision:XXX specifies the revision to check out.
:import Opens the import dialog. The /path specifies the directory with the data to import. You can also specify the /logmsg switch to pass a predefined log message to the import dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message.
:update Updates the working copy in /path to HEAD. If the option /rev is given then a dialog is shown to ask the user to which revision the update should go. To avoid the dialog specify a revision number /rev:1234. Other options are /nonrecursive, /ignoreexternals and /includeexternals. The /stickydepth indicates that the specified depth should be sticky, creating a sparse checkout.
:commit Opens the commit dialog. The /path specifies the target directory or the list of files to commit. You can also specify the /logmsg switch to pass a predefined log message to the commit dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message. To pre-fill the bug ID box (in case you've set up integration with bug trackers properly), you can use the /bugid:"the bug id here" to do that.
:add Adds the files in /path to version control.
:revert Reverts local modifications of a working copy. The /path tells which items to revert.
:cleanup Cleans up interrupted or aborted operations and unlocks the working copy in /path. Use /noui to prevent the result dialog from popping up (either telling about the cleanup being finished or showing an error message). /noprogressui also disables the progress dialog. /nodlg disables showing the cleanup dialog where the user can choose what exactly should be done in the cleanup. The available actions can be specified with the options /cleanup for status cleanup, /revert, /delunversioned, /delignored, /refreshshell and /externals.
:resolve Marks a conflicted file specified in /path as resolved. If /noquestion is given, then resolving is done without asking the user first if it really should be done.
:repocreate Creates a repository in /path
:switch Opens the switch dialog. The /path specifies the target directory.
:export Exports the working copy in /path to another directory. If the /path points to an unversioned directory, a dialog will ask for an URL to export to the directory in /path. If you specify the key /blockpathadjustments, the automatic export path adjustments are blocked.
:dropexport Exports the working copy in /path to the directory specified in /droptarget. This exporting does not use the export dialog but executes directly. The option /overwrite specifies that existing files are overwritten without user confirmation, and the option /autorename specifies that if files already exist, the exported files get automatically renamed to avoid overwriting them.
:merge Opens the merge dialog. The /path specifies the target directory. For merging a revision range, the following options are available: /fromurl:URL, /revrange:string. For merging two repository trees, the following options are available: /fromurl:URL, /tourl:URL, /fromrev:xxx and /torev:xxx. For doing a reintegrate merge, use the following options: /fromurl:URL and /reintegrate. These pre-fill the relevant fields in the merge dialog.
:mergeall Opens the merge all dialog. The /path specifies the target directory.
:copy Brings up the branch/tag dialog. The /path is the working copy to branch/tag from. And the /url is the target URL. You can also specify the /logmsg switch to pass a predefined log message to the branch/tag dialog. Or, if you don't want to pass the log message on the command line, use /logmsgfile:path, where path points to a file containing the log message.
:settings Opens the settings dialog.
:remove Removes the file(s) in /path from version control.
:rename Renames the file in /path. The new name for the file is asked with a dialog. To avoid the question about renaming similar files in one step, pass /noquestion.
:diff Starts the external diff program specified in the TortoiseSVN settings. The /path specifies the first file. If the option /path2 is set, then the diff program is started with those two files. If /path2 is omitted, then the diff is done between the file in /path and its BASE. To explicitly set the revision numbers use /startrev:xxx and /endrev:xxx, and for the optional peg revision use /pegrevision:xxx. If /blame is set and /path2 is not set, then the diff is done by first blaming the files with the given revisions. The parameter /line:xxx specifies the line to jump to when the diff is shown.
:showcompare

Depending on the URLs and revisions to compare, this either shows a unified diff (if the option unified is set), a dialog with a list of files that have changed or if the URLs point to files starts the diff viewer for those two files.

The options url1, url2, revision1 and revision2 must be specified. The options pegrevision, ignoreancestry, blame and unified are optional.

:conflicteditor Starts the conflict editor specified in the TortoiseSVN settings with the correct files for the conflicted file in /path.
:relocate Opens the relocate dialog. The /path specifies the working copy path to relocate.
:help Opens the help file.
:repostatus Opens the check-for-modifications dialog. The /path specifies the working copy directory. If /remote is specified, the dialog contacts the repository immediately on startup, as if the user clicked on the Check repository button.
:repobrowser

Starts the repository browser dialog, pointing to the URL of the working copy given in /path or /path points directly to an URL.

An additional option /rev:xxx can be used to specify the revision which the repository browser should show. If the /rev:xxx is omitted, it defaults to HEAD.

If /path points to an URL, the /projectpropertiespath:path/to/wc specifies the path from where to read and use the project properties.

If /outfile:path\to\file is specified, the selected URL and revision are written to that file when the repository browser is closed. The first line in that text file contains the URL, the second line the revision in text format.

:ignore Adds all targets in /path to the ignore list, i.e. adds the svn:ignore property to those files.
:blame

Opens the blame dialog for the file specified in /path.

If the options /startrev and /endrev are set, then the dialog asking for the blame range is not shown but the revision values of those options are used instead.

If the option /line:nnn is set, TortoiseBlame will open with the specified line number showing.

The options /ignoreeol, /ignorespaces and /ignoreallspaces are also supported.

:cat Saves a file from an URL or working copy path given in /path to the location given in /savepath:path. The revision is given in /revision:xxx. This can be used to get a file with a specific revision.
:createpatch Creates a patch file for the path given in /path.
:revisiongraph

Shows the revision graph for the path given in /path.

To create an image file of the revision graph for a specific path, but without showing the graph window, pass /output:path with the path to the output file. The output file must have an extension that the revision graph can actually export to. These are: .svg, .wmf, .png, .jpg, .bmp and .gif.

Since the revision graph has many options that affect how it is shown, you can also set the options to use when creating the output image file. Pass these options with /options:XXXX, where XXXX is a decimal value. The best way to find the required options is to start the revision graph the usual way, set all user-interface options and close the graph. Then the options you need to pass on the command line can be read from the registry HKCU\Software\TortoiseSVN\RevisionGraphOptions.

:lock Locks a file or all files in a directory given in /path. The 'lock' dialog is shown so the user can enter a comment for the lock.
:unlock Unlocks a file or all files in a directory given in /path.
:rebuildiconcache Rebuilds the windows icon cache. Only use this in case the windows icons are corrupted. A side effect of this (which can't be avoided) is that the icons on the desktop get rearranged. To suppress the message box, pass /noquestion.
:properties Shows the properties dialog for the path given in /path.


Examples (which should be entered on one line):

TortoiseProc.exe /command:commit
                 /path:"c:\svn_wc\file1.txt*c:\svn_wc\file2.txt"
                 /logmsg:"test log message" /closeonend:0

TortoiseProc.exe /command:update /path:"c:\svn_wc\" /closeonend:0

TortoiseProc.exe /command:log /path:"c:\svn_wc\file1.txt"
                 /startrev:50 /endrev:60 /closeonend:0

TortoiseSVN(Diff, Log, Blame)과 Visual Studio 통합 방법

저장소/VC++

요기서 퍼왔어요~

http://tortoisesvn.net/visualstudio.html


AnkhSVN이나 VisualSVN을 설치해서 써도 좋지만,

TortoiseSVN의 Diff, Log, Blame 기능만 사용해도 충분하다면 다음과 같이 설정한다.



If you're using Visual Studio, you can integrate TortoiseSVN commands to various context menus. Of course, there are Subversion plugins for Visual Studio like AnkhSVN or VisualSVN, with the latter already using TortoiseSVN for many of its UI. Those plugins also have the advantage that when you do refactoring, they automatically record the renames and moves in SVN.

But if you're using one of the free versions of Visual Studio, you can not use those plugins. And sometimes it's still nice to have some of the TortoiseSVN commands available from Visual Studio directly, even if you have such a plugin installed.

The first step is to add the TortoiseSVN commands as external tools, under the menu TOOLS->External Tools....


  한국어 버전 ->  

Add the name of the command, the path to TortoiseProc.exe and then the parameters for the command.

Use the VS variables wherever needed. Since I add my commands to the context menu of the open file tab, here's the parameters I used:

  • /command:blame /path:"$(ItemPath)" /line:$(CurLine)
  • /command:diff /path:"$(ItemPath)"
  • /command:log /path:"$(ItemPath)"

Notice the /line: parameter: this will make TortoiseBlame automatically scroll to the same line the cursor is located in the opened file in Visual Studio.

Now to add those new commands to the file tab context menu, go to TOOLS->Customize..., select the Commands tab, click the radio button Context menu and then select Other Context Menus | Easy MDI Document Window.


 

 한국어 버전 ->  

Then click the Add command... button:


  한국어 버전 ->  

Now you have to select the commands. Problem is that the custom commands are not shown with their title but only as External Command X with X being the number of the external command.

In my case, the commands were number 9-11, you might have to do some trial-and-error here. Just add the commands you think are the ones you added and then check if the right ones show up in the context menu.

음... 외부  도구에서 추가한 기능의 이름이 안 보이고 그냥 '외부 명령 XX' 요렇게 보이는 것에 주의 필요합니다.

대충 제일 아래쪽부터 순서대로 찍으면 될듯... ^^;

And this is how the context menu of the open file tab looks like:


  한국어 버전 ->  

Verifying the Signature of a PE File : 코드사인 검증

저장소/VC++


MSDN : Example C Program: Verifying the Signature of a PE File

http://msdn.microsoft.com/en-us/library/aa382384(VS.85).aspx