int printksset_S(CSOUND *csound, PRINTKS *p){ char *sarg; sarg = ((STRINGDAT*)p->ifilcod)->data; if(sarg == NULL) return csoundInitError(csound, Str("null string\n")); p->old = cs_strdup(csound, sarg); return printksset_(csound, p, sarg); }
static int Load_CV_File_(CSOUND *csound, const char *filnam, char **allocp, int32 *len) { FILE *f; int length = 4096; unsigned int i = 0; int j = 0; MYFLT x; char *all; CVSTRUCT cvh = {0,0,0,0,0.0,0,0,0,0,{0}}; char buff[120]; char *p; f = fopen(filnam, "r"); csoundNotifyFileOpened(csound, filnam, CSFTYPE_CVANAL, 0, 0); all = (char *)csound->Malloc(csound, (size_t) length); (void)fgets(buff, 120, f); /* Skip CVANAL */ cvh.magic = CVMAGIC; p = fgets(buff, 120, f); if (p==NULL) return csoundInitError(csound, Str("Ill-formed CV file\n")); cvh.headBsize = strtol(p, &p, 10); cvh.dataBsize = strtol(p, &p, 10); cvh.dataFormat = strtol(p, &p, 10); cvh.samplingRate = (MYFLT)cs_strtod(p, &p); cvh.src_chnls = strtol(p, &p, 10); cvh.channel = strtol(p, &p, 10); cvh.Hlen = strtol(p, &p, 10); cvh.Format = strtol(p, &p, 10); /* fscanf(f, "%d %d %d %g %d %d %d %d\n", */ /* &cvh.headBsize, &cvh.dataBsize, &cvh.dataFormat, */ /* &cvh.samplingRate, &cvh.src_chnls, &cvh.channel, */ /* &cvh.Hlen, &cvh.Format); */ cvh.headBsize = sizeof(int32)*8 + sizeof(MYFLT); memcpy(&all[0], &cvh, sizeof(CVSTRUCT)); /* Read data until end, pack as MYFLTs */ for (i=sizeof(CVSTRUCT);;i+=sizeof(MYFLT)) { /* Expand as necessary */ if (i>=length-sizeof(MYFLT)-4) { //printf("expanding from %p[%d] to\n", all, length); all = csound->ReAlloc(csound, all, length+=4096); //printf("i=%d %p[%d]\n", i, all, length); } x = read_ieee(f, &j); if (j) break; memcpy(&all[i], &x, sizeof(MYFLT)); } fclose(f); /* and close it */ //printf("length=%d i=%d\n", length, i); *len = i; all = csound->ReAlloc(csound, all, i); *allocp = all; return 0; /* return 0 for OK */ }