projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-19981026-1
[rocksndiamonds.git]
/
src
/
misc.c
diff --git
a/src/misc.c
b/src/misc.c
index 7a790ce13f0cc96d3efbbb193badefdb7b5bd3a1..9c6d93b18618d4b6e87b9927f5fe40d5bb2a3586 100644
(file)
--- a/
src/misc.c
+++ b/
src/misc.c
@@
-76,7
+76,7
@@
static void sleep_milliseconds(unsigned long milliseconds_delay)
delay.tv_usec = 1000 * (milliseconds_delay % 1000);
if (select(0, NULL, NULL, NULL, &delay) != 0)
delay.tv_usec = 1000 * (milliseconds_delay % 1000);
if (select(0, NULL, NULL, NULL, &delay) != 0)
- Error(ERR_
RETU
RN, "sleep_milliseconds(): select() failed");
+ Error(ERR_
WA
RN, "sleep_milliseconds(): select() failed");
}
}
}
}
@@
-129,12
+129,23
@@
void WaitUntilDelayReached(unsigned long *counter_var, unsigned long delay)
*counter_var = actual_counter;
}
*counter_var = actual_counter;
}
-char *int2str(int
ct, int nr
)
+char *int2str(int
number, int size
)
{
{
- static char s
tr[2
0];
+ static char s
[4
0];
- sprintf(str,"%09d",ct);
- return(&str[strlen(str)-nr]);
+ if (size > 20)
+ size = 20;
+
+ if (size)
+ {
+ sprintf(s, " %09d", number);
+ return &s[strlen(s) - size];
+ }
+ else
+ {
+ sprintf(s, "%d", number);
+ return s;
+ }
}
unsigned int SimpleRND(unsigned int max)
}
unsigned int SimpleRND(unsigned int max)
@@
-318,7
+329,7
@@
void Error(int mode, char *format_str, ...)
FILE *output_stream = stderr;
char *process_name = "";
FILE *output_stream = stderr;
char *process_name = "";
- if (mode
== ERR_EXIT
_SOUNDSERVER)
+ if (mode
& ERR
_SOUNDSERVER)
process_name = " sound server";
if (format_str)
process_name = " sound server";
if (format_str)
@@
-331,6
+342,9
@@
void Error(int mode, char *format_str, ...)
fprintf(output_stream, "%s%s: ", program_name, process_name);
fprintf(output_stream, "%s%s: ", program_name, process_name);
+ if (mode & ERR_WARN)
+ fprintf(output_stream, "warning: ");
+
va_start(ap, format_str); /* ap points to first unnamed argument */
for(format_ptr=format_str; *format_ptr; format_ptr++)
va_start(ap, format_str); /* ap points to first unnamed argument */
for(format_ptr=format_str; *format_ptr; format_ptr++)
@@
-370,11
+384,11
@@
void Error(int mode, char *format_str, ...)
fprintf(output_stream, "\n");
}
fprintf(output_stream, "\n");
}
- if (mode
== ERR_EXIT
_HELP)
+ if (mode
& ERR
_HELP)
fprintf(output_stream, "%s: Try option '--help' for more information.\n",
program_name);
fprintf(output_stream, "%s: Try option '--help' for more information.\n",
program_name);
- if (mode
!= ERR_RETURN
)
+ if (mode
& ERR_EXIT
)
{
fprintf(output_stream, "%s%s: aborting\n", program_name, process_name);
CloseAllAndExit(1);
{
fprintf(output_stream, "%s%s: aborting\n", program_name, process_name);
CloseAllAndExit(1);