int status, lineno;
char **arg = argv, *qargv[U_END];
char *p, *first, *middle, *last, *id, *login, *server;
- char buf[BUFSIZ], idbuf[32];
+ char buf[BUFSIZ];
FILE *input;
/* clear all flags & lists */
void usage(char **argv)
{
+#define USAGE_OPTIONS_FORMAT " %-39s%s\n"
fprintf(stderr, "Usage: %s listname [options]\n", argv[0]);
fprintf(stderr, "Options are\n");
- fprintf(stderr, " %-39s%-39s\n", "-v | -verbose",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-v | -verbose",
"-C | -create");
- fprintf(stderr, " %-39s%-39s\n", "-m | -members",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-m | -members",
"-R | -rename newname");
- fprintf(stderr, " %-39s%-39s\n", "-u | -users",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-u | -users",
"-P | -public");
- fprintf(stderr, " %-39s%-39s\n", "-l | -lists",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-l | -lists",
"-NP | -private");
- fprintf(stderr, " %-39s%-39s\n", "-s | -strings",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-s | -strings",
"-A | -active");
- fprintf(stderr, " %-39s%-39s\n", "-k | -kerberos",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-k | -kerberos",
"-I | -inactive");
- fprintf(stderr, " %-39s%-39s\n", "-i | -info",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-i | -info",
"-V | -visible");
- fprintf(stderr, " %-39s%-39s\n", "-r | -recursive",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-r | -recursive",
"-H | -hidden");
- fprintf(stderr, " %-39s%-39s\n", "-a | -add member",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-a | -add member",
"-M | -mail");
- fprintf(stderr, " %-39s%-39s\n", "-d | -delete member",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-d | -delete member",
"-NM | -notmail");
- fprintf(stderr, " %-39s%-39s\n", "-al | -addlist filename",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-al | -addlist filename",
"-G | -group");
- fprintf(stderr, " %-39s%-39s\n", "-dl | -deletelist filename",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-dl | -deletelist filename",
"-NG | -notgroup");
- fprintf(stderr, " %-39s%-39s\n", "-f | -file filename",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-f | -file filename",
"-D | -desc description");
- fprintf(stderr, " %-39s%-39s\n", "-at | -addtagged member tag",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-at | -addtagged member tag",
"-O | -owner owner");
- fprintf(stderr, " %-39s%-39s\n", "-ct | -changetag member tag",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-ct | -changetag member tag",
"-t | -tags");
- fprintf(stderr, " %-39s%-39s\n", "-n | -noauth",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-n | -noauth",
"-db | -database host[:port]");
exit(1);
}
void show_list_member(struct member *memberstruct)
{
char *s = "";
- char *tag;
switch (memberstruct->type)
{
extern char *whoami;
+#ifdef _WIN32
+#define strtok_r(s, tokens, resume) strtok(s, tokens)
+#endif /* _WIN32 */
+
int mrcl_validate_pobox_smtp(char *user, char *address, char **ret)
{
char *addr, *retaddr, *p, *lasts = NULL;
#include <ctype.h>
#ifdef HAVE_CURSES
+#ifdef _WIN32
+#include <conio.h>
+#ifdef MOUSE_MOVED
+#undef MOUSE_MOVED
+#endif
+#endif /*_WIN32*/
#include <curses.h>
#endif
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
#include <krb.h>
+#ifdef _WIN32
+#define INPUT_MASK 0xff
+#ifdef getchar
+#undef getchar
+#endif
+#define getchar() _getch()
+#ifdef title
+#undef title
+#endif
+static void DELETE_A_CHAR(void)
+{
+ int x, y;
+ getsyx(&y, &x);
+ x -= 1;
+ mvdelch(y,x);
+}
+#else /* !_WIN32 */
+#define INPUT_MASK 0x7f
+#define DELETE_A_CHAR() printf("\b \b");
+#endif /* !_WIN32 */
+
RCSID("$Header$");
#define STARTCOL 0
void display_menu(MENU *menu);
void pack_main_menu(void);
void pack_help_menu(void);
+void free_menu(MENU* menu);
void highlight(MENU *menu);
void title(char *buff);
void center_text(int row, char *buff);
display_buff("to at least 24 lines and 60 columns.\n");
exit(0);
}
+
raw();
noecho();
old_hook = set_com_err_hook(menu_err_hook);
position[0] = oldpos[0] = 1;
level = 0;
+
pack_main_menu();
pack_help_menu();
display_menu(main_menu);
cls();
endwin();
set_com_err_hook(old_hook);
+
+ free_menu(main_menu);
+ free_menu(help_menu);
+
+ if (current_li->acl_type)
+ free(current_li->acl_type);
+ if (current_li->acl_name)
+ free(current_li->acl_name);
+ if (current_li->desc)
+ free(current_li->desc);
+ if (current_li->modtime)
+ free(current_li->modtime);
+ if (current_li->modby)
+ free(current_li->modby);
+ if (current_li->modwith)
+ free(current_li->modwith);
+ free(current_li);
+
+ mr_disconnect();
+
exit(0);
punt:
currow = DISPROW + 2;
page = 1;
toggle = num_members = moreflg = 0;
- c = getchar() & 0x7f; /* mask parity bit */
+ c = getchar() & INPUT_MASK; /* mask parity bit */
if (c == '\r' || c == '\n')
{
if (position[level] == 7)
if (retflg)
delete_member();
break;
+#ifndef _WIN32
case 27: /* escape */
- c = getchar() & 0x7f;
+ c = getchar() & INPUT_MASK;
if (c == 91)
{
- c = getchar() & 0x7f;
+ c = getchar() & INPUT_MASK;
if (c == 65) /* up arrow */
{
position[level]--;
}
}
}
+#else /* _WIN32 */
+ case 0xe0:
+ c = getchar() & INPUT_MASK;
+ if (c == 0x48) /* up arrow */
+ {
+ position[level]--;
+ if (!position[level])
+ position[level] = 7;
+ }
+ else
+ {
+ if (c == 0x50) /* down arrow */
+ {
+ position[level]++;
+ if (position[level] > 7)
+ position[level] = 1;
+ }
+ }
+#endif /* _WIN32 */
break;
default:
printf("%c", 7);
show_text(currow, STARTCOL, "Press any Key to continue...");
getchar();
}
+ free(buf);
clrwin(DISPROW);
}
void display_buff(char *buf)
{
int i, cnt;
- char *printbuf;
+ char *printbuf = NULL;
int maxcol;
+ int len;
maxcol = COLS;
cnt = 0;
printbuf = calloc(maxcol, 1);
- for (i = 0; i <= strlen(buf); i++)
+ len = strlen(buf);
+ for (i = 0; i <= len; i++)
{
printbuf[cnt] = buf[i];
cnt++;
printbuf = calloc(maxcol, 1);
}
}
- if (strlen(buf) % maxcol != 0)
+ if (len % maxcol != 0)
{
start_display_buff(printbuf);
- free(printbuf);
}
+ if (printbuf)
+ free(printbuf);
return;
}
show_text(DISPROW + 4, STARTCOL, "Press any Key to continue...");
getchar();
}
+ free(buf);
clrwin(DISPROW);
}
currow = DISPROW + 4;
show_text(DISPROW + 4, STARTCOL, "Press any Key to continue...");
getchar();
+ free(argv[0]);
+ free(argv[1]);
+ free(argv[2]);
}
+ free(buf);
clrwin(DISPROW);
}
show_text(currow, STARTCOL, "Press any Key to continue...");
getchar();
clrwin(DISPROW);
+ free(buf);
}
/****************************************************/
char c;
show_text(DISPROW, STARTCOL, "This function may take a while... proceed? [n] ");
- c = getchar() & 0x7f;
+ c = getchar() & INPUT_MASK;
if (c == 'y' || c == 'Y')
{
move(DISPROW + 1, STARTCOL);
show_text(currow, STARTCOL, "Press any key to continue...");
getchar();
clrwin(DISPROW);
- return;
+ goto cleanup;
}
end_display();
- return;
+ goto cleanup;
}
clrwin(DISPROW);
+ cleanup:
+ free(buf);
}
/****************************************************/
erase_line(currow, STARTCOL);
show_text(currow, STARTCOL, "Flushing query...");
moreflg = 1;
- return;
+ goto cleanup;
}
clrwin(DISPROW + 2);
currow = DISPROW + 2;
currow++;
}
toggle = !toggle;
+ cleanup:
+ free(buffer);
}
/****************************************************/
show_text(currow, STARTCOL, "Press any key to continue...");
getchar();
clrwin(DISPROW);
+ free(buffer);
}
/****************************************************/
main_menu->items[4] = strdup("5. Add yourself to a mailing list.");
main_menu->items[5] = strdup("6. Delete yourself from a mailing list.");
main_menu->items[6] = strdup("q. Quit.");
+ free(buf);
}
/****************************************************/
help_menu->items[4] = strdup("Press any key to continue.");
}
+/****************************************************/
+void free_menu(MENU* menu)
+{
+ int i;
+ for (i = 0; i < menu->num_items; i++)
+ free(menu->items[i]);
+ free(menu->items);
+ free(menu->title);
+ free(menu);
+}
+
/****************************************************/
void highlight(MENU *menu)
{
addstr(prompt);
refresh();
+
for (p = buf; abs(strlen(p) - strlen(buf)) <= buflen;)
{
refresh();
- c = getchar() & 0x7f;
+ c = getchar() & INPUT_MASK;
switch (c)
{
case CTL('C'):
if (p > buf)
{
p--;
- printf("\b \b");
+ DELETE_A_CHAR();
}
break;
case CTL('U'):
case CTL('G'):
case CTL('['):
while (p-- > buf)
- printf("\b \b");
+ DELETE_A_CHAR();
p = buf;
break;
+#ifdef _WIN32
+ case 0xe0:
+ c = getchar() & INPUT_MASK;
+ putchar(CTL('G'));
+ break;
+#endif /*_WIN32*/
default:
if (abs(strlen(p) - strlen(buf)) >= buflen)
{
{
static char name[BUFSIZ];
char buf[BUFSIZ];
- int status;
if (!info) /* If no informaion */
{
static char **AskACLInfo(char **info)
{
char temp_buf[BUFSIZ];
- char *args[3];
- char *s, *d;
- int status;
Put_message("");
info[ACL_HOST] = canonicalize_hostname(info[ACL_HOST]);
int AddACL(int argc, char **argv)
{
- char *info[MAX_ARGS_SIZE], **args, *host;
+ char *info[MAX_ARGS_SIZE], **args;
int stat;
argv[1] = canonicalize_hostname(strdup(argv[1]));
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
RCSID("$Header$");
return info[FS_NAME];
}
-
char *canonicalize_cell(char *c)
{
+#ifdef _WIN32
+ return c;
+#else /* !_WIN32 */
struct stat stbuf;
char path[512];
int count;
path[count] = 0;
free(c);
return strdup(path);
+#endif /* _WIN32 */
}
#include "globals.h"
#include <sys/types.h>
+
+#ifdef HAVE_UNAME
#include <sys/utsname.h>
+#endif
+#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#endif /* _WIN32 */
#include <ctype.h>
#include <stdio.h>
return NULL;
if (GetAddressFromUser("Network mask", &info[SN_MASK]) == SUB_ERROR)
return NULL;
- if (atoi(info[SN_LOW]) == ntohl(inet_addr(S_DEFAULT_LOW)))
+ if (atoi(info[SN_LOW]) == (int)ntohl(inet_addr(S_DEFAULT_LOW)))
{
struct in_addr low;
unsigned long mask, addr;
if (GetAddressFromUser("Lowest assignable address", &info[SN_LOW]) ==
SUB_ERROR)
return NULL;
- if (atoi(info[SN_HIGH]) == ntohl(inet_addr(S_DEFAULT_HIGH)))
+ if (atoi(info[SN_HIGH]) == (int)ntohl(inet_addr(S_DEFAULT_HIGH)))
{
struct in_addr high;
unsigned long mask, addr;
else
{
struct hostent *hp;
+#ifdef HAVE_UNAME
struct utsname name;
-
uname(&name);
hp = gethostbyname(name.nodename);
+#else
+ char name[256];
+ gethostname(name, sizeof(name));
+ name[sizeof(name)-1] = 0;
+ hp = gethostbyname(name);
+#endif /* HAVE_UNAME */
cp = strchr(hp->h_name, '.');
if (cp)
def_domain = strdup(++cp);
{
char *args[10];
int status;
- char temp_buf[BUFSIZ];
if (GetMemberInfo("tag", args) == SUB_ERROR)
return DM_NORMAL;
#include "f_defs.h"
#include "globals.h"
-#include <pwd.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
-
-#include <krb.h>
+#endif /* HAVE_UNISTD_H */
RCSID("$Header$");
static void ErrorExit(char *buf, int status);
static void Usage(void);
-static void Signal_Handler(void);
-static void CatchInterrupt(void);
+static void Signal_Handler(int sig);
+static void CatchInterrupt(int sig);
+static void SetHandlers(void);
char *whoami; /* used by menu.c ugh!!! */
char *moira_server;
{
int status;
Menu *menu;
- char **arg, pname[ANAME_SZ];
- struct sigaction act;
+ char **arg;
if (!(program_name = strrchr(argv[0], '/')))
program_name = argv[0];
* These signals should not be set until just before we fire up the menu
* system.
*/
-
- sigemptyset(&act.sa_mask);
- act.sa_flags = 0;
- act.sa_handler = Signal_Handler;
- sigaction(SIGHUP, &act, NULL);
- sigaction(SIGQUIT, &act, NULL);
-#ifdef HAVE_CURSES
- if (use_menu)
- sigaction(SIGINT, &act, NULL);
- else
-#endif
- {
- act.sa_handler = CatchInterrupt;
- sigaction(SIGINT, &act, NULL);
- }
+ SetHandlers();
if (!strcmp(program_name, "listmaint"))
menu = &list_menu;
* Returns: doesn't
*/
-static void Signal_Handler(void)
+static void Signal_Handler(int sig)
{
Put_message("Signal caught - exiting");
#ifdef HAVE_CURSES
}
-static void CatchInterrupt(void)
+static void CatchInterrupt(int sig)
{
Put_message("Interrupt! Press RETURN to continue");
interrupt = 1;
}
+
+#ifdef HAVE_POSIX_SIGNALS
+static void SetHandlers(void)
+{
+ struct sigaction act;
+
+ sigemptyset(&act.sa_mask);
+ act.sa_flags = 0;
+ act.sa_handler = Signal_Handler;
+ sigaction(SIGHUP, &act, NULL);
+ sigaction(SIGQUIT, &act, NULL);
+#ifdef HAVE_CURSES
+ if (use_menu)
+ sigaction(SIGINT, &act, NULL);
+ else
+#endif
+ {
+ act.sa_handler = CatchInterrupt;
+ sigaction(SIGINT, &act, NULL);
+ }
+}
+#else
+static void SetHandlers(void)
+{
+ signal(SIGTERM, Signal_Handler);
+#ifdef HAVE_CURSES
+ if (use_menu)
+ signal(SIGINT, Signal_Handler);
+ else
+#endif
+ signal(SIGINT, CatchInterrupt);
+}
+#endif
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#include <conio.h>
+#ifdef getchar
+#undef getchar
+#endif
+#define getchar() _getch()
+#define getpid _getpid
+#endif /* _WIN32 */
RCSID("$Header$");
/* Prompt the user for input in the input window of cur_ms */
int Prompt_input(char *prompt, char *buf, int buflen)
{
+#ifdef HAVE_CURSES
int c;
char *p;
int y, x, oldx, oldy;
-#ifdef HAVE_CURSES
if (cur_ms != NULLMS)
{
more_flg = 1;
/* Will be truncated to COLS characters. */
void Put_line(char *msg)
{
- int y, x, i;
- char *msg1, chr;
-
if (!more_flg)
return;
#ifdef HAVE_CURSES
if (cur_ms != NULLMS)
{
+ int x, y;
+ char chr;
+
wstandout(cur_ms->ms_input);
wprintw(cur_ms->ms_input, "---More---");
wstandend(cur_ms->ms_input);
#ifdef HAVE_CURSES
if (cur_ms != NULLMS)
{
+ int i;
+ char *msg1;
+
msg1 = calloc(COLS, 1);
strncpy(msg1, msg, COLS - 1);
for (i = strlen(msg1); i < COLS - 1; i++)
return find_command_from(command, m, MAX_MENU_DEPTH);
}
+static char *get_tmp_dir(void)
+{
+#ifdef _WIN32
+ static char tmp[BUFSIZ];
+ DWORD len;
+ if (!tmp[0])
+ {
+ len = GetTempPath(sizeof(tmp), tmp);
+ if (!len || (len > sizeof(tmp)))
+ strcpy(tmp, ".");
+ }
+ return tmp;
+#else
+ return "/var/tmp";
+#endif
+}
+
int toggle_logging(int argc, char *argv[])
{
char buf[BUFSIZ];
if (!log_file)
{
- sprintf(buf, "/var/tmp/%s-log.%ld", whoami, (long)getpid());
+ sprintf(buf, "%s/%s-log.%ld", get_tmp_dir(), whoami, (long)getpid());
/* open the file */
log_file = fopen(buf, "a");
#include "globals.h"
#include <sys/types.h>
+#ifndef _WIN32
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#endif /* _WIN32 */
#include <stdio.h>
#include <stdlib.h>
{
int status;
char *type, temp_buf[BUFSIZ], *local_user, *args[10], *box;
- char *temp_box;
struct mqelem *top = NULL;
local_user = argv[1];
{
char temp_buf[BUFSIZ];
char *args[3], *lpc_acl;
- char *s, *d;
int status;
Put_message("");
static char *PrintPrintSrvInfo(char **info)
{
char buf[BUFSIZ];
- int status;
if (!info) /* If no informaion */
{
static char **AskPrintSrvInfo(char **info)
{
char buf[BUFSIZ];
- char *args[3], *lpc_acl;
- char *s, *d;
- int status;
Put_message("");
sprintf(buf, "Print Server entry for %s.", info[PRINTSERVER_HOST]);
int ChangePrintSrv(int argc, char **argv)
{
- char *name, **args;
+ char *name;
struct mqelem *elem = NULL;
int stat;
#include "f_defs.h"
#include "globals.h"
-#include <sys/time.h>
-
#include <ctype.h>
#include <stdio.h>
#include <stdlib.h>
char **AskUserInfo(char **info, Bool name)
{
- int i, state;
+ int state;
char temp_buf[BUFSIZ], *newname;
if (name)
FreeAndClear(&args[L_MODTIME], TRUE);
FreeAndClear(&args[L_MODBY], TRUE);
FreeAndClear(&args[L_MODWITH], TRUE);
- SlipInNewName(args, args[L_NAME]);
+ SlipInNewName(args, strdup(args[L_NAME]));
if ((status = do_mr_query("update_list", CountArgs(args), args,
NULL, NULL)))
{
FreeAndClear(&args[FS_MODTIME], TRUE);
FreeAndClear(&args[FS_MODBY], TRUE);
FreeAndClear(&args[FS_MODWITH], TRUE);
- SlipInNewName(args, args[FS_NAME]);
+ SlipInNewName(args, strdup(args[FS_NAME]));
if ((status = do_mr_query("update_filesys", CountArgs(args), args,
NULL, NULL)))
{
#include <sys/types.h>
+#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h> /* for gethostbyname. */
+#endif /* _WIN32 */
#include <ctype.h>
#include <stdio.h>
strcat(buffer, " (");
for (elem = GetTypeValues(tname); elem; elem = elem->q_forw)
{
+ /* Make sure we don't blow up and get too long a prompt */
+ if (strlen(buffer) > 64)
+ break;
strcat(buffer, elem->q_data);
if (elem->q_forw)
strcat(buffer, ", ");
}
strcat(buffer, ")");
+ /* Trim the prompt if it is too long */
if (strlen(buffer) > 64)
sprintf(buffer, "%s (? for help)", prompt);
if (GetValueFromUser(buffer, pointer) == SUB_ERROR)
#include <moira_site.h>
#include <mrclient.h>
-#include <sys/time.h>
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char *whoami;
static int count = 0;
-static struct timeval now;
+static time_t now;
struct service {
char name[17];
disp_svc(argv, "Should this be enabled?\n");
else if (atoi(argv[SVC_ENABLE]) &&
60 * atoi(argv[SVC_INTERVAL]) + 86400 + atoi(argv[SVC_DFCHECK])
- < now.tv_sec)
+ < now)
disp_svc(argv, "Service has not been updated\n");
return MR_CONT;
disp_sh(argv, "Should this be enabled?\n");
else if (atoi(argv[SH_ENABLE]) && update_int &&
60 * atoi(update_int) + 86400 + atoi(argv[SH_LASTSUCCESS])
- < now.tv_sec)
+ < now)
disp_sh(argv, "Host has not been updated\n");
return MR_CONT;
goto punt;
}
- gettimeofday(&now, 0);
+ now = time(NULL);
sq = sq_create();
/* Check services first */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
+
+#ifdef _WIN32
+#include <windows.h>
+#include <io.h>
+#define dup _dup
+#define dup2 _dup2
+#define isatty _isatty
+#define close _close
+#define open _open
+#define sigjmp_buf jmp_buf
+#define siglongjmp longjmp
+#define sigsetjmp(env, save) setjmp(env)
+#endif /* _WIN32 */
#ifdef HAVE_READLINE
#include "readline/readline.h"
int recursion = 0, quote_output = 0, interactive;
int count, quit = 0, cancel = 0;
char *whoami;
+
sigjmp_buf jb;
#define MAXARGS 20
-void discard_input(void);
+void discard_input(int sig);
char *mr_gets(char *prompt, char *buf, size_t len);
void execute_line(char *cmdbuf);
int parse(char *buf, char *argv[MAXARGS]);
void test_script(int argc, char **argv);
void test_list_requests(void);
void test_version(int argc, char **argv);
+void set_signal_handler(int, void (*handler)(int));
+void set_signal_blocking(int, int);
int main(int argc, char **argv)
{
char cmdbuf[BUFSIZ];
- struct sigaction action;
int c;
whoami = argv[0];
rl_bind_key('\t', rl_insert);
#endif
- action.sa_handler = discard_input;
- action.sa_flags = 0;
- sigemptyset(&action.sa_mask);
- sigaction(SIGINT, &action, NULL);
+ set_signal_handler(SIGINT, discard_input);
sigsetjmp(jb, 1);
while (!quit)
exit(0);
}
-void discard_input(void)
+void discard_input(int sig)
{
putc('\n', stdout);
void test_query(int argc, char **argv)
{
int status, help;
- sigset_t sigs;
if (argc < 2)
{
count = 0;
/* Don't allow ^C during the query: it will confuse libmoira's
internal state. (Yay static variables) */
- sigemptyset(&sigs);
- sigaddset(&sigs, SIGINT);
- sigprocmask(SIG_BLOCK, &sigs, NULL);
+ set_signal_blocking(SIGINT, 1);
status = mr_query(argv[1], argc - 2, argv + 2, print_reply, &help);
- sigprocmask(SIG_UNBLOCK, &sigs, NULL);
+ set_signal_blocking(SIGINT, 0);
printf("%d tuple%s\n", count, ((count == 1) ? "" : "s"));
if (status)
com_err("moira (query)", status, "");
if (status)
com_err("moira (version)", status, "");
}
+
+#ifdef HAVE_POSIX_SIGNALS
+
+void set_signal_handler(int sig, void (*handler)(int))
+{
+ struct sigaction action;
+
+ sigemptyset(&action.sa_mask);
+ action.sa_flags = 0;
+ action.sa_handler = handler;
+ sigaction(sig, &action, NULL);
+}
+
+void set_signal_blocking(int sig, int block)
+{
+ sigset_t sigs;
+ sigemptyset(&sigs);
+ sigaddset(&sigs, sig);
+ sigprocmask(block ? SIG_BLOCK : SIG_UNBLOCK, &sigs, NULL);
+}
+
+#else
+
+void set_signal_handler(int sig, void (*handler)(int))
+{
+ signal(sig, handler);
+}
+
+#ifdef _WIN32
+BOOL WINAPI blocking_handler(DWORD dwCtrlType)
+{
+ return(TRUE);
+}
+
+void set_signal_blocking(int sig, int block)
+{
+ SetConsoleCtrlHandler(blocking_handler, block ? TRUE : FALSE);
+}
+#endif /* _WIN32 */
+
+#endif /* HAVE_POSIX_SIGNALS */
int status; /* general purpose exit status */
int q_argc; /* argc for mr_query */
char *q_argv[F_END]; /* argv for mr_query */
- char *motd; /* for Moira server status */
int i;
struct finger_info old_info;
char *result;
int i;
int dashes = FALSE;
+ int len;
#define BLANK "none"
else
result = buf;
- for (i = 0; i < strlen(buf); i++)
+ len = strlen(buf);
+ for (i = 0; i < len; i++)
{
switch (buf[i])
{
if (phone_num && ok)
{
- for (i = 0; i < strlen(result); i++)
+ len = strlen(result);
+ for (i = 0; i < len; i++)
{
if (!isdigit(result[i]) && (result[i] != '-'))
{
#include <moira_site.h>
#include <mrclient.h>
-#include <pwd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+#ifdef HAVE_GETOPT_H
+#include <getopt.h>
+#endif
RCSID("$Header$");
int main(int argc, char *argv[])
{
- struct passwd *pwd;
char *mrarg[3];
char *address, *uname;
int c, setflag, splitflag, prevflag, status;
{
int status, success;
char **arg = argv;
- char *server = NULL, *p;
+ char *server = NULL;
/* clear all flags & lists */
info_flag = update_flag = create_flag = list_map_flag = update_map_flag = 0;
else if (argis("S", "status")) {
if (arg - argv < argc - 1) {
int i;
+ int len;
arg++;
update_flag++;
h_status = *arg;
- for(i=0; i<strlen(h_status); i++) {
+ len = strlen(h_status);
+ for(i = 0; i < len; i++) {
if(!isdigit(h_status[i])) {
printf("Error: status code %s is not numeric.\n", h_status);
exit(1);
char *old_argv[30];
char *argv[16];
char *args[5];
- int cnt;
args[0] = canonicalize_hostname(strdup(hostname));
args[1] = args[2] = args[3] = "*";
void usage(char **argv)
{
+#define USAGE_OPTIONS_FORMAT " %-39s%s\n"
fprintf(stderr, "Usage: %s hostname [options]\n", argv[0]);
fprintf(stderr, "Options are\n");
- fprintf(stderr, " %-39s%-39s\n", "-C | -create",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-C | -create",
"-O | -owner owner");
- fprintf(stderr, " %-39s%-39s\n", "-D | -delete",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-D | -delete",
"-S | -status status");
- fprintf(stderr, " %-39s%-39s\n", "-R | -rename newname",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-R | -rename newname",
"-V | -vendor vendor");
- fprintf(stderr, " %-39s%-39s\n", "-a | -addalias alias",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-a | -addalias alias",
"-M | -model model");
- fprintf(stderr, " %-39s%-39s\n", "-d | -deletealias alias",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-d | -deletealias alias",
"-L | -location location");
- fprintf(stderr, " %-39s%-39s\n", "-i | -info",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-i | -info",
"-o | -os os");
- fprintf(stderr, " %-39s%-39s\n", "-oc | -opcmt op_cmt",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-oc | -opcmt op_cmt",
"-c | -contact contact");
- fprintf(stderr, " %-39s%-39s\n", "-ac | -admcmt adm_cmt",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-ac | -admcmt adm_cmt",
"-A | -address address");
- fprintf(stderr, " %-39s%-39s\n", "-am | -addmap cluster",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-am | -addmap cluster",
"-N | -network network");
- fprintf(stderr, " %-39s%-39s\n", "-dm | -deletemap cluster",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-dm | -deletemap cluster",
"-lm | -listmap");
- fprintf(stderr, " %-39s%-39s\n", "-db | -database host[:port]",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-db | -database host[:port]",
"-n | -noauth");
- fprintf(stderr, " %-39s%-39s\n", "-v | -verbose",
+ fprintf(stderr, USAGE_OPTIONS_FORMAT, "-v | -verbose",
"");
exit(1);
}
-for ac_func in getusershell strlcpy strlcat
+for ac_func in getusershell strlcpy strlcat uname
do
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
echo "configure:2452: checking for $ac_func" >&5
done
+echo $ac_n "checking for sigaction""... $ac_c" 1>&6
+echo "configure:2506: checking for sigaction" >&5
+if eval "test \"`echo '$''{'ac_cv_func_sigaction'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2511 "configure"
+#include "confdefs.h"
+/* System header to define __stub macros and hopefully few prototypes,
+ which can conflict with char sigaction(); below. */
+#include <assert.h>
+/* Override any gcc2 internal prototype to avoid an error. */
+/* We use char because int might match the return type of a gcc2
+ builtin and then its argument prototype would still apply. */
+char sigaction();
+
+int main() {
+
+/* The GNU C library defines this for functions which it implements
+ to always fail with ENOSYS. Some functions are actually named
+ something starting with __ and the normal name is an alias. */
+#if defined (__stub_sigaction) || defined (__stub___sigaction)
+choke me
+#else
+sigaction();
+#endif
+
+; return 0; }
+EOF
+if { (eval echo configure:2534: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
+ rm -rf conftest*
+ eval "ac_cv_func_sigaction=yes"
+else
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_func_sigaction=no"
+fi
+rm -f conftest*
+fi
+
+if eval "test \"`echo '$ac_cv_func_'sigaction`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ cat >> confdefs.h <<\EOF
+#define HAVE_POSIX_SIGNALS 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+
+
+echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
+echo "configure:2558: checking how to run the C preprocessor" >&5
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+ CPP=
+fi
+if test -z "$CPP"; then
+if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ # This must be in double quotes, not single quotes, because CPP may get
+ # substituted into the Makefile and "${CC-cc}" will confuse make.
+ CPP="${CC-cc} -E"
+ # On the NeXT, cc -E runs the code through the compiler's parser,
+ # not just through cpp.
+ cat > conftest.$ac_ext <<EOF
+#line 2573 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2579: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -E -traditional-cpp"
+ cat > conftest.$ac_ext <<EOF
+#line 2590 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2596: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP="${CC-cc} -nologo -E"
+ cat > conftest.$ac_ext <<EOF
+#line 2607 "configure"
+#include "confdefs.h"
+#include <assert.h>
+Syntax Error
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2613: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ :
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ CPP=/lib/cpp
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+fi
+rm -f conftest*
+ ac_cv_prog_CPP="$CPP"
+fi
+ CPP="$ac_cv_prog_CPP"
+else
+ ac_cv_prog_CPP="$CPP"
+fi
+echo "$ac_t""$CPP" 1>&6
+
+for ac_hdr in unistd.h getopt.h
+do
+ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
+echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
+echo "configure:2641: checking for $ac_hdr" >&5
+if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
+ echo $ac_n "(cached) $ac_c" 1>&6
+else
+ cat > conftest.$ac_ext <<EOF
+#line 2646 "configure"
+#include "confdefs.h"
+#include <$ac_hdr>
+EOF
+ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
+{ (eval echo configure:2651: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
+ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
+if test -z "$ac_err"; then
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=yes"
+else
+ echo "$ac_err" >&5
+ echo "configure: failed program was:" >&5
+ cat conftest.$ac_ext >&5
+ rm -rf conftest*
+ eval "ac_cv_header_$ac_safe=no"
+fi
+rm -f conftest*
+fi
+if eval "test \"`echo '$ac_cv_header_'$ac_safe`\" = yes"; then
+ echo "$ac_t""yes" 1>&6
+ ac_tr_hdr=HAVE_`echo $ac_hdr | sed 'y%abcdefghijklmnopqrstuvwxyz./-%ABCDEFGHIJKLMNOPQRSTUVWXYZ___%'`
+ cat >> confdefs.h <<EOF
+#define $ac_tr_hdr 1
+EOF
+
+else
+ echo "$ac_t""no" 1>&6
+fi
+done
+
+
case $PRO_C_INCLUDES in
*INCLUDE='$(srcdir)'*) ;;
s%@CURSES_CPPFLAGS@%$CURSES_CPPFLAGS%g
s%@CURSES_LIBS@%$CURSES_LIBS%g
s%@CURSES_SUBDIRS@%$CURSES_SUBDIRS%g
+s%@CPP@%$CPP%g
s%@KLIBS@%$KLIBS%g
s%@MR_LIBDEP@%$MR_LIBDEP%g
AC_SUBST(CURSES_SUBDIRS)
-AC_CHECK_FUNCS(getusershell strlcpy strlcat)
+AC_CHECK_FUNCS(getusershell strlcpy strlcat uname)
+
+AC_CHECK_FUNC(sigaction, AC_DEFINE(HAVE_POSIX_SIGNALS))
+
+AC_CHECK_HEADERS(unistd.h getopt.h)
MR_EXTEND(PRO_C_INCLUDES, INCLUDE='$(srcdir)')
MR_INCLUDE('$(SRCTOP)/include')
#ifndef _moira_h_
#define _moira_h_
-/* return values from queries (and error codes) */
+#ifdef _WIN32
+#include <windows.h>
+#ifndef strcasecmp
+#define strcasecmp stricmp
+#endif
+#endif /*_WIN32 */
+/* return values from queries (and error codes) */
#include <sys/types.h>
#include <com_err.h>
#include "mr_et.h"
#include "krb_et.h"
#include "ureg_err.h"
+
#define MR_SUCCESS 0 /* Query was successful */
#define MR_VERSION_1 1 /* Version in use from 7/87 to 4/88 */
char *strtrim(char *s);
char *uppercase(char *s);
char *lowercase(char *s);
+
#ifndef HAVE_STRLCPY
size_t strlcpy(char *dst, const char *src, size_t size);
#endif
#include <moira.h>
#include <sys/types.h>
-#include <sys/socket.h>
+
+#ifdef HAVE_UNAME
#include <sys/utsname.h>
+#endif
+#ifndef _WIN32
+#include <sys/socket.h>
#include <netdb.h>
#include <netinet/in.h>
+#endif /* _WIN32 */
#include <ctype.h>
#include <stdio.h>
RCSID("$Header$");
+static struct hostent *local_gethostbyname(void)
+{
+#ifdef HAVE_UNAME
+ struct utsname name;
+ uname(&name);
+ return gethostbyname(name.nodename);
+#else
+ char hostname[128];
+ gethostname(hostname, sizeof(hostname));
+ hostname[sizeof(hostname)-1] = 0;
+ return gethostbyname(hostname);
+#endif
+}
+
static char *local_domain(void)
{
static char *domain = NULL;
}
else
{
- struct utsname name;
- uname(&name);
- hp = gethostbyname(name.nodename);
+ hp = local_gethostbyname();
if (hp)
{
cp = strchr(hp->h_name, '.');
#include "mr_private.h"
#include <errno.h>
-#include <netinet/in.h>
#include <stdlib.h>
#include <string.h>
+#ifndef _WIN32
+#include <netinet/in.h>
+#endif /* _WIN32 */
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
RCSID("$Header$");
int mr_send(int fd, struct mr_params *params)
{
- u_long length, written;
+ u_long length;
+ int written;
int i, *argl;
char *buf, *p;
length = p - buf;
putlong(buf, length);
- written = write(fd, buf, length);
+ written = send(fd, buf, length, 0);
free(buf);
if (!params->mr_argl)
free(argl);
- if (written != length)
+ if (written != (int)length)
return MR_ABORTED;
else
return MR_SUCCESS;
* on failure, or -1 if the packet hasn't been completely received
* yet.
*/
+
int mr_cont_receive(int fd, struct mr_params *reply)
{
u_long length, data;
- ssize_t size, more;
+ int size, more;
char *p, *end;
int i;
{
char lbuf[4];
- size = read(fd, lbuf, 4);
+ size = recv(fd, lbuf, 4, 0);
if (size != 4)
return size ? MR_ABORTED : MR_NOT_CONNECTED;
getlong(lbuf, length);
else
getlong(reply->mr_flattened, length);
- more = read(fd, reply->mr_flattened + reply->mr_filled,
- length - reply->mr_filled);
+ more = recv(fd, reply->mr_flattened + reply->mr_filled,
+ length - reply->mr_filled, 0);
if (more == -1)
{
mr_destroy_reply(*reply);
getlong(reply->mr_flattened + 8, reply->u.mr_status);
getlong(reply->mr_flattened + 12, reply->mr_argc);
- if (reply->mr_argc > (length - 16) / 8)
+ if (reply->mr_argc > ((int)length - 16) / 8)
{
mr_destroy_reply(*reply);
return MR_INTERNAL;
#include "mr_private.h"
#include <sys/types.h>
-#include <sys/socket.h>
-
-#include <netinet/in.h>
-#include <netdb.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
+
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+
+#ifndef _WIN32
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#ifndef closesocket
+#define closesocket close
+#endif
+#ifndef SOCKET_ERROR
+#define SOCKET_ERROR -1
+#endif
+#endif
#ifdef HAVE_HESIOD
#include <hesiod.h>
RCSID("$Header$");
+#define DEFAULT_SERV "moira_db"
+#define DEFAULT_PORT 775
+
int _mr_conn = 0;
static char *mr_server_host = NULL;
int mr_connect_internal(char *server, char *port)
{
- int fd, size, more;
+ int size, more;
struct sockaddr_in target;
struct hostent *shost;
char actualresponse[53];
+ char *host = NULL;
+ int fd = SOCKET_ERROR;
+ int ok = 0;
shost = gethostbyname(server);
if (!shost)
- return 0;
+ goto cleanup;
+
+ /* Get the host info in case some library decides to clobber shost. */
+ memcpy(&target.sin_addr, shost->h_addr, shost->h_length);
+ target.sin_family = shost->h_addrtype;
+ host = strdup(shost->h_name);
if (port[0] == '#')
- target.sin_port = htons(atoi(port + 1));
+ target.sin_port = htons((unsigned short)atoi(port + 1));
else
{
struct servent *s;
+ target.sin_port = 0;
s = getservbyname(port, "tcp");
if (s)
target.sin_port = s->s_port;
- else
#ifdef HAVE_HESIOD
+ if (!target.sin_port)
{
s = hes_getservbyname(port, "tcp");
if (s)
target.sin_port = s->s_port;
- else
- return 0;
}
-#else
- return 0;
#endif
+ if (!target.sin_port && !strcasecmp(port, DEFAULT_SERV))
+ target.sin_port = htons(DEFAULT_PORT);
+ if (!target.sin_port)
+ goto cleanup;
}
- memcpy(&target.sin_addr, shost->h_addr, shost->h_length);
- target.sin_family = shost->h_addrtype;
-
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0)
- return 0;
+ goto cleanup;
if (connect(fd, (struct sockaddr *)&target, sizeof(target)) < 0)
- {
- close(fd);
- return 0;
- }
+ goto cleanup;
/* Do magic mrgdb initialization */
- size = write(fd, challenge, sizeof(challenge));
+ size = send(fd, challenge, sizeof(challenge), 0);
if (size != sizeof(challenge))
- {
- close(fd);
- return 0;
- }
+ goto cleanup;
for (size = 0; size < sizeof(actualresponse); size += more)
{
- more = read(fd, actualresponse + size, sizeof(actualresponse) - size);
+ more = recv(fd, actualresponse + size, sizeof(actualresponse) - size, 0);
if (more <= 0)
break;
}
if (size != sizeof(actualresponse))
- {
- close(fd);
- return 0;
- }
+ goto cleanup;
if (memcmp(actualresponse, response, sizeof(actualresponse)))
+ goto cleanup;
+
+ ok = 1;
+ mr_server_host = host;
+
+ cleanup:
+ if (!ok)
{
- close(fd);
+ if (host)
+ free(host);
+ if (fd != SOCKET_ERROR)
+ closesocket(fd);
return 0;
}
-
- mr_server_host = strdup(shost->h_name);
-
/* You win */
return fd;
}
int mr_disconnect(void)
{
CHECK_CONNECTED;
- close(_mr_conn);
+ closesocket(_mr_conn);
_mr_conn = 0;
free(mr_server_host);
mr_server_host = NULL;
return -1;
if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, (char *)&on, sizeof(int)) < 0)
{
- close(s);
+ closesocket(s);
return -1;
}
if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) < 0)
{
- close(s);
+ closesocket(s);
return -1;
}
if (listen(s, 5) < 0)
{
- close(s);
+ closesocket(s);
return -1;
}
if (!*buf)
{
char lbuf[4];
- if (read(conn, lbuf, 4) != 4)
+ if (recv(conn, lbuf, 4, 0) != 4)
{
- close(conn);
+ closesocket(conn);
return 0;
}
getlong(lbuf, len);
*buf = malloc(len);
if (!*buf || len < 58)
{
- close(conn);
+ closesocket(conn);
free(*buf);
return 0;
}
else
getlong(*buf, len);
- more = read(conn, *buf + *nread, len - *nread);
+ more = recv(conn, *buf + *nread, len - *nread, 0);
if (more == -1 && errno != EINTR)
{
- close(conn);
+ closesocket(conn);
free(*buf);
return 0;
}
if (memcmp(*buf + 4, challenge + 4, 34))
{
- close(conn);
+ closesocket(conn);
free(*buf);
return 0;
}
/* good enough */
free(*buf);
- if (write(conn, response, sizeof(response)) != sizeof(response))
+ if (send(conn, response, sizeof(response), 0) != sizeof(response))
{
- close(conn);
+ closesocket(conn);
return 0;
}
return conn;
#include <sys/types.h>
+#ifndef _WIN32
#include <netinet/in.h>
#include <arpa/inet.h>
+#endif /*_WIN32*/
extern int _mr_conn, mr_inited;
#define CHECK_CONNECTED if (!_mr_conn) return MR_NOT_CONNECTED
#define getlong(cp, l) do { l = ((((unsigned char *)cp)[0] * 256 + ((unsigned char *)cp)[1]) * 256 + ((unsigned char *)cp)[2]) * 256 + ((unsigned char *)cp)[3]; } while(0)
-#define putlong(cp, l) do { ((unsigned char *)cp)[0] = l >> 24; ((unsigned char *)cp)[1] = l >> 16; ((unsigned char *)cp)[2] = l >> 8; ((unsigned char *)cp)[3] = l; } while(0)
+#define putlong(cp, l) do { ((unsigned char *)cp)[0] = (unsigned char)(l >> 24); ((unsigned char *)cp)[1] = (unsigned char)(l >> 16); ((unsigned char *)cp)[2] = (unsigned char)(l >> 8); ((unsigned char *)cp)[3] = (unsigned char)(l); } while(0)
/* prototypes from mr_call.h */
int mr_do_call(struct mr_params *params, struct mr_params *reply);