프로그램 사용/busybox2010. 4. 20. 20:08
원인은 못찾았지만, 커널 옵션에서 quiet 주어도 나오길래, 최소한 커널 오류는 아닌것으로 판단
busybox에서 찾아보니

./shell/ash.c:4849:     ash_msg_and_raise_error("cannot open %s: %s", fname, errmsg(errno, "no such file"));

한녀석이 걸려 나온다.

특이한건, 이 소스가 있는 부분은 openredirect라는 함수.
음.. 머하는 녀석일려나?

static int
openredirect(union node *redir)
{
    char *fname;
    int f;

    switch (redir->nfile.type) {
    case NFROM:
        fname = redir->nfile.expfname;
        f = open(fname, O_RDONLY);
        if (f < 0)
            goto eopen;
        break;
    case NFROMTO:
        fname = redir->nfile.expfname;
        f = open(fname, O_RDWR|O_CREAT|O_TRUNC, 0666);
        if (f < 0)
            goto ecreate;
        break;
    case NTO:
        /* Take care of noclobber mode. */
        if (Cflag) {
            fname = redir->nfile.expfname;
            f = noclobberopen(fname);
            if (f < 0)
                goto ecreate;
            break;
        }
        /* FALLTHROUGH */
    case NCLOBBER:
        fname = redir->nfile.expfname;
        f = open(fname, O_WRONLY|O_CREAT|O_TRUNC, 0666);
        if (f < 0)
            goto ecreate;
        break;
    case NAPPEND:
        fname = redir->nfile.expfname;
        f = open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666);
        if (f < 0)
            goto ecreate;
        break;
    default:
#if DEBUG
        abort();
#endif
        /* Fall through to eliminate warning. */
    case NTOFD:
    case NFROMFD:
        f = -1;
        break;
    case NHERE:
    case NXHERE:
        f = openhere(redir);
        break;
    }

    return f;
 ecreate:
    ash_msg_and_raise_error("cannot create %s: %s", fname, errmsg(errno, "nonexistent directory"));
 eopen:
    ash_msg_and_raise_error("cannot open %s: %s", fname, errmsg(errno, "no such file"));
}


2010.04.21 추가
inittab에 ttyAS1을 초기화 하는 부분이 있었는데, 커널에서(?) 사용하지 않도록 해놔서 계속 에러가 난 모양이다.
아무튼, /bin/sh에 ttyAS1을 열도록 해놓았기 때문에, busybox에서 ash이 sh을 대체하고,
그러다 보니 ash에서 에러발생. 머.. 문제 해결 끝!

$ cat target/etc/inittab
# Example Busybox inittab
::sysinit:/etc/init.d/rcS
ttyAS0::askfirst:/bin/sh
ttyAS1::askfirst:/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/sbin/swapoff -a
::shutdown:/bin/umount -a -r
::restart:/sbin/init

'프로그램 사용 > busybox' 카테고리의 다른 글

busybox tftp  (0) 2013.06.18
busybox - setconsole  (0) 2011.10.21
busybox ps는 BSD 스타일?  (0) 2010.01.12
ifup / ifdown 을 통한 static <-> dhcp 변환  (0) 2009.12.29
udhcpd 용 interface 예제  (0) 2009.12.23
Posted by 구차니
iconv_open() 함수는 dest, source 형식으로 인자를 받고
iconv() 함수는 2중 포인터를 사용한다.

#include <iconv.h>

iconv_t iconv_open(const char *tocode, const char *fromcode);
size_t iconv(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);

iconv_open(TO, FROM);
이므로 반대로 넣으면 이상하게 나온다. 주의요망!

그리고 iconv() 함수는
문자열 변수들은 2중 포인터로 넘겨주고(왜?)
inbytesleft는 strlen(*inbuf) 의 값을
outbytesleft는 strlen(*outbuf) 의 값을 넣어주면된다.

물론 변환에 따라서, 길이가 가변적으로 달라질수 있기 때문에 주의해야 한다.

만약, 변환중 메모리가 넘치게 되면 EILSEQ 에러가 발생하게 되며, (물론 넘치기 전에 데이터는 빼낼수 있다.)
변수의 포인터가 2중 포인터가 아니면
"__gconv: Assertion `outbuf != ((void *)0) && *outbuf != ((void *)0)' failed."
이런 에러를 만나게 될 것이다.


#include "stdio.h"
#include "string.h"
#include "iconv.h"
#include "errno.h"

#define BUFF_SIZE 64

int main()
{
        iconv_t cd = iconv_open("UNICODE", "UTF-8");
        if (cd == (iconv_t)(-1))
        {
                perror("iconv_open");
                return 0;
        }

        char inBuf[BUFF_SIZE] = "Hello world";
        int inBufSize = sizeof(inBuf);

        char outBuf[BUFF_SIZE];
        int outBufSize = sizeof(outBuf);
        memset(outBuf, 0, outBufSize);

        // convert
        size_t readBytes = strlen(inBuf);
        size_t writeBytes = sizeof(outBuf);
        char* in = inBuf;
        char* out = outBuf;

        printf("readBytes:%d writeBytes:%d\n",readBytes,writeBytes);

        if (iconv(cd, &in, &readBytes, &out, &writeBytes) == -1)
        {
                printf("failed to iconv errno:%d EILSEQ:%d\n", errno, EILSEQ);
        }
        else
        {
                int idx;
                printf("in:%x out:%x\n",in,out);
                printf("readBytes:%d writeBytes:%d\n",readBytes,writeBytes);
                for(idx = 0; idx < BUFF_SIZE; idx++)
                {
                        printf("%03d %c %x\t\t", idx, inBuf[idx], inBuf[idx]);
                        printf("%03d %c %x\n", idx, outBuf[idx], outBuf[idx]);
                }
                outBuf[writeBytes] = '\0';
        }

        iconv_close(cd);
        return 0;
}


2010/04/20 - [Linux] - linux iconv 테스트
2010/04/19 - [Linux] - iconv

Posted by 구차니
iconv 유틸리티를 이용해서 일단 변환 테스트.
-f=UTF-8        (UTF-8 문서를)
-t=UNICODE   (유니코드로 변환)
-o result.txt    (result.txt로 출력)

$ cat test.str
Hello world
$ vi test.str
  1 Hello world

$ iconv -f=UTF8 -t=UNICODE test.str -o result.txt

$ cat result.txt
▒▒Hello world
$ vi result.txt
  1 ÿþH^@e^@l^@l^@o^@ ^@w^@o^@r^@l^@d^@
  2 ^@




Posted by 구차니
언어는 &hl
국가는 &gl 로 변수를 넘겨준다.
(웹상에서 언어를 변경할때는 이렇게 되는데 RSS Feed에는 영향을 미치지 못하는 것으로 보인다.)

http://gdata.youtube.com/feeds/api/standardfeeds/regionID/feedID?v=2

http://gdata.youtube.com/feeds/api/standardfeeds/ko/top_rated
위의 주소는, 한국의 top rated를 받아오는 방법이다.

Country Region ID
Australia AU
Brazil BR
Canada CA
Czech Republic CZ
France FR
Germany DE
Great Britain GB
Holland NL
Hong Kong HK
India IN
Ireland IE
Israel IL
Italy IT
Japan JP
Mexico MX
New Zealand NZ
Poland PL
Russia RU
South Korea KR
Spain ES
Sweden SE
Taiwan TW
United States US

[링크 : http://code.google.com/intl/ko-KR/apis/youtube/2.0/reference.html]

http://gdata.youtube.com/schemas/2007/categories.cat?hl=<LANGUAGE>
위의 내용은, 스키마를 언어별로 받아오는 것이다.
간단하게 카테고리별 문자열을 구글에게서 받아올수 있다.(내부적인 번역이 필요없다!)

Language/Locale hl Parameter Value
Chinese (Traditional) zh-TW
Czech cs-CZ
Dutch nl-NL
English (Great Britain, Ireland, Australia and New Zealand) en-GB
English (United States and Canada)
* default value
en-US
French fr-FR
German de-DE
Italian it-IT
Language/Locale hl Parameter Value
Japanese ja-JP
Korean ko-KR
Polish pl-PL
Portuguese (Brazil) pt-BR
Russian ru-RU
Spanish (Spain) es-ES
Spanish (Mexico) es-MX
Swedish sv-SE

[링크 : http://code.google.com/intl/ko-KR/apis/youtube/2.0/reference.html]

Posted by 구차니
http://gdata.youtube.com/feeds/api/
에서 XML 파일을 받으면 기본적으로

<openSearch:startIndex>1</openSearch:startIndex>
<openSearch:itemsPerPage>25</openSearch:itemsPerPage>

첫번째 페이지, 25개 항목을 받아오도록 되어있다.
즉, 인자를 넘겨주면 다른 값을 볼수도 있다는 의미!

<link rel='previous' type='application/atom+xml'
  href='http://gdata.youtube.com/feeds/api/videos?start-index=1&max-results=25...'/>
<link rel='next' type='application/atom+xml'
  href='http://gdata.youtube.com/feeds/api/videos?start-index=51&max-results=25...'/>

[링크 : http://code.google.com/intl/ko-KR/apis/youtube/2.0/reference.html]


2010.05.07 추가
start-index 는 대소문자 구분하며, 1 부터 시작한다.

'프로그램 사용 > 유튜브(youtube)' 카테고리의 다른 글

youtube api 변동으로 인한 content 태그 변경  (0) 2010.05.13
youtube locale 관련  (0) 2010.04.20
youtube html5  (2) 2010.04.17
Percent encoding = URL Encoding  (0) 2010.04.16
유튜브 fmt 와 t 값  (0) 2010.04.15
Posted by 구차니
Linux2010. 4. 19. 17:13
리눅스에서 cd는 디렉토리를 변경하고,
pwd는 현재 작업 디렉토리를 보여준다.

그걸 api 수준에서 보자면
cd는 chdir() 이고
pwd는 getcwd() 이다.

long getcwd(char *buf, unsigned long size);

#include <unistd.h>
int chdir(const char *path);
int fchdir(int fd);

[링크 : http://linux.die.net/man/3/getcwd]
[링크 : http://linux.die.net/man/3/chdir]


2010.04.20 추가

코드샘플
#include "unistd.h"

void main()
{
	int ret;
	char buff[256];
	
	getcwd(buff, 255);
	printf("%s\n",buff);
	
	ret = chdir("/etc");

	getcwd(buff, 255);
	printf("%s\n",buff);	
}

Posted by 구차니
iconv는 utf 나 iso8859 등, 여러가지 방법으로
문자열 코딩을 변환해주는 역활을 하는 함수/유틸리티이다.

$ man -k iconv
iconv                (1)  - Convert encoding of given files from one encoding to another
iconv                (1p)  - codeset conversion
iconv                (3)  - perform character set conversion
iconv                (3p)  - codeset conversion function
iconv.h [iconv]      (0p)  - codeset conversion facility
iconv_close          (3)  - deallocate descriptor for character set conversion
iconv_close          (3p)  - codeset conversion deallocation function
iconv_open           (3)  - allocate descriptor for character set conversion
iconv_open           (3p)  - codeset conversion allocation function
아무튼, iconv는 함수(3/3p) 이자 유틸리티(1) 인데
함수의 경우 iconv_open() - iconv() - iconv_close() 를 이용하여 사용한다.

#include <iconv.h>
iconv_t iconv_open(const char *tocode, const char *fromcode);

tocode나 fromcode에 들어갈 내용은
명령어로 확인이 가능하다.

$ ldd /usr/bin/iconv
        linux-gate.so.1 =>  (0x005e5000)
        libc.so.6 => /lib/libc.so.6 (0x47ae8000)
        /lib/ld-linux.so.2 (0x47119000)
ldd로 확인해보니, libc만 있으면 실질적으로 구동이 가능한 함수로 보인다.

테스트가 필요한 코드
[링크 : http://kldp.org/node/77391]
[링크 : http://www.korone.net/bbs/board.php?bo_table=etc_misc&wr_id=160&page=2]
Posted by 구차니
개소리 왈왈2010. 4. 18. 20:53
옥상에 어머니의 강력한 추진으로 인해
딸기 12 녀석이 폭폭폭!

아무튼 분홍꽃 / 흰꽃이 있는데 꽃집에서 하는 말이
흰꽃은 열매가 하나만 열리고,
분홍꽃은 열매가 여러개 열린다고 하는데..


머.. 열려 보면 알겠지?

'개소리 왈왈' 카테고리의 다른 글

비온다.  (8) 2010.04.26
참 혹은 거짓. 그리고 경계  (0) 2010.04.21
전 지대로 컴맹이빈다 /ㅁ/  (8) 2010.04.14
매정한 네이버  (12) 2010.04.12
구차니로 컴백합니다  (0) 2010.04.05
Posted by 구차니
IBM 문서인데,
결국 XML 탐색은 tagname이 유일하거나 혹은 name space로 구분함으로서
실질적으로 유일한 tag name을 주어 키워드로 검색하고
그에 따른 child나 parent 이런식으로 검색을 용이하게 하는 것으로 보인다.

결론 : 결국은 범용 XML 리더는 존재하지 않고, 개별 XML 구조에 맞도록 읽어 와야 한다는 것으로 판단됨.

[링크 : http://www.ibm.com/developerworks/kr/library/x-xmlajaxpt1/]
Posted by 구차니
음.. 역시 모든 언어는 skeleton code를 외우면 상대적으로 익히기가 쉬운듯!
(문득 C언어 배울때 #include <stdio.h> void main() {} 하던 기억이.. OTL)

.386
.MODEL Flat, STDCALL
.DATA
; Your initialized data. <comment>
.DATA?
;Your uninitialized data. <comment>
.CONST
.CODE
label:
    end label

[링크 : http://win32assembly.online.fr/tut1.html]

'Programming > Assembly(어셈블리)' 카테고리의 다른 글

.DATA? 지시어  (0) 2011.07.31
x86 register  (2) 2011.07.17
PowerPC(PPC) 어셈관련 내용  (0) 2011.04.04
어셈블리 메모리 참조 (x86 memory addressing)  (0) 2010.05.03
어셈블리 언어  (0) 2010.05.03
Posted by 구차니