VMS formatting issues - util.c

John E. Malmberg wb8tyw at qsl.net
Thu Aug 24 22:36:49 GMT 2006


In order to not maintain some OpenVMS specific edits to the SAMBA code, 
I would like to request a change to some modules to allow accommodation.

Some of the values for OpenVMS need to be formatted differently than on 
UNIX in order to be meaningful for display, input, or easy debugging.

Could something similar to this patch be done to util.c as a start?

These routines format the values in them the way that UNIX expects.

With the OpenVMS build, In most cases, I can selectively replace the 
calls to them with ones that do the formatting in the way that OpenVMS 
users expect, so that that the OpenVMS specific code can be put in a 
separate module.

For a more detailed explanation:

Process IDs on OpenVMS are usually displayed and entered in hex, so the 
routine "interpret_pid" on OpenVMS needs to handle a hex string instead
of an ASCII string.

To make this obvious, I set up a macro to replace atoi() that can be 
overridden at compile time for interpret_pid()

On OpenVMS procid_str_static() needs to return it's result in hex for 
display.  This is why I set up a macro that can be externally defined to 
a different format string.


uid_t values on OpenVMS are split in to two parts and displayed in octal 
with brackets surrounding them, example: [1,4].

gid_t values on OpenVMS have two formats.  For numbers under about 
0x10000, they are displayed in octal.  For numbers above 0x10000 they 
are displayed in hex.  This is because there are two types of gid_t 
values that could be in use.

ino_t values on OpenVMS are displayed as a triple enclosed in 
parenthesis.  Example: (10,100,1).


OpenVMS will also need code in status.c, and web/*.c changed to use the 
strings returned by these routines instead of the %d and %0.0f that they 
are using now.  After something similar to this is in util.c, I will be 
able to submit patches for that.

Having these changes to some of the debug formatting would also be 
useful for OpenVMS users.


Thank you,
-John Malmberg
wb8tyw at qsl.net
(john.malmberg$hp.com)
Personal Opinion Only

-------------- next part --------------
--- /src_root/samba_3_0/source/lib/util.c	Thu Aug 24 00:56:46 2006
+++ /lcl_root/samba_3_0/source/lib/util.c	Thu Aug 24 18:07:09 2006
@@ -2962,11 +2962,17 @@
 	return (pid->pid == sys_getpid());
 }
 
+#ifndef samba_ascii_pid_to_int
+#define samba_ascii_pid_to_int(x) atoi(x)
+#endif
 struct process_id interpret_pid(const char *pid_string)
 {
-	return pid_to_procid(atoi(pid_string));
+	return pid_to_procid(samba_ascii_pid_to_int(pid_string));
 }
 
+#ifndef SAMBA_PID_FORMATSTR
+#define SAMBA_PID_FORMATSTR "%d"
+#endif
 char *procid_str_static(const struct process_id *pid)
 {
 	static fstring str;
@@ -2988,6 +2994,28 @@
 {
 	return True;
 }
+
+char *uid_str_static(uid_t uid)
+{
+	static fstring str;
+	fstr_sprintf(str, "%d", uid);
+	return str;
+}
+
+char *gid_str_static(gid_t gid)
+{
+	static fstring str;
+	fstr_sprintf(str, "%d", gid);
+	return str;
+}
+
+char *ino_str_static(ino_t ino)
+{
+	static fstring str;
+	fstr_sprintf(str, "%9.0f", ino);
+	return str;
+}
+
 
 int this_is_smp(void)
 {


More information about the samba-technical mailing list