iconv() 함수에서
변환결과로 나와야 하는 방법이 unicode일 경우에는 (일단 다른건 안해봤으니 -ㅁ-?)
(strlen(inbuf) + 2) * 2 가 된다.

size_t iconv(iconv_t cd,
                     char **inbuf, size_t *inbytesleft,
                     char **outbuf, size_t *outbytesleft);

예를 들어 UTF-8을 UNICODE로 변환시에는
UTF-8 문자열 특성상, stelen(utf8str) == 100 일 경우
유니코드(2바이트) 스트링은 최소 25에서 최대 100 까지 변환이 된다.

그리고 iconv 특성상 처음에 2바이트 BOM(Byte Order Mark)을 붙이므로
실질적으로 변환을 위해 필요로 하는 outbuf의 길이는
(strlen(inbuf) + 2) * 2 가 된다.

원래대로라면
(strlen(inbuf) + 1) * 2 + 2 이고
+1 은 '\0'
+2 는 Unicode BOM(0xFEFF in big endian)이다.

[링크 : http://mwultong.blogspot.com/2006/05/qna-unicode-bom-byte-order-mark.html]


덧 : UTF-8로 인코딩된 아랍어의 경우, 조합은 별도로 해주어야 한다.
iconv()가 UNICODE로 변환은 해주지만, 그렇다고 해서 조합까지 해주지는 않는다.
Posted by 구차니
물론 난 중간에 끼인 세대로서
일단은 취업을 했고, 그렇다고 해서 지금의 80년 중후반 세대처럼 죽네사네 하지도 않았고,
그렇다고 해서 90학번 이전 세대 처럼 몇백주고 pc 학원 다녀서 전산실 취업하고 띵까띵까 노는 세대도 아니고


솔찍히 환경적인 면이라던가, 배워야 하는 정보의 양에서
현재의 아이들은 과거의 어른이 되어버린 아이들보다 엄청나게 많다.
사회/기술은 발전해가고, 그로 인해서 점점 후대에 태어난 사람은
배워야 할건 많고, 기술의 발전속도는 더더욱 빨라지는 상황에서
인간이 받아들일수 있는 정보의 양은 한계가 있고, 습득할수 있는 양의 한계는 더욱 좁다.

90이전 학번들의
"우리때는 정보도 없고, 혼자서 맨땅에 헤딩해야 했어. 그에 비하면 너네는 인터넷도 있고 좋잖아~"
라는 드립을 듣고 있으면, 수긍보다는 짜증이 밀려온다.
"아 예. 그러셨쎄요? 맨땅에 헤딩할 시간도 있었고 좋으셨겠어요~"
라고 밖에 카운터를 날릴수가 없으니 답답하기만 하다.

천천히 기술이 개발하던 시기에 헤딩도 해서 답이 나올수준의 기술들.
그에 비하면 배우는 입장에 그들의 수준을 기준으로 이야기 하는 '보통'이라는 수준의 높이.
진심으로 묻고 싶다.

당신들이 c언어 기본도 하나도 모르는 상태에서 지금의 아이들 처럼 시작해서
어느정도 높이 까지 올라갈수 있겠는가? 지금의 88만원 세대들에게 70년대 헝그리 정신만으로
얼마나 기술을 습득하고 단기간에 배울수 있겠는가?


지금 아이들도 충분히 빡시다.
쓰지도 않을 쓸데없는 정보들에 묻혀
그리고 앞에 사람들이 배워왔던 그리고 장시간에 축적해온 기술들을 단시간에 흡수해야 하는데
그정도로도 충분히 이미 힘들어하는 아이들에게 얼마나 더 짐을 지으고 싶어 하는건가?


물론, 나역시 한때는 환경이 지랄맞아도
그 사람의 생각이 옳곧기만 하다면, 살인자 마을에서 성자가 날수도 있고,
환경이 나쁘다고 해서 나쁜 아이가 된건 그 아이의 잘못이라고 생각했다.

하지만, 돌이켜 보건데 내가 있었던 환경들이 나쁜건 아니었고
정말 진심으로 부모님들의 사랑을 받으면서 그때는 싫었던 것들이
지극히 정상적이고 소소한 일상이었고, 그 속에서 사랑을 듬뿍 받으면서 자랐다는걸 이제야 꺠달았을때
나의 그러한 생각들은, 내가 그만큼 미숙했기 때문이었기에 나온 그릇된 판단이었기 때문이다.



요약 :
당신들은 기술발전도 느린 시절부터 차곡차곡 배워왔지만,
지금의 아이들은 만렙과 싸워야 하는 1렙 초보이고, 당신들의 수준에 이르기 위해 필요로 하는 시간이
당신들 보다 상대적으로 적고, 배워야 할 것은 많다.

캠퍼스의 낭만?
웃기지도/ 좆까지도 말라고 그래라. 지금의 캠퍼스에 낭만이 있는가?
이미 경쟁으로 인해 피로 얼룩진 전장일 뿐이다.

당신들의 게으름으로 인해 다음세대들이 피를 더 흘리는 것을
왜 나약하다고 떠넘기기만 하는가?

[링크 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=69&MAEULNO=28&no=13894&page=2] 허약한
[링크 : http://www.devpia.com/MAEUL/Contents/Detail.aspx?BoardID=69&MAEULNO=28&no=13909&page=1] 나약해?

'개소리 왈왈 > 직딩의 비애' 카테고리의 다른 글

..............  (10) 2010.05.25
2009년 SW 기술자 노임 단가  (2) 2010.05.18
딱고 조이고 기름치고!  (0) 2010.04.21
출근일기 - 20100406  (6) 2010.04.06
주간회의 == 인민재판?  (0) 2010.04.06
Posted by 구차니
Programming/C Win32 MFC2010. 4. 22. 14:28

#include "stdio.h"

int main(int argc, char *argv[])
{
	int x = 1;
	printf("%d %d %d\n", ++x, x, x++);
	return 0;
}

You're running into two issues:

1. Undefined behavior -- you are attempting to modify the value of an
object more than once between sequence points, and the Standard imposes
no requirement on how to handle that behavior. Basically, any
expression of the forms:

i = i++;
j = k++ * k++;
foo(i,i++,--i);

invoke undefined behavior. Read up on the semantics of the "++" and
"--" operators in an *authoritative* reference (the Standard would
obviously be one, but also K&R2 or H&S5); they don't work the way most
people think they should.

2. Order of evaluation -- AFAIK, there's no requirement that
expressions in a function parameter list be evaluated in any particular
order. At first blush, it *looks* like the arguments were evaluated
from right to left (if x = 1, then x++ evaluates to 1, with the side
effect that x == 2, and ++x evaluates to 3, with the side effect that x
== 3), but given that you've invoked undefined behavior the actual
reason may be something else entirely.

[링크 : http://bytes.com/topic/c/answers/222558-operation-x-may-undefined]

위의 소스를 gcc -Wall 옵션을 주고 컴파일 할 경우에
$ gcc -Wall cc_test.c
cc_test.c: In function ‘main’:
cc_test.c:6: warning: operation on ‘x’ may be undefined
cc_test.c:6: warning: operation on ‘x’ may be undefined
이런 경고가 발생한다.

분명 x는 변수인데, 그에 대한 operation이 정의되지 않았다는게 무슨 말인지 모르겠지만,
아무튼 실행을 하면
$ ./a.out
3 3 1
요런 희한한 결과가 나온다.

아무튼, calling convention과도 연관이 있어 보이는데,
c언어 특성상 right-left 로 push 하므로(가장 위에는 왼쪽 값이 오도록)
가장 먼저들어가는, 오른쪽 x++ 은 1이 들어가고
1을 더해준다음, 다음 명령어를 수행하면서(++x) 한번에 2가 증가하게 되고
그럼으로 인해 x, ++x 순으로 3이 들어가는게 아닐까 생각된다.

아니면 말구?

[링크 : http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html]


winXP SP3 32bit / VC++ 6 에서 해본 결과
 2 1 1


linux / gcc 결과
 3 3 1


objdump를 소스와 함께 디스어셈블 하기 위해서는
gcc -g 옵션으로 디버깅 정보를 주어야 한다.
[링크 : http://wikidocs.net/mybook/1473]


솔찍히 어셈을 몰라서 모르겠다 ㅋㅋ
결론 : 한줄에 ++나 -- 연산자를 중복으로 사용하지 말자.
Posted by 구차니
프로그램 사용/VLC2010. 4. 22. 11:06
http://192.168.10.94:8080/?control=pause

현재 사용중인 PC의 ip가 192.168.10.94 이고, VLC 에서 웹 인터페이스를 켜놨을 경우
위와 같이 URL을 입력하면 플레이 중인 동영상이 일시정지 된다.
pause는 토글 방식으로, 한번 보내면 멈추고, 다시 보내면 재생된다.

위는 dreambox에서 PC의 VLC로 원격명령을 날리는 부분을, wireshark로 캡쳐한 화면

2010/04/21 - [프로그램 사용/VLC] - VLC를 웹 쿼리로 제어하기 - VLC web control

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

VLC - V4L2 modules  (0) 2010.07.03
VLC 1.1.0 Luggage  (0) 2010.07.03
VLC를 웹 쿼리로 제어하기 - VLC web control  (0) 2010.04.21
x264 와 h264의 관계?  (0) 2010.04.15
VLC nightly build  (0) 2010.04.13
Posted by 구차니
프로그램 사용/VLC2010. 4. 21. 15:08
VLC 에는 web interface 라는 넘이 있는데,
이녀석을 원격지에서 http query를 통해 제어가 가능하다.

윈도우에서 기본설치시
C:\Program Files\VideoLAN\VLC\http\requests 경로에 존재하는 파일을 읽어보면 될 듯 하다.

웹에서 접속시에는
http://localhost:8080/requests/filename.xml?query
식으로 하면된다.

아래는 readme.txt 파일
$Id$

This file describes commands available through the requests/ file:

Lines starting with < describe what the page sends back
Lines starting with > describe what you can send to the page

All parameters need to be URL encoded.
Examples:
 # -> %23
 % -> %25
 + -> %2B
 space -> +
 ...

status.xml:
===========
< Get VLC status information, current item info and meta.

> add <mrl> to playlist and start playback:
  ?command=in_play&input=<mrl>

> add <mrl> to playlist:
  ?command=in_enqueue&input=<mrl>

> play playlist item <id>:
  ?command=pl_play&id=<id>

> toggle pause. If current state was 'stop', play item <id>:
  ?command=pl_pause&id=<id>

> stop playback:
  ?command=pl_stop

> jump to next item:
  ?command=pl_next

> jump to previous item:
  ?command=pl_previous

> delete item <id> from playlist:
  ?command=pl_delete&id=<id>

> empty playlist:
  ?command=pl_empty

> sort playlist using sort mode <val> and order <id>:
  ?command=pl_sort&id=<id>&val=<val>
  If id=0 then items will be sorted in normal order, if id=1 they will be
  sorted in reverse order
  A non exhaustive list of sort modes:
    0 Id
    1 Name
    3 Author
    5 Random
    7 Track number

> toggle random playback:
  ?command=pl_random

> toggle loop:
  ?command=pl_loop

> toggle repeat:
  ?command=pl_repeat

> toggle enable service discovery module <val>:
  ?command=pl_sd&val=<val>
  Typical values are:
    sap
    shoutcast
    podcast
    hal

> toggle fullscreen:
  ?command=fullscreen

> set volume level to <val> (can be absolute integer, percent or +/- relative value):
  ?command=volume&val=<val>
  Allowed values are of the form:
    +<int>, -<int>, <int> or <int>%

> seek to <val>:
  ?command=seek&val=<val>
  Allowed values are of the form:
    [+ or -][<int><H or h>:][<int><M or m or '>:][<int><nothing or S or s or ">]
    or [+ or -]<int>%
    (value between [ ] are optional, value between < > are mandatory)
  examples:
    1000 -> seek to the 1000th second
    +1H:2M -> seek 1 hour and 2 minutes forward
    -10% -> seek 10% back

playlist.xml:
=============
< get the full playlist tree

browse.xml:
===========
< ?dir=<dir>
> get <dir>'s filelist

vlm.xml:
========
< get the full list of VLM elements

vlm_cmd.xml:
============
< execute VLM command <cmd>
  ?command=<cmd>
> get the error message from <cmd>



[링크 : http://forum.videolan.org/viewtopic.php?f=16&t=45842]

2009/12/08 - [프로그램 사용/VLC] - VLC 웹 인터페이스 원격지에서 안될경우
2009/11/24 - [프로그램 사용/VLC] - VLC web interface(웹 인터페이스)
Posted by 구차니
개소리 왈왈/영화2010. 4. 21. 11:09





내가 개띠이긴 하지만..
애인이 보내오는 애인네 고냥이를 보면..
고양이를 기르고 싶어진다.

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

아이언맨 2  (8) 2010.05.02
광화문 / 경복궁  (4) 2010.04.25
free for what?  (0) 2010.04.02
end of D+848  (0) 2010.03.29
그린존 (Grren zone, 2010)  (4) 2010.03.28
Posted by 구차니

CPU 쿨러를 들어내고 나서 찍은 사진..
3년만에 이정도 밖에 안쌓인거면 다행인건가?

아무튼, 쿨러 몇개는 거의 고장나서 기름 칠해주고 돌리니
뱅글뱅글~ 졸라 조용한 내 자리!
Posted by 구차니
개소리 왈왈2010. 4. 21. 01:48
1.
선이 있다.
왼쪽과 오른쪽이 생긴다.
아니 갈라진다.


왼쪽이 옳다면 오른쪽이 그르고
오른쪽이 옳다면 왼쪽이 그른것일까?

그렇다면 선을 따라가면 그건 틀린것일까




문득 후배의 넉두리를 듣고 있자니
내 몸 하나 건사하지 못하면서
남에 걱정이나 들어주는 내 신세가 답답하기만 해진다.



2.
어른이 되어간다는 것.
시스템을 안정화 시키면서 평균 출력을 올리되 최대 출력을 낮추는 것.
어쩌면 이것 이상도 이하도 아닌, 딱 이 수준이 아닐까 싶다.




3.

자면서 꾸는것도 꿈이고, 내가 무언가를 갈망하는 것도 꿈이지만
어른이 되어간다는 것과 더불어 부쩍 들어가는 상실감 중에
다중적인 꿈이 포함된게 아닐까 생각된다.

어느샌가부터 꿈을 꾸는지 조차 모르게 되었고
내가 지금 꾸고 있는 꿈이 구체화 되지 않고 있다.




4.
무와 유. 그리고 부유
지금 내 정신상태는 존재냐 사라지냐 그 경계선에서 두둥실 떠있다.
고 표현하는게 옳을지도 모르겠다.

근데.. 1번에서 처럼
정신줄 붙잡고 유를 지키는게 옳은일일까. 아니 제대로 된 일일까
아니면 사라지는게 옳은일일까. 이대로 있는건 어떨까?

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

페이스북 가입!  (4) 2010.04.28
비온다.  (8) 2010.04.26
딸기  (8) 2010.04.18
전 지대로 컴맹이빈다 /ㅁ/  (8) 2010.04.14
매정한 네이버  (12) 2010.04.12
Posted by 구차니
Linux2010. 4. 20. 22:43
예전글인 이녀석
2008/12/22 - [Linux] - 심볼릭 링크에 대한 미스테리
왜 심볼릭 링크의 크기는 파일크기와 문자열 길이가 동일할까? 라는 의문이 들었는데,
not null-terminated 라고 함은, inode 쪽에서 filename 변수를 가지고,
실제로 filename 변수에는 \0(=NULL)이 없기 때문이 아닐까 싶다.

i-node에는 파일의 속성이 저장되고,
디렉토리 구조체에 파일의 i-node와 파일의 이름이 저장된다.
# vi /usr/include/bits/dirent.h
struct dirent
  {
#ifndef __USE_FILE_OFFSET64
    __ino_t d_ino;
    __off_t d_off;
#else
    __ino64_t d_ino;
    __off64_t d_off;
#endif
    unsigned short int d_reclen;
    unsigned char d_type;
    char d_name[256];           /* We must not include limits.h! */
  };

# vi /usr/include/bits/stat.h
struct stat
  {
    __dev_t st_dev;                     /* Device.  */
    unsigned short int __pad1;
#ifndef __USE_FILE_OFFSET64
    __ino_t st_ino;                     /* File serial number.  */
#else
    __ino_t __st_ino;                   /* 32bit file serial number.    */
#endif
    __mode_t st_mode;                   /* File mode.  */
    __nlink_t st_nlink;                 /* Link count.  */
    __uid_t st_uid;                     /* User ID of the file's owner. */
    __gid_t st_gid;                     /* Group ID of the file's group.*/
    __dev_t st_rdev;                    /* Device number, if device.  */
    unsigned short int __pad2;
#ifndef __USE_FILE_OFFSET64
    __off_t st_size;                    /* Size of file, in bytes.  */
#else
    __off64_t st_size;                  /* Size of file, in bytes.  */
#endif
    __blksize_t st_blksize;             /* Optimal block size for I/O.  */

#ifndef __USE_FILE_OFFSET64
    __blkcnt_t st_blocks;               /* Number 512-byte blocks allocated. */
#else
    __blkcnt64_t st_blocks;             /* Number 512-byte blocks allocated. */
#endif
#ifdef __USE_MISC
    /* Nanosecond resolution timestamps are stored in a format
       equivalent to 'struct timespec'.  This is the type used
       whenever possible but the Unix namespace rules do not allow the
       identifier 'timespec' to appear in the  header.
       Therefore we have to handle the use of this header in strictly
       standard-compliant sources special.  */
    struct timespec st_atim;            /* Time of last access.  */
    struct timespec st_mtim;            /* Time of last modification.  */
    struct timespec st_ctim;            /* Time of last status change.  */
# define st_atime st_atim.tv_sec        /* Backward compatibility.  */
# define st_mtime st_mtim.tv_sec
# define st_ctime st_ctim.tv_sec
#else
    __time_t st_atime;                  /* Time of last access.  */
    unsigned long int st_atimensec;     /* Nscecs of last access.  */
    __time_t st_mtime;                  /* Time of last modification.  */
    unsigned long int st_mtimensec;     /* Nsecs of last modification.  */
    __time_t st_ctime;                  /* Time of last status change.  */
    unsigned long int st_ctimensec;     /* Nsecs of last status change.  */
#endif
#ifndef __USE_FILE_OFFSET64
    unsigned long int __unused4;
    unsigned long int __unused5;
#else
    __ino64_t st_ino;                   /* File serial number.  */
#endif
  };

다르게 생각해 보자면,
directory table에 파일 이름이 저장되고, (심볼릭 링크)
속성으로 심볼릭 링크가 지정되며,
inode의 filesize는 string이 아닌 data로서 \0(=NULL)이 빠진 순수한 원본 경로만 들어가서
ls 시의 심볼릭 링크 파일의 크기가 예상과 달리 -1 크기로 나오는게 아닐까 싶다.

#include <unistd.h>
ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);

Return Value
Upon successful completion, readlink() shall return the count of bytes placed in the buffer. Otherwise, it shall return a value of -1, leave the buffer unchanged, and set errno to indicate the error.

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

The readlink function gets the value of the symbolic link filename. The file name that the link points to is copied into buffer. This file name string is not null-terminated; readlink normally returns the number of characters copied. The size argument specifies the maximum number of characters to copy, usually the allocation size of buffer.

[링크 : http://www.gnu.org/s/libc/manual/html_node/Symbolic-Links.html]

APPLICATION USAGE
    Conforming applications should not assume that the returned contents of the symbolic link are null-terminated.

RATIONALE
    Since IEEE Std 1003.1-2001 does not require any association of file times with symbolic links, there is no requirement that file times be updated by readlink(). The type associated with bufsiz is a size_t in order to be consistent with both the ISO C standard and the definition of read(). The behavior specified for readlink() when bufsiz is zero represents historical practice. For this case, the standard developers considered a change whereby readlink() would return the number of non-null bytes contained in the symbolic link with the buffer buf remaining unchanged; however, since the stat structure member st_size value can be used to determine the size of buffer necessary to contain the contents of the symbolic link as returned by readlink(), this proposal was rejected, and the historical practice retained.

[링크 : http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html]

'Linux' 카테고리의 다른 글

ubuntu 9.10 에서 APM + viewvc + cvsgraph 돌리기  (0) 2010.04.28
enscript  (0) 2010.04.28
pwd(getcwd), cd(chdir)  (4) 2010.04.19
wget  (4) 2010.04.10
/dev의 major minor에 대하여  (0) 2010.04.08
Posted by 구차니
프로그램 사용/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 구차니