aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.c
blob: 9aa15e5b605826eb72b9dfae8840d2cf806c2609 (plain)
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>   

#include <linux/limits.h> /* PATH_MAX*/
#include "ini_rw.h"
#define main_c


  
int main()
{
    char filename[] = "tests/test0.ini", *buff1, *buff2, *buff3, *buff4, *buff5;
    lci_data *ini=NULL, *tmp=NULL;
    int len=0, elen=50, lens=0, lenp=0, lenv=0, lenc=0; 
    FILE *fp;

    fp = fopen(filename, "rb");
    len = getFileMaxLineLen(fp);
    fclose(fp);

    buff1 = malloc((len+3)*sizeof(char));
    buff2 = malloc((len+3)*sizeof(char));
    buff3 = malloc((len+3)*sizeof(char));
    buff4 = malloc((len+3)*sizeof(char));
    buff5 = malloc((elen+3)*sizeof(char));
memset(buff1, 0, (len+3)*sizeof(char));
memset(buff2, 0, (len+3)*sizeof(char));
memset(buff3, 0, (len+3)*sizeof(char));
memset(buff4, 0, (len+3)*sizeof(char));
memset(buff5, 0, (elen+3)*sizeof(char));

    char *aa, *bb, *cc;
    aa = (char *) malloc(20*sizeof(char));
    aa[0] = 'q';
    aa[1] = 'w';
    aa[2] = 'e';
    aa[3] = '\0';
    bb = (char *) malloc(30*sizeof(char));

    cc=aa;
    strncpy(bb,aa,20);
    free(aa);
    free(NULL);

    printf("\n%s\n", bb);

    


    


    printf("\nLineMax: %d\n\n",len); 

    ini = iniReadOut(filename);

    lens=18;
    lenp=18;
    lenv=18;
    lenc=44;


    tmp = ini;
    while(tmp != NULL){

        snprintf(buff1, len+3, "'%s' %3ld",tmp->section, tmp->sectionLen);
        snprintf(buff2, len+3, "'%s' %3ld",tmp->param, tmp->paramLen);
        snprintf(buff3, len+3, "'%s' %3ld",tmp->value, tmp->valueLen);
        snprintf(buff4, len+3, "'%s' %3ld",tmp->comment, tmp->commentLen);
        snprintf(buff5, elen, "'%s' %3ld", tmp->errorMsg, tmp->errorMsgLen);


        printf("LN: %ld,\tLL: %ld,\tSE: %*s,%2ld P: %*s,%2ld V: %*s,%2ld C: %*s,%2ld ER: %*s \n", tmp->lineNum, tmp->lineLen, lens, buff1,tmp->sectionStartPos,
            lenp, buff2, tmp->paramStartPos, lenv, buff3, tmp->valueStartPos, lenc, buff4, tmp->commentStartPos, elen, buff5);

        tmp=tmp->next;
    }




    return 0;
}