Exemplo n.º 1
0
int main (int argc, char *argv[])
{
  /* variable declarations */
  int ArgIdx;
  int CanSwitchFileMode;
  int ShouldExit;
  int RetVal = 0;
  CFlag *pFlag;
  char *ptr;
#ifdef ENABLE_NLS
  char localedir[1024];

   ptr = getenv("DOS2UNIX_LOCALEDIR");
   if (ptr == NULL)
      strcpy(localedir,LOCALEDIR);
   else
   {
      if (strlen(ptr) < sizeof(localedir))
         strcpy(localedir,ptr);
      else
      {
         fprintf(stderr,_("unix2dos: error: Value of environment variable UNIX2DOS_LOCALEDIR is too long.\n"));
         strcpy(localedir,LOCALEDIR);
      }
   }

   setlocale (LC_ALL, "");
   bindtextdomain (PACKAGE, localedir);
   textdomain (PACKAGE);
#endif


  /* variable initialisations */
  ArgIdx = 0;
  CanSwitchFileMode = 1;
  ShouldExit = 0;
  pFlag = (CFlag*)malloc(sizeof(CFlag));  
  pFlag->NewFile = 0;
  pFlag->Quiet = 0;
  pFlag->KeepDate = 0;
  pFlag->ConvMode = 0;
  pFlag->NewLine = 0;
  pFlag->Force = 0;
  pFlag->status = 0;

  if ( ((ptr=strrchr(argv[0],'/')) == NULL) && ((ptr=strrchr(argv[0],'\\')) == NULL) )
    ptr = argv[0];
  else
    ptr++;

  if ((strcmpi("unix2mac", ptr) == 0) || (strcmpi("unix2mac.exe", ptr) == 0))
    pFlag->ConvMode = 3;

  /* no option, use stdin and stdout */
  if (argc == 1)
  {
    exit(ConvertUnixToDosStdio(pFlag));
  }

  while ((++ArgIdx < argc) && (!ShouldExit))
  {
    /* is it an option? */
    if (argv[ArgIdx][0] == '-')
    {
      /* an option */
      if ((strcmp(argv[ArgIdx],"-h") == 0) || (strcmp(argv[ArgIdx],"--help") == 0))
        PrintUsage();
      if ((strcmp(argv[ArgIdx],"-k") == 0) || (strcmp(argv[ArgIdx],"--keepdate") == 0))
        pFlag->KeepDate = 1;
      if ((strcmp(argv[ArgIdx],"-f") == 0) || (strcmp(argv[ArgIdx],"--force") == 0))
        pFlag->Force = 1;
      if ((strcmp(argv[ArgIdx],"-q") == 0) || (strcmp(argv[ArgIdx],"--quiet") == 0))
        pFlag->Quiet = 1;
      if ((strcmp(argv[ArgIdx],"-l") == 0) || (strcmp(argv[ArgIdx],"--newline") == 0))
        pFlag->NewLine = 1;
      if ((strcmp(argv[ArgIdx],"-V") == 0) || (strcmp(argv[ArgIdx],"--version") == 0))
      {
        PrintVersion();
#ifdef ENABLE_NLS
        PrintLocaledir(localedir);
#endif
      }
      if ((strcmp(argv[ArgIdx],"-L") == 0) || (strcmp(argv[ArgIdx],"--license") == 0))
        PrintLicense();

      if ((strcmp(argv[ArgIdx],"-c") == 0) || (strcmp(argv[ArgIdx],"--convmode") == 0))
      {
        if (++ArgIdx < argc)
        {
          if (strcmpi(argv[ArgIdx],"ascii") == 0)
            pFlag->ConvMode = 0;
          else if (strcmpi(argv[ArgIdx], "7bit") == 0)
            pFlag->ConvMode = 1;
          else if (strcmpi(argv[ArgIdx], "iso") == 0)
            pFlag->ConvMode = 2;
          else if (strcmpi(argv[ArgIdx], "mac") == 0)
            pFlag->ConvMode = 3;
          else
          {
            if (!pFlag->Quiet)
              fprintf(stderr, _("unix2dos: invalid %s conversion mode specified\n"),argv[ArgIdx]);
            ShouldExit = 1;
          }
        }
        else
        {
          ArgIdx--;
          if (!pFlag->Quiet)
            fprintf(stderr,_("unix2dos: option '%s' requires an argument\n"),argv[ArgIdx]);
          ShouldExit = 1;
        }
      }

      if ((strcmp(argv[ArgIdx],"-o") == 0) || (strcmp(argv[ArgIdx],"--oldfile") == 0))
      {
        /* last convert not paired */
        if (!CanSwitchFileMode)
        {
          if (!pFlag->Quiet)
            fprintf(stderr, _("unix2dos: target of file %s not specified in new file mode\n"), argv[ArgIdx-1]);
          ShouldExit = 1;
        }
        pFlag->NewFile = 0;
      }

      if ((strcmp(argv[ArgIdx],"-n") == 0) || (strcmp(argv[ArgIdx],"--newfile") == 0))
      {
        /* last convert not paired */
        if (!CanSwitchFileMode)
        {
          if (!pFlag->Quiet)
            fprintf(stderr, _("unix2dos: target of file %s not specified in new file mode\n"), argv[ArgIdx-1]);
          ShouldExit = 1;
        }
        pFlag->NewFile = 1;
      }
    }
    else
    {
      /* not an option */
      if (pFlag->NewFile)
      {
        if (CanSwitchFileMode)
          CanSwitchFileMode = 0;
        else
        {
          RetVal = ConvertUnixToDosNewFile(argv[ArgIdx-1], argv[ArgIdx], pFlag);
          if (pFlag->status & NO_REGFILE)
          {
            if (!pFlag->Quiet)
              fprintf(stderr, _("unix2dos: Skipping %s, not a regular file.\n"), argv[ArgIdx-1]);
          } else if (pFlag->status & BINARY_FILE)
          {
            if (!pFlag->Quiet)
              fprintf(stderr, _("unix2dos: Skipping binary file %s\n"), argv[ArgIdx-1]);
          } else {
            if (!pFlag->Quiet)
            {
              if (pFlag->ConvMode == 3)
                fprintf(stderr, _("unix2dos: converting file %s to file %s in MAC format ...\n"), argv[ArgIdx-1], argv[ArgIdx]);
              else
                fprintf(stderr, _("unix2dos: converting file %s to file %s in DOS format ...\n"), argv[ArgIdx-1], argv[ArgIdx]);
            }
            if (RetVal)
            {
              if (!pFlag->Quiet)
                fprintf(stderr, _("unix2dos: problems converting file %s to file %s\n"), argv[ArgIdx-1], argv[ArgIdx]);
              ShouldExit = 1;
            }
          }
          CanSwitchFileMode = 1;
        }
      }
      else
      {
        RetVal = ConvertUnixToDosOldFile(argv[ArgIdx], pFlag);
        if (pFlag->status & NO_REGFILE)
        {
          if (!pFlag->Quiet)
            fprintf(stderr, _("unix2dos: Skipping %s, not a regular file.\n"), argv[ArgIdx]);
        } else if (pFlag->status & BINARY_FILE)
        {
          if (!pFlag->Quiet)
            fprintf(stderr, _("unix2dos: Skipping binary file %s\n"), argv[ArgIdx]);
        } else {
          if (!pFlag->Quiet)
          {
            if (pFlag->ConvMode == 3)
              fprintf(stderr, _("unix2dos: converting file %s to MAC format ...\n"), argv[ArgIdx]);
            else
              fprintf(stderr, _("unix2dos: converting file %s to DOS format ...\n"), argv[ArgIdx]);
          }
          if (RetVal)
          {
            if (!pFlag->Quiet)
              fprintf(stderr, _("unix2dos: problems converting file %s\n"), argv[ArgIdx]);
            ShouldExit = 1;
          }
        }
      }
    }
  }

  if ((!pFlag->Quiet) && (!CanSwitchFileMode))
  {
    fprintf(stderr, _("unix2dos: target of file %s not specified in new file mode\n"), argv[ArgIdx-1]);
    ShouldExit = 1;
  }
  free(pFlag);
  return (ShouldExit);
}
Exemplo n.º 2
0
int main(int argc, char *argv[]){
	int result, offset_result, jitter_result;
	double offset=0, jitter=0;
	char *result_line, *perfdata_line;

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	result = offset_result = jitter_result = STATE_OK;

	/* Parse extra opts if any */
	argv=np_extra_opts (&argc, argv, progname);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	set_thresholds(&offset_thresholds, owarn, ocrit);
	set_thresholds(&jitter_thresholds, jwarn, jcrit);

	/* initialize alarm signal handling */
	signal (SIGALRM, socket_timeout_alarm_handler);

	/* set socket timeout */
	alarm (socket_timeout);

	offset = offset_request(server_address, &offset_result);
	/* check_ntp used to always return CRITICAL if offset_result == STATE_UNKNOWN.
	 * Now we'll only do that is the offset thresholds were set */
	if (do_offset && offset_result == STATE_UNKNOWN) {
		result = STATE_CRITICAL;
	} else {
		result = get_status(fabs(offset), offset_thresholds);
	}

	/* If not told to check the jitter, we don't even send packets.
	 * jitter is checked using NTP control packets, which not all
	 * servers recognize.  Trying to check the jitter on OpenNTPD
	 * (for example) will result in an error
	 */
	if(do_jitter){
		jitter=jitter_request(server_address, &jitter_result);
		result = max_state_alt(result, get_status(jitter, jitter_thresholds));
		/* -1 indicates that we couldn't calculate the jitter
		 * Only overrides STATE_OK from the offset */
		if(jitter == -1.0 && result == STATE_OK)
			result = STATE_UNKNOWN;
	}
	result = max_state_alt(result, jitter_result);

	switch (result) {
		case STATE_CRITICAL :
			xasprintf(&result_line, _("NTP CRITICAL:"));
			break;
		case STATE_WARNING :
			xasprintf(&result_line, _("NTP WARNING:"));
			break;
		case STATE_OK :
			xasprintf(&result_line, _("NTP OK:"));
			break;
		default :
			xasprintf(&result_line, _("NTP UNKNOWN:"));
			break;
	}
	if(offset_result == STATE_UNKNOWN){
		xasprintf(&result_line, "%s %s", result_line, _("Offset unknown"));
		xasprintf(&perfdata_line, "");
	} else {
		xasprintf(&result_line, "%s %s %.10g secs", result_line, _("Offset"), offset);
		xasprintf(&perfdata_line, "%s", perfd_offset(offset));
	}
	if (do_jitter) {
		xasprintf(&result_line, "%s, jitter=%f", result_line, jitter);
		xasprintf(&perfdata_line, "%s %s", perfdata_line,  perfd_jitter(jitter));
	}
	printf("%s|%s\n", result_line, perfdata_line);

	if(server_address!=NULL) free(server_address);
	return result;
}
Exemplo n.º 3
0
int main(int argc, char **argv)
{
	int c;
	int cnt;
	char *childArgv[10];
	char *buff;
	int childArgc = 0;
	int retcode;

	char *pwdbuf = NULL;
	struct passwd *pwd = NULL, _pwd;

	struct login_context cxt = {
		.tty_mode = TTY_MODE,		/* tty chmod() */
		.pid = getpid(),		/* PID */
		.conv = { misc_conv, NULL }	/* PAM conversation function */
	};

	timeout = (unsigned int)getlogindefs_num("LOGIN_TIMEOUT", LOGIN_TIMEOUT);

	signal(SIGALRM, timedout);
	siginterrupt(SIGALRM, 1);	/* we have to interrupt syscalls like ioclt() */
	alarm(timeout);
	signal(SIGQUIT, SIG_IGN);
	signal(SIGINT, SIG_IGN);

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);

	setpriority(PRIO_PROCESS, 0, 0);
	initproctitle(argc, argv);

	/*
	 * -p is used by getty to tell login not to destroy the environment
	 * -f is used to skip a second login authentication
	 * -h is used by other servers to pass the name of the remote
	 *    host to login so that it may be placed in utmp and wtmp
	 */
	while ((c = getopt(argc, argv, "fHh:pV")) != -1)
		switch (c) {
		case 'f':
			cxt.noauth = 1;
			break;

		case 'H':
			cxt.nohost = 1;
			break;

		case 'h':
			if (getuid()) {
				fprintf(stderr,
					_("login: -h for super-user only.\n"));
				exit(EXIT_FAILURE);
			}
			init_remote_info(&cxt, optarg);
			break;

		case 'p':
			cxt.keep_env = 1;
			break;

		case 'V':
			printf(UTIL_LINUX_VERSION);
			return EXIT_SUCCESS;
		case '?':
		default:
			fprintf(stderr, _("usage: login [ -p ] [ -h host ] [ -H ] [ -f username | username ]\n"));
			exit(EXIT_FAILURE);
		}
	argc -= optind;
	argv += optind;

	if (*argv) {
		char *p = *argv;
		cxt.username = xstrdup(p);

		/* wipe name - some people mistype their password here */
		/* (of course we are too late, but perhaps this helps a little ..) */
		while (*p)
			*p++ = ' ';
	}

	for (cnt = get_fd_tabsize() - 1; cnt > 2; cnt--)
		close(cnt);

	setpgrp();	 /* set pgid to pid this means that setsid() will fail */

	openlog("login", LOG_ODELAY, LOG_AUTHPRIV);

	init_tty(&cxt);
	init_loginpam(&cxt);

	/* login -f, then the user has already been authenticated */
	cxt.noauth = cxt.noauth && getuid() == 0 ? 1 : 0;

	if (!cxt.noauth)
		loginpam_auth(&cxt);

	/*
	 * Authentication may be skipped (for example, during krlogin, rlogin,
	 * etc...), but it doesn't mean that we can skip other account checks.
	 * The account could be disabled or password expired (although
	 * kerberos ticket is valid).         -- [email protected] (22-Feb-2006)
	 */
	loginpam_acct(&cxt);

	if (!(cxt.pwd = get_passwd_entry(cxt.username, &pwdbuf, &_pwd))) {
		warnx(_("\nSession setup problem, abort."));
		syslog(LOG_ERR, _("Invalid user name \"%s\" in %s:%d. Abort."),
		       cxt.username, __FUNCTION__, __LINE__);
		pam_end(cxt.pamh, PAM_SYSTEM_ERR);
		sleepexit(EXIT_FAILURE);
	}

	pwd = cxt.pwd;
	cxt.username = pwd->pw_name;

	/*
	 * Initialize the supplementary group list. This should be done before
	 * pam_setcred because the PAM modules might add groups during
	 * pam_setcred.
	 *
         * For root we don't call initgroups, instead we call setgroups with
	 * group 0. This avoids the need to step through the whole group file,
	 * which can cause problems if NIS, NIS+, LDAP or something similar
	 * is used and the machine has network problems.
	 */
	retcode = pwd->pw_uid ? initgroups(cxt.username, pwd->pw_gid) :	/* user */
			        setgroups(0, NULL);			/* root */
	if (retcode < 0) {
		syslog(LOG_ERR, _("groups initialization failed: %m"));
		warnx(_("\nSession setup problem, abort."));
		pam_end(cxt.pamh, PAM_SYSTEM_ERR);
		sleepexit(EXIT_FAILURE);
	}

	/*
	 * Open PAM session (after successful authentication and account check)
	 */
	loginpam_session(&cxt);

	/* committed to login -- turn off timeout */
	alarm((unsigned int)0);

	endpwent();

	cxt.quiet = get_hushlogin_status(pwd);

	log_utmp(&cxt);
	log_audit(&cxt, 1);
	log_lastlog(&cxt);

	chown_tty(&cxt);

	if (setgid(pwd->pw_gid) < 0 && pwd->pw_gid) {
		syslog(LOG_ALERT, _("setgid() failed"));
		exit(EXIT_FAILURE);
	}

	if (pwd->pw_shell == NULL || *pwd->pw_shell == '\0')
		pwd->pw_shell = _PATH_BSHELL;

	init_environ(&cxt);		/* init $HOME, $TERM ... */

	setproctitle("login", cxt.username);

	log_syslog(&cxt);

	if (!cxt.quiet) {
		motd();

#ifdef LOGIN_STAT_MAIL
		/*
		 * This turns out to be a bad idea: when the mail spool
		 * is NFS mounted, and the NFS connection hangs, the
		 * login hangs, even root cannot login.
		 * Checking for mail should be done from the shell.
		 */
		{
			struct stat st;
			char *mail;

			mail = getenv("MAIL");
			if (mail && stat(mail, &st) == 0 && st.st_size != 0) {
				if (st.st_mtime > st.st_atime)
					printf(_("You have new mail.\n"));
				else
					printf(_("You have mail.\n"));
			}
		}
#endif
	}

	/*
	 * Detach the controlling terminal, fork() and create, new session
	 * and reinilizalize syslog stuff.
	 */
	fork_session(&cxt);

	/* discard permissions last so can't get killed and drop core */
	if (setuid(pwd->pw_uid) < 0 && pwd->pw_uid) {
		syslog(LOG_ALERT, _("setuid() failed"));
		exit(EXIT_FAILURE);
	}

	/* wait until here to change directory! */
	if (chdir(pwd->pw_dir) < 0) {
		warn(_("%s: change directory failed"), pwd->pw_dir);

		if (!getlogindefs_bool("DEFAULT_HOME", 1))
			exit(0);
		if (chdir("/"))
			exit(EXIT_FAILURE);
		pwd->pw_dir = "/";
		printf(_("Logging in with home = \"/\".\n"));
	}

	/* if the shell field has a space: treat it like a shell script */
	if (strchr(pwd->pw_shell, ' ')) {
		buff = xmalloc(strlen(pwd->pw_shell) + 6);

		strcpy(buff, "exec ");
		strcat(buff, pwd->pw_shell);
		childArgv[childArgc++] = "/bin/sh";
		childArgv[childArgc++] = "-sh";
		childArgv[childArgc++] = "-c";
		childArgv[childArgc++] = buff;
	} else {
		char tbuf[PATH_MAX + 2], *p;

		tbuf[0] = '-';
		xstrncpy(tbuf + 1, ((p = strrchr(pwd->pw_shell, '/')) ?
				    p + 1 : pwd->pw_shell), sizeof(tbuf) - 1);

		childArgv[childArgc++] = pwd->pw_shell;
		childArgv[childArgc++] = xstrdup(tbuf);
	}

	childArgv[childArgc++] = NULL;

	execvp(childArgv[0], childArgv + 1);

	if (!strcmp(childArgv[0], "/bin/sh"))
		warn(_("couldn't exec shell script"));
	else
		warn(_("no shell"));

	exit(EXIT_SUCCESS);
}
Exemplo n.º 4
0
void __attribute__((constructor)) swh_init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	ringmod_2i1oDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (ringmod_2i1oDescriptor) {
		ringmod_2i1oDescriptor->UniqueID = 1188;
		ringmod_2i1oDescriptor->Label = "ringmod_2i1o";
		ringmod_2i1oDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		ringmod_2i1oDescriptor->Name =
		 D_("Ringmod with two inputs");
		ringmod_2i1oDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		ringmod_2i1oDescriptor->Copyright =
		 "GPL";
		ringmod_2i1oDescriptor->PortCount = 4;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(4,
		 sizeof(LADSPA_PortDescriptor));
		ringmod_2i1oDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(4,
		 sizeof(LADSPA_PortRangeHint));
		ringmod_2i1oDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(4, sizeof(char*));
		ringmod_2i1oDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Modulation depth (0=none, 1=AM, 2=RM) */
		port_descriptors[RINGMOD_2I1O_DEPTH] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_2I1O_DEPTH] =
		 D_("Modulation depth (0=none, 1=AM, 2=RM)");
		port_range_hints[RINGMOD_2I1O_DEPTH].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_2I1O_DEPTH].LowerBound = 0;
		port_range_hints[RINGMOD_2I1O_DEPTH].UpperBound = 2;

		/* Parameters for Input */
		port_descriptors[RINGMOD_2I1O_INPUT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[RINGMOD_2I1O_INPUT] =
		 D_("Input");
		port_range_hints[RINGMOD_2I1O_INPUT].HintDescriptor = 0;

		/* Parameters for Modulator */
		port_descriptors[RINGMOD_2I1O_MODULATOR] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[RINGMOD_2I1O_MODULATOR] =
		 D_("Modulator");
		port_range_hints[RINGMOD_2I1O_MODULATOR].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_2I1O_MODULATOR].LowerBound = -1;
		port_range_hints[RINGMOD_2I1O_MODULATOR].UpperBound = +1;

		/* Parameters for Output */
		port_descriptors[RINGMOD_2I1O_OUTPUT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[RINGMOD_2I1O_OUTPUT] =
		 D_("Output");
		port_range_hints[RINGMOD_2I1O_OUTPUT].HintDescriptor = 0;

		ringmod_2i1oDescriptor->activate = NULL;
		ringmod_2i1oDescriptor->cleanup = cleanupRingmod_2i1o;
		ringmod_2i1oDescriptor->connect_port = connectPortRingmod_2i1o;
		ringmod_2i1oDescriptor->deactivate = NULL;
		ringmod_2i1oDescriptor->instantiate = instantiateRingmod_2i1o;
		ringmod_2i1oDescriptor->run = runRingmod_2i1o;
		ringmod_2i1oDescriptor->run_adding = runAddingRingmod_2i1o;
		ringmod_2i1oDescriptor->set_run_adding_gain = setRunAddingGainRingmod_2i1o;
	}

	ringmod_1i1o1lDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (ringmod_1i1o1lDescriptor) {
		ringmod_1i1o1lDescriptor->UniqueID = 1189;
		ringmod_1i1o1lDescriptor->Label = "ringmod_1i1o1l";
		ringmod_1i1o1lDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		ringmod_1i1o1lDescriptor->Name =
		 D_("Ringmod with LFO");
		ringmod_1i1o1lDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		ringmod_1i1o1lDescriptor->Copyright =
		 "GPL";
		ringmod_1i1o1lDescriptor->PortCount = 8;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(8,
		 sizeof(LADSPA_PortDescriptor));
		ringmod_1i1o1lDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(8,
		 sizeof(LADSPA_PortRangeHint));
		ringmod_1i1o1lDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(8, sizeof(char*));
		ringmod_1i1o1lDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Modulation depth (0=none, 1=AM, 2=RM) */
		port_descriptors[RINGMOD_1I1O1L_DEPTHP] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_DEPTHP] =
		 D_("Modulation depth (0=none, 1=AM, 2=RM)");
		port_range_hints[RINGMOD_1I1O1L_DEPTHP].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_1I1O1L_DEPTHP].LowerBound = 0;
		port_range_hints[RINGMOD_1I1O1L_DEPTHP].UpperBound = 2;

		/* Parameters for Frequency (Hz) */
		port_descriptors[RINGMOD_1I1O1L_FREQ] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_FREQ] =
		 D_("Frequency (Hz)");
		port_range_hints[RINGMOD_1I1O1L_FREQ].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_440;
		port_range_hints[RINGMOD_1I1O1L_FREQ].LowerBound = 1;
		port_range_hints[RINGMOD_1I1O1L_FREQ].UpperBound = 1000;

		/* Parameters for Sine level */
		port_descriptors[RINGMOD_1I1O1L_SIN] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_SIN] =
		 D_("Sine level");
		port_range_hints[RINGMOD_1I1O1L_SIN].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1;
		port_range_hints[RINGMOD_1I1O1L_SIN].LowerBound = -1;
		port_range_hints[RINGMOD_1I1O1L_SIN].UpperBound = +1;

		/* Parameters for Triangle level */
		port_descriptors[RINGMOD_1I1O1L_TRI] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_TRI] =
		 D_("Triangle level");
		port_range_hints[RINGMOD_1I1O1L_TRI].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_1I1O1L_TRI].LowerBound = -1;
		port_range_hints[RINGMOD_1I1O1L_TRI].UpperBound = +1;

		/* Parameters for Sawtooth level */
		port_descriptors[RINGMOD_1I1O1L_SAW] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_SAW] =
		 D_("Sawtooth level");
		port_range_hints[RINGMOD_1I1O1L_SAW].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_1I1O1L_SAW].LowerBound = -1;
		port_range_hints[RINGMOD_1I1O1L_SAW].UpperBound = +1;

		/* Parameters for Square level */
		port_descriptors[RINGMOD_1I1O1L_SQU] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[RINGMOD_1I1O1L_SQU] =
		 D_("Square level");
		port_range_hints[RINGMOD_1I1O1L_SQU].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[RINGMOD_1I1O1L_SQU].LowerBound = -1;
		port_range_hints[RINGMOD_1I1O1L_SQU].UpperBound = +1;

		/* Parameters for Input */
		port_descriptors[RINGMOD_1I1O1L_INPUT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[RINGMOD_1I1O1L_INPUT] =
		 D_("Input");
		port_range_hints[RINGMOD_1I1O1L_INPUT].HintDescriptor = 0;

		/* Parameters for Output */
		port_descriptors[RINGMOD_1I1O1L_OUTPUT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[RINGMOD_1I1O1L_OUTPUT] =
		 D_("Output");
		port_range_hints[RINGMOD_1I1O1L_OUTPUT].HintDescriptor = 0;

		ringmod_1i1o1lDescriptor->activate = activateRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->cleanup = cleanupRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->connect_port = connectPortRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->deactivate = NULL;
		ringmod_1i1o1lDescriptor->instantiate = instantiateRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->run = runRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->run_adding = runAddingRingmod_1i1o1l;
		ringmod_1i1o1lDescriptor->set_run_adding_gain = setRunAddingGainRingmod_1i1o1l;
	}
}
Exemplo n.º 5
0
int main(int argc, char **argv)
{
	struct mcookie_control ctl = { .verbose = 0 };
	size_t i;
	unsigned char digest[MD5LENGTH];
	unsigned char buf[RAND_BYTES];
	int c;

	static const struct option longopts[] = {
		{"file", required_argument, NULL, 'f'},
		{"max-size", required_argument, NULL, 'm'},
		{"verbose", no_argument, NULL, 'v'},
		{"version", no_argument, NULL, 'V'},
		{"help", no_argument, NULL, 'h'},
		{NULL, 0, NULL, 0}
	};

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	if (2 < argc)
		ctl.files = xmalloc(sizeof(char *) * argc);

	while ((c = getopt_long(argc, argv, "f:m:vVh", longopts, NULL)) != -1) {
		switch (c) {
		case 'v':
			ctl.verbose = 1;
			break;
		case 'f':
			ctl.files[ctl.nfiles++] = optarg;
			break;
		case 'm':
			ctl.maxsz = strtosize_or_err(optarg,
						     _("failed to parse length"));
			break;
		case 'V':
			printf(UTIL_LINUX_VERSION);
			return EXIT_SUCCESS;
		case 'h':
			usage(stdout);
		default:
			usage(stderr);
		}
	}

	if (ctl.maxsz && ctl.nfiles == 0)
		warnx(_("--max-size ignored when used without --file."));

	randomness_from_files(&ctl);
	free(ctl.files);

	random_get_bytes(&buf, RAND_BYTES);
	MD5Update(&ctl.ctx, buf, RAND_BYTES);
	if (ctl.verbose)
		fprintf(stderr, _("Got %d bytes from %s\n"), RAND_BYTES,
				random_tell_source());

	MD5Final(digest, &ctl.ctx);
	for (i = 0; i < MD5LENGTH; i++)
		printf("%02x", digest[i]);
	putchar('\n');

	return EXIT_SUCCESS;
}
Exemplo n.º 6
0
int main(int argc, char *arg[])
{
  bindtextdomain(GETTEXT_PACKAGE, DARKTABLE_LOCALEDIR);
  bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
  textdomain(GETTEXT_PACKAGE);

  gtk_init_check(&argc, &arg);

  // parse command line arguments
  dt_mipmap_size_t min_mip = DT_MIPMAP_0;
  dt_mipmap_size_t max_mip = DT_MIPMAP_2;
  int32_t min_imgid = 0;
  int32_t max_imgid = INT32_MAX;

  int k;
  for(k = 1; k < argc; k++)
  {
    if(!strcmp(arg[k], "-h") || !strcmp(arg[k], "--help"))
    {
      usage(arg[0]);
      exit(EXIT_FAILURE);
    }
    else if(!strcmp(arg[k], "--version"))
    {
      printf("this is darktable-generate-cache\ncopyright (c) 2014 johannes hanika; 2015 LebedevRI\n");
      exit(EXIT_FAILURE);
    }
    else if((!strcmp(arg[k], "-m") || !strcmp(arg[k], "--max-mip")) && argc > k + 1)
    {
      k++;
      max_mip = (dt_mipmap_size_t)MIN(MAX(atoi(arg[k]), 0), 7);
    }
    else if(!strcmp(arg[k], "--min-mip") && argc > k + 1)
    {
      k++;
      min_mip = (dt_mipmap_size_t)MIN(MAX(atoi(arg[k]), 0), 7);
    }
    else if(!strcmp(arg[k], "--min-imgid") && argc > k + 1)
    {
      k++;
      min_imgid = (int32_t)MIN(MAX(atoi(arg[k]), 0), INT32_MAX);
    }
    else if(!strcmp(arg[k], "--max-imgid") && argc > k + 1)
    {
      k++;
      max_imgid = (int32_t)MIN(MAX(atoi(arg[k]), 0), INT32_MAX);
    }
    else if(!strcmp(arg[k], "--core"))
    {
      // everything from here on should be passed to the core
      k++;
      break;
    }
  }

  int m_argc = 0;
  char **m_arg = malloc((3 + argc - k) * sizeof(char *));
  m_arg[m_argc++] = "darktable-generate-cache";
  m_arg[m_argc++] = "--conf";
  m_arg[m_argc++] = "write_sidecar_files=FALSE";
  for(; k < argc; k++) m_arg[m_argc++] = arg[k];
  m_arg[m_argc] = NULL;

  // init dt without gui:
  if(dt_init(m_argc, m_arg, 0, NULL))
  {
    free(m_arg);
    exit(EXIT_FAILURE);
  }

  if(!dt_conf_get_bool("cache_disk_backend"))
  {
    fprintf(stderr,
            _("warning: disk backend for thumbnail cache is disabled (cache_disk_backend)\nif you want "
              "to pre-generate thumbnails and for darktable to use them, you need to enable disk backend "
              "for thumbnail cache\nno thumbnails to be generated, done."));
    dt_cleanup();
    free(m_arg);
    exit(EXIT_FAILURE);
  }

  if(min_mip > max_mip)
  {
    fprintf(stderr, _("error: ensure that min_mip <= max_mip\n"));
    free(m_arg);
    exit(EXIT_FAILURE);
  }

  fprintf(stderr, _("creating complete lighttable thumbnail cache\n"));

  if(generate_thumbnail_cache(min_mip, max_mip, min_imgid, max_imgid))
  {
    free(m_arg);
    exit(EXIT_FAILURE);
  }

  dt_cleanup();

  free(m_arg);
}
Exemplo n.º 7
0
int
main(int argc, char **argv) {
	int ch;
	struct iovec iov;
	struct utmp *utmpptr;
	char *p;
	char line[sizeof(utmpptr->ut_line) + 1];
	int print_banner = TRUE;
	char *mbuf;
	size_t mbufsize;
	unsigned timeout = WRITE_TIME_OUT;

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	static const struct option longopts[] = {
		{ "nobanner",	no_argument,		0, 'n' },
		{ "timeout",	required_argument,	0, 't' },
		{ "version",	no_argument,		0, 'V' },
		{ "help",	no_argument,		0, 'h' },
		{ NULL,	0, 0, 0 }
	};

	while ((ch = getopt_long(argc, argv, "nt:Vh", longopts, NULL)) != -1) {
		switch (ch) {
		case 'n':
			if (geteuid() == 0)
				print_banner = FALSE;
			else
				warnx(_("--nobanner is available only for root"));
			break;
		case 't':
			timeout = strtou32_or_err(optarg, _("invalid timeout argument"));
			if (timeout < 1)
				errx(EXIT_FAILURE, _("invalid timeout argument: %s"), optarg);
			break;
		case 'V':
			printf(_("%s from %s\n"), program_invocation_short_name,
						  PACKAGE_STRING);
			exit(EXIT_SUCCESS);
		case 'h':
			usage(stdout);
		default:
			usage(stderr);
		}
	}
	argc -= optind;
	argv += optind;
	if (argc > 1)
		usage(stderr);

	mbuf = makemsg(*argv, &mbufsize, print_banner);

	iov.iov_base = mbuf;
	iov.iov_len = mbufsize;
	while((utmpptr = getutent())) {
		if (!utmpptr->ut_name[0] ||
		    !strncmp(utmpptr->ut_name, IGNOREUSER,
			     sizeof(utmpptr->ut_name)))
			continue;
#ifdef USER_PROCESS
		if (utmpptr->ut_type != USER_PROCESS)
			continue;
#endif

		/* Joey Hess reports that use-sessreg in /etc/X11/wdm/
		   produces ut_line entries like :0, and a write
		   to /dev/:0 fails. */
		if (utmpptr->ut_line[0] == ':')
			continue;

		xstrncpy(line, utmpptr->ut_line, sizeof(utmpptr->ut_line));
		if ((p = ttymsg(&iov, 1, line, timeout)) != NULL)
			warnx("%s", p);
	}
	endutent();
	free(mbuf);
	exit(EXIT_SUCCESS);
}
Exemplo n.º 8
0
int
main (int argc, char *argv[])
{
        GConfClient              *gc;
        GtkWidget                *dialog;
        NcbSelection             *selection;
        NcbSelectionDialogSource  source_type;
        char                     *source_name;
        char                     *last_device;
        static char              *source_device;
        static char              *source_iso;
        static char              *source_cue;
        GOptionContext           *context;
        GnomeProgram             *program;
        static const GOptionEntry options []  = {
                { "source-device", 0, 0, G_OPTION_ARG_FILENAME, &source_device,
                  N_("Use CD/DVD device as source instead of burn:///"), N_("DEVICE") },
                { "source-iso", 0, 0, G_OPTION_ARG_FILENAME, &source_iso,
                  N_("Use ISO image as source instead of burn:///"), N_("FILENAME") },
                { "source-cue", 0, 0, G_OPTION_ARG_FILENAME, &source_cue,
                  N_("Use CUE/TOC file as source instead of burn:///"), N_("FILENAME") },
                { NULL}
        };

        bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);

        context = g_option_context_new (NULL);

        g_option_context_add_main_entries (context, options, GETTEXT_PACKAGE);

        program = gnome_program_init ("nautilus-cd-burner", VERSION,
                                      LIBGNOMEUI_MODULE, argc, argv,
                                      GNOME_PARAM_GOPTION_CONTEXT, context,
                                      GNOME_PARAM_APP_DATADIR, SHAREDIR,
                                      GNOME_PARAM_NONE);

        nautilus_burn_init ();

        dialog = ncb_selection_dialog_new ();
        g_signal_connect (dialog, "response", G_CALLBACK (selection_dialog_response), NULL);
        gtk_widget_show (dialog);

        if (source_iso != NULL) {
                char *path;

                path = expand_path_input (source_iso);
                if (path == NULL) {
                        goto out;
                }

                source_type = NCB_SELECTION_DIALOG_SOURCE_ISO;
                source_name = path;
        } else if (source_cue != NULL) {
                char *path;

                path = expand_path_input (source_cue);
                if (path == NULL) {
                        goto out;
                }

                source_type = NCB_SELECTION_DIALOG_SOURCE_CUE;
                source_name = path;
        } else if (source_device != NULL) {
                source_type = NCB_SELECTION_DIALOG_SOURCE_DEVICE;
                source_name = g_strdup (source_device);
        } else {
                source_type = NCB_SELECTION_DIALOG_SOURCE_BURN_FOLDER;
                source_name = NULL;
        }

        selection = ncb_selection_dialog_get_selection (NCB_SELECTION_DIALOG (dialog));
        ncb_selection_set_source (selection, source_type, source_name);

        gc = gconf_client_get_default ();
        last_device = gconf_load_device (gc);
        if (last_device != NULL) {
                NautilusBurnDrive *drive;

                drive = nautilus_burn_drive_monitor_get_drive_for_device (nautilus_burn_get_drive_monitor (),
                                                                          last_device);
                ncb_selection_set_drive (selection, drive);
                if (drive != NULL) {
                        g_object_unref (drive);
                } else {
                        g_warning ("Drive not found for saved device: %s", last_device);
                }
                g_free (last_device);
        }

        g_object_unref (selection);

        g_object_unref (gc);

        g_free (source_name);

        gtk_main ();

 out:
        g_object_unref (program);
        nautilus_burn_shutdown ();

        return 0;
}
Exemplo n.º 9
0
void _init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	surroundEncoderDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (surroundEncoderDescriptor) {
		surroundEncoderDescriptor->UniqueID = 1401;
		surroundEncoderDescriptor->Label = "surroundEncoder";
		surroundEncoderDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		surroundEncoderDescriptor->Name =
		 D_("Surround matrix encoder");
		surroundEncoderDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		surroundEncoderDescriptor->Copyright =
		 "GPL";
		surroundEncoderDescriptor->PortCount = 6;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(6,
		 sizeof(LADSPA_PortDescriptor));
		surroundEncoderDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(6,
		 sizeof(LADSPA_PortRangeHint));
		surroundEncoderDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(6, sizeof(char*));
		surroundEncoderDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for L */
		port_descriptors[SURROUNDENCODER_L] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_L] =
		 D_("L");
		port_range_hints[SURROUNDENCODER_L].HintDescriptor = 0;

		/* Parameters for R */
		port_descriptors[SURROUNDENCODER_R] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_R] =
		 D_("R");
		port_range_hints[SURROUNDENCODER_R].HintDescriptor = 0;

		/* Parameters for C */
		port_descriptors[SURROUNDENCODER_C] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_C] =
		 D_("C");
		port_range_hints[SURROUNDENCODER_C].HintDescriptor = 0;

		/* Parameters for S */
		port_descriptors[SURROUNDENCODER_S] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_S] =
		 D_("S");
		port_range_hints[SURROUNDENCODER_S].HintDescriptor = 0;

		/* Parameters for Lt */
		port_descriptors[SURROUNDENCODER_LT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_LT] =
		 D_("Lt");
		port_range_hints[SURROUNDENCODER_LT].HintDescriptor = 0;

		/* Parameters for Rt */
		port_descriptors[SURROUNDENCODER_RT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[SURROUNDENCODER_RT] =
		 D_("Rt");
		port_range_hints[SURROUNDENCODER_RT].HintDescriptor = 0;

		surroundEncoderDescriptor->activate = activateSurroundEncoder;
		surroundEncoderDescriptor->cleanup = cleanupSurroundEncoder;
		surroundEncoderDescriptor->connect_port = connectPortSurroundEncoder;
		surroundEncoderDescriptor->deactivate = NULL;
		surroundEncoderDescriptor->instantiate = instantiateSurroundEncoder;
		surroundEncoderDescriptor->run = runSurroundEncoder;
		surroundEncoderDescriptor->run_adding = runAddingSurroundEncoder;
		surroundEncoderDescriptor->set_run_adding_gain = setRunAddingGainSurroundEncoder;
	}
}
Exemplo n.º 10
0
Arquivo: zdump.c Projeto: richtr/tz
int
main(int argc, char *argv[])
{
	register int		i;
	register int		vflag;
	register int		Vflag;
	register char *		cutarg;
	register char *		cuttimes;
	register time_t		cutlotime;
	register time_t		cuthitime;
	register char **	fakeenv;
	time_t			now;
	time_t			t;
	time_t			newt;
	struct tm		tm;
	struct tm		newtm;
	register struct tm *	tmp;
	register struct tm *	newtmp;

	cutlotime = absolute_min_time;
	cuthitime = absolute_max_time;
#if HAVE_GETTEXT
	(void) setlocale(LC_ALL, "");
#ifdef TZ_DOMAINDIR
	(void) bindtextdomain(TZ_DOMAIN, TZ_DOMAINDIR);
#endif /* defined TEXTDOMAINDIR */
	(void) textdomain(TZ_DOMAIN);
#endif /* HAVE_GETTEXT */
	progname = argv[0];
	for (i = 1; i < argc; ++i)
		if (strcmp(argv[i], "--version") == 0) {
			(void) printf("zdump %s%s\n", PKGVERSION, TZVERSION);
			exit(EXIT_SUCCESS);
		} else if (strcmp(argv[i], "--help") == 0) {
			usage(stdout, EXIT_SUCCESS);
		}
	vflag = Vflag = 0;
	cutarg = cuttimes = NULL;
	for (;;)
	  switch (getopt(argc, argv, "c:t:vV")) {
	  case 'c': cutarg = optarg; break;
	  case 't': cuttimes = optarg; break;
	  case 'v': vflag = 1; break;
	  case 'V': Vflag = 1; break;
	  case -1:
	    if (! (optind == argc - 1 && strcmp(argv[optind], "=") == 0))
	      goto arg_processing_done;
	    /* Fall through.  */
	  default:
	    usage(stderr, EXIT_FAILURE);
	  }
 arg_processing_done:;

	if (vflag | Vflag) {
		intmax_t	lo;
		intmax_t	hi;
		char		dummy;
		register intmax_t cutloyear = ZDUMP_LO_YEAR;
		register intmax_t cuthiyear = ZDUMP_HI_YEAR;
		if (cutarg != NULL) {
			if (sscanf(cutarg, "%"SCNdMAX"%c", &hi, &dummy) == 1) {
				cuthiyear = hi;
			} else if (sscanf(cutarg, "%"SCNdMAX",%"SCNdMAX"%c",
				&lo, &hi, &dummy) == 2) {
					cutloyear = lo;
					cuthiyear = hi;
			} else {
(void) fprintf(stderr, _("%s: wild -c argument %s\n"),
					progname, cutarg);
				exit(EXIT_FAILURE);
			}
		}
		if (cutarg != NULL || cuttimes == NULL) {
			cutlotime = yeartot(cutloyear);
			cuthitime = yeartot(cuthiyear);
		}
		if (cuttimes != NULL) {
			if (sscanf(cuttimes, "%"SCNdMAX"%c", &hi, &dummy) == 1) {
				if (hi < cuthitime) {
					if (hi < absolute_min_time)
						hi = absolute_min_time;
					cuthitime = hi;
				}
			} else if (sscanf(cuttimes, "%"SCNdMAX",%"SCNdMAX"%c",
					  &lo, &hi, &dummy) == 2) {
				if (cutlotime < lo) {
					if (absolute_max_time < lo)
						lo = absolute_max_time;
					cutlotime = lo;
				}
				if (hi < cuthitime) {
					if (hi < absolute_min_time)
						hi = absolute_min_time;
					cuthitime = hi;
				}
			} else {
				(void) fprintf(stderr,
					_("%s: wild -t argument %s\n"),
					progname, cuttimes);
				exit(EXIT_FAILURE);
			}
		}
	}
	(void) time(&now);
	longest = 0;
	for (i = optind; i < argc; ++i)
		if (strlen(argv[i]) > longest)
			longest = strlen(argv[i]);
	{
		register int	from;
		register int	to;

		for (i = 0; environ[i] != NULL; ++i)
			continue;
		fakeenv = malloc((i + 2) * sizeof *fakeenv);
		if (fakeenv == NULL
		    || (fakeenv[0] = malloc(longest + 4)) == NULL) {
					(void) perror(progname);
					exit(EXIT_FAILURE);
		}
		to = 0;
		(void) strcpy(fakeenv[to++], "TZ=");
		for (from = 0; environ[from] != NULL; ++from)
			if (strncmp(environ[from], "TZ=", 3) != 0)
				fakeenv[to++] = environ[from];
		fakeenv[to] = NULL;
		environ = fakeenv;
	}
	for (i = optind; i < argc; ++i) {
		static char	buf[MAX_STRING_LENGTH];

		(void) strcpy(&fakeenv[0][3], argv[i]);
		if (! (vflag | Vflag)) {
			show(argv[i], now, FALSE);
			continue;
		}
		warned = FALSE;
		t = absolute_min_time;
		if (!Vflag) {
			show(argv[i], t, TRUE);
			t += SECSPERDAY;
			show(argv[i], t, TRUE);
		}
		if (t < cutlotime)
			t = cutlotime;
		tmp = my_localtime(&t);
		if (tmp != NULL) {
			tm = *tmp;
			(void) strncpy(buf, abbr(&tm), (sizeof buf) - 1);
		}
		for ( ; ; ) {
			newt = (t < absolute_max_time - SECSPERDAY / 2
				? t + SECSPERDAY / 2
				: absolute_max_time);
			if (cuthitime <= newt)
				break;
			newtmp = localtime(&newt);
			if (newtmp != NULL)
				newtm = *newtmp;
			if ((tmp == NULL || newtmp == NULL) ? (tmp != newtmp) :
				(delta(&newtm, &tm) != (newt - t) ||
				newtm.tm_isdst != tm.tm_isdst ||
				strcmp(abbr(&newtm), buf) != 0)) {
					newt = hunt(argv[i], t, newt);
					newtmp = localtime(&newt);
					if (newtmp != NULL) {
						newtm = *newtmp;
						(void) strncpy(buf,
							abbr(&newtm),
							(sizeof buf) - 1);
					}
			}
			t = newt;
			tm = newtm;
			tmp = newtmp;
		}
		if (!Vflag) {
			t = absolute_max_time;
			t -= SECSPERDAY;
			show(argv[i], t, TRUE);
			t += SECSPERDAY;
			show(argv[i], t, TRUE);
		}
	}
	if (fflush(stdout) || ferror(stdout)) {
		(void) fprintf(stderr, "%s: ", progname);
		(void) perror(_("Error writing to standard output"));
		exit(EXIT_FAILURE);
	}
	exit(EXIT_SUCCESS);
	/* If exit fails to exit... */
	return EXIT_FAILURE;
}
Exemplo n.º 11
0
Arquivo: cpm.c Projeto: atluxity/cpm
/* if don't have any envorin variable at all */
int main(int argc, char **argv, char **envp)
#endif
#endif
  {
    rlim_t              memlock_limit = -2;
    int                 error = 0,
                        max_mem_lock = 0,
                        memory_safe = 0,
                        ptrace_safe = 0;
#ifdef TEST_OPTION
    int                 testrun = 0;
#endif
    char*               binaryname;

    savetermios();
    TRACE(99, "main()", NULL);

#ifndef HAVE_EXTERN_ENVIRON
#ifndef MANUAL_EXTERN_ENVIRON
    /* since in solaris environ does not exist, we manually pass it along */
    environ = envp;
#endif
#endif

    if (initSecurity(&max_mem_lock, &memory_safe, &ptrace_safe, &memlock_limit))
      { exit(1); }

    /* we initialize gettext */
    setlocale(LC_ALL, "");
#ifdef TEST_OPTION
    bindtextdomain(PACKAGE_NAME, "./po/");
#else
    bindtextdomain(PACKAGE_NAME, LOCALEDIR);
#endif
    textdomain(PACKAGE_NAME);

#ifndef LIBXML_TREE_ENABLED
    fprintf(stderr, _("Tree support not compiled in to libxml2 %s\n"),
        LIBXML_DOTTED_VERSION);
    exit(1);
#endif

    /*
     * This function installs "sighandler" to handle the SIGINT and returns a
     * pointer to the previously installed handler for this signal (which is
     * the default handler SIG_DFL initially). If we try to install another
     * handler to handle SIGINT at some other time... Then the new handler
     * replaces this current one and returns a pointer to this handler.
     */
    signal(SIGINT, sighandler);
    signal(SIGTERM, sighandler);
    /* the SIGWINCH handler is set in userInterface() */

    initConfiguration();

    runtime -> memlock_limit  = memlock_limit;
    runtime -> max_mem_lock   = max_mem_lock;
    runtime -> memory_safe    = memory_safe;
    runtime -> ptrace_safe    = ptrace_safe;

    initKeys();
    initPatternparser();
    initXML();
    initXMLInterface();

    if (getOptions(argc, argv))
      {
        fprintf(stderr, _("Try `%s --help' for more information.\n"), argv[0]);
        error = 1;
      }
    if (!error && config -> help)
      { showHelp(); }
    else if (!error && config -> version)
      { showVersion(); }
    else if (!error)
      {
        getDefaultOptions();
        if (readResources())
            return 1;

        if (config -> dbfilecmd)
          {   /* the --file option must overwrite the resource file */
            runtime -> dbfile = resolveFilelink(config -> dbfilecmd);
          }
        else
          {   /* we use the resource file configuration or the compiletime
               * default
               */
            runtime -> dbfile = resolveFilelink(config -> dbfilerc);
          }
      }

    /* we switch to read-only mode on request */
    if (config -> readonly)
      { runtime -> readonly = 1; }

    /* in case our basename is cpmv, we switch to read-only mode */
    binaryname = basename(argv[0]);
    if (!strcmp(binaryname, "cpmv"))
      { runtime -> readonly = 1; }

    initGPG();

    if (!error && config -> security)
      { checkSecurity(0); }

#ifdef TEST_OPTION
    if (!error &&
        config -> testrun &&
        !strncmp(config -> testrun, "compress", 8))
      {
        testCompress();
        testrun = 1;
      }
    if (!error &&
        config -> testrun &&
        !strcmp(config -> testrun, "environment"))
      {
        testEnvironment();
        testrun = 1;
      }
    if (!error &&
        config -> testrun && (
        !strcmp(config -> testrun, "backup") ||
        !strcmp(config -> testrun, "garbage") ||
        !strcmp(config -> testrun, "searchpattern")))
      { testrun = 1; }
#endif

    if (config -> configtest &&
        !error)
      { fprintf(stderr, _("configuration ok.\n")); }

    if (config -> environtmentlist &&
        !error)
      { listEnvironment(); }

    if (!error &&
        !config -> configtest &&
        !config -> environtmentlist &&
        !config -> help &&
        !config -> security &&
        !config -> version)
      {
#ifdef TEST_OPTION
        if (checkSecurity(1) != MAX_SECURITY_LEVEL &&
            !config -> testrun)
#else
        if (checkSecurity(1) != MAX_SECURITY_LEVEL)
#endif
          {
            checkSecurity(0);
            printf("\n%s %s\n%s\n",
                _("Maximum security level not reached."),
                _("Your database will be less protected while CPM is running."),
                _("Are you sure you want to continue?"),
                _("Press CTRL+C to stop now or ENTER to continue."));

            fgetc(stdin);
          }
        if (runtime -> guimode)
          {   /* we run in interactive mode */
            userInterface();
          }
        else
          {   /* we run in CLI mode */
            error = cliInterface();
#ifdef TEST_OPTION
            if (error == 2)
              {   /* for testruns, we must modify the stuff a little */
                error = 0;
                testrun = 1;
              }
#endif
          }
      }

    freeGPG();
    freeXMLInterface();
    freeUTF8Interface();
    freeXML();
    freePatternparser();
    freeKeys();
    freeConfiguration();

    if (memCheck())
      {   /* we validate our memory consumption */
        fprintf(stderr, _("error: memory leak detected.\n"));
        if (memCheck() > 0)
          {
            fprintf(stderr, _("%ld byte of memory were not freed.\n"),
                memCheck());
          }
        else
          {
            fprintf(stderr,
                _("%ld byte of memory were freed without being allocated.\n"),
                memCheck());
          }

        fprintf(stderr, _("Please send a report about this problem to Harry Brueckner <*****@*****.**>.\n"));

        error = 1;
      }

#ifdef TEST_OPTION
    if (testrun)
      { return 0; }
    else
      { return error; }
#else
    return error;
#endif
  }
Exemplo n.º 12
0
int
main (int argc, char *argv[])
{
	signal_user_data_t *ud;
	GValue *preset;
	GError *error = NULL;
	GOptionContext *context;

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	if (!g_thread_supported())
		g_thread_init(NULL);
	context = g_option_context_new ("- Rip and encode DVD or MPEG file");
	g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
	g_option_context_add_group (context, gtk_get_option_group (TRUE));
#if !defined(_WIN32)
	g_option_context_add_group (context, gst_init_get_option_group ());
#endif
	g_option_context_parse (context, &argc, &argv, &error);
	g_option_context_free(context);

	if (argc > 1 && dvd_device == NULL && argv[1][0] != '-')
	{
		dvd_device = argv[1];
	}
	
	gtk_set_locale ();
	gtk_init (&argc, &argv);
	gtk_rc_parse_string(hud_rcstyle);
	g_type_class_unref(g_type_class_ref(GTK_TYPE_BUTTON));
	g_object_set(gtk_settings_get_default(), "gtk-button-images", TRUE, NULL);
#if !defined(_WIN32)
	notify_init("HandBrake");
#endif
	ghb_register_transforms();
	ghb_resource_init();
	ghb_load_icons();

#if !defined(_WIN32)
	dbus_g_thread_init();
#endif
	ghb_udev_init();

	ghb_write_pid_file();
	ud = g_malloc0(sizeof(signal_user_data_t));
	ud->debug = ghb_debug;
	g_log_set_handler (NULL, G_LOG_LEVEL_DEBUG, debug_log_handler, ud);
	g_log_set_handler ("Gtk", G_LOG_LEVEL_WARNING, warn_log_handler, ud);
	//g_log_set_handler ("Gtk", G_LOG_LEVEL_CRITICAL, warn_log_handler, ud);
	ud->settings = ghb_settings_new();
	ud->builder = create_builder_or_die (BUILDER_NAME);
	// Enable events that alert us to media change events
	watch_volumes (ud);

	//GtkWidget *widget = GHB_WIDGET(ud->builder, "PictureDetelecineCustom");
	//gtk_entry_set_inner_border(widget, 2);

	// Since GtkBuilder no longer assigns object ids to widget names
	// Assign a few that are necessary for style overrides to work
	GtkWidget *widget;
#if defined(_NO_UPDATE_CHECK)
	widget = GHB_WIDGET(ud->builder, "check_updates_box");
	gtk_widget_hide(widget);
#endif

	widget = GHB_WIDGET(ud->builder, "preview_hud");
	gtk_widget_set_name(widget, "preview_hud");
	widget = GHB_WIDGET(ud->builder, "preview_window");
	gtk_widget_set_name(widget, "preview_window");

	// Set up the "hud" control overlay for the preview window
	GtkWidget *draw, *hud, *blender, *align;

	align = GHB_WIDGET(ud->builder, "preview_window_alignment");
	draw = GHB_WIDGET(ud->builder, "preview_image_align");
	hud = GHB_WIDGET(ud->builder, "preview_hud");

	// Set up compositing for hud
	blender = ghb_compositor_new();

	gtk_container_add(GTK_CONTAINER(align), blender);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), draw, 1, 1);
	ghb_compositor_zlist_insert(GHB_COMPOSITOR(blender), hud, 2, .85);
	gtk_widget_show(blender);

	// Redirect stderr to the activity window
	ghb_preview_init(ud);
	IoRedirect(ud);
	ghb_log( "%s - %s - %s",
		HB_PROJECT_TITLE, HB_PROJECT_BUILD_TITLE, HB_PROJECT_URL_WEBSITE );
	ghb_init_dep_map();

	// Need to connect x264_options textview buffer to the changed signal
	// since it can't be done automatically
	GtkTextView *textview;
	GtkTextBuffer *buffer;
	textview = GTK_TEXT_VIEW(GHB_WIDGET (ud->builder, "x264Option"));
	buffer = gtk_text_view_get_buffer (textview);
	g_signal_connect(buffer, "changed", (GCallback)x264_entry_changed_cb, ud);

	ghb_combo_init(ud);

	g_debug("ud %p\n", ud);
	g_debug("ud->builder %p\n", ud->builder);

	bind_audio_tree_model(ud);
	bind_subtitle_tree_model(ud);
	bind_presets_tree_model(ud);
	bind_queue_tree_model(ud);
	bind_chapter_tree_model(ud);
	// Connect up the signals to their callbacks
	// I wrote my own connector so that I could pass user data
	// to the callbacks.  Builder's standard autoconnect doesn't all this.
	gtk_builder_connect_signals_full (ud->builder, MyConnect, ud);

	// Load all internal settings
	ghb_settings_init(ud);
	// Load the presets files
	ghb_presets_load(ud);
	ghb_prefs_load(ud);

	ghb_prefs_to_ui(ud);

	gint logLevel;
	logLevel = ghb_settings_get_int(ud->settings, "LoggingLevel");
	ghb_backend_init(logLevel);

	if (ghb_settings_get_boolean(ud->settings, "hbfd"))
	{
		ghb_hbfd(ud, TRUE);
	}
	gchar *source = ghb_settings_get_string(ud->settings, "default_source");
	ghb_dvd_set_current(source, ud);
	g_free(source);

	// Parsing x264 options "" initializes x264 widgets to proper defaults
	ghb_x264_parse_options(ud, "");

	// Populate the presets tree view
	ghb_presets_list_init(ud, NULL, 0);
	// Get the first preset name
	if (arg_preset != NULL)
	{
		preset = ghb_parse_preset_path(arg_preset);
		if (preset)
		{
			ghb_select_preset(ud->builder, preset);
			ghb_value_free(preset);
		}
	}
	else
	{
		ghb_select_default_preset(ud->builder);
	}

	// Grey out widgets that are dependent on a disabled feature
	ghb_check_all_depencencies (ud);

	if (dvd_device != NULL)
	{
		// Source overridden from command line option
		ghb_settings_set_string(ud->settings, "scan_source", dvd_device);
		g_idle_add((GSourceFunc)ghb_idle_scan, ud);
	}
	// Reload and check status of the last saved queue
	g_idle_add((GSourceFunc)ghb_reload_queue, ud);

	// Start timer for monitoring libhb status, 500ms
	g_timeout_add (500, ghb_timer_cb, (gpointer)ud);

	// Add dvd devices to File menu
	ghb_volname_cache_init();
	g_thread_create((GThreadFunc)ghb_cache_volnames, ud, FALSE, NULL);

	GtkStatusIcon *si;
	si = GTK_STATUS_ICON(GHB_OBJECT(ud->builder, "hb_status"));

	gtk_status_icon_set_visible(si,
			ghb_settings_get_boolean(ud->settings, "show_status"));

#if GTK_CHECK_VERSION(2, 16, 0)
	gtk_status_icon_set_has_tooltip(si, TRUE);
	g_signal_connect(si, "query-tooltip", 
					status_icon_query_tooltip_cb, ud);
#else
	gtk_status_icon_set_tooltip(si, "HandBrake");
#endif

	// Ugly hack to keep subtitle table from bouncing around as I change
	// which set of controls are visible
	GtkRequisition req;
	gint height;
	
	widget = GHB_WIDGET(ud->builder, "SrtCodeset");
	gtk_widget_size_request( widget, &req );
	height = req.height;
	widget = GHB_WIDGET(ud->builder, "srt_code_label");
	gtk_widget_size_request( widget, &req );
	height += req.height;
	widget = GHB_WIDGET(ud->builder, "subtitle_table");
	gtk_widget_set_size_request(widget, -1, height);
	
	// Everything should be go-to-go.  Lets rock!

	gtk_main ();
	gtk_status_icon_set_visible(si, FALSE);
	ghb_backend_close();
	if (ud->queue)
		ghb_value_free(ud->queue);
	ghb_value_free(ud->settings);
	g_io_channel_unref(ud->activity_log);
	ghb_settings_close();
#if !defined(_WIN32)
	notify_uninit();
#endif
	g_free(ud);

	return 0;
}
Exemplo n.º 13
0
int main(int argc, char **argv)
{
    int ret = 0;
    char **spp;

#if I18N
    setlocale (LC_ALL, "");
    bindtextdomain("net-tools", "/usr/share/locale");
    textdomain("net-tools");
#endif

    if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
	perror("socket");
	exit(-1);
    }
    /* Find any options. */
    argc--;
    argv++;
    while (argv[0] && *argv[0] == '-') {
	if (!strcmp(*argv, "-a"))
	    opt_a = 1;
	if (!strcmp(*argv, "-v"))
	    opt_v = 1;
	if (!strcmp(*argv, "-V") || !strcmp(*argv, "--version"))
	    version();
	argv++;
	argc--;
    }

    if (argc == 0)
	usage();

    spp = argv;
    strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
    plip=(struct plipconf *)&ifr.ifr_data;

    plip->pcmd = PLIP_GET_TIMEOUT;	/* get current settings for device */
    if (ioctl(skfd, SIOCDEVPLIP, &ifr) < 0) {
	perror("ioctl");
	exit(-1);
    }
    if (*spp == (char *) NULL) {
	print_plip();
	(void) close(skfd);
	exit(0);
    }
    while (*spp != (char *) NULL) {
	if (!strcmp(*spp, "nibble")) {
	    if (*++spp == NULL)
		usage();
	    plip->nibble = atoi(*spp);
	    spp++;
	    continue;
	}
	if (!strcmp(*spp, "trigger")) {
	    if (*++spp == NULL)
		usage();
	    plip->trigger = atoi(*spp);
	    spp++;
	    continue;
	}
	usage();
    }

    plip->pcmd = PLIP_SET_TIMEOUT;
    if (ioctl(skfd, SIOCDEVPLIP, &ifr) < 0)
	perror("ioctl");

    print_plip();

    /* Close the socket. */
    (void) close(skfd);

    return (ret);
}
int
main (int argc, char **argv)
{
	GnomeProgram   *program;
	GConfClient    *client;
	GladeXML       *dialog;
	GtkWidget      *dialog_win, *w;
	GOptionContext *context;
	gchar *start_page = NULL;

	GOptionEntry cap_options[] = {
		{"show-page", 'p', G_OPTION_FLAG_IN_MAIN,
		 G_OPTION_ARG_STRING,
		 &start_page,
		 /* TRANSLATORS: don't translate the terms in brackets */
		 N_("Specify the name of the page to show (general|accessibility)"),
		 N_("page") },
		{NULL}
	};

	bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	context = g_option_context_new (_("- GNOME Mouse Preferences"));
	g_option_context_add_main_entries (context, cap_options,
					   GETTEXT_PACKAGE);

	program = gnome_program_init ("gnome-mouse-properties", VERSION,
				      LIBGNOMEUI_MODULE, argc, argv,
				      GNOME_PARAM_GOPTION_CONTEXT, context,
				      GNOME_PARAM_APP_DATADIR, GNOMECC_DATA_DIR,
				      NULL);

	capplet_init_stock_icons ();

	activate_settings_daemon ();

	client = gconf_client_get_default ();
	gconf_client_add_dir (client, "/desktop/gnome/peripherals/mouse", GCONF_CLIENT_PRELOAD_ONELEVEL, NULL);

	dialog = create_dialog ();

	if (dialog) {
		setup_dialog (dialog, NULL);
		setup_accessibility (dialog, client);

		dialog_win = WID ("mouse_properties_dialog");
		g_signal_connect (dialog_win, "response",
				  G_CALLBACK (dialog_response_cb), NULL);

		if (start_page != NULL) {
			gchar *page_name;

			page_name = g_strconcat (start_page, "_vbox", NULL);
			g_free (start_page);

			w = WID (page_name);
			if (w != NULL) {
				GtkNotebook *nb;
				gint pindex;

				nb = GTK_NOTEBOOK (WID ("prefs_widget"));
				pindex = gtk_notebook_page_num (nb, w);
				if (pindex != -1)
					gtk_notebook_set_current_page (nb, pindex);
			}
			g_free (page_name);
		}

		capplet_set_icon (dialog_win, "gnome-dev-mouse-optical");
		gtk_widget_show (dialog_win);

		gtk_main ();

		g_object_unref (dialog);
	}

	g_object_unref (client);
	g_object_unref (program);

	return 0;
}
Exemplo n.º 15
0
void _init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	matrixStMSDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (matrixStMSDescriptor) {
		matrixStMSDescriptor->UniqueID = 1420;
		matrixStMSDescriptor->Label = "matrixStMS";
		matrixStMSDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		matrixStMSDescriptor->Name =
		 D_("Matrix: Stereo to MS");
		matrixStMSDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		matrixStMSDescriptor->Copyright =
		 "GPL";
		matrixStMSDescriptor->PortCount = 4;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(4,
		 sizeof(LADSPA_PortDescriptor));
		matrixStMSDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(4,
		 sizeof(LADSPA_PortRangeHint));
		matrixStMSDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(4, sizeof(char*));
		matrixStMSDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Left */
		port_descriptors[MATRIXSTMS_LEFT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSTMS_LEFT] =
		 D_("Left");
		port_range_hints[MATRIXSTMS_LEFT].HintDescriptor = 0;

		/* Parameters for Right */
		port_descriptors[MATRIXSTMS_RIGHT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSTMS_RIGHT] =
		 D_("Right");
		port_range_hints[MATRIXSTMS_RIGHT].HintDescriptor = 0;

		/* Parameters for Mid */
		port_descriptors[MATRIXSTMS_MID] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSTMS_MID] =
		 D_("Mid");
		port_range_hints[MATRIXSTMS_MID].HintDescriptor = 0;

		/* Parameters for Side */
		port_descriptors[MATRIXSTMS_SIDE] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSTMS_SIDE] =
		 D_("Side");
		port_range_hints[MATRIXSTMS_SIDE].HintDescriptor = 0;

		matrixStMSDescriptor->activate = NULL;
		matrixStMSDescriptor->cleanup = cleanupMatrixStMS;
		matrixStMSDescriptor->connect_port = connectPortMatrixStMS;
		matrixStMSDescriptor->deactivate = NULL;
		matrixStMSDescriptor->instantiate = instantiateMatrixStMS;
		matrixStMSDescriptor->run = runMatrixStMS;
		matrixStMSDescriptor->run_adding = runAddingMatrixStMS;
		matrixStMSDescriptor->set_run_adding_gain = setRunAddingGainMatrixStMS;
	}
}
Exemplo n.º 16
0
int
main (int argc, char **argv)
{

	MYSQL mysql;
	MYSQL_RES *res;
	MYSQL_ROW row;
	
	double value;
	char *error = NULL;
	int status;

	setlocale (LC_ALL, "");
	bindtextdomain (PACKAGE, LOCALEDIR);
	textdomain (PACKAGE);

	/* Parse extra opts if any */
	argv=np_extra_opts (&argc, argv, progname);

	if (process_arguments (argc, argv) == ERROR)
		usage4 (_("Could not parse arguments"));

	/* initialize mysql  */
	mysql_init (&mysql);

	mysql_options(&mysql,MYSQL_READ_DEFAULT_GROUP,"client");

	/* establish a connection to the server and error checking */
	if (!mysql_real_connect(&mysql,db_host,db_user,db_pass,db,db_port,db_socket,0)) {
		if (mysql_errno (&mysql) == CR_UNKNOWN_HOST)
			die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), mysql_error (&mysql));
		else if (mysql_errno (&mysql) == CR_VERSION_ERROR)
			die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), mysql_error (&mysql));
		else if (mysql_errno (&mysql) == CR_OUT_OF_MEMORY)
			die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), mysql_error (&mysql));
		else if (mysql_errno (&mysql) == CR_IPSOCK_ERROR)
			die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), mysql_error (&mysql));
		else if (mysql_errno (&mysql) == CR_SOCKET_CREATE_ERROR)
			die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), mysql_error (&mysql));
		else
			die (STATE_CRITICAL, "QUERY %s: %s\n", _("CRITICAL"), mysql_error (&mysql));
	}

	if (mysql_query (&mysql, sql_query) != 0) {
		error = strdup(mysql_error(&mysql));
		mysql_close (&mysql);
		die (STATE_CRITICAL, "QUERY %s: %s - %s\n", _("CRITICAL"), _("Error with query"), error);
	}

	/* store the result */
	if ( (res = mysql_store_result (&mysql)) == NULL) {
		error = strdup(mysql_error(&mysql));
		mysql_close (&mysql);
		die (STATE_CRITICAL, "QUERY %s: Error with store_result - %s\n", _("CRITICAL"), error);
	}

	/* Check there is some data */
	if (mysql_num_rows(res) == 0) {
		mysql_close(&mysql);
		die (STATE_WARNING, "QUERY %s: %s\n", _("WARNING"), _("No rows returned"));
	}

	/* fetch the first row */
	if ( (row = mysql_fetch_row (res)) == NULL) {
		error = strdup(mysql_error(&mysql));
		mysql_free_result (res);
		mysql_close (&mysql);
		die (STATE_CRITICAL, "QUERY %s: Fetch row error - %s\n", _("CRITICAL"), error);
	}

	/* free the result */
	mysql_free_result (res);

	/* close the connection */
	mysql_close (&mysql);

	if (! is_numeric(row[0])) {
		die (STATE_CRITICAL, "QUERY %s: %s - '%s'\n", _("CRITICAL"), _("Is not a numeric"), row[0]);
	}

	value = strtod(row[0], NULL);

	if (verbose >= 3)
		printf("mysql result: %f\n", value);

	status = get_status(value, my_thresholds);

	if (status == STATE_OK) {
		printf("QUERY %s: ", _("OK"));
	} else if (status == STATE_WARNING) {
		printf("QUERY %s: ", _("WARNING"));
	} else if (status == STATE_CRITICAL) {
		printf("QUERY %s: ", _("CRITICAL"));
	}
	printf(_("'%s' returned %f | %s"), sql_query, value,
	 fperfdata("result", value, "",
	 my_thresholds->warning?TRUE:FALSE, my_thresholds->warning?my_thresholds->warning->end:0,
	 my_thresholds->critical?TRUE:FALSE, my_thresholds->critical?my_thresholds->critical->end:0,
	 FALSE, 0,
	 FALSE, 0)
	);

	printf("\n");

	return status;
}
Exemplo n.º 17
0
int main(int ac, char **av)
{
    int saved_x, saved_y;
    char *mode;
    int res;

    setlocale(LC_ALL, "");
    bindtextdomain(PACKAGE, LOCALEDIR);
    textdomain(PACKAGE);

    conf_parse(av[1]);
    conf_read(NULL);

    mode = getenv("MENUCONFIG_MODE");
    if (mode) {
        if (!strcasecmp(mode, "single_menu"))
            single_menu_mode = 1;
    }

    getyx(stdscr, saved_y, saved_x);
    if (init_dialog(NULL)) {
        fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
        fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
        return 1;
    }

    set_config_filename(conf_get_configname());
    do {
        conf(&rootmenu);
        dialog_clear();
        if (conf_get_changed())
            res = dialog_yesno(NULL,
                               _("Do you wish to save your "
                                 "new configuration?\n"
                                 "<ESC><ESC> to continue."),
                               6, 60);
        else
            res = -1;
    } while (res == KEY_ESC);
    end_dialog(saved_x, saved_y);

    switch (res) {
    case 0:
        if (conf_write(filename)) {
            fprintf(stderr, _("\n\n"
                              "Error during writing of the configuration.\n"
                              "Your configuration changes were NOT saved."
                              "\n\n"));
            return 1;
        }
        if (conf_write_autoconf()) {
            fprintf(stderr, _("\n*** Error during writing of the configuration.\n\n"));
            return 1;
        }
    case -1:
        printf(_("\n\n"
                 "*** End of coreinfo configuration.\n"
                 "*** Execute 'make' to build or try 'make help'."
                 "\n\n"));
        break;
    default:
        fprintf(stderr, _("\n\n"
                          "Your configuration changes were NOT saved."
                          "\n\n"));
    }

    return 0;
}
Exemplo n.º 18
0
gint
main (gint argc, gchar **argv)
{
	GtkWidget       *window;
	GOptionContext  *context;
	const gchar     *filename;
	EvDocumentModel *model;
	GError          *error = NULL;

#ifdef ENABLE_NLS
	/* Initialize the i18n stuff */
	bindtextdomain (GETTEXT_PACKAGE, ev_get_locale_dir());
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif
	
	context = g_option_context_new (_("MATE Document Previewer"));
	g_option_context_set_translation_domain (context, GETTEXT_PACKAGE);
	g_option_context_add_main_entries (context, goption_options, GETTEXT_PACKAGE);

	g_option_context_add_group (context, gtk_get_option_group (TRUE));
	
	if (!g_option_context_parse (context, &argc, &argv, &error)) {
		g_warning ("Error parsing command line arguments: %s", error->message);
		g_error_free (error);
		g_option_context_free (context);

		return 1;
	}
	g_option_context_free (context);

	if (!filenames) {
		g_warning ("File argument is required");
		
		return 1;
	}

	filename = filenames[0];
	
	if (!g_file_test (filename, G_FILE_TEST_IS_REGULAR)) {
		g_warning ("Filename \"%s\" does not exist or is not a regular file", filename);

		return 1;
	}

	if (!ev_init ())
		return 1;

	ev_stock_icons_init ();

	g_set_application_name (_("MATE Document Previewer"));
	gtk_window_set_default_icon_name ("atril");

	model = ev_document_model_new ();
	window = ev_previewer_window_new (model);
	ev_previewer_window_set_source_file (EV_PREVIEWER_WINDOW (window), filename);
	ev_previewer_window_set_print_settings (EV_PREVIEWER_WINDOW (window), print_settings);
	g_signal_connect (window, "delete-event",
			  G_CALLBACK (gtk_main_quit), NULL);
	g_signal_connect (window, "destroy",
			  G_CALLBACK (gtk_main_quit), NULL);
	gtk_widget_show (window);

	ev_previewer_load_document (filename, model);
	
	gtk_main ();

	if (unlink_temp_file)
		ev_previewer_unlink_tempfile (filename);
	if (print_settings)
		ev_previewer_unlink_tempfile (print_settings);

	ev_shutdown ();
	ev_stock_icons_shutdown ();
	g_object_unref (model);
	
	return 0;
}
Exemplo n.º 19
0
void __attribute__((constructor)) swh_init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	matrixSpatialiserDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (matrixSpatialiserDescriptor) {
		matrixSpatialiserDescriptor->UniqueID = 1422;
		matrixSpatialiserDescriptor->Label = "matrixSpatialiser";
		matrixSpatialiserDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		matrixSpatialiserDescriptor->Name =
		 D_("Matrix Spatialiser");
		matrixSpatialiserDescriptor->Maker =
		 "Joern Nettingsmeier <*****@*****.**>";
		matrixSpatialiserDescriptor->Copyright =
		 "GPL";
		matrixSpatialiserDescriptor->PortCount = 5;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(5,
		 sizeof(LADSPA_PortDescriptor));
		matrixSpatialiserDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(5,
		 sizeof(LADSPA_PortRangeHint));
		matrixSpatialiserDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(5, sizeof(char*));
		matrixSpatialiserDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Input L */
		port_descriptors[MATRIXSPATIALISER_I_LEFT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSPATIALISER_I_LEFT] =
		 D_("Input L");
		port_range_hints[MATRIXSPATIALISER_I_LEFT].HintDescriptor = 0;

		/* Parameters for Input R */
		port_descriptors[MATRIXSPATIALISER_I_RIGHT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSPATIALISER_I_RIGHT] =
		 D_("Input R");
		port_range_hints[MATRIXSPATIALISER_I_RIGHT].HintDescriptor = 0;

		/* Parameters for Width */
		port_descriptors[MATRIXSPATIALISER_WIDTH] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[MATRIXSPATIALISER_WIDTH] =
		 D_("Width");
		port_range_hints[MATRIXSPATIALISER_WIDTH].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER | LADSPA_HINT_DEFAULT_0;
		port_range_hints[MATRIXSPATIALISER_WIDTH].LowerBound = -512;
		port_range_hints[MATRIXSPATIALISER_WIDTH].UpperBound = 512;

		/* Parameters for Output L */
		port_descriptors[MATRIXSPATIALISER_O_LEFT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSPATIALISER_O_LEFT] =
		 D_("Output L");
		port_range_hints[MATRIXSPATIALISER_O_LEFT].HintDescriptor = 0;

		/* Parameters for Output R */
		port_descriptors[MATRIXSPATIALISER_O_RIGHT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[MATRIXSPATIALISER_O_RIGHT] =
		 D_("Output R");
		port_range_hints[MATRIXSPATIALISER_O_RIGHT].HintDescriptor = 0;

		matrixSpatialiserDescriptor->activate = activateMatrixSpatialiser;
		matrixSpatialiserDescriptor->cleanup = cleanupMatrixSpatialiser;
		matrixSpatialiserDescriptor->connect_port = connectPortMatrixSpatialiser;
		matrixSpatialiserDescriptor->deactivate = NULL;
		matrixSpatialiserDescriptor->instantiate = instantiateMatrixSpatialiser;
		matrixSpatialiserDescriptor->run = runMatrixSpatialiser;
		matrixSpatialiserDescriptor->run_adding = runAddingMatrixSpatialiser;
		matrixSpatialiserDescriptor->set_run_adding_gain = setRunAddingGainMatrixSpatialiser;
	}
}
Exemplo n.º 20
0
void _init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	gsmDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (gsmDescriptor) {
		gsmDescriptor->UniqueID = 1215;
		gsmDescriptor->Label = "gsm";
		gsmDescriptor->Properties =
		 0;
		gsmDescriptor->Name =
		 D_("GSM simulator");
		gsmDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		gsmDescriptor->Copyright =
		 "GPL";
		gsmDescriptor->PortCount = 6;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(6,
		 sizeof(LADSPA_PortDescriptor));
		gsmDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(6,
		 sizeof(LADSPA_PortRangeHint));
		gsmDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(6, sizeof(char*));
		gsmDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Dry/wet mix */
		port_descriptors[GSM_DRYWET] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[GSM_DRYWET] =
		 D_("Dry/wet mix");
		port_range_hints[GSM_DRYWET].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_1;
		port_range_hints[GSM_DRYWET].LowerBound = 0;
		port_range_hints[GSM_DRYWET].UpperBound = 1;

		/* Parameters for Number of passes */
		port_descriptors[GSM_PASSES] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[GSM_PASSES] =
		 D_("Number of passes");
		port_range_hints[GSM_PASSES].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_INTEGER | LADSPA_HINT_DEFAULT_1;
		port_range_hints[GSM_PASSES].LowerBound = 0;
		port_range_hints[GSM_PASSES].UpperBound = 10;

		/* Parameters for Error rate (bits/block) */
		port_descriptors[GSM_ERROR] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[GSM_ERROR] =
		 D_("Error rate (bits/block)");
		port_range_hints[GSM_ERROR].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[GSM_ERROR].LowerBound = 0;
		port_range_hints[GSM_ERROR].UpperBound = 30;

		/* Parameters for Input */
		port_descriptors[GSM_INPUT] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[GSM_INPUT] =
		 D_("Input");
		port_range_hints[GSM_INPUT].HintDescriptor = 0;

		/* Parameters for Output */
		port_descriptors[GSM_OUTPUT] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[GSM_OUTPUT] =
		 D_("Output");
		port_range_hints[GSM_OUTPUT].HintDescriptor = 0;

		/* Parameters for latency */
		port_descriptors[GSM_LATENCY] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_CONTROL;
		port_names[GSM_LATENCY] =
		 D_("latency");
		port_range_hints[GSM_LATENCY].HintDescriptor = 0;

		gsmDescriptor->activate = activateGsm;
		gsmDescriptor->cleanup = cleanupGsm;
		gsmDescriptor->connect_port = connectPortGsm;
		gsmDescriptor->deactivate = NULL;
		gsmDescriptor->instantiate = instantiateGsm;
		gsmDescriptor->run = runGsm;
		gsmDescriptor->run_adding = runAddingGsm;
		gsmDescriptor->set_run_adding_gain = setRunAddingGainGsm;
	}
}
Exemplo n.º 21
0
void SetTitles(void)
{
    int have_run_dir;
#ifndef HAVE_RUN_DIR
    have_run_dir = 1;
#else
    have_run_dir = 0;
#endif

#ifdef ENABLE_NLS
    setlocale(LC_MESSAGES, getenv("LANG"));

    bindtextdomain("citadel-setup", LOCALEDIR"/locale");
    textdomain("citadel-setup");
    bind_textdomain_codeset("citadel-setup","UTF8");
#endif

    setup_titles[eCitadelHomeDir] = _("Citadel Home Directory");
    if (have_run_dir)
        setup_text[eCitadelHomeDir] = _(
                                          "Enter the full pathname of the directory in which the Citadel\n"
                                          "installation you are creating or updating resides.  If you\n"
                                          "specify a directory other than the default, you will need to\n"
                                          "specify the -h flag to the server when you start it up.\n");
    else
        setup_text[eCitadelHomeDir] = _(
                                          "Enter the subdirectory name for an alternate installation of "
                                          "Citadel. To do a default installation just leave it blank."
                                          "If you specify a directory other than the default, you will need to\n"
                                          "specify the -h flag to the server when you start it up.\n"
                                          "note that it may not have a leading /");


    setup_titles[eSysAdminName] = _("Citadel administrator username:"******"Please enter the name of the Citadel user account that should be granted "
                                    "administrative privileges once created. If using internal authentication "
                                    "this user account will be created if it does not exist. For external "
                                    "authentication this user account has to exist.");


    setup_titles[eSysAdminPW] = _("Administrator password:"******"Enter a password for the system administrator. When setup\n"
                                  "completes it will attempt to create the administrator user\n"
                                  "and set the password specified here.\n");

    setup_titles[eUID] = _("Citadel User ID:");
    setup_text[eUID] = _(
                           "Citadel needs to run under its own user ID.  This would\n"
                           "typically be called \"citadel\", but if you are running Citadel\n"
                           "as a public site, you might also call it \"bbs\" or \"guest\".\n"
                           "The server will run under this user ID.  Please specify that\n"
                           "user ID here.  You may specify either a user name or a numeric\n"
                           "UID.\n");

    setup_titles[eIP_ADDR] = _("Listening address for the Citadel server:");
    setup_text[eIP_ADDR] = _(
                               "Please specify the IP address which the server should be listening to. "
                               "You can name a specific IPv4 or IPv6 address, or you can specify\n"
                               "\"*\" for \"any address\", \"::\" for \"any IPv6 address\", or \"0.0.0.0\"\n"
                               "for \"any IPv4 address\". If you leave this blank, Citadel will\n"
                               "listen on all addresses. "
                               "This can usually be left to the default unless multiple instances of Citadel "
                               "are running on the same computer.");

    setup_titles[eCTDL_Port] = _("Server port number:");
    setup_text[eCTDL_Port] = _(
                                 "Specify the TCP port number on which your server will run.\n"
                                 "Normally, this will be port 504, which is the official port\n"
                                 "assigned by the IANA for Citadel servers.  You will only need\n"
                                 "to specify a different port number if you run multiple instances\n"
                                 "of Citadel on the same computer and there is something else\n"
                                 "already using port 504.\n");

    setup_titles[eAuthType] = _("Authentication method to use:");
    setup_text[eAuthType] = _(
                                "Please choose the user authentication mode. By default Citadel will use its "
                                "own internal user accounts database. If you choose Host, Citadel users will "
                                "have accounts on the host system, authenticated via /etc/passwd or a PAM "
                                "source. LDAP chooses an RFC 2307 compliant directory server, the last option "
                                "chooses the nonstandard MS Active Directory LDAP scheme."
                                "\n"
                                "Do not change this option unless you are sure it is required, since changing "
                                "back requires a full reinstall of Citadel."
                                "\n"
                                " 0. Self contained authentication\n"
                                " 1. Host system integrated authentication\n"
                                " 2. External LDAP - RFC 2307 compliant directory\n"
                                " 3. External LDAP - nonstandard MS Active Directory\n"
                                "\n"
                                "For help: http://www.citadel.org/doku.php/faq:installation:authmodes\n"
                                "\n"
                                "ANSWER \"0\" UNLESS YOU COMPLETELY UNDERSTAND THIS OPTION.\n");

    setup_titles[eLDAP_Host] = _("LDAP host:");
    setup_text[eLDAP_Host] = _(
                                 "Please enter the host name or IP address of your LDAP server.\n");

    setup_titles[eLDAP_Port] = _("LDAP port number:");
    setup_text[eLDAP_Port] = _(
                                 "Please enter the port number of the LDAP service (usually 389).\n");

    setup_titles[eLDAP_Base_DN] = _("LDAP base DN:");
    setup_text[eLDAP_Base_DN] = _(
                                    "Please enter the Base DN to search for authentication\n"
                                    "(for example: dc=example,dc=com)\n");

    setup_titles[eLDAP_Bind_DN] = _("LDAP bind DN:");
    setup_text[eLDAP_Bind_DN] = _(
                                    "Please enter the DN of an account to use for binding to the LDAP server for "
                                    "performing queries. The account does not require any other privileges. If "
                                    "your LDAP server allows anonymous queries, you can leave this blank.\n");

    setup_titles[eLDAP_Bind_PW] = _("LDAP bind password:"******"If you entered a Bind DN in the previous question, you must now enter\n"
                                    "the password associated with that account.  Otherwise, you can leave this\n"
                                    "blank.\n");

#if 0
// Debug loading of locales... Strace does a better job though.
    printf("Message catalog directory: %s\n", bindtextdomain("citadel-setup", LOCALEDIR"/locale"));
    printf("Text domain: %s\n", textdomain("citadel-setup"));
    printf("Text domain Charset: %s\n", bind_textdomain_codeset("citadel-setup","UTF8"));
    {
        int i;
        for (i = 0; i < eMaxQuestions; i++)
            printf("%s - %s\n", setup_titles[i], _(setup_titles[i]));
        exit(0);
    }
#endif
}
Exemplo n.º 22
0
/* Uaaahahahh, ich will dir einloggen!  PAM authentication entry
   point.  */
PAM_EXTERN int
pam_sm_authenticate (pam_handle_t *pam_handle,
		     int flags, int argc, const char **argv)
{
  const void *conv_void;
  gpg_error_t err; 
  poldi_ctx_t ctx;
  conv_t conv;
  scd_context_t scd_ctx;
  int ret;
  const char *pam_username;
  struct auth_method_parse_cookie method_parse_cookie = { NULL, NULL };
  simpleparse_handle_t method_parse;
  struct getpin_cb_data getpin_cb_data;

  pam_username = NULL;
  scd_ctx = NULL;
  conv = NULL;
  ctx = NULL;
  method_parse = NULL;
  err = 0;

  /*** Basic initialization. ***/

  bindtextdomain (PACKAGE, LOCALEDIR);

  /* Initialize Libgcrypt.  Disable secure memory for now; because of
     the implicit priviledge dropping, having secure memory enabled
     causes the following error:

     su: Authentication service cannot retrieve authentication
     info. */
  gcry_control (GCRYCTL_DISABLE_SECMEM);

  /*** Setup main context.  ***/

  err = create_context (&ctx, pam_handle);
  if (err)
    goto out;

  /* Setup logging prefix.  */
  log_set_flags (ctx->loghandle,
		 LOG_FLAG_WITH_PREFIX | LOG_FLAG_WITH_TIME | LOG_FLAG_WITH_PID);
  log_set_prefix (ctx->loghandle, "Poldi");
  log_set_backend_syslog (ctx->loghandle);

  /*** Parse auth-method independent options.  ***/

  /* ... from configuration file:  */
  err = simpleparse_parse_file (ctx->parsehandle, 0, POLDI_CONF_FILE);
  if (err)
    {
      log_msg_error (ctx->loghandle,
		     _("failed to parse configuration file '%s': %s"),
		     POLDI_CONF_FILE,
		     gpg_strerror (err));
      goto out;
    }

  /* ... and from argument vector provided by PAM: */
  if (argc)
    {
      err = simpleparse_parse (ctx->parsehandle, 0, argc, argv, NULL);
      if (err)
	{
	  log_msg_error (ctx->loghandle,
			 _("failed to parse PAM argument vector: %s"),
			 gpg_strerror (err));
	  goto out;
	}
    }

  /*** Initialize logging. ***/

  /* In case `logfile' has been set in the configuration file,
     initialize jnlib-logging the traditional file, loggin to the file
     (or socket special file) specified in the configuration file; in
     case `logfile' has NOT been set in the configuration file, log
     through Syslog.  */
  if (ctx->logfile)
    {
      gpg_error_t rc;

      rc = log_set_backend_file (ctx->loghandle, ctx->logfile);
      if (rc != 0)
	/* Last try...  */
	log_set_backend_syslog (ctx->loghandle);
    }

  /*** Sanity checks. ***/

  /* Authentication method to use must be specified.  */
  if (ctx->auth_method < 0)
    {
      log_msg_error (ctx->loghandle,
		     _("no authentication method specified"));
      err = GPG_ERR_CONFIGURATION;
      goto out;
    }

  /* Authentication methods must provide a parser callback in case
     they have specific a configuration file.  */
  assert ((!auth_methods[ctx->auth_method].method->config)
	  || (auth_methods[ctx->auth_method].method->parsecb
	      && auth_methods[ctx->auth_method].method->opt_specs));

  if (ctx->debug)
    {
      log_msg_debug (ctx->loghandle,
		     _("using authentication method `%s'"),
		     auth_methods[ctx->auth_method].name);
    }

  /*** Init authentication method.  ***/
  
  if (auth_methods[ctx->auth_method].method->func_init)
    {
      err = (*auth_methods[ctx->auth_method].method->func_init) (&ctx->cookie);
      if (err)
	{
	  log_msg_error (ctx->loghandle,
			 _("failed to initialize authentication method %i: %s"),
			 -1, gpg_strerror (err));
	  goto out;
	}
    }

  if (auth_methods[ctx->auth_method].method->config)
    {
      /* Do auth-method specific parsing. */

      err = simpleparse_create (&method_parse);
      if (err)
	{
	  log_msg_error (ctx->loghandle,
			 _("failed to initialize parsing of configuration file for authentication method %s: %s"),
			 auth_methods[ctx->auth_method].name, gpg_strerror (err));
	  goto out_parsing;
	}

      method_parse_cookie.poldi_ctx = ctx;
      method_parse_cookie.method_ctx = ctx->cookie;

      simpleparse_set_loghandle (method_parse, ctx->loghandle);
      simpleparse_set_parse_cb (method_parse,
				auth_methods[ctx->auth_method].method->parsecb,
				&method_parse_cookie);
      simpleparse_set_i18n_cb (method_parse, i18n_cb, NULL);
      simpleparse_set_specs (method_parse,
			     auth_methods[ctx->auth_method].method->opt_specs);

      err = simpleparse_parse_file (method_parse, 0, 
				    auth_methods[ctx->auth_method].method->config);
      if (err)
	{
	  log_msg_error (ctx->loghandle,
			 _("failed to parse configuration for authentication method %i: %s"),
			 auth_methods[ctx->auth_method].name, gpg_strerror (err));
	  goto out_parsing;
	}

    out_parsing:

      simpleparse_destroy (method_parse);
      if (err)
	goto out;
    }

  /*** Prepare PAM interaction.  ***/

  /* Ask PAM for conv structure.  */
  ret = pam_get_item (ctx->pam_handle, PAM_CONV, &conv_void);
  if (ret != PAM_SUCCESS)
    {
      log_msg_error (ctx->loghandle,
		     _("failed to retrieve PAM conversation structure"));
      err = GPG_ERR_INTERNAL;
      goto out;
    }

  /* Init conv subsystem by creating a conv_t object.  */
  err = conv_create (&conv, conv_void);
  if (err)
    goto out;

  ctx->conv = conv;

  /*** Retrieve username from PAM.  ***/

  err = retrieve_username_from_pam (ctx->pam_handle, &pam_username);
  if (err)
    {
      log_msg_error (ctx->loghandle,
		     _("failed to retrieve username from PAM: %s"),
		     gpg_strerror (err));
    }

  /*** Connect to Scdaemon. ***/

  err = scd_connect (&scd_ctx,
		     NULL, getenv ("GPG_AGENT_INFO"),
		     ctx->scdaemon_program, ctx->scdaemon_options,
		     0, ctx->loghandle);
  if (err)
    goto out;

  ctx->scd = scd_ctx;

  /* Install PIN retrival callback. */
  getpin_cb_data.poldi_ctx = ctx;
  scd_set_pincb (ctx->scd, getpin_cb, &getpin_cb_data);

  /*** Wait for card insertion.  ***/

  if (pam_username)
    {
      if (ctx->debug)
	log_msg_debug (ctx->loghandle, _("Waiting for card for user `%s'..."), pam_username);
      if (!ctx->quiet)
	conv_tell (ctx->conv, _("Insert authentication card for user `%s'"), pam_username);
    }
  else
    {
      if (ctx->debug)
	log_msg_debug (ctx->loghandle, _("Waiting for card..."));
      if (!ctx->quiet)
	conv_tell (ctx->conv, _("Insert authentication card"));
    }

  err = wait_for_card (ctx->scd, 0);
  if (err)
    {
      log_msg_error (ctx->loghandle,
		     _("failed to wait for card insertion: %s"),
		     gpg_strerror (err));
      goto out;
    }

  /*** Receive card info. ***/

  err = scd_learn (ctx->scd, &ctx->cardinfo);
  if (err)
    goto out;

  if (ctx->debug)
    log_msg_debug (ctx->loghandle,
		   _("connected to card; serial number is: %s"),
		   ctx->cardinfo.serialno);

  /*** Authenticate.  ***/

  if (pam_username)
    {
      /* Try to authenticate user as PAM_USERNAME.  */

      if (!(*auth_methods[ctx->auth_method].method->func_auth_as) (ctx, ctx->cookie,
								   pam_username))
	/* Authentication failed.  */
	err = GPG_ERR_GENERAL;
    }
  else
    {
      /* Try to authenticate user, choosing an identity is up to the
	 user.  */

      char *username_authenticated = NULL;

      if (!(*auth_methods[ctx->auth_method].method->func_auth) (ctx, ctx->cookie,
								&username_authenticated))
	/* Authentication failed.  */
	err = GPG_ERR_GENERAL;
      else
	{
	  /* Send username received during authentication process back
	     to PAM.  */
	  err = send_username_to_pam (ctx->pam_handle, username_authenticated);
	  xfree (username_authenticated);
	}
    }

 out:

  /* Log result.  */
  if (err)
    log_msg_error (ctx->loghandle, _("authentication failed: %s"), gpg_strerror (err));
  else
    {
      if (ctx->debug)
	log_msg_debug (ctx->loghandle, _("authentication succeeded"));
      if (ctx->modify_environment)
	modify_environment (pam_handle, ctx);
    }

  /* Call authentication method's deinit callback. */
  if ((ctx->auth_method >= 0)
      && auth_methods[ctx->auth_method].method->func_deinit)
    (*auth_methods[ctx->auth_method].method->func_deinit) (ctx->cookie);

  /* FIXME, cosmetics? */
  conv_destroy (conv);
  destroy_context (ctx);

  /* Return to PAM.  */

  return err ? PAM_AUTH_ERR : PAM_SUCCESS;
}
Exemplo n.º 23
0
/**
 * Program entry point. Initializes gtk+, calls the widget creating
 * functions and starts the main loop. Also connects 'popup-menu',
 * 'activate' and 'button-release-event' to the tray_icon.
 *
 * @param argc count of arguments
 * @param argv string array of arguments
 * @return 0 for success, otherwise error code
 */
int
main(int argc, char *argv[])
{
	GError *error = NULL;
	GOptionContext *context;
	want_debug = FALSE;

#ifdef ENABLE_NLS
	bindtextdomain(GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
	textdomain(GETTEXT_PACKAGE);
#endif

	DEBUG_PRINT("[Debugging Mode Build]\n");

	setlocale(LC_ALL, "");
	context = g_option_context_new(_("- A mixer for the system tray."));
	g_option_context_add_main_entries(context, args, GETTEXT_PACKAGE);
	g_option_context_add_group(context, gtk_get_option_group(TRUE));
	g_option_context_parse(context, &argc, &argv, &error);
	gtk_init(&argc, &argv);

	g_option_context_free(context);

	if (version) {
		printf(_("%s version: %s\n"), PACKAGE, VERSION);
		exit(0);
	}

	popup_window = NULL;

	add_pixmap_directory(PACKAGE_DATA_DIR "/" PACKAGE "/pixmaps");
	add_pixmap_directory("./data/pixmaps");

	prefs_ensure_save_dir();
	prefs_load();
	cards = NULL;		// so we don't try and free on first run
	alsa_init();
	init_libnotify();
	create_popup_window();
	create_popup_menu();
	add_filter();

	tray_icon = create_tray_icon();

	g_signal_connect(G_OBJECT(tray_icon), "popup-menu",
			 G_CALLBACK(popup_callback), popup_menu);
	g_signal_connect(G_OBJECT(tray_icon), "activate",
			 G_CALLBACK(tray_icon_on_click), NULL);
	g_signal_connect(G_OBJECT(tray_icon), "button-release-event",
			 G_CALLBACK(tray_icon_button), NULL);
	mute_check_popup_menu_handler =
		g_signal_connect(G_OBJECT(mute_check_popup_menu),
				"toggled", G_CALLBACK(on_mute_clicked), NULL);
	mute_check_popup_window_handler =
		g_signal_connect(G_OBJECT(mute_check_popup_window),
				"toggled", G_CALLBACK(on_mute_clicked), NULL);

	apply_prefs(0);

	gtk_main();
	uninit_libnotify();
	alsa_close();
	return 0;
}
Exemplo n.º 24
0
/*!
  \brief main() is the typical main function in a C program, it performs
  all core initialization, loading of all main parameters, initializing handlers
  and entering gtk_main to process events until program close
  \param argc is the count of command line arguments
  \param argv is the array of command line args
  \returns TRUE
  */
gint main(gint argc, gchar ** argv)
{
	Serial_Params *serial_params = NULL;
	GAsyncQueue *queue = NULL;
	GTimer *timer = NULL;
	GCond *rtv_thread_cond = NULL;
	GMutex *dash_mutex = NULL;
	GMutex *rtt_mutex = NULL;
	GMutex *rtv_mutex = NULL;
	GMutex *rtv_thread_mutex = NULL;
	GMutex *serio_mutex = NULL;
	gint id = 0;
	setlocale(LC_ALL,"");
#ifdef __WIN32__
	bindtextdomain(PACKAGE, "C:\\Program Files\\MegaTunix\\dist\\locale");
#else
	bindtextdomain(PACKAGE, LOCALEDIR);
#endif
	textdomain (PACKAGE);

#ifdef DEBUG
	printf("This is a debug release, Git hash: %s\n",GIT_HASH);
#endif
	// Not needed?
//	gdk_threads_init();
	gtk_init(&argc, &argv);
	glade_init();

	/* Check if OpenGL is supported. */
	if (gdk_gl_query() == FALSE) {
		g_print("OpenGL not supported\n");
		return 0;
	}
	else
		gl_ability = TRUE;

//	gdk_gl_init_check(&argc, &argv);
//	gl_ability = gtk_gl_init_check(&argc, &argv);

	global_data = g_new0(gconstpointer, 1);

	/* Condition Variables */
	rtv_thread_cond = g_new0(GCond,1);
	g_cond_init(rtv_thread_cond);
	DATA_SET(global_data,"rtv_thread_cond",rtv_thread_cond);
	/* Mutexes */
	dash_mutex = g_new0(GMutex, 1);
	g_mutex_init(dash_mutex);
	DATA_SET(global_data,"dash_mutex",dash_mutex);
	rtt_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtt_mutex);
	DATA_SET(global_data,"rtt_mutex",rtt_mutex);
	rtv_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtv_mutex);
	DATA_SET(global_data,"rtv_mutex",rtv_mutex);
	rtv_thread_mutex = g_new0(GMutex, 1);
	g_mutex_init(rtv_thread_mutex);
	DATA_SET(global_data,"rtv_thread_mutex",rtv_thread_mutex);
	serio_mutex = g_new0(GMutex, 1);
	g_mutex_init(serio_mutex);
	DATA_SET(global_data,"serio_mutex",serio_mutex);

	/* For testing if gettext works
	   printf(_("Hello World!\n"));
	 */

	/* Build table of strings to enum values */
	build_string_2_enum_table();
	serial_params = (Serial_Params *)g_malloc0(sizeof(Serial_Params));
	DATA_SET(global_data,"serial_params",serial_params);

	handle_args(argc,argv);	/* handle CLI arguments */

	/* This will exit mtx if the locking fails! */
	/* Prevents multiple instances  but stops esoteric usess too 
	 * create_mtx_lock();
	 * */
	open_debug();		/* Open debug log */

	ENTER();
	/* Allocate memory  */
	init();			/* Initialize global vars */
	make_mtx_dirs();	/* Create config file dirs if missing */

	/* Create Message passing queues */
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_data_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"slave_msg_queue",queue,g_async_queue_unref);
	queue = g_async_queue_new();
	DATA_SET_FULL(global_data,"io_repair_queue",queue,g_async_queue_unref);

	read_config();
	setup_gui();		

	gtk_rc_parse_string("style \"override\"\n{\n\tGtkTreeView::horizontal-separator = 0\n\tGtkTreeView::vertical-separator = 0\n}\nwidget_class \"*\" style \"override\"");

	/* This doesn't do any GUI stuff so can run as is... */
	id = g_timeout_add(2000,(GSourceFunc)flush_binary_logs,NULL);
    DATA_SET(global_data,"binlog_flush_id",GINT_TO_POINTER(id));

	sleep_calib();
	/* Check for first_time flag, if so, run first time wizard, otherwise
	   load personality choice
	   */
	timer = g_timer_new();
	DATA_SET_FULL(global_data,"mtx_uptime_timer",timer,g_timer_destroy);
	g_idle_add((GSourceFunc)check_for_first_time,NULL);
	
	DATA_SET(global_data,"ready",GINT_TO_POINTER(TRUE));

	gdk_threads_enter();
	gtk_main();
	gdk_threads_leave();
	EXIT();
	return (0);
}
Exemplo n.º 25
0
int
main (int argc, char **argv)
{
	GtkBuilder *builder;
	char       *uifile;
	char       *applets_dir;
	GError     *error;

	bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);

	error = NULL;
	if (!gtk_init_with_args (&argc, &argv,
				 "", (GOptionEntry *) options, GETTEXT_PACKAGE,
				 &error)) {
		if (error) {
			g_printerr ("%s\n", error->message);
			g_error_free (error);
		} else
			g_printerr ("Cannot initiliaze GTK+.\n");

		return 1;
	}

	panel_modules_ensure_loaded ();

	if (g_file_test ("../libmate-panel-applet", G_FILE_TEST_IS_DIR)) {
		applets_dir = g_strdup_printf ("%s:../libmate-panel-applet", MATE_PANEL_APPLETS_DIR);
		g_setenv ("MATE_PANEL_APPLETS_DIR", applets_dir, FALSE);
		g_free (applets_dir);
	}

	if (cli_iid) {
		load_applet_from_command_line ();
		gtk_main ();
		panel_cleanup_do ();

		return 0;
	}

	builder = gtk_builder_new ();
	gtk_builder_set_translation_domain (builder, GETTEXT_PACKAGE);

	uifile = BUILDERDIR "/panel-test-applets.ui";
	gtk_builder_add_from_file (builder, uifile, &error);

	if (error) {
		g_warning ("Error loading \"%s\": %s", uifile, error->message);
		g_error_free (error);
		panel_cleanup_do ();

		return 1;
	}

	gtk_builder_connect_signals (builder, NULL);

	win             = GTK_WIDGET (gtk_builder_get_object (builder,
							      "toplevel"));
	applet_combo    = GTK_WIDGET (gtk_builder_get_object (builder,
							      "applet-combo"));
	prefs_path_entry = GTK_WIDGET (gtk_builder_get_object (builder,
							      "prefs-path-entry"));
	orient_combo    = GTK_WIDGET (gtk_builder_get_object (builder,
							      "orient-combo"));
	size_combo      = GTK_WIDGET (gtk_builder_get_object (builder,
							      "size-combo"));
	g_object_unref (builder);

	setup_options ();

	gtk_widget_show (win);

	gtk_main ();

	panel_cleanup_do ();

	return 0;
}
Exemplo n.º 26
0
int main(int argc, char **argv)  {
	int optval = 1;
	int print_help = 0;
	int send_packets = 5;
	int fastmode = 0;
	int c;
	struct sockaddr_in si_me;
	struct mt_packet packet;
	int i;

	setlocale(LC_ALL, "");
	bindtextdomain("mactelnet","/usr/share/locale");
	textdomain("mactelnet");

	while (1) {
		c = getopt(argc, argv, "fs:c:hv?");

		if (c == -1) {
			break;
		}

		switch (c) {
			case 'f':
				fastmode = 1;
				break;

			case 's':
				ping_size = atoi(optarg) - 18;
				break;

			case 'v':
				print_version();
				exit(0);
				break;

			case 'c':
				send_packets = atoi(optarg);
				break;

			case 'h':
			case '?':
				print_help = 1;
				break;

		}
	}

	/* We don't want people to use this for the wrong reasons */
	if (fastmode && (send_packets == 0 || send_packets > 100)) {
		fprintf(stderr, _("Number of packets to send must be more than 0 and less than 100 in fast mode.\n"));
		return 1;
	}

	if (argc - optind < 1 || print_help) {
		print_version();
		fprintf(stderr, _("Usage: %s <MAC> [-h] [-f] [-c <count>] [-s <packet size>]\n"), argv[0]);

		if (print_help) {
			fprintf(stderr, _("\nParameters:\n"
			"  MAC       MAC-Address of the RouterOS/mactelnetd device.\n"
			"  -f        Fast mode, do not wait before sending next ping request.\n"
			"  -s        Specify size of ping packet.\n"
			"  -c        Number of packets to send. (0 = unlimited)\n"
			"  -h        This help.\n"
			"\n"));
		}
		return 1;
	}

	if (ping_size > ETH_FRAME_LEN - 42) {
		fprintf(stderr, _("Packet size must be between 18 and %d\n"), ETH_FRAME_LEN - 42 + 18);
		exit(1);
	}

	/* Mikrotik RouterOS does not answer unless the packet has the correct recipient mac-address in
	 * the ethernet frame. Unlike real MacTelnet connections where the OS is ok with it being a
	 * broadcast mac address.
	 */
	if (geteuid() != 0) {
		fprintf(stderr, _("You need to have root privileges to use %s.\n"), argv[0]);
		return 1;
	}

	/* Get mac-address from string, or check for hostname via mndp */
	if (!query_mndp_or_mac(argv[optind], dstmac, 1)) {
		/* No valid mac address found, abort */
		return 1;
	}

	sockfd = net_init_raw_socket();

	insockfd = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
	if (insockfd < 0) {
		perror("insockfd");
		return 1;
	}

	/* Set initialize address/port */
	memset((char *) &si_me, 0, sizeof(si_me));
	si_me.sin_family = AF_INET;
	si_me.sin_port = htons(MT_MACTELNET_PORT);
	si_me.sin_addr.s_addr = htonl(INADDR_ANY);

	setsockopt(insockfd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (optval));

	/* Bind to specified address/port */
	if (bind(insockfd, (struct sockaddr *)&si_me, sizeof(si_me))==-1) {
		fprintf(stderr, _("Error binding to %s:%d\n"), inet_ntoa(si_me.sin_addr), MT_MNDP_PORT);
		return 1;
	}

	/* Listen address*/
	inet_pton(AF_INET, (char *)"0.0.0.0", &sourceip);

	/* Set up global info about the connection */
	inet_pton(AF_INET, (char *)"255.255.255.255", &destip);

	srand(time(NULL));

	/* Enumerate available interfaces */
	net_get_interfaces(&interfaces);

	if (ping_size < sizeof(struct timeval)) {
		ping_size = sizeof(struct timeval);
	}

	signal(SIGINT, display_results);

	for (i = 0; i < send_packets || send_packets == 0; ++i) {
		fd_set read_fds;
		static struct timeval lasttimestamp;
		int reads, result;
		struct timeval timeout;
		int ii;
		int sent = 0;
		int waitforpacket;
		struct timeval timestamp;
		unsigned char pingdata[1500];
		struct net_interface *interface;

		gettimeofday(&timestamp, NULL);
		memcpy(pingdata, &timestamp, sizeof(timestamp));
		for (ii = sizeof(timestamp); ii < ping_size; ++ii) {
			pingdata[ii] = rand() % 256;
		}

		LL_FOREACH(interfaces, interface) {
			if (!interface->has_mac) {
				continue;
			}

			init_pingpacket(&packet, interface->mac_addr, dstmac);
			add_packetdata(&packet, pingdata, ping_size);
			result = net_send_udp(sockfd, interface, interface->mac_addr, dstmac, &sourceip, MT_MACTELNET_PORT, &destip, MT_MACTELNET_PORT, packet.data, packet.size);

			if (result > 0) {
				sent++;
			}

		}
		if (sent == 0) {
			fprintf(stderr, _("Error sending packet.\n"));
			continue;
		}
		ping_sent++;

		FD_ZERO(&read_fds);
		FD_SET(insockfd, &read_fds);

		timeout.tv_sec = 1;
		timeout.tv_usec = 0;

		waitforpacket = 1;

		while (waitforpacket) {
			/* Wait for data or timeout */
			reads = select(insockfd+1, &read_fds, NULL, NULL, &timeout);
			if (reads <= 0) {
				waitforpacket = 0;
				fprintf(stderr, _("%s ping timeout\n"), ether_ntoa((struct ether_addr *)&dstmac));
				break;
			}

			unsigned char buff[1500];
			struct sockaddr_in saddress;
			unsigned int slen = sizeof(saddress);
			struct mt_mactelnet_hdr pkthdr;

			result = recvfrom(insockfd, buff, 1500, 0, (struct sockaddr *)&saddress, &slen);
			parse_packet(buff, &pkthdr);

			/* TODO: Check that we are the receiving host */
			if (pkthdr.ptype != MT_PTYPE_PONG) {
				/* Wait for the correct packet */
				continue;
			}
			
			struct timeval pongtimestamp;
			struct timeval nowtimestamp;

			waitforpacket = 0;
			gettimeofday(&nowtimestamp, NULL);

			memcpy(&pongtimestamp, pkthdr.data - 4, sizeof(pongtimestamp));
			if (memcmp(pkthdr.data - 4, pingdata, ping_size) == 0) {
				float diff = toddiff(&nowtimestamp, &pongtimestamp) / 1000.0f;

				if (diff < min_ms) {
					min_ms = diff;
				}

				if (diff > max_ms) {
					max_ms = diff;
				}

				avg_ms += diff;

				printf(_("%s %d byte, ping time %.2f ms%s\n"), ether_ntoa((struct ether_addr *)&(pkthdr.srcaddr)), result, diff, (char *)(memcmp(&pongtimestamp,&lasttimestamp,sizeof(lasttimestamp)) == 0 ? " DUP" : ""));
			} else {
				printf(_("%s Reply of %d bytes of unequal data\n"), ether_ntoa((struct ether_addr *)&(pkthdr.srcaddr)), result);
			}
			pong_received++;
			memcpy(&lasttimestamp, &pongtimestamp, sizeof(pongtimestamp));
			if (!fastmode) {
				sleep(1);
			}
		}
	}

	/* Display statistics and exit */
	display_results();

	return 0;
}
Exemplo n.º 27
0
gint
main (gint argc,
      gchar *argv[])
{
	GError *error = NULL;

#ifdef G_OS_WIN32
	/* Reduce risks */
	{
		typedef BOOL (WINAPI *t_SetDllDirectoryA) (LPCSTR lpPathName);
		t_SetDllDirectoryA p_SetDllDirectoryA;

		p_SetDllDirectoryA = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetDllDirectoryA");
		if (p_SetDllDirectoryA)
			(*p_SetDllDirectoryA) ("");
	}
#ifndef _WIN64
	{
		typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
		t_SetProcessDEPPolicy p_SetProcessDEPPolicy;

		p_SetProcessDEPPolicy = GetProcAddress (GetModuleHandle ("kernel32.dll"), "SetProcessDEPPolicy");
		if (p_SetProcessDEPPolicy)
			(*p_SetProcessDEPPolicy) (PROCESS_DEP_ENABLE | PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION);
	}
#endif

	if (fileno (stdout) != -1 && _get_osfhandle (fileno (stdout)) != -1) {
		/* stdout is fine, presumably redirected to a file or pipe */
	} else {
		typedef BOOL (* WINAPI AttachConsole_t) (DWORD);

		AttachConsole_t p_AttachConsole =
			(AttachConsole_t) GetProcAddress (GetModuleHandle ("kernel32.dll"), "AttachConsole");

		if (p_AttachConsole && p_AttachConsole (ATTACH_PARENT_PROCESS)) {
			freopen ("CONOUT$", "w", stdout);
			dup2 (fileno (stdout), 1);
			freopen ("CONOUT$", "w", stderr);
			dup2 (fileno (stderr), 2);
		}
	}
#endif

	static GOptionEntry entries[] = {
		{ "socket",
		  's',
		  G_OPTION_FLAG_IN_MAIN,
		  G_OPTION_ARG_INT,
		  &socket_id,
		  /* TRANSLATORS: don't translate the terms in brackets */
		  N_("ID of the socket to embed in"),
		  N_("socket") },
		{ G_OPTION_REMAINING, 0, 0, G_OPTION_ARG_STRING_ARRAY, &remaining_args, NULL, NULL },
		{ NULL, 0, 0, 0, NULL, NULL, NULL }
	};

#ifdef ENABLE_NLS
	bindtextdomain (GETTEXT_PACKAGE, PACKAGE_LOCALE_DIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	textdomain (GETTEXT_PACKAGE);
#endif

	setlocale (LC_ALL, NULL);

	if (!gtk_init_with_args (&argc, &argv, NULL, entries, NULL, &error))
		g_error ("%s", error->message);

	if (!g_thread_get_initialized ())
		g_thread_init (NULL);

	e_passwords_init ();
	categories_icon_theme_hack ();

	create_default_shell ();

	gtk_main ();

	return 0;
}
Exemplo n.º 28
0
void __attribute__((constructor)) swh_init() {
	char **port_names;
	LADSPA_PortDescriptor *port_descriptors;
	LADSPA_PortRangeHint *port_range_hints;

#ifdef ENABLE_NLS
#define D_(s) dgettext(PACKAGE, s)
	bindtextdomain(PACKAGE, PACKAGE_LOCALE_DIR);
#else
#define D_(s) (s)
#endif


	xfadeDescriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (xfadeDescriptor) {
		xfadeDescriptor->UniqueID = 1915;
		xfadeDescriptor->Label = "xfade";
		xfadeDescriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		xfadeDescriptor->Name =
		 D_("Crossfade");
		xfadeDescriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		xfadeDescriptor->Copyright =
		 "GPL";
		xfadeDescriptor->PortCount = 7;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(7,
		 sizeof(LADSPA_PortDescriptor));
		xfadeDescriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(7,
		 sizeof(LADSPA_PortRangeHint));
		xfadeDescriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(7, sizeof(char*));
		xfadeDescriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Crossfade */
		port_descriptors[XFADE_XFADE] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[XFADE_XFADE] =
		 D_("Crossfade");
		port_range_hints[XFADE_XFADE].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[XFADE_XFADE].LowerBound = -1;
		port_range_hints[XFADE_XFADE].UpperBound = 1;

		/* Parameters for Input A left */
		port_descriptors[XFADE_INPUTLA] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_INPUTLA] =
		 D_("Input A left");
		port_range_hints[XFADE_INPUTLA].HintDescriptor = 0;

		/* Parameters for Input A right */
		port_descriptors[XFADE_INPUTRA] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_INPUTRA] =
		 D_("Input A right");
		port_range_hints[XFADE_INPUTRA].HintDescriptor = 0;

		/* Parameters for Input B left */
		port_descriptors[XFADE_INPUTLB] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_INPUTLB] =
		 D_("Input B left");
		port_range_hints[XFADE_INPUTLB].HintDescriptor = 0;

		/* Parameters for Input B right */
		port_descriptors[XFADE_INPUTRB] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_INPUTRB] =
		 D_("Input B right");
		port_range_hints[XFADE_INPUTRB].HintDescriptor = 0;

		/* Parameters for Output left */
		port_descriptors[XFADE_OUTPUTL] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_OUTPUTL] =
		 D_("Output left");
		port_range_hints[XFADE_OUTPUTL].HintDescriptor = 0;

		/* Parameters for Output right */
		port_descriptors[XFADE_OUTPUTR] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE_OUTPUTR] =
		 D_("Output right");
		port_range_hints[XFADE_OUTPUTR].HintDescriptor = 0;

		xfadeDescriptor->activate = NULL;
		xfadeDescriptor->cleanup = cleanupXfade;
		xfadeDescriptor->connect_port = connectPortXfade;
		xfadeDescriptor->deactivate = NULL;
		xfadeDescriptor->instantiate = instantiateXfade;
		xfadeDescriptor->run = runXfade;
		xfadeDescriptor->run_adding = runAddingXfade;
		xfadeDescriptor->set_run_adding_gain = setRunAddingGainXfade;
	}

	xfade4Descriptor =
	 (LADSPA_Descriptor *)malloc(sizeof(LADSPA_Descriptor));

	if (xfade4Descriptor) {
		xfade4Descriptor->UniqueID = 1917;
		xfade4Descriptor->Label = "xfade4";
		xfade4Descriptor->Properties =
		 LADSPA_PROPERTY_HARD_RT_CAPABLE;
		xfade4Descriptor->Name =
		 D_("Crossfade (4 outs)");
		xfade4Descriptor->Maker =
		 "Steve Harris <*****@*****.**>";
		xfade4Descriptor->Copyright =
		 "GPL";
		xfade4Descriptor->PortCount = 9;

		port_descriptors = (LADSPA_PortDescriptor *)calloc(9,
		 sizeof(LADSPA_PortDescriptor));
		xfade4Descriptor->PortDescriptors =
		 (const LADSPA_PortDescriptor *)port_descriptors;

		port_range_hints = (LADSPA_PortRangeHint *)calloc(9,
		 sizeof(LADSPA_PortRangeHint));
		xfade4Descriptor->PortRangeHints =
		 (const LADSPA_PortRangeHint *)port_range_hints;

		port_names = (char **)calloc(9, sizeof(char*));
		xfade4Descriptor->PortNames =
		 (const char **)port_names;

		/* Parameters for Crossfade */
		port_descriptors[XFADE4_XFADE] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_CONTROL;
		port_names[XFADE4_XFADE] =
		 D_("Crossfade");
		port_range_hints[XFADE4_XFADE].HintDescriptor =
		 LADSPA_HINT_BOUNDED_BELOW | LADSPA_HINT_BOUNDED_ABOVE | LADSPA_HINT_DEFAULT_0;
		port_range_hints[XFADE4_XFADE].LowerBound = -1;
		port_range_hints[XFADE4_XFADE].UpperBound = 1;

		/* Parameters for Input A left */
		port_descriptors[XFADE4_INPUTLA] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_INPUTLA] =
		 D_("Input A left");
		port_range_hints[XFADE4_INPUTLA].HintDescriptor = 0;

		/* Parameters for Input A right */
		port_descriptors[XFADE4_INPUTRA] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_INPUTRA] =
		 D_("Input A right");
		port_range_hints[XFADE4_INPUTRA].HintDescriptor = 0;

		/* Parameters for Input B left */
		port_descriptors[XFADE4_INPUTLB] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_INPUTLB] =
		 D_("Input B left");
		port_range_hints[XFADE4_INPUTLB].HintDescriptor = 0;

		/* Parameters for Input B right */
		port_descriptors[XFADE4_INPUTRB] =
		 LADSPA_PORT_INPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_INPUTRB] =
		 D_("Input B right");
		port_range_hints[XFADE4_INPUTRB].HintDescriptor = 0;

		/* Parameters for Output A left */
		port_descriptors[XFADE4_OUTPUTLA] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_OUTPUTLA] =
		 D_("Output A left");
		port_range_hints[XFADE4_OUTPUTLA].HintDescriptor = 0;

		/* Parameters for Output A right */
		port_descriptors[XFADE4_OUTPUTRA] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_OUTPUTRA] =
		 D_("Output A right");
		port_range_hints[XFADE4_OUTPUTRA].HintDescriptor = 0;

		/* Parameters for Output B left */
		port_descriptors[XFADE4_OUTPUTLB] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_OUTPUTLB] =
		 D_("Output B left");
		port_range_hints[XFADE4_OUTPUTLB].HintDescriptor = 0;

		/* Parameters for Output B right */
		port_descriptors[XFADE4_OUTPUTRB] =
		 LADSPA_PORT_OUTPUT | LADSPA_PORT_AUDIO;
		port_names[XFADE4_OUTPUTRB] =
		 D_("Output B right");
		port_range_hints[XFADE4_OUTPUTRB].HintDescriptor = 0;

		xfade4Descriptor->activate = NULL;
		xfade4Descriptor->cleanup = cleanupXfade4;
		xfade4Descriptor->connect_port = connectPortXfade4;
		xfade4Descriptor->deactivate = NULL;
		xfade4Descriptor->instantiate = instantiateXfade4;
		xfade4Descriptor->run = runXfade4;
		xfade4Descriptor->run_adding = runAddingXfade4;
		xfade4Descriptor->set_run_adding_gain = setRunAddingGainXfade4;
	}
}
Exemplo n.º 29
0
int
main (int argc, char *argv[])
{

        gboolean              res;
        GError               *error;

        manager = NULL;

        if (!g_thread_supported ()) {
                g_thread_init (NULL);
        }

        gnome_settings_profile_start (NULL);

        bindtextdomain (GETTEXT_PACKAGE, GNOME_SETTINGS_LOCALEDIR);
        bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
        textdomain (GETTEXT_PACKAGE);
        setlocale (LC_ALL, "");

        parse_args (&argc, &argv);

        g_type_init ();

        gnome_settings_profile_start ("opening gtk display");
        if (! gtk_init_check (NULL, NULL)) {
                g_warning ("Unable to initialize GTK+");
                exit (EXIT_FAILURE);
        }
        gnome_settings_profile_end ("opening gtk display");

        g_log_set_default_handler (gsd_log_default_handler, NULL);

        notify_init ("gnome-settings-daemon");

        bus_register ();

        gnome_settings_profile_start ("gnome_settings_manager_new");
        manager = gnome_settings_manager_new ();
        gnome_settings_profile_end ("gnome_settings_manager_new");
        if (manager == NULL) {
                g_warning ("Unable to register object");
                goto out;
        }

        /* If we aren't started by dbus then load the plugins
           automatically.  Otherwise, wait for an Awake etc. */
        if (g_getenv ("DBUS_STARTER_BUS_TYPE") == NULL) {
                error = NULL;
                res = gnome_settings_manager_start (manager, &error);
                if (! res) {
                        g_warning ("Unable to start: %s", error->message);
                        g_error_free (error);
                        goto out;
                }
        }

        if (do_timed_exit) {
                g_timeout_add_seconds (30, (GSourceFunc) timed_exit_cb, NULL);
        }

        gtk_main ();

        g_debug ("Shutting down");

out:
        if (name_id > 0) {
                g_bus_unown_name (name_id);
                name_id = 0;
        }

        if (manager != NULL) {
                g_object_unref (manager);
        }

        g_debug ("SettingsDaemon finished");
        gnome_settings_profile_end (NULL);

        return 0;
}
int
main (int argc, char *argv[])
{
	GOptionContext *opt_ctx;
	GError *error = NULL;
	NMConnectionList *list;
	DBusGConnection *bus;
	char *type = NULL;
	gboolean create = FALSE;
	gboolean show = FALSE;
	gboolean success;
	char *uuid = NULL;
	NMCEService *service = NULL;
	DBusGProxy *proxy = NULL;
	gboolean show_list;

	GOptionEntry entries[] = {
		{ ARG_TYPE,   't', 0, G_OPTION_ARG_STRING, &type,   "Type of connection to show or create", NM_SETTING_WIRED_SETTING_NAME },
		{ ARG_CREATE, 'c', 0, G_OPTION_ARG_NONE,   &create, "Create a new connection", NULL },
		{ ARG_SHOW,   's', 0, G_OPTION_ARG_NONE,   &show,   "Show a given connection type page", NULL },
		{ "edit",     'e', 0, G_OPTION_ARG_STRING, &uuid,   "Edit an existing connection with a given UUID", "UUID" },
		{ NULL }
	};

	bindtextdomain (GETTEXT_PACKAGE, NMALOCALEDIR);
	bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
	gtk_init (&argc, &argv);
	textdomain (GETTEXT_PACKAGE);

	opt_ctx = g_option_context_new (NULL);
	g_option_context_set_summary (opt_ctx, "Allows users to view and edit network connection settings");
	g_option_context_add_main_entries (opt_ctx, entries, NULL);
	success = g_option_context_parse (opt_ctx, &argc, &argv, &error);
	g_option_context_free (opt_ctx);

	if (!success) {
		g_warning ("%s\n", error->message);
		g_error_free (error);
		return 1;
	}

	/* Just one page for both CDMA & GSM, handle that here */
	if (type && g_strcmp0 (type, NM_SETTING_CDMA_SETTING_NAME) == 0)
		type = (char *) NM_SETTING_GSM_SETTING_NAME;

	/* Inits the dbus-glib type system too */
	bus = dbus_g_bus_get (DBUS_BUS_SESSION, NULL);
	if (bus) {
		proxy = dbus_g_proxy_new_for_name (bus,
		                                   "org.freedesktop.DBus",
		                                   "/org/freedesktop/DBus",
		                                   "org.freedesktop.DBus");
		g_assert (proxy);

		/* Check for an existing instance on the bus, and if there
		 * is one, send the arguments to it and exit instead of opening
		 * a second instance of the connection editor.
		 */
		if (try_existing_instance (bus, proxy, type, create, show, uuid))
			return 0;
	}

	loop = g_main_loop_new (NULL, FALSE);

	list = nm_connection_list_new ();
	if (!list) {
		g_warning ("Failed to initialize the UI, exiting...");
		return 1;
	}
	g_signal_connect_swapped (list, "done", G_CALLBACK (g_main_loop_quit), loop);

	/* Create our single-instance-app service if we can */
	if (proxy)
		service = nm_ce_service_new (bus, proxy, list);

	/* Show the dialog */
	g_signal_connect_swapped (list, "done", G_CALLBACK (g_main_loop_quit), loop);

	/* Figure out what page or editor window we'll show initially */
	show_list = handle_arguments (list, type, create, show, uuid, (create || show || uuid));
	if (show_list)
		nm_connection_list_present (list);

	setup_signals ();
	g_main_loop_run (loop);

	/* Cleanup */
	g_object_unref (list);
	if (service)
		g_object_unref (service);
	if (proxy)
		g_object_unref (proxy);
	if (bus)
		dbus_g_connection_unref (bus);
	return 0;
}