<commit_before>/*  
    main.c:

    Copyright (C) 1991-2002 <NAME>, <NAME>

    This file is part of Csound.

    The Csound Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    Csound is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Csound; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

#include "cs.h"                 /*                               MAIN.C */
#include "soundio.h"
#include <ctype.h>              /* For isdigit */

extern void remove_tmpfiles(void);      /* IV - Oct 31 2002 */
extern void add_tmpfile(char*);

#ifdef mills_macintosh
#include <SIOUX.h>
#include "perf.h"
#include"MacTransport.h"

#define PATH_LEN        128

extern struct Transport transport;
extern Boolean displayText;

extern char sfdir_path[];
extern char sadir_path[];
extern char ssdir_path[];
extern char saved_scorename[];
extern unsigned char mytitle[];
extern Boolean util_perf;
static char *foo;
static char listing_file[PATH_LEN];
static int  vbuf;
static int csNGraphs;
static MYFLT temp;
extern int RescaleFloatFile;
#endif

static  char    *sortedscore = NULL;
static  char    *xtractedscore = "score.xtr";
static  char    scnm[255];
static  char    nme[255];
static  char    *playscore = NULL;     /* unless we extract */
static  FILE    *scorin, *scorout, *xfile;
extern  void    dieu(char *);
extern  OPARMS  O;
extern  ENVIRON cenviron;
extern int argdecode(int, char**, char**, char*);
extern void init_pvsys(void);
extern int csoundYield(void *);

#include <signal.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#if defined(LINUX)
#include <sys/types.h>
#include <errno.h>
#include <sched.h>
#include <sys/mman.h>

void csoundMessage(void *, const char *, ...);

void set_rt_priority(int argc, char **argv)
{
    int     rtmode;
    struct sched_param p;
    int     i;

    if (geteuid() != 0) return;    /* not root, nothing to do */

    rtmode = 0;
    if (argc > 2) {
      for (i = 1; i <= (argc - 2); i++) {
        if (!(strcmp (argv[i], "-o")) &&                    /* check if     */
            (!(strcmp (argv[i + 1], "dac")) ||              /* output is    */
             !(strcmp (argv[i + 1], "devaudio"))))          /* audio device */
          rtmode |= 2;
      }
    }
    if (argc > 1) {
      for (i = 1; i <= (argc - 1); i++) {                   /* also check  */
        if (!(strcmp (argv[i], "--sched"))) rtmode |= 1;    /* for --sched */
        if (!(strcmp (argv[i], "-d"))) rtmode |= 4;         /* option, and */
      }                                                     /* -d          */
    }

    if (rtmode != 7) {          /* all the above are required to enable */
      setuid(getuid());         /* give up root permissions */
      if (rtmode & 1) {
        fprintf (stderr, "csound: --sched requires -d and either -o dac ");
        fprintf (stderr, "or -o devaudio\n");
        exit (-1);
      }
      return;
    }

#ifndef __FreeBSD__
    /* lock all pages into physical memory */
    if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
      err_printf( "csound: cannot lock memory pages: %s\n",
                       strerror(errno));
      exit(-1);
    }
#endif<commit_msg>changed strcmp to strncmp for searching for dac or devaudio so that on linux --sched can work even when passing device numbers to port audio<commit_after>/*  
    main.c:

    Copyright (C) 1991-2002 <NAME>, <NAME>

    This file is part of Csound.

    The Csound Library is free software; you can redistribute it
    and/or modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    Csound is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Csound; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
    02111-1307 USA
*/
#if defined(HAVE_CONFIG_H)
#include "config.h"
#endif

#include "cs.h"                 /*                               MAIN.C */
#include "soundio.h"
#include <ctype.h>              /* For isdigit */

extern void remove_tmpfiles(void);      /* IV - Oct 31 2002 */
extern void add_tmpfile(char*);

#ifdef mills_macintosh
#include <SIOUX.h>
#include "perf.h"
#include"MacTransport.h"

#define PATH_LEN        128

extern struct Transport transport;
extern Boolean displayText;

extern char sfdir_path[];
extern char sadir_path[];
extern char ssdir_path[];
extern char saved_scorename[];
extern unsigned char mytitle[];
extern Boolean util_perf;
static char *foo;
static char listing_file[PATH_LEN];
static int  vbuf;
static int csNGraphs;
static MYFLT temp;
extern int RescaleFloatFile;
#endif

static  char    *sortedscore = NULL;
static  char    *xtractedscore = "score.xtr";
static  char    scnm[255];
static  char    nme[255];
static  char    *playscore = NULL;     /* unless we extract */
static  FILE    *scorin, *scorout, *xfile;
extern  void    dieu(char *);
extern  OPARMS  O;
extern  ENVIRON cenviron;
extern int argdecode(int, char**, char**, char*);
extern void init_pvsys(void);
extern int csoundYield(void *);

#include <signal.h>

#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif

#if defined(LINUX)
#include <sys/types.h>
#include <errno.h>
#include <sched.h>
#include <sys/mman.h>

void csoundMessage(void *, const char *, ...);

void set_rt_priority(int argc, char **argv)
{
    int     rtmode;
    struct sched_param p;
    int     i;

    if (geteuid() != 0) return;    /* not root, nothing to do */

    rtmode = 0;
    if (argc > 2) {
      for (i = 1; i <= (argc - 2); i++) {
        if (!(strcmp (argv[i], "-o")) &&                    /* check if     */
            (!(strncmp (argv[i + 1], "dac", 3)) ||              /* output is    */
             !(strncmp (argv[i + 1], "devaudio", 8))))          /* audio device */
          rtmode |= 2;
      }
    }
    if (argc > 1) {
      for (i = 1; i <= (argc - 1); i++) {                   /* also check  */
        if (!(strcmp (argv[i], "--sched"))) rtmode |= 1;    /* for --sched */
        if (!(strcmp (argv[i], "-d"))) rtmode |= 4;         /* option, and */
      }                                                     /* -d          */
    }

    if (rtmode != 7) {          /* all the above are required to enable */
      setuid(getuid());         /* give up root permissions */
      if (rtmode & 1) {
        fprintf (stderr, "csound: --sched requires -d and either -o dac ");
        fprintf (stderr, "or -o devaudio\n");
        exit (-1);
      }
      return;
    }

#ifndef __FreeBSD__
    /* lock all pages into physical memory */
    if (mlockall(MCL_CURRENT | MCL_FUTURE) != 0) {
      err_printf( "csound: cannot lock memory pages: %s\n",
                       strerror(errno));
      exit(-1);
    }
#endif
{'fraction_non_alphanumeric': 0.12197356366967674, 'fraction_numerical': 0.015181258997513415, 'mean_word_length': 2.2756108015430776, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1002459', 'n_tokens_mistral': 2501, 'n_tokens_neox': 2355, 'n_words': 857}