-static void
-jetsam_priority_from_job(job_t j, bool front, jetsam_priority_entry_t *jp)
-{
- jp->pid = j->p;
- jp->flags |= front ? kJetsamFlagsFrontmost : 0;
-}
-
-static int
-job_cmp(const job_t *lhs, const job_t *rhs)
-{
- job_t _lhs = *lhs;
- job_t _rhs = *rhs;
- /* Sort in descending order. (Priority correlates to the soonishness with which you will be killed.) */
- if( _lhs->jetsam_priority > _rhs->jetsam_priority ) {
- return -1;
- } else if( _lhs->jetsam_priority < _rhs->jetsam_priority ) {
- return 1;
+void
+jetsam_property_setup(launch_data_t obj, const char *key, job_t j)
+{
+ job_log(j, LOG_DEBUG, "Setting Jetsam properties for job...");
+ if( strcasecmp(key, LAUNCH_JOBKEY_JETSAMPRIORITY) == 0 && launch_data_get_type(obj) == LAUNCH_DATA_INTEGER ) {
+ j->jetsam_priority = (typeof(j->jetsam_priority))launch_data_get_integer(obj);
+ job_log(j, LOG_DEBUG, "Priority: %d", j->jetsam_priority);
+ } else if( strcasecmp(key, LAUNCH_JOBKEY_JETSAMMEMORYLIMIT) == 0 && launch_data_get_type(obj) == LAUNCH_DATA_INTEGER ) {
+ j->jetsam_memlimit = (typeof(j->jetsam_memlimit))launch_data_get_integer(obj);
+ job_log(j, LOG_DEBUG, "Memory limit: %d", j->jetsam_memlimit);
+ } else if( strcasecmp(key, LAUNCH_KEY_JETSAMFRONTMOST) == 0 ) {
+ /* Ignore. We only recognize this key so we don't complain when we get SpringBoard's request.
+ * You can't set this in a plist.
+ */
+ } else if( strcasecmp(key, LAUNCH_KEY_JETSAMLABEL) == 0 ) {
+ /* Ignore. This key is present in SpringBoard's request dictionary, so we don't want to
+ * complain about it.
+ */
+ } else {
+ job_log(j, LOG_ERR, "Unknown Jetsam key: %s", key);