Develop
2003.04.23 09:44

[c] CGI Library to C^^

Views 8421 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

C언어의 CGI 라이브러리 함수


C언어의 구체적인 설명은 약하고 함수의 기능만 설명한다. 예제는 처음에 나오는 getword()함수만 우선 살펴보겠다.


#include <stdio.h>

#include "cgiutil.h"

void main()

{

    char *qs;

    qs = getenv("QUERY_STRING");

    

    printf("Content-type: text/html\n\n");

    printf("CGI 프로그램 : %s", qs);

}



#include <stdlib.h>

#include "cgiutil.h"

void main(int argc, char *argv[]) {

     char buf[200];

     char exeFile[BUFSIZE];

     strcpy(exeFile, argv[1]);

     while(1) {

          getword(buf, exeFile, '/');

          if(!strchr(exeFile, '/'))

             break;

     }

     printf(exeFile);

}


void getword(char *word, char *line, char stop) : 라인으로 전달되어온 문자열을 지정된 stop지시문자까지 읽어서 *word에 리턴하고, 그 다음부터 나오는 문자열을 line에 전달한다. 즉, line으로 온 문자열을 stop에서 지시한 구분자로 분리하여 앞의 것은 word에 뒤의 것은 line에 전달한다. 


char *makeword(char *line, char stop) : getword()와 같은 기능을 하되 getword()가 인자에 의해 값을 전달함에 비해 이 함수는 리턴값에 의해 결과를 전달한다. 


char *fmakeword(FILE *f, char stop, int *cl) : 파일 스트림에서 stop문자 전까지 읽어서 리턴값으로 돌려주고, 그 문자수만큼 cl값을 차감한다. 이것은 문자열의 크기만큼 매번 메모리 할당을 해야하는 번거로움을 줄이기 위해 사용한다.


char *smakeword(char *str, char stop, int *cl) : fmakeword()함수와 같은 기능을 하되, 파일 포인터를 인자로 받지 않고 문자열 포인터를 인자로 받는다. 


void plustospace(char *str) : 웹브라우저에서 인코딩된 '+'를 다시 원래 값인 스페이스로 치환한다.


int ind(char *s, char c) : 문자열 s에서 지정 문자 c가 나타나는 인덱스를 리턴한다. 인덱스는 0부터 시작하고, 없으면 -1을 리턴한다. 


int rind(char *s, char c) : int()함수와 같은 기능을 하되 문자열을 뒤에서 부터 찾는다. 


int getline(char *s, int n, FILE *f) : 파일스트림 f에서 n바이트를 읽어 문자열 s에 치환한다. 만약에 파일의 끝에 도달하면 1을, 그렇지 않으면 0을 리턴값으로 한다. 


void send_fd(FILE *f, FILE *fd) : 파일스트림 f를 fd로 복사한다. 


void escape_shell_cmd(char *cmd) : 특수문자 앞에 를 붙여서 제어문자로 작동하지 않도록 한다. 


char *rmCtrlChar(char *str) : &amp;, ", &lt;, &gt; 등과 같이 프로그램 처리나 보안상 문제가 될만한 문자를 제거한다. 


char rmCrLf(char *str) : Carriage Return이나 Line Feed문자를 제거한다. 


void prtErrMsg(char *str) : 모든 에러 메시지를 정형화된 형태로 출력한다. 


void back(void) : 직전 메뉴로 이동하는 앵커를 준비한다.


?

  1. [php] whois정보 조회 프로그램

    Date2003.04.23 CategoryDevelop Byhooni Views11733
    Read More
  2. [c] 최대공약수 알고리즘 (유클릿)

    Date2003.04.23 CategoryDevelop Byhooni Views8873
    Read More
  3. [c] 소수점 반올림^^

    Date2003.04.23 CategoryDevelop Byhooni Views8478
    Read More
  4. [c] 하노이탑 - 재귀함수

    Date2003.04.23 CategoryDevelop Byhooni Views9153
    Read More
  5. [c] 팩토리얼.. - 재귀함수

    Date2003.04.23 CategoryDevelop Byhooni Views9500
    Read More
  6. [c] 간단한 채팅(클라이언트/서버) 프로그램 소스

    Date2003.04.23 CategoryDevelop Byhooni Views9068
    Read More
  7. [c] 그래픽스 자료(OpenGL 라이브러리) 샘플 소스

    Date2003.04.23 CategoryDevelop Byhooni Views10181
    Read More
  8. [opengl] 컴퓨터 그래픽스 강의 자료(수업자료)

    Date2003.04.23 CategoryDevelop Byhooni Views20432
    Read More
  9. [c++] p.47 연습문제 3번

    Date2003.04.23 CategoryDevelop Byhooni Views10105
    Read More
  10. [c++] p.58 연습문제 2번

    Date2003.04.23 CategoryDevelop Byhooni Views16296
    Read More
  11. [c++] p.118 확인학습 5번

    Date2003.04.23 CategoryDevelop Byhooni Views10734
    Read More
  12. [c] 프로그래밍 ppt, 스킬업 (비트 수업자료)

    Date2003.04.23 CategoryDevelop Byhooni Views8177
    Read More
  13. [css] 스크롤바 안생기게

    Date2003.04.23 CategoryDevelop Byhooni Views9886
    Read More
  14. [c] 민수형 libipq 샘플 소스 ㅋㅋ

    Date2003.04.23 CategoryDevelop Byhooni Views14112
    Read More
  15. [php] 니우쪽지다.. 받아라~ ^^

    Date2003.04.23 CategoryDevelop Byhooni Views9834
    Read More
  16. [c++]현승이가 보내준 동영상 암호화 자료.. 볼것..

    Date2003.04.23 CategoryDevelop Byhooni Views9728
    Read More
Board Pagination Prev 1 2 3 4 5 ... 53 Next
/ 53