1 / 13

ex6-5

ex6-5. 2007242145 황용 하. 프로세스 환경 변수 : getenv, putenv. 목차. envp 이란 ? getenv 와 putenv 가 무엇 ? 소스코드 설명 구 현. envp 이란 ?. envp (environment program) Linux 환경은 shell 변수들로 이루어짐 shell 변수들은 stack 에 저장 되어있음 접근방법 : argument( 행인수 ) 를 접근하는 것처럼 main 함수에 파라미터를 하나 추가. envp 이란 ?(windows).

poppy
Download Presentation

ex6-5

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. ex6-5 2007242145 황용하 프로세스 환경 변수 : getenv, putenv

  2. 목차 • envp 이란? • getenv와 putenv가 무엇? • 소스코드 설명 • 구현

  3. envp 이란? • envp(environment program) • Linux 환경은 shell 변수들로 이루어짐 • shell변수들은 stack에 저장 되어있음 • 접근방법: argument(행인수)를접근하는 것처럼 main함수에 파라미터를 하나 추가

  4. envp 이란?(windows)

  5. envp 이란?(linux)

  6. getenv와 putenv가 무엇? • environ은 환경변수들이 저장된 테이블의 시작주소를 갖고있음 • 프로그램에서 extern char **environ; 으로 선언하여 환경 변수에 접근

  7. getenv와 putenv가 무엇? • getenv()는주어진 셀 변수의 값이 저장된 주소를 반환 • environ 변수를 사용하여 검색 하는 것보다 편리 • putenv()는 name = value 형태의 셀 변수를 환경 변수 테이블에 추가 혹은 수정

  8. getenv와 putenv가 무엇? • getenv: • 환경 리스트(environ) 를 검색 • name = value형태의 문자열을 찾음 • 그 문자열이 있으면 현재 환경리스트 내의 값 value를 가르키는 포인터를 반환 • 그렇지 않으면 null을 반환

  9. getenv와 putenv가 무엇? • putenv: • string은 “name = value”형의 문자열을 가르킴 • 존재하는 변수를 바꾸거나, 새로운 것을 생성해서 환경 변수 name의 값을 value와 같게 함 • string이 함수 내에서 선언 될 경우 static으로 선언 되어야 함

  10. 소스코드 설명

  11. 예제 설명 • 자신의 환경 변수를 모두 출력하는 프로그램 작성 • 환경변수 Time Zone을 변경한 후 변경된 내용을 출력 • 새로운 환경변수에 WARNING값을 설정 후 그 내용을 출력

  12. 소스코드 설명

  13. 구현

More Related