Ships Monday, April 22 if ordered in the next 2 days, 21 hours and 5 minutes!
What size return pump would good for this overflow?
Youo want to match this overflow box with pump that can give you 1000-1200 gph of the actual flow. Pump like Simplicity DC-1600 would be a good fit for this box.
Yes, this overflow box will be a good match with Vectra M1 pump.
will this fit on a tank with a 1 1/4 inch frame on it?
This box can accommodate rim up to 1 5/8" in width.
This box can handle flow of up to 1,200 GPD. When selecting return pump please take into consideration head drop. Current USA 1050 pump will give you max. output of only 550 gph at 5 ft. of head.


Totally cool metallic silver tote bag featuring a white faux leather half and twin grab handles. Spacious inner compartment with a top zip closure.
Work It - Goes best with black skinnies & a printed top on a day out with the gals.


text:
The RR Way
RoughRider Curriculum
Player Development Model
USA Basketball Developmental Model
College Prep Program CPP
Basketball Tryouts
Lady Rough Riders
17U Girls Team
16U Girls Nationals
15U Elite Girls
Girls Team Coaches
Lady Roughriders Director
Staff & Coaches
Our Home–the Sport Stable
Brian is a Colorado native and grew up in Thornton. Brian was a standout player at Horizon High School where he won a State Championship in 1998 and was named Colorado Mr. Basketball in 1999. Brian went on to play 4 years at Colorado State where he led the Rams to their first ever Mountain West Conference Championship and their first trip to the NCAA Tournament in 13 years. After his college career Brian went on to play professionally for 13 seasons in Europe. Since retiring in 2015 Brian has enjoyed coaching multiple youth teams in the Denver area including more than 3 years with the Rough Riders.
Kelly Meek
Kelly Meek spent 36 years as a high school coach, including 34 as the Head Boys Basketball Coach at Steamboat Springs High School. With the Sailors, he won 44 league, district or regional championships, and 20 preseason tournament championships.
Meek finished with 544 wins all-time at Steamboat Springs which ranks him third all-time among Colorado high school coaches and second all-time among coaches at one school.
Meek entered the Colorado High School Coaches Association Hall of Fame in 2011.
Tracy Neely
Tracy brings an abundance of experience as both a player and a coach. Tracy enjoyed a very good college career as a 4-year starter with individual awards that included: All-Conference, All-State, All-District 25 (Georgia and Florida) College All-Star Team, 1st Team All-Tournament and team's Most Valuable Player at Kennesaw State University in Georgia, averaging 21 points and 8 rebounds per game. Tracy completed a Master's degree from Walla Walla University in College Place, Washington.
Tracy has coached basketball in a variety of capacities, starting with AAU basketball. Two seasons ago, he coached high school basketball at Nezperce High School in Idaho and spent three seasons at Legacy High School, first as an assistant and promoted to Head Coach.
My background is in psychology with an emphasis on child and sport psychology. I've been playing basketball for 25 years and played at the collegiate level. I've been coaching basketball for 13 years, 3 years at the middle school level, 4 years at the high school level and 6 years at the AAU level. My aim is to build the best basketball player that the player can be and to push each player to reach their ultimate potential.
Rick Dunn
Rick has lived in Colorado for the past 11 years when he moved with his family from the Midwest living in Indiana, Minnesota and Illinois. He has over 10 years' experience of coaching youth sports up to high school where he prefers to focus on teaching fundamentals, the importance of working as a team and learning lessons through both successes and failures. Knowing the impact that coaches had on his life, he takes the role with the players seriously and tries to be a positive role model by building an environment that promotes growth and development while making sure to bring passion and fun to the game.
© 2022 Colorado RoughRiders Basketball Organization | Powered by TeamSnap®

redpajama_set_name: RedPajamaCommonCrawl


Mason helps our individual clients in the planned giving area by integrating their charitable inclinations while considering the complex principles of financial and estate planning.
Financial independence – the resources needed to maintain the desired lifestyle.
Family legacy – the amount of money available for family members and other heirs.
Social capital legacy – the remainder of the estate which will be used for society's needs, either through estate taxes or charitable gifts.
Some of the charitable tools we recommend include: charitable remainder trusts, charitable lead trusts, charitable gift annuities, family foundations, donor-advised funds, outright gifts, supporting organizations, community foundations, pooled-income funds and bargain sales. We work closely with our clients' attorneys to carefully integrate estate planning tools.
Social capital planning gives our clients the flexibility to control the allocation of their resources between themselves, their heirs and society.
Click below to request more information about Mason's charitable giving services.


These words of divine encouragement were given to John Woolley in his work as a hospital chaplain, and have since inspired and uplifted tens of thousands, even changed their lives.
This title is been the best-selling devotional in the UK. During his work as a hospital chaplain, John Woolley received many words of divine encouragement from the Lord during prayer. He has passed on these words in a series of titles which have inspired and uplifted tens of thousands, even changed their lives. First published in 1985 as a hardback, but since 2005 published in paperback.
This is the first in the series of devotional books of "heart whispers" which John Woolley received. Companion volumes published by O Books are "Abide in My Love", "I Am With You for Young People and the Young At Heart", "Many Mansions" and "My Burden is Light".
Lifetime sales of Father Woolley's devotionals exceed 100,000, nearly 10,000 have been sold in the past year.
"I Am With You" will bring peace and consolation to all who read it. Cardinal Cormac Murphy-OConnor, Archbishop of Westminster.


text:
BrexitEuropeWorld News
Brexit divorce deal text agreed by United Kingdom and European Union
Guy Faulconbridge and Elizabeth PiperAAP
Wed, 14 November 2018 6:00AM
Cabinet to consider Brexit deal in special meeting on Wednesday
VideoA Brexit deal has been reached by negotiators in Brussels and will be the focus of a crunch Cabinet meeting on Wednesday. A UK Government source confirmed that agreement had been reached at a "technical level" but Theresa May will need to win the.
Britain has struck a draft divorce deal with the European Union after more than a year of talks, thrusting Prime Minister Theresa May into a perilous battle over Brexit that could shape her country's prosperity for generations to come.
As officials choreograph the first withdrawal of a sovereign state from the EU, May's ultimate test will be whether she can get the deal approved by the British parliament where hardline Brexiteers accused her of surrendering to Brussels.
The British cabinet will meet at 2pm local time on Wednesday to consider the draft withdrawal agreement, a Downing Street spokesman said after Irish and British media were leaked details of the breakthrough.
But May has struggled to untangle nearly 46 years of EU membership without damaging commerce or upsetting MPs who will ultimately decide the fate of the divorce accord.
"The trick will be for Theresa May, can she satisfy everyone?" said Nigel Dodds, the deputy leader of the Northern Irish Democratic Unionist Party which props up her minority government.
"It is going to be a very, very hard sell, I would have thought, but let's wait and see the actual detail," Dodds said on Tuesday.
A senior EU official confirmed that a draft text had been agreed. EU leaders could meet on November 25 for a summit to seal the Brexit deal if May's cabinet approves the text, diplomatic sources said.
The EU and Britain need an agreement to keep trade flowing between the world's biggest trading bloc and the United Kingdom, home to the biggest international financial centre.
Camera IconUK Prime Minister Theresa May and French President Emmanuel Macron. Credit: Getty Images
By seeking to leave the EU while preserving the closest possible ties, May's compromise plan has upset Brexiteers, pro-Europeans, Scottish nationalists, the Northern Irish party that props up her government, and some of her own ministers.
To get the deal approved she needs the votes of about 320 MPs in the 650-seat parliament.
She will have a mountain to climb.
Prominent Brexiteers such as Conservative MP Jacob Rees-Mogg and former Foreign Secretary Boris Johnson said May had sold out the UK and that they would oppose it.
"It is a failure of the government's negotiating position, it is a failure to deliver on Brexit, and it is potentially dividing up the United Kingdom," Conservative lawmaker Jacob Rees-Mogg said.
The opposition Labour Party, which has said it would oppose any agreement that does not retain "the exact same" economic benefits that it now has with the EU, said it was unlikely the announced deal was right for Britain.
"It is vassal state stuff," Johnson said, adding that he would vote against such an unacceptable accord. "Chuck it out."
How China beat the world a year on from COVID-19Premium
Eurostar survival fears grow as UK firms seek rescuePremium
Samsung's heir ordered back to prison for briberyPremium
China economy grows as rebound from virus gainsPremium
Aussie nurse's London COVID nightmarePremium
Not my job to lecture Americans, says ScoMoPremium


text:
Der Literarian Award for Outstanding Service to the American Literary Community wird von der National Book Foundation seit 2005 als Ehrenpreis für ein Lebenswerk vergeben.

Preisträger

Weblinks
 Offizielle Website (englisch)

Einzelnachweise

National Book Award
Erstverleihung 2005

redpajama_set_name: RedPajamaWikipedia


BEIRUT (AP) — Russia's Foreign Ministry said Wednesday that Moscow expects the Syrian government to take over the areas where the U.S. troops are currently deployed following their withdrawal.
Turkey said Tuesday it is working with the United States to coordinate the withdrawal of American forces but remains "determined" to clear U.S.-allied Kurdish fighters from Manbij in northeastern Syria.
Asked about Turkey's plans to launch an attack on the area, Zakharova answered that Russia and Turkey have closely coordinated their actions in Syria, "including military counter-terrorist operations," but wouldn't elaborate further.
Youssef Hammoud, spokesman for the Syrian National Army, which is expected to be a core force in a Turkish campaign in eastern Syria, said Wednesday the return of government forces to the area would trigger "a disaster and a catastrophe" with a new wave of refugees and the displaced people.


text:
Amnesia: The Bunker opens its doors in May
Zara Deniz Lackenby-Brown leaves Love Island mansion after surprise reunion
Married farming couple win €137,914 tax dispute with proceeds of €950,000 from land sale
Home/News/Suspected killer of Brit beaten to death in Ibiza to stand trial for murder
Suspected killer of Brit beaten to death in Ibiza to stand trial for murder
Fry Electronics TeamMay 30, 2022
Prosecutors allege Mitchell Andrew Loveridge, 25, attacked the club promoter after knocking him unconscious with a blow to the head to prevent him from separating two other rowing Brits.
Mitchell Andrew Loveridge, 25, has been warned he faces up to 25 years in prison if found guilty (
Image: SOLARPIX.COM)
The suspected killer of a Brit who was bludgeoned to death in Ibiza while trying to stop a fight will be tried for murder today.
Mitchell Andrew Loveridge, 25, has been warned he faces up to 25 years in prison if found guilty of the premeditated killing of 21-year-old club promoter Harry Kingsland.
Loveridge was due to appear in court last September, shortly after being ordered back into custody almost 14 months after his release over the July 18, 2018 incident. The start date was postponed to today in the Mallorcan capital Palma after an interruption.
Prosecutors are seeking an 18-year sentence for the Welshman from Llwynypia in Rhondda, and private attorneys working for Harry's grieving parents want him sentenced to 25 years in prison if convicted of murder.
Both claim he attacked Harry from Solihull as he lay on the ground after allegedly hitting him with a blow to the head to prevent him from separating two other rowing Brits at a flat.
Club promoter Harry Kingsland, 21
SOLARPIX.COM)
Harry allegedly tried to break up two other rowing Brits in an apartment
Loveridge was arrested after jumping from the second floor apartment and held in custody in Spain for more than six months before being released on bail on January 30, 2019. He will be tried by a nine-person jury.
A five-page indictment filed by prosecutors ahead of the trial said: "The defendant hit Harry Kingsland hard in the head, leaving him stunned and semi-conscious on the ground.
"Intending to end Harry's life and taking advantage of the fact that he had no way of defending himself because he was lying on the floor shaking and convulsing, he punched him several more times in the front and side of the head until he caused his death."
Spanish lawyer Oscar Hernanz, on behalf of Harry's family, has accused Loveridge of hitting Harry sideways on the head when his back was turned and continuing to attack him on the ground after knocking him unconscious with "unjustified malice and clear intent". which deals maximum damage to him."
An Irish woman also staying at the San Antonio party resort apartment who pleaded with Loveridge to stop hitting Harry as his life ebbed away according to the indictment was subpoenaed to testify at the murder trial.
Loveridge was arrested after jumping from the second floor apartment
Loveridge was allowed to return to Britain after being released on bail on condition that he signed regularly with the Spanish consulate in London.
One of seven siblings and a world taekwondo champion at the age of ten, Harry enjoyed his early days living and working away from home after finding a job as club pros in San Antonio. He worked as a bricklayer to raise money for his trip.
Former Benefits Street star White Dee – Deirdre Kelly – was among those paying tribute to him after his death.
Loveridge was held in custody in Spain for more than six months before being released on bail in 2019
She revealed that she had met him twice when he was working as a dancer for a friend's company and described him as "an easy-going young man with a zest for life".
She added at the time, "It is absolutely tragic that this should happen to anyone, let alone someone that young."
Harry's mother Julie previously said: "Harry was a happy, ambitious young man whose brawn, love of sports and charming manner brought him friends wherever he went.
"He was so excited to move to Ibiza, it was his first experience abroad and he dreamed of many more. Always wanting to work abroad, he worked two jobs to raise money to travel to Ibiza, his favorite happy place. That the journey ended in such tragic circumstances is heartbreaking indeed.
"It's been a long few years but we are so grateful to the Spanish authorities for doing everything in their power to pursue a criminal case. Knowing that the accused no longer poses a risk of escaping is a great relief for us. Hopefully he can now stand trial and all the evidence can be heard.
"We will participate in the process of hoping that we can end this terrible pain that we are going through."
https://www.mirror.co.uk/news/uk-news/suspected-killer-british-man-beaten-27099807 Suspected killer of Brit beaten to death in Ibiza to stand trial for murder
'Appalled' mum wins £20,000 after being 'kicked out' with newborn baby while on maternity leave
Commander loyal to Vladimir Putin's Chechen warlord boasts he enjoys killing Ukrainians - World News
US uses 'bats and birds' for biological warfare, Russia claims during UN meeting – World News
Ted Crosbie remembered as a "true pioneer of modern Irish media" and a gentleman
'Iron Princess of Crimea' fired by Vladimir Putin after criticizing Russian war – World News
Inside Gov. Hochul's Choice to Raise 'Masks or Vax' Rule in New York


text:
/* resource.c - resorce metadata operation */

#include "resource.h"
#include "genQuery.h"
#include "rodsClient.h"

/* getRescInfo - Given the rescName or rescgrpName in condInput keyvalue
 * pair or defaultResc, return the rescGrpInfo containing the info on
 * this resource or resource group.
 * The resource given in condInput is taken first, then defaultResc.
 * If it is a resource, the returned integer can be 0, SYS_RESC_IS_DOWN
 * SYS_RESC_QUOTA_EXCEEDED.
 *
 */

int
getRescInfo (rsComm_t *rsComm, char *defaultResc, keyValPair_t *condInput,
rescGrpInfo_t **rescGrpInfo)
{
    char *rescName;
    int status;

    if ((rescName = getValByKey (condInput, BACKUP_RESC_NAME_KW)) == NULL &&
      (rescName = getValByKey (condInput, DEST_RESC_NAME_KW)) == NULL &&
      (rescName = getValByKey (condInput, DEF_RESC_NAME_KW)) == NULL &&
      (rescName = getValByKey (condInput, RESC_NAME_KW)) == NULL &&
      ((rescName = defaultResc) == NULL || strcmp (defaultResc, "null") == 0)) {
        return (USER_NO_RESC_INPUT_ERR);
    }
    status = _getRescInfo (rsComm, rescName, rescGrpInfo);

    return (status);
}

/* _getRescInfo -  given the input string rescGroupName (which can be
 * the name of a resource or resource group), return the rescGrpInfo
 * containing the info on this resource or resource group.
 * If it is a resource, the returned integer can be 0, SYS_RESC_IS_DOWN
 * SYS_RESC_QUOTA_EXCEEDED.
 */

int
_getRescInfo (rsComm_t *rsComm, char *rescGroupName,
rescGrpInfo_t **rescGrpInfo)
{
    int status;

    *rescGrpInfo = NULL;

    /* a resource ? */

    status = resolveAndQueResc (rescGroupName, NULL, rescGrpInfo);
    if (status >= 0 || status == SYS_RESC_IS_DOWN) {
        return (status);
    }
    /* assume it is a rescGrp */

    status = resolveRescGrp (rsComm, rescGroupName, rescGrpInfo);

    return (status);
}

/* getRescStatus - Given a resource name in inpRescName or condInput
 * key value pair, return the status of the resource. The returned
 * value can be INT_RESC_STATUS_DOWN or INT_RESC_STATUS_UP.
 */
int
getRescStatus (rsComm_t *rsComm, char *inpRescName, keyValPair_t *condInput)
{
    char *rescName;
    int status;
    rescGrpInfo_t *rescGrpInfo = NULL;

    if (inpRescName == NULL) {
        if ((rescName = getValByKey (condInput, BACKUP_RESC_NAME_KW)) == NULL &&
          (rescName = getValByKey (condInput, DEST_RESC_NAME_KW)) == NULL &&
          (rescName = getValByKey (condInput, DEF_RESC_NAME_KW)) == NULL) {
            return (INT_RESC_STATUS_DOWN);
        }
    } else {
        rescName = inpRescName;
    }
    status = _getRescInfo (rsComm, rescName, &rescGrpInfo);

    freeAllRescGrpInfo (rescGrpInfo);

    if (status < 0) {
        return INT_RESC_STATUS_DOWN;
    } else {
        return INT_RESC_STATUS_UP;
    }
}

/* resolveRescGrp - Given the rescGroupName string, returns info for
 * all resources in this resource group.
 * rescGroupName can only be a resource group.
 */

int
resolveRescGrp (rsComm_t *rsComm, char *rescGroupName,
rescGrpInfo_t **rescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo;
    int status;

    if ((status = initRescGrp (rsComm)) < 0) return status;

    /* see if it is in cache */

    tmpRescGrpInfo = CachedRescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        if (strcmp (rescGroupName, tmpRescGrpInfo->rescGroupName)
          == 0) {
            replRescGrpInfo (tmpRescGrpInfo, rescGrpInfo);
            /* *rescGrpInfo = tmpRescGrpInfo; */
            return (0);
        }
        tmpRescGrpInfo = tmpRescGrpInfo->cacheNext;
    }

    return CAT_NO_ROWS_FOUND;
}

/* replRescGrpInfo - Replicate a rescGrpInfo_t struct. The source struct
 * is srcRescGrpInfo and the result is destRescGrpInfo.
 */

int
replRescGrpInfo (rescGrpInfo_t *srcRescGrpInfo, rescGrpInfo_t **destRescGrpInfo)
{
    rescGrpInfo_t *tmpSrcRescGrpInfo, *tmpDestRescGrpInfo,
      *lastDestRescGrpInfo;

    *destRescGrpInfo = lastDestRescGrpInfo = NULL;

    tmpSrcRescGrpInfo = srcRescGrpInfo;
    while (tmpSrcRescGrpInfo != NULL) {
        tmpDestRescGrpInfo = (rescGrpInfo_t *) malloc (sizeof (rescGrpInfo_t));
        memset (tmpDestRescGrpInfo, 0, sizeof (rescGrpInfo_t));
	tmpDestRescGrpInfo->status = tmpSrcRescGrpInfo->status;
        tmpDestRescGrpInfo->rescInfo = tmpSrcRescGrpInfo->rescInfo;
        rstrcpy (tmpDestRescGrpInfo->rescGroupName,
          tmpSrcRescGrpInfo->rescGroupName, NAME_LEN);
        if (*destRescGrpInfo == NULL) {
            *destRescGrpInfo = tmpDestRescGrpInfo;
        } else {
            lastDestRescGrpInfo->next = tmpDestRescGrpInfo;
        }
        lastDestRescGrpInfo = tmpDestRescGrpInfo;
        tmpSrcRescGrpInfo = tmpSrcRescGrpInfo->next;
    }

    return (0);
}

/* queryRescInRescGrp - Given the rescGroupName string which must be the
 * name of a resource group, query all resources in this resource group.
 * The output of the query is given in genQueryOut.
 * YYYY - queryRescInRescGrp - this routine is currently not used
 */

int
queryRescInRescGrp (rsComm_t *rsComm, char *rescGroupName,
genQueryOut_t **genQueryOut)
{
    genQueryInp_t genQueryInp;
    char tmpStr[NAME_LEN];
    int status;

    memset (&genQueryInp, 0, sizeof (genQueryInp_t));

    snprintf (tmpStr, NAME_LEN, "='%s'", rescGroupName);
    addInxVal (&genQueryInp.sqlCondInp, COL_RESC_GROUP_NAME, tmpStr);
    addInxIval (&genQueryInp.selectInp, COL_R_RESC_NAME, 1);

    genQueryInp.maxRows = MAX_SQL_ROWS;

    status =  rsGenQuery (rsComm, &genQueryInp, genQueryOut);

    clearGenQueryInp (&genQueryInp);

    return (status);

}

/* resolveAndQueResc - Given the rescName string, get the resource info
 * in a rescGrpInfo_t struct and queue this struct in the rescGrpInfo
 * link list by resource type. Also copy the rescGroupName string to this
 * rescGrpInfo_t struct.
 */
int
resolveAndQueResc (char *rescName, char *rescGroupName,
rescGrpInfo_t **rescGrpInfo)
{
    rescInfo_t *myRescInfo;
    int status;

    status = resolveResc (rescName, &myRescInfo);

    if (status < 0) {
        return (status);
    } else if (myRescInfo->rescStatus == INT_RESC_STATUS_DOWN) {
        return SYS_RESC_IS_DOWN;
    } else {
        queResc (myRescInfo, rescGroupName, rescGrpInfo, BY_TYPE_FLAG);
        return (0);
    }
}

/* resolveResc - Given the rescName string, get the info of this resource
 * in rescInfo.
 */

int
resolveResc (char *rescName, rescInfo_t **rescInfo)
{
    rescInfo_t *myRescInfo;
    rescGrpInfo_t *tmpRescGrpInfo;

    *rescInfo = NULL;

    /* search the global RescGrpInfo */

    tmpRescGrpInfo = RescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        myRescInfo = tmpRescGrpInfo->rescInfo;
        if (strcmp (rescName, myRescInfo->rescName) == 0) {
            *rescInfo = myRescInfo;
            return (0);
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    /* no match */
#if 0	/* this has problem for subsequent query. need to mkresc to work  */
    if (strcmp (rescName, BUNDLE_RESC) == 0) {
	/* it is the virtual bundleResc. Make one */
	rescInfo_t *myRescInfo;
        myRescInfo = ( rescInfo_t* )malloc (sizeof (rescInfo_t));
        memset (myRescInfo, 0, sizeof (rescInfo_t));
        myRescInfo->rodsServerHost = ServerHostHead;
        rstrcpy (myRescInfo->zoneName, ZoneInfoHead->zoneName, NAME_LEN);
        rstrcpy (myRescInfo->rescName, BUNDLE_RESC, NAME_LEN);
        rstrcpy (myRescInfo->rescLoc, "localhost", NAME_LEN);
        rstrcpy (myRescInfo->rescType, "unix file system", NAME_LEN);
	myRescInfo->rescTypeInx = getRescTypeInx (myRescInfo->rescType);
	rstrcpy (myRescInfo->rescClass, "bundle", NAME_LEN);
	myRescInfo->rescClassInx = getRescClassInx (myRescInfo->rescClass);
	rstrcpy (myRescInfo->rescVaultPath, "/bundle", MAX_NAME_LEN);
        myRescInfo->quotaLimit = RESC_QUOTA_UNINIT;     /* not initialized */
        queResc (myRescInfo, NULL, &RescGrpInfo, BOTTOM_FLAG);
	*rescInfo = myRescInfo;
	return 0;
    }
#endif
    rodsLog (LOG_DEBUG1,
      "resolveResc: resource %s not configured in RCAT", rescName);
    return (SYS_INVALID_RESC_INPUT);
}

#if 0	/* replaced by getRescCnt */
/* getNumResc - count the number of resources in the rescGrpInfo link list.
 */

int
getNumResc (rescGrpInfo_t *rescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo;
    int numResc = 0;

    tmpRescGrpInfo = rescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        numResc++;
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    return (numResc);
}
#endif

/* sortResc - Sort the resources given in the rescGrpInfo link list
 * according to the sorting scheme given in sortScheme. sortScheme
 * can be "random", "byRescClass" or "byLoad". The sorted rsources
 * is also given in rescGrpInfo.
 */

int
sortResc (rsComm_t *rsComm, rescGrpInfo_t **rescGrpInfo,
char *sortScheme)
{
    int numResc;

    if (sortScheme == NULL) {
        return (0);
    }

    if (rescGrpInfo == NULL || *rescGrpInfo == NULL) {
        return (0);
    }

    numResc = getRescCnt (*rescGrpInfo);

    if (numResc <= 1) {
        return (0);
    }

    if (sortScheme == NULL) {
        return (0);
    }

    if (strcmp (sortScheme, "random") == 0) {
        sortRescRandom (rescGrpInfo);
    } else if (strcmp (sortScheme, "byRescClass") == 0) {
        sortRescByType (rescGrpInfo);
        } else if (strcmp (sortScheme, "byLoad") == 0) {
        sortRescByLoad (rsComm, rescGrpInfo);
    } else {
            rodsLog (LOG_ERROR,
              "sortResc: unknown sortScheme %s", sortScheme);
    }

    return (0);
}

/* sortRescRandom - source the resources in the rescGrpInfo link list
 * randomly.
 */

int
sortRescRandom (rescGrpInfo_t **rescGrpInfo)
{
    int *randomArray;
    int numResc;
    int i, j, status;
    rescGrpInfo_t *tmpRescGrpInfo;
    rescInfo_t **rescInfoArray;

    tmpRescGrpInfo = *rescGrpInfo;
    numResc = getRescCnt (tmpRescGrpInfo);

    if (numResc <= 1) {
        return (0);
    }
    if ((status = getRandomArray (&randomArray, numResc)) < 0) return status;
    rescInfoArray = ( rescInfo_t** )malloc (numResc * sizeof (rescInfo_t *));
    for (i = 0; i < numResc; i++) {
        j = randomArray[i] - 1;
        rescInfoArray[j] = tmpRescGrpInfo->rescInfo;
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    tmpRescGrpInfo = *rescGrpInfo;
    for (i = 0; i < numResc; i++) {
        tmpRescGrpInfo->rescInfo = rescInfoArray[i];
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    free (rescInfoArray);
    free (randomArray);
    return 0;
}

/* sortRescByType - sort the resource in the rescGrpInfo link list by
 * resource type in the order of CACHE_CL, ARCHIVAL_CL and the rest.
 */

int
sortRescByType (rescGrpInfo_t **rescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo, *tmp1RescGrpInfo;
    rescInfo_t *tmpRescInfo, *tmp1RescInfo;

    tmpRescGrpInfo = *rescGrpInfo;

    /* float CACHE_CL to top */

    while (tmpRescGrpInfo != NULL) {
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (RescClass[tmpRescInfo->rescClassInx].classType == CACHE_CL) {
            /* find a slot to exchange rescInfo */
            tmp1RescGrpInfo = *rescGrpInfo;
            while (tmp1RescGrpInfo != NULL) {
                if (tmp1RescGrpInfo == tmpRescGrpInfo) break;
                tmp1RescInfo = tmp1RescGrpInfo->rescInfo;
                if (RescClass[tmp1RescInfo->rescClassInx].classType > CACHE_CL) {
                    tmpRescGrpInfo->rescInfo = tmp1RescInfo;
                    tmp1RescGrpInfo->rescInfo = tmpRescInfo;
                    break;
                }
                tmp1RescGrpInfo = tmp1RescGrpInfo->next;
            }
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

    /* float ARCHIVAL_CL to second */

    while (tmpRescGrpInfo != NULL) {
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (RescClass[tmpRescInfo->rescClassInx].classType == ARCHIVAL_CL) {
            /* find a slot to exchange rescInfo */
            tmp1RescGrpInfo = *rescGrpInfo;
            while (tmp1RescGrpInfo != NULL) {
                if (tmp1RescGrpInfo == tmpRescGrpInfo) break;
                tmp1RescInfo = tmp1RescGrpInfo->rescInfo;
                if (RescClass[tmp1RescInfo->rescClassInx].classType >
		 ARCHIVAL_CL) {
                    tmpRescGrpInfo->rescInfo = tmp1RescInfo;
                    tmp1RescGrpInfo->rescInfo = tmpRescInfo;
                    break;
                }
                tmp1RescGrpInfo = tmp1RescGrpInfo->next;
            }
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

    return 0;
}

/* sortRescByLoad - sort the resource in the rescGrpInfo link list by
 * load with the lightest load first.
 */

int
sortRescByLoad (rsComm_t *rsComm, rescGrpInfo_t **rescGrpInfo)
{
    int i, j, loadmin, loadList[MAX_NSERVERS], nresc, status,
     timeList[MAX_NSERVERS];
    char rescList[MAX_NSERVERS][MAX_NAME_LEN], *tResult;
    rescGrpInfo_t *tmpRescGrpInfo, *tmp1RescGrpInfo;
    rescInfo_t *tmpRescInfo;
    genQueryInp_t genQueryInp;
    genQueryOut_t *genQueryOut = NULL;
    time_t timenow;

    /* query the database in order to retrieve the information on the
     * resources' load */
    memset(&genQueryInp, 0, sizeof (genQueryInp));
    addInxIval(&genQueryInp.selectInp, COL_SLD_RESC_NAME, 1);
    addInxIval(&genQueryInp.selectInp, COL_SLD_LOAD_FACTOR, 1);
    addInxIval(&genQueryInp.selectInp, COL_SLD_CREATE_TIME, SELECT_MAX);
    /* XXXXX a tmp fix to increase no. of resource to 2560 */
    genQueryInp.maxRows = MAX_SQL_ROWS * 10;
    status =  rsGenQuery(rsComm, &genQueryInp, &genQueryOut);
    if ( status == 0 ) {
        nresc = genQueryOut->rowCnt;
        for (i=0; i<genQueryOut->attriCnt; i++) {
            for (j=0; j<nresc; j++) {
                tResult = genQueryOut->sqlResult[i].value;
                tResult += j*genQueryOut->sqlResult[i].len;
                switch (i) {
                  case 0:
                    rstrcpy(rescList[j], tResult,
		      genQueryOut->sqlResult[i].len);
                    break;
                  case 1:
                    loadList[j] = atoi(tResult);
                    break;
                  case 2:
                    timeList[j] = atoi(tResult);
                    break;
                }
            }
	}
    } else {
        return (0);
    }
    clearGenQueryInp(&genQueryInp);
    freeGenQueryOut(&genQueryOut);

    /* find the least loaded resource among the ones for which the
     * information is available */
    tmpRescGrpInfo = *rescGrpInfo;
    tmpRescInfo = tmpRescGrpInfo->rescInfo;
    tmp1RescGrpInfo = tmpRescGrpInfo;
    loadmin = 100;
    /* retrieve local time in order to check if the load information is up
     * to date, ie less than MAX_ELAPSE_TIME seconds old */
    (void) time(&timenow);
    while (tmpRescGrpInfo != NULL) {
        for (i=0; i<nresc; i++) {
            if (strcmp(rescList[i], tmpRescGrpInfo->rescInfo->rescName) == 0) {
                if ( loadList[i] >= 0 && loadmin > loadList[i] &&
		  (timenow - timeList[i]) < MAX_ELAPSE_TIME ) {
                    loadmin = loadList[i];
                    tmpRescInfo = tmpRescGrpInfo->rescInfo;
                    tmp1RescGrpInfo = tmpRescGrpInfo;
                }
            }
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    /* exchange rescInfo with the head */
    tmp1RescGrpInfo->rescInfo = (*rescGrpInfo)->rescInfo;
    (*rescGrpInfo)->rescInfo = tmpRescInfo;

    return 0;
}

/* sortRescByLocation - float LOCAL_HOST resources to the top */
int
sortRescByLocation (rescGrpInfo_t **rescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo, *tmp1RescGrpInfo;
    rescInfo_t *tmpRescInfo, *tmp1RescInfo;

    tmpRescGrpInfo = *rescGrpInfo;

    /* float CACHE_CL to top */

    while (tmpRescGrpInfo != NULL) {
        int tmpClass, tmp1Class;
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (isLocalHost (tmpRescInfo->rescLoc)) {
            tmpClass = RescClass[tmpRescInfo->rescClassInx].classType;
            /* find a slot to exchange rescInfo */
            tmp1RescGrpInfo = *rescGrpInfo;
            while (tmp1RescGrpInfo != NULL) {
                if (tmp1RescGrpInfo == tmpRescGrpInfo) break;
                tmp1RescInfo = tmp1RescGrpInfo->rescInfo;
                tmp1Class = RescClass[tmp1RescInfo->rescClassInx].classType;
                if (tmp1Class > tmpClass ||
                 (tmp1Class == tmpClass &&
                  isLocalHost (tmp1RescInfo->rescLoc) == 0)) {
                    tmpRescGrpInfo->rescInfo = tmp1RescInfo;
                    tmp1RescGrpInfo->rescInfo = tmpRescInfo;
                    break;
                }
                tmp1RescGrpInfo = tmp1RescGrpInfo->next;
            }
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

    return 0;
}

/* getRescClass - Given the rescInfo, returns the classType of the resource.
 */

int
getRescClass (rescInfo_t *rescInfo)
{
    int classType;

    if (rescInfo == NULL) return USER__NULL_INPUT_ERR;

    classType = RescClass[rescInfo->rescClassInx].classType;

    return classType;
}

/* getRescGrpClass - Get the classType of the resources in a resource group
 * (given in rescGrpInfo). Return COMPOUND_CL if one of the resource is
 * this class. Otherwise return the class of the top one in the list.
 */

int
getRescGrpClass (rescGrpInfo_t *rescGrpInfo, rescInfo_t **outRescInfo)
{
    rescInfo_t *tmpRescInfo;
    rescGrpInfo_t *tmpRescGrpInfo = rescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (getRescClass (tmpRescInfo) == COMPOUND_CL) {
            *outRescInfo = tmpRescInfo;
            return COMPOUND_CL;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    *outRescInfo = NULL;
    /* just use the top */
    return (getRescClass(rescGrpInfo->rescInfo));
}

/* compareRescAddr - Given 2 rescInfo, if they have the same host address,
 * return 1. Otherwise, return 0.
 * YYYY - compareRescAddr - this routine is currently not used
 */

int
compareRescAddr (rescInfo_t *srcRescInfo, rescInfo_t *destRescInfo)
{
    rodsHostAddr_t srcAddr;
    rodsHostAddr_t destAddr;
    rodsServerHost_t *srcServerHost = NULL;
    rodsServerHost_t *destServerHost = NULL;

    bzero (&srcAddr, sizeof (srcAddr));
    bzero (&destAddr, sizeof (destAddr));

    rstrcpy (srcAddr.hostAddr, srcRescInfo->rescLoc, NAME_LEN);
    rstrcpy (destAddr.hostAddr, destRescInfo->rescLoc, NAME_LEN);

    resolveHost (&srcAddr, &srcServerHost);
    resolveHost (&destAddr, &destServerHost);

    if (srcServerHost == destServerHost)
        return 1;
    else
        return 0;
}

/* getCacheRescInGrp - get the cache resc in the resource group specified
 * by rescGroupName. If rescGroupName does not exist, find the rescGroupName
 * that include memberRescInfo. Either rescGroupName or memberRescInfo must
 * exist. If rescGroupName is zero len, the rescGroupName will be updated.
 */
int
getCacheRescInGrp (rsComm_t *rsComm, char *rescGroupName,
rescInfo_t *memberRescInfo, rescInfo_t **outCacheResc)
{
    int status;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    rescGrpInfo_t *tmpRescGrpInfo;

    *outCacheResc = NULL;

    if (rescGroupName == NULL || strlen (rescGroupName) == 0) {

        if (memberRescInfo == NULL) {
            rodsLog (LOG_ERROR,
              "getCacheRescInGrp: no rescGroupName input");
            return SYS_NO_CACHE_RESC_IN_GRP;
        }

        /* no input rescGrp. Try to find one that matches rescInfo. */
        status = getRescGrpOfResc (rsComm, memberRescInfo, &myRescGrpInfo);
        if (status < 0) {
            rodsLog (LOG_NOTICE,
              "getCacheRescInGrp:getRescGrpOfResc err for %s. stat=%d",
              memberRescInfo->rescName, status);
            return status;
        } else if (rescGroupName != NULL) {
            rstrcpy (rescGroupName, myRescGrpInfo->rescGroupName, NAME_LEN);
        }
    } else {
        status = resolveRescGrp (rsComm, rescGroupName, &myRescGrpInfo);
        if (status < 0) return status;
    }
    tmpRescGrpInfo = myRescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        rescInfo_t *tmpRescInfo;
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (RescClass[tmpRescInfo->rescClassInx].classType == CACHE_CL) {
            *outCacheResc = tmpRescInfo;
            freeAllRescGrpInfo (myRescGrpInfo);
            return 0;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    freeAllRescGrpInfo (myRescGrpInfo);
    return SYS_NO_CACHE_RESC_IN_GRP;
}

int
getRescInGrpByClass (rsComm_t *rsComm, char *rescGroupName,
int rescClass, rescInfo_t **outCacheResc, rescGrpInfo_t **outRescGrp)
{
    int status;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    rescGrpInfo_t *tmpRescGrpInfo;

    *outCacheResc = NULL;

    if (rescGroupName == NULL || strlen (rescGroupName) == 0) {
        rodsLog (LOG_NOTICE,
          "getRescInGrpByClass: NULL rescGroupName input");
	    return USER__NULL_INPUT_ERR;
    }
    status = resolveRescGrp (rsComm, rescGroupName, &myRescGrpInfo);
    if (status < 0) return status;
    tmpRescGrpInfo = myRescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        rescInfo_t *tmpRescInfo;
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (RescClass[tmpRescInfo->rescClassInx].classType == rescClass) {
            *outCacheResc = tmpRescInfo;
	    if (outRescGrp != NULL) {
		*outRescGrp = myRescGrpInfo;
	    } else {
                freeAllRescGrpInfo (myRescGrpInfo);
	    }
            return 0;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    freeAllRescGrpInfo (myRescGrpInfo);
    return SYS_NO_CACHE_RESC_IN_GRP;
}

/* getRescInGrp - Given the rescName string and the rescGroupName string
 * get the rescInfo of the resource in the resource group. If rescName
 * is not in rescGroupName, return SYS_UNMATCHED_RESC_IN_RESC_GRP.
 */

int
getRescInGrp (rsComm_t *rsComm, char *rescName, char *rescGroupName,
rescInfo_t **outRescInfo)
{
    int status;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    rescGrpInfo_t *tmpRescGrpInfo;

    if (rescGroupName == NULL || strlen (rescGroupName) == 0)
        return USER__NULL_INPUT_ERR;

    status = resolveRescGrp (rsComm, rescGroupName, &myRescGrpInfo);

    if (status < 0) return status;

    tmpRescGrpInfo = myRescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        rescInfo_t *tmpRescInfo;
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        if (strcmp (tmpRescInfo->rescName, rescName) == 0) {
            if (outRescInfo != NULL)
                *outRescInfo = tmpRescInfo;
            freeAllRescGrpInfo (myRescGrpInfo);
            return 0;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    freeAllRescGrpInfo (myRescGrpInfo);
    return SYS_UNMATCHED_RESC_IN_RESC_GRP;
}

/* getRescGrpOfResc - Given a resource represented by rescInfo, get
 * the resource group where this resource is a member. The output is
 * the resource group link list.
 */

int
getRescGrpOfResc (rsComm_t *rsComm, rescInfo_t * rescInfo,
rescGrpInfo_t **rescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo, *myRescGrpInfo;
    rescGrpInfo_t *outRescGrpInfo = NULL;
    rescInfo_t *myRescInfo;
    int status;

    *rescGrpInfo = NULL;

    if ((status = initRescGrp (rsComm)) < 0) return status;

    /* in cache ? */
    tmpRescGrpInfo = CachedRescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        myRescGrpInfo = tmpRescGrpInfo;
        while (myRescGrpInfo != NULL) {
            myRescInfo = myRescGrpInfo->rescInfo;
            if (strcmp (rescInfo->rescName, myRescInfo->rescName) == 0) {
                replRescGrpInfo (tmpRescGrpInfo, &outRescGrpInfo);
                outRescGrpInfo->cacheNext = *rescGrpInfo;
                *rescGrpInfo = outRescGrpInfo;
                break;
            }
            myRescGrpInfo = myRescGrpInfo->next;
        }

        tmpRescGrpInfo = tmpRescGrpInfo->cacheNext;
    }

    if (*rescGrpInfo == NULL)
        return SYS_NO_CACHE_RESC_IN_GRP;
    else
        return 0;
}

/* isRescsInSameGrp - check if 2 rescources are in the same rescGroup
 * returns 1 if match, 0 for no match.
 */

int
isRescsInSameGrp (rsComm_t *rsComm, char *rescName1, char *rescName2,
rescGrpInfo_t **outRescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo, *myRescGrpInfo;
    rescInfo_t *myRescInfo;
    int status;
    int match1, match2;

    if (outRescGrpInfo != NULL)
        *outRescGrpInfo = NULL;

    if ((status = initRescGrp (rsComm)) < 0) return status;

    /* in cache ? */
    tmpRescGrpInfo = CachedRescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        myRescGrpInfo = tmpRescGrpInfo;
        match1 = match2 = 0;
        while (myRescGrpInfo != NULL) {
            myRescInfo = myRescGrpInfo->rescInfo;
            if (match1 == 0 &&
              strcmp (rescName1, myRescInfo->rescName) == 0) {
                match1 = 1;
            } else if (match2 == 0 &&
              strcmp (rescName2, myRescInfo->rescName) == 0) {
                match2 = 1;
            }
            if (match1 == 1 && match2 == 1) {
                if (outRescGrpInfo != NULL) *outRescGrpInfo = tmpRescGrpInfo;
                return 1;
            }
            myRescGrpInfo = myRescGrpInfo->next;
        }

        tmpRescGrpInfo = tmpRescGrpInfo->cacheNext;
    }
    return 0;
}

/* initRescGrp - Initialize the CachedRescGrpInfo queue. Query all resource
 * groups and queue them it the CachedRescGrpInfo link list. Resources in
 * each resource group are queued by class.
 */

int
initRescGrp (rsComm_t *rsComm)
{
    genQueryInp_t genQueryInp;
    rescGrpInfo_t *tmpRescGrpInfo;
    genQueryOut_t *genQueryOut = NULL;
    sqlResult_t *rescName, *rescGrpName;
    char *rescNameStr, *rescGrpNameStr;
    char *curRescGrpNameStr = NULL;
    int i;
    int status = 0;
    int savedRescGrpStatus = 0;

    if (RescGrpInit > 0) return 0;

    RescGrpInit = 1;

    /* query all resource groups */
    memset (&genQueryInp, 0, sizeof (genQueryInp_t));

    addInxIval (&genQueryInp.selectInp, COL_R_RESC_NAME, 1);
    addInxIval (&genQueryInp.selectInp, COL_RESC_GROUP_NAME, ORDER_BY);

    /* increased to 2560 */
    genQueryInp.maxRows = MAX_SQL_ROWS * 10;

    status =  rsGenQuery (rsComm, &genQueryInp, &genQueryOut);

    clearGenQueryInp (&genQueryInp);

    if (status < 0) {
        if (status == CAT_NO_ROWS_FOUND)
            return 0;
        else
            return status;
    }

    if ((rescName = getSqlResultByInx (genQueryOut, COL_R_RESC_NAME)) ==
      NULL) {
        rodsLog (LOG_NOTICE,
          "initRescGrp: getSqlResultByInx for COL_R_RESC_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((rescGrpName = getSqlResultByInx (genQueryOut, COL_RESC_GROUP_NAME)) ==
      NULL) {
        rodsLog (LOG_NOTICE,
          "initRescGrp: getSqlResultByInx for COL_RESC_GROUP_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    tmpRescGrpInfo = NULL;
    for (i = 0;i < genQueryOut->rowCnt; i++) {
        rescNameStr = &rescName->value[rescName->len * i];
        rescGrpNameStr = &rescGrpName->value[rescGrpName->len * i];
        if (tmpRescGrpInfo != NULL && curRescGrpNameStr != NULL) {
            if (strcmp (rescGrpNameStr, curRescGrpNameStr) != 0) {
		rescGrpInfo_t *myRescGrpInfo;
                /* a new rescGrp. queue the current one */
                tmpRescGrpInfo->cacheNext = CachedRescGrpInfo;
		if (savedRescGrpStatus != 0) {
		    myRescGrpInfo = tmpRescGrpInfo;
		    while (myRescGrpInfo != NULL) {
                        myRescGrpInfo->status = savedRescGrpStatus;
			myRescGrpInfo = myRescGrpInfo->next;
		    }
		}
                savedRescGrpStatus = 0;
                CachedRescGrpInfo = tmpRescGrpInfo;
                tmpRescGrpInfo = NULL;
            }
        }
        curRescGrpNameStr = rescGrpNameStr;
        status = resolveAndQueResc (rescNameStr, rescGrpNameStr,
          &tmpRescGrpInfo);
        if (status < 0) {
            if (status == SYS_RESC_IS_DOWN) {
                savedRescGrpStatus = SYS_RESC_IS_DOWN;
            } else {
                rodsLog (LOG_NOTICE,
                  "initRescGrp: resolveAndQueResc error for %s. status = %d",
                  rescNameStr, status);
                freeGenQueryOut (&genQueryOut);
                return (status);
            }
        }
    }
    /* query the remaining in cache */
    if (tmpRescGrpInfo != NULL) {
        tmpRescGrpInfo->status = savedRescGrpStatus;
        tmpRescGrpInfo->cacheNext = CachedRescGrpInfo;
        CachedRescGrpInfo = tmpRescGrpInfo;
    }
    if (genQueryOut != NULL &&  genQueryOut->continueInx > 0) {
        rodsLog (LOG_NOTICE,
          "initRescGrp: number of resources in resc groups exceed 2560");
        freeGenQueryOut (&genQueryOut);
	return SYS_INVALID_RESC_INPUT;
    } else {
        freeGenQueryOut (&genQueryOut);
        return 0;
    }
}

/* setDefaultResc - set the default resource and put the result in the
 * outRescGrpInfo link list. This is normally called by the msiSetDefaultResc
 * micro-service. The defaultRescList and optionStr are input
 * parameters of msiSetDefaultResc.
 * If optionStr is "force" and this user is not LOCAL_PRIV_USER_AUTH,
 * only a resource in the defaultRescList will be used.
 * If optionStr is "preferred", the resource group is taken from condInput
 * if it exists and the preferred resource in this resource group is given
 * in the defaultRescList.
 * Otherwise, use the resource given in condInput, then in defaultRescList.
 *
 */

int
setDefaultResc (rsComm_t *rsComm, char *defaultRescList, char *optionStr,
keyValPair_t *condInput, rescGrpInfo_t **outRescGrpInfo)
{
    rescGrpInfo_t *myRescGrpInfo = NULL;
    rescGrpInfo_t *defRescGrpInfo = NULL;
    rescGrpInfo_t *tmpRescGrpInfo, *prevRescGrpInfo;
    char *value = NULL;
    strArray_t strArray;
    int i, status;
    char *defaultResc;
    int startInx;

    if (defaultRescList != NULL && strcmp (defaultRescList, "null") != 0 &&
      optionStr != NULL &&  strcmp (optionStr, "forced") == 0 &&
      rsComm->proxyUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
        condInput = NULL;
    }

    memset (&strArray, 0, sizeof (strArray));

    status = parseMultiStr (defaultRescList, &strArray);

#if 0   /* this will produce no output */
    if (status <= 0)
        return (0);
#endif

    value = strArray.value;
    if (strArray.len <= 1) {
        startInx = 0;
        defaultResc = value;
    } else {
        /* select one on the list randomly */
        startInx = random() % strArray.len;
        defaultResc = &value[startInx * strArray.size];
    }
    status = getRescInfoAndStatus (rsComm, defaultResc, NULL, &defRescGrpInfo);
    if (status < 0) {
        /* the random defaultResc is not good. pick other */
        if (strArray.len <= 1) {
            defaultResc = NULL;
        } else {
            for (i = 0; i < strArray.len; i++) {
                defaultResc =  &value[i * strArray.size];
                status = getRescInfoAndStatus (rsComm, defaultResc, NULL,
                &defRescGrpInfo);
                if (status >= 0) break;
            }
            if (status < 0) defaultResc = NULL;
        }
    }

    if (strcmp (optionStr, "preferred") == 0) {
        /* checkinput first, then default */
        status = getRescInfoAndStatus (rsComm, NULL, condInput,
          &myRescGrpInfo);
        if (status >= 0) {
            freeAllRescGrpInfo (defRescGrpInfo);
            if (strlen (myRescGrpInfo->rescGroupName) > 0) {
                for (i = 0; i < strArray.len; i++) {
                    int j;
                    j = startInx + i;
                    if (j >= strArray.len) {
                        /* wrap around */
                        j = strArray.len - j;
                    }
                    tmpRescGrpInfo = myRescGrpInfo;
                    prevRescGrpInfo = NULL;
                    while (tmpRescGrpInfo != NULL) {
                        rescInfo_t *myResc = tmpRescGrpInfo->rescInfo;
                        if (strcmp (&value[j * strArray.size],
                          myResc->rescName) == 0 &&
                            myResc->rescStatus != INT_RESC_STATUS_DOWN) {
                            /* put it on top */
                            if (prevRescGrpInfo != NULL) {
                                prevRescGrpInfo->next = tmpRescGrpInfo->next;
                                tmpRescGrpInfo->next = myRescGrpInfo;
                                myRescGrpInfo = tmpRescGrpInfo;
                            }
                            break;
                        }
                        prevRescGrpInfo = tmpRescGrpInfo;
                        tmpRescGrpInfo = tmpRescGrpInfo->next;
                    }
                }
            }
        } else {
            /* error may mean there is no input resource. try to use the
             * default resource by dropping down */
            if (defRescGrpInfo != NULL) {
                myRescGrpInfo = defRescGrpInfo;
                status = 0;
            }
        }
    } else if (strcmp (optionStr, "forced") == 0 &&
      rsComm->clientUser.authInfo.authFlag < LOCAL_PRIV_USER_AUTH) {
        if (defRescGrpInfo != NULL) {
            myRescGrpInfo = defRescGrpInfo;
        }
    } else {
        /* input first. If not good, use def */
        status = getRescInfo (rsComm, NULL, condInput,
          &myRescGrpInfo);
        if (status < 0) {
            if (status == USER_NO_RESC_INPUT_ERR && defRescGrpInfo != NULL) {
                /* user have not input a resource. Use default */
                myRescGrpInfo = defRescGrpInfo;
                status = 0;
            } else {
                freeAllRescGrpInfo (defRescGrpInfo);
            }
        } else {
            freeAllRescGrpInfo (defRescGrpInfo);
        }
    }

    if (status == CAT_NO_ROWS_FOUND)
      status = SYS_RESC_DOES_NOT_EXIST;

    if (value != NULL)
        free (value);

    if (status >= 0) {
        *outRescGrpInfo = myRescGrpInfo;
    } else {
        *outRescGrpInfo = NULL;
    }

    return (status);
}

/* getRescInfoAndStatus - Given a resource or rescGroup name, see if the
 * resource is up or down.
 * The resource given in condInput is taken first, then rescName.
 * If the resource is a resource group, a INT_RESC_STATUS_UP will be
 * returned if any one of the resource in the group is up.
 * If the resource is up, the resource info will be put in the rescGrpInfo
 * link list.
 */
int
getRescInfoAndStatus (rsComm_t *rsComm, char *rescName, keyValPair_t *condInput,
rescGrpInfo_t **rescGrpInfo)
{
    int status;
    rescGrpInfo_t *myRescGrpInfo = NULL;
    rescGrpInfo_t *tmpRescGrpInfo;

    status = getRescInfo (rsComm, rescName, condInput, &myRescGrpInfo);
    if (status >= 0 && *myRescGrpInfo->rescGroupName != '\0') {
        /* make sure at least one resc is not down */
        tmpRescGrpInfo = myRescGrpInfo;
        while (tmpRescGrpInfo != NULL) {
            if (tmpRescGrpInfo->rescInfo->rescStatus != INT_RESC_STATUS_DOWN)
                break;
            tmpRescGrpInfo = tmpRescGrpInfo->next;
        }
        if (tmpRescGrpInfo == NULL) {
            status = SYS_RESC_IS_DOWN;
            if (myRescGrpInfo != NULL) freeAllRescGrpInfo (myRescGrpInfo);
        }
    }
    if (status >= 0) {
        *rescGrpInfo = myRescGrpInfo;
    } else {
        *rescGrpInfo = NULL;
    }
    return status;
}

/* initResc - Initialize the global resource link list RescGrpInfo which
 * contains all resources known to the system.
 */

int
initResc (rsComm_t *rsComm)
{
    genQueryInp_t genQueryInp;
    genQueryOut_t *genQueryOut = NULL;
    int status;
    int continueInx;

    memset (&genQueryInp, 0, sizeof (genQueryInp));

    addInxIval (&genQueryInp.selectInp, COL_R_RESC_ID, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_RESC_NAME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_ZONE_NAME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_TYPE_NAME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_CLASS_NAME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_LOC, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_VAULT_PATH, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_FREE_SPACE, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_RESC_INFO, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_RESC_COMMENT, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_CREATE_TIME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_MODIFY_TIME, 1);
    addInxIval (&genQueryInp.selectInp, COL_R_RESC_STATUS, 1);

    genQueryInp.maxRows = MAX_SQL_ROWS;

    if (RescGrpInfo != NULL) {
        /* we are updating RescGrpInfo */
        freeAllRescGrp (RescGrpInfo);
        RescGrpInfo = NULL;
    }

    continueInx = 1;	/* a fake one so it will do the first query */
    while (continueInx > 0) {
        status =  rsGenQuery (rsComm, &genQueryInp, &genQueryOut);

        if (status < 0) {
            if (status !=CAT_NO_ROWS_FOUND) {
                rodsLog (LOG_NOTICE,
                  "initResc: rsGenQuery error, status = %d",
                  status);
            }
            clearGenQueryInp (&genQueryInp);
            return (status);
        }

        status = procAndQueRescResult (genQueryOut);

        if (status < 0) {
            rodsLog (LOG_NOTICE,
              "initResc: rsGenQuery error, status = %d", status);
            freeGenQueryOut (&genQueryOut);
	    break;
        } else {
	    if (genQueryOut != NULL) {
		continueInx = genQueryInp.continueInx =
		genQueryOut->continueInx;
                freeGenQueryOut (&genQueryOut);
	    } else {
		continueInx = 0;
	    }
	}
    }
    clearGenQueryInp (&genQueryInp);
    return (status);
}

/* procAndQueRescResult - Process the query results from initResc ().
 * Queue the results in the global resource link list RescGrpInfo.
 */

int
procAndQueRescResult (genQueryOut_t *genQueryOut)
{
    sqlResult_t *rescId, *rescName, *zoneName, *rescType, *rescClass;
    sqlResult_t *rescLoc, *rescVaultPath, *freeSpace, *rescInfo;
    sqlResult_t *rescComments, *rescCreate, *rescModify, *rescStatus;
    char *tmpRescId, *tmpRescName, *tmpZoneName, *tmpRescType, *tmpRescClass;
    char *tmpRescLoc, *tmpRescVaultPath, *tmpFreeSpace, *tmpRescInfo;
    char *tmpRescComments, *tmpRescCreate, *tmpRescModify, *tmpRescStatus;
    int i, status;
    rodsHostAddr_t addr;
    rodsServerHost_t *tmpRodsServerHost;
    rescInfo_t *myRescInfo;

    if (genQueryOut == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: NULL genQueryOut");
        return (0);
    }

    if ((rescId = getSqlResultByInx (genQueryOut, COL_R_RESC_ID)) == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_RESC_ID failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((rescName = getSqlResultByInx(genQueryOut, COL_R_RESC_NAME)) == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_RESC_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((zoneName = getSqlResultByInx(genQueryOut, COL_R_ZONE_NAME)) == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_ZONE_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescType = getSqlResultByInx(genQueryOut, COL_R_TYPE_NAME)) == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_TYPE_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescClass = getSqlResultByInx(genQueryOut,COL_R_CLASS_NAME))==NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult: getSqlResultByInx for COL_R_CLASS_NAME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescLoc = getSqlResultByInx (genQueryOut, COL_R_LOC)) == NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_LOC failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescVaultPath = getSqlResultByInx (genQueryOut, COL_R_VAULT_PATH))
      == NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult: getSqlResultByInx for COL_R_VAULT_PATH failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((freeSpace = getSqlResultByInx (genQueryOut, COL_R_FREE_SPACE)) ==
      NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult: getSqlResultByInx for COL_R_FREE_SPACE failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescInfo = getSqlResultByInx (genQueryOut, COL_R_RESC_INFO)) ==
      NULL) {
        rodsLog (LOG_NOTICE,
          "procAndQueResResult: getSqlResultByInx for COL_R_RESC_INFO failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescComments = getSqlResultByInx (genQueryOut, COL_R_RESC_COMMENT))
      == NULL) {
        rodsLog (LOG_NOTICE,
        "procAndQueResResult:getSqlResultByInx for COL_R_RESC_COMMENT failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescCreate = getSqlResultByInx (genQueryOut, COL_R_CREATE_TIME))
      == NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult:getSqlResultByInx for COL_R_CREATE_TIME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }
    if ((rescModify = getSqlResultByInx (genQueryOut, COL_R_MODIFY_TIME))
      == NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult:getSqlResultByInx for COL_R_MODIFY_TIME failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

    if ((rescStatus = getSqlResultByInx (genQueryOut, COL_R_RESC_STATUS))
      == NULL) {
        rodsLog (LOG_NOTICE,
         "procAndQueResResult:getSqlResultByInx for COL_R_RESC_STATUS failed");
        return (UNMATCHED_KEY_OR_INDEX);
    }

#if 0	/* do multiple continueInx */
    if (RescGrpInfo != NULL) {
        /* we are updating RescGrpInfo */
        freeAllRescGrp (RescGrpInfo);
        RescGrpInfo = NULL;
    }
#endif
    for (i = 0;i < genQueryOut->rowCnt; i++) {
        tmpRescId = &rescId->value[rescId->len * i];
        tmpRescName = &rescName->value[rescName->len * i];
        tmpZoneName = &zoneName->value[zoneName->len * i];
        tmpRescType = &rescType->value[rescType->len * i];
        tmpRescClass = &rescClass->value[rescClass->len * i];
        tmpRescLoc = &rescLoc->value[rescLoc->len * i];
        tmpRescVaultPath = &rescVaultPath->value[rescVaultPath->len * i];
        tmpFreeSpace = &freeSpace->value[freeSpace->len * i];
        tmpRescInfo = &rescInfo->value[rescInfo->len * i];
        tmpRescComments = &rescComments->value[rescComments->len * i];
        tmpRescCreate = &rescCreate->value[rescCreate->len * i];
        tmpRescModify = &rescModify->value[rescModify->len * i];
        tmpRescStatus = &rescStatus->value[rescStatus->len * i];

        /* queue the host. XXXXX resolveHost does not deal with zone yet.
         * need to do so */
        memset (&addr, 0, sizeof (addr));
        rstrcpy (addr.hostAddr, tmpRescLoc, LONG_NAME_LEN);
        rstrcpy (addr.zoneName, tmpZoneName, NAME_LEN);
        status = resolveHost (&addr, &tmpRodsServerHost);
        if (status < 0) {
            rodsLog (LOG_NOTICE,
              "procAndQueRescResult: resolveHost error for %s",
              addr.hostAddr);
        }
        /* queue the resource */
        myRescInfo = ( rescInfo_t* )malloc (sizeof (rescInfo_t));
        memset (myRescInfo, 0, sizeof (rescInfo_t));
        myRescInfo->rodsServerHost = tmpRodsServerHost;
        myRescInfo->rescId = strtoll (tmpRescId, 0, 0);
        rstrcpy (myRescInfo->zoneName, tmpZoneName, NAME_LEN);
        rstrcpy (myRescInfo->rescName, tmpRescName, NAME_LEN);
        rstrcpy (myRescInfo->rescLoc, tmpRescLoc, NAME_LEN);
        rstrcpy (myRescInfo->rescType, tmpRescType, NAME_LEN);
        /* convert rescType to rescTypeInx */
        myRescInfo->rescTypeInx = getRescTypeInx (tmpRescType);
        if (myRescInfo->rescTypeInx < 0) {
            rodsLog (LOG_ERROR,
             "procAndQueResResult: Unknown rescType %s. Resource %s will not be configured",
              tmpRescType, myRescInfo->rescName);
            continue;
        }
        rstrcpy (myRescInfo->rescClass, tmpRescClass, NAME_LEN);
        myRescInfo->rescClassInx = getRescClassInx (tmpRescClass);
        if (myRescInfo->rescClassInx < 0) {
            rodsLog (LOG_ERROR,
             "procAndQueResResult: Unknown rescClass %s. Resource %s will not be configured",
              tmpRescClass, myRescInfo->rescName);
            continue;
        }
        rstrcpy (myRescInfo->rescVaultPath, tmpRescVaultPath, MAX_NAME_LEN);
        if (RescTypeDef[myRescInfo->rescTypeInx].driverType == WOS_FILE_TYPE &&
          tmpRodsServerHost->localFlag == LOCAL_HOST) {
	    /* For WOS_FILE_TYPE, the vault path is wosHost/wosPolicy */
	    char wosHost[MAX_NAME_LEN], wosPolicy[MAX_NAME_LEN];
	    char *tmpStr;
            if (splitPathByKey (tmpRescVaultPath, wosHost, wosPolicy, '/') < 0)
            {
		rodsLog (LOG_ERROR,
                  "procAndQueResResult:splitPathByKey of wosHost error for %s",
		  wosHost, wosPolicy);
	    } else {
		tmpStr = (char*)malloc (strlen (wosHost) + 40);
                snprintf (tmpStr, MAX_NAME_LEN, "%s=%s", WOS_HOST_ENV, wosHost);
                putenv (tmpStr);
//              free(tmpStr);	// don't free or environment is lost
		tmpStr = (char*)malloc (strlen (wosPolicy) + 40);
                snprintf (tmpStr, MAX_NAME_LEN, "%s=%s",
		  WOS_POLICY_ENV, wosPolicy);
                putenv (tmpStr);
//              free(tmpStr);	// don't free or environment is lost
		if (ProcessType == SERVER_PT) {
		    rodsLog (LOG_NOTICE,
		     "Set WOS env wosHost=%s, wosPolicy=%s",
		      wosHost, wosPolicy);
		}
	    }
        }
        rstrcpy (myRescInfo->rescInfo, tmpRescInfo, LONG_NAME_LEN);
        rstrcpy (myRescInfo->rescComments, tmpRescComments, LONG_NAME_LEN);
        myRescInfo->freeSpace = strtoll (tmpFreeSpace, 0, 0);
        rstrcpy (myRescInfo->rescCreate, tmpRescCreate, TIME_LEN);
        rstrcpy (myRescInfo->rescModify, tmpRescModify, TIME_LEN);
        if (strstr (tmpRescStatus, RESC_DOWN) != NULL) {
            myRescInfo->rescStatus = INT_RESC_STATUS_DOWN;
        } else {
            myRescInfo->rescStatus = INT_RESC_STATUS_UP;
        }
        myRescInfo->quotaLimit = RESC_QUOTA_UNINIT;     /* not initialized */
        queResc (myRescInfo, NULL, &RescGrpInfo, BOTTOM_FLAG);
    }
    return (0);
}

/* getHostStatusByRescInfo - get the status host based on rescStatus */
int
getHostStatusByRescInfo (rodsServerHost_t *rodsServerHost)
{
    rescGrpInfo_t *tmpRescGrpInfo;
    rescInfo_t *myRescInfo;
    int match = 0;

    tmpRescGrpInfo = RescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
        myRescInfo = tmpRescGrpInfo->rescInfo;
        if (myRescInfo->rodsServerHost == rodsServerHost) {
            if (myRescInfo->rescStatus == INT_RESC_STATUS_UP) {
                return INT_RESC_STATUS_UP;
            }
            match = 1;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

    if (match == 0) {
        /* no match in resc. assume up */
        return INT_RESC_STATUS_UP;
    } else {
        return INT_RESC_STATUS_DOWN;
    }
}

/* printLocalResc - Print the global resource link list RescGrpInfo which
 * contains all resources known to the system. This routine is normally
 * used by the irodsServer for logging.
 */

int
printLocalResc ()
{
    rescInfo_t *myRescInfo;
    rescGrpInfo_t *tmpRescGrpInfo;
    rodsServerHost_t *tmpRodsServerHost;
    int localRescCnt = 0;

#ifndef windows_platform
#ifdef IRODS_SYSLOG
        rodsLog (LOG_NOTICE,"Local Resource configuration: \n");
#else /* IRODS_SYSLOG */
    fprintf (stderr, "Local Resource configuration: \n");
#endif /* IRODS_SYSLOG */
#else
        rodsLog (LOG_NOTICE,"Local Resource configuration: \n");
#endif

    /* search the global RescGrpInfo */

    tmpRescGrpInfo = RescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        myRescInfo = tmpRescGrpInfo->rescInfo;
        tmpRodsServerHost = (rodsServerHost_t*)myRescInfo->rodsServerHost;
        if (tmpRodsServerHost->localFlag == LOCAL_HOST) {
#ifndef windows_platform
#ifdef IRODS_SYSLOG
        rodsLog (LOG_NOTICE,"   RescName: %s, VaultPath: %s\n",
              myRescInfo->rescName, myRescInfo->rescVaultPath);
#else /* IRODS_SYSLOG */
            fprintf (stderr, "   RescName: %s, VaultPath: %s\n",
              myRescInfo->rescName, myRescInfo->rescVaultPath);
#endif /* IRODS_SYSLOG */
#else
        rodsLog (LOG_NOTICE,"   RescName: %s, VaultPath: %s\n",
              myRescInfo->rescName, myRescInfo->rescVaultPath);
#endif
            localRescCnt ++;
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

#ifndef windows_platform
#ifdef IRODS_SYSLOG
        rodsLog (LOG_NOTICE,"\n");
#else /* IRODS_SYSLOG */
    fprintf (stderr, "\n");
#endif /* IRODS_SYSLOG */
#else
    rodsLog (LOG_NOTICE,"\n");
#endif

    if (localRescCnt == 0) {
#ifndef windows_platform
#ifdef IRODS_SYSLOG
        rodsLog (LOG_NOTICE,"   No Local Resource Configured\n");
#else /* IRODS_SYSLOG */
        fprintf (stderr, "   No Local Resource Configured\n");
#endif /* IRODS_SYSLOG */
#else
        rodsLog (LOG_NOTICE,"   No Local Resource Configured\n");
#endif
    }

    return (0);
}

/* queResc - Queue a resource given in myRescInfo to the rescGrpInfoHead
 * link list. If rescGroupName is not NULL, copy the string to
 * myRescGrpInfo->rescGroupName. If topFlag == TOP_FLAG, queue it
 * to the top of the link list. Otherwise queue it to the bottom.
 */

int
queResc (rescInfo_t *myRescInfo, char *rescGroupName,
rescGrpInfo_t **rescGrpInfoHead, int topFlag)
{
    rescGrpInfo_t *myRescGrpInfo;
    int status;

    if (myRescInfo == NULL)
        return (0);

    myRescGrpInfo = (rescGrpInfo_t *) malloc (sizeof (rescGrpInfo_t));
    memset (myRescGrpInfo, 0, sizeof (rescGrpInfo_t));

    myRescGrpInfo->rescInfo = myRescInfo;

    if (rescGroupName != NULL) {
        rstrcpy (myRescGrpInfo->rescGroupName, rescGroupName, NAME_LEN);
    }

    status = queRescGrp (rescGrpInfoHead, myRescGrpInfo, topFlag);

    return (status);

}

/* queRescGrp - Queue a resource given in myRescGrpInfo to the
 * rescGrpInfoHead link list.  If flag == TOP_FLAG, queue it
 * to the top of the link list. Otherwise queue it to the bottom.
 */

int
queRescGrp (rescGrpInfo_t **rescGrpInfoHead, rescGrpInfo_t *myRescGrpInfo,
int flag)
{
    rescInfo_t *tmpRescInfo, *myRescInfo;
    rescGrpInfo_t *tmpRescGrpInfo, *lastRescGrpInfo = NULL;

    myRescInfo = myRescGrpInfo->rescInfo;
    tmpRescGrpInfo = *rescGrpInfoHead;
    if (flag == TOP_FLAG) {
        *rescGrpInfoHead = myRescGrpInfo;
        myRescGrpInfo->next = tmpRescGrpInfo;
    } else {
        while (tmpRescGrpInfo != NULL) {
            tmpRescInfo = tmpRescGrpInfo->rescInfo;
            if (flag == BY_TYPE_FLAG && myRescInfo != NULL &&
              tmpRescInfo != NULL) {
                if (RescClass[myRescInfo->rescClassInx].classType <
                  RescClass[tmpRescInfo->rescClassInx].classType) {
                    break;
                }
            }
            lastRescGrpInfo = tmpRescGrpInfo;
            tmpRescGrpInfo = tmpRescGrpInfo->next;
        }

        if (lastRescGrpInfo == NULL) {
            *rescGrpInfoHead = myRescGrpInfo;
        } else {
            lastRescGrpInfo->next = myRescGrpInfo;
        }
        myRescGrpInfo->next = tmpRescGrpInfo;
    }

    return (0);
}

/* freeAllRescGrp - Free the rescGrpInfo_t link list given in rescGrpHead
 */

int
freeAllRescGrp (rescGrpInfo_t *rescGrpHead)
{
    rescGrpInfo_t *tmpRrescGrp, *nextRrescGrp;

    tmpRrescGrp = rescGrpHead;
    while (tmpRrescGrp != NULL) {
        nextRrescGrp = tmpRrescGrp->next;
        if (tmpRrescGrp->rescInfo != NULL) free (tmpRrescGrp->rescInfo);
        free (tmpRrescGrp);
        tmpRrescGrp = tmpRrescGrp->next;
    }
    return 0;
}

/* getRescType - Return a fileDriverType_t in the rescInfo. The return value
 * can be UNIX_FILE_TYPE, HPSS_FILE_TYPE, NT_FILE_TYPE ----
 */

int
getRescType (rescInfo_t *rescInfo)
{
    int rescTypeInx;

    if (rescInfo == NULL) return USER__NULL_INPUT_ERR;
    rescTypeInx = rescInfo->rescTypeInx;
    if (rescTypeInx >= NumRescTypeDef) return RESCTYPEINX_EMPTY_IN_STRUCT_ERR;
    return (RescTypeDef[rescTypeInx].driverType);
}

/* getRescTypeInx - Given a resource type string token (e.g.,
 * output of "iadmin lt resc_type" - "unix file system", hpss ...),
 * get the index number into the RescTypeDef array.
 */

int
getRescTypeInx (char *rescType)
{
    int i;

    if (rescType == NULL) {
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }

    for (i = 0; i < NumRescTypeDef; i++) {
        if (strstr (rescType, RescTypeDef[i].typeName) != NULL) {
            return (i);
        }
    }
    rodsLog (LOG_NOTICE,
      "getRescTypeInx: No match for input rescType %s", rescType);

    return (UNMATCHED_KEY_OR_INDEX);
}

/* getRescClassInx - Given a resource class string token (e.g.,
 * output of "iadmin lt resc_class" - cache, archive, compound ...),
 * get the index number into the RescClass array.
 */

int
getRescClassInx (char *rescClass)
{
    int i;

    if (rescClass == NULL) {
        return SYS_INTERNAL_NULL_INPUT_ERR;
    }

    for (i = 0; i < NumRescClass; i++) {
        if (strstr (rescClass, RescClass[i].className) != NULL) {
	    /* "primary" is currently not used */
            if (strstr (rescClass, "primary") != NULL) {
                return (i | PRIMARY_FLAG);
            } else {
                return (i);
            }
        }
    }
    rodsLog (LOG_NOTICE,
      "getRescClassInx: No match for input rescClass %s", rescClass);

    return (UNMATCHED_KEY_OR_INDEX);
}

/* getMultiCopyPerResc - call the acSetMultiReplPerResc rule to see if
 * multiple copies can exist in a resource. If the rule allows multi copy,
 * return 1, otherwise retun 0.
 */

int
getMultiCopyPerResc (rsComm_t *rsComm)
{
    ruleExecInfo_t rei;

    memset (&rei, 0, sizeof (rei));
    rei.rsComm = rsComm;
    applyRule ("acSetMultiReplPerResc", NULL, &rei, NO_SAVE_REI);
    if (strcmp (rei.statusStr, MULTI_COPIES_PER_RESC) == 0) {
        return 1;
    } else {
        return 0;
    }
}

/* getRescCnt - count the number of resources in the rescGrpInfo link list.
 */

int
getRescCnt (rescGrpInfo_t *myRescGrpInfo)
{
    rescGrpInfo_t *tmpRescGrpInfo;
    int rescCnt = 0;

    tmpRescGrpInfo = myRescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        rescCnt ++;
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }

    return (rescCnt);
}

int
updateResc (rsComm_t *rsComm)
{
    int status;

    rescGrpInfo_t *tmpRescGrpInfo, *nextRescGrpInfo;

    /* free CachedRescGrpInfo */
    freeAllRescGrpInfo (CachedRescGrpInfo);
    CachedRescGrpInfo = NULL;
    RescGrpInit = 0;

    /* free the configured rescInfo */
    tmpRescGrpInfo = RescGrpInfo;
    while (tmpRescGrpInfo != NULL) {
	nextRescGrpInfo = tmpRescGrpInfo->next;
	free (tmpRescGrpInfo->rescInfo);
        free (tmpRescGrpInfo);
        tmpRescGrpInfo = nextRescGrpInfo;
    }
    RescGrpInfo = NULL;
    status = initResc (rsComm);

    return status;
}

/* matchSameHostRescByType - find a resource on the same host
 * as the input myRescInfo but with the input driverType.
 * YYYY - this routine is currently not used
 */

rescInfo_t *
matchSameHostRescByType (rescInfo_t *myRescInfo, int driverType)
{
    rescInfo_t *tmpRescInfo;
    rescGrpInfo_t *tmpRescGrpInfo;

    tmpRescGrpInfo = RescGrpInfo;

    while (tmpRescGrpInfo != NULL) {
        tmpRescInfo = tmpRescGrpInfo->rescInfo;
        /* same location ? */
        if (strcmp (myRescInfo->rescLoc, tmpRescInfo->rescLoc) == 0) {
            /* match driverType ? */
            int rescTypeInx = tmpRescInfo->rescTypeInx;
            if (RescTypeDef[rescTypeInx].driverType == driverType) {
                return tmpRescInfo;
            }
        }
        tmpRescGrpInfo = tmpRescGrpInfo->next;
    }
    return NULL;
}

int
getFileDriverTypeByResc (rescInfo_t *rescInfo)
{
    int rescTypeInx;
    int fileDriverType;

    if (rescInfo == NULL) return USER__NULL_INPUT_ERR;

    rescTypeInx = rescInfo->rescTypeInx;
    fileDriverType = RescTypeDef[rescTypeInx].driverType;
    return fileDriverType;
}

int
setDataTypeByResc (dataObjInfo_t *dataObjInfo)
{
    int fileDriverType;

    if (dataObjInfo == NULL || dataObjInfo->rescInfo == NULL)
        return USER__NULL_INPUT_ERR;

    fileDriverType = getFileDriverTypeByResc (dataObjInfo->rescInfo);

    if (fileDriverType == PYDAP_FILE_TYPE ||
      fileDriverType == ERDDAP_FILE_TYPE || fileDriverType == TDS_FILE_TYPE) {
        rstrcpy (dataObjInfo->dataType, "netcdf", NAME_LEN);
    }
    return 0;
}

redpajama_set_name: RedPajamaGithub


What are some of the firsts that you remember; your first love, your first kiss, or the first time your parents took you to the beach? We all have so many firsts but which one sticks in your head the most? Which one first changed your life? Mine was my first concert. My life changed so much that I learned through music how to cope with the bad things life put me through. My first concert was actually a music festival. We got to see the Kumbia Kings. They were a Mexican-American boy band from Corpus Christi, Texas founded by AB Quintanilla, Selena's brother. I remember the atmosphere and how excited I was, not only to see them but all of the bands. I remember dancing and singing the songs and the vibe that was in the crowd. I remember the exact feeling I felt when AB spoke about his sister and we danced and sang at the top of our lungs to her songs. At 13 years old that feeling left a profound moment in my heart and soul; that is when I knew music was my first love.
As I got older, I went to more concerts and music festivals and learned to experience music. Each musical experience was different for me and each one has touched my soul in a different way. I wanted my loved ones to have the same experience and to love music as much as I did so I started a tradition of taking them to their first concerts.
My niece Stephanie was first. I took her and a cousin to see Backstreet Boys when they were at the top of every teeny boppers list to see and we were all big fans. When I sprung the news on my niece she was so excited that the waiting time for the show was excruciating. I just wanted her to feel what I felt when I saw these musicians on stage and I just could not wait to see her little face when we got to the venue. She had a blast, we laughed, we cried, we sang at the top of our lungs, and we even did the cliché lighter side to side action (this was before everyone had a cell phone). This was definitely one of the best nights for us and only forged a stronger bond between us.
In my last years in high school I became obsessed with one artist. While I love all music, I am not the biggest rap fan but this artist had something that other rappers at the time did not have; something to say. Eminem still holds a very special part of my heart but at that age it was a crazed teenaged obsession. I had his posters plastered from wall to ceiling in my room, I could sing all his songs, but I needed to see him in concert. I would go by myself but why do that alone with I could share the experience with another Slim Shady lover? My cousin Philip, who is like a little brother to me also loved Marshall as much as I did. When I told him I wanted us to go see the Up in Smoke Tour he was beside himself with excitement. The concert did not let me down. I got to see Eminem live and in color, Dre, and Snoop and I got to share the excitement with one of the most important people in my life. We even waited afterwards to try and catch a glimpse of Em but to no avail. Even though we did not get to see him up close and personal, my cousin and I get to have that memory together forever.
I continued to pop concert cherries and have till this day but the best has been taking my kids to their first concerts. I had the opportunity to take my daughter to see Taylor Swift when she was only 7. We had to drive to Austin get a room and take a bus to a secret location. We then had to walk 3 miles to get to the spot, but that did not deter my little Swifty. We got tto the location and she had the time of her life and I could not be happier. Seeing her dance under the flashing lights while her hero sang her favorite songs to her was the best feeling ever. I had to recreate that feeling for my son who was older so I bought tickets in Arkansas to see Twenty-One Pilots, his favorite band. We drove four hours to the high rise Marriott. We then took a cab to the location and I had to hold on to him before he ran off into a crowd of teenagers. His face lit up at the site of the venue he was just so excited. He sang along to Tyler, he danced, and cheered at the band's performance. I got to see them fall in love with music and I get to see them as that love grows. I get teary-eyed when they put their earphones and zone out to their favorite artists because that is where my love started.
We all have first loves but there is nothing that can replace mine. Music is my first love and will be my last love. I have had the pleasure of passing that love onto my family and friends and we will always have those memories. Peace, Love, and Music everyone; pass it on!
Great article! I love the Eminem reference. I'm still a fan myself. Music is a great unifier, and people from all walks of life can come together over a song and in that moment forget about the things that can divide us.
Love your stuff! Keep it up!


text:
Legio I Parthica
Legio I Parthica: one of the Roman legions. Its name indicates that it was recruited to fight against the Parthians.
This army unit and its sisters II Parthica and III Parthica were founded in 197 by the emperor Lucius Septimius Severus, who used them in his war against the Parthian Empire. The expedition was very successful and culminated in the sack of the Parthian capital Ctesiphon. According to the Roman historian Cassius Dio the First and the Third remained in the region, because Severus annexed Mesopotamia (northern Iraq) and converted it into a province.note[Cassius Dio, Roman History 55.24.4.] The Second Parthian Legion was transferred to the Alban mountain near Rome, where it served as the empire's strategic reserve.
It is possible that the full name of the First Parthian Legion was I Parthica Severiana Antoniniana: Severus, who had come to power after a civil war, claimed that he had been adopted by the emperor Marcus Aurelius Antoninus. This fake adoption may have been commemorated in the name of the new legion.
I Parthica was stationed in a fortress called Singara (modern Balat Sinjar), where it stayed for centuries, defending the empire against the Parthians and - after the fall of their empire - the Sasanian Persians. The province Mesopotamia was not a common province, because its governors were prefects from the equestrian order, not senatorial governors. Accordingly, the commander of I Parthica was not a senator but a Roman knight.
The First must have taken part in the expeditions of third century, like the one led by Severus' son Caracalla (217) and the war waged by Severus Alexander against the new, Sasanian Persian empire. The Sasanians had invaded the Roman empire in 230 and had installed an emperor in Emessa, but Severus Alexander was able to restore order and invade Iraq. In 244, the Romans again invaded Iraq, but their emperor Gordian III died and was succeeded by Philippus Arabs, who owed his throne to the Sasanian king Shapur I.
Your Philippus Arabs submits to Shapur; Valerian being seized. Relief from Naqš-e Rustam
Even worse was to come In 256 Shapur captured Satala (the fortress of XV Apollinaris), and two years later he sacked Trapezus. When the Roman emperor Valerian tried to restore order and invaded Iraq, he was defeated and captured. These Roman defeats are commemorated on several Sasanian monuments. Captive Roman soldiers were ordered to build a bridge at modern Shushtar.
However, under the emperors Odaenathus of Palmyra (r.261-267) and Diocletian (r.284-305), the Romans restored their fortunes and in 298, a peace treaty was concluded in which the Persians had to give up territories in northern Mesopotamia. The First Parthian Legion must have played a role during these campaigns, but we have almost no information about them.
It was not uncommon that subunits of a legion were sent to other parts of the empire. From inscriptions, we know that soldiers of the First Parthian legion served in Lycia and Cyrenaica. The soldier who buried his son in Cilicia was probably not on a foreign mission, because Cilicia is close to Mesopotamia. (It is possible that this soldier belonged to III Parthica.)
In 360, the First Parthian legion was still at Singara, because it is mentioned as one of the units that tried to defend the city against a Persian attack. Unfortunately, they failed, and I Parthica was transferred to Constantina, where it is mentioned in the early fifth century.
C. Wolff, "Legio I Parthica", in: Yann Le Bohec, Les légions de Rome sous le Haut-Empire (2000 Lyon) 247-249
article by Emil Ritterling.
This page was created in 2002; last modified on 6 May 2019.
Home » Articles » Legions » Legio I Parthica
Subdiscipline
Legion: alphabetically (article)
Legion: chronological (article)


This training will provide you with the knowledge you need to develop and implement a successful online marketing plan. Learn the ins and outs of online marketing, including email marketing, SEO, and Google Ads. Note: Please bring a laptop.


Do corporations have to file contributions with the SEC?
Intro IP Survey Multiple Choice Questions Book/whatever?
SEC or State AG internship?
Has anyone heard of a 2L Law Review EIC?
Criminal Procedure II Practice Exams?
The ABA Should Revoke Accreditation of 33% of Law Schools?
24 HR Exam, still outline?
How many people at your school want clinic but can't get it?
I need a favor from a Harvard student!
Dean's Scholar in clinic at HLS?
Anyone here not going to their graduation?


text:
Canon EOS (APS-C)
Canon EOS (full format)
Nikon DX (APS-C)
Nikon FX (full format)
Nikon 1 (CX)
Sony Alpha (APS-C)
Sony Alpha (full format)
Four-Thirds
DSLR Reviews
Lens Test FAQ
PZ Rating System
Follow @photozonede
Canon EOS (full F.)
Nikon FX (full F.)
Sony Alpha (full F.)
Pentax SMC DA 10-17mm f/3.5-4.5 ED[IF] Fisheye - Review / Test Report
Lens Reviews - Pentax
Sample Images & Verdict
Review by Klaus Schroiff, published May 2007
Special thanks to Rüdiger Neumann for providing this lens for testing!
Pentax always had a love affair with fisheye lenses and they were also the first to design a full format fisheye zoom lens. The current Pentax SMC DA 10-17mm f/3.5-4.5 ED[IF] Fisheye is the latest incarnation dedicated for Pentax APS-C DSLRs. This lens is also available as a Tokina incarnation for Canon and Nikon users. The full frame (APS-C) fisheye has a field-of-view ranging from 180 degrees (diagonal) at 10mm to 100 degrees at 17mm.
Traditionally fisheyes are often used for aerial-, underwater- and some kind of indoor photography. Due to the uncorrected extreme field-of-view the fisheye perspective can produce some oooohs and aaahs from your audience but it shouldn´t be used too often in presentations because the effect of awe-inspiring vistas fades rapidly. Besides it isn´t exactly easy to achieve a good composition. It is worth to note that you can now generate a distortion-corrected image by using distortion correction tools (e.g PTLens) so you can combine the best of both worlds (fisheye and corrected ultra-wides) if you're willing to invest some post-processing efforts.
The build quality of the lens is very decent thanks to a combination of metal and good quality plastic parts assembled with very tight tolerances (no wobbling). Both the zoom and focus ring operate quite smooth and slightly damped. The lens extends a few millimeters at 10mm and 17mm and the shortest length is reached at about 12mm. Regarding its extreme field-of-view it is impossible to mount any filters. A newly developed SP (Super Protective) coating made of a special fluoride compound has been applied to the front element making it easier to clean and more resistant against water and fingerprints.
The lens has no internal AF motor and relies on a slotted drive screw operated by the camera. As a result AF operation will generate a moderate degree of noise. The AF speed is extremely fast and accurate on the K10D. Thanks to a "Quick-Shift Focus System" manual focusing is instantly possible once the AF has achieved focus.
Equiv. focal length 15-25.5 mm (full format equivalent)
Equiv. aperture f/5.3-f/6.8 (full format equivalent, in terms of depth-of-field)
Optical construction 10 elements in 8 groups inc. ED elements
Number of aperture blades 6
min. focus distance 0.14 m (max. magnification ratio 1:2.5 @ 17mm)
Dimensions 68 x 72 mm
Filter size -
Hood built-in, petal shaped
Other features -
© by opticallimits.com
Disclaimer & Cookie Statement


Palm Springs, CA has become such a hotbed for travel. It's attracting a diverse crowd ranging from hipsters and celebs to the young to the retired. One of the best features of the area is that there's a ton of cheap and free things to do in Palm Springs. When vacationing, the costs can really start to add up quickly, especially for a family or a group. All the meals out and entertainment start to make your hearty travel budget look, well, like a pauper's purse.
Who knew there were so many free things to do in Palm Springs? Your first stop should be to the Palm Springs Visitor Center, to get an idea of the vast array of Free Activities that await you. We've gathered a few of our favorite free things to do in Palm Springs and the general vicinity.
If you're in the area on any Thursday night, drop downtown to Palm Canyon Drive. There are several blocks of the street that are closed off to traffic, and the area becomes a great big street fair. Food, music, arts and crafts, vendors, and a farmer's market are all rolled into one location. This is also one of the best places for relaxing and people watching. For $20, we usually have a great evening of fun and dinner for 2 of us. Villagefest is every Thursday evening until ten p.m.
There are two great districts for window shopping in the area, each with their own feel. Take your choice of Palm Canyon Drive in downtown Palm Springs, or head a little further south to El Paseo in Palm Desert. The shops on Palm Canyon are kitschy-cool, quirky, and you can pick up some pretty cool souvenirs. El Paseo is the 'Rodeo Drive' of the desert, with many designer shops and stores exclusive to there or Beverly Hills. Both options are a great way to spend an afternoon. You can also head down Hwy 111 and check out the furniture and antique consignment shops, if home décor is more your speed.
Visit the Coachella Valley Preserve, and you can get the opportunity to stand on one of the most famous and major earthquake faults in the world. Located in Thousand Palms, it's just a short drive to the park from Palm Springs, which has hiking and picnic facilities available. While the Coachella Valley Preserve is free, they do run on donations. There are also natural hot springs in Thousand Palms, and many of the local hotels have reasonable day rates to use their therapeutic pools.
Palm Springs has many historical and art museums, most of which are free or rather inexpensive. Start with the Historical Society downtown for a look at the history from the native Indian settlements through the post WWII movie stars shaping the town into a resort area, to the present day developments. The Palm Springs Art Museum is free, and there are many public art displays to view.
This highway takes you from Rancho Mirage all the way up to Idyllwild. It's about a 30-40 minute drive to Idyllwild, which is a sort of artsy mountain town. The road is full of switchback curves and goes up the side of the mountain, so be aware of that. There are great places to turn off and look out over the entire Coachella valley. The Palms to Pines Highway starts at one end of El Paseo, so pair them up for a great day of free fun. This is one of the best totally free things to do in Palm Springs.
The admission is free, but this place is always packed. Locals and visitors alike come for the wide variety of arts and crafts, food, produce, clothing furniture, and entertainment. Still going strong after more than thirty years, this is the place to be on a weekend morning. This is one of the premier places to acquire local art, ceramics, and handicrafts, too. It's a lot of fun, and another great place to people watch. COD Street Fair is open every Saturday and Sunday morning from 7:00 a.m. in the parking lot at COD, Palm Desert.
The weather in Palm Springs is pretty amazing. Getting outside is one of the best free things to do in Palm Springs. Take a hike to one of the many oasis, play tennis at one of the many free parks, or go swimming. Make sure to take care of yourself, as the desert heat can cause serious health problems. You'll find that a lot of locals start heading outdoors after about 6 pm. You may even want to take a trip to Joshua Tree National Park.
Palm Springs has a thriving art scene. The whole Coachella Valley does. Check out the art galleries, and the little hidden arts districts like Backstreet Art District in Palm Springs. These are usually free, and many times, there may even be a special event going on that you can attend.
A couple of bonus activities – if you're in town at the right time, there are a couple of great local festivals to visit; both are held in Indio. The first is the Date Festival, held in mid-February each year. Indio is one of the largest date producing areas of the world, and this festival is more than seventy years old. The second is the International Tamale Festival held the first weekend in December. The food network has rated it as one of the top ten food festivals in the nation, and it has been around since 1992. Enjoy every kind of tamale imaginable, plus a carnival like atmosphere for the kids.
These are just a few of the great cheap and free things to do in Palm Springs and the Coachella Valley. There are tons more ways to enjoy yourself without going broke.