[하프]초미지향 님 Mabinogi Server CheckUp 1.2 소스 참고 했습니다.
한국 본서버 기준 :
http://211.218.233.238/patch/patch.txt
파일 중에
patch_accept 값이 1 이면 게임 접속이 가능하다
patch_accept=1
테스트 서버 URL
http://211.218.233.238/patch/patch_test.txt
C/C++로 구현한다면
Socket으로 211.218.233.238 80번 포트로 연결후
"GET /patch/patch.txt HTTP/1.0\r\n\r\n" 을 보내고(send)
결과값을 받는다 (recv)
마비노기 게임 접속 가능한지 알아내는 방법
2010. 2. 1. 15:47
ACE_Task 사용시 부모 윈도우에 LogMsg출력하기
2010. 1. 28. 18:01
Task 구현
호출
class LogTest_Task : public ACE_Task<ACE_NULL_SYNCH> { typedef ACE_Task<ACE_NULL_SYNCH> super; private: ACE_Log_Msg_Callback * m_pLogCallback; public: LogTest_Task( ACE_Log_Msg_Callback * logCallback ) : super(), m_pLogCallback( logCallback ) { } virtual int svc() { if( m_pLogCallback ) { ACE_LOG_MSG->set_flags( ACE_Log_Msg::MSG_CALLBACK ); ACE_LOG_MSG->clr_flags( ACE_Log_Msg::STDERR ); ACE_LOG_MSG->msg_callback( m_pLogCallback ); } // Log 출력. ACE_DEBUG( ( LM_DEBUG, ACE_TEXT("DEBUG hello World") ) ); ACE_ERROR( ( LM_ERROR, ACE_TEXT("ERROR hello World") ) ); return 0; } };
호출
// Task생성및 Task 실행. LogTest_Task logTask( ACE_Log_Msg::instance()->msg_callback() ); logTask.activate(); logTask.wait();
ACE + MFC
2010. 1. 28. 17:50
추가된소스
BOOL CACE_MFCApp::InitInstance() { ..... ///////////////////////////////////////////////////////////////// // 추가 WORD wVersionRequested; WSADATA wsaData; int err = 0; wVersionRequested = MAKEWORD( 2, 2 ); if( WSAStartup( wVersionRequested, &wsaData ) != 0 ) return FALSE; ACE::init(); ///////////////////////////////////////////////////////////////// CACE_MFCDlg dlg; m_pMainWnd = &dlg; INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } ///////////////////////////////////////////////////////////////// // 추가 ACE::fini(); WSACleanup( ); ///////////////////////////////////////////////////////////////// // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
마비노기 게임 현재 시간 구하는 소스
2010. 1. 19. 21:46
#include <time.h> #include <iostream> #include <Windows.h> using namespace std; int main() { cout << "http://fehead.tistory.com/" << endl; for( ;; ) { time_t now = time( 0 ); // 자정(오늘의 0시 시각을 구함) struct tm todayStartTm; localtime_s( &todayStartTm, &now ); todayStartTm.tm_sec = 0; todayStartTm.tm_min = 0; todayStartTm.tm_hour = 0; // 자정부터 현재까지 지난 초를 구함 time_t todayTotalSec = now - mktime( &todayStartTm ); // 에린의 현재 누적된 분(Min)을 구함. // (에린시간은 1.5초당 1분이 지나기 때문에 1.5로 나누었음.) time_t erinTotalMin = static_cast<time_t>( todayTotalSec / 1.5 ); // 에린의 하루 시간을 구함. // 누적된 시간에서 오늘로부터 지난 시간을 구함(24 * 60 - 하루) time_t erinTodayMin = erinTotalMin % (60*24); time_t erinHour = erinTodayMin / 60; // 에린시간 시 time_t erinMin = erinTodayMin % 60; // 에린시간 분 cout << erinHour << " : " << erinMin << endl; // 시간 출력 Sleep( 1000 ); } return 0; }
늑대와 향신료 호로양
2010. 1. 7. 17:29
호로양 Gif에서 에서 글자를 뺀것
용량 최적화 한것
용량 최적화 한것
VC++ 2008기반 간단한 디렉토리 ZipUnzip 압축 라이브러리(Simple Directory ZipUnzip library)
2009. 12. 30. 16:12
간단하게 디렉토리를 압축할수 있게하는 라이브러리이다.
위 사이트를 참고하여
Zlib( http://www.winimage.com/zLibDll/index.html )
MiniZip( http://www.winimage.com/zLibDll/minizip.html )
zipunzip 라이브러리( http://www.codeproject.com/KB/cpp/zipunzip.aspx )
사이트에 가서 해당 소스를 가져와 소스를 합치고 해서 visual c++ 2008에서 컴파일 했다.
파일은 두개인데
한개는 ZipUnzip 라이브러리 파일이고
한개는 ZipUnzip라이브러리를 사용한 샘플파일( 위사이트에서 참고한 파일 )이다.
사용법은 아래와 같다.
http://joyholic.kr/trackback/32
위 사이트를 참고하여
Zlib( http://www.winimage.com/zLibDll/index.html )
MiniZip( http://www.winimage.com/zLibDll/minizip.html )
zipunzip 라이브러리( http://www.codeproject.com/KB/cpp/zipunzip.aspx )
사이트에 가서 해당 소스를 가져와 소스를 합치고 해서 visual c++ 2008에서 컴파일 했다.
파일은 두개인데
한개는 ZipUnzip 라이브러리 파일이고
한개는 ZipUnzip라이브러리를 사용한 샘플파일( 위사이트에서 참고한 파일 )이다.
사용법은 아래와 같다.
// DirectoryZip --- c:\tmp 디렉토리를 c:\tmp.zip 으로 압축 CZipper zip; if (zip.OpenZip("c:\\tmp.zip", false)) zip.AddFolderToZip("c:\\tmp", false); // FileZip --- c:\tmp\test.txt 파일을 c:\tmp.zip 으로 압축 CZipper zip; if (zip.OpenZip("c:\\tmp.zip", false)) zip.AddFileToZip("c:\\tmp\\text.txt", false); // Unzip --- c:\tmp.zip 을 c:\tmp에 압축해제 CUnzipper uz; bool br = uz.OpenZip("c:\\tmp.zip"); if(br) br = uz.UnzipTo("c:\\tmp");
아래 샘플 코드의 실행 방법은 인자를 붙여 실행합니다. ZipUnzip.exe c C:\tmp ==> c:\tmp 디렉토리를 압축하여 c:\tmp.zip 파일을 만든다. ZipUnzip.exe d C:\tmp ==> c:\tmp.zip 파일을 압축해제하여 c:\tmp에 압축을 푼다.
Dos Time to time_t
2009. 12. 24. 12:38
압축을 해제할때 필요.
예제 소스
http://www.opensource.apple.com/source/gcc3/gcc3-1161/fastjar/dostime.c
예제 소스
http://www.opensource.apple.com/source/gcc3/gcc3-1161/fastjar/dostime.c
/* dostime.c - routines for converting UNIX time to MS-DOS time. Borrowed from Info-zip's unzip Copyright (C) 1999 Bryan Burns This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /* $Id: dostime.c,v 1.3 2001/09/17 20:35:55 zlaski Exp $ $Log: dostime.c,v $ Revision 1.3 2001/09/17 20:35:55 zlaski Resolve conflicts due to 2001-09-12 FSF import. Revision 1.2 2000/12/14 18:45:35 ghazi Warning fixes: * compress.c: Include stdlib.h and compress.h. (rcsid): Delete. (report_str_error): Make static. (ez_inflate_str): Delete unused variable. Add parens in if-stmt. (hrd_inflate_str): Likewise. * compress.h (init_compression, end_compression, init_inflation, end_inflation): Prototype void arguments. * dostime.c (rcsid): Delete. * jargrep.c: Include ctype.h, stdlib.h, zlib.h and compress.h. Make functions static. Cast ctype function argument to `unsigned char'. Add parens in if-stmts. Constify. (Usage): Change into a macro. (jargrep): Remove unused parameter. * jartool.c: Constify. Add parens in if-stmts. Align signed/unsigned char pointers in functions calls using casts. (rcsid): Delete. (list_jar): Fix printf format specifier. (usage): Chop long string into bits. Reformat. * pushback.c (rcsid): Delete. Revision 1.1 2000/12/09 03:08:23 apbianco 2000-12-08 Alexandre Petit-Bianco < apbianco@cygnus.com > * fastjar: Imported. Revision 1.1.1.1 1999/12/06 03:09:12 toast initial checkin.. Revision 1.6 1999/05/10 08:32:26 burnsbr added dos2unixtime Revision 1.5 1999/04/27 10:03:50 burnsbr configure support Revision 1.4 1999/04/26 21:55:19 burnsbr switched from sys/time.h to time.h for better portability Revision 1.3 1999/04/20 08:54:30 burnsbr added GPL comment Revision 1.2 1999/04/20 05:10:53 burnsbr added RCS tags */ #include "config.h" #ifdef TM_IN_SYS_TIME #include < sys/time.h > #else #include < time.h > #endif #include "dostime.h" /* Copyright (C) 1990-1997 Mark Adler, Richard B. Wales, Jean-loup Gailly, Kai Uwe Rommel, Onno van der Linden and Igor Mandrichenko. Permission is granted to any individual or institution to use, copy, or redistribute this software so long as all of the original files are included, that it is not sold for profit, and that this copyright notice is retained. */ time_t dos2unixtime(dostime) unsigned long dostime; /* DOS time to convert */ /* Return the Unix time_t value (GMT/UTC time) for the DOS format (local) * time dostime, where dostime is a four byte value (date in most * significant word, time in least significant word), see dostime() * function. */ { struct tm *t; /* argument for mktime() */ time_t clock = time(NULL); t = localtime(&clock); t->tm_isdst = -1; /* let mktime() determine if DST is in effect */ /* Convert DOS time to UNIX time_t format */ t->tm_sec = (((int)dostime) << 1) & 0x3e; t->tm_min = (((int)dostime) >> 5) & 0x3f; t->tm_hour = (((int)dostime) >> 11) & 0x1f; t->tm_mday = (int)(dostime >> 16) & 0x1f; t->tm_mon = ((int)(dostime >> 21) & 0x0f) - 1; t->tm_year = ((int)(dostime >> 25) & 0x7f) + 80; return mktime(t); } unsigned long dostime(y, n, d, h, m, s) int y; /* year */ int n; /* month */ int d; /* day */ int h; /* hour */ int m; /* minute */ int s; /* second */ /* Convert the date y/n/d and time h:m:s to a four byte DOS date and time (date in high two bytes, time in low two bytes allowing magnitude comparison). */ { return y < 1980 ? dostime(1980, 1, 1, 0, 0, 0) : (((unsigned long)y - 1980) << 25) | ((unsigned long)n << 21) | ((unsigned long)d << 16) | ((unsigned long)h << 11) | ((unsigned long)m << 5) | ((unsigned long)s >> 1); } unsigned long unix2dostime(t) time_t *t; /* unix time to convert */ /* Return the Unix time t in DOS format, rounded up to the next two second boundary. */ { time_t t_even; struct tm *s; /* result of localtime() */ t_even = (*t + 1) & (~1); /* Round up to even seconds. */ s = localtime(&t_even); /* Use local time since MSDOS does. */ return dostime(s->tm_year + 1900, s->tm_mon + 1, s->tm_mday, s->tm_hour, s->tm_min, s->tm_sec); }
파일 접근시간및 수정 날짜 바꾸기
2009. 12. 24. 12:30
utime
예제 참고
http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/utime
#include < sys/types.h > #include < utime.h > int utime(const char *filename, const struct utimbuf *times);
예제 참고
http://www.joinc.co.kr/modules/moniwiki/wiki.php/man/2/utime
#include < sys/types.h > #include < utime.h > #include < sys/time.h > #include < stdio.h > #include < string.h > int main() { struct utimbuf ubuf; ubuf.actime = time((time_t *)0); ubuf.modtime = time((time_t *)0); // 접근,수정 시간을 현재 시간으로 변경한다. utime("sizeof.c", NULL); // NULL 대신 actime,modtime 을 세팅해서 // 직접 값을 지정해줄수도 있다. utime("sizeof.c", &ubuf); return 0; }
Scoped Locking idiom 패턴
2009. 12. 23. 12:44
해당 범위를 벗어나면 락을 해제하는 패턴.
예제 1 ) Scoped Locking 패턴을 사용하지 않은 예제
변수 m 은 뮤텍스.
예제 2 ) Scoped Locking 패턴을 사용한 예제
변수 m 은 뮤텍스.
예제 1 ) Scoped Locking 패턴을 사용하지 않은 예제
변수 m 은 뮤텍스.
virtual int handle_data() { while( log_record() != -1 ) { if( m.acquire() == -1 ) return 0; ++request_count; // 요청개수 증가 m.release(); // 잠금해제 } m.acquire(); int cnt = request_count; m.release(); cout << "request_count" = " << cnt << endl; }
예제 2 ) Scoped Locking 패턴을 사용한 예제
변수 m 은 뮤텍스.
virtual int handle_data() { while( log_record() != -1 ) { // 생성자에서 잠금 획득 ACE_GUARD_RETURN ( ACE_Thread_Mutex, guard, m , -1 ); ++request_count; // 요청개수 증가 // 소멸자에서 잠금 해제. } { // 생성자에서 잠금 획득 ACE_GUARD_RETURN ( ACE_Thread_Mutex, guard, m , -1 ); int cnt = request_count; // 소멸자에서 잠금 해제. } cout << "request_count" = " << cnt << endl; }
Null Object 패턴
2009. 12. 23. 12:35
아무것도 하지 않는 객체를 만드는것.
예제)
예제)
class ACE_Null_Mutex { public: ACE_Null_Mutex( const char * = 0, ACE_mutexattr_t * = 0 ) {} int acquire() { return 0; } int release() { return 0; } // .... };