static void initstats(void) { int i; actual_start = mkinterval(mktime(&destruction), mktime(&creation)); actual_complete = actual_start; tottasks = totstatz = totstatnz = 0; for (i = 0; i < NUM_RESOURCES; i++) { statistics[i][min] = DBL_MAX; statistics[i][max] = 0.0; statistics[i][tot] = 0.0; resRecNum[i] = 0; } }
static void setdefaults (void) { int n; char *confpath, *localHost; struct config_param acctdir[] = { {"LSF_RES_ACCTDIR", NULL}, {NULL, NULL} }; struct stat statBuf; char lsfUserName[MAX_LOGIN + 1]; details = 0; if ((confpath = getenv ("LSF_ENVDIR")) == NULL) confpath = "/etc"; ls_readconfenv (acctdir, confpath); if (acctdir[0].paramValue == NULL || stat (acctdir[0].paramValue, &statBuf) == -1) acctdir[0].paramValue = "/tmp"; strcpy (logfile, acctdir[0].paramValue); n = strlen (logfile); strncat (logfile, "/lsf.acct.", MAX_PATH - n); if ((localHost = ls_getmyhostname ()) == NULL) { ls_perror ("ls_getmyhostname"); return; } n = strlen (logfile); strncat (logfile, localHost, MAX_PATH - n); if (getLSFUser_ (lsfUserName, MAX_LOGIN + 1) != 0) { ls_perror ("getLSFUser_"); return; } strcpy (mylogin, lsfUserName); users[0] = mylogin; users[1] = NULL; hosts[0] = NULL; eternity = mkinterval (mktime (&creation), mktime (&destruction)); start = complete = eternity; }
struct interval_list *interval_add(struct interval_list *interval_list, int first, int last, void *map) { struct interval_list *e, **p; for (p = &interval_list; *p;) { e = *p; if (first > e->last + 1 || first > e->last && (map != e->map)) { /* e is below new range, skip it */ p = &e->next; } else if (e->first > last + 1 || e->first > last && (map != e->map)) { /* e is fully above new range, so insert new one here */ break; } else if (e->map == map) { /* merge e into new */ if (e->first <= first) { if (e->last >= last) { /* && e->first <= first */ /* Existing covers new: we're done */ return interval_list; } else { /* e->last < last && e->first <= first */ /* Enlarge new, delete existing */ first = e->first; *p = e->next; e->next = 0; rminterval(e); } } else { /* e->first > first */ if (e->last <= last) { /* && e->first > first */ /* New fully covers existing, delete existing */ *p = e->next; e->next = 0; rminterval(e); } else { /* e->last > last && e->first > first */ /* Extend existing */ e->first = first; return interval_list; } } } else { /* replace e with new */ if (e->first < first) { if (e->last <= last) { /* && e->first < first */ /* Top part of existing get cut-off by new */ e->last = first - 1; } else { /* e->last > last && e->first < first */ int org = e->last; void *orgmap = e->map; e->last = first - 1; p = &e->next; *p = mkinterval(*p, first, last, map); p = &(*p)->next; *p = mkinterval(*p, last + 1, org, orgmap); return interval_list; } } else { /* e->first >= first */ if (e->last <= last) { /* && e->first >= first */ /* Delete existing */ *p = e->next; e->next = 0; rminterval(e); } else { /* e->last > last && e->first >= first */ e->first = last + 1; break; } } } } *p = mkinterval(*p, first, last, map); return interval_list; }