Example #1
0
	static void shell(CTX ctx)
	{
		kwb_t wb;
		kwb_init((ctx.stack.cwb), wb);
		kline_t uline/* = FILEID_("(shell)") | 1*/;
		while(true) {
			kline_t inc = 0;
			kstatus_t status = readstmt(ctx, wb, inc);
			if(status == K_CONTINUE && kwb_bytesize(wb) > 0) {
				status = konoha_eval(ctx, kwb_top(wb, 1), uline);
				uline += inc;
				kwb_free(wb);
				if(status != K_FAILED) {
					dumpEval(ctx, wb);
					kwb_free(wb);
				}
			}
			if(status == K_BREAK) {
				break;
			}
		}
		kwb_free(wb);
		FileWriter fw = new FileWriter(stdout);
		fw.write(stdout + "\n");
		return;
	}
Example #2
0
  public void deployElement(Element e, String fileName, boolean encrypt, boolean isTransient)
      throws ISOException, IOException, GeneralSecurityException {
    e = ((Element) e.clone());

    XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
    Document doc = new Document();
    doc.setRootElement(e);
    File qbean = new File(deployDir, fileName);
    if (isTransient) {
      e.setAttribute("instance", getInstanceId().toString());
      qbean.deleteOnExit();
    }
    FileWriter writer = new FileWriter(qbean);
    if (encrypt) doc = encrypt(doc);
    out.output(doc, writer);
    writer.close();
  }
Example #3
0
 private long persist(File f, ObjectName name) {
   long deployed = f.lastModified();
   try {
     Element e = (Element) server.getAttribute(name, "Persist");
     if (e != null) {
       XMLOutputter out = new XMLOutputter(Format.getPrettyFormat());
       Document doc = new Document();
       e.detach();
       doc.setRootElement(e);
       File tmp = new File(f.getAbsolutePath() + ".tmp");
       FileWriter writer = new FileWriter(tmp);
       out.output(doc, writer);
       writer.close();
       f.delete();
       tmp.renameTo(f);
       deployed = f.lastModified();
     }
   } catch (Exception ex) {
     log.warn("persist", ex);
   }
   return deployed;
 }
Example #4
0
	public static int builtinTest(String name) {//TODO How to do #ifdef, #else, #endif
	/*
	#ifdef USE_BUILTINTEST
		Ftest f = lookupTestFunc(KonohaTestSet, name);
		if(f != NULL) {
			konoha_t konoha = konoha_open();
			int ret = f((CTX_t)konoha);
			konoha_close(konoha);
			return ret;
		}
		fprintf(stderr, "Built-in test is not found: '%s'\n", name);
	#else
		fprintf(stderr, "Built-in tests are not built; rebuild with -DUSE_BUILTINTEST\n");
	#endif
		return 1;
	*/
		try {
		FileWriter stderr = new FileWriter("./stderr");
		stderr.write("Built-in tests are not built; rebuild with -DUSE_BUILTINTEST" + name);
		} catch (IOException e) {
			System.out.println(e + "Exception occured");
		}
		return 1;
	}
Example #5
0
	static void show_version(CTX ctx)
	{
		int i;
		FileWriter fw = new FileWriter(stdout);
		fw.write("Konoha 2.0-alpha (Miyajima) (" + K_REVISION + "," + __DATE__ + ")\n");
		fw.write("[gcc " + __VERSxION__ + "]\n");
		fw.write("options:");
		for(i = 0; i < MOD_MAX; i++) {
			if(ctx.modshare[i] != null) {
				fw.write(ctx.modshare[i].name);
			}
		}
		fw.write("\n");
		fw.close();
	}