OSDN Git Service

addid library source 20140221
[zither/ds-zither.git] / sources / lib / libms / self_delim_get.c
1 // 固定長のデリミターカット
2 // dataはlen分の長さが保証されていること
3
4 #include<stdio.h>
5 #include<string.h>
6 #include <errno.h>
7 #include <stdlib.h>
8
9 #include "almemsys.h"
10
11
12 int self_delim_get(char * swap, char * data, char delim, int target, int len)
13 {
14 int sto, sta, count, ret;
15 sta =0;
16 sto =0;
17 count = 0;
18 ret = 0;
19
20 // delim の位置、データの大きさ
21 count  = delim_count(swap, delim, target, &sta, &sto);
22 #ifdef MAIL_DEBUG
23 printf("DELIM 1 %d -> %d %d\n", sta, sto, count);
24 #endif
25 if(count > 0 && sta <= sto && count < len){
26    ret = memcount_cpm(data, swap, sta, sto, len);
27    }
28 else{
29    ret = -1;
30    }
31 #ifdef MAIL_DEBUG
32 printf("data =%s\n", data);
33 #endif
34
35 return ret;
36 }
37
38
39
40
41