Um pequeno programa de teste para obter alguns campos de uma declaração.
[cascardo/libreceita.git] / decfile.c
index 1829667..26ef3bc 100644 (file)
--- a/decfile.c
+++ b/decfile.c
@@ -1,5 +1,6 @@
 /*
- *  Copyright (C) 2012-2013  Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+ *  Copyright (C) 2012-2014  Thadeu Lima de Souza Cascardo <cascardo@minaslivre.org>
+ *  Copyright (C) 2014  Alexandre Oliva <lxoliva@fsfla.org>
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -210,7 +211,7 @@ static int parse_header_2014(struct pmhash *hash, char *buffer)
        parse("hash", 10);
 
        if (p - buffer != RNET_HEADER_HEAD_2014) {
-               fprintf(stderr, "RNET_HEADER_HEAD_2014 in decfile.h needs to be adjusted to %li\n", p - buffer);
+               fprintf(stderr, "RNET_HEADER_HEAD_2014 in decfile.h needs to be adjusted to %ti\n", p - buffer);
                goto out_val;
        }
 
@@ -294,24 +295,24 @@ static int parse_header_2014(struct pmhash *hash, char *buffer)
 
        if (*p++ != '\r') {
                fprintf(stderr,
-                       "missing CR at the %lith header character\n",
+                       "missing CR at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (*p++ != '\n') {
                fprintf(stderr,
-                       "missing LF at the %lith header character\n",
+                       "missing LF at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (*p != 0) {
                fprintf(stderr,
-                       "missing NUL at the %lith header character\n",
+                       "missing NUL at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (p - buffer != RNET_HEADER_SIZE_2014) {
-               fprintf(stderr, "RNET_HEADER_SIZE_2014 in decfile.h needs to be adjusted to %li,\nor parse_header in decfile.c needs updating\n", p - buffer);
+               fprintf(stderr, "RNET_HEADER_SIZE_2014 in decfile.h needs to be adjusted to %ti,\nor parse_header in decfile.c needs updating\n", p - buffer);
                goto out_val;
        } else if (p - tail != RNET_HEADER_TAIL_2014) {
-               fprintf(stderr, "RNET_HEADER_TAIL_2014 in decfile.h needs to be adjusted to %li\n", p - tail);
+               fprintf(stderr, "RNET_HEADER_TAIL_2014 in decfile.h needs to be adjusted to %ti\n", p - tail);
                goto out_val;
        }
 
@@ -364,7 +365,7 @@ static int parse_header_2013(struct pmhash *hash, char *buffer)
        parse("hash", 10);
 
        if (p - buffer != RNET_HEADER_HEAD_2013) {
-               fprintf(stderr, "RNET_HEADER_HEAD_2013 in decfile.h needs to be adjusted to %li\n", p - buffer);
+               fprintf(stderr, "RNET_HEADER_HEAD_2013 in decfile.h needs to be adjusted to %ti\n", p - buffer);
                goto out_val;
        }
 
@@ -443,24 +444,24 @@ static int parse_header_2013(struct pmhash *hash, char *buffer)
 
        if (*p++ != '\r') {
                fprintf(stderr,
-                       "missing CR at the %lith header character\n",
+                       "missing CR at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (*p++ != '\n') {
                fprintf(stderr,
-                       "missing LF at the %lith header character\n",
+                       "missing LF at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (*p != 0) {
                fprintf(stderr,
-                       "missing NUL at the %lith header character\n",
+                       "missing NUL at the %tith header character\n",
                        p - buffer);
                goto out_val;
        } else if (p - buffer != RNET_HEADER_SIZE_2013) {
-               fprintf(stderr, "RNET_HEADER_SIZE_2013 in decfile.h needs to be adjusted to %li,\nor parse_header in decfile.c needs updating\n", p - buffer);
+               fprintf(stderr, "RNET_HEADER_SIZE_2013 in decfile.h needs to be adjusted to %ti,\nor parse_header in decfile.c needs updating\n", p - buffer);
                goto out_val;
        } else if (p - tail != RNET_HEADER_TAIL_2013) {
-               fprintf(stderr, "RNET_HEADER_TAIL_2013 in decfile.h needs to be adjusted to %li\n", p - tail);
+               fprintf(stderr, "RNET_HEADER_TAIL_2013 in decfile.h needs to be adjusted to %ti\n", p - tail);
                goto out_val;
        }
 
@@ -552,3 +553,10 @@ char * rnet_decfile_get_header(struct rnet_decfile *decfile)
 {
        return get_header(decfile);
 }
+
+char * rnet_decfile_get_line(struct rnet_decfile *decfile, int i)
+{
+       if (i < decfile->lines_len)
+               return decfile->lines[i];
+       return NULL;
+}