File: satest.c

package info (click to toggle)
sufary 2.1.1-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 1,236 kB
  • ctags: 782
  • sloc: ansic: 4,122; perl: 1,378; makefile: 736; sh: 664; tcl: 441; cpp: 192
file content (39 lines) | stat: -rw-r--r-- 961 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "sufary.h"

main(int argc, char *argv[])
{
  char *s;
  SUFARY *ary;
  long tmp, pos;
  int i;

  if (argc != 3){fprintf(stderr,"argument error\n");}  /*  */

  if ((ary = sa_openfiles(argv[2],NULL)) == NULL){ /* ե򳫤 */
    fprintf(stderr,"file open error\n");
  }


  printf("%ld\n", ((long*)(ary->arymap))[0]);


  /*  */
  if (sa_sel(ary, argv[1]) == CONT){
    /* bottomtopޤǥ롼 */
    for (tmp = sa_left(ary); tmp <= sa_right(ary) ; tmp++){
      pos = sa_aryidx2txtidx(ary, tmp); /* ֤ */
/*      s = sa_getline(ary, pos); */ /* Ԥ */
      s = sa_getlines(ary, pos, 0, 0); /* Ԥ */
      printf("--\n%s\n", s); /* ɽ */
      s = sa_getstr(ary, pos, 3);
      printf("[%s]\n", s); /* ɽ */
      printf("%s:%ld: %s\n", argv[1], pos, s);
      free(s);
    }
    printf("--\n");
  }
  sa_closefiles(ary);  /* եĤ */
}