comparison libmenu/menu_txt.c @ 17994:6927fabaef92

Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
author reynaldo
date Thu, 30 Mar 2006 06:40:58 +0000
parents 931bdbc37ee0
children ac69ba536915
comparison
equal deleted inserted replaced
17993:98eb966a4024 17994:6927fabaef92
1 1
2 #include "config.h" 2 #include "config.h"
3 #include "mp_msg.h"
4 #include "help_mp.h"
3 5
4 #include <stdlib.h> 6 #include <stdlib.h>
5 #include <stdio.h> 7 #include <stdio.h>
6 #include <string.h> 8 #include <string.h>
7 9
127 menu->draw = draw; 129 menu->draw = draw;
128 menu->read_cmd = read_cmd; 130 menu->read_cmd = read_cmd;
129 menu->read_key = read_key; 131 menu->read_key = read_key;
130 132
131 if(!mpriv->file) { 133 if(!mpriv->file) {
132 printf("Menu txt need a txt file name (param file)\n"); 134 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtNeedATxtFileName);
133 return 0; 135 return 0;
134 } 136 }
135 137
136 fd = fopen(mpriv->file,"r"); 138 fd = fopen(mpriv->file,"r");
137 if(!fd) { 139 if(!fd) {
138 printf("Menu txt can't open: %s\n",mpriv->file); 140 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtCantOpen,mpriv->file);
139 return 0; 141 return 0;
140 } 142 }
141 143
142 while(1) { 144 while(1) {
143 r = fread(buf+pos,1,BUF_SIZE-pos-1,fd); 145 r = fread(buf+pos,1,BUF_SIZE-pos-1,fd);
164 memmove(buf,l+1,pos); 166 memmove(buf,l+1,pos);
165 buf[pos] = '\0'; 167 buf[pos] = '\0';
166 mpriv->num_lines++; 168 mpriv->num_lines++;
167 } 169 }
168 if(pos >= BUF_SIZE-1) { 170 if(pos >= BUF_SIZE-1) {
169 printf("Warning too long line, splitting it\n"); 171 mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_WarningTooLongLineSplitting);
170 mpriv->lines = realloc(mpriv->lines,(mpriv->num_lines + 1)*sizeof(char*)); 172 mpriv->lines = realloc(mpriv->lines,(mpriv->num_lines + 1)*sizeof(char*));
171 mpriv->lines[mpriv->num_lines] = strdup(buf); 173 mpriv->lines[mpriv->num_lines] = strdup(buf);
172 mpriv->num_lines++; 174 mpriv->num_lines++;
173 pos = 0; 175 pos = 0;
174 } 176 }
175 } 177 }
176 178
177 printf("Parsed %d lines\n",mpriv->num_lines); 179 mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ParsedLines,mpriv->num_lines);
178 180
179 return 1; 181 return 1;
180 } 182 }
181 183
182 const menu_info_t menu_info_txt = { 184 const menu_info_t menu_info_txt = {