카테고리

asm (27) bootloader_x86_grub (1) C (92) compile (11) config (76) CPP (13) CSS (1) debugging (7) gimp (1) Go (1) html (1) Java (1) JavaScript (1) kernel (19) LibreOffice (3) Linux system progamming (21) MFC (1) opencv (4) OpenGL (1) PHP (1) Python (4) qemu (29) shell (3) socket (7) troubleshooting (2) ubuntu18.04 (2) windows (1)

2018/12/11

socket 파일 전송 서버

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <ctype.h>


void error(const char *msg){
perror(msg);
exit(1);
}

int main(int argc, char *argv[])
{
int sockfd, newsockfd, port_number;
socklen_t clilen;
char buffer[1024];
struct sockaddr_in serv_addr, cli_addr;
int n;
if (argc < 2) {
fprintf(stderr,"ERROR, no port provided\n");
exit(1);
}
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
bzero((char *) &serv_addr, sizeof(serv_addr));
port_number = atoi(argv[1]);
serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = INADDR_ANY;
serv_addr.sin_port = htons(port_number);
if (bind(sockfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr)) < 0)
error("ERROR on binding");
listen(sockfd, 5);
clilen = sizeof(cli_addr);
newsockfd = accept(sockfd, (struct sockaddr *) &cli_addr, &clilen);
if (newsockfd < 0)
error("ERROR on accept");

FILE *fp;
int ch = 0;
fp = fopen("Hean_receive.txt","a");
int words;
read(newsockfd, &words, sizeof(int));
//printf("Passed integer is : %d\n" , words);      //Ignore , Line for Testing
while(ch != words){
read(newsockfd, buffer, 1024);
fprintf(fp, " %s", buffer);
//printf(" %s %d "  , buffer , ch); //Line for Testing , Ignore
ch++;
}
printf("The file was received successfully\n");
printf("The new file created is Korea_HeaNam Full Name");
close(newsockfd);
close(sockfd);
return 0;
}

// compile: gcc -o server server.c
// ./server 9999

socket 파일 전송 클라이언트

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netdb.h>
#include<ctype.h>

void error(const char *msg){
perror(msg);
exit(0);
}

int main(int argc, char *argv[]){
int sockfd, port_number, n;
struct sockaddr_in serv_addr;
struct hostent *server;

char buffer[1024];
if (argc < 3){
fprintf(stderr,"usage %s hostname port\n", argv[0]);
exit(0);
}
port_number = atoi(argv[2]);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
error("ERROR opening socket");
server = gethostbyname(argv[1]);
if (server == NULL) {
fprintf(stderr,"ERROR, no such host\n");
exit(0);
}
bzero((char *) &serv_addr, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
bcopy((char *)server->h_addr, (char *)&serv_addr.sin_addr.s_addr, server->h_length);
serv_addr.sin_port = htons(port_number);
if (connect(sockfd,(struct sockaddr *) &serv_addr,sizeof(serv_addr)) < 0)
error("ERROR connecting");

bzero(buffer,1024);

FILE *f;

int words = 0;
char c;
f=fopen("HeaN.txt","r");
while((c=getc(f))!=EOF){ //Counting No of words in the file
fscanf(f , "%s" , buffer);
if(isspace(c)||c=='\t')
words++;
}
//printf("Words = %d \n"  , words); //Ignore


write(sockfd, &words, sizeof(int));
rewind(f);

/*      fseek(f, 0L, SEEK_END);    // tells size of the file. Not rquired for the functionality in code.
int sz = ftell(f); //Just written for curiosity.
printf("Size is %d \n" , sz);
rewind(f);
*/

char ch ;
while(ch != EOF){

fscanf(f , "%s" , buffer);
//printf("%s\n" , buffer); //Ignore
write(sockfd,buffer,1024);
ch = fgetc(f);
}
printf("The file was sent successfully");

close(sockfd);
return 0;
}

// compile: gcc -o client client.c
// ./client 127.0.0.1 9999

vim + ctags + cscope + taglist 연동

사용방법.
잘 정리 된 국내 사이트 참고  http://vlee.kr/946

vim 명령 모드에서 다음을 입력

:cs [명령]
– 명령
help : 도움말
예제 : :cs help / :cs
add : 새 데이타 베이스 더하기
사용법 : add file|dir [pre-path] [flags]
예제 : :cs add ./cscope.out
show : 연결 보여주기
사용법 : show
예제 : :cs show
kill : 연결 끊기
사용법 : kill # (#은 연결된 데이타베이스 번호로 show 를 통해 확인 가능)
예제 : :cs kill 0
reset : 모든 연결 초기화
사용법 : reset
예제 : :cs reset
find : Query for a pattern
사용법 : find c|d|e|f|g|i|s|t name
0 또는 s C 심볼 검색
1 또는 g 전역 선언만 검색
2 또는 d 이 함수에 의해 호출되는 함수들 검색
3 또는 c 이 함수를 호출하는 함수들 검색
4 또는 t 텍스트 문자열을 검색
5 또는 e 확장 정규식을 사용하여 검색
7 또는 f 파일 이름을 검색
8 또는 i 이 파일을 인클루드하는 파일 검색
예제: :cs find s start_kernel
:cn 다음 태그
:cp 이전 태그

cscope 직접 실행
cscope DB가 존재하는 디렉토리에서 다음을 입력
$ cscope -d
다음과 같은 메뉴에서 입력을 할 수 있다.
Find this C symbol : ctags와 마찬가지로 C 심볼(변수, 함수, 매크로, 구조체)들을 찾는다.
Find this global definition : 전역 선언만 검색
Find functions called by this function : 이 함수에 의해 호출되는 함수를 검색
Find functions calling this function : 이 함수를 호출하는 함수를 검색
Find this text string : 텍스트 문자열을 검색
Change this text string : 문자열을 검색해서 변경
Find this egrep pattern : 정규식을 이용해서 소스코드 검색
Find this file : 특정이름을 포함한 파일을 모두 검색
Find files #including this file : 특정헤더를 포함시키는 모든 소스코드를 검색
프로그램에서 빠져나오고 싶으면 ctrl + d 입력, tab을 누르면 검색메뉴로 돌아갈 수 있다.

taglist
vim 명령 모드에서 다음을 입력
:Tlist

창이 분리되고 왼쪽에 함수, 매크로 등의 목록이 나온다. ctrl + w + w 로 창간 이동이 가능하며 태그 리스트 창에서 특정 함수 명이나 매크로에 커서를 갖다 놓고 enter를 치면 해당 함수나 매크로가 선언되어 잇는 곳으로 이동 한다.
taglist 창을 닫기 위해선 taglist 창으로 이동 하여 vim 명령 모드에서 :q 를 입력한다.

커널 분석 추가 vimrc 설정

vim 설정
VIM 플러그인들을 관리 할 수 있도록 돕는 플러그인.
VIM 내에서 플러그인 검색, 설치, 업데이트, 삭제 등의 작업이 가능

git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim

플로그인 검색 및 자동 설치 Keymap
: VundleSearch

Keymap
i : Install plugin
c : Clean up
s : Search
R : Reload list

수동 플러그인 설정
vi .vimrc

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" 바닥글
Plugin 'vim-airline/vim-airline'

" 바닥글 추가, 삭제, 변경 정보 확인.
Plugin 'tpope/vim-fugitive'

" 문법 체크
Plugin 'scrooloose/syntastic'

" IDE 파일 Tree
Plugin 'nerdtree'

" git 관리 파일 변경 부분 확인
Plugin 'airblade/vim-gitgutter'

" 색상 테마 적용
Plugin 'nanotech/jellybeans.vim'

" 커피스크립트 Synatx
Plugin 'kchmck/vim-coffee-script'

" vimshell
Plugin 'shougo/vimshell.vim'
Plugin 'vimproc.vim'

call vundle#end()            " required
filetype plugin indent on    " required

map <Leader>nt <ESC>:NERDTree<CR>
color jellybeans

플러그인 적용
vi vim
:PluginInstall

플로그인 삭제
vi .vimrc
Plugin 이름 삭제
:PluginClena

설치 플로그인 기능 활성화
:NERDTree
:NERDTreeToggle on/off

vimshell 설치
git clone https://github.com/Shougo/vimshell.vim.git ~/.vim/bundle/VimShell.vim
cd ~/.vim/bundle/VimShell.vim

sudo apt-get install ctags cscope exuberant-ctags
cscope: 코드를 탐색하는 데 사용됩니다 (함수 간 전환 등).
ctags: Tagbar플러그인을 위해 필요하고 그리고 Omni completion(vim의 자동 완성 메카니즘); 네비게이션에도 사용할 수 있음.

커널 소스 scripts/tags.sh 커널 분석 데이터베이스 스크립트.
============================================
스크립트를 직접 실행하는 대신 커널 작성 규칙 make cscope, make tags 규칙을 사용한다.

예:
make O=. ARCH=arm SUBARCH=omap2 COMPILED_SOURCE=1 cscope tags

옵션 설명
O=.
- 절대 경로를 사용
(생성 된 cscope/ctags 색인 파일을 커널 디렉토리 외부로 로드하려는 경우 유용함. 예: 트리 외부 커널 모듈 개발 용).
상대 경로 (즉, 커널 디렉토리에서만 개발)를 사용하려면 해당 매개 변수를 생략한다.

ARCH=...
- 인덱싱 할 CPU 아키텍처를 선택
- ARCH=arm, arch/arm/

SUBARCH=...
- 인덱싱 할 하위 아키텍처 (예: 보드 관련 파일)를 선택
- 예를 들어, 디렉토리 와 인덱스 SUBARCH=omap2만 인덱싱되면 나머지 머신과 플랫폼은 무시된다.
- arch/arm/mach-omap2/ arch/arm/plat-omap/ 이 플랫폼만 관련해 인덱싱 색인 정보를 만든다.

COMPILED_SOURCE=1
- 컴파일 된 파일 만 색인한다.
- 일반적으로 빌드에 사용 된 소스 파일에만 관심이 있으므로(따라서 컴파일 됨). 빌드되지 않은 파일도 같이 색인화하려면이 옵션을 생략한다.

cscope
- cscope 색인을 만드는 규칙

tags
- ctags 인덱스를 만드는 규칙

수동 생성 색인
=============
스크립트 동작에 문제가 있을 경우 수동으로 생성한다.
http://cscope.sourceforge.net/large_projects.html

먼저 cscope.files색인을 생성하려는 모든 파일을 나열하는 파일 을 작성한다.
예를 들어,
다음 명령을 사용하여 ARM 아키텍처(arch/arm)에 대한 파일을 나열 하고 특히 OMAP 플랫폼(나머지 플랫폼은 제외하고 탐색을 쉽게 유지할 수 있음)을 사용한다.
vi cscope.files

find    $dir                                          \
        -path "$dir/arch*"               -prune -o    \
        -path "$dir/tmp*"                -prune -o    \
        -path "$dir/Documentation*"      -prune -o    \
        -path "$dir/scripts*"            -prune -o    \
        -path "$dir/tools*"              -prune -o    \
        -path "$dir/include/config*"     -prune -o    \
        -path "$dir/usr/include*"        -prune -o    \
        -type f                                       \
        -not -name '*.mod.c'                          \
        -name "*.[chsS]" -print > cscope.files
find    $dir/arch/arm                                 \
        -path "$dir/arch/arm/mach-*"     -prune -o    \
        -path "$dir/arch/arm/plat-*"     -prune -o    \
        -path "$dir/arch/arm/configs"    -prune -o    \
        -path "$dir/arch/arm/kvm"        -prune -o    \
        -path "$dir/arch/arm/xen"        -prune -o    \
        -type f                                       \
        -not -name '*.mod.c'                          \
        -name "*.[chsS]" -print >> cscope.files
find    $dir/arch/arm/mach-omap2/                     \
        $dir/arch/arm/plat-omap/                      \
        -type f                                       \
        -not -name '*.mod.c'                          \
        -name "*.[chsS]" -print >> cscope.files


vi cscope.files
x86 아키텍처 (arch/x86)에서는 다음과 같은 것을 사용한다.
find    $dir                                          \
        -path "$dir/arch*"               -prune -o    \
        -path "$dir/tmp*"                -prune -o    \
        -path "$dir/Documentation*"      -prune -o    \
        -path "$dir/scripts*"            -prune -o    \
        -path "$dir/tools*"              -prune -o    \
        -path "$dir/include/config*"     -prune -o    \
        -path "$dir/usr/include*"        -prune -o    \
        -type f                                       \
        -not -name '*.mod.c'                          \
        -name "*.[chsS]" -print > cscope.files
find    $dir/arch/x86                                 \
        -path "$dir/arch/x86/configs"    -prune -o    \
        -path "$dir/arch/x86/kvm"        -prune -o    \
        -path "$dir/arch/x86/lguest"     -prune -o    \
        -path "$dir/arch/x86/xen"        -prune -o    \
        -type f                                       \
        -not -name '*.mod.c'                          \
        -name "*.[chsS]" -print >> cscope.files

변수 설명
dir변수는 다음 값 중 하나를 가질 수 있다:
- .: 커널 소스 코드 디렉토리에서만 작업한다면; 이 경우 해당 명령은 커널 소스 코드의 루트 디렉토리에서 실행해야 한다.
- 커널 소스 코드 디렉토리의 절대 경로: 트리를 벗어난 커널 모듈을 개발할 경우; 이 경우 스크립트는 어디서나 실행할 수 있다.

위의 첫 번째 옵션 (dir =.)을 사용하고 있다.
모듈을 개발하지 않기 때문에 dir =. 을 사용함.

cscope.files파일이 준비되면 실제 인덱싱을 실행한다.
cscope -b -q -k

옵션 설명
-k매개 변수는 C 표준 라이브러리를 색인하지 않도록 지시한다.(커널은 C 표준을 사용하지 않는다.)

ctags인덱스 데이터베이스 생성한다.
이 단계를 가속화하기 위해 이미 만들어 둔 cscope.files을 사용한다
ctags -L cscope.files

cscope및 ctags인덱스 데이터베이스가 새롭게 생성된다.
cscope.files은 더이상 필요하지 않기 때문에 삭제한다.
rm -f cscope.files

생성된 다음 파일에는 색인 데이터베이스(cscope및 ctags)가 들어 있다.
- cscope.in.out
- cscope.out
- cscope.po.out
- tags

커널 vim 플러그인 설치
=====================
참고:  vim8 native package loading 사용 가능.
native package loading : https://shapeshed.com/vim-packages/

pathogen.vim 플러그인 설치
https://github.com/tpope/vim-pathogen
~/.vim/bundle/ 상태 유지 하면서 설치 한다.
mkdir -p ~/.vim/autoload && curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

vi .vimrc
execute pathogen#infect()

아무런 설정이 없다면 3줄 추가.
vi .vimrc
execute pathogen#infect()
syntax on
filetype plugin indent on

vim cscope 맵 설치
==================
현재 cscope 지원한다.
:help cscope

지정한 기호를 사용해 파일 이동 가능.
:cs f g kfree

단축키 사용.
cscope_maps.vim
https://github.com/joe-skb7/cscope-maps
git clone https://github.com/joe-skb7/cscope-maps.git ~/.vim/bundle/cscope-maps

커서를 일부 함수에 놓고 다음 키를 차례로 누르면 구현 부분으로 찾아간다.
Ctrl+\
g

키 맵핑에 관련해 다음 사이트를 참고한다.
https://github.com/joe-skb7/cscope-maps/blob/master/plugin/cscope_maps.vim#L52

ctags 참고
========
#define 선언을 찾을 때 탐색 하는 방법.
#define 커서 이동 후 다음 키를 순서대로 누른다.
g
Ctrl + ]

g
ctrl - ]

cscope 참고
===========
:cs f t struct device {

위의 명령은 특정 구조체 선언 스타일 (커널에서 사용됨)임.
다른 코딩 스타일을 가진 프로젝트에서는 작동하지 않을 수 있음.

out-of-tree 모듈 개발 노트
=========================
외부 트리 모듈을 개발할 경우 커널 디렉토리에서 데이터베이스 cscope와 ctags데이터베이스를 로드해야 한다.

외부 cscope 데이터베이스 로드:
:cs add /path/to/your/kernel/cscope.out

외부 ctags 데이터베이스 로드:
:set tags=/path/to/your/kernel/tags

커널 개발 지원 전용 vimrc 변경.
=============================
열 81 수직 적용(커널 코딩은 줄 길이를 최대 80 문자로 유지해야 함)
" 80 characters line
set colorcolumn=81
"execute "set colorcolumn=" . join(range(81,335), ',')
highlight ColorColumn ctermbg=Black ctermfg=DarkRed

80 열 이상을 강조 표시하려면 "execute "set colorcolumn=" . join(range(81,335), ',') 주석 처리 해제.

후행 공백은 커널 코딩 스타일에 의해 금지되므로 강조 표시 할 수 있다.
" Highlight trailing spaces
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()

커널 코딩 스타일 플러그인
=======================
https://github.com/vivien/vim-linux-coding-style

vi .vimrc
Plugin 'vim-linux-coding-style'

Plugin 'bogado/file-line'

나중 커널용 구성시 참고해 볼 만한 플러그인
https://github.com/vim-syntastic/syntastic
https://github.com/Valloric/YouCompleteMe

Omni completion
Vim 7 (및 그 이상)은 이미 자동 완성 지원 기능을 내장하고 있다.
자세한 내용 http://vimdoc.sourceforge.net/htmldoc/version7.html#new-omni-completion

큰 프로제그에서는 느리게 동작한다.
만약 사용한다면 .vimrc 내용 추가.
" Enable OmniCompletion
" http://vim.wikia.com/wiki/Omni_completion
filetype plugin on
set omnifunc=syntaxcomplete#Complete

" Configure menu behavior
" http://vim.wikia.com/wiki/VimTip1386
set completeopt=longest,menuone
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
inoremap <expr> <C-n> pumvisible() ? '<C-n>' :
  \ '<C-n><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'
inoremap <expr> <M-,> pumvisible() ? '<C-n>' :
  \ '<C-x><C-o><C-n><C-p><C-r>=pumvisible() ? "\<lt>Down>" : ""<CR>'

" Use Ctrl+Space for omni-completion
" https://stackoverflow.com/questions/510503/ctrlspace-for-omni-and-keyword-completion-in-vim
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
  \ "\<lt>C-n>" :
  \ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
  \ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
  \ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>

" Popup menu hightLight Group
highlight Pmenu ctermbg=13 guibg=LightGray
highlight PmenuSel ctermbg=7 guibg=DarkBlue guifg=White
highlight PmenuSbar ctermbg=7 guibg=DarkGray
highlight PmenuThumb guibg=Black

" Enable global scope search
let OmniCpp_GlobalScopeSearch = 1
" Show function parameters
let OmniCpp_ShowPrototypeInAbbr = 1
" Show access information in pop-up menu
let OmniCpp_ShowAccess = 1
" Auto complete after '.'
let OmniCpp_MayCompleteDot = 1
" Auto complete after '->'
let OmniCpp_MayCompleteArrow = 1
" Auto complete after '::'
let OmniCpp_MayCompleteScope = 0
" Don't select first item in pop-up menu
let OmniCpp_SelectFirstItem = 0

자동 완성 기능은 ctrl + space 사용.

색상 지정
=========
vi .bashrc
export TERM="xterm-256color"

vi .vimrc
set t_Co=256

색 구성 표 작성
==============
 ~/.vim/colors
현재 jellybeans.vim 구성 됨

cd .vim/colors
wget https://github.com/w0ng/vim-hybrid/blob/master/colors/hybrid.vim

cd ~/.vim/bundle
git clone git://github.com/altercation/vim-colors-solarized.git
mv vim-colors-solarized ~/.vim/bundle/

어두운 배경 설정
syntax enable
set background=dark
colorscheme solarized

밝은 배경 설정
syntax enable
set background=light
colorscheme solarized

원하는 색상 지정
vi .vimrc
Plugin 'mrkn256.vim'
Plugin 'hybrid.vim'

GUI eclipse IDE 사용 방법 분석
=============================
https://wiki.eclipse.org/HowTo_use_the_CDT_to_navigate_Linux_kernel_source

taglist 설치
============
wget http://vim-taglist.sourceforge.net/ 최신 버전 다운로드
플러그인 적용
$ mkdir ~/.vim
$ unzip taglist.zip

스크립트 생성
vim mktrace.sh

#!/bin/sh
rm -rf cscope.files cscope.files
rm -rf tags

find . \( -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' -o -name '*.s' -o -name '*.S' -o -name '*.asm' \) -print > cscope.files
ctags -R

cscope -i cscope.files

.vimrc 설정
vi .vimrc
" cscope 설정
set csprg=/usr/bin/cscope
set csto=0
set cst
set nocsverb

if filereadable("./cscope.out")
cs add cscope.out
else
cs add /usr/src/linux/cscope.out
endif
set csverb

vim 셀 접근
: VimShell

창 분할
vs, sp

vimrc 설정 내용

.vimrc
set nocompatible     " 오리지날 VI와 호환하지 않음
set autoindent       " 자동 들여쓰기
set cindent          " C 프로그래밍용 자동 들여쓰기
set smartindent      " 스마트한 들여쓰기
set wrap
set nowrapscan       " 검색할 때 문서의 끝에서 처음으로 안돌아감
set nobackup         " 백업 파일을 안만듬
set noswapfile
set ruler            " 화면 우측 하단에 현재 커서의 위치(줄,칸) 표시
set shiftwidth=4     " 자동 들여쓰기 4칸
set number           " 행번호 표시, set nu 도 가능
set fencs=ucs-bom,utf-8,euc-kr.latin1 " 한글 파일은 euc-kr로, 유니코드는 유니코드로
set fileencoding=utf-8 " 파일저장인코딩
set tenc=utf-8       " 터미널 인코딩
set hlsearch         " 검색어 강조, set hls 도 가능
set ignorecase       " 검색시 대소문자 무시, set ic 도 가능
set tabstop=4        " 탭을 4칸으로
set lbr
set incsearch        " 키워드 입력시 점진적 검색
set cursorline       " 편집 위치에 커서 라인 설정
set laststatus=2     " 상태바 표시를 항상한다
syntax on "  구문강조 사용
filetype indent on   " 파일 종류에 따른 구문강조
set background=dark  " 하이라이팅 lihgt / dark
colorscheme jellybeans  "  vi 색상 테마 설정
set backspace=eol,start,indent "  줄의 끝, 시작, 들여쓰기에서 백스페이스시 이전줄로
set history=1000     " vi 편집기록 기억갯수 .viminfo에 기록
highlight Comment term=bold cterm=bold ctermfg=4 " 코멘트 하이라이트
set mouse=a          " vim에서 마우스 사용
set t_Co=256         " 색 조정

set background=dark
colorscheme hybrid

set nocompatible              " be iMproved, required
filetype off                  " required

" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()

Plugin 'Tagbar'

" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'

" 바닥글
Plugin 'vim-airline/vim-airline'

" 바닥글 추가, 삭제, 변경 정보 확인.
Plugin 'tpope/vim-fugitive'

" 문법 체크
Plugin 'scrooloose/syntastic'

" IDE 파일 Tree
Plugin 'nerdtree'

" git 관리 파일 변경 부분 확인
Plugin 'airblade/vim-gitgutter'

" 색상 테마 적용
Plugin 'nanotech/jellybeans.vim'
Plugin 'mrkn256.vim'
Plugin 'hybrid.vim'

" 커피스크립트 Synatx
Plugin 'kchmck/vim-coffee-script'

Plugin 'DoxygenToolkit.vim'

" vimshell
Plugin 'shougo/vimshell.vim'
Plugin 'vimproc.vim'

Plugin 'kernel-coding-style'
Plugin 'unite.vim'

Plugin 'bogado/file-line'

Plugin 'cscope-maps'

call vundle#end()            " required
filetype plugin indent on    " required
execute pathogen#infect()

" 키 맵핑
" <F1> 폴딩
"map <F1> v]}zf
map <F1> :tabnew<cr>
" <F2> 창이동
map <F2> <C-w><C-w>
" <F3> NERDTree
map <F3> :NERDTreeToggle<cr>
" <F4> Tlist
"map <F4> :Tlist<cr>
map <F4> :TagbarToggle<cr>
" <F5> [i 정의 내용 보여주기
map <F5> [i
" <F6> gd 변수 선언으로 이동
map <F6> gd
" <F7> shell
map <F7> :VimShell<cr>
" <F8> Dox
map <F8> :Dox<cr>
" bnext, bprev
map <F11> :bp<cr>
map <F12> :bn<cr>
" tabn
map <S-Tab> gt<cr>
" bnext
map <S-F1> :bnext<cr>

" shift + p키에 파일 검색을 등록하고 shift + b에 buffer 목록 열기
nmap <S-p> :Unite file_rec/async<cr>
nmap <S-b> :Unite buffer<cr>

color jellybeans

set csverb

" 열 81 수직 적용(커널 코딩은 줄 길이를 최대 80 문자로 유지해야 함)
" 80 characters line
set colorcolumn=81
execute "set colorcolumn=" . join(range(81,335), ',')
highlight ColorColumn ctermbg=Black ctermfg=DarkRed
" 80 열 이상을 강조 표시하려면 "execute "set colorcolumn=" . join(range(81,335), ',') 주석 처리 해제.
"

" 후행 공백은 커널 코딩 스타일에 의해 금지되므로 강조 표시 할 수 있다.
" Highlight trailing spaces
" http://vim.wikia.com/wiki/Highlight_unwanted_spaces
highlight ExtraWhitespace ctermbg=red guibg=red
match ExtraWhitespace /\s\+$/
autocmd BufWinEnter * match ExtraWhitespace /\s\+$/
autocmd InsertEnter * match ExtraWhitespace /\s\+\%#\@<!$/
autocmd InsertLeave * match ExtraWhitespace /\s\+$/
autocmd BufWinLeave * call clearmatches()