int process_args( char* buffer, arg_t segments, char delim1, char delim2 ) { // Divide the string by the delimiting character to get individual segments int n_segments = get_instances( buffer, segments, delim1 ); // Dividne the substsrings by the secondary delimiter to get pairs for ( int i = 0; i < n_segments; ++i ) { get_pairs( segments[i], delim2 ); } return n_segments; }
int photoproc(struct tstat *tasks, int *taskslen) { static int setup; static pmID pmids[TASK_NMETRICS]; static pmDesc descs[TASK_NMETRICS]; pmResult *result; char **insts; int *pids, count, i; if (!setup) { setup_metrics(procmetrics, pmids, descs, TASK_NMETRICS); setup = 1; } fetch_metrics("task", TASK_NMETRICS, pmids, &result); /* extract external process names (insts) */ count = get_instances("task", TASK_GEN_NAME, descs, &pids, &insts); if (count > *taskslen) { size_t size; int ents = (*taskslen + PROCCHUNK); if (count > ents) ents = count; size = ents * sizeof(struct tstat); tasks = (struct tstat *)realloc(tasks, size); ptrverify(tasks, "photoproc [%ld]\n", (long)size); *taskslen = ents; } for (i=0; i < count; i++) { if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "%s: updating process %d: %s\n", pmProgname, pids[i], insts[i]); update_task(&tasks[i], pids[i], insts[i], result, descs); } if (pmDebug & DBG_TRACE_APPL0) fprintf(stderr, "%s: done %d processes\n", pmProgname, count); pmFreeResult(result); free(insts); free(pids); return count; }