Example #1
0
void modalfatalbox(const char *p, ...)
{
    va_list ap;
    fprintf(stderr, "FATAL ERROR: ");
    va_start(ap, p);
    vfprintf(stderr, p, ap);
    va_end(ap);
    fputc('\n', stderr);
    cleanup_exit(1);
}
Example #2
0
void modalfatalbox(char *fmt, ...) {
    va_list ap;
    Str255 stuff;
    
    va_start(ap, fmt);
    /* We'd like stuff to be a Pascal string */
    stuff[0] = vsprintf((char *)(&stuff[1]), fmt, ap);
    va_end(ap);
    ParamText(stuff, NULL, NULL, NULL);
    StopAlert(128, NULL);
    cleanup_exit(1);
}
Example #3
0
void fatalbox(char *fmt, ...)
{
    va_list ap;
    char *stuff, morestuff[100];

    va_start(ap, fmt);
    stuff = dupvprintf(fmt, ap);
    va_end(ap);
    sprintf(morestuff, "%.70s Fatal Error", appname);
    MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
    sfree(stuff);
    cleanup_exit(1);
}
Example #4
0
void modalfatalbox(const char *fmt, ...)
{
    va_list ap;
    char* str;

    va_start(ap, fmt);
    str = dupvprintf(fmt, ap);
    va_end(ap);
    fzprintf(sftpError, "Fatal error: %s", str);
    sfree(str);

    cleanup_exit(1);
}
Example #5
0
void connection_fatal(void *frontend, char *p, ...)
{
    struct gui_data *inst = (struct gui_data *)frontend;
    va_list ap;
    char *msg;
    va_start(ap, p);
    msg = dupvprintf(p, ap);
    va_end(ap);
    inst->exited = TRUE;
    QMessageBox::critical(qPutty,"Fatal error",msg);
    sfree(msg);
    if (conf_get_int(inst->conf, CONF_close_on_exit) == FORCE_ON)
        cleanup_exit(1);
}
Example #6
0
void connection_fatal(void *frontend, char *p, ...)
{
	va_list ap;
	char *stuff, morestuff[100];

	va_start(ap, p);
	stuff = dupvprintf(p, ap);
	va_end(ap);
	sprintf(morestuff, "%.70s Fatal Error", appname);
	MessageBox(GetParentHwnd(), stuff, morestuff,
		MB_SYSTEMMODAL | MB_ICONERROR | MB_OK);
	sfree(stuff);
	cleanup_exit(1);
}
Example #7
0
void connection_fatal(void *frontend, char *p, ...)
{
    va_list ap;
    fprintf(stderr, "FATAL ERROR: ");
    va_start(ap, p);
    vfprintf(stderr, p, ap);
    va_end(ap);
    fputc('\n', stderr);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
    cleanup_exit(1);
}
Example #8
0
void modalfatalbox(char *p, ...)
{
    va_list ap;
    fprintf(stderr, "FATAL ERROR: ");
    va_start(ap, p);
    vfprintf(stderr, p, ap);
    va_end(ap);
    fputc('\n', stderr);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
    cleanup_exit(1);
}
Example #9
0
static void mac_menucommand(long result)
{
    short menu, item;
    WindowPtr window;
#if !TARGET_API_MAC_CARBON
    Str255 da;
#endif

    menu = HiWord(result);
    item = LoWord(result);
    window = FrontWindow();
    /* Things which do the same whatever window we're in. */
    switch (menu) {
      case mApple:
        switch (item) {
          case iAbout:
	    mac_openabout();
            goto done;
#if !TARGET_API_MAC_CARBON
          default:
            GetMenuItemText(GetMenuHandle(mApple), item, da);
            OpenDeskAcc(da);
            goto done;
#endif
        }
        break;
      case mFile:
        switch (item) {
	  case iNew:
	    mac_newkey();
	    goto done;
          case iClose:
            mac_closewindow(window);
            goto done;
          case iQuit:
            cleanup_exit(0);
            goto done;
        }
        break;
    }
    /* If we get here, handling is up to window-specific code. */
    if (mac_wininfo(window)->menu != NULL)
	(*mac_wininfo(window)->menu)(window, menu, item);

  done:
    HiliteMenu(0);
}
Example #10
0
void fatalbox(char *p, ...)
{
	va_list ap;
	char *stuff, morestuff[100];

	va_start(ap, p);
	stuff = dupvprintf(p, ap);
	va_end(ap);
	sprintf(morestuff, "%.70s Fatal Error", appname);
	MessageBox(GetParentHwnd(), stuff, morestuff, MB_ICONERROR | MB_OK);
	sfree(stuff);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
	cleanup_exit(1);
}
Example #11
0
void modalfatalbox(char *p, ...)
{
    struct termios cf;
    va_list ap;
    premsg(&cf);
    fprintf(stderr, "FATAL ERROR: ");
    va_start(ap, p);
    vfprintf(stderr, p, ap);
    va_end(ap);
    fputc('\n', stderr);
    postmsg(&cf);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
    cleanup_exit(1);
}
Example #12
0
const char *
get_remote_ipaddr(void)
{
	/* Check whether we have cached the ipaddr. */
	if (canonical_host_ip == NULL) {
		if (packet_connection_is_on_socket()) {
			canonical_host_ip =
			    get_peer_ipaddr(packet_get_connection_in());
			if (canonical_host_ip == NULL)
				cleanup_exit(255);
		} else {
			/* If not on socket, return UNKNOWN. */
			canonical_host_ip = xstrdup("UNKNOWN");
		}
	}
	return canonical_host_ip;
}
Example #13
0
void connection_fatal(void *frontend, const char *p, ...)
{
    struct termios cf;
    va_list ap;
    premsg(&cf);
    fprintf(stderr, "FATAL ERROR: ");
    va_start(ap, p);
    vfprintf(stderr, p, ap);
    va_end(ap);
    fputc('\n', stderr);
    postmsg(&cf);
    if (logctx) {
        log_free(logctx);
        logctx = NULL;
    }
    cleanup_exit(1);
}
Example #14
0
File: tpico.c Project: aropop/pico
static void read_file(char * name)
{
   FILE *file = fopen(name,"r");
   int ch, j;
   char *bufptr;

   if (file == NULL) {
      sprintf(sprintfbuf, "ERROR: Cannot open file \"%s\": skipping\n", name);
      show(sprintfbuf, ON_NEW_LINE);
      globalfilebuf = NULL;
      return;
   }
   errno = 0;
   (void)fseek(file, 0, SEEK_END);
      /* fseek return value puzzling, using errno */
   if (errno) {
      sprintf(sprintfbuf, "ERROR: Reading file \"%s\": skipping\n", name);
      show(sprintfbuf, ON_NEW_LINE);
      globalfilebuf = NULL;
      return;
   }
   if ((bufptr = globalfilebuf =
            (char *)malloc((size_t)ftell(file)+1)) == NULL) {
      sprintf(sprintfbuf,
             "FATAL ERROR: Cannot allocate %ld bytes to load program text\n",
              ftell(file)+1);
      show(sprintfbuf, ON_NEW_LINE);
      cleanup_exit(EXIT_FAILURE);
   }
   strncpy(globalfilename, name, NAMELEN);
   globalfilename[NAMELEN-1] = '\0';

   rewind(file);
   while (!feof(file) && ((ch = getc(file)) != EOF))
      *bufptr++ = (char)ch;
   *bufptr = '\0';

   (void)fclose(file);

   if (standalone && globalfilebuf[0]=='#' && globalfilebuf[1]=='!')
      for (j=0; globalfilebuf[j]!=CR && globalfilebuf[j]!=LF; j++)
         globalfilebuf[j] = ' ';
   /* allow #!/usr/local/bin/pico -bis (and don't mess up mark) */
}
Example #15
0
File: zproxy.c Project: zmike/ezrpc
static void sighandler(int signum){

	int ret = EXIT_FAILURE;

 	if (signum == -1) {
		fprintf(stderr, "Exiting due to errors.\n");
	} else {

		if (signum == SIGTERM || signum == SIGINT){
			fprintf(stderr, "Caught CTRL-C or SIGTERM.\n");
			ret = EXIT_SUCCESS;
		} else {
			fprintf(stderr, "Exiting due to errors.\n");
		}
	}

	cleanup_exit(ret);

}
Example #16
0
void stdouterr_sent(struct handle *h, size_t new_backlog, int err)
{
    if (err) {
	char buf[4096];
	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, err, 0,
		      buf, lenof(buf), NULL);
	buf[lenof(buf)-1] = '\0';
	if (buf[strlen(buf)-1] == '\n')
	    buf[strlen(buf)-1] = '\0';
	fprintf(stderr, "Unable to write to standard %s: %s\n",
		(h == stdout_handle ? "output" : "error"), buf);
	cleanup_exit(0);
    }

    if (backend_connected(backend)) {
        backend_unthrottle(backend, (handle_backlog(stdout_handle) +
                                     handle_backlog(stderr_handle)));
    }
}
Example #17
0
int console_get_line(const char *prompt, char *str,
			    int maxlen, int is_pw)
{
    HANDLE hin, hout;
    DWORD savemode, newmode, i;

    if (console_batch_mode) {
	if (maxlen > 0)
	    str[0] = '\0';
	return 0;
    } else {
	hin = GetStdHandle(STD_INPUT_HANDLE);
	hout = GetStdHandle(STD_OUTPUT_HANDLE);
	if (hin == INVALID_HANDLE_VALUE || hout == INVALID_HANDLE_VALUE) {
	    fprintf(stderr, "Cannot get standard input/output handles\n");
	    cleanup_exit(1);
	}

	GetConsoleMode(hin, &savemode);
	newmode = savemode | ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT;
	if (is_pw)
	    newmode &= ~ENABLE_ECHO_INPUT;
	else
	    newmode |= ENABLE_ECHO_INPUT;
	SetConsoleMode(hin, newmode);

	WriteFile(hout, prompt, strlen(prompt), &i, NULL);
	ReadFile(hin, str, maxlen - 1, &i, NULL);

	SetConsoleMode(hin, savemode);

	if ((int) i > maxlen)
	    i = maxlen - 1;
	else
	    i = i - 2;
	str[i] = '\0';

	if (is_pw)
	    WriteFile(hout, "\r\n", 2, &i, NULL);

	return 1;
    }
}
Example #18
0
int main(int argc, char **argv)
{
    extern int pt_main(int argc, char **argv);
    int ret;

    sk_init();
    flags = FLAG_VERBOSE | FLAG_INTERACTIVE;
    default_protocol = be_default_protocol;
    /* Find the appropriate default port. */
    {
	Backend *b = backend_from_proto(default_protocol);
	default_port = 0; /* illegal */
	if (b)
	    default_port = b->default_port;
    }
    ret = pt_main(argc, argv);
    cleanup_exit(ret);
    return ret;             /* not reached, but placates optimisers */
}
Example #19
0
int verify_ssh_host_key(void *frontend, char *host, int port, char *keytype,
                        char *keystr, char *fingerprint,
                        void (*callback)(void *ctx, int result), void *ctx)
{
    int ret;
    static const char absentmsg_batch[] =
	"The server's host key is not cached in the registry. You\n"
	"have no guarantee that the server is the computer you\n"
	"think it is.\n"
	"The server's %s key fingerprint is:\n"
	"%s\n"
	"Connection abandoned.\n";

    static const char wrongmsg_batch[] =
	"WARNING - POTENTIAL SECURITY BREACH!\n"
	"The server's host key does not match the one PuTTY has\n"
	"cached in the registry. This means that either the\n"
	"server administrator has changed the host key, or you\n"
	"have actually connected to another computer pretending\n"
	"to be the server.\n"
	"The new %s key fingerprint is:\n"
	"%s\n"
	"Connection abandoned.\n";

    /*
     * Verify the key against the registry.
     */
    ret = verify_host_key(host, port, keytype, keystr);

    if (ret == 0)		       /* success - key matched OK */
	return 1;

    if (ret == 2) {		       /* key was different */
        appendLogF(wrongmsg_batch, keytype, fingerprint);
        return 0;
    }
    if (ret == 1) {		       /* key was absent */
        appendLogF(absentmsg_batch, keytype, fingerprint);
        cleanup_exit(1);
    }
    return 1;
}
Example #20
0
char *ssh_sftp_get_cmdline(char *prompt, int no_fds_ok)
{
    int ret;
    struct command_read_ctx actx, *ctx = &actx;
    DWORD threadid;
    HANDLE hThread;

    fputs(prompt, stdout);
    fflush(stdout);

    if ((sftp_ssh_socket == INVALID_SOCKET && no_fds_ok) ||
	p_WSAEventSelect == NULL) {
	return fgetline(stdin);	       /* very simple */
    }

    /*
     * Create a second thread to read from stdin. Process network
     * and timing events until it terminates.
     */
    ctx->event = CreateEvent(NULL, FALSE, FALSE, NULL);
    ctx->line = NULL;

    hThread = CreateThread(NULL, 0, command_read_thread, ctx, 0, &threadid);
    if (!hThread) {
	CloseHandle(ctx->event);
	fprintf(stderr, "Unable to create command input thread\n");
	cleanup_exit(1);
    }

    do {
	ret = do_eventsel_loop(ctx->event);

	/* Error return can only occur if netevent==NULL, and it ain't. */
	assert(ret >= 0);
    } while (ret == 0);

    CloseHandle(hThread);
    CloseHandle(ctx->event);

    return ctx->line;
}
Example #21
0
static void write_body(readfunc_t rf, void *rfarg)
{
    ssize_t rd;
    char   *out;

    int hadlf = 1;
    /* If the message terminated early (without body or blank
     * line between header and body), enforce a blank line to
     * prevent anything past us from choking. */
    (void) fputs(eol, fpo);

    /* print body */
    while ((rd = rf(&out, rfarg)) > 0)
    {
	(void) fwrite(out, 1, rd, fpo);
	hadlf = (out[rd-1] == '\n');
	if (ferror(fpo)) cleanup_exit(EX_ERROR, 1);
    }

    if (!hadlf) (void) fputs(eol, fpo);
}
Example #22
0
void stdouterr_sent(struct handle *h, int new_backlog)
{
    if (new_backlog < 0) {
	/*
	 * Special case: report write error.
	 */
	char buf[4096];
	FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, -new_backlog, 0,
		      buf, lenof(buf), NULL);
	buf[lenof(buf)-1] = '\0';
	if (buf[strlen(buf)-1] == '\n')
	    buf[strlen(buf)-1] = '\0';
	fprintf(stderr, "Unable to write to standard %s: %s\n",
		(h == stdout_handle ? "output" : "error"), buf);
	cleanup_exit(0);
    }
    if (connopen && back->connected(backhandle)) {
	back->unthrottle(backhandle, (handle_backlog(stdout_handle) +
				      handle_backlog(stderr_handle)));
    }
}
Example #23
0
void
mm_request_receive(int sock, Buffer *m)
{
	u_char buf[4];
	u_int msg_len;

	debug3("%s entering", __func__);

	if (atomicio(read, sock, buf, sizeof(buf)) != sizeof(buf)) {
		if (errno == EPIPE)
			cleanup_exit(255);
		fatal("%s: read: %s", __func__, strerror(errno));
	}
	msg_len = get_u32(buf);
	if (msg_len > 256 * 1024)
		fatal("%s: read: bad msg_len %d", __func__, msg_len);
	buffer_clear(m);
	buffer_append_space(m, msg_len);
	if (atomicio(read, sock, buffer_ptr(m), msg_len) != msg_len)
		fatal("%s: read: %s", __func__, strerror(errno));
}
Example #24
0
void write_message(rc_t status)
{
    readfunc_t rf = NULL;	/* assignment to quench warning */
    void *rfarg = 0;		/* assignment to quench warning */
    textdata_t *text;
    bool seen_subj = false;

    build_spam_header();

    if (!passthrough)
    {
	write_spam_info();
    }
    else
    {
	eol = NULL;
	/* initialize */
	rf = read_mem;
	text = textblock_head();
	rfarg = &text;

	seen_subj = write_header(status, rf, rfarg);

	if (!seen_subj) {
	    if (status == RC_SPAM && spam_subject_tag != NULL)
		(void) fprintf(fpo, "Subject: %s%s", spam_subject_tag, eol);
	    if (status == RC_UNSURE && unsure_subject_tag != NULL)
		(void) fprintf(fpo, "Subject: %s%s", unsure_subject_tag, eol);
	}

	write_body(rf, rfarg);

	if (verbose || Rtable) {
	    if (fflush(fpo) || ferror(fpo))
		cleanup_exit(EX_ERROR, 1);
	}
    }

    return;
}
Example #25
0
int main(int argc, char * argv[], char * env[])
{
	struct stat st;
	int ret = -1;

    /* strobj.c need memory helper */
	mh_init_all();
	parse_args(argc, argv);

	do
	{
		/* If we have output, read the output first. */
		if (o_slpfile) read_sealpac(o_slpfile);

		/* If we have files to read, read the files. */
		if (o_targetpath != NULL)
		{
			if (stat(o_targetpath, &st) < 0)
			{
				printf("stat() error, %s !\n",strerror(errno));
				break;
			}
			if		(S_ISREG(st.st_mode))	ret = read_file(o_targetpath);
			else if	(S_ISDIR(st.st_mode))	ret = read_directory(o_targetpath);
			else
			{
				printf("Unable to handle '%s'.\n",o_targetpath);
				break;
			}
			printf("Number of files read : %d\n",g_filecount);
		}

		/* Dump to output */
		dump_i18n_strings();
		ret = 0;
	} while (0);
	cleanup_exit(ret);
	return ret;
}
Example #26
0
static void show_usage(int exit_code)
{
	printf(	PROGNAME " version " VERSION "\n"
			"usage: " PROGNAME " [OPTIONS]\n"
			"  -h                 show this help message.\n"
			"  -v                 verbose mode.\n"
			"  -r                 recursive.\n"
			"  -l                 list files.\n"
			"  -c {langcode}      language code.\n"
			"  -f {file}          sealpac file.\n"
			"  -d {target}        target directory or file.\n"
			"  -t {type}          file type, file extension.\n"
			"\n"
			"  Sealpac will search the directory & files (specified with -d, -t & -r) for\n"
			"  i18n() functions of EPHP and extract the text. The text string will be save\n"
			"  in the Sealpac file (specified with -f).\n"
			"  ex:\n"
			"  To create sealpac: sealpac -d rootfs -t php -r -f sealpac.slt\n"
			"  To dump info:      sealpac -f sealpac.slt -v\n"
			);
	cleanup_exit(exit_code);
}
Example #27
0
static void mac_eventloop(void) {
    Boolean gotevent;
    EventRecord event;
    RgnHandle cursrgn;
    Point mousenow, mousethen;
    KeyState *ks;
    WindowPtr front;

    cursrgn = NewRgn();
    GetMouse(&mousethen);
    for (;;) {
    	mac_adjustcursor(cursrgn);
	gotevent = WaitNextEvent(everyEvent, &event, LONG_MAX, cursrgn);
	mac_adjustcursor(cursrgn);
	front = mac_frontwindow();
	if (front != NULL) {
	    ks = mac_windowkey(front);
	    if (ks->collecting_entropy) {
		GetMouse(&mousenow);
		if (mousenow.h != mousethen.h || mousenow.v != mousethen.v) {
		    ks->entropy[ks->entropy_got++] = *(unsigned *)&mousenow;
		    ks->entropy[ks->entropy_got++] = TickCount();
		    if (ks->entropy_got >= ks->entropy_required)
			ks->collecting_entropy = 0;
		    SetControlValue(ks->progress, ks->entropy_got);
		    mousethen = mousenow;
		}
		SetEmptyRgn(cursrgn);
	    }
	}
	    
	if (gotevent)
	    mac_event(&event);
	if (borednow)
	    cleanup_exit(0);
    }
    DisposeRgn(cursrgn);
}
Example #28
0
int console_get_userpass_input(prompts_t *p, unsigned char *in, int inlen)
{
    char* prompt;
    int i;
    size_t curr_prompt;

    /*
     * Zero all the results, in case we abort half-way through.
     */
    for (i = 0; i < (int)p->n_prompts; i++)
        memset(p->prompts[i]->result, 0, p->prompts[i]->result_len);

    if (console_batch_mode)
    return 0;

    prompt = dupstr("");
    /* We only print the `name' caption if we have to... */
    if (p->name_reqd && p->name)
        prompt = dupstr(p->name);
    /* ...but we always print any `instruction'. */
    if (p->instruction) {
        char* old = prompt;
        prompt = dupcat(prompt, p->instruction, 0);
        sfree(old);
    }
    for (curr_prompt = 0; curr_prompt < p->n_prompts; curr_prompt++) {
        prompt_t *pr = p->prompts[curr_prompt];
        char* thisprompt = dupcat(prompt, pr->prompt, 0);
        if (!DoLoginDialog(pr->result, pr->result_len, thisprompt, TRUE))
        {
            return 0;
            cleanup_exit(1);
        }
    }
    return 1;
}
Example #29
0
static void
client_alive_check(void)
{
	int channel_id;

	/* timeout, check to see how many we have had */
	if (packet_inc_alive_timeouts() > options.client_alive_count_max) {
		logit("Timeout, client not responding.");
		cleanup_exit(255);
	}

	/*
	 * send a bogus global/channel request with "wantreply",
	 * we should get back a failure
	 */
	if ((channel_id = channel_find_open()) == -1) {
		packet_start(SSH2_MSG_GLOBAL_REQUEST);
		packet_put_cstring("[email protected]");
		packet_put_char(1);	/* boolean: want reply */
	} else {
		channel_request_start(channel_id, "[email protected]", 1);
	}
	packet_send();
}
Example #30
0
static void
mm_record_login(Session *s, struct passwd *pw)
{
	socklen_t fromlen;
	struct sockaddr_storage from;

	/*
	 * Get IP address of client. If the connection is not a socket, let
	 * the address be 0.0.0.0.
	 */
	memset(&from, 0, sizeof(from));
	fromlen = sizeof(from);
	if (packet_connection_is_on_socket()) {
		if (getpeername(packet_get_connection_in(),
			(struct sockaddr *) & from, &fromlen) < 0) {
			debug("getpeername: %.100s", strerror(errno));
			cleanup_exit(255);
		}
	}
	/* Record that there was a login on that tty from the remote host. */
	record_login(s->pid, s->tty, pw->pw_name, pw->pw_uid,
	    get_remote_name_or_ip(utmp_len, options.use_dns),
	    (struct sockaddr *)&from, fromlen);
}