summaryrefslogtreecommitdiffstats
path: root/libmenu
diff options
context:
space:
mode:
authorreynaldo <reynaldo@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-30 06:40:58 +0000
committerreynaldo <reynaldo@b3059339-0415-0410-9bf9-f77b7e298cf2>2006-03-30 06:40:58 +0000
commitbf25812a43c2e3ca244cc1698a7e006391ce34b8 (patch)
tree5d5f792df73067fc4e2d5ff9295fea966c3baf80 /libmenu
parent9c301c3e16546f00e9230abfbe36a45793bd9389 (diff)
downloadmpv-bf25812a43c2e3ca244cc1698a7e006391ce34b8.tar.bz2
mpv-bf25812a43c2e3ca244cc1698a7e006391ce34b8.tar.xz
Part1 of several printf2mp_msg changes in patch from Otvos Attila oattila AT chello DOT hu
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@17995 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmenu')
-rw-r--r--libmenu/menu.c24
-rw-r--r--libmenu/menu_cmdlist.c10
-rw-r--r--libmenu/menu_console.c18
-rw-r--r--libmenu/menu_filesel.c14
-rw-r--r--libmenu/menu_param.c11
-rw-r--r--libmenu/menu_pt.c6
-rw-r--r--libmenu/menu_txt.c10
-rw-r--r--libmenu/vf_menu.c6
8 files changed, 56 insertions, 43 deletions
diff --git a/libmenu/menu.c b/libmenu/menu.c
index e0ef965e24..6113fb6dce 100644
--- a/libmenu/menu.c
+++ b/libmenu/menu.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include <stdlib.h>
#include <stdio.h>
@@ -63,7 +65,7 @@ static int menu_parse_config(char* buffer) {
while(1) {
r = asx_get_element(parser,&buffer,&element,&body,&attribs);
if(r < 0) {
- printf("Syntax error at line %d\n",parser->line);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
asx_parser_free(parser);
return 0;
} else if(r == 0) {
@@ -73,7 +75,7 @@ static int menu_parse_config(char* buffer) {
// Has it a name ?
name = asx_get_attrib("name",attribs);
if(!name) {
- printf("Menu definitions need a name attrib (line %d)\n",parser->line);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuDefinitionsNeedANameAttrib,parser->line);
free(element);
if(body) free(body);
asx_free_attribs(attribs);
@@ -98,13 +100,13 @@ static int menu_parse_config(char* buffer) {
for(i = 0 ; attribs[2*i] ; i++) {
if(strcasecmp(attribs[2*i],"name") == 0) continue;
if(!m_struct_set(&minfo->priv_st,menu_list[mcount].cfg,attribs[2*i], attribs[2*i+1]))
- printf("Bad attrib %s=%s in menu %s at line %d\n",attribs[2*i],attribs[2*i+1],
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_BadAttrib,attribs[2*i],attribs[2*i+1],
name,parser->line);
}
mcount++;
memset(&menu_list[mcount],0,sizeof(menu_def_t));
} else {
- printf("Unknown menu type %s at line %d\n",element,parser->line);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuType,element,parser->line);
free(name);
if(body) free(body);
}
@@ -130,7 +132,7 @@ int menu_init(char* cfg_file) {
#endif
fd = open(cfg_file, O_RDONLY);
if(fd < 0) {
- printf("Can't open menu config file: %s\n",cfg_file);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantOpenConfigFile,cfg_file);
return 0;
}
buffer = malloc(bl);
@@ -138,7 +140,7 @@ int menu_init(char* cfg_file) {
int r;
if(bl - br < BUF_MIN) {
if(bl >= BUF_MAX) {
- printf("Menu config file is too big (> %d KB)\n",BUF_MAX/1024);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ConfigFileIsTooBig,BUF_MAX/1024);
close(fd);
free(buffer);
return 0;
@@ -151,7 +153,7 @@ int menu_init(char* cfg_file) {
br += r;
}
if(!br) {
- printf("Menu config file is empty\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ConfigFileIsEmpty);
return 0;
}
buffer[br-1] = '\0';
@@ -208,7 +210,7 @@ menu_t* menu_open(char *name) {
break;
}
if(menu_list[i].name == NULL) {
- printf("Menu %s not found\n",name);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuNotFound,name);
return NULL;
}
m = calloc(1,sizeof(menu_t));
@@ -219,7 +221,7 @@ menu_t* menu_open(char *name) {
if(m->priv)
m_struct_free(m->priv_st,m->priv);
free(m);
- printf("Menu %s: init failed\n",name);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuInitFailed,name);
return NULL;
}
@@ -301,7 +303,7 @@ void menu_draw_text(mp_image_t* mpi,char* txt, int x, int y) {
int font;
if(!draw_alpha) {
- printf("Unsupported outformat !!!!\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnsupportedOutformat);
return;
}
@@ -332,7 +334,7 @@ void menu_draw_text_full(mp_image_t* mpi,char* txt,
draw_alpha_f draw_alpha = get_draw_alpha(mpi->imgfmt);
if(!draw_alpha) {
- printf("Unsupported outformat !!!!\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnsupportedOutformat);
return;
}
diff --git a/libmenu/menu_cmdlist.c b/libmenu/menu_cmdlist.c
index cd0c8ff763..bdef83892b 100644
--- a/libmenu/menu_cmdlist.c
+++ b/libmenu/menu_cmdlist.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include <stdlib.h>
#include <stdio.h>
@@ -106,19 +108,19 @@ static int parse_args(menu_t* menu,char* args) {
while(1) {
r = asx_get_element(parser,&args,&element,&body,&attribs);
if(r < 0) {
- printf("Syntax error at line %d\n",parser->line);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
asx_parser_free(parser);
return -1;
} else if(r == 0) {
asx_parser_free(parser);
if(!m)
- printf("No entry found in the menu definition\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition);
return m ? 1 : 0;
}
// Has it a name ?
name = asx_get_attrib("name",attribs);
if(!name) {
- printf("List menu entry definitions need a name (line %d)\n",parser->line);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuEntryDefinitionsNeedAName,parser->line);
free(element);
if(body) free(body);
asx_free_attribs(attribs);
@@ -145,7 +147,7 @@ static int open(menu_t* menu, char* args) {
menu->close = close;
if(!args) {
- printf("List menu need an argument\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_ListMenuNeedAnArgument);
return 0;
}
diff --git a/libmenu/menu_console.c b/libmenu/menu_console.c
index 5f70b871bd..1005ee2125 100644
--- a/libmenu/menu_console.c
+++ b/libmenu/menu_console.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include <stdlib.h>
#include <stdio.h>
@@ -260,10 +262,10 @@ static void check_child(menu_t* menu) {
mpriv->prompt = mpriv->mp_prompt;
//add_line(mpriv,"Child process exited");
}
- else printf("waitpid error: %s\n",strerror(errno));
+ else mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WaitPidError,strerror(errno));
}
} else if(r < 0) {
- printf("select error\n");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_SelectError);
return;
}
@@ -273,7 +275,7 @@ static void check_child(menu_t* menu) {
if(w) mpriv->add_line = 1;
r = read(mpriv->child_fd[i],buffer,255);
if(r < 0)
- printf("Read error on child's %s \n", i == 1 ? "stdout":"stderr");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReadErrorOnChilds, i == 1 ? "stdout":"stderr");
else if(r>0) {
buffer[r] = '\0';
add_string(mpriv,buffer);
@@ -291,9 +293,9 @@ static int run_shell_cmd(menu_t* menu, char* cmd) {
#ifndef __MINGW32__
int in[2],out[2],err[2];
- printf("Console run %s ...\n",cmd);
+ mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ConsoleRun,cmd);
if(mpriv->child) {
- printf("A child is alredy running\n");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_AChildIsAlreadyRunning);
return 0;
}
@@ -303,7 +305,7 @@ static int run_shell_cmd(menu_t* menu, char* cmd) {
mpriv->child = fork();
if(mpriv->child < 0) {
- printf("Fork failed !!!\n");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ForkFailed);
close_pipe(in);
close_pipe(out);
close_pipe(err);
@@ -377,14 +379,14 @@ static void read_key(menu_t* menu,int c) {
while(l > 0) {
int w = write(mpriv->child_fd[0],str,l);
if(w < 0) {
- printf("Write error\n");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
break;
}
l -= w;
str += w;
}
if(write(mpriv->child_fd[0],"\n",1) < 0)
- printf("Write error\n");
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_WriteError);
enter_cmd(menu);
return;
}
diff --git a/libmenu/menu_filesel.c b/libmenu/menu_filesel.c
index 9148dc2c8d..b4b3b98783 100644
--- a/libmenu/menu_filesel.c
+++ b/libmenu/menu_filesel.c
@@ -12,6 +12,8 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include "m_struct.h"
#include "m_option.h"
@@ -142,7 +144,7 @@ static int open_dir(menu_t* menu,char* args) {
mpriv->p.title = replace_path(mpriv->title,mpriv->dir);
if ((dirp = opendir (mpriv->dir)) == NULL){
- printf("opendir error: %s", strerror(errno));
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_OpendirError, strerror(errno));
return 0;
}
@@ -155,7 +157,7 @@ static int open_dir(menu_t* menu,char* args) {
if(n%20 == 0){ // Get some more mem
if((tp = (char **) realloc(namelist, (n+20) * sizeof (char *)))
== NULL) {
- printf("realloc error: %s", strerror(errno));
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReallocError, strerror(errno));
n--;
goto bailout;
}
@@ -164,7 +166,7 @@ static int open_dir(menu_t* menu,char* args) {
namelist[n] = (char *) malloc(strlen(dp->d_name) + 2);
if(namelist[n] == NULL){
- printf("malloc error: %s", strerror(errno));
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
n--;
goto bailout;
}
@@ -182,7 +184,7 @@ bailout:
qsort(namelist, n, sizeof(char *), (kill_warn)compare);
if (n < 0) {
- printf("readdir error: %s\n",strerror(errno));
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_ReaddirError,strerror(errno));
return 0;
}
while(n--) {
@@ -193,7 +195,7 @@ bailout:
e->d = 1;
menu_list_add_entry(menu,e);
}else{
- printf("malloc error: %s", strerror(errno));
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_MallocError, strerror(errno));
}
free(namelist[n]);
}
@@ -237,7 +239,7 @@ static void read_cmd(menu_t* menu,int cmd) {
}
menu_list_uninit(menu,free_entry);
if(!open_dir(menu,p)) {
- printf("Can't open directory %s\n",p);
+ mp_msg(MSGT_GLOBAL,MSGL_ERR,MSGTR_LIBMENU_CantOpenDirectory,p);
menu->cl = 1;
}
free(p);
diff --git a/libmenu/menu_param.c b/libmenu/menu_param.c
index a82bcaf358..8cec09b9a0 100644
--- a/libmenu/menu_param.c
+++ b/libmenu/menu_param.c
@@ -97,13 +97,13 @@ static int parse_args(menu_t* menu,char* args) {
while(1) {
r = asx_get_element(parser,&args,&element,&body,&attribs);
if(r < 0) {
- mp_msg(MSGT_OSD_MENU,MSGL_ERR,"Syntax error at line %d\n",parser->line);
+ mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_SyntaxErrorAtLine,parser->line);
asx_parser_free(parser);
return -1;
} else if(r == 0) {
asx_parser_free(parser);
if(!m)
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,"No entry found in the menu definition\n");
+ mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_NoEntryFoundInTheMenuDefinition);
m = calloc(1,sizeof(struct list_entry_s));
m->p.txt = strdup("Back");
menu_list_add_entry(menu,m);
@@ -112,7 +112,7 @@ static int parse_args(menu_t* menu,char* args) {
if(!strcmp(element,"menu")) {
name = asx_get_attrib("menu",attribs);
if(!name) {
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,"Submenu definition need a 'menu' attribut.\n");
+ mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_SubmenuDefinitionNeedAMenuAttribut);
goto next_element;
}
m = calloc(1,sizeof(struct list_entry_s));
@@ -127,8 +127,7 @@ static int parse_args(menu_t* menu,char* args) {
name = asx_get_attrib("property",attribs);
opt = name ? mp_property_find(name) : NULL;
if(!opt) {
- mp_msg(MSGT_OSD_MENU,MSGL_WARN,"Pref menu entry definitions need a valid 'property'"
- " attribut (line %d)\n",parser->line);
+ mp_msg(MSGT_OSD_MENU,MSGL_WARN,MSGTR_LIBMENU_PrefMenuEntryDefinitionsNeed,parser->line);
goto next_element;
}
m = calloc(1,sizeof(struct list_entry_s));
@@ -239,7 +238,7 @@ static int openMenu(menu_t* menu, char* args) {
if(!args) {
- mp_msg(MSGT_OSD_MENU,MSGL_ERR,"Pref menu need an argument\n");
+ mp_msg(MSGT_OSD_MENU,MSGL_ERR,MSGTR_LIBMENU_PrefMenuNeedAnArgument);
return 0;
}
diff --git a/libmenu/menu_pt.c b/libmenu/menu_pt.c
index c5dc3673ea..6a1aca0963 100644
--- a/libmenu/menu_pt.c
+++ b/libmenu/menu_pt.c
@@ -5,6 +5,8 @@
//#include <libgen.h>
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include "img_format.h"
#include "mp_image.h"
@@ -77,7 +79,7 @@ static void read_cmd(menu_t* menu,int cmd) {
d--;
}
if(i == NULL) {
- printf("Can't find the target item ????\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_CantfindTheTargetItem);
break;
}
}
@@ -87,7 +89,7 @@ static void read_cmd(menu_t* menu,int cmd) {
if(c)
mp_input_queue_cmd(c);
else
- printf("Failed to build command %s\n",str);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToBuildCommand,str);
} break;
default:
menu_list_read_cmd(menu,cmd);
diff --git a/libmenu/menu_txt.c b/libmenu/menu_txt.c
index 0798108466..1d836c98ca 100644
--- a/libmenu/menu_txt.c
+++ b/libmenu/menu_txt.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include <stdlib.h>
#include <stdio.h>
@@ -129,13 +131,13 @@ static int open(menu_t* menu, char* args) {
menu->read_key = read_key;
if(!mpriv->file) {
- printf("Menu txt need a txt file name (param file)\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtNeedATxtFileName);
return 0;
}
fd = fopen(mpriv->file,"r");
if(!fd) {
- printf("Menu txt can't open: %s\n",mpriv->file);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_MenuTxtCantOpen,mpriv->file);
return 0;
}
@@ -166,7 +168,7 @@ static int open(menu_t* menu, char* args) {
mpriv->num_lines++;
}
if(pos >= BUF_SIZE-1) {
- printf("Warning too long line, splitting it\n");
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_WarningTooLongLineSplitting);
mpriv->lines = realloc(mpriv->lines,(mpriv->num_lines + 1)*sizeof(char*));
mpriv->lines[mpriv->num_lines] = strdup(buf);
mpriv->num_lines++;
@@ -174,7 +176,7 @@ static int open(menu_t* menu, char* args) {
}
}
- printf("Parsed %d lines\n",mpriv->num_lines);
+ mp_msg(MSGT_GLOBAL,MSGL_INFO,MSGTR_LIBMENU_ParsedLines,mpriv->num_lines);
return 1;
}
diff --git a/libmenu/vf_menu.c b/libmenu/vf_menu.c
index 3903d954c1..5601fdb323 100644
--- a/libmenu/vf_menu.c
+++ b/libmenu/vf_menu.c
@@ -1,5 +1,7 @@
#include "config.h"
+#include "mp_msg.h"
+#include "help_mp.h"
#include <stdio.h>
#include <stdlib.h>
@@ -116,7 +118,7 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
else if(strcmp(arg,"hide") == 0)
priv->current->show = 0;
else
- printf("Unknown menu command: '%s'\n",arg);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_UnknownMenuCommand,arg);
return 1;
}
case MP_CMD_SET_MENU : {
@@ -124,7 +126,7 @@ static int cmd_filter(mp_cmd_t* cmd, int paused, struct vf_priv_s * priv) {
menu_t* l = priv->current;
priv->current = menu_open(menu);
if(!priv->current) {
- printf("Failed to open menu '%s'\n",menu);
+ mp_msg(MSGT_GLOBAL,MSGL_WARN,MSGTR_LIBMENU_FailedToOpenMenu,menu);
priv->current = l;
priv->current->show = 0;
} else {