Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[f41b88]: daemons / dump_config.c Maximize Restore History

Download this file

dump_config.c    232 lines (212 with data), 5.3 kB

  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
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
/* $Id: dump_config.c,v 1.1 1999/04/29 21:17:07 columbus Exp $ */
/****************************************************************************
** dump_config.c ***********************************************************
****************************************************************************
*
* dump_config.c - dumps data structures into file
*
* Copyright (C) 1998 Pablo d'Angelo <pablo@ag-trek.allgaeu.org>
*
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include "dump_config.h"
#include "config_file.h"
void fprint_comment(FILE *f,struct ir_remote *rem)
{
time_t timet;
struct tm *tmp;
timet=time(NULL);
tmp=localtime(&timet);
fprintf(f,
"#\n"
"# this config file was automatically generated\n"
"# using lirc-%s on %s"
"#\n"
"# contributed by \n"
"#\n"
"# brand: %s\n"
"# model: \n"
"# supported devices: \n"
"#\n\n",VERSION,asctime(tmp),
rem->name);
}
void fprint_flags(FILE *f, int flags)
{
int i;
int begin=0;
for(i=0;i<NR_FLAGS;i++)
{
if(flags&all_flags[i].flag)
{
if(begin==0) fprintf(f, " flags ");
else if(begin==1) fprintf(f,"|");
fprintf(f,"%s",all_flags[i].name);
begin=1;
}
}
if(begin==1) fprintf(f,"\n");
}
void fprint_remotes(FILE *f, struct ir_remote *all){
while(all)
{
fprint_remote(f, all);
fprintf(f, "\n\n");
all=all->next;
}
}
void fprint_remote_head(FILE *f, struct ir_remote *rem)
{
fprintf(f, "begin remote\n\n");
if(!is_raw(rem)){
fprintf(f, " name %s\n",rem->name);
fprintf(f, " bits %5d\n",rem->bits);
fprint_flags(f,rem->flags);
fprintf(f, " eps %5d\n",rem->eps);
fprintf(f, " aeps %5d\n\n",rem->aeps);
if(has_header(rem))
{
fprintf(f, " header %5d %5d\n",
rem->phead, rem->shead);
}
fprintf(f, " one %5d %5d\n",rem->pone, rem->sone);
fprintf(f, " zero %5d %5d\n",rem->pzero, rem->szero);
if(rem->ptrail!=0)
{
fprintf(f, " ptrail %5d\n",rem->ptrail);
}
if(rem->plead!=0)
{
fprintf(f, " plead %5d\n",rem->plead);
}
if(has_foot(rem))
{
fprintf(f, " foot %5d %5d\n",
rem->pfoot, rem->sfoot);
}
if(has_repeat(rem))
{
fprintf(f, " repeat %5d %5d\n",
rem->prepeat, rem->srepeat);
}
if(rem->pre_data_bits>0)
{
fprintf(f, " pre_data_bits %d\n",rem->pre_data_bits);
# ifdef LONG_IR_CODE
fprintf(f, " pre_data 0x%llX\n",rem->pre_data);
# else
fprintf(f, " pre_data 0x%lX\n",rem->pre_data);
# endif
}
if(rem->post_data_bits>0)
{
fprintf(f, " post_data_bits %d\n",rem->post_data_bits);
# ifdef LONG_IR_CODE
fprintf(f, " post_data 0x%llX\n",rem->post_data);
# else
fprintf(f, " post_data 0x%lX\n",rem->post_data);
# endif
}
if(rem->pre_p!=0 && rem->pre_s!=0)
{
fprintf(f, " pre %5d %5d\n",
rem->pre_p, rem->pre_s);
}
if(rem->post_p!=0 && rem->post_s!=0)
{
fprintf(f, " post %5d %5d\n",
rem->post_p, rem->post_s);
}
fprintf(f, " gap %lu\n",rem->gap);
if(has_repeat_gap(rem))
{
fprintf(f, " repeat_gap %lu\n",rem->repeat_gap);
}
fprintf(f, " repeat_bit %d\n\n",rem->repeat_bit);
}
else
{
fprintf(f, " name %s\n",rem->name);
fprint_flags(f,rem->flags);
fprintf(f, " eps %5d\n",rem->eps);
fprintf(f, " aeps %5d\n\n",rem->aeps);
fprintf(f, " ptrail %5d\n",rem->ptrail);
fprintf(f, " repeat %5d %5d\n",rem->prepeat, rem->srepeat);
fprintf(f, " gap %lu\n\n",rem->gap);
}
}
void fprint_remote_foot(FILE *f, struct ir_remote *rem)
{
fprintf(f, "end remote\n");
}
void fprint_remote_signal_head(FILE *f, struct ir_remote *rem)
{
if(!is_raw(rem))
fprintf(f, " begin codes\n");
else
fprintf(f, " begin raw_codes\n\n");
}
void fprint_remote_signal_foot(FILE *f, struct ir_remote *rem)
{
if(!is_raw(rem))
fprintf(f, " end codes\n\n");
else
fprintf(f, " end raw_codes\n\n");
}
void fprint_remote_signal(FILE *f,struct ir_remote *rem, struct ir_ncode *codes)
{
int i,j;
if(!is_raw(rem))
{
# ifdef LONG_IR_CODE
fprintf(f, " %-24s 0x%016llX\n",codes->name, codes->code);
# else
fprintf(f, " %-24s 0x%016lX\n",codes->name, codes->code);
# endif
}
else
{
fprintf(f, " name %s\n",codes->name);
j=0;
for(i=0;i<codes->length;i++){
if (j==0){
fprintf(f, " %7lu",codes->signals[i]);
}else if (j<5){
fprintf(f, " %7lu",codes->signals[i]);
}else{
fprintf(f, " %7lu\n",codes->signals[i]);
j=-1;
}
j++;
}
codes++;
if (j==0)
{
fprintf(f,"\n");
}else
{
fprintf(f,"\n\n");
j=0;
}
}
}
void fprint_remote_signals(FILE *f, struct ir_remote *rem)
{
struct ir_ncode *codes;
fprint_remote_signal_head(f,rem);
codes=rem->codes;
while(codes->name!=NULL)
{
fprint_remote_signal(f,rem,codes);
codes++;
}
fprint_remote_signal_foot(f,rem);
}
void fprint_remote(FILE *f, struct ir_remote *rem)
{
fprint_comment(f,rem);
fprint_remote_head(f,rem);
fprint_remote_signals(f,rem);
fprint_remote_foot(f,rem);
}