Google

Go to the first, previous, next, last section, table of contents.


¥é¥¤¥Ö¥é¥ê¥¤¥ó¥¿¥Õ¥§¡¼¥¹

Asir ¤ÎÄ󶡤¹¤ëµ¡Ç½¤ò¾¤Î¥×¥í¥°¥é¥à¤«¤é»ÈÍѤ¹¤ëÊýË¡¤È¤·¤Æ, OpenXM ¤Ë¤è¤ë ¾¤Ë, ¥é¥¤¥Ö¥é¥ê¤ÎľÀÜ¥ê¥ó¥¯¤Ë¤è¤ëÊýË¡¤¬²Äǽ¤Ç¤¢¤ë. ¥é¥¤¥Ö¥é¥ê¤Ï, GC ¥é¥¤¥Ö¥é¥ê¤Ç¤¢¤ë `libasir-gc.a' ¤È¤È¤â¤Ë OpenXM distribution (http://www.math.kobe-u.ac.jp/OpenXM) ¤Ë´Þ¤Þ¤ì¤ë. ¸½¾õ¤Ç¤ÏOpenXM ¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Î¤ß¤¬¸ø³«¤µ¤ì¤Æ¤¤¤ë¤¿¤á, °Ê²¼¤Ç¤Ï OpenXM ¤¬¥¤¥ó¥¹¥È¡¼¥ë¤µ¤ì¤Æ¤¤¤ë¤È²¾Äꤹ¤ë. OpenXM root ¥Ç¥£¥ì¥¯¥È¥ê¤ò $OpenXM_HOME¤È½ñ¤¯. ¥é¥¤¥Ö¥é¥ê¥Õ¥¡¥¤¥ë¤ÏÁ´¤Æ `$OpenXM_HOME/lib' ¤Ë¤ª¤«¤ì¤Æ¤¤¤ë. ¥é¥¤¥Ö¥é¥ê¤Ë¤Ï°Ê²¼¤Î 3 ¼ïÎब¤¢¤ë.

  • `libasir.a'
    PARI, X11 ´ØÏ¢¤Îµ¡Ç½¤ò´Þ¤Þ¤Ê¤¤. ¥ê¥ó¥¯¤Ë¤Ï `libasir-gc.a' ¤Î¤ß¤¬É¬Í×.
  • `libasir_pari.a'
    X11 ´ØÏ¢¤Îµ¡Ç½¤ò´Þ¤Þ¤Ê¤¤. ¥ê¥ó¥¯¤Ë¤Ï `libasir-gc.a', `libpari.a' ¤¬É¬Í×.
  • `libasir_pari_X.a'
    Á´¤Æ¤Îµ¡Ç½¤ò´Þ¤à. ¥ê¥ó¥¯¤Ë¤Ï `libasir-gc.a', `libpari.a' ¤ª¤è¤Ó X11 ´ØÏ¢¤Î¥é¥¤¥Ö¥é¥ê»ØÄ꤬ɬÍ×.

Ä󶡤µ¤ì¤Æ¤¤¤ë´Ø¿ô¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¢¤ë.

  • int asir_ox_init(int byteorder)
    ¥é¥¤¥Ö¥é¥ê¤Î½é´ü²½. byteorder ¤Ï¥á¥â¥ê¾å¤Ø¤Î¥Ð¥¤¥Ê¥ê CMO ¥Ç¡¼¥¿ ¤Ø¤ÎŸ³«ÊýË¡¤ò»ØÄꤹ¤ë. byteorder ¤¬ 0 ¤Î¤È¤­¥Þ¥·¥ó¸ÇÍ­¤Î byteorder ¤òÍѤ¤¤ë. 1 ¤Î¤È¤­ network byteorder ¤òÍѤ¤¤ë. ½é´ü²½¤ËÀ®¸ù¤·¤¿¾ì¹ç 0, ¼ºÇԤλþ -1 ¤òÊÖ¤¹.
  • void asir_ox_push_cmo(void *cmo)
    ¥á¥â¥ê¾å¤ËÃÖ¤«¤ì¤¿ CMO ¥Ç¡¼¥¿¤ò Asir ¤ÎÆâÉô·Á¼°¤ËÊÑ´¹¤·¤Æ¥¹¥¿¥Ã¥¯¤Ë push ¤¹¤ë. It converts CMO data pointed by cmo into an Asir object and it pushes the object onto the stack.
  • int asir_ox_peek_cmo_size()
    ¥¹¥¿¥Ã¥¯¤ÎºÇ¾å°Ì¤Ë¤¢¤ë Asir ¥Ç¡¼¥¿¤ò CMO ¤ËÊÑ´¹¤·¤¿¤È¤­¤Î¥µ¥¤¥º¤òÊÖ¤¹. ÊÑ´¹ÉÔǽ¤Ê¾ì¹ç¤Ë¤Ï -1 ¤òÊÖ¤¹.
  • int asir_ox_pop_cmo(void *cmo, int limit)
    ¥¹¥¿¥Ã¥¯¤ÎºÇ¾å°Ì¤Ë¤¢¤ë Asir ¥Ç¡¼¥¿¤ò pop ¤·, CMO ¤ËÊÑ´¹¤·¤Æ cmo¤Ç »Ø¤µ¤ì¤ëÇÛÎó¤Ë½ñ¤­, CMO ¤Î¥µ¥¤¥º¤òÊÖ¤¹. ¤³¤Î¤È¤­, CMO ¤Î¥µ¥¤¥º¤¬ limit ¤è¤êÂ礭¤¤¾ì¹ç¤Ë¤Ï -1 ¤òÊÖ¤¹. cmo ¤ÏŤµ¤¬¾¯¤Ê¤¯¤È¤â limit¥Ð¥¤¥È¤ÎÇÛÎó¤ò»Ø¤¹É¬Íפ¬¤¢¤ë. ÊÑ´¹¤µ¤ì¤¿ CMO ¤ò¼ýÍÆ¤Ç¤­¤ë ÇÛÎó¤ÎŤµ¤òÃΤ뤿¤á¤Ë, asir_ox_peek_cmo_size ¤òÍѤ¤¤ë.
  • void asir_ox_push_cmd(int cmd)
    ¥¹¥¿¥Ã¥¯¥Þ¥·¥ó¥³¥Þ¥ó¥É cmd ¤ò¼Â¹Ô¤¹¤ë.
  • void asir_ox_execute_string(char *str)
    Asir ¤¬¼Â¹Ô²Äǽ¤Êʸ»úÎó str ¤ò¼Â¹Ô¤·, ¤½¤Î·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤Ë push ¤¹¤ë.

include ¤¹¤Ù¤­ header file ¤Ï `$OpenXM_HOME/include/asir/ox.h' ¤Ç¤¢¤ë. ¤³¤Î header file ¤Ë¤Ï, OpenXM ¤Ë´Ø¤¹¤ëÁ´¤Æ¤Î tag, command ¤ÎÄêµÁ¤¬´Þ¤Þ¤ì¤Æ ¤¤¤ë. ¼¡¤ÎÎã (`$OpenXM_HOME/doc/oxlib/test3.c') ¤Ï¾åµ­´Ø¿ô¤Î»ÈÍÑ Ë¡¤ò¼¨¤¹.

#include <asir/ox.h>
#include <signal.h>

main(int argc, char **argv)
{
  char buf[BUFSIZ+1];
  int c;
  unsigned char sendbuf[BUFSIZ+10];
  unsigned char *result;
  unsigned char h[3];
  int len,i,j;
  static int result_len = 0;
  char *kwd,*bdy;
  unsigned int cmd;

  signal(SIGINT,SIG_IGN);
  asir_ox_init(1); /* 1: network byte order; 0: native byte order */
  result_len = BUFSIZ;
  result = (void *)malloc(BUFSIZ);
  while ( 1 ) {
    printf("Input>"); fflush(stdout);
    fgets(buf,BUFSIZ,stdin);
    for ( i = 0; buf[i] && isspace(buf[i]); i++ );
    if ( !buf[i] )
      continue;
    kwd = buf+i;
    for ( ; buf[i] && !isspace(buf[i]); i++ );
    buf[i] = 0;
    bdy = buf+i+1;
    if ( !strcmp(kwd,"asir") ) {
      sprintf(sendbuf,"%s;",bdy);
      asir_ox_execute_string(sendbuf);
    } else if ( !strcmp(kwd,"push") ) {
      h[0] = 0;
      h[2] = 0;
      j = 0;
      while ( 1 ) {
        for ( ; (c= *bdy) && isspace(c); bdy++ );
        if ( !c )
          break;
        else if ( h[0] ) {
          h[1] = c;
          sendbuf[j++] = strtoul(h,0,16);
          h[0] = 0;
        } else
          h[0] = c;
        bdy++;
      }
      if ( h[0] )
        fprintf(stderr,"Number of characters is odd.\n");
      else {
        sendbuf[j] = 0;
        asir_ox_push_cmo(sendbuf);
      }
    } else if ( !strcmp(kwd,"cmd") ) {
      cmd = atoi(bdy);
      asir_ox_push_cmd(cmd);
    } else if ( !strcmp(kwd,"pop") ) {
      len = asir_ox_peek_cmo_size();
      if ( !len )
        continue;
      if ( len > result_len ) {
        result = (char *)realloc(result,len);
        result_len = len;
      }
      asir_ox_pop_cmo(result,len);
      printf("Output>"); fflush(stdout);
      printf("\n");
      for ( i = 0; i < len; ) {
        printf("%02x ",result[i]);
        i++;
        if ( !(i%16) )
          printf("\n");
      }
      printf("\n");
    }
  }
}

¤³¤Î¥×¥í¥°¥é¥à¤Ï, keyword body ¤Ê¤ë 1 ¹Ô¤òÆþÎϤȤ·¤Æ¼õ¤±¼è¤ê keyword ¤Ë±þ¤¸¤Æ¼¡¤Î¤è¤¦¤Êưºî¤ò¹Ô¤¦.

  • asir body
    body ¤ò Asir ¸À¸ì¤Ç½ñ¤«¤ì¤¿¼°¤È¤ß¤Ê¤·, ¼Â¹Ô·ë²Ì¤ò¥¹¥¿¥Ã¥¯¤Ë push ¤¹¤ë. asir_ox_execute_string() ¤¬ÍѤ¤¤é¤ì¤ë.
  • push body
    body ¤ò 16 ¿Ê¿ô¤Çɽ¼¨¤µ¤ì¤¿ CMO ¥Ç¡¼¥¿¤È¤ß¤Ê¤·, Asir ¥ª¥Ö¥¸¥§¥¯¥È¤ËÊÑ´¹ ¤·¤Æ¥¹¥¿¥Ã¥¯¤Ë push ¤¹¤ë. asir_ox_push_cmo() ¤¬ÍѤ¤¤é¤ì¤ë.
  • pop
    ¥¹¥¿¥Ã¥¯ºÇ¾å°Ì¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ò CMO ¤ËÊÑ´¹¤·, 16 ¿Ê¿ô¤Çɽ¼¨¤¹¤ë. asir_ox_peek_cmo_size() ¤ª¤è¤Ó asir_ox_pop_cmo() ¤¬ÍѤ¤¤é¤ì¤ë.
  • cmd body
    body ¤ò SM ¥³¥Þ¥ó¥É¤È¤ß¤Ê¤·, ¼Â¹Ô¤¹¤ë. asir_ox_push_cmd() ¤¬ÍѤ¤¤é¤ì¤ë.


Go to the first, previous, next, last section, table of contents.