JunkBox_Lib  1.10.2
isnet.c File Reference

ISNETプロトコル用ライブラリ More...

#include "isnet.h"
#include "isnet_server.c"
#include "isnet_client.c"
Include dependency graph for isnet.c:

Go to the source code of this file.

Functions

Buffer get_command (Buffer msg)
 
Buffer get_operand (Buffer msg)
 
Buffer get_comment (Buffer msg)
 

Detailed Description

Author
Fumi.Iseki (C)
Attention
make_Buffer() の確保チェックを行っていない.

Definition in file isnet.c.

Function Documentation

◆ get_command()

Buffer get_command ( Buffer  msg)

Buffer get_command(Buffer msg)

Buffer (命令)からコマンド部を取り出す.小文字は大文字に変換する.

Parameters
msg命令を格納した Buffer.改行コードは入れない.
Returns
コマンド部を格納した Buffer
Attention
注: 命令は comannd_operand_comment (_は複数の空白) の形をしている.comment自体は空白を含んでも良い.

Definition at line 36 of file isnet.c.

37 {
38  unsigned int i;
39  Buffer com;
40 
41  com = cawk_Buffer(msg, ' ', 1);
42  if (com.buf==NULL) {
43  com = make_Buffer(1);
44  return com;
45  }
46 
47  for (i=0; i<strlen((const char*)com.buf); i++) {
48  if (com.buf[i]>='a' && com.buf[i]<='z') com.buf[i] += - 'a' + 'A';
49  }
50  return com;
51 }
Buffer make_Buffer(int sz)
Buffer型変数のバッファ部をつくり出す.
Definition: buffer.c:71
Buffer cawk_Buffer(Buffer str, char cc, int n)
Buffer文字列に対する(変形の)awk.
Definition: buffer.c:1094
Definition: buffer.h:35
unsigned char * buf
バッファの先頭へのポインタ.str[bufsz]は必ず 0x00となる.
Definition: buffer.h:39

References Buffer::buf, cawk_Buffer(), and make_Buffer().

Referenced by send_command_recv_ans().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_comment()

Buffer get_comment ( Buffer  msg)

Buffer get_comment(Buffer msg)

Buffer(命令)からコメント部を取り出す.空白も含む.

Parameters
msg命令を格納した Buffer.改行コードは入れない.
Returns
コメント部を格納した Buffer
Attention
注: 命令は comannd_operand_comment (_は複数の空白) の形をしている.comment自体は空白を含んでも良い.

Definition at line 87 of file isnet.c.

88 {
89  int i, j, pos, cnt;
90  char* buf;
91  Buffer com;
92 
93  buf = (char*)msg.buf;
94  for(i=0, j=0; j<2; j++) {
95  while (buf[i]!='\0' && buf[i]!=' ') i++;
96  while (buf[i]!='\0' && buf[i]==' ') i++;
97  }
98 
99  pos = i;
100  while (buf[i]!='\0') i++;
101  cnt = i - pos;
102  com = make_Buffer(cnt+1);
103 
104  if (com.buf==NULL) com = make_Buffer(1);
105  else {
106  for (i=0; i<cnt; i++) com.buf[i] = buf[pos+i];
107  com.vldsz = cnt;
108  }
109 
110  return com;
111 }
unsigned char ** buf
Definition: jpeg_tool.h:96
int vldsz
データの長さ.バイナリデータの場合も使用可能.文字列の場合は 0x00 を含まない.
Definition: buffer.h:37

References buf, Buffer::buf, make_Buffer(), and Buffer::vldsz.

Here is the call graph for this function:

◆ get_operand()

Buffer get_operand ( Buffer  msg)

Buffer get_operand(Buffer msg)

Buffer(命令)からオペランド部を取り出す.小文字は大文字に変換する.

Parameters
msg命令を格納した Buffer.改行コードは入れない.
Returns
オペランド部を格納した Buffer
Attention
注: 命令は comannd_operand_comment (_は複数の空白) の形をしている.comment自体は空白を含んでも良い.

Definition at line 65 of file isnet.c.

66 {
67  Buffer opr;
68 
69  opr = cawk_Buffer(msg, ' ', 2);
70  if (opr.buf==NULL) opr = make_Buffer(1);
71 
72  return opr;
73 }

References Buffer::buf, cawk_Buffer(), and make_Buffer().

Referenced by send_command_recv_ans().

Here is the call graph for this function:
Here is the caller graph for this function: