'2019/06/24'에 해당되는 글 7건

  1. 2019.06.24 sgrep
  2. 2019.06.24 expat 다시 사용..
  3. 2019.06.24 libpq
  4. 2019.06.24 python expat parseFile()
  5. 2019.06.24 ubuntu에서 python으로 postgres 접속하기
  6. 2019.06.24 fopen64
  7. 2019.06.24 ddi tcon
Linux2019. 6. 24. 21:19

structure grep 이라고 하는데

대충 찾아봤지만.. 검색된 내용을 개별 파일로 저장하는 기능만 있으면 딱일텐데 그게 없어서 많이 아쉽..

일단 사용법은 아래와 같이 express 부분에

'"from pattern" .. "end pattern"' 식으로 해주면 되긴 한다.

sgrep '("<TITLE>" .. "</TITLE>") or ("<H1>" .. "</H1>") or \
	("<H2>" .. "</H2>") or ("<H3>" .. "</H3>") or \
	("<H4>" .. "</H4>") or ("<H5>" .. "</H5>") or \ 
	("<H6>" .. "</H6>") or ("<H7>" .. "</H7>") or\
	("<H8>" .. "</H8>") or ("<H9>" .. "</H9>")'


[링크 : https://www.cs.helsinki.fi/u/jjaakkol/sgrepexamples.html]

'Linux' 카테고리의 다른 글

wget -m (mirror)  (0) 2019.06.26
bash argument list is too long  (0) 2019.06.25
리눅스 캐시 비우기  (0) 2019.06.19
gzip -k  (0) 2019.06.18
diff: memory exhausted  (0) 2019.06.18
Posted by 구차니

그나저나 망할(?) &lt를 <로 바꿔버리는 바람에 귀찮아지네...

특수문자를 건드리지 않고 바이패스 하는법 없으려나?

 

#include <stdio.h>
#include <string.h>
#include <expat.h>

#ifdef XML_LARGE_SIZE
# if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400
#  define XML_FMT_INT_MOD "I64"
# else
#  define XML_FMT_INT_MOD "ll"
# endif
#else
# define XML_FMT_INT_MOD "l"
#endif

#ifdef XML_UNICODE_WCHAR_T
# define XML_FMT_STR "ls"
#else
# define XML_FMT_STR "s"
#endif

#define BUFFSIZE        8192

char Buff[BUFFSIZE];
char Buff_con[BUFFSIZE];

int Depth;
XML_Parser p;

static void XMLCALL
start(void *data, const XML_Char *el, const XML_Char **attr)
{
  int i;
  (void)data;

  for (i = 0; i < Depth; i++)
    printf("\t");

  printf("<%" XML_FMT_STR, el);

  for (i = 0; attr[i]; i += 2) {
    printf(" %" XML_FMT_STR "=\"%" XML_FMT_STR "\"", attr[i], attr[i + 1]);
  }

  printf(">");
//  printf(">\n");
  Depth++;
}

static void XMLCALL
data(void *data, const XML_Char *s, int len)
{
        if(len > 0)
        {
        memcpy(Buff_con, s, len);
        Buff_con[len] = '\0';
        printf("%s", Buff_con);
        }
}

static void XMLCALL
end(void *data, const XML_Char *el)
{
  int i;
  (void)data;
  (void)el;

//  for (i = 0; i < Depth; i++)
//    printf("\t");

  printf("</%" XML_FMT_STR, el);
  printf(">");
//  printf(">\n");
  Depth--;
}

int
main(int argc, char *argv[])
{
//  XML_Parser p = XML_ParserCreate(NULL);
  p = XML_ParserCreate(NULL);
  (void)argc;
  (void)argv;

  if (! p) {
    fprintf(stderr, "Couldn't allocate memory for parser\n");
    exit(-1);
  }

  XML_SetElementHandler(p, start, end);
  XML_SetCharacterDataHandler(p, data);
  XML_SetParamEntityParsing(p, XML_PARAM_ENTITY_PARSING_NEVER);

  for (;;) {
    int done;
    int len;

    len = (int)fread(Buff, 1, BUFFSIZE, stdin);
    if (ferror(stdin)) {
      fprintf(stderr, "Read error\n");
      exit(-1);
    }
    done = feof(stdin);

    if (XML_Parse(p, Buff, len, done) == XML_STATUS_ERROR) {
      fprintf(stderr,
              "Parse error at line %" XML_FMT_INT_MOD "u:\n%" XML_FMT_STR "\n",
              XML_GetCurrentLineNumber(p),
              XML_ErrorString(XML_GetErrorCode(p)));
      exit(-1);
    }

    if (done)
      break;
  }
  XML_ParserFree(p);
  return 0;
}

 

start / end

[링크 : https://github.com/libexpat/libexpat/blob/master/expat/examples/elements.c]

 

data

[링크 : https://stackoverflow.com/questions/609376/geting-xml-data-using-xml-parser-expat]

 

 

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

GPX TCX 포맷  (0) 2013.06.22
Javascript DOM API / XML  (2) 2010.07.13
[해결중] expat 버퍼 관련 문제  (0) 2010.05.25
expat으로 smi 자막파일 파싱은 불가?  (0) 2010.05.03
SAX (Simple API for XML)  (0) 2010.04.23
Posted by 구차니

c용 postgresql 라이브러리

libpg-dev를 설치하면 되려나?

 

[링크 : https://www.postgresql.org/docs/9.1/libpq-example.html]

[링크 : https://www.postgresql.org/docs/9.5/libpq-connect.html]

[링크 : http://www.askyb.com/cpp/c-postgresql-example/] cpp class

 

 

+

sudo apt-get install libpq-dev

vi pg_exam.c

#include <postgresql/libpq-fe.h>

gcc pg_exam.c -lpq

./a.out "dbname=postgres host=localhost user=postgres password=postgres"

[링크 : https://www.postgresql.org/docs/8.3/libpq-build.html]

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

postgresql ''  (0) 2019.06.25
postgresql truncate table  (0) 2019.06.25
xsd to postgresql DDL  (0) 2019.06.18
postgresql dbms 설정  (0) 2019.06.14
pgadmin dashboard 살려내기  (0) 2019.06.13
Posted by 구차니

python의 expat을 써보려는데 원하는대로 안되서 멘붕 중

 

xmlparser.ParseFile(file)
Parse XML data reading from the object file. file only needs to provide the read(nbytes) method, returning the empty string when there’s no more data.

[링크 : https://docs.python.org/3.1/library/pyexpat.html]

 

>>> r = open('18549666.xml')
>>> p.ParseFile(r)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: read() did not return a bytes object (type=str)

 

rb(read binary)가 중요한거였냐..

>>> r = open('18549666.xml','rb')

[링크 : https://stackoverflow.com/questions/1179305/expat-parsing-in-python-3]

Posted by 구차니

 

$ sudo apt install postgresql-server-dev-all

$ pip3 install psycopg2

$ python3

import psycopg2 as pg2 
conn=pg2.connect(database="postgres",user="postgres",password="1234",host="localhost",port="5432") 
cur = conn.cursor() 
cur.execute("select * from table_name") 
cur.fetchall()

[링크 : https://freeprog.tistory.com/100]

'Programming > python(파이썬)' 카테고리의 다른 글

python pip 특정 버전설치 / 목록에서 설치  (0) 2019.09.09
python expat parseFile()  (0) 2019.06.24
python pip 특정 버전 설치하기  (0) 2019.06.18
python pdb를 이용한 디버깅  (0) 2019.05.15
anaconda(python)  (0) 2019.05.15
Posted by 구차니
Linux API/linux2019. 6. 24. 13:55

이걸 써야 하는지 안써도 되는데

그게 아니라면 -D_LARGEFILE_SOURCE 만 켜주면 되는건가?

 

[링크 : https://resetme.tistory.com/43]

[링크 : https://kldp.org/node/479]

[링크 : https://www.mkssoftware.com/docs/man3/fopen.3.asp]

 

[링크 : https://stackoverflow.com/.../what-is-the-difference-between-largefile-source-and-file-offset-bits-64]

Posted by 구차니
하드웨어/Display 장비2019. 6. 24. 08:35

LCD에서 TFT-LCD 자체를 제어하기 위한 드라이버 칩이 DDI 이고

DDI로 데이터를 주는 녀석이 T-CON 이라고 불리는 듯

Display Driver IC 

Timing Controller

 

[링크 : https://news.samsung.com/kr/90]

'하드웨어 > Display 장비' 카테고리의 다른 글

USB-C to HDMI 컨버터 회로  (0) 2022.01.24
e-paper 보드 발견  (0) 2022.01.21
강원전자 IC-314-AUD DVI KVM 4:1 스위치  (0) 2019.01.23
nvidia shield over internet  (0) 2018.05.08
Asus Bezel Free Triple Monitor Kit CES 2018  (0) 2018.04.10
Posted by 구차니