Mercurial > hg > dmlib
comparison src/dmtimelinew.c @ 2013:862a943afff4
Fix some warnings in regards to strncpy().
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 06 Aug 2018 15:25:12 +0300 |
parents | 73545a442ffe |
children | 9807ae37ad69 |
comparison
equal
deleted
inserted
replaced
2012:bec158e00f17 | 2013:862a943afff4 |
---|---|
5 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP) | 5 * (C) Copyright 2012-2015 Tecnic Software productions (TNSP) |
6 */ | 6 */ |
7 #include "dmengine.h" | 7 #include "dmengine.h" |
8 | 8 |
9 | 9 |
10 static BOOL dmSaveFloatValue(DMResource *res, DMFloat val) | 10 static BOOL dmSaveFloatValue(DMResource *res, const DMFloat val) |
11 { | 11 { |
12 char tmp[DT_FLOAT_STORE_SIZE]; | 12 char tmp[DT_FLOAT_STORE_SIZE]; |
13 snprintf(tmp, DT_FLOAT_STORE_SIZE, "%f", val); | 13 snprintf(tmp, DT_FLOAT_STORE_SIZE, "%f", val); |
14 return !dmf_write_str(res, tmp, DT_FLOAT_STORE_SIZE); | 14 return !dmf_write_str(res, tmp, DT_FLOAT_STORE_SIZE); |
15 } | 15 } |
16 | 16 |
17 | 17 |
18 static int dmSaveTimelinePoints(DMResource *res, DMTimelinePoints *points, int type) | 18 static int dmSaveTimelinePoints(DMResource *res, const DMTimelinePoints *points, const int type) |
19 { | 19 { |
20 int point; | 20 int point; |
21 Uint32 npoints; | 21 Uint32 npoints; |
22 | 22 |
23 // Save number of points | 23 // Save number of points |
71 } | 71 } |
72 return DMERR_OK; | 72 return DMERR_OK; |
73 } | 73 } |
74 | 74 |
75 | 75 |
76 static int dmSaveTimelineCurve(DMResource *res, DMTimelineCurve *curve) | 76 static int dmSaveTimelineCurve(DMResource *res, const DMTimelineCurve *curve) |
77 { | 77 { |
78 int err; | 78 int err; |
79 | 79 |
80 if (!dmf_write_byte(res, curve->enabled)) | 80 if (!dmf_write_byte(res, curve->enabled)) |
81 return DMERR_FWRITE; | 81 return DMERR_FWRITE; |
85 | 85 |
86 return DMERR_OK; | 86 return DMERR_OK; |
87 } | 87 } |
88 | 88 |
89 | 89 |
90 static int dmSaveTimelineEventParam(DMResource *res, DMTimelineEventParam *param) | 90 static int dmSaveTimelineEventParam(DMResource *res, const DMTimelineEventParam *param) |
91 { | 91 { |
92 int err; | 92 int err; |
93 DMFTimelineEventParam hdr; | 93 DMFTimelineEventParam hdr; |
94 Uint16 len; | 94 Uint16 len; |
95 | 95 |
96 strncpy(hdr.name, param->name, sizeof(hdr.name)); | 96 strncpy(hdr.name, param->name, sizeof(hdr.name)); |
97 hdr.name[sizeof(hdr.name) - 1] = 0; | |
97 hdr.type = param->type; | 98 hdr.type = param->type; |
98 | 99 |
99 if (!dmf_write_str(res, hdr.name, sizeof(hdr.name)) || | 100 if (!dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |
100 !dmf_write_le32(res, hdr.type)) | 101 !dmf_write_le32(res, hdr.type)) |
101 return DMERR_FWRITE; | 102 return DMERR_FWRITE; |
122 | 123 |
123 return DMERR_OK; | 124 return DMERR_OK; |
124 } | 125 } |
125 | 126 |
126 | 127 |
127 static int dmSaveTimelineEvent(DMResource *res, DMTimelineEvent *event) | 128 static int dmSaveTimelineEvent(DMResource *res, const DMTimelineEvent *event) |
128 { | 129 { |
129 int param, err; | 130 int param, err; |
130 DMFTimelineEvent hdr; | 131 DMFTimelineEvent hdr; |
131 | 132 |
132 strncpy(hdr.effectName, event->effect->name, sizeof(hdr.effectName)); | 133 strncpy(hdr.effectName, event->effect->name, sizeof(hdr.effectName)); |
134 hdr.effectName[sizeof(hdr.effectName) - 1] = 0; | |
135 | |
133 hdr.start = event->start; | 136 hdr.start = event->start; |
134 hdr.duration = event->duration; | 137 hdr.duration = event->duration; |
135 hdr.nparams = event->nparams; | 138 hdr.nparams = event->nparams; |
136 | 139 |
137 if (!dmf_write_le32(res, hdr.start) || | 140 if (!dmf_write_le32(res, hdr.start) || |
148 | 151 |
149 return DMERR_OK; | 152 return DMERR_OK; |
150 } | 153 } |
151 | 154 |
152 | 155 |
153 static int dmSaveTimelineTrack(DMResource *res, DMTimelineTrack *track) | 156 static int dmSaveTimelineTrack(DMResource *res, const DMTimelineTrack *track) |
154 { | 157 { |
155 int event, err; | 158 int event, err; |
156 DMFTimelineTrack hdr; | 159 DMFTimelineTrack hdr; |
157 | 160 |
158 strncpy(hdr.name, track->name, sizeof(hdr.name)); | 161 strncpy(hdr.name, track->name, sizeof(hdr.name)); |
162 hdr.name[sizeof(hdr.name) - 1] = 0; | |
159 | 163 |
160 if (!dmf_write_le32(res, track->index) || | 164 if (!dmf_write_le32(res, track->index) || |
161 !dmf_write_le32(res, track->layer) || | 165 !dmf_write_le32(res, track->layer) || |
162 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || | 166 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |
163 !dmf_write_byte(res, track->enabled) || | 167 !dmf_write_byte(res, track->enabled) || |
175 | 179 |
176 return DMERR_OK; | 180 return DMERR_OK; |
177 } | 181 } |
178 | 182 |
179 | 183 |
180 int dmSaveTimeline(DMResource *res, DMTimeline *tl) | 184 int dmSaveTimeline(DMResource *res, const DMTimeline *tl) |
181 { | 185 { |
182 int track, err; | 186 int track, err; |
183 DMFTimeline hdr; | 187 DMFTimeline hdr; |
184 | 188 |
185 memcpy(&hdr.magic, DT_MAGIC_ID, sizeof(hdr.magic)); | 189 memcpy(&hdr.magic, DT_MAGIC_ID, sizeof(hdr.magic)); |
186 strncpy(hdr.name, tl->name, sizeof(hdr.name)); | 190 strncpy(hdr.name, tl->name, sizeof(hdr.name)); |
191 hdr.name[sizeof(hdr.name) - 1] = 0; | |
192 | |
187 hdr.ntracks = tl->ntracks; | 193 hdr.ntracks = tl->ntracks; |
188 hdr.duration = tl->duration; | 194 hdr.duration = tl->duration; |
189 | 195 |
190 if (!dmf_write_str(res, hdr.magic, sizeof(hdr.magic)) || | 196 if (!dmf_write_str(res, hdr.magic, sizeof(hdr.magic)) || |
191 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || | 197 !dmf_write_str(res, hdr.name, sizeof(hdr.name)) || |