@Override public SDKResult<String> getDeviceCapability(int capabilityType, String devCode) { SDKResult<String> result = new SDKResult<String>(); int sessionId = getIVSSessionId(); String[] strings = {""}; StringArray rspXml = new StringArray(strings); rspXml.clear(); Pointer p = rspXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetDeviceCapability(sessionId, capabilityType, devCode, p); rspXml.read(); result.setErrCode(resultCode); //成功返回0,失败返回错误码 if (0 == resultCode) { strings = rspXml.getStringArray(0); if (null != strings && strings.length > 0) { result.setResult(strings[0]); } } return result; }
/** * 告警订阅查询 * * @param requestXML * 告警订阅请求xml * @return SDKResult<String> 告警订阅查询响应xml * @since eSDK IVS V100R003C00 */ @Override public SDKResult<String> subscribeAlarmQuery(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_SubscribeAlarmQuery(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
@Override public SDKResult<String> getAlarmLinkageAction(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetAlarmLinkageAction(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
@Override public SDKResult<String> getAlarmLinkageList(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetAlarmlinkageList(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
@Override public SDKResult<String> getAlarmLinkage(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetAlarmLinkage(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
/** * 新增告警联动策略 * * @param requestXML * 告警联动策略xml * @return SDKResult<String> 新增告警联动策略响应xml * @since eSDK IVS V100R003C00 */ @Override public SDKResult<String> addAlarmLinkage(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_AddAlarmLinkage(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
/** * 查询告警快照列表 * * @return SDKResult<AlarmLevelList> 告警快照信息列表 * @see [类、类#方法、类#成员] * @since eSDK IVS V100R005C10 */ @Override public SDKResult<String> getAlarmSnapshotList(String requestXML) { int sessionId = super.getIVSSessionId(); String[] strings = { "" }; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetAlarmSnapshotList(sessionId, requestXML, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if (null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); return result; }
@Override protected int spawnWithCwd(final IntByReference restrict_pid, final String restrict_path, final Pointer file_actions, final Pointer /*const posix_spawnattr_t*/ restrict_attrp, final StringArray /*String[]*/ argv, final Pointer /*String[]*/ envp, final Path cwd) { int cwdBufSize = 1024; long peer = Native.malloc(cwdBufSize); Pointer oldCwd = new Pointer(peer); LibC.getcwd(oldCwd, cwdBufSize); String newCwd = cwd.toAbsolutePath().toString(); int rc = LibC.SYSCALL.syscall(SyscallLibrary.SYS___pthread_chdir, newCwd); checkReturnCode(rc, "syscall(SYS__pthread_chdir) failed to set current directory"); try { return LibC.posix_spawnp(restrict_pid, restrict_path, file_actions, restrict_attrp, argv, envp); } finally { rc = LibC.SYSCALL.syscall(SyscallLibrary.SYS___pthread_chdir, oldCwd); Native.free(Pointer.nativeValue(oldCwd)); checkReturnCode(rc, "syscall(SYS__pthread_chdir) failed to restore current directory"); } }
private static SyntaxError syntaxCheck(ProjectFile f, ResNode root, Map<String, TargetSelection> newTargets) { ResourceHolder<EnigmaSettings> rh = f.resMap.get(EnigmaSettings.class); EnigmaSettings ess = rh == null ? new EnigmaSettings() : rh.getResource(); transformEnigmaSettings(ess, newTargets); SyntaxError err = ess.commitToDriver(DRIVER); //returns SyntaxError if (err.absoluteIndex != -1) return err; int scrNum = LGM.currentFile.resMap.getList(Script.class).size(); String osl[] = new String[scrNum]; Script isl[] = LGM.currentFile.resMap.getList(Script.class).toArray(new Script[0]); for (int i = 0; i < scrNum; i++) osl[i] = isl[i].getName(); StringArray scripts = new StringArray(osl); for (Script s : isl) if ((err = DRIVER.syntaxCheck(scrNum,scripts,s.getCode())).absoluteIndex != -1) return err; return null; }
/** * Initializes Tesseract engine. */ protected void init() { api = TessAPI.INSTANCE; handle = api.TessBaseAPICreate(); StringArray sarray = new StringArray(configList.toArray(new String[0])); PointerByReference configs = new PointerByReference(); configs.setPointer(sarray); api.TessBaseAPIInit1(handle, datapath, language, ocrEngineMode, configs, configList.size()); if (psm > -1) { api.TessBaseAPISetPageSegMode(handle, psm); } }
/** * Initializes Tesseract engine. */ protected void init() { handle = TessBaseAPICreate(); StringArray sarray = new StringArray(configList.toArray(new String[0])); PointerByReference configs = new PointerByReference(); configs.setPointer(sarray); TessBaseAPIInit1(handle, datapath, language, ocrEngineMode, configs, configList.size()); if (psm > -1) { TessBaseAPISetPageSegMode(handle, psm); } }
@Override public SDKResult<String> verifyDevice(String domainCode, String verifyInfo) { SDKResult<String> sdkResult = new SDKResult<String>(); int sessionId = getIVSSessionId(); String[] strings = {""}; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int result = super.getBaseCablilityJNA().IVS_SDK_VerifyDevice(sessionId, domainCode, verifyInfo, res); respXml.read(); if (0 == result) { strings = respXml.getStringArray(0); if(null != strings && 0 < strings.length) { sdkResult.setResult(strings[0]); } } sdkResult.setErrCode(result); return sdkResult; }
@Override public SDKResult<String> getVideoDiagnose(String domainCode, String cameraCode) { LOGGER.info("getVideoDiagnose method start--->>>"); LOGGER.debug("input parameter domainCode:" + domainCode); LOGGER.debug("input parameter cameraCode:" + cameraCode); int sessionId = super.getIVSSessionId(); String[] strings = {""}; StringArray respXml = new StringArray(strings); respXml.clear(); Pointer res = respXml; int resultCode = super.getBaseCablilityJNA().IVS_SDK_GetVideoDiagnose(sessionId, domainCode, cameraCode, res); respXml.read(); SDKResult<String> result = new SDKResult<String>(); if (0 == resultCode) { strings = respXml.getStringArray(0); if(null != strings && 0 < strings.length) { result.setResult(strings[0]); } } result.setErrCode(resultCode); LOGGER.info("getVideoDiagnose method result code:" + resultCode); LOGGER.info("getVideoDiagnose method end--->>>"); return result; }
public static List<Process> getProcessesUsing(File file) { List<Process> processes = new LinkedList<Process>(); // If the DLL was not present (XP or other OS), do not try to find it again. if (ourFailed) { return processes; } try { IntByReference session = new IntByReference(); char[] sessionKey = new char[Win32RestartManager.CCH_RM_SESSION_KEY + 1]; int error = Win32RestartManager.INSTANCE.RmStartSession(session, 0, sessionKey); if (error != 0) { Runner.logger.warn("Unable to start restart manager session"); return processes; } StringArray resources = new StringArray(new WString[]{new WString(file.toString())}); error = Win32RestartManager.INSTANCE.RmRegisterResources(session.getValue(), 1, resources, 0, Pointer.NULL, 0, null); if (error != 0) { Runner.logger.warn("Unable to register restart manager resource " + file.getAbsolutePath()); return processes; } IntByReference procInfoNeeded = new IntByReference(); Win32RestartManager.RmProcessInfo info = new Win32RestartManager.RmProcessInfo(); Win32RestartManager.RmProcessInfo[] infos = (Win32RestartManager.RmProcessInfo[])info.toArray(MAX_PROCESSES); IntByReference procInfo = new IntByReference(infos.length); error = Win32RestartManager.INSTANCE.RmGetList(session.getValue(), procInfoNeeded, procInfo, info, new LongByReference()); if (error != 0) { Runner.logger.warn("Unable to get the list of processes using " + file.getAbsolutePath()); return processes; } for (int i = 0; i < procInfo.getValue(); i++) { processes.add(new Process(infos[i].Process.dwProcessId, new String(infos[i].strAppName).trim())); } Win32RestartManager.INSTANCE.RmEndSession(session.getValue()); } catch (Throwable t) { // Best effort approach, if no DLL is found ignore. ourFailed = true; } return processes; }
protected abstract int spawnWithCwd(IntByReference restrict_pid, String restrict_path, Pointer posix_spawn_file_actions, Pointer posix_spawnattr, StringArray commandsArray, Pointer environmentArray, Path cwd);
/** * Lookup the value associated eith PATH * * @return the value */ public String get(String path) { check(); String[] items = new String[1]; StringArray itemArray = new StringArray(items); lastReturn = AugLib.aug_get(aug, path, itemArray); processLastCall("get failed"); return items[0]; }
public static SyntaxError checkSyntax(String code) { if (!assertReady()) return null; String osl[] = new String[LGM.currentFile.resMap.getList(Script.class).size()]; Script isl[] = LGM.currentFile.resMap.getList(Script.class).toArray(new Script[0]); for (int i = 0; i < osl.length; i++) osl[i] = isl[i].getName(); return DRIVER.syntaxCheck(osl.length,new StringArray(osl),code); }
/** * Test of ResultRenderer method, of class TessAPI. * * @throws java.lang.Exception */ @Test public void testResultRenderer() throws Exception { logger.info("TessResultRenderer"); String image = String.format("%s/%s", this.testResourcesDataPath, "eurotext.tif"); String output = "capi-test.txt"; int set_only_init_params = FALSE; int oem = TessOcrEngineMode.OEM_DEFAULT; PointerByReference configs = null; int configs_size = 0; String[] params = {"load_system_dawg", "tessedit_char_whitelist"}; String vals[] = {"F", ""}; //0123456789-.IThisalotfpnex PointerByReference vars_vec = new PointerByReference(); vars_vec.setPointer(new StringArray(params)); PointerByReference vars_values = new PointerByReference(); vars_values.setPointer(new StringArray(vals)); NativeSize vars_vec_size = new NativeSize(params.length); api.TessBaseAPISetOutputName(handle, output); int rc = api.TessBaseAPIInit4(handle, datapath, language, oem, configs, configs_size, vars_vec, vars_values, vars_vec_size, set_only_init_params); if (rc != 0) { api.TessBaseAPIDelete(handle); logger.error("Could not initialize tesseract."); return; } String outputbase = "target/test-classes/test-results/outputbase"; TessResultRenderer renderer = api.TessHOcrRendererCreate(outputbase); api.TessResultRendererInsert(renderer, api.TessBoxTextRendererCreate(outputbase)); api.TessResultRendererInsert(renderer, api.TessTextRendererCreate(outputbase)); String dataPath = api.TessBaseAPIGetDatapath(handle); api.TessResultRendererInsert(renderer, api.TessPDFRendererCreate(outputbase, dataPath, TRUE)); int result = api.TessBaseAPIProcessPages(handle, image, null, 0, renderer); if (result == FALSE) { logger.error("Error during processing."); return; } while ((renderer = api.TessResultRendererNext(renderer)) != null) { String ext = api.TessResultRendererExtention(renderer).getString(0); logger.info(String.format("TessResultRendererExtention: %s\nTessResultRendererTitle: %s\nTessResultRendererImageNum: %d", ext, api.TessResultRendererTitle(renderer).getString(0), api.TessResultRendererImageNum(renderer))); } api.TessDeleteResultRenderer(renderer); assertTrue(new File(outputbase + ".pdf").exists()); }
/** * Test of ResultRenderer method, of class TessAPI1. * * @throws java.lang.Exception */ @Test public void testResultRenderer() throws Exception { logger.info("TessResultRenderer"); String image = String.format("%s/%s", this.testResourcesDataPath, "eurotext.tif"); String output = "capi-test.txt"; int set_only_init_params = ITessAPI.FALSE; int oem = TessOcrEngineMode.OEM_DEFAULT; PointerByReference configs = null; int configs_size = 0; String[] params = {"load_system_dawg", "tessedit_char_whitelist"}; String vals[] = {"F", ""}; //0123456789-.IThisalotfpnex PointerByReference vars_vec = new PointerByReference(); vars_vec.setPointer(new StringArray(params)); PointerByReference vars_values = new PointerByReference(); vars_values.setPointer(new StringArray(vals)); NativeSize vars_vec_size = new NativeSize(params.length); TessAPI1.TessBaseAPISetOutputName(handle, output); int rc = TessAPI1.TessBaseAPIInit4(handle, datapath, language, oem, configs, configs_size, vars_vec, vars_values, vars_vec_size, set_only_init_params); if (rc != 0) { TessAPI1.TessBaseAPIDelete(handle); logger.error("Could not initialize tesseract."); return; } String outputbase = "target/test-classes/test-results/outputbase1"; TessResultRenderer renderer = TessAPI1.TessHOcrRendererCreate(outputbase); TessAPI1.TessResultRendererInsert(renderer, TessAPI1.TessBoxTextRendererCreate(outputbase)); TessAPI1.TessResultRendererInsert(renderer, TessAPI1.TessTextRendererCreate(outputbase)); String dataPath = TessAPI1.TessBaseAPIGetDatapath(handle); TessAPI1.TessResultRendererInsert(renderer, TessAPI1.TessPDFRendererCreate(outputbase, dataPath, TRUE)); int result = TessAPI1.TessBaseAPIProcessPages(handle, image, null, 0, renderer); // if (result == FALSE) { // logger.error("Error during processing."); // return; // } while ((renderer = TessAPI1.TessResultRendererNext(renderer)) != null) { String ext = TessAPI1.TessResultRendererExtention(renderer).getString(0); logger.info(String.format("TessResultRendererExtention: %s\nTessResultRendererTitle: %s\nTessResultRendererImageNum: %d", ext, TessAPI1.TessResultRendererTitle(renderer).getString(0), TessAPI1.TessResultRendererImageNum(renderer))); } TessAPI1.TessDeleteResultRenderer(renderer); assertTrue(new File(outputbase + ".pdf").exists()); }
public static native int posix_spawnp(IntByReference restrict_pid, String restrict_path, Pointer file_actions, Pointer /*const posix_spawnattr_t*/ restrict_attrp, StringArray /*String[]*/ argv, Pointer /*String[]*/ envp);
public NuProcess start(List<String> command, String[] environment, Path cwd) { callPreStart(); String[] commands = command.toArray(new String[command.size()]); Pointer posix_spawn_file_actions = createPipes(); Pointer posix_spawnattr = createPosixSpawnAttributes(); try { int rc = LibC.posix_spawnattr_init(posix_spawnattr); checkReturnCode(rc, "Internal call to posix_spawnattr_init() failed"); LibC.posix_spawnattr_setflags(posix_spawnattr, getSpawnFlags()); IntByReference restrict_pid = new IntByReference(); StringArray commandsArray = new StringArray(commands); StringArray environmentArray = new StringArray(environment); if (cwd != null) { rc = spawnWithCwd(restrict_pid, commands[0], posix_spawn_file_actions, posix_spawnattr, commandsArray, environmentArray, cwd); } else { rc = LibC.posix_spawnp(restrict_pid, commands[0], posix_spawn_file_actions, posix_spawnattr, commandsArray, environmentArray); } pid = restrict_pid.getValue(); initializeBuffers(); if (!checkLaunch()) { return null; } checkReturnCode(rc, "Invocation of posix_spawn() failed"); afterStart(); registerProcess(); callStart(); singleProcessContinue(); } catch (RuntimeException re) { // TODO remove from event processor pid map? re.printStackTrace(System.err); onExit(Integer.MIN_VALUE); return null; } finally { LibC.posix_spawnattr_destroy(posix_spawnattr); LibC.posix_spawn_file_actions_destroy(posix_spawn_file_actions); // After we've spawned, close the unused ends of our pipes (that were dup'd into the child process space) LibC.close(stdinWidow); LibC.close(stdoutWidow); LibC.close(stderrWidow); deallocateStructures(posix_spawn_file_actions, posix_spawnattr); } return this; }
@Override public int execve(String command, String[] argv, String[] env) { StringArray argvp = (argv == null) ? new StringArray(new String[]{command}) : new StringArray(argv); StringArray envp = (env == null) ? null : new StringArray(env); return m_Clib.execve(command, argvp, envp); }
@Override public void execv(String path, String[] argv) { StringArray argvp = (argv == null) ? new StringArray(new String[]{path}) : new StringArray(argv); m_Clib.execv(path, argvp); }
/** * This routine initializes the Notes runtime system for all environments.<br> * <br> * This routine can also be used for standalone programs running with Domino.<br> * <br> * After completing all C API actions and before the program exits, call {@link #notesTerm()}.<br> * <br> * NotesInitExtended uses argv[0] to attempt to locate the Domino or Notes executable directory.<br> * If the Domino or Notes executable directory is not in argv[0], then NotesInitExtended will * use the path to determine the Domino or Notes executable directory. * Then it performs the same initialization that NotesInit() performs.<br> * <br> * As of release 5 of Domino and Notes, you can specify an ini file to NotesInitExtended, * by passing an argument preceded by an "=" sign. This argument can be any argument * except the first argument.<br> * <br> * The name of the ini file may include the full path specification.<br> * <br> * If the path is not included then the specified ini file must reside in the Domino or Notes * executable directory.<br> * <br> * Use the following syntax followed by the file name in the argv list: example "=new.ini".<br> * <br> * Applications may use more than one thread of execution accessing Domino or Notes.<br> * <br> * Each new thread created by an application must call {@link #notesInitThread()} before * making calls to Domino or Notes and {@link #notesTermThread()} before the thread terminates.<br> * <br> * Please refer to the reference entries for these functions for more information.<br> * * @param argvArr arguments */ public static void notesInitExtended(String[] argvArr) { StringArray strArr = new StringArray(argvArr); short result = NotesNativeAPI.get().NotesInitExtended(argvArr.length, strArr); if (result!=0) throw new NotesError(result, "Error initializing Notes connection"); }
public short HTMLSetHTMLOptions(long hHTML, StringArray optionList);
public native short HTMLSetHTMLOptions(int hHTML, StringArray optionList);
public short HTMLSetHTMLOptions(int hHTML, StringArray optionList);
public native short HTMLSetHTMLOptions(long hHTML, StringArray optionList);
int execv(String path, StringArray args);
int execvp(String file, StringArray args);
int aug_get(AugPointer aug, String path, StringArray value);
int execv(String command, StringArray argv);