static Value mathAbs(Context *ctx, const List<Value>& args) { if (args.getCount() != 1) { ctx->throwException(createException(ExcType::ValueError, "abs takes only one argument.")); } switch (args[0].type) { case ValueType::Float: { return createFloat(std::abs(args[0].f)); } case ValueType::Int: { return createInt(std::llabs(args[0].i)); } default: { ctx->throwException(createException(ExcType::TypeError, "Value is not convertable to float.")); } } SDL_assert_release(false); return createInt(0); }
void CFileSystemServiceImpl::internalWriteAllText(const wstring& path1, const wstring& text, const wstring& encoding) { BException ex; wstring ret; wstring path = makeValidPath(path1); FILE* file = NULL; wstringstream ssmode; ssmode << L"w"; if (encoding.size()) ssmode << L", ccs=" << checkValidEncoding(encoding); errno_t err = _wfopen_s(&file, path.c_str(), ssmode.str().c_str()); if (err) { wstringstream wss; wss << L"Failed to open file \"" << path << L"\"."; ex = createException(wss.str(), err); goto leave; } err = fputws(text.c_str(), file); if (err) { wstringstream wss; wss << L"Failed to write file \"" << path << L"\"."; ex = createException(wss.str(), err); goto leave; } leave: if (file) fclose(file); if (ex) throw ex; }
static Value methodCall(Context *ctx, const List<Value>& args) { if (args.getCount() < 1) { ctx->throwException(createException(ExcType::ValueError, "Method call requires at least 1 argument.")); } if (args[0].type != ValueType::Object) { ctx->throwException(createException(ExcType::TypeError, "Method call requires (method) object as first parameter.")); } HashMap<Str, Value>& members = ((ObjectData *)args[0].p)->members; Value func; Value obj; try { func = members.get("__func__"); obj = members.get("__obj__"); } catch (LookupException& e) { ctx->throwException(createException(ExcType::ValueError, "Invalid method object.")); SDL_assert_release(false); } List<Value> args2; args2.append(obj); args2.append(args.getCount()-1, args.getData()+1); return call(ctx, func, args2); }
static Value classNew(Context *ctx, const List<Value>& args) { if (args.getCount() < 1) { ctx->throwException(createException(ExcType::ValueError, "__new__/__call__ takes at least 1 argument.")); } Value class_ = args[0]; Value __base__ = createString("__base__"); Value base = getMember(ctx, class_, __base__); destroy(ctx, __base__); Value __typeID__ = createString("__typeID__"); Value typeID = getMember(ctx, class_, __typeID__); destroy(ctx, __typeID__); if (base.type != ValueType::Object) { ctx->throwException(createException(ExcType::TypeError, "Class base must be an object.")); } if (typeID.type != ValueType::Int) { ctx->throwException(createException(ExcType::TypeError, "Class type ID must be an integer.")); } Value resultHead = createObject(); HashMap<Str, Value>& resultMembers = ((ObjectData *)resultHead.p)->members; HashMap<Str, Value>& baseMembers = ((ObjectData *)base.p)->members; for (auto kv : baseMembers) { resultMembers.set(kv.first, createCopy(kv.second)); } resultMembers.set("__classTypeID__", createInt(typeID.i)); resultMembers.set("__class__", createCopy(args[0])); auto pos = resultMembers.find("__init__"); if (pos != resultMembers.end()) { destroy(ctx, callMethod(ctx, resultHead, "__init__", List<Value>(args.getCount()-1, args.getData()+1))); } else { if (args.getCount() != 1) { ctx->throwException(createException(ExcType::ValueError, "__new__/__call__ takes 1 argument.")); } } destroy(ctx, typeID); destroy(ctx, base); return resultHead; }
PyObject *PyCodeObject_ParseString(char *string, char **msg) { size_t length = strlen(string); PyObject *code_object, *tuple, *mystr; char *code_copy = GDKmalloc(length * sizeof(char)); char hex[3]; size_t i, j; hex[2] = '\0'; if (code_copy == NULL) { *msg = createException(MAL, "pyapi.eval", SQLSTATE(HY001) MAL_MALLOC_FAIL); return NULL; } // decode hex codes (e.g. \x00) in the string to the actual numeric // representation for (i = 2, j = 0; i < length - 2; i++) { if (string[i] == '\\' && string[i + 1] == '\\') i++; if (string[i] == '\\' && string[i + 1] == 't') { code_copy[j++] = '\t'; i++; } else if (string[i] == '\\' && string[i + 1] == 'n') { code_copy[j++] = '\n'; i++; } else if (string[i] == '\\' && string[i + 1] == 'x') { hex[0] = string[i + 2]; hex[1] = string[i + 3]; code_copy[j++] = (char)strtol(hex, NULL, 16); i += 3; } else { code_copy[j++] = string[i]; } } code_copy[j] = '\0'; tuple = PyTuple_New(1); mystr = PyString_FromStringAndSize( code_copy, j); // use FromStringAndSize because the string is not null-terminated PyTuple_SetItem(tuple, 0, mystr); code_object = PyObject_CallObject(marshal_loads, tuple); Py_DECREF(tuple); GDKfree(code_copy); if (code_object == NULL) { PyErr_Print(); *msg = createException(MAL, "pyapi.eval", SQLSTATE(PY000) "Failed to marshal.loads() encoded object"); return NULL; } *msg = MAL_SUCCEED; return code_object; }
EjsVar *ejsCreateException(Ejs *ejs, int slot, cchar *fmt, va_list fmtArgs) { EjsType *type; EjsVar *error; char *buf; if (ejs->exception) { buf = mprVasprintf(ejs, 0, fmt, fmtArgs); mprError(ejs, "Double exception: %s", buf); mprFree(buf); return ejs->exception; } if (!ejs->initialized || (ejs->flags & EJS_FLAG_EMPTY)) { buf = mprVasprintf(ejs, 0, fmt, fmtArgs); mprError(ejs, "Exception: %s", buf); mprFree(buf); return ejs->exception; } type = (EjsType*) ejsGetProperty(ejs, ejs->global, slot); if (type == 0) { type = ejs->errorType; } error = createException(ejs, type, fmt, fmtArgs); if (error) { ejsThrowException(ejs, error); } return error; }
str FITSdir(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { str msg = MAL_SUCCEED; str dir = *(str*)getArgReference(stk, pci, 1); DIR *dp; struct dirent *ep; fitsfile *fptr; char *s; int status = 0; (void)mb; dp = opendir(dir); if (dp != NULL) { char stmt[BUFSIZ]; char fname[BUFSIZ]; s = stmt; while ((ep = readdir(dp)) != NULL) { snprintf(fname, BUFSIZ, "%s%s", dir, ep->d_name); status = 0; fits_open_file(&fptr, fname, READONLY, &status); if (status == 0) { snprintf(stmt, BUFSIZ, ATTACHDIR, fname); msg = SQLstatementIntern(cntxt, &s, "fits.listofdir", TRUE, FALSE); fits_close_file(fptr, &status); } } (void)closedir(dp); }else msg = createException(MAL, "listdir", "Couldn't open the directory"); return msg; }
byps_ptr< vector<PFileInfo> > CFileSystemServiceImpl::findFiles(const wstring& path, const PFindOptions& ) { wstring search = makeValidPath(path); wstring dir = getDir(search); WIN32_FIND_DATA fd; HANDLE hfind = ::FindFirstFile(search.c_str(), &fd); if (hfind == INVALID_HANDLE_VALUE) throw createException(::GetLastError()); vector<PFileInfo>* fileInfos = new vector<PFileInfo>(); for (int32_t i = 0; i < 1000*1000; i++) { if (i != 0) { if (!::FindNextFile(hfind, &fd)) break; } PFileInfo fi = fileInfoFromWin32FindData(dir, fd); if (fi) { fileInfos->push_back(fi); } } ::FindClose(hfind); return byps_ptr< vector<PFileInfo> >(fileInfos); }
str SABgetLocalConnectionPort(int *ret) { str tmp, con, p; rethrow("sabaoth.getLocalConnectionHost", tmp, SABAOTHgetLocalConnection(&con)); /* this happens if no connection is available */ if (strcmp(con, (str)str_nil) == 0) { *ret = 0; GDKfree(con); return(MAL_SUCCEED); } /* con looks like mapi:monetdb://hostname:port */ /* do some poor man's parsing */ tmp = con; if ((p = strchr(con, ':')) == NULL) { p = createException(MAL, "sabaoth.getLocalConnectionHost", "invalid local connection string: %s", tmp); GDKfree(tmp); return(p); } if ((p = strchr(p + 1, ':')) == NULL) { p = createException(MAL, "sabaoth.getLocalConnectionHost", "invalid local connection string: %s", tmp); GDKfree(tmp); return(p); } if ((con = strchr(p + 1, ':')) == NULL) { p = createException(MAL, "sabaoth.getLocalConnectionHost", "invalid local connection string: %s", tmp); GDKfree(tmp); return(p); } if ((p = strchr(con + 1, '/')) == NULL) { p = createException(MAL, "sabaoth.getLocalConnectionHost", "invalid local connection string: %s", tmp); GDKfree(tmp); return(p); } *p = '\0'; *ret = atoi(con + 1); GDKfree(tmp); return(MAL_SUCCEED); }
PFileInfo CFileSystemServiceImpl::makeFileInfo(const wstring& path) { WIN32_FIND_DATA fd; HANDLE hfind = ::FindFirstFile(path.c_str(), &fd); if (hfind == INVALID_HANDLE_VALUE) throw createException(::GetLastError()); ::FindClose(hfind); PFileInfo fi = fileInfoFromWin32FindData(std::wstring(), fd); return fi; }
static Value isNil(Context *ctx, const List<Value>& args) { if (args.getCount() != 1) { ctx->throwException(createException(ExcType::ValueError, "isNil takes one argument.")); } return createBoolean(args[0].type == ValueType::Nil); }
static Value f(Context *ctx, const List<Value>& args) { if (args.getCount() != 2) { ctx->throwException(createException(ExcType::ValueError, "Function takes only one argument.")); } return createFloat(F(asNumber(ctx, args[0]), asNumber(ctx, args[1]))); }
/* Compose create table statement to create table representing NetCDF variable in the * database. Used for testing, can be removed from release. */ str NCDFimportVarStmt(str *sciqlstmt, str *fname, int *varid) { int ncid; /* dataset id */ int vndims, vnatts, i, j, retval; int vdims[NC_MAX_VAR_DIMS]; size_t dlen; char dname[NC_MAX_NAME+1], vname[NC_MAX_NAME+1]; nc_type vtype; /* == int */ char buf[BUFSIZ]; str msg = MAL_SUCCEED; /* Open NetCDF file */ if ((retval = nc_open(*fname, NC_NOWRITE, &ncid))) return createException(MAL, "netcdf.importvar", "Cannot open NetCDF file %s: %s", *fname, nc_strerror(retval)); if ( (retval = nc_inq_var(ncid, *varid, vname, &vtype, &vndims, vdims, &vnatts))) return createException(MAL, "netcdf.attach", "Cannot read variable %d : %s", *varid, nc_strerror(retval)); j = snprintf(buf, BUFSIZ,"create table %s( ", vname); for (i = 0; i < vndims; i++){ if ((retval = nc_inq_dim(ncid, vdims[i], dname, &dlen))) return createException(MAL, "netcdf.attach", "Cannot read dimension %d : %s", vdims[i], nc_strerror(retval)); (void)dlen; j += snprintf(buf + j, BUFSIZ - j, "%s INTEGER, ", dname); } j += snprintf(buf + j, BUFSIZ - j, "value %s);", NCDF2SQL(vtype)); nc_close(ncid); *sciqlstmt = GDKstrdup(buf); return msg; }
int64_t CFileSystemServiceImpl::getFileContentLength(const wstring& path) { HANDLE hFile = ::CreateFile(path.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (hFile == INVALID_HANDLE_VALUE) { DWORD err = ::GetLastError(); throw createException(err); } LARGE_INTEGER fsize = {0}; ::GetFileSizeEx(hFile, &fsize); ::CloseHandle(hFile); return fsize.QuadPart; }
static JSON * JSONparse(char *j, int silent) { JSON *jt = JSONnewtree(0); skipblancs(j); if (!*j || !(*j == '{' || *j == '[')) { jt->error = createException(MAL, "json.parser", "Syntax error: json parse failed, expecting '{', '['"); return jt; } JSONtoken(jt, j, &j, silent); if (jt && jt->error) return jt; skipblancs(j); if (*j) { if (!silent) jt->error = createException(MAL, "json.parser", "Syntax error: json parse failed"); } return jt; }
wstring CFileSystemServiceImpl::internalReadAllText(const wstring& path1, const wstring& encoding) { BException ex; wstring ret; wstring path = makeValidPath(path1); FILE* file = NULL; wstringstream ssmode; ssmode << L"r"; if (encoding.size()) { ssmode << L", ccs=" << checkValidEncoding(encoding); } errno_t err = _wfopen_s(&file, path.c_str(), ssmode.str().c_str()); if (err) { wstringstream wss; wss << L"Failed to open file \"" << path << L"\"."; ex = createException(wss.str(), err); goto leave; } { wstringstream wss; //if (fseek(file, 0L, SEEK_END)) { // wstringstream wss; // wss << L"Failed to get size of file \"" << path << L"\"."; // ex = createException(wss.str(), err); // goto leave; //} //int32_t size = ftell(file); //if (size < 0) { // wstringstream wss; // wss << L"Failed to get size of file \"" << path << L"\", size < 0."; // ex = createException(wss.str(), err); // goto leave; //} //fseek(file, 0L, SEEK_SET); WCHAR buf[10*1000]; while (fgetws(buf, ARRAYSIZE(buf), file) != NULL) { wss << buf; } ret = wss.str(); } leave: if (file) fclose(file); if (ex) throw ex; return ret; }
static str mythrow(enum malexception type, const char *fcn, const char *msg) { char *errbuf = GDKerrbuf; char *s; if (errbuf && *errbuf) { if (strncmp(errbuf, "!ERROR: ", 8) == 0) errbuf += 8; if (strchr(errbuf, '!') == errbuf + 5) { s = createException(type, fcn, "%s", errbuf); } else if ((s = strchr(errbuf, ':')) != NULL && s[1] == ' ') { s = createException(type, fcn, "%s", s + 2); } else { s = createException(type, fcn, "%s", errbuf); } GDKclrerr(); return s; } return createException(type, fcn, "%s", msg); }
void OutOfMemoryException_init(void) { //! xercesc::OutOfMemoryException auto OutOfMemoryException = boost::python::class_<xercesc::OutOfMemoryException>("OutOfMemoryException") .def("getCode", &xercesc::OutOfMemoryException::getCode) .def("getMessage", &xercesc::OutOfMemoryException::getMessage, boost::python::return_value_policy<boost::python::return_by_value>()) .def("getType", &xercesc::OutOfMemoryException::getType, boost::python::return_value_policy<boost::python::return_by_value>()) .def("getSrcFile", &xercesc::OutOfMemoryException::getSrcFile) .def("getSrcLine", &xercesc::OutOfMemoryException::getSrcLine) ; pyXercesOutOfMemoryExceptionType = createException("OutOfMemoryException", PyExc_MemoryError); boost::python::register_exception_translator<xercesc::OutOfMemoryException>(&translateOutOfMemoryException); }
/** * Returns an exception string for the given type of exception, function * and additional formatting parameters. This function will crash the * system or return bogus when the malexception enum is not aligned with * the exceptionNames array. */ str createException(enum malexception type, const char *fcn, const char *format, ...) { va_list ap; str ret; if (GDKerrbuf && (ret = strstr(format, MAL_MALLOC_FAIL)) != NULL && ret[strlen(MAL_MALLOC_FAIL)] != ':' && (strncmp(GDKerrbuf, "GDKmalloc", 9) == 0 || strncmp(GDKerrbuf, "GDKrealloc", 10) == 0 || strncmp(GDKerrbuf, "GDKzalloc", 9) == 0 || strncmp(GDKerrbuf, "GDKstrdup", 9) == 0 || strncmp(GDKerrbuf, "allocating too much virtual address space", 41) == 0)) { /* override errors when the underlying error is memory * exhaustion, but include whatever it is that the GDK level * reported */ ret = createException(type, fcn, SQLSTATE(HY001) MAL_MALLOC_FAIL ": %s", GDKerrbuf); GDKclrerr(); return ret; } if (strcmp(format, GDK_EXCEPTION) == 0 && GDKerrbuf[0]) { /* for GDK errors, report the underlying error */ char *p = GDKerrbuf; if (strncmp(p, GDKERROR, strlen(GDKERROR)) == 0) p += strlen(GDKERROR); if (strlen(p) > 6 && p[5] == '!') ret = createException(type, fcn, "%s", p); else ret = createException(type, fcn, "GDK reported error: %s", p); GDKclrerr(); return ret; } va_start(ap, format); ret = createExceptionInternal(type, fcn, format, ap); va_end(ap); GDKclrerr(); return ret; }
/* simple test for netcdf library */ str NCDFtest(int *vars, str *fname) { int ncid; /* dataset id */ int dims, ngatts, unlimdim; int retval; str msg = MAL_SUCCEED; /* Open NetCDF file */ if ((retval = nc_open(*fname, NC_NOWRITE, &ncid))) return createException(MAL, "netcdf.test", "Cannot open NetCDF file %s: %s", *fname, nc_strerror(retval)); if ((retval = nc_inq(ncid, &dims, vars, &ngatts, &unlimdim))) return createException(MAL, "netcdf.test", "Cannot read NetCDF header: %s", nc_strerror(retval)); if ((retval = nc_close(ncid))) return createException(MAL, "netcdf.test", "Cannot close file %s: \ %s", *fname, nc_strerror(retval)); return msg; }
static Value createClass(Context *ctx, const List<Value>& args) { if (args.getCount() != 1) { ctx->throwException(createException(ExcType::ValueError, "__classify takes 1 argument.")); } Value base = args[0]; if (base.type != ValueType::Object) { ctx->throwException(createException(ExcType::ValueError, "base must be an object.")); } Value result = createObject(); HashMap<Str, Value>& resultMembers = ((ObjectData *)result.p)->members; resultMembers.set("__base__", createCopy(args[0])); resultMembers.set("__typeID__", createInt(ctx->getEngine()->createNewTypeID())); resultMembers.set("__call__", createNativeFunction(classNew)); return result; }
/* COMMAND "getContent": Retrieve the file referenced * SIGNATURE: getContent(str) : str; */ str URLgetContent(str *retval, url *Str1) { stream *f; str retbuf = NULL; str oldbuf = NULL; char *buf[8096]; ssize_t len; size_t rlen; if ((f = open_urlstream(*Str1)) == NULL) throw(MAL, "url.getContent", "failed to open urlstream"); if (mnstr_errnr(f) != 0) { str err = createException(MAL, "url.getContent", "opening stream failed: %s", mnstr_error(f)); mnstr_destroy(f); *retval = NULL; return err; } rlen = 0; while ((len = mnstr_read(f, buf, 1, sizeof(buf))) > 0) { if (retbuf != NULL) { oldbuf = retbuf; retbuf = GDKrealloc(retbuf, rlen + len + 1); } else { retbuf = GDKmalloc(len + 1); } if (retbuf == NULL) { if (oldbuf != NULL) GDKfree(oldbuf); mnstr_destroy(f); throw(MAL, "url.getContent", "contents too large"); } oldbuf = NULL; (void)memcpy(retbuf + rlen, buf, len); rlen += len; } if (len < 0) { GDKfree(retbuf); throw(MAL, "url.getContent", "read error"); } retbuf[rlen] = '\0'; *retval = retbuf; return MAL_SUCCEED; }
static Value createMethod(Context *ctx, const List<Value>& args) { if (args.getCount() != 2) { ctx->throwException(createException(ExcType::ValueError, "__methodify takes 2 argument.")); } Value result = createObject(); HashMap<Str, Value>& resultMembers = ((ObjectData *)result.p)->members; resultMembers.set("__func__", createCopy(args[0])); resultMembers.set("__obj__", createCopy(args[1])); resultMembers.set("__call__", createNativeFunction(methodCall)); return result; }
/* * A scenario is initialized only once per session. * All other requests are silently ignored. * After initialization, all state functions should have been set. * Initialization includes searching for the scenario startup file in * the etc/MonetDB directory. This creates a dependency, because the * malInclude also needs a scenario. To break this cycle, the system should * call once the routine default scenario for each client first. */ static str initScenario(Client c, Scenario s) { str l = s->language; str msg = MAL_SUCCEED; if (s->initSystemCmd) return(fillScenario(c, s)); /* prepare for conclicts */ MT_lock_set(&mal_contextLock); if (s->initSystem && s->initSystemCmd == 0) { s->initSystemCmd = (MALfcn) getAddress(s->initSystem); if (s->initSystemCmd) { msg = (*s->initSystemCmd) (c); } else { char buf[BUFSIZ]; snprintf(buf,BUFSIZ,"%s.init", l); msg = createException(MAL, buf, "Scenario not initialized"); } } if (msg) { MT_lock_unset(&mal_contextLock); return msg; } if (s->exitSystem && s->exitSystemCmd == 0) s->exitSystemCmd = (MALfcn) getAddress(s->exitSystem); if (s->initClient && s->initClientCmd == 0) s->initClientCmd = (MALfcn) getAddress(s->initClient); if (s->exitClient && s->exitClientCmd == 0) s->exitClientCmd = (MALfcn) getAddress(s->exitClient); if (s->reader && s->readerCmd == 0) s->readerCmd = (MALfcn) getAddress(s->reader); if (s->parser && s->parserCmd == 0) s->parserCmd = (MALfcn) getAddress(s->parser); if (s->optimizer && s->optimizerCmd == 0) s->optimizerCmd = (MALfcn) getAddress(s->optimizer); if (s->tactics && s->tacticsCmd == 0) s->tacticsCmd = (MALfcn) getAddress(s->tactics); if (s->callback && s->callbackCmd == 0) s->callbackCmd = (MALfcn) getAddress(s->callback); if (s->engine && s->engineCmd == 0) s->engineCmd = (MALfcn) getAddress(s->engine); MT_lock_unset(&mal_contextLock); return(fillScenario(c, s)); }
str FITStest(int *res, str *fname) { fitsfile *fptr; /* pointer to the FITS file, defined in fitsio.h */ str msg = MAL_SUCCEED; int status = 0, hdutype; *res = 0; if (fits_open_file(&fptr, *fname, READONLY, &status)) msg = createException(MAL, "fits.test", "Missing FITS file %s", *fname); else { fits_movabs_hdu(fptr, 2, &hdutype, &status); *res = hdutype; fits_close_file(fptr, &status); } return msg; }
static int JSONnew(JSON *js) { JSONterm *term; if (js->free == js->size) { term = (JSONterm *) GDKrealloc(js->elm, sizeof(JSONterm) * (js->size + 8)); if (term == NULL) { js->error = createException(MAL, "json.new", MAL_MALLOC_FAIL); return js->free - 1; } js->elm = term; memset(((char *) term) + sizeof(JSONterm) * js->size, 0, 8 * sizeof(JSONterm)); js->size += 8; if (jsonhint < js->size) jsonhint = js->size; } return js->free++; }
EjsAny *ejsCreateException(Ejs *ejs, int slot, cchar *fmt, va_list fmtArgs) { EjsType *type; EjsAny *error; if (ejs->exception) { mprLog("ejs vm", 0, "Double exception: %s", sfmtv(fmt, fmtArgs)); return ejs->exception; } type = (ejs->initialized) ? ejsGetProperty(ejs, ejs->global, slot) : NULL; if (type == 0) { type = EST(Error); } error = createException(ejs, type, fmt, fmtArgs); if (error) { ejsThrowException(ejs, error); } return error; }
static double asNumber(Context *ctx, const Value& value) { switch (value.type) { case ValueType::Float: { return value.f; } case ValueType::Int: { return value.i; } default: { ctx->throwException(createException(ExcType::TypeError, "Value is not convertable to float.")); } } SDL_assert_release(false); return 0.0; }
str FITSdirpat(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci) { str msg = MAL_SUCCEED; str dir = *(str*)getArgReference(stk, pci, 1); str pat = *(str*)getArgReference(stk, pci, 2); fitsfile *fptr; char *s; int status = 0; glob_t globbuf; char fulldirectory[BUFSIZ]; size_t j = 0; (void)mb; globbuf.gl_offs = 0; snprintf(fulldirectory, BUFSIZ, "%s%s", dir, pat); glob(fulldirectory, GLOB_DOOFFS, NULL, &globbuf); /* mnstr_printf(GDKout,"#fulldir: %s \nSize: %lu\n",fulldirectory, globbuf.gl_pathc);*/ if (globbuf.gl_pathc == 0) msg = createException(MAL, "listdir", "Couldn't open the directory or there are no files that match the pattern"); for (j = 0; j < globbuf.gl_pathc; j++) { char stmt[BUFSIZ]; char fname[BUFSIZ]; s = stmt; snprintf(fname, BUFSIZ, "%s", globbuf.gl_pathv[j]); status = 0; fits_open_file(&fptr, fname, READONLY, &status); if (status == 0) { snprintf(stmt, BUFSIZ, ATTACHDIR, fname); msg = SQLstatementIntern(cntxt, &s, "fits.listofdirpat", TRUE, FALSE); fits_close_file(fptr, &status); } } return msg; }
str GRPsubgroup4(bat *ngid, bat *next, bat *nhis, bat *bid, bat *gid, bat *eid, bat *hid) { BAT *b, *g, *e, *h, *gn, *en, *hn; gdk_return r; b = BATdescriptor(*bid); g = gid ? BATdescriptor(*gid) : NULL; e = eid ? BATdescriptor(*eid) : NULL; h = hid ? BATdescriptor(*hid) : NULL; if (b == NULL || (gid != NULL && g == NULL) || (eid != NULL && e == NULL) || (hid != NULL && h == NULL)) { if (g) BBPreleaseref(g->batCacheid); if (e) BBPreleaseref(e->batCacheid); if (h) BBPreleaseref(h->batCacheid); throw(MAL, "group.subgroup", RUNTIME_OBJECT_MISSING); } if ((r = BATgroup(&gn, &en, &hn, b, g, e, h)) == GDK_SUCCEED) { *ngid = gn->batCacheid; *next = en->batCacheid; *nhis = hn->batCacheid; BBPkeepref(*ngid); BBPkeepref(*next); BBPkeepref(*nhis); } BBPreleaseref(b->batCacheid); if (g) BBPreleaseref(g->batCacheid); if (e) BBPreleaseref(e->batCacheid); if (h) BBPreleaseref(h->batCacheid); return r == GDK_SUCCEED ? MAL_SUCCEED : createException(MAL, "group.subgroup", GDK_EXCEPTION); }