data.c (a976c2951d8f376112361830aa7762beff83a205) data.c (f858927fd6ce394a7f431153d44ad0a09e8f49a1)
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 60 unchanged lines hidden (view full) ---

69}
70
71struct data data_copy_escape_string(const char *s, int len)
72{
73 int i = 0;
74 struct data d;
75 char *q;
76
1/*
2 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
3 *
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.

--- 60 unchanged lines hidden (view full) ---

69}
70
71struct data data_copy_escape_string(const char *s, int len)
72{
73 int i = 0;
74 struct data d;
75 char *q;
76
77 d = data_grow_for(empty_data, len + 1);
77 d = data_add_marker(empty_data, TYPE_STRING, NULL);
78 d = data_grow_for(d, len + 1);
78
79 q = d.val;
80 while (i < len) {
81 char c = s[i++];
82
83 if (c == '\\')
84 c = get_escape_char(s, &i);
85
86 q[d.len++] = c;
87 }
88
89 q[d.len++] = '\0';
90 return d;
91}
92
93struct data data_copy_file(FILE *f, size_t maxlen)
94{
95 struct data d = empty_data;
96
79
80 q = d.val;
81 while (i < len) {
82 char c = s[i++];
83
84 if (c == '\\')
85 c = get_escape_char(s, &i);
86
87 q[d.len++] = c;
88 }
89
90 q[d.len++] = '\0';
91 return d;
92}
93
94struct data data_copy_file(FILE *f, size_t maxlen)
95{
96 struct data d = empty_data;
97
98 d = data_add_marker(d, TYPE_NONE, NULL);
97 while (!feof(f) && (d.len < maxlen)) {
98 size_t chunksize, ret;
99
100 if (maxlen == -1)
101 chunksize = 4096;
102 else
103 chunksize = maxlen - d.len;
104

--- 165 unchanged lines hidden ---
99 while (!feof(f) && (d.len < maxlen)) {
100 size_t chunksize, ret;
101
102 if (maxlen == -1)
103 chunksize = 4096;
104 else
105 chunksize = maxlen - d.len;
106

--- 165 unchanged lines hidden ---