Пример #1
0
int checkEqual(QString s, QString t)
{
	if (s != t) {
		printf("Error: Expecting: '%s' found: '%s' at line %d\n",
		       QSTR(t), QSTR(s), lineNumber);
		exit(-1);
	}
	return 1;
}
Пример #2
0
QString getValue(QString s, QString t)
{
	if (!s.startsWith(t + " " + TOKEQUAL)) {
		printf("Error: Expecting: '%s' found: '%s' at line %d\n",
		       QSTR(t), QSTR(s), lineNumber);
		exit(-1);
	}
	return s.mid(s.indexOf(TOKEQUAL) + 1).trimmed();
}
Пример #3
0
void CronString::tokenize(QString line) {
    tokens.clear();
    int section = 0;
    QString token;
    while (not line.isEmpty()) {

        QChar next_char = line[0];
        line.remove(0,1);

        // Digit
        if (next_char.isDigit() or next_char.isLetter()) {
            LDEBUG_ << "Found digit";
            token.append(next_char);
            continue;

            // Operator
        } else if (CronToken::operators.contains(next_char)) {
            if (not token.isEmpty()) {
                LDEBUG_ << "Pushing token " << QSTR(token);
                tokens << CronToken::identify(token);
                token.clear();
            }
            LDEBUG_ << "Pushing operator " << next_char.toAscii();
            tokens << CronToken(next_char);
            continue;

            // Space separator
        } else if (next_char.isSpace()) {
            LDEBUG_ << "Found space";

            if (not token.isEmpty()) {
                LDEBUG_ << "Pushing token: " << QSTR (token);
                tokens << CronToken::identify(token);
                token.clear();
            }

            if (not tokens.last().isSeparator()) {
                LDEBUG_ << "Pushing separator";
                tokens << CronToken();
                section++;
            }

            if (section == 5) { // The rest is the command to execute
                LDEBUG_ << "Pushing command";
                tokens << CronToken(line.trimmed());
                LDEBUG_ << "Clearing the rest of the cron line";
                line.clear();
                continue;
            }

            continue;
        }

    }
    LDEBUG_ << "Done parsing cron line";

}
Пример #4
0
int main(int argc, char *argv[]) {
	QCoreApplication a(argc, argv);

	init_logs();

	Schedule schedule;
	CronString cron;
	//cron.tokenize("0 0 * * * command line");
	//cron.tokenize("0 0 */2 1,5 */2 command line");
	cron.tokenize("0 0 * * sun command line");

	foreach(CronToken token, cron.tokens)
		LDEBUG_ << QSTR(token.toString());

	schedule.build(cron.tokens);

	LDEBUG_ << QSTR(schedule.toString());
	//return a.exec();
	return 0;
}
Пример #5
0
modelCoupled *parseCoordinator()
{
	modelCoupled *ret = new modelCoupled();

	QString strLine = getLine();
	checkEqual(strLine, TOKOBRACE);

	do {
		strLine = getLine();
		if (strLine.trimmed() == TOKSIMULATOR) {
			modelChild *c = new modelChild();
			c->childType = ATOMIC;
			c->atomic = parseSimulator();
			ret->childs.append(c);
		} else if (strLine.trimmed() == TOKCOORDINATOR) {
			modelChild *c = new modelChild();
			c->childType = COUPLED;
			c->coupled = parseCoordinator();
			ret->childs.append(c);
		} else if (strLine.trimmed() == TOKEIC) {
			QList < modelConnection * >l = parseConnections();
			ret->lsEIC = l;
		} else if (strLine.trimmed() == TOKEOC) {
			QList < modelConnection * >l = parseConnections();
			ret->lsEOC = l;
		} else if (strLine.trimmed() == TOKIC) {
			QList < modelConnection * >l = parseConnections();
			ret->lsIC = l;
		} else if (strLine != TOKCBRACE) {
			printf("Expecting {%s, %s, %s, %s, %s}: found %s\n",
			       TOKSIMULATOR, TOKCOORDINATOR, TOKEIC, TOKEOC,
			       TOKIC, QSTR(strLine));
			exit(-1);
		}
	} while (strLine != TOKCBRACE);

	return ret;
}
Пример #6
0
void Schedule::build(QList<CronToken> tokens) {
    cron.clear();

    LSEPARATOR_;
    m_current_segment = CronSegment::Minute;
    cron[m_current_segment].setType((CronSegment::Types)m_current_segment);
    CronSegment::State last_token;
    last_token = CronSegment::Separator;
    int last_number = -1;
    int low_range = -1;
    bool used_as_repeater = false;

    foreach(CronToken token, tokens) {



        switch (last_token) {
        case CronSegment::Separator:
            if (token.isSeparator()) {
                LDEBUG_ << "Duplicate separator";
                last_token = CronSegment::Separator;
                continue;
            }

            if (token.isNumber()) {
                LDEBUG_ << "First number " << token.number;
                last_number = token.number;
                last_token = CronSegment::Number;
            }

            if (token.isGlob()) {
                cron[m_current_segment].glob = true;
                last_token = CronSegment::Glob;
            }

            if (token.isCommand()) {
                cron[m_current_segment].command = token.command;
            }

            break;

        case CronSegment::Number:
            if (token.isList() or token.isSeparator()) {
                if (used_as_repeater) {
                    used_as_repeater = false;
                } else if (low_range == -1) {
                    LDEBUG_ << "Single";
                    cron[m_current_segment].addSingle(last_number);
                } else {
                    LDEBUG_ << "Range";
                    cron[m_current_segment].addSpan(low_range, last_number);
                    low_range = -1;
                }
                if (token.isList())
                    last_token = CronSegment::ListSeparator;
                else
                    last_token = CronSegment::Separator;
            }
            if (token.isRange()) {
                LDEBUG_ << "Entering range";
                low_range = last_number;
                last_token = CronSegment::Range;
            }

            break;

        case CronSegment::Range:
            if (token.isNumber()) {
                last_number = token.number;
                last_token = CronSegment::Number;
            }
            break;

        case CronSegment::ListSeparator:
            if (token.isNumber()) {
                last_number = token.number;
                last_token = CronSegment::Number;
            }
            break;

        case CronSegment::Repeater:
            if (token.isNumber()) {
                LDEBUG_ << "Repeater";
                cron[m_current_segment].setRepeater(token.number);
                last_token = CronSegment::Number;
                used_as_repeater = true;
            }
            break;

        case CronSegment::Glob:
            if (token.isRepeater()) {
                LDEBUG_ << "Glob";
                last_token = CronSegment::Repeater;
            }
            break;

        }

        if (token.isSeparator()) {
            LDEBUG_ << "Separator";
            last_token = CronSegment::Separator;
            LDEBUG_ << "Segment: " << QSTR(cron[m_current_segment].toString());
            m_current_segment = (CronSegment::Types) ((int) m_current_segment + 1);
            cron[m_current_segment].setType((CronSegment::Types)m_current_segment);
        }

    }

}
Пример #7
0
#include "hercules.h"
#include "machdep.h"

/*--------------------------------------------------*/
/*   "Unusual" (i.e. noteworthy) build options...   */
/*--------------------------------------------------*/

static const char *build_info[] = {

#if defined(_MSVC_)
    "Windows (MSVC) "
  #if defined(DEBUG)
    "** DEBUG ** "
  #endif
    "build for " QSTR(HOST_ARCH)
    ,
#endif

#if defined(CUSTOM_BUILD_STRING)
    CUSTOM_BUILD_STRING,
#endif

#if !defined(_ARCHMODE2)
    "Mode:"
#else
    "Modes:"
#endif
#if defined(_370)
    " " _ARCH_370_NAME
#endif
Пример #8
0
/*-------------------------------------------------------------------*/
int ARCH_DEP(load_hmc) (char *fname, int cpu, int clear)
{
REGS   *regs;                           /* -> Regs                   */
FILE   *fp;
char    inputbuff[MAX_PATH];
char   *inputline;
char    filename[MAX_PATH];             /* filename of image file    */
char    pathname[MAX_PATH];             /* pathname of image file    */
U32     fileaddr;
int     rc = 0;                         /* Return codes (work)       */

    /* Get started */
    if (ARCH_DEP(common_load_begin) (cpu, clear) != 0)
        return -1;

    /* The actual IPL proper starts here... */

    regs = sysblk.regs[cpu];    /* Point to IPL CPU's registers */

    if(fname == NULL)                   /* Default ipl from DASD     */
        fname = "HERCULES.ins";         /*   from HERCULES.ins       */

    hostpath(pathname, fname, sizeof(pathname));

    if(!(fname = set_sce_basedir(pathname)))
        return -1;

    /* Construct and check full pathname */
    if(!check_sce_filepath(fname,filename))
    {
        WRMSG(HHC00601,"E",fname,strerror(errno));
        return -1;
    }

    fp = fopen(filename, "r");
    if(fp == NULL)
    {
        WRMSG(HHC00600,"E", fname,"fopen()",strerror(errno));
        return -1;
    }

    do
    {
        inputline = fgets(inputbuff,sizeof(inputbuff),fp);

#if !defined(_MSVC_)
        if(inputline && *inputline == 0x1a)
            inputline = NULL;
#endif /*!defined(_MSVC_)*/

        if(inputline)
        {
            rc = sscanf(inputline,"%" QSTR(MAX_PATH) "s %i",filename,&fileaddr);
        }

        /* If no load address was found load to location zero */
        if(inputline && rc < 2)
            fileaddr = 0;

        if(inputline && rc > 0 && *filename != '*' && *filename != '#')
        {
            hostpath(pathname, filename, sizeof(pathname));

            /* Construct and check full pathname */
            if(!check_sce_filepath(pathname,filename))
            {
                WRMSG(HHC00602,"E",pathname,strerror(errno));
                return -1;
            }

            if( ARCH_DEP(load_main) (filename, fileaddr, 0) < 0 )
            {
                fclose(fp);
                HDC1(debug_cpu_state, regs);
                return -1;
            }
            sysblk.main_clear = sysblk.xpnd_clear = 0;
        }
    } while(inputline);
    fclose(fp);

    /* Finish up... */
    return ARCH_DEP(common_load_finish) (regs);

} /* end function load_hmc */
Пример #9
0
/*-------------------------------------------------------------------*/
int build_config (const char *hercules_cnf)
{
int     i;                              /* Array subscript           */
int     devtmax;                        /* Max number device threads */

    /*      From impl.c, using system defaults of:
     *
     * LPARNUM  1                       # LPAR 1 with LPAR ID 01
     * CPUIDFMT 0                       # CPU ID format 0
     * XPNDSIZE 0                       # Expanded storage size
     */

    sysblk.xpndsize = 0;

    /* Set sysblk.maxcpu to our preferred default value, if possible */
#if (PREF_DEF_MAXCPU <= MAX_CPU_ENGINES)
    sysblk.maxcpu = PREF_DEF_MAXCPU;
#else
    WARNING( "sysblk.maxcpu reduced from " QSTR( PREF_DEF_MAXCPU ) " to " QSTR( MAX_CPU_ENGINES ))
    sysblk.maxcpu = MAX_CPU_ENGINES;
#endif

#ifdef    _FEATURE_VECTOR_FACILITY
    sysblk.numvec = sysblk.maxcpu;
#else  //!_FEATURE_VECTOR_FACILITY
    sysblk.numvec = 0;
#endif // _FEATURE_VECTOR_FACILITY

#if defined(_900)
    set_archlvl(_ARCH_900_NAME);
#elif defined(_390)
    set_archlvl(_ARCH_390_NAME);
#else
    set_archlvl(_ARCH_370_NAME);
#endif
    devtmax  = MAX_DEVICE_THREADS;

    ptt_trace_init (0, 1);

    /* Set max number device threads */
    sysblk.devtmax = devtmax;
    sysblk.devtwait = sysblk.devtnbr =
    sysblk.devthwm  = sysblk.devtunavail = 0;

#if defined(OPTION_LPP_RESTRICT)
    /* Default the licence setting */
    losc_set(PGM_PRD_OS_RESTRICTED);
#endif

    /* Reset the clock steering registers */
    csr_reset();

    /* Default CPU type CP */
    for (i = 0; i < sysblk.maxcpu; i++)
        sysblk.ptyp[i] = SCCB_PTYP_CP;

    /* Default main storage to 2M with one CPU */
    configure_storage(2 << (SHIFT_MEBIBYTE - 12));
    configure_numcpu(1);

    if (hercules_cnf && (process_config(hercules_cnf)))
        return -1;

    /* Connect each channel set to its home cpu */
    for (i = 0; i < sysblk.maxcpu; i++)
        if (IS_CPU_ONLINE(i))
            sysblk.regs[i]->chanset = i < FEATURE_LCSS_MAX ? i : 0xFFFF;

    return 0;
} /* end function build_config */