Пример #1
0
/* doesn't really belong here, but I couldn't figure out where else */
void 
do_page(dbref player, const char *arg1, const char *arg2)
{
    int     ignored;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];
    dbref   target;

    if (!payfor(player, tp_lookup_cost)) {
	anotify_fmt(player, CFAIL "You don't have enough %s.", tp_pennies);
	return;
    }
    if ( strcmp(arg1, "me") ) {
	if ((target = lookup_player(arg1)) == NOTHING) {
	    anotify(player, CINFO WHO_MESG);
	    return;
	}
    } else target = player;

    if(Guest(player)) {
	if(!Mage(target)) {
	    anotify(player, CINFO "Guests can only page " NAMEWIZ "s, type 'wizzes'.");
	    return;
	}
    }

    if (FLAGS(target) & HAVEN) {
	anotify(player, CFAIL "That player is haven.");
	return;
    }

    ignored = ignoring(target, player);
    if(ignored == 1) {
	anotify(player, CFAIL "That player is ignoring you.");
	return;
    } else if(ignored == 2) {
	anotify(player, CINFO "That player is ignoring you.");
    }

    do_parse_mesg(player, player, arg2, "(page)", buf, MPI_ISPRIVATE);
    tct(buf,buf2);

    if (!*buf2) {
	sprintf(buf, CGREEN "You sense that %s is looking for you in %s.",
			PNAME(player), NAME(DBFETCH(player)->location));
    } else {
	if(buf2[0] == ':' || buf2[0] == ';') {
	    sprintf(buf, CGREEN "%s pages \"" CYELLOW "%s %.3900s" CGREEN "\"",
			PNAME(player), PNAME(player), buf2);
	} else {
	    sprintf(buf, CGREEN "%s pages \"" CYELLOW "%.3900s" CGREEN "\"",
			PNAME(player), buf2);
	}
    }
    if (anotify_from(player, target, buf))
	anotify(player, CSUCC "Your message has been sent.");
    else {
	sprintf(buf, CINFO "%s is not connected.", PNAME(target));
	anotify(player, buf);
    }
}
Пример #2
0
/* doesn't really belong here, but I couldn't figure out where else */
void
do_page(int descr, dbref player, const char *arg1, const char *arg2)
{
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];
    dbref target;

    if (!payfor(player, tp_lookup_cost)) {
        anotify_fmt(player, CFAIL "You don't have enough %s.", tp_pennies);
        return;
    }
    if (strcmp(arg1, "me")) {
        if ((target = lookup_player(arg1)) == NOTHING) {
            anotify_nolisten2(player, CINFO "Who?");
            return;
        }
    } else
        target = player;

    if (Guest(player)) {
        if (!Mage(target)) {
            anotify_nolisten2(player,
                              CINFO
                              "Guests can only page wizards, type 'wizzes'.");
            return;
        }
    }

    if (FLAGS(target) & HAVEN) {
        anotify_nolisten2(player, CFAIL "That player is haven.");
        return;
    }
    if (Meeper(OWNER(player))) {
        do_parse_mesg(descr, player, player, arg2, "(page)", buf,
                      MPI_ISPRIVATE);
        tct(buf, buf2);
    } else {
        tct(arg2, buf2);
    }

    if (!*buf2) {
        sprintf(buf, CSUCC "You sense that %s is looking for you in %s.",
                PNAME(player), NAME(DBFETCH(player)->location));
    } else {
        if (buf2[0] == ':' || buf2[0] == ';') {
            sprintf(buf, SYSGREEN "%s pages \"" SYSYELLOW "%s %s" SYSGREEN "\"",
                    PNAME(player), PNAME(player), buf2);
        } else {
            sprintf(buf, SYSGREEN "%s pages \"" SYSYELLOW "%s" SYSGREEN "\"",
                    PNAME(player), buf2);
        }
    }
    if (anotify_from(player, target, buf))
        anotify_nolisten2(player, CSUCC "Your message has been sent.");
    else {
        sprintf(buf, CSUCC "%s is not connected.", PNAME(target));
        anotify_nolisten2(player, buf);
    }
}
Пример #3
0
const char *
unparse_object(dbref player, dbref loc)
{
    static char buf[BUFFER_LEN];

    if (Typeof(player) != TYPE_PLAYER)
	player = OWNER(player);
    switch (loc) {
	case NOTHING:
	    return "*NOTHING*";
	case AMBIGUOUS:
	    return "*AMBIGUOUS*";
	case HOME:
	    return "*HOME*";
	default:
	    if (loc < 0 || loc > db_top)
#ifdef SANITY
	    {
	        sprintf(buf, "*INVALID*(#%d)", loc);
	        return buf;
	    }
#else
		return "*INVALID*";
#endif
#ifndef SANITY
	    if (!(FLAGS(player) & STICKY) &&
		    (can_link_to(player, NOTYPE, loc) ||
		     ((Typeof(loc) != TYPE_PLAYER) &&
		      (controls_link(player, loc) ||
		       (FLAGS(loc) & CHOWN_OK)))
		    )) {
		/* show everything */
#endif
		sprintf(buf, "%s(#%d%s)", PNAME(loc), loc, unparse_flags(loc));
		return buf;
#ifndef SANITY
	    } else {
		/* show only the name */
		return PNAME(loc);
	    }
#endif
    }
}
Пример #4
0
void
do_pose(int descr, dbref player, const char *message)
{
    dbref loc;
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];

    if ((loc = getloc(player)) == NOTHING)
        return;
    tct(message, buf2);
    /* notify everybody */
    sprintf(buf, "^SAY/POSE^%s %s", PNAME(player), buf2);
    anotify_except(DBFETCH(loc)->contents, NOTHING, buf, player);
}
Пример #5
0
bool
can_doit(int descr, dbref player, dbref thing,
         const char *default_fail_msg)
{
    dbref loc;

    if ((loc = getloc(player)) == NOTHING)
        return 0;

    if (OkObj(thing)) {
        dbref dest = Typeof(thing) == TYPE_EXIT ? (DBFETCH(thing)->sp.exit.ndest ? DBFETCH(thing)->sp.exit.dest[0] : NOTHING) : NOTHING;

        if (((FLAG2(player) & F2IMMOBILE) && !(FLAG2(thing) & F2IMMOBILE)) &&
            (!OkObj(dest) || Typeof(dest) != TYPE_PROGRAM)
            ) {
            envpropqueue(descr, player, OkObj(player) ? getloc(player) : -1,
                         thing, thing, NOTHING, "@immobile", "Immobile", 1, 1);
            return 0;
        }
    }
    if (!TMage(OWNER(player)) && Typeof(player) == TYPE_THING &&
        (FLAGS(thing) & ZOMBIE)) {
        notify(player, "Sorry, but zombies can't do that.");
        return 0;
    }
    if (!could_doit(descr, player, thing)) {
        /* can't do it */
        if (GETFAIL(thing)) {
            exec_or_notify(descr, player, thing, GETFAIL(thing), "(@Fail)");
        } else if (default_fail_msg) {
            notify(player, default_fail_msg);
        }
        if (GETOFAIL(thing) && !Dark(player)) {
            parse_omessage(descr, player, loc, thing, GETOFAIL(thing),
                           PNAME(player), "(@Ofail)");
        }
        return 0;
    } else {
        /* can do it */
/* I moved these to the 'trigger()' function. -Akari */
/*	if (GETSUCC(thing)) {
	    exec_or_notify(descr, player, thing, GETSUCC(thing), "(@Succ)");
	}
	if (GETOSUCC(thing) && !Dark(player)) {
	    parse_omessage(descr, player, loc, thing, GETOSUCC(thing),
			    NAME(player), "(@Osucc)");
	}
 */
        return 1;
    }
}
Пример #6
0
Файл: s2.cpp Проект: dCache/s2
static void
init_s2(void)
{
  /* s2 options */
  opts.help = 0;			/* 0: no help; 1: basic help; ... */
  opts.ansi = FALSE;			/* use ansi colors */
  opts.verbose = 0;			/* -2: no errors; -1: no warnings; 0: normal; 1: verbose */
  opts.pp_indent = PP_INDENT;		/* pretty-printer indentation value */
  opts.show_defaults = FALSE;		/* show default values (pretty-printer, evaluator) */
  opts.scr_fname = NULL;		/* script filename */
  opts.simple_name = FALSE;		/* whether ${0} has the simple name */
  opts.progress_bar = TRUE;		/* show progres bar */
  opts.pp_fname = NULL;			/* pretty-printer output filename */
  opts.pp_file = PP_DEFAULT_OUTPUT;	/* pretty-printer output file */
  opts.log_fname = NULL;		/* log messages output filename */
  opts.dbg_fname = NULL;		/* debug messages output filename */
  opts.warn_fname = NULL;		/* warning messages output filename */
  opts.err_fname = NULL;		/* error messages output filename */
  opts.e0_fname = NULL;			/* before-execution log messages filename */
  opts.e0_file = E0_DEFAULT_OUTPUT;	/* before-execution log messages file */
  opts.e1_fname = NULL;			/* after-execution log messages filename */
  opts.e1_file = E1_DEFAULT_OUTPUT;	/* after-execution log messages file */
  opts.e2_fname = NULL;			/* after-evaluation log messages filename */
  opts.e2_file = E2_DEFAULT_OUTPUT;	/* after-evaluation log messages file */
  opts.s2_eval = S2_EVAL;		/* default evaluation threshold for branches */
  opts.s2_timeout = S2_TIMEOUT;		/* default timeout for branches in microseconds */
  opts.tp_size = TP_THREADS_DEF;	/* number of threads to use in the thread pool */

  /* diagnose library */
  DM_PGMNAME_SET(PNAME());
  DM_ANSI_SET(opts.ansi);		/* environment variable DM_ANSI takes preference over this */
  DM_LOG_OPEN(opts.log_fname);
  DM_DBG_OPEN(opts.dbg_fname);
  DM_WARN_OPEN(opts.warn_fname);
  DM_ERR_OPEN(opts.err_fname);
  /* no debug (apart 0-level messages), environment variable DG_DBG takes preference over this */
  DM_DBG_SET_L(0);

  /* callback functions */
  DM_WARN_CB(WarnCB);
  DM_ERR_CB(ErrCB);

  /* open output files */
  f_open(opts.pp_fname, &opts.pp_file);
  f_open(opts.e0_fname, &opts.e0_file);
  f_open(opts.e1_fname, &opts.e1_file);
  f_open(opts.e2_fname, &opts.e2_file);

  /* initialise random number generation */
  srandom(gettime_ms() + (getpid() << 16));
}
Пример #7
0
void 
do_pose(dbref player, const char *message)
{
    dbref   loc;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];

    if ((loc = getloc(player)) == NOTHING)
	return;

    do_parse_mesg(player, player, message, "(pose)", buf, MPI_ISPRIVATE);
    tct(buf,buf2);

    /* notify everybody */
    sprintf(buf, CAQUA "%s%s%.3900s", PNAME(player),
		isalpha(buf2[0]) ? " " : "", buf2);
    anotify_except(DBFETCH(loc)->contents, NOTHING, buf, player);
}
Пример #8
0
void
do_say(int descr, dbref player, const char *message)
{
    dbref loc;
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];

    if ((loc = getloc(player)) == NOTHING)
        return;
    tct(message, buf2);
    /* notify everybody */
    sprintf(buf, "^SAY/POSE^You say, ^SAY/QUOTES^\"^SAY/TEXT^%s^SAY/QUOTES^\"",
            buf2);
    anotify(player, buf);

    sprintf(buf, "^SAY/POSE^%s says, ^SAY/QUOTES^\"^SAY/TEXT^%s^SAY/QUOTES^\"",
            PNAME(player), buf2);
    anotify_except(DBFETCH(loc)->contents, player, buf, player);
}
Пример #9
0
void 
do_say(dbref player, const char *message)
{
    dbref   loc;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];

    if ((loc = getloc(player)) == NOTHING)
	return;

    do_parse_mesg(player, player, message, "(say)", buf, MPI_ISPRIVATE);
    tct(buf,buf2);

    /* Notify player */
    sprintf(buf, CAQUA "You say, \"" CYELLOW "%.3900s" CAQUA "\"", buf2);
    anotify(player, buf);

    /* notify everybody else */
    sprintf(buf, CAQUA "%s says, \"" CYELLOW "%.3900s" CAQUA "\"", PNAME(player), buf2);
    anotify_except(DBFETCH(loc)->contents, player, buf, player);
}
Пример #10
0
Файл: s2.cpp Проект: dCache/s2
/********************************************************************
 * Usage function
 ********************************************************************/
static int
usage(int ret_val)
{
  option_item *op;
  const char *PG = PNAME();

  fprintf(stderr, _("Usage: %s [-+"), PG);

  for (op = optionlist; op->short_name != 0; op++)
  {
    if(op->sw == '+') continue;
    putc(op->short_name[0], stderr);
  }

  fprintf(stderr, "] [LONG-OPT]... [SCRIPT_ARGS]\n");

  fprintf(stderr, _("Example: %s --file=eval01.s2\n"), PG);
  fprintf(stderr, _("Type `%s --help' for more information.\n"), PG);

  return ret_val;
}
Пример #11
0
dbref
create_player(const char *name, const char *password)
{
    char buf[80];
    dbref player;

    if (!ok_player_name(name) || !ok_password(password))
        return NOTHING;
    if (!tp_building || tp_db_readonly) return NOTHING;

    /* else he doesn't already exist, create him */
    player = new_object();

    /* initialize everything */
    NAME(player) = alloc_string(name);
    FLAGS(player) = TYPE_PLAYER | PCREATE_FLAGS;
    FLAG2(player) = PCREATE_FLAG2;
    DBFETCH(player)->location = RootRoom;	/* home */
    OWNER(player) = player;
    DBFETCH(player)->sp.player.home = RootRoom;
    DBFETCH(player)->exits = NOTHING;
    DBFETCH(player)->sp.player.pennies = tp_start_pennies;
    DBFETCH(player)->sp.player.password = alloc_string(password);
    DBFETCH(player)->sp.player.curr_prog = NOTHING;
    DBFETCH(player)->sp.player.insert_mode = 0;

    /* link him to tp_player_start */
    PUSH(player, DBFETCH(RootRoom)->contents);
    add_player(player);
    DBDIRTY(player);
    DBDIRTY(RootRoom);

    sprintf(buf, CNOTE "%s is born!", PNAME(player));
    anotify_except(DBFETCH(RootRoom)->contents, NOTHING, buf, player);

    return player;
}
Пример #12
0
#define FNAME parasail_sg_flags_rowcol_scan_avx2_256_64
#define PNAME parasail_sg_flags_rowcol_scan_profile_avx2_256_64
#else
#define FNAME parasail_sg_flags_scan_avx2_256_64
#define PNAME parasail_sg_flags_scan_profile_avx2_256_64
#endif
#endif

parasail_result_t* FNAME(
        const char * const restrict s1, const int s1Len,
        const char * const restrict s2, const int s2Len,
        const int open, const int gap, const parasail_matrix_t *matrix,
        int s1_beg, int s1_end, int s2_beg, int s2_end)
{
    parasail_profile_t *profile = parasail_profile_create_avx_256_64(s1, s1Len, matrix);
    parasail_result_t *result = PNAME(profile, s2, s2Len, open, gap, s1_beg, s1_end, s2_beg, s2_end);
    parasail_profile_free(profile);
    return result;
}

parasail_result_t* PNAME(
        const parasail_profile_t * const restrict profile,
        const char * const restrict s2, const int s2Len,
        const int open, const int gap,
        int s1_beg, int s1_end, int s2_beg, int s2_end)
{
    int32_t i = 0;
    int32_t j = 0;
    int32_t k = 0;
    const int s1Len = profile->s1Len;
    int32_t end_query = s1Len-1;
Пример #13
0
void
do_whisper(int descr, dbref player, const char *arg1, const char *arg2)
{
    dbref who;
    char buf[BUFFER_LEN], buf2[BUFFER_LEN];
    struct match_data md;

    if (Guest(player)) {
        anotify_fmt(player, CFAIL "%s", tp_noguest_mesg);
        return;
    }

    init_match(descr, player, arg1, TYPE_PLAYER, &md);
    match_neighbor(&md);
    match_me(&md);
    if (Mage(player) && Typeof(player) == TYPE_PLAYER) {
        match_absolute(&md);
        match_player(&md);
    }
    switch (who = match_result(&md)) {
        case NOTHING:
            anotify_nolisten2(player, CINFO "Who?");
            break;
        case AMBIGUOUS:
            anotify_nolisten2(player, CINFO "I don't know who you mean!");
            break;
        default:
            if (Meeper(OWNER(player))) {
                do_parse_mesg(descr, player, player, arg2, "(whisper)", buf,
                              MPI_ISPRIVATE);
                tct(buf, buf2);
            } else {
                tct(arg2, buf2);
            }

            if (buf2[0] == ':' || buf2[0] == ';') {
                sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s %s"
                        SYSBLUE "\"", PNAME(player), PNAME(player), buf2 + 1);
                if (!anotify_from(player, who, buf)) {
                    sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who));
                    anotify_nolisten2(player, buf);
                    break;
                }
                sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s %s"
                        SYSBLUE "\" to %s.", PNAME(player), buf2 + 1,
                        PNAME(who));
                anotify(player, buf);
                break;
            } else {
                sprintf(buf, SYSBLUE "%s whispers, \"" SYSPURPLE "%s" SYSBLUE
                        "\"", PNAME(player), buf2);
                if (!anotify_from(player, who, buf)) {
                    sprintf(buf, SYSBLUE "%s is not connected.", PNAME(who));
                    anotify_nolisten2(player, buf);
                    break;
                }
                sprintf(buf, SYSBLUE "You whisper, \"" SYSPURPLE "%s" SYSBLUE
                        "\" to %s.", buf2, PNAME(who));
                anotify(player, buf);
                break;
            }
    }
}
Пример #14
0
Файл: s2.cpp Проект: dCache/s2
/********************************************************************
 * Parse command-line option (global)
 *
 * Parameters:
 *  cfg_file:  TRUE  if called from a configuration file
 *             FALSE if command-line option
 *
 * Returns:
 *  -1: parameter was found (opt doesn't start with -+)
 *   0: option was found
 *   1: option was NOT found
 *   2: an error
 ********************************************************************/
static int
parse_cmd_opt(char *opt, BOOL cfg_file)
{
  option_item *op;
  int opt_off;
  char *p_err;

  if(opt == NULL) {
    /* internal error */
    DM_ERR_ASSERT("opt == NULL\n");
    return 0;
  }

  /* Process the options */

  /* Parameters */
  if (!(*opt == '-' || *opt == '+'))
    return -1;

  if (OPL("-0") || OPL("--e0-file"))
  { /* before-execution log messages filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    f_close(opts.e0_fname, &opts.e0_file);
    opts.e0_fname = opt + opt_off;

    if(strcmp(opts.e0_fname, "-") == 0)
      /* standard output */
      opts.e0_fname = NULL;

    f_open(opts.e0_fname, &opts.e0_file);
    return 0;
  }

  if (OPL("-1") || OPL("--e1-file"))
  { /* after-execution log messages filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    f_close(opts.e1_fname, &opts.e1_file);
    opts.e1_fname = opt + opt_off;

    if(strcmp(opts.e1_fname, "-") == 0)
      /* standard output */
      opts.e1_fname = NULL;

    f_open(opts.e1_fname, &opts.e1_file);
    return 0;
  }

  if (OPL("-2") || OPL("--e2-file"))
  { /* after-evaluation log messages filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    f_close(opts.e2_fname, &opts.e2_file);
    opts.e2_fname = opt + opt_off;

    if(strcmp(opts.e2_fname, "-") == 0)
      /* standard output */
      opts.e2_fname = NULL;

    f_open(opts.e2_fname, &opts.e2_file);
    return 0;
  }

  if (OPL("-a") || OPL("--ansi"))
  { /* ANSI colors */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.ansi = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err) {
      /* no option value given || value contains invalid/non-digit char */
      opts.ansi = TRUE;
    }
    DM_ANSI_SET(opts.ansi);

    return 0;
  }

  if (OPL("-b") || OPL("--verbose"))
  { /* verbose/quiet execution */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.verbose = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err)
      /* no option value given || value contains invalid/non-digit char */
      opts.verbose = 1;

    /* limit verbosity */
    if(opts.verbose > VERBOSE_MAX)
      opts.verbose = VERBOSE_MAX;
    else if(opts.verbose < VERBOSE_MIN)
      opts.verbose = VERBOSE_MIN;

    if(opts.verbose > 0)
      DM_LOG_SET_L((1 << opts.verbose) - 1);

    if(opts.verbose <= -1)
      /* disable warning messages */
      DM_WARN_SET_L(0);

    if(opts.verbose <= -2)
      /* disable error messages */
      DM_ERR_SET_L(0);

    return 0;
  }

  if (OPL("-h") || OPL("-?") || OPL("--help"))
  { /* help */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.help = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err) {
      /* no option value given || value contains invalid/non-digit char */
      opts.help = 0;
    }

//    hlp(opts.help); exit(0);
    hlp(0); /* only level 0 help so far */ exit(0);
    return 0;
  }

  if (OPL("-d") || OPL("--dbg-file"))
  { /* debug messages output filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.dbg_fname = opt + opt_off;
    DM_DBG_OPEN(opts.dbg_fname);     /* old stream is automatically closed */

    return 0;
  }

  if (OPL("-e") || OPL("--eval"))
  { /* default evaluation threshold for branches */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.s2_eval = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err)
      /* no option value given || value contains invalid/non-digit char */
      opts.s2_eval = S2_EVAL;

    return 0;
  }

  if (OPL("-f") || OPL("--file"))
  { /* script filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.scr_fname = opt + opt_off;

    if(strcmp(opts.scr_fname, "-") == 0)
      /* standard input */
      opts.scr_fname = NULL;

    return 0;
  }

  if (OPL("-g") || OPL("--progress"))
  { /* progress bar */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.progress_bar = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err)
      /* no option value given || value contains invalid/non-digit char */
      opts.progress_bar = TRUE;

    return 0;
  }

  if (OPL("-i") || OPL("--pp-indent"))
  { /* pretty-printer indentation value */
    BOOL vrb_msg = FALSE;

    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.pp_indent = strtol(opt + opt_off, &p_err, 0);

    /* limit pretty-printer indentation */
    if (opts.pp_indent > PP_INDENT_MAX) {
      opts.pp_indent = PP_INDENT_MAX;
      vrb_msg = TRUE;
    } else
    if (opts.pp_indent < PP_INDENT_MIN) {
      opts.pp_indent = PP_INDENT_MIN;
      vrb_msg = TRUE;
    }

    if (p_err == opt + opt_off || *p_err ||
        opts.pp_indent < PP_INDENT_MIN || opts.pp_indent > PP_INDENT_MAX) {
      /* no option value given || value contains invalid/non-digit char */
      opts.pp_indent = PP_INDENT;
      vrb_msg = TRUE;
    }

    if(vrb_msg)
      DM_DBG(DM_N(1),_("pretty-printer indentation set to %d spaces\n"), opts.pp_indent);

    return 0;
  }

  if (OPL("-l") || OPL("--log-file"))
  { /* default log filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.log_fname = opt + opt_off;
    DM_LOG_OPEN(opts.log_fname);     /* old stream is automatically closed */

    return 0;
  }

  if (OPL("-p") || OPL("--pp-out-file"))
  { /* pretty-printer output file */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    f_close(opts.pp_fname, &opts.pp_file);
    opts.pp_fname = opt + opt_off;

    if(strcmp(opts.pp_fname, "-") == 0)
      /* standard output */
      opts.pp_fname = NULL;

    f_open(opts.pp_fname, &opts.pp_file);
    return 0;
  }

  if (OPL("-r") || OPL("--err-file"))
  { /* error messages output filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.err_fname = opt + opt_off;
    DM_ERR_OPEN(opts.err_fname);     /* old stream is automatically closed */

    return 0;
  }

  if (OPL("-s") || OPL("--show-defaults"))
  { /* show default values (pretty-printer, evaluator) ON/OFF */

    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.show_defaults = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err) {
      /* no option value given || value contains invalid/non-digit char */
      opts.show_defaults = TRUE;
    }

    return 0;
  }

  if (OPL("-S") || OPL("--simple-name"))
  {
    opts.simple_name = TRUE;
  }

  if (OPL("-T") || OPL("--threads"))
  { /* threads in the thread pool */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.tp_size = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err)
      /* no option value given || value contains invalid/non-digit char */
      opts.tp_size = TP_THREADS_DEF;

    /* limit verbosity */
    if(opts.tp_size > TP_THREADS_MAX)
      opts.tp_size = TP_THREADS_MAX;
    else if(opts.tp_size < TP_THREADS_MIN)
      opts.tp_size = TP_THREADS_MIN;

    return 0;
  }

  if (OPL("-t") || OPL("--timeout"))
  { /* default timeout for branches */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.s2_timeout = strtol(opt + opt_off, &p_err, 0);
    if (p_err == opt + opt_off || *p_err)
      /* no option value given || value contains invalid/non-digit char */
      opts.s2_timeout = S2_TIMEOUT;

    return 0;
  }

  if (OPL("-V") || OPL("--version"))
  { /* print the version and exit */
    fprintf(stderr,_("%s version %s\n"), PNAME(), VERSION);
    exit(ERR_OK);
  }

  if (OPL("-w") || OPL("--warn-file"))
  { /* warning messages output filename */
    if(opt_off > 2 && *(opt + opt_off) == '=')
      /* long option, ignore '=' */
      opt_off++;

    opts.warn_fname = opt + opt_off;
    DM_WARN_OPEN(opts.warn_fname);   /* old stream is automatically closed */

    return 0;
  }

  /* default option handling */
  if (opt[1] == '-' || opt[1] == '+') {
    int ret_val = 1;
    /* try long options */
    for (op = optionlist; op->short_name; op++)
    {
      if (op->long_name && strcmp(opt+2, op->long_name) == 0)
      {
        ret_val = 0;
        handle_option(op->short_name);
        break;
      }
    }
    return ret_val;
  } else
    /* try short options */
    return handle_option(opt+1);

  return 1;
}
Пример #15
0
Файл: s2.cpp Проект: dCache/s2
/********************************************************************
 * Help function
 *
 * Params
 *   l: help level
 ********************************************************************/
extern void
hlp(int l)
{
  option_item *op;
  const char *PG = PNAME();

  switch(l) {
  case 0:
    hlp_head(PG);
    fprintf(stderr, "\n");
    fprintf(stderr,_("Options:\n"));

    for (op = optionlist; op->sw != 0; op++)
    {
      int n;
      char s[32];
      s[0] = 0;
      if (op->short_name)
        sprintf(s, "  %c%s%s%n", op->sw, op->short_name, op->long_name? ",": "", &n);
      else n = 0;
      n = 9 - n;                                        /* 9 */
      if (n < 1) n = 1;
      fprintf(stderr, "%s%.*s", s, n, "         ");     /* 9 spaces */
      s[0] = 0;
      if (op->long_name) sprintf(s,"%c%c%s%n", op->sw, op->sw, op->long_name, &n);
      else n = 0;
      n = 23 - n;
      if (n < 1) n = 1;
      fprintf(stderr, "%s%.*s", s, n, "                           ");
      if(op->short_name)
        switch(op->short_name[0]) {
        case '0':
          /* before-execution tree output filename (<p>: path); disabled if not specified */
          fprintf(stderr,_("before-evaluation tree output filename (%s)\n"), opts.e0_fname? opts.e0_fname : "");
        break;

        case '1':
          /* after-execution tree output filename (<p>: path); disabled if not specified */
          fprintf(stderr,_("after-execution tree output filename (%s)\n"), opts.e1_fname? opts.e1_fname : "");
        break;

        case '2':
          /* after-evaluation tree output filename (<p>: path) */
          fprintf(stderr,_("after-evaluation tree output filename (%s)\n"), opts.e2_fname? opts.e2_fname : "");
        break;

        case 'a':
          fprintf(stderr,_("ANSI colors 0/1 (%s)\n"), opts.ansi ? _("on") : _("off"));
        break;

	case 'S':
          fprintf(stderr,_("Simple script filename (%s)\n"), opts.simple_name ? _("on") : _("off"));
        break;

        case 'b':
          fprintf(stderr,_("verbose execution %d..%d (%d)\n"), VERBOSE_MIN, VERBOSE_MAX, opts.verbose);
        break;

        case 'd':
          /* debug messages output filename (<p>: path) */
          fprintf(stderr, _("debug messages output filename (%s)\n"), opts.dbg_fname? opts.dbg_fname:
                  DS_DBG_FOUT == stdout? "stdout":
                  DS_DBG_FOUT == stderr? "stderr": "?");
        break;

        case 'e':
          fprintf(stderr,_("default evaluation threshold for branches (%d)\n"), opts.s2_eval);
        break;

        case 'f':
          /* script filename (<p>: path) */
          fprintf(stderr,_("script filename (%s)\n"), opts.scr_fname? opts.scr_fname : "stdin");
        break;

        case 'g':
          fprintf(stderr,_("progress bar 0/1 (%s)\n"), opts.progress_bar ? _("on") : _("off"));
        break;

        case 'i':
          fprintf(stderr,_("pretty-printer indentation value (%d)\n"), opts.pp_indent);
        break;

        case 'l':
          /* log messages output filename (<p>: path) */
          fprintf(stderr, _("log messages output filename (%s)\n"), opts.log_fname? opts.log_fname:
                  DS_LOG_FOUT == stdout? "stdout":
                  DS_LOG_FOUT == stderr? "stderr": "?");
        break;

        case 'p':
          /* pretty-printer output filename (<p>: path) */
          fprintf(stderr,_("pretty-printer output filename (%s)\n"), opts.pp_fname? opts.pp_fname :
                         PP_DEFAULT_OUTPUT == stdout? "stdout":
                         PP_DEFAULT_OUTPUT == stderr? "stderr": "?");
        break;

        case 'r':
          /* error messages output filename (<p>: path) */
          fprintf(stderr, _("error messages output filename (%s)\n"), opts.err_fname? opts.err_fname:
                  DS_ERR_FOUT == stdout? "stdout":
                  DS_ERR_FOUT == stderr? "stderr": "?");
        break;

        case 's':
          /* show default values (pretty-printer, evaluator) ON/OFF */
          fprintf(stderr,_("show default values (%s)\n"), opts.show_defaults? "on": "off");
        break;

        case 'T':
          fprintf(stderr,_("threads in the thread pool %d..%d (%d)\n"), TP_THREADS_MIN, TP_THREADS_MAX, opts.tp_size);
        break;

        case 't':
          fprintf(stderr,_("default timeout for branches in microseconds (%"PRIu64")\n"), opts.s2_timeout);
        break;

        case 'w':
          /* warning messages output filename (<p>: path) */
          fprintf(stderr, _("warning messages output filename (%s)\n"), opts.warn_fname? opts.warn_fname:
                  DS_WARN_FOUT == stdout? "stdout":
                  DS_WARN_FOUT == stderr? "stderr": "?");
        break;

        default:
          fprintf(stderr,"%s\n", op->help_text);
        } else {
          /* we ran out of short options..., distinguish by the long one */
        }
    }

    hlp_tail();
  break;

  case 1:
  default: {
  } /* end default */
  } /* end switch */
}
#ifdef PARASAIL_ROWCOL
#define FNAME parasail_nw_rowcol_striped_avx2_256_32
#define PNAME parasail_nw_rowcol_striped_profile_avx2_256_32
#else
#define FNAME parasail_nw_striped_avx2_256_32
#define PNAME parasail_nw_striped_profile_avx2_256_32
#endif
#endif

parasail_result_t* FNAME(
        const char * const restrict s1, const int s1Len,
        const char * const restrict s2, const int s2Len,
        const int open, const int gap, const parasail_matrix_t *matrix)
{
    parasail_profile_t *profile = parasail_profile_create_avx_256_32(s1, s1Len, matrix);
    parasail_result_t *result = PNAME(profile, s2, s2Len, open, gap);
    parasail_profile_free(profile);
    return result;
}

parasail_result_t* PNAME(
        const parasail_profile_t * const restrict profile,
        const char * const restrict s2, const int s2Len,
        const int open, const int gap)
{
    int32_t i = 0;
    int32_t j = 0;
    int32_t k = 0;
    int32_t end_query = 0;
    int32_t end_ref = 0;
    int32_t segNum = 0;
Пример #17
0
void 
do_whisper(dbref player, const char *arg1, const char *arg2)
{
    int     ignored;
    dbref   who;
    char    buf[BUFFER_LEN], buf2[BUFFER_LEN];
    struct match_data md;

    if(Guest(player)) {
	anotify(player, CFAIL NOGUEST_MESG);
	return;
    }

    init_match(player, arg1, TYPE_PLAYER, &md);
    match_neighbor(&md);
    match_me(&md);
    if (Mage(player) && Typeof(player) == TYPE_PLAYER) {
	match_absolute(&md);
	match_player(&md);
    }
    switch (who = match_result(&md)) {
	case NOTHING:
	case AMBIGUOUS:
	    anotify(player, CINFO WHO_MESG);
	    break;
	default:

	    ignored = ignoring(who, player);
	    if(ignored == 1) {
		anotify(player, CFAIL "That player is ignoring you.");
		return;
	    } else if(ignored == 2) {
		anotify(player, CINFO "That player is ignoring you.");
	    }

	    do_parse_mesg(player, player, arg2, "(whisper)", buf, MPI_ISPRIVATE);
	    tct(buf,buf2);

	    if (buf2[0] == ':' || buf2[0] == ';') {
		sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%s %.3900s" CBLUE "\"",
					PNAME(player), PNAME(player), buf2+1);
		if (!anotify_from(player, who, buf)) {
		    sprintf(buf, CBLUE "%s is not connected.", PNAME(who));
		    anotify(player, buf);
		    break;
		}
		sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%s %.3900s" CBLUE "\" to %s.",
					 PNAME(player), buf2+1, PNAME(who));
		anotify(player, buf);
		break;
	    } else { 
		sprintf(buf, CBLUE "%s whispers, \"" CPURPLE "%.3900s" CBLUE "\"", PNAME(player), buf2);
		if (!anotify_from(player, who, buf)) {
		    sprintf(buf, CBLUE "%s is not connected.", PNAME(who));
		    anotify(player, buf);
		    break;
		}
		sprintf(buf, CBLUE "You whisper, \"" CPURPLE "%.3900s" CBLUE "\" to %s.", buf2, PNAME(who));
		anotify(player, buf);
		break;
	    }
    }
}