static void pids_init(void) { int i; if ((childpids = malloc(maxprocs * sizeof(*childpids))) == NULL) errx(1, "malloc failed"); for (i = 0; i < maxprocs; i++) clearslot(i); }
static int pids_remove(pid_t pid) { int slot; if ((slot = findslot(pid)) < 0) return (0); clearslot(slot); curprocs--; return (1); }
/* * Save the instrument to a slot */ void Bank::savetoslot(unsigned int ninstrument, Part *part) { clearslot(ninstrument); const int maxfilename = 200; char tmpfilename[maxfilename + 20]; ZERO(tmpfilename, maxfilename + 20); snprintf(tmpfilename, maxfilename, "%4d-%s", ninstrument + 1, (char *)part->Pname); //add the zeroes at the start of filename for(int i = 0; i < 4; i++) if(tmpfilename[i] == ' ') tmpfilename[i] = '0'; //make the filenames legal for(int i = 0; i < (int)strlen(tmpfilename); i++) { char c = tmpfilename[i]; if((c >= '0') && (c <= '9')) continue; if((c >= 'A') && (c <= 'Z')) continue; if((c >= 'a') && (c <= 'z')) continue; if((c == '-') || (c == ' ')) continue; tmpfilename[i] = '_'; } strncat(tmpfilename, ".xiz", maxfilename + 10); int fnsize = strlen(dirname) + strlen(tmpfilename) + 10; char *filename = new char[fnsize + 4]; ZERO(filename, fnsize + 2); snprintf(filename, fnsize, "%s/%s", dirname, tmpfilename); remove(filename); part->saveXML(filename); addtobank(ninstrument, tmpfilename, (char *) part->Pname); delete[] filename; }