Example #1
0
static void do_work(void)
{
    char *curip = NULL;
    struct in_addr inr;

    log_line("updating to interface: [%s]", ifname);

    while (1) {
        free(curip);

        if (update_from_remote == 0) {
            curip = get_interface_ip(ifname);
        } else {
            curip = query_curip();
        }

        if (!curip)
            goto sleep;
        if (inet_aton(curip, &inr) == 0) {
            log_line("%s has ip: [%s], which is invalid.  Sleeping.",
                     ifname, curip);
            goto sleep;
        }

        dd_work(curip);
        nc_work(curip);
        he_dns_work(curip);
        he_tun_work(curip);
sleep:
        do_sleep();
    }
}
Example #2
0
void quit_program(int rc)
{
	set_process_permissions(0, 0, xstrtoo(VBOX_ROOT_UMASK, 0));

	modem_hangup(&vboxmodem);

	log_line(LOG_D, "Closing modem device (%d)...\n", vboxmodem.fd);

	if (vboxmodem_close(&vboxmodem) != 0)
	{
		log_line(LOG_E, "%s (%s)\n", vboxmodem_error(), strerror(errno));
	}

	if (isdnttyname)
	{
		printstring(temppathname, "%s/LCK..%s", LOCKDIR, isdnttyname);

		lock_remove(temppathname);

		printstring(temppathname, "%s/vboxgetty-%s.pid", PIDDIR, isdnttyname);

		pid_remove(temppathname);
	}

	scr_remove_interpreter();
	rc_free(rc_getty_c);
	breaklist_clear();
	log_close();

	exit(rc);
}
Example #3
0
/*
 * db_set --
 *	Store a line in the file.
 *
 * PUBLIC: int db_set __P((SCR *, db_recno_t, CHAR_T *, size_t));
 */
int
db_set(SCR *sp, db_recno_t lno, CHAR_T *p, size_t len)
{
	DBT data, key;
	EXF *ep;
	const char *fp;
	size_t flen;

#if defined(DEBUG) && 0
	vtrace(sp, "replace line %lu: len %lu {%.*s}\n",
	    (u_long)lno, (u_long)len, MIN(len, 20), p);
#endif
	/* Check for no underlying file. */
	if ((ep = sp->ep) == NULL) {
		ex_emsg(sp, NULL, EXM_NOFILEYET);
		return (1);
	}
	if (ep->l_win && ep->l_win != sp->wp) {
		ex_emsg(sp, NULL, EXM_LOCKED);
		return 1;
	}
		
	/* Log before change. */
	log_line(sp, lno, LOG_LINE_RESET_B);

	INT2FILE(sp, p, len, fp, flen);

	/* Update file. */
	memset(&key, 0, sizeof(key));
	key.data = &lno;
	key.size = sizeof(lno);
	memset(&data, 0, sizeof(data));
	data.data = __UNCONST(fp);
	data.size = flen;
	if ((sp->db_error = ep->db->put(ep->db, NULL, &key, &data, 0)) != 0) {
		msgq(sp, M_DBERR, "006|unable to store line %lu", (u_long)lno);
		return (1);
	}

	/* Flush the cache, update line count, before screen update. */
	update_cache(sp, LINE_RESET, lno);

	/* File now dirty. */
	if (F_ISSET(ep, F_FIRSTMODIFY))
		(void)rcv_init(sp);
	F_SET(ep, F_MODIFIED);

	/* Log after change. */
	log_line(sp, lno, LOG_LINE_RESET_F);

	/* Update screen. */
	return (scr_update(sp, lno, LINE_RESET, 1));
}
Example #4
0
/*
 * db_set --
 *	Store a line in the file.
 *
 * PUBLIC: int db_set(SCR *, recno_t, CHAR_T *, size_t);
 */
int
db_set(
	SCR *sp,
	recno_t lno,
	CHAR_T *p,
	size_t len)
{
	DBT data, key;
	EXF *ep;
	char *fp;
	size_t flen;

#if defined(DEBUG) && 0
	TRACE(sp, "replace line %lu: len %lu {%.*s}\n",
	    (u_long)lno, (u_long)len, MIN(len, 20), p);
#endif
	/* Check for no underlying file. */
	if ((ep = sp->ep) == NULL) {
		ex_emsg(sp, NULL, EXM_NOFILEYET);
		return (1);
	}
		
	/* Log before change. */
	log_line(sp, lno, LOG_LINE_RESET_B);

	INT2FILE(sp, p, len, fp, flen);

	/* Update file. */
	key.data = &lno;
	key.size = sizeof(lno);
	data.data = fp;
	data.size = flen;
	if (ep->db->put(ep->db, &key, &data, 0) == -1) {
		msgq(sp, M_SYSERR,
		    "006|unable to store line %lu", (u_long)lno);
		return (1);
	}

	/* Flush the cache, before logging or screen update. */
	if (lno == ep->c_lno)
		ep->c_lno = OOBLNO;

	/* File now dirty. */
	if (F_ISSET(ep, F_FIRSTMODIFY))
		(void)rcv_init(sp);
	F_SET(ep, F_MODIFIED);

	/* Log after change. */
	log_line(sp, lno, LOG_LINE_RESET_F);

	/* Update screen. */
	return (scr_update(sp, lno, LINE_RESET, 1));
}
Example #5
0
static int vboxgettyrc_parse(unsigned char *tty)
{
	unsigned char tempsectname[VBOX_MAX_RCLINE_SIZE + 1];

	xstrncpy(temppathname, SYSCONFDIR		 , PATH_MAX);
	xstrncat(temppathname, "/vboxgetty.conf", PATH_MAX);

		/* First time, the global ttyI settings will be	*/
		/* parsed.													*/

	xstrncpy(tempsectname, "vboxgetty-tty", VBOX_MAX_RCLINE_SIZE);

	if (rc_read(rc_getty_c, temppathname, tempsectname) == -1) return(-1);

		/* Second, the settings for the used ttyI will be	*/
		/* parsed.														*/

	xstrncpy(tempsectname, "vboxgetty-", VBOX_MAX_RCLINE_SIZE);
	xstrncat(tempsectname, tty			  , VBOX_MAX_RCLINE_SIZE);

	if (rc_read(rc_getty_c, temppathname, tempsectname) == -1) return(-1);

		/* After this, all unset variables will be filled with	*/
		/* the defaults.														*/

	log_line(LOG_D, "Filling unset configuration variables with defaults...\n");

	if (!rc_set_empty(rc_getty_c, "init"				, "ATZ&B512"		 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "badinitsexit"		, "10"				 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "initpause"			, "2500"				 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "commandtimeout"	, "4"					 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "echotimeout"		, "4"					 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "ringtimeout"		, "6"					 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "alivetimeout"		, "1800"				 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "toggledtrtime"	, "400"				 )) return(-1);
	if (!rc_set_empty(rc_getty_c, "spooldir"			, "/var/spool/vbox")) return(-1);

	modemsetup.echotimeout		= xstrtol(rc_get_entry(rc_getty_c, "echotimeout"	), 4		);
	modemsetup.commandtimeout	= xstrtol(rc_get_entry(rc_getty_c, "commandtimeout"), 4		);
	modemsetup.ringtimeout		= xstrtol(rc_get_entry(rc_getty_c, "ringtimeout"	), 6		);
	modemsetup.alivetimeout		= xstrtol(rc_get_entry(rc_getty_c, "alivetimeout"	), 1800	);
	modemsetup.toggle_dtr_time	= xstrtol(rc_get_entry(rc_getty_c, "toggledtrtime"	), 400	);

	if (!rc_get_entry(rc_getty_c, "initnumber"))
	{
		log_line(LOG_E, "Variable \"initnumber\" *must* be set!\n");
		
		return(-1);
	}

	return(0);
}
Example #6
0
static bool test_string_set(struct ConfigSet *cs, struct Buffer *err)
{
  log_line(__func__);

  const char *valid[] = { "*****@*****.**", "*****@*****.**", NULL };
  const char *name = "Damson";
  char *addr = NULL;

  int rc;
  for (unsigned int i = 0; i < mutt_array_size(valid); i++)
  {
    mutt_buffer_reset(err);
    rc = cs_str_string_set(cs, name, valid[i], err);
    if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
    {
      TEST_MSG("%s\n", err->data);
      return false;
    }

    addr = VarDamson ? VarDamson->mailbox : NULL;
    if (!TEST_CHECK(mutt_str_strcmp(addr, valid[i]) == 0))
    {
      TEST_MSG("Value of %s wasn't changed\n", name);
      return false;
    }
    TEST_MSG("%s = '%s', set by '%s'\n", name, NONULL(addr), NONULL(valid[i]));
  }

  name = "Elderberry";
  for (unsigned int i = 0; i < mutt_array_size(valid); i++)
  {
    mutt_buffer_reset(err);
    rc = cs_str_string_set(cs, name, valid[i], err);
    if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
    {
      TEST_MSG("%s\n", err->data);
      return false;
    }

    addr = VarElderberry ? VarElderberry->mailbox : NULL;
    if (!TEST_CHECK(mutt_str_strcmp(addr, valid[i]) == 0))
    {
      TEST_MSG("Value of %s wasn't changed\n", name);
      return false;
    }
    TEST_MSG("%s = '%s', set by '%s'\n", name, NONULL(addr), NONULL(valid[i]));
  }

  log_line(__func__);
  return true;
}
Example #7
0
/*
 * db_delete --
 *	Delete a line from the file.
 *
 * PUBLIC: int db_delete __P((SCR *, db_recno_t));
 */
int
db_delete(SCR *sp, db_recno_t lno)
{
	DBT key;
	EXF *ep;

#if defined(DEBUG) && 0
	vtrace(sp, "delete line %lu\n", (u_long)lno);
#endif
	/* Check for no underlying file. */
	if ((ep = sp->ep) == NULL) {
		ex_emsg(sp, NULL, EXM_NOFILEYET);
		return (1);
	}
	if (ep->l_win && ep->l_win != sp->wp) {
		ex_emsg(sp, NULL, EXM_LOCKED);
		return 1;
	}
		
	/* Update marks, @ and global commands. */
	if (line_insdel(sp, LINE_DELETE, lno))
		return 1;

	/* Log before change. */
	log_line(sp, lno, LOG_LINE_DELETE_B);

	/* Update file. */
	memset(&key, 0, sizeof(key));
	key.data = &lno;
	key.size = sizeof(lno);
	if ((sp->db_error = ep->db->del(ep->db, NULL, &key, 0)) != 0) {
		msgq(sp, M_DBERR, "003|unable to delete line %lu", 
		    (u_long)lno);
		return (1);
	}

	/* Flush the cache, update line count, before screen update. */
	update_cache(sp, LINE_DELETE, lno);

	/* File now modified. */
	if (F_ISSET(ep, F_FIRSTMODIFY))
		(void)rcv_init(sp);
	F_SET(ep, F_MODIFIED);

	/* Log after change. */
	log_line(sp, lno, LOG_LINE_DELETE_F);

	/* Update screen. */
	return (scr_update(sp, lno, LINE_DELETE, 1));
}
Example #8
0
int set_process_permissions(uid_t uid, gid_t gid, int mask)
{
	struct passwd *pwd;
	int            groupsset;

	log_line(LOG_D, "Setting effective permissions to %d.%d [%04o]...\n", uid, gid, mask);

	errno     = 0;
	groupsset = 0;

		/* Eintrag des zu setzenden Benutzers aus der passwd lesen. Mit	*/
		/* initgroups() werden dann die realen Gruppen des Benutzers ein-	*/
		/* gestellt. Ab Kernel 2.1.x scheint das nicht mehr von setgid()	*/
		/* gemacht zu werden!															*/

	if ((pwd = getpwuid(uid)))
	{
		if (uid != 0)
		{
			if (initgroups(pwd->pw_name, gid) == 0) groupsset = 1;
		}

		if (setegid(gid) == 0)
		{
			if (seteuid(uid) == 0)
			{
				if (mask != 0) umask(mask);

				if ((uid == 0) || (!groupsset))
				{
					if (initgroups(pwd->pw_name, gid) == 0) groupsset = 1;
				}

				if (!groupsset)
				{
					log(LOG_E, "Can't run initgroups(\"%s\", %d) (%s).\n", pwd->pw_name, gid, strerror(errno));

					return(-1);
				}
			
				return(0);
			}
			else log_line(LOG_E, "Can't set effective uid to %d (%s).\n", uid, strerror(errno));
		}
		else log_line(LOG_E, "Can't set effective gid to %d (%s).\n", gid, strerror(errno));
	}
	else log(LOG_E, "Can't get uid %d passwd entry (%s).", strerror(errno));

	return(-1);
}
Example #9
0
static int check_ssl(void)
{
    int t;
    curl_version_info_data *data;

    data = curl_version_info(CURLVERSION_NOW);

    t = data->features & CURL_VERSION_SSL;
    if (t) {
        log_line("curl has SSL support, using https.");
    } else {
        log_line("curl lacks SSL support, using http.");
    }
    return t;
}
Example #10
0
static bool test_native_set(struct ConfigSet *cs, struct Buffer *err)
{
  log_line(__func__);

  struct Address *a = address_new("*****@*****.**");
  const char *name = "Ilama";
  char *addr = NULL;
  bool result = false;

  mutt_buffer_reset(err);
  int rc = cs_str_native_set(cs, name, (intptr_t) a, err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
  {
    TEST_MSG("%s\n", err->data);
    goto tbns_out;
  }

  addr = VarIlama ? VarIlama->mailbox : NULL;
  if (!TEST_CHECK(mutt_str_strcmp(addr, a->mailbox) == 0))
  {
    TEST_MSG("Value of %s wasn't changed\n", name);
    goto tbns_out;
  }
  TEST_MSG("%s = '%s', set by '%s'\n", name, NONULL(addr), a->mailbox);

  name = "Jackfruit";
  mutt_buffer_reset(err);
  rc = cs_str_native_set(cs, name, 0, err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
  {
    TEST_MSG("%s\n", err->data);
    goto tbns_out;
  }

  if (!TEST_CHECK(VarJackfruit == NULL))
  {
    TEST_MSG("Value of %s wasn't changed\n", name);
    goto tbns_out;
  }
  addr = VarJackfruit ? VarJackfruit->mailbox : NULL;
  TEST_MSG("%s = '%s', set by NULL\n", name, NONULL(addr));

  log_line(__func__);
  result = true;
tbns_out:
  address_free(&a);
  return result;
}
Example #11
0
static void voice_handle_touchtone_dle(int byte)
{
	switch (byte)
	{
		case '0':
		case '1':
		case '2':
		case '3':
		case '4':
		case '5':
		case '6':
		case '7':
		case '8':
		case '9':
		case '*':
		case '#':
		case 'A':
		case 'B':
		case 'C':
		case 'D':
			voice_handle_touchtone(byte);
			break;

		default:
			log_line(L_ERROR, "Illeagal \"<DLE>\" shielded code \"");
			log_char(L_ERROR, byte);
			log_text(L_ERROR, "\" (ignored)...\n");
			break;
	}
}
Example #12
0
static void sig_print_format(THEME_REC *theme, const char *module,
			     TEXT_DEST_REC *dest, void *formatnum, char **args)
{
	char *str, *linestart, *tmp;

	if (log_theme == NULL) {
		/* theme isn't loaded for some reason (/reload destroys it),
		   reload it. */
		log_theme = theme_load(log_theme_name);
		if (log_theme == NULL) return;
	}

	if (theme == log_theme)
		return;

	str = format_get_text_theme_charargs(log_theme, module, dest,
					     GPOINTER_TO_INT(formatnum), args);
	skip_next_printtext = TRUE;

	if (*str != '\0') {
                /* add the line start format */
		linestart = format_get_level_tag(log_theme, dest);
                tmp = str;
		str = format_add_linestart(tmp, linestart);
		g_free_not_null(linestart);
		g_free(tmp);

		/* strip colors from text, log it. */
		log_line(dest, str);
	}
	g_free(str);

}
Example #13
0
BOOL file_reader::SetFilePointerEx(__in LARGE_INTEGER liDistanceToMove, __out_opt PLARGE_INTEGER lpNewFilePointer, __in DWORD dwMoveMethod)
{
	log_line("SetFilePointerEx, %d, %d", liDistanceToMove, dwMoveMethod);
	if (!m_is_encrypted || !m_key_ok)
		return ::SetFilePointerEx(m_file, liDistanceToMove, lpNewFilePointer, dwMoveMethod);

	__int64 old_pos = m_pos;

	if (dwMoveMethod == SEEK_SET)
		m_pos = liDistanceToMove.QuadPart;
	else if (dwMoveMethod == SEEK_CUR)
	{
		m_pos += liDistanceToMove.QuadPart;
	}
	else if (dwMoveMethod == SEEK_END)
		m_pos = m_file_size;


	if (m_pos <0)
	{
		m_pos = old_pos;
		return FALSE;
	}
	if (lpNewFilePointer)
		lpNewFilePointer->QuadPart = m_pos;

	return TRUE;
}
Example #14
0
void ViewSFML::drawUI(sf::RenderTarget &target) const {
  // Switch view to Screenspace
  sf::View old_view = target.getView();
  sf::Vector2f size = (sf::Vector2f)target.getSize();
  target.setView(sf::View({0.f, 0.f, size.x, size.y}));

  // Draw fps counter
  sf::Text fps_counter(frameTimer.getOutput(), font, 12);
  target.draw(fps_counter);

  // Draw Log
  // const int spacing = 14;
  sf::Text log_line("", font, 12);
  for (int i = 0; i < logLength; i++) {
    const std::string &line = logging[(logIndex + i) % logLength];
    if (!line.empty()) {
      log_line.setString(sf::String::fromUtf8(line.begin(), line.end()));
      log_line.move({0, log_line.getLocalBounds().height * 1.1f});

      target.draw(log_line);
    }
  }

  // restore view
  target.setView(old_view);
}
Example #15
0
/*
 * db_insert --
 *	Insert a line into the file.
 *
 * PUBLIC: int db_insert(SCR *, recno_t, CHAR_T *, size_t);
 */
int
db_insert(
	SCR *sp,
	recno_t lno,
	CHAR_T *p,
	size_t len)
{
	DBT data, key;
	EXF *ep;
	char *fp;
	size_t flen;
	int rval;

#if defined(DEBUG) && 0
	TRACE(sp, "insert before %lu: len %lu {%.*s}\n",
	    (u_long)lno, (u_long)len, MIN(len, 20), p);
#endif
	/* Check for no underlying file. */
	if ((ep = sp->ep) == NULL) {
		ex_emsg(sp, NULL, EXM_NOFILEYET);
		return (1);
	}
		
	INT2FILE(sp, p, len, fp, flen);
		
	/* Update file. */
	key.data = &lno;
	key.size = sizeof(lno);
	data.data = fp;
	data.size = flen;
	if (ep->db->put(ep->db, &key, &data, R_IBEFORE) == -1) {
		msgq(sp, M_SYSERR,
		    "005|unable to insert at line %lu", (u_long)lno);
		return (1);
	}

	/* Flush the cache, update line count, before screen update. */
	if (lno >= ep->c_lno)
		ep->c_lno = OOBLNO;
	if (ep->c_nlines != OOBLNO)
		++ep->c_nlines;

	/* File now dirty. */
	if (F_ISSET(ep, F_FIRSTMODIFY))
		(void)rcv_init(sp);
	F_SET(ep, F_MODIFIED);

	/* Log change. */
	log_line(sp, lno, LOG_LINE_INSERT);

	/* Update marks, @ and global commands. */
	rval = 0;
	if (mark_insdel(sp, LINE_INSERT, lno))
		rval = 1;
	if (ex_g_insdel(sp, LINE_INSERT, lno))
		rval = 1;

	/* Update screen. */
	return (scr_update(sp, lno, LINE_INSERT, 1) || rval);
}
Example #16
0
/*
 * void init_server(char *bind_ip, int port)
 * 
 * Starts the server and its threads,
 * binds to given ip and port.
 */
void init_server(char *bind_ip, int port) {
    int server_len;
    struct sockaddr_in server_addr;
    
    server_sockfd = socket(AF_INET, SOCK_DGRAM, 0);
    
    server_addr.sin_family = AF_INET;
    server_addr.sin_addr.s_addr = inet_addr(bind_ip);
    server_addr.sin_port = htons(port);
    
    server_len = sizeof(server_addr);
    
    if(bind(server_sockfd, (struct sockaddr *) &server_addr, server_len) != 0) {
        raise_error("Error binding, exiting.");
    }
    
    /* Set socket timeout depending on OS */
    set_socket_timeout_linux();
    
    /* Log */
    sprintf(log_buffer,
            "Starting server with IP %s and port %d",
            bind_ip,
            port
            );
    
    log_line(log_buffer, LOG_ALWAYS);
}
Example #17
0
static bool test_string_get(struct ConfigSet *cs, struct Buffer *err)
{
  log_line(__func__);
  const char *name = "Fig";
  char *addr = NULL;

  mutt_buffer_reset(err);
  int rc = cs_str_string_get(cs, name, err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
  {
    TEST_MSG("Get failed: %s\n", err->data);
    return false;
  }
  addr = VarFig ? VarFig->mailbox : NULL;
  TEST_MSG("%s = '%s', '%s'\n", name, NONULL(addr), err->data);

  name = "Guava";
  mutt_buffer_reset(err);
  rc = cs_str_string_get(cs, name, err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
  {
    TEST_MSG("Get failed: %s\n", err->data);
    return false;
  }
  addr = VarGuava ? VarGuava->mailbox : NULL;
  TEST_MSG("%s = '%s', '%s'\n", name, NONULL(addr), err->data);

  name = "Hawthorn";
  rc = cs_str_string_set(cs, name, "hawthorn", err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
    return false;

  mutt_buffer_reset(err);
  rc = cs_str_string_get(cs, name, err);
  if (!TEST_CHECK(CSR_RESULT(rc) == CSR_SUCCESS))
  {
    TEST_MSG("Get failed: %s\n", err->data);
    return false;
  }
  addr = VarHawthorn ? VarHawthorn->mailbox : NULL;
  TEST_MSG("%s = '%s', '%s'\n", name, NONULL(addr), err->data);

  log_line(__func__);
  return true;
}
Example #18
0
static void sig_printtext(TEXT_DEST_REC *dest, const char *text,
			  const char *stripped)
{
	if (skip_next_printtext) {
		skip_next_printtext = FALSE;
		return;
	}

	log_line(dest, text);
}
Example #19
0
void make_username(const char* start, ssize_t len, const char* msgprefix)
{
  str_copyb(&username, start, len);
  if (local_name && str_findfirst(&username, AT) < 0) {
    str_catc(&username, AT);
    str_cats(&username, local_name);
  }
  str_copy2s(&msgstr, msgprefix, username.s);
  log_line(msgstr.s, msgstr.len);
}
Example #20
0
HIDDEN void
get_cbar(void)
{
    int eid, pid;
    int g1, g2;
    point_t pt1, pt2;
    fastf_t radius;
    vect_t height;
    struct pbar *pb;
    char cbar_name[NAMESIZE+1];

    eid = atoi( curr_rec[1] );

    pid = atoi( curr_rec[2] );
    if ( !pid )
    {
	if ( bar_def_pid )
	    pid = bar_def_pid;
	else
	    pid = eid;
    }

    g1 = atoi( curr_rec[3] );

    g2 = atoi( curr_rec[4] );

    get_grid( g1, pt1 );
    get_grid( g2, pt2 );

    for ( BU_LIST_FOR( pb, pbar, &pbar_head.l ) )
    {
	if ( pb->pid == pid )
	    break;
    }

    if ( BU_LIST_IS_HEAD( &pb->l, &pbar_head.l ) )
    {
	log_line( "Non-existent PID referenced in CBAR" );
	return;
    }

    VSCALE( pt1, pt1, conv[units] );
    VSCALE( pt2, pt2, conv[units] );

    radius = sqrt( pb->area/bn_pi );
    radius = radius * conv[units];

    VSUB2( height, pt2, pt1 );

    sprintf( cbar_name, "cbar.%d", eid );
    mk_rcc( fpout, cbar_name, pt1, height, radius );

    mk_addmember( cbar_name, &pb->head.l, NULL, WMOP_UNION );
}
Example #21
0
static int run_modem_init(void)
{
	struct vbox_tcl_variable vars[] = 
	{
		{ "vbxv_init"			, rc_get_entry(rc_getty_c, "init"		) },
		{ "vbxv_initnumber"	, rc_get_entry(rc_getty_c, "initnumber") },
		{ NULL					, NULL											  }
	};

	log_line(LOG_D, "Initializing modem...\n");

	if (scr_init_variables(vars) == 0)
	{
		if (scr_execute("initmodem.tcl", NULL) == 0) return(0);
	}

	log_line(LOG_E, "Can't initialize modem device!\n");

	return(-1);
}
Example #22
0
void file_reader::set_key(unsigned char*key)
{
	if (!m_is_encrypted)
		log_line("warning: not a encrypted file, ignored and set key.\n");

	m_codec.set_key(key, 256);
	m_codec.encrypt(m_keyhint, m_keyhint);
	if (memcmp(m_keyhint, m_keyhint+16, 16))
	{
		log_line("key error.\n");
		m_key_ok = false;
	}
	else
	{
		log_line("key ok.\n");
		m_key_ok = true;
	}

	m_codec.decrypt(m_keyhint, m_keyhint);
}
Example #23
0
BOOL file_reader::GetFileSizeEx(PLARGE_INTEGER lpFileSize)
{
	log_line("GetFileSizeEx");
	if (!m_is_encrypted || !m_key_ok)
		return ::GetFileSizeEx(m_file, lpFileSize);

	if (!lpFileSize)
		return FALSE;
	lpFileSize->QuadPart = m_file_size;
	return TRUE;
}
Example #24
0
static void pid_create(unsigned char *name)
{
	FILE *pptr;

	log_line(LOG_D, "Creating \"%s\"...\n", name);
	
	if ((pptr = fopen(name, "w")))
	{
		fprintf(pptr, "%d\n", getpid());
		fclose(pptr);
	}
}
void port_reschedule(void)
{
    SAVE_CONTEXT();
    log_line(running_task->name);
    log_string(" --> ");
    reschedule();
    timer_tick = RR_TIMEOUT_MS;
    log_string(running_task->name);
    RESTORE_CONTEXT();
    /* The RETI instruction enables interrupts. */
    __asm__ __volatile__ ("reti \n\t");
}
Example #26
0
unsigned char *rc_set_entry(struct vboxrc *rc, unsigned char *name, unsigned char *value)
{
	int				i = 0;
	unsigned char *v = NULL;

	log(LOG_D, "Setting \"%s\" to \"%s\"...\n", ((char *)name ? (char *)name : "???"), ((char *)value ? (char *)value : "???"));

	if ((!name) || (!value))
	{
		if (!name ) log_line(LOG_W, "Configuration variable name not set (ignored).\n");
		if (!value) log_line(LOG_W, "Configuration argument not set (ignored).\n");

		return(NULL);
	}
	
	while (rc[i].name)
	{
		if (strcasecmp(rc[i].name, name) == 0)
		{
			v = strdup(value);
			
			if (v)
			{
				if (rc[i].value) free(rc[i].value);
				
				rc[i].value = v;
			}
			else log_line(LOG_E, "Can't set \"%s\"'s value.\n", name);

			return(v);
		}

		i++;
	}

	log_line(LOG_W, "Unknown entry \"%s\" ignored.\n", name);

	return(NULL);
}
Example #27
0
/*
___________________________________________________________

    Display curent server uptime.
___________________________________________________________
*/
void display_uptime() {
    struct timeval temp_tv;
    
    gettimeofday(&temp_tv, NULL);


    sprintf(log_buffer,
            "Server uptime: %01.0fh:%02.0fm:%02.0fs",
            floor( (temp_tv.tv_sec - ts_start.tv_sec) / 3600.),
            floor(fmod((temp_tv.tv_sec - ts_start.tv_sec), 3600.0) / 60.0),
            fmod((temp_tv.tv_sec - ts_start.tv_sec), 60.0)
            );
    log_line(log_buffer, LOG_ALWAYS);
}
Example #28
0
/*
 * db_delete --
 *	Delete a line from the file.
 *
 * PUBLIC: int db_delete(SCR *, recno_t);
 */
int
db_delete(
	SCR *sp,
	recno_t lno)
{
	DBT key;
	EXF *ep;

#if defined(DEBUG) && 0
	TRACE(sp, "delete line %lu\n", (u_long)lno);
#endif
	/* Check for no underlying file. */
	if ((ep = sp->ep) == NULL) {
		ex_emsg(sp, NULL, EXM_NOFILEYET);
		return (1);
	}
		
	/* Update marks, @ and global commands. */
	if (mark_insdel(sp, LINE_DELETE, lno))
		return (1);
	if (ex_g_insdel(sp, LINE_DELETE, lno))
		return (1);

	/* Log change. */
	log_line(sp, lno, LOG_LINE_DELETE);

	/* Update file. */
	key.data = &lno;
	key.size = sizeof(lno);
	if (ep->db->del(ep->db, &key, 0) == 1) {
		msgq(sp, M_SYSERR,
		    "003|unable to delete line %lu", (u_long)lno);
		return (1);
	}

	/* Flush the cache, update line count, before screen update. */
	if (lno <= ep->c_lno)
		ep->c_lno = OOBLNO;
	if (ep->c_nlines != OOBLNO)
		--ep->c_nlines;

	/* File now modified. */
	if (F_ISSET(ep, F_FIRSTMODIFY))
		(void)rcv_init(sp);
	F_SET(ep, F_MODIFIED);

	/* Update screen. */
	return (scr_update(sp, lno, LINE_DELETE, 1));
}
Example #29
0
void log_msg(const int priority, const char *fmt, ...)
{
	char DebugBuffer[DEBUG_BUF_SIZE];
	va_list argptr;

	if ((priority < LogLevel) /* log priority lower than threshold? */
		|| (DEBUGLOG_NO_DEBUG == LogMsgType))
		return;

	va_start(argptr, fmt);
	vsnprintf(DebugBuffer, sizeof DebugBuffer, fmt, argptr);
	va_end(argptr);

	log_line(priority, DebugBuffer);
} /* log_msg */
Example #30
0
static bool test_native_get(struct ConfigSet *cs, struct Buffer *err)
{
  log_line(__func__);
  const char *name = "Kumquat";

  if (!TEST_CHECK(cs_str_string_set(cs, name, "*****@*****.**", err) != INT_MIN))
    return false;

  mutt_buffer_reset(err);
  intptr_t value = cs_str_native_get(cs, name, err);
  struct Address *a = (struct Address *) value;

  if (!TEST_CHECK(VarKumquat == a))
  {
    TEST_MSG("Get failed: %s\n", err->data);
    return false;
  }
  char *addr1 = VarKumquat ? VarKumquat->mailbox : NULL;
  char *addr2 = a ? a->mailbox : NULL;
  TEST_MSG("%s = '%s', '%s'\n", name, NONULL(addr1), NONULL(addr2));

  log_line(__func__);
  return true;
}