C 언어
매크로 사용하기(php소스 쪼개서 사용하기)
SpeeDr00t
2016. 7. 21. 00:00
반응형
매크로 사용하기
부제 : php소스 쪼개서 사용하기(php7.0.8-src/sapi/cgi/cgi_main.c)
발췌 소스
if (!env_document_root && PG(doc_root)) { env_document_root = CGI_PUTENV("DOCUMENT_ROOT", PG(doc_root)); /* fix docroot */ TRANSLATE_SLASHES(env_document_root); }
1.소스
#include <stdio.h> #include <string.h> #define TRANSLATE_SLASHES(path) \ { \ char *tmp = path; \ while (*tmp) { \ if (*tmp == '\\') *tmp = '/'; \ tmp++; \ } \ } int main( int argc , char ** argv ) { char * buf = "c:\\test\\path\\"; char env_document_root[256]; strcpy( env_document_root, buf ); TRANSLATE_SLASHES(env_document_root); printf("result = %s \n", env_document_root ); return 0; }
결과
gcc -o translate_slashes translate_slashes.c hacker@ubuntu:~/c/php$ ./translate_slashes result = c:/test/path/
반응형