T1 integer register file

Need some help regarding how the T1 irf works.
From bw_r_irf.v, during a SWAP operation, apparently during 1 cycle, 8 registers need to move from the "active_window" reg to "globals" reg. If I understand correctly, "active_window" is made up of rf cells, and "globals" is made up of sram cells. To move 8 registers (8x72 bits) from one memory structure to another memory structure in 1 cycle seems to require a lot of hardware (8 read ports and 8 write ports). Could anyone explain to me how this SWAP is really accomplished? Thanks,
James
always @ (posedge clk) begin
if (swap_global_d1_vld) begin
for (i = 6'd0; i < 6'd8; i = i + 1) begin
active_pointer[6:0] = {global_tid_d1[1:0], i[4:0]};
regfile_pointer[7:0] = {1'b0, global_tid_d1[1:0], old_agp_d1[1:0], i[2:0]};
// prevent back to back swaps on same thread
if (swap_global_d2 & (global_tid_d1[1:0] == global_tid_d2[1:0])) begin
globals[regfile_pointer[6:0]] = {72{1'bx}};
end
else globals[regfile_pointer[6:0]] = active_window[active_pointer[6:0]];
end
end

Thanks. Finally understood some of the wordings in the megacell doc. In every register cell, there are 9 bits, 1 for active_window, 8 for architecture window. This is a very clever way of implementing the SWAP operation.

Similar Messages

  • Number of irf (integer register file) reading ports, 3 or 4??

    All T1 documents indicate that irf (integer register file) has 3 reading ports. But when reading through its rtl model bw_r_irf.v, I have to raise the doubt that it actually has 4 reading ports physically, which are r1, r2, r3 and r3h. Even though the addresses of r3 and r3h are very close, they are different by the lowest bit in the rtl. In physical implementation, you have to use a different ports for different addresses. So my question is:
    1. Is T1 irf implemented with 4 ports physically or I miss-understand the problem?
    2. What's the use for that extra port 3h?

    Hi,
    The register file is implemented such that, when doing a read, only 4 high bits of the address got decoded, so content of two neighboring register got read out. For port 1 and 2, the lowerst bit of the address is used to select which one goes to the output.
    RTL for port rs1, rs2 and rs3 are identical but implementation could be how you describe above. ie. using lowest bit of address to mux select which output goes out.
    However for port3, the lowerst bit of the address is not used(even thouth it exists in RTL), so the content of both registers goes to the output, the data from the even register goes to port 3 while the data from the odd register goes to port 3h
    All five bits of address are used for port3 in RTL, lowest bit is hardcoded to 1 for the port 3h. For double-store the lowest bit has to be zero (double word/even register alignment). For single word store, port3 can access either odd or even address (same mechanism as port1 and port2) and lower 32bits of port3 will be the same as port3h.
    Thanks.

  • PDF does not remain in the Registered file types list

    I've installed Adobe Reader X. The PDF file type was not automatically associated with Adobe Reader. So, I went through the standard process of adding it to the Windows Registered file types. It does not remain in the list. I've checked the box to "Always use the selected program.....", but when I reopen the Registered File types window, PDF is not there. PDFX is there and registered to open with Adobe Reader, but not PDF.

    I forgot to mention, I'm running Windows XP SP3.

  • Can't register file server

    Hi
    I have just managed to install OVM 3.0.2, I have only one server and one manager, my server have some free space I want to use to stora images, templates, etc. How do I add that as a file server?
    When trying from Storage-Register File Server it fails. I'm probably doing something really stupid but I'm note sure where to look so if anyone could point me in the right direction I would be very happy.
    Rgds
    Robert
    The full error (server name: diesel, storage name: MyStorage, OVS: 172.25.110.13):
    Job Construction Phase
    begin()
    Appended operation 'Discover File Server File Systems' to object '0004fb0000090000bc54cb0b0ac6834b (MyStorage)'.
    commit()
    Completed Step: COMMIT
    Objects and Operations
    Object (IN_USE): [NetworkFileServer] 0004fb0000090000bc54cb0b0ac6834b (MyStorage)
    Operation: Discover File Server File Systems
    Job Running Phase at 15:10 on Mon, Dec 19, 2011
    Job Participants: [e2:a0:7e:8b:f0:45:39:8d:91:ce:54:74:a5:f2:01:40 (diesel)]
    Actioner
    Starting operation 'Discover File Server File Systems' on object '0004fb0000090000bc54cb0b0ac6834b (MyStorage)'
    Setting Context to model only in job with id=1324303839294
    Job Internal Error (Operation)com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_B000E Storage plugin command [storage_plugin_listFileSystems] failed for storage server [0004fb0000090000bc54cb0b0ac6834b] failed with [com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011] OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.StoragePluginAction.processException(StoragePluginAction.java:1287)
    at com.oracle.ovm.mgr.action.StoragePluginAction.discoverFileSystems(StoragePluginAction.java:947)
    at com.oracle.ovm.mgr.discover.ovm.FileSystemsDiscoverHandler.query(FileSystemsDiscoverHandler.java:71)
    at com.oracle.ovm.mgr.discover.ovm.FileSystemsDiscoverHandler.query(FileSystemsDiscoverHandler.java:43)
    at com.oracle.ovm.mgr.discover.ovm.DiscoverHandler.execute(DiscoverHandler.java:50)
    at com.oracle.ovm.mgr.discover.StorageServerDiscover.handleDiscover(StorageServerDiscover.java:72)
    at com.oracle.ovm.mgr.discover.StorageServerDiscover.discoverStorageServer(StorageServerDiscover.java:52)
    at com.oracle.ovm.mgr.op.physical.storage.FileServerRefresh.discoverFileSystems(FileServerRefresh.java:35)
    at com.oracle.ovm.mgr.op.physical.storage.FileServerRefresh.action(FileServerRefresh.java:26)
    at com.oracle.ovm.mgr.api.job.JobEngine.operationActioner(JobEngine.java:191)
    at com.oracle.ovm.mgr.api.job.JobEngine.objectActioner(JobEngine.java:257)
    at com.oracle.ovm.mgr.api.job.InternalJobDbImpl.objectCommitter(InternalJobDbImpl.java:1019)
    at com.oracle.odof.core.AbstractVessel.invokeMethod(AbstractVessel.java:223)
    at com.oracle.odof.core.BasicWork.invokeMethod(BasicWork.java:136)
    at com.oracle.odof.command.InvokeMethodCommand.process(InvokeMethodCommand.java:100)
    at com.oracle.odof.core.BasicWork.processCommand(BasicWork.java:81)
    at com.oracle.odof.core.TransactionManager.processCommand(TransactionManager.java:751)
    at com.oracle.odof.core.WorkflowManager.processCommand(WorkflowManager.java:395)
    at com.oracle.odof.core.WorkflowManager.processWork(WorkflowManager.java:453)
    at com.oracle.odof.io.AbstractClient.run(AbstractClient.java:42)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.ActionEngine.sendCommandToServer(ActionEngine.java:474)
    at com.oracle.ovm.mgr.action.ActionEngine.sendUndispatchedServerCommand(ActionEngine.java:426)
    at com.oracle.ovm.mgr.action.ActionEngine.sendServerCommand(ActionEngine.java:368)
    at com.oracle.ovm.mgr.action.StoragePluginAction.discoverFileSystems(StoragePluginAction.java:943)
    ... 23 more
    Caused by: com.oracle.ovm.mgr.api.exception.IllegalOperationException: OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.ActionEngine.sendAction(ActionEngine.java:752)
    at com.oracle.ovm.mgr.action.ActionEngine.sendCommandToServer(ActionEngine.java:470)
    ... 26 more
    FailedOperationCleanup
    Starting failed operation 'Discover File Server File Systems' cleanup on object 'MyStorage'
    Complete rollback operation 'Discover File Server File Systems' completed with direction=MyStorage
    Rollbacker
    Objects To Be Rolled Back
    Object (IN_USE): [NetworkFileServer] 0004fb0000090000bc54cb0b0ac6834b (MyStorage)
    Completed Step: ROLLBACK
    Job failed commit (internal) due to OVMAPI_B000E Storage plugin command [storage_plugin_listFileSystems] failed for storage server [0004fb0000090000bc54cb0b0ac6834b] failed with [com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011] OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_B000E Storage plugin command [storage_plugin_listFileSystems] failed for storage server [0004fb0000090000bc54cb0b0ac6834b] failed with [com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011] OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.StoragePluginAction.processException(StoragePluginAction.java:1287)
    at com.oracle.ovm.mgr.action.StoragePluginAction.discoverFileSystems(StoragePluginAction.java:947)
    at com.oracle.ovm.mgr.discover.ovm.FileSystemsDiscoverHandler.query(FileSystemsDiscoverHandler.java:71)
    at com.oracle.ovm.mgr.discover.ovm.FileSystemsDiscoverHandler.query(FileSystemsDiscoverHandler.java:43)
    at com.oracle.ovm.mgr.discover.ovm.DiscoverHandler.execute(DiscoverHandler.java:50)
    at com.oracle.ovm.mgr.discover.StorageServerDiscover.handleDiscover(StorageServerDiscover.java:72)
    at com.oracle.ovm.mgr.discover.StorageServerDiscover.discoverStorageServer(StorageServerDiscover.java:52)
    at com.oracle.ovm.mgr.op.physical.storage.FileServerRefresh.discoverFileSystems(FileServerRefresh.java:35)
    at com.oracle.ovm.mgr.op.physical.storage.FileServerRefresh.action(FileServerRefresh.java:26)
    at com.oracle.ovm.mgr.api.job.JobEngine.operationActioner(JobEngine.java:191)
    at com.oracle.ovm.mgr.api.job.JobEngine.objectActioner(JobEngine.java:257)
    at com.oracle.ovm.mgr.api.job.InternalJobDbImpl.objectCommitter(InternalJobDbImpl.java:1019)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.oracle.odof.core.AbstractVessel.invokeMethod(AbstractVessel.java:223)
    at com.oracle.odof.core.BasicWork.invokeMethod(BasicWork.java:136)
    at com.oracle.odof.command.InvokeMethodCommand.process(InvokeMethodCommand.java:100)
    at com.oracle.odof.core.BasicWork.processCommand(BasicWork.java:81)
    at com.oracle.odof.core.TransactionManager.processCommand(TransactionManager.java:751)
    at com.oracle.odof.core.WorkflowManager.processCommand(WorkflowManager.java:395)
    at com.oracle.odof.core.WorkflowManager.processWork(WorkflowManager.java:453)
    at com.oracle.odof.io.AbstractClient.run(AbstractClient.java:42)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: com.oracle.ovm.mgr.api.exception.FailedOperationException: OVMAPI_4010E Attempt to send command: storage_plugin_listFileSystems to server: diesel failed. OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.ActionEngine.sendCommandToServer(ActionEngine.java:474)
    at com.oracle.ovm.mgr.action.ActionEngine.sendUndispatchedServerCommand(ActionEngine.java:426)
    at com.oracle.ovm.mgr.action.ActionEngine.sendServerCommand(ActionEngine.java:368)
    at com.oracle.ovm.mgr.action.StoragePluginAction.discoverFileSystems(StoragePluginAction.java:943)
    ... 23 more
    Caused by: com.oracle.ovm.mgr.api.exception.IllegalOperationException: OVMAPI_4004E Server Failed Command: storage_plugin_listFileSystems, Status: oracle.generic.NFSPlugin.GenericNFSPlugin
    Mon Dec 19 15:10:40 CET 2011
    at com.oracle.ovm.mgr.action.ActionEngine.sendAction(ActionEngine.java:752)
    at com.oracle.ovm.mgr.action.ActionEngine.sendCommandToServer(ActionEngine.java:470)
    ... 26 more
    End of Job
    ##########################

    Mallander wrote:
    I do have unmanaged space left on the OVS, it was installed using default values, however I can't see that space when I configure the server pool.You can't use the unused space on an already partitioned disk, i.e. if there is a single disk in your server, the entire disk is consumed by the Oracle VM operating system.
    When selecting the magnifying glass next to "Location" in the wizard I have three options in the dropdown list: Unmanaged iSCSI, Unmanaged FibreChannel and Generic Local Storage Array @Diesel
    No matter which one I choose there isn't anything in the big list, what am I doing wrong?Only completely unused, unpartitioned disks are presented as local storage. These will show up under the "Local Storage Array" when available.

  • Writing integer to file error

    Hey
    Im trying to write an integer to a file, but it writes an whole ohter number than variable contains. I know this because i do i System.out.println on the variable and it prints the correct number. Why does the write function write anohter number? For example the print shows 50 but the write functions write " 2" to file.
    Here i call the write:
    private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {                                          
            String file = "C:\\Users\\Jesper\\Documents\\NetBeansProjects\\Katrinelund_v0.16\\secure\\checkNewOrder.txt";
            control.deleteFile(file);
            control.createFile(file);
            int currentOrder = control.getCurrentOrderNumber();
            System.out.println(currentOrder);
            control.setWriteToFile(file, currentOrder);
            quit();       
        } Here is the write function:
    public void writeToFile(String fileDestination, int WhatToWrite){       
            FileOutputStream fos;
            DataOutputStream dos;
            try {
                File file= new File(fileDestination);
                fos = new FileOutputStream(file);
                dos = new DataOutputStream(fos);
                dos.writeInt(WhatToWrite);
            } catch (IOException e) {
                e.printStackTrace();
        }

    jverd wrote:
    newark wrote:
    Try
    PrintWriter pw = new PrintWriter(new PrintWriter(file), true);
    You wanna rethink that maybe? :-)Probably. First I just put the file in, then realized that the autoflush constructor needs a writer, not a file. So I put a BufferedWriter in, but then realized BufferedWriter doesn't take a file either. Then I was all confused, and meant to use a FileWriter but put PrintWriter instead.
    So how about
    PrintWriter pw = new PrintWriter(new FileWriter(file), true);In short, I hate nested readers/writers and think that if you ever have to use them, there's a flaw in the IO system.

  • Unable to register file server in OVM 3.0.1

    I'm stuck on attempting to register a fileserver in VM Manager 3.0.1; When I go to register a new file server, the "Storage Plug-in" drop-down is blank. What can I do to dig into this? Nothing about this is covered in the documentation...

    First must Discover VM Server!

  • Failing to register files??

    I have been using iTunes with no problems for a while now but today it wouldn't open up. Said that I was missing files which to me sounds rather trojan/virus. But when I try to reinstall/repair it I am told that "Module C:\Program Files\iTunes\iTunesMiniPlayer.dll failed to register. HRESULT 2147023782. Contact your support personel." So that's what I'm doing. Help?

    I had the same problem. May I ask if you use AVG, there are other posts regarding trojans etc, again my AVG decided I had them. However if you allow a certain path to be "missed" by AVG then it should solve your problems. If youre like me and uninstalled itunes, then you wouldnt have the directory so you would need to uninstall AVG, install itunes, then reinstall AVG and allow the forementioned directory. Hope that helps

  • Modifying the size of an SMB 3.0 registered file share in SCVMM 2012 SP1

    Hi -
    We are leveraging the Netapp SMI-S 5.0 provider with SCVMM 2012 SP1 to register and use SMB 3.0 file shares on our HV clusters.  Working great after a few early problems.  One thing that we've yet to find is a solution to this problem.
    On the netapp side, let's say a volume with size 1TB is created.  Then through SCVMM/SMI-S, a new file share is created within this volume for use with HV clusters/VMs.  Let's say, for example when creating this share through the SCVMM GUI that
    you define the file share size as 500gb.  This leaves 500gb free in the parent volume.
    How in the world do you modify that file share size from the SCVMM perspective - if you start running low on space within the share.  The free space is definitely there, but we can't seem to find a way from within SCVMM to modify the file share 'size'
    (which is a parameter you have to define during file share creation) from original size to something larger (yet still smaller than parent volume size).
    Anyone else seen this scenario and/or found a solution?  I apologize if this is already answered elsewhere - just not seeing much on searches.  Thanks in advance -

    Ok so we just ran into a similar issue with our netapp. And after digging around my colleagues and I found this document ( https://communities.netapp.com/community/netapp-blogs/msenviro/blog/2014/02/19/data-ontap-smi-s-agent-51--use-netapp-smi-s-provider-to-provision-a-cifs-share-for-smb-30-environments-windows-server-2012-using-scvmm-2012-r2
    ) had a key passage: "SMIS create/manage shares created on qtree with quota assigned to it."
    So taking that the SMI-S agent uses quotas on the volume to determine the 'file share' size you can adjust the space available to Hyper-V by adjusting the quota on the volume, even increasing it to beyond the space available in the volume. We are actually
    doing this because of dedupe savings on our hyper-v store.
    IMPORTANT - the SMI-S agent only scans every 5 minutes, so when you make a quota change it may take up to 5 minutes for it to be detected... so wait
    6 minutes and then refresh the storage provider.  We were working with SCVMM 2012 R2 but this should be reflected with SCVMM 2012 SP1 if im not mistaken.

  • Windows Registered File Types and Icons

    Hi does anyone know how to get the list of extensions and file types that are registered in Windows.
    Also is there a way to get a file icon(that is registered with windows) without using the whole file path. For example if I just want to display the icon for .xls files without using the name, is that possible?
    Thanks

    Icons are stored in the exe files, dll files, etc (which I suppose you know) so they can be extracted with ExtractIcon(). From java's perspective, they don't exist at all so you have two options:
    1) Make some assumptions about the file types you will be handling and store the appropriate icons in your jar file then use FileFilter to decide which icon to display.
    2) Use extract icon as mentioned above.

  • Write Integer to file

    Stuck. I've got six integers and I need them to be written to file, each with a new line and for them to overwrite the digits currently held on file. Help appreciated.

    I had the same trouble when I started my project (writing stuff to files). But instead of writing new IO methods for every class of mine, I wrote one with a static method. This way it can be called from every class I have. If you want to use it here it is;
    import java.io.*;
    public class WriteThis
    public static String fileName;
    public static void WriteIt (String [] whatToWrite)
    try
    fileName = whatToWrite [0];
    String writeOnLine;
    FileWriter fw = new FileWriter (fileName);
    BufferedWriter bw = new BufferedWriter (fw);
    PrintWriter outFile = new PrintWriter (bw);
    for (int i = 1; i < whatToWrite.length; i++)
    writeOnLine = whatToWrite ["i"];//don't actually use the quotes,
    //the whole page kept going to
    //italics without them.
    outFile.println (writeOnLine);
    outFile.close ();
    catch (IOException e)
    String error = "There was an error";
    The way you can use this is to convert your integers into a String array. In the first entry (yourArray [0]) put your filename ("myInts.dat" or whatever you want to call it). It then prints each array index on a new line for your. If you end up using it would you reply to this, just so I know if it is actually useable for everyone.
    If you don't want this file saved in the same directory as your classes just pass the path you want it to save to ("C:\Program Files\My Program\here\") and it will save in here\.
    To call it all you have to do is something like this:
    String [] saving = {
         "myints.dat",
         caption.getText (),
         news.getText ()
    WriteThis.WriteIt (saving);
    except you will have to convert your integers into strings. Hope this works, and just watch that the formating is right, when I was previewing square braces were working like HTML brackets and parenthesis were working like square brackets.

  • Registered Files

    I've recently installed Photoshop Elements and now when I open an attached pdf file in an email, Photoshop is used to open the file rather than Acrobat which i also have and use extensively.  How do I change the default program used to open a file?

    If you have Vista, you can type in default programs in the search bar if you do it the way post 2 suggests.
    Alternately, you can right click any PDF file on your hard drive and select "Open With" in the menu; then "Choose Default Program" even if Acrobat is in the list. In the dialog that comes up, click on the Acrobat icon in the recommended program list to select it. The box marked "Always use the selected program to open this kind of file" should be checked to make the setting sticky. Click Okay to commit the change.
    Note: The reason you would not want to use "Open With" then select Acrobat from the list instead of "Choose Default Program" is because it would be a one time deal.

  • Does Portal register file deletions?

    Hi Everybody,
    I need to know if Portal saves any kind of history about KM documents.
    If some user deletes a file, does Portal saves who and when did it?
    I'm not talking about versions, what I need is some kind of log i.e. in the database.
    Thanks in advance,
    Fede

    You may see it exaclty using SVN client. The bw_r_irf_fpga1.v is all new, as is the underlying regfile_1w_4r.v. At last, execution unit, rml and cwp are modified (current cwp is wired from rml to bw_r_irf_fpga1).

  • How to extract register names & their addresses from .inc file of a microcontroller

    Hi,
    I want to extract register names to a dropdown and their corresponding addresses from .inc file in such a way that when I select a register from dropdown, it has to also show its address in a string indicator.
    However, only a part of .inc file consists of register definitions and the rest has bit definition of registers (unwanted). How can I extract this using labview?
    Attached is a sample .inc file for PIC18F4620 device.
    Attachments:
    p18f4620.inc ‏48 KB

    Read the file line by line until you find "Register Files" (use for example Search/Split String).
    Then, read again splitting each line in its tokens (use Scan String for Tokens).
    Keep the first token as name and convert the proper substring of the third token to the address value.
    Terminate when line is empty.
    Paolo
    LV 7.0, 7.1, 8.0.1, 2011

  • Can't Figure Out How to Add Nodes to Existing XML File by Attribute

    <?xml version="1.0" encoding="UTF-8"?>
    -<Project_Data>
    -<Project_Info>
    <Client>frankLINVILE</Client>
    <Name>COOKIE MONSTER INDICTMNET</Name>
    <Number>198883cookie</Number>
    <Tester>JK</Tester>
    <Reviewer>CM</Reviewer>
    <Location>Sesame Street, MD</Location>
    <SD>03/10/2015</SD>
    <Boring_Header>Boring1</Boring_Header>
    <Sample_Header>Sample2</Sample_Header>
    <Depth_Header>Depth3</Depth_Header>
    <Location_Header>Location4</Location_Header>
    <SD_Header>Sample Date5</SD_Header>
    <Remarks>asdf sdafas</Remarks>
    <Is_LOC_Global>True</Is_LOC_Global>
    <Is_SD_Global>True</Is_SD_Global>
    <Count>12</Count>
    <Has_MC_Data>N</Has_MC_Data>
    </Project_Info>
    -<Samples>
    -<Sample ID="@B1 S1 1-2 SESAME STREET, MD 03/10/2015">
    <Boring>b1</Boring>
    <Sample>s1</Sample>
    <Depth>1-2</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frank1</Remarks>
    <Login_Order>1</Login_Order>
    <Report_Order>1</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B2 S2 2-2 SESAME STREET, MD 03/10/2015">
    <Boring>b2</Boring>
    <Sample>s2</Sample>
    <Depth>2-2</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frakn2</Remarks>
    <Login_Order>2</Login_Order>
    <Report_Order>2</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B3 S3 3-3 SESAME STREET, MD 03/10/2015">
    <Boring>b3</Boring>
    <Sample>s3</Sample>
    <Depth>3-3</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frakn3</Remarks>
    <Login_Order>3</Login_Order>
    <Report_Order>3</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B4 S4 4-4 SESAME STREET, MD 03/10/2015">
    <Boring>b4</Boring>
    <Sample>s4</Sample>
    <Depth>4-4</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi4</Remarks>
    <Login_Order>4</Login_Order>
    <Report_Order>4</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B5 S5 5-5 SESAME STREET, MD 03/10/2015">
    <Boring>b5</Boring>
    <Sample>s5</Sample>
    <Depth>5-5</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi5</Remarks>
    <Login_Order>5</Login_Order>
    <Report_Order>5</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B6 S6 6-6 SESAME STREET, MD 03/10/2015">
    <Boring>b6</Boring>
    <Sample>s6</Sample>
    <Depth>6-6</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi6</Remarks>
    <Login_Order>6</Login_Order>
    <Report_Order>6</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B7 S7 7-7 SESAME STREET, MD 03/10/2015">
    <Boring>b7</Boring>
    <Sample>s7</Sample>
    <Depth>7-7</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi7</Remarks>
    <Login_Order>9</Login_Order>
    <Report_Order>9</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B8 S8 8-8 SESAME STREET, MD 03/10/2015">
    <Boring>b8</Boring>
    <Sample>s8</Sample>
    <Depth>8-8</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi8</Remarks>
    <Login_Order>10</Login_Order>
    <Report_Order>10</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B9 S9 9-9 SESAME STREET, MD 03/10/2015">
    <Boring>b9</Boring>
    <Sample>s9</Sample>
    <Depth>9-9</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi9</Remarks>
    <Login_Order>11</Login_Order>
    <Report_Order>11</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@B10 S10 10-10 SESAME STREET, MD 03/10/2015">
    <Boring>b10</Boring>
    <Sample>s10</Sample>
    <Depth>10-10</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi10</Remarks>
    <Login_Order>12</Login_Order>
    <Report_Order>12</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@FRANK FARKN2">
    <Boring>frank</Boring>
    <Sample>farkn2</Sample>
    <Depth> </Depth>
    <Location> </Location>
    <SD> </SD>
    <Remarks> </Remarks>
    <Login_Order>7</Login_Order>
    <Report_Order>7</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    -<Sample ID="@FRANK FRANK">
    <Boring>frank</Boring>
    <Sample>frank</Sample>
    <Depth> </Depth>
    <Location> </Location>
    <SD> </SD>
    <Remarks> </Remarks>
    <Login_Order>8</Login_Order>
    <Report_Order>8</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    </Samples>
    </Project_Data
    What I need to do is find the sample by its ID attribute...IN THEN add the following
    <MC_Data>
    <Wet>blah</Wet
    <Dry>blah</Dry>
    </MC_Data>
    Here is the code I have now, which doesn't work...
    Public Sub XML_Add_Child_Node_Group(Sample_ID As String, Which_Category As Integer)
            If File.Exists(Program_Settings_File.PG_Filepath) = False Then MsgBox("The program settings file for the program has been moved or deleted! Cancelled.") : Exit Sub
            Dim XMLFile As New Xml.XmlDocument, NewNode As Xml.XmlElement = Nothing, NewChild As Xml.XmlElement = Nothing
            XMLFile.Load(Current_File.Current_File_Path)
            Dim Root_Node As XmlNode = XMLFile.SelectSingleNode("/Project_Data/Samples/[@ID='" & Sample_ID & "']")
            Dim Root_Element As Xml.XmlElement = CType(XMLFile.SelectSingleNode("/Project_Data/Samples/[@ID='" & Sample_ID & "']"), XmlElement)
            '1 = Add MC nodes
            Select Which_Category
                Case 1
                    '----Add new node.
                    NewNode = XMLFile.CreateElement("MC_Data")
                    '----Add children nodes.
                    NewChild = XMLFile.CreateElement("MC_Wet") : NewNode.AppendChild(NewChild)
                    'MsgBox(NewNode.Name)
                    NewChild = XMLFile.CreateElement("MC_Dry") : NewNode.AppendChild(NewChild)
                    NewChild = XMLFile.CreateElement("MC_Tare") : NewNode.AppendChild(NewChild)
                    NewChild = XMLFile.CreateElement("MC_Tare_No") : NewNode.AppendChild(NewChild)
                    NewChild = XMLFile.CreateElement("MC_Remarks") : NewNode.AppendChild(NewChild)
                    NewChild = XMLFile.CreateElement("MC_MC") : NewNode.AppendChild(NewChild)
                    Root_Element.AppendChild(NewNode)
            End Select
            '----Add entire tree.
            XMLFile.Save(Current_File.Current_File_Path)
        End Sub
    No matter what, it will not add these nodes. Can anyone help me out? Thanks ahead of time...
    Shawn

    Here is the XML
    <?xml version="1.0" encoding="UTF-8"?>
    <Project_Data>
    <Project_Info>
    <Client>frankLINVILE</Client>
    <Name>COOKIE MONSTER INDICTMNET</Name>
    <Number>198883cookie</Number>
    <Tester>JK</Tester>
    <Reviewer>CM</Reviewer>
    <Location>Sesame Street, MD</Location>
    <SD>03/10/2015</SD>
    <Boring_Header>Boring1</Boring_Header>
    <Sample_Header>Sample2</Sample_Header>
    <Depth_Header>Depth3</Depth_Header>
    <Location_Header>Location4</Location_Header>
    <SD_Header>Sample Date5</SD_Header>
    <Remarks>asdf sdafas</Remarks>
    <Is_LOC_Global>True</Is_LOC_Global>
    <Is_SD_Global>True</Is_SD_Global>
    <Count>12</Count>
    <Has_MC_Data>N</Has_MC_Data>
    </Project_Info>
    <Samples>
    <Sample ID="@B1 S1 1-2 SESAME STREET, MD 03/10/2015">
    <Boring>b1</Boring>
    <Sample>s1</Sample>
    <Depth>1-2</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frank1</Remarks>
    <Login_Order>1</Login_Order>
    <Report_Order>1</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B2 S2 2-2 SESAME STREET, MD 03/10/2015">
    <Boring>b2</Boring>
    <Sample>s2</Sample>
    <Depth>2-2</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frakn2</Remarks>
    <Login_Order>2</Login_Order>
    <Report_Order>2</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B3 S3 3-3 SESAME STREET, MD 03/10/2015">
    <Boring>b3</Boring>
    <Sample>s3</Sample>
    <Depth>3-3</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>frakn3</Remarks>
    <Login_Order>3</Login_Order>
    <Report_Order>3</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B4 S4 4-4 SESAME STREET, MD 03/10/2015">
    <Boring>b4</Boring>
    <Sample>s4</Sample>
    <Depth>4-4</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi4</Remarks>
    <Login_Order>4</Login_Order>
    <Report_Order>4</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B5 S5 5-5 SESAME STREET, MD 03/10/2015">
    <Boring>b5</Boring>
    <Sample>s5</Sample>
    <Depth>5-5</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi5</Remarks>
    <Login_Order>5</Login_Order>
    <Report_Order>5</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B6 S6 6-6 SESAME STREET, MD 03/10/2015">
    <Boring>b6</Boring>
    <Sample>s6</Sample>
    <Depth>6-6</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi6</Remarks>
    <Login_Order>6</Login_Order>
    <Report_Order>6</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B7 S7 7-7 SESAME STREET, MD 03/10/2015">
    <Boring>b7</Boring>
    <Sample>s7</Sample>
    <Depth>7-7</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi7</Remarks>
    <Login_Order>9</Login_Order>
    <Report_Order>9</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B8 S8 8-8 SESAME STREET, MD 03/10/2015">
    <Boring>b8</Boring>
    <Sample>s8</Sample>
    <Depth>8-8</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi8</Remarks>
    <Login_Order>10</Login_Order>
    <Report_Order>10</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B9 S9 9-9 SESAME STREET, MD 03/10/2015">
    <Boring>b9</Boring>
    <Sample>s9</Sample>
    <Depth>9-9</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi9</Remarks>
    <Login_Order>11</Login_Order>
    <Report_Order>11</Report_Order>
    <Has_Data>Y</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@B10 S10 10-10 SESAME STREET, MD 03/10/2015">
    <Boring>b10</Boring>
    <Sample>s10</Sample>
    <Depth>10-10</Depth>
    <Location>SESAME STREET, MD</Location>
    <SD>03/10/2015</SD>
    <Remarks>hi10</Remarks>
    <Login_Order>12</Login_Order>
    <Report_Order>12</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@FRANK FARKN2">
    <Boring>frank</Boring>
    <Sample>farkn2</Sample>
    <Depth> </Depth>
    <Location> </Location>
    <SD> </SD>
    <Remarks> </Remarks>
    <Login_Order>7</Login_Order>
    <Report_Order>7</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    <Sample ID="@FRANK FRANK">
    <Boring>frank</Boring>
    <Sample>frank</Sample>
    <Depth> </Depth>
    <Location> </Location>
    <SD> </SD>
    <Remarks> </Remarks>
    <Login_Order>8</Login_Order>
    <Report_Order>8</Report_Order>
    <Has_Data>N</Has_Data>
    <Has_MC_Data>N</Has_MC_Data>
    <Has_GSA_Data>N</Has_GSA_Data>
    <Has_P_Data>N</Has_P_Data>
    <Has_C_Data>N</Has_C_Data>
    <Has_H_Data>N</Has_H_Data>
    <Has_USDA_Data>N</Has_USDA_Data>
    <Has_CM_Data>N</Has_CM_Data>
    <Has_UCS_Data>N</Has_UCS_Data>
    <Has_Cons_Data>N</Has_Cons_Data>
    <Has_ConsSw_Data>N</Has_ConsSw_Data>
    <Has_Pills_Data>N</Has_Pills_Data>
    <Has_UCSC_Data>N</Has_UCSC_Data>
    </Sample>
    </Samples>
    </Project_Data>
    jdweng

  • How to SCAN uploaded files for VIRUS in APEX

    part 1:
    Goal:
    Do a virus scan of the uploaded file from APEX application prior to storing the file in custom tables.
    The process:
    Followed the document from www.developer.com:
    Implementing an Anti-Virus File Scan in JEE Applications
    By Vlad Kofman
    Go to page: 1 2 3 Next
    This article will discuss one of the ways to implement antivirus file scanning in Java, particular in the JEE applications. Viruses, Trojan Horses, and different malware and spyware are a real problem for current computer environments, and especially for the Windows operating system. If you are designing any application in Java that has a requirement to be able to upload external files, you have a potential security risk. By uploading, I mean any way to get the external file inside of the corporate firewall be it via HTTP protocol or any other means. It is quite common to have this type of requirement in an enterprise application and with Java being one of the most popular web development platforms, it is unfortunate that this type of gaping security risk is quite often overlooked.
    Java's Development Kit (JDK) does not have any means to do the antivirus scan right out of the box. This is primarily because Java is a programming language, and does not have any virus scanning packages. Furthermore, anti-virus software is not Sun's area of expertise or business model. Developing this type of software (or Java package), and more importantly maintaining it, would be a huge task for Sun. Mainly because viruses are constantly evolving and keeping virus definitions up-to-date is a daunting task. Large companies such as McAffee, Symantec, or Zone Labs develop virus detecting and combating products and spend a lot of resources to maintain them.
    Application Environment
    To implement a virus file scan in Java, a third-party package needs to be used. For the purposes of this article, I will use Symantec Scan Engine (SSE) package, which comes with Java APIs. This package is an application that serves as a TCP/IP server and has a programming interface and enables Java applications to incorporate support for content scanning technologies. For this article, I used Symantec Scan Engine 5.1, which is available as a Unix or Windows install.
    If you are using an anti-virus package from the different vendor, you will need to investigate what kind of APIs are available; however, the general approach should be similar. Also, note that my implementation can be used with JEE technology and any modern MVC framework such as Struts or Spring.
    The architecture is as follows: A server machine needs to have SSE running at all times. This can be the same machine that hosts your Application Server, but in an enterprise environment this should be a different machine. The Default Port needs to be open through the firewall to allow communication with the scan engine. All JEE applications that need to do file scanning can talk to the SSE server machine through a default port. Also, multiple applications running on different application servers can re-use the same scanning server. For more information, you should refer to the Symantec Scan Engine (SSE) Installation Guide, available on the Symantec web site.
    When an external file that needs to be scanned is sent to the SSE via its programming interface (Java APIs using the default port), before any other operation on the file is performed, the SSE returns a result code. For instance, a file is uploaded by an external user into the web email type application as an attachment; then, the SSE API is invoked by the application and the return code of pass or fail determines the outcome of the upload and whether that email can actually be sent. If you have an account on Yahoo mail, you probably have seen that Yahoo is using Norton Antivirus to scan all attachments, although no Java.
    Click here for a larger image.
    Figure 1: Screen shot from Yahoo
    For details on the Scan Engine Server Installationm please see the Symantec Scan Engine (SSE) Implementation Guide from Symantec.
    Here are some key things to remember about SSE:
    •     Java 2 SE Runtime (JRE) 5.0 Update 6.0 or later must be installed on the server before the SSE installation is done.
    •     After installation, verify that the Symantec Scan Engine daemon is running. At the Unix command prompt (if it's a Unix install), type the following command:
    ps –ea | grep sym.
    A list of processes similar to the following should appear:
    o     5358 ? 0:00 symscan
    o     5359 ? 0:00 symscan
    If nothing is displayed the SSE process did not start.
    If the SSE process did not start, type the following command to restart SSE:
    /etc/init.d/symscan restart
    •     Keeping the virus definition up to date is the most important task and if new updates are not installed, the whole scan becomes ineffective. Symantec automatically downloads the most current file definitions through LiveUpdate. Please make sure that firewall rules are in place to allow the host server to connect to the Symantec update service.
    Project Setup
    For the purposes of this article, I included a wrapper for the Symantec SSE APIs, av.jar, which has Symantec Java APIs and serves as a client to the SSE server and takes care of all communications with the server. Please refer to the download source section. The av.jar should be included in the Java CLASSPATH to work with the SSE. This jar contains a class called AVClient that takes care of actually sending the files to SSE as byte arrays and returning the result.
    In my project setting, I added three variables to be accessed via the System.getProperty mechanism. For example:
    AV_SERVER_HOST=192.168.1.150
    AV_SERVER_PORT=1344
    AV_SERVER_MODE=SCAN
    The AV_SERVER_HOST is the host name or IP of the machine where Scan Engine is installed.
    The AV_SERVER_PORT is the port where Scan Engine listens for incoming files.
    The AV_SERVER_MODE is the scan mode which can be:
    •     NOSCAN: No scanning will be done (any keyword that does not start with "SCAN" will result in ignoring the call to the Scan Engine and no files will be transferred for scanning).
    •     SCAN: Files or the byte stream will be scanned, but the scan engine will not try to repair infections.
    •     SCANREPAIR: Files will be scanned, the scan engine will try to repair infections, but nothing else will be done.
    •     SCANREPAIRDELETE: Files will be scanned, the scan engine will try to repair infections, and irreparable files will be deleted.
    Note: For the file stream (byte array) scanning, the only meaning full values are "SCAN" and "NOSCAN".
    Using the SSE Scanning Java APIs
    In any class where scan is required, call the scanning API provided in the AVClient object located in the av.jar. The AVClient object will establish connection to the Scan Engine server and has the following APIs:
    Figure 2: The significant APIs for the communication with to the Scan Engine Server.
    If scanning a file on the file system, in SCAN only mode, use the call that accepts filename only.
    If scanning a file on the file system, with SCANREPAIR or SCANREPAIRDELETE, use the call that accepts input and output file names.
    If scanning an in-memory file (byte array), use the call accepting byte array.
    For example:
    import com.av.*;
    Initialize setup parameters:
    static String avMode =
    (System.getProperty("AV_SERVER_MODE") != null)
    ? (String) System.getProperty("AV_SERVER_MODE") : "NOSCAN";
    static boolean scan = avMode.startsWith("SCAN");
    static String avServer =
    (String) System.getProperty("AV_SERVER_HOST");
    static int avPort =
    Integer.parseInt( (String) System.getProperty("AV_SERVER_PORT"));
    Scan check example for an in-memory file byte array:
    public void scanFile(byte[] fileBytes, String fileName)
    throws IOException, Exception {
    if (scan) {
    AVClient avc = new AVClient(avServer, avPort, avMode);
    if (avc.scanfile(fileName, fileBytes) == -1) {
    throw new VirusException("WARNING: A virus was detected in
    your attachment: " + fileName + "<br>Please scan
    your system with the latest antivirus software with
    updated virus definitions and try again.");
    Note that if you are using this code inside of the MVC handler, you can throw a custom VirusException and check for it in the calling method and perform any necessary cleanup. I have included the class in the AV Jar as well.
    For example:
    catch (Exception ex) {
    logger.error(ex);
    if (ex instanceof VirusException) {
    // do something here
    else {
    // there was some other error – handle it
    For more details on the Scan Engine Client API, please see Symantec Scan Engine Software Developers Guide.
    Continuation in part2

    part 4:
    c)     Clienttester.java – This is the gui app set to test if the configuration is working or not. This gui uses the method scanfile(inputfile, outputfile) as you can see the result in the outputpane of the jframe.
    * clienttester.java
    * Created on April 12, 2005, 2:37 PM
    * @author george_maculley
    package com.av;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class clienttester
    implements ActionListener {
    // private String ipaddress = "127.0.0.1";
    private String ipaddress = "199.209.150.58";
    //private String ipaddress = "192.168.0.55";
    static JFrame frame;
    JFileChooser chooser = new JFileChooser();
    TextField pathtofile = new TextField(System.getProperty("user.home"), 30);
    // TextField pathtooutfile= new TextField(System.getProperty("user.home"),30);
    private int port = 1344;
    JButton filechooser = new JButton("Browse to file"); ;
    private String originalfilename;
    private String outputfilename;
    JButton scanbutton = new JButton("Scan");
    TextArea outputarea = new TextArea(20, 40);
    TextField iptext = new TextField("127.0.0.1", 16);
    TextField porttext = new TextField("1344", 5);
    AVClient mine;
    JRadioButton choosescan = new JRadioButton("SCAN");
    // JRadioButton choosedelete= new JRadioButton("SCANREPAIRDELETE");
    /** Creates a new instance of gui */
    public clienttester() {
    public clienttester(java.lang.String ip, java.lang.String infile, java.lang.String outfile, int port) {
    this.ipaddress = ip;
    this.port = port;
    this.originalfilename = infile;
    this.outputfilename = outfile;
    boolean setValues(java.lang.String ip, java.lang.String infile, java.lang.String outfile, int port) {
    this.ipaddress = ip;
    this.port = port;
    this.originalfilename = infile;
    this.outputfilename = outfile;
    return (true);
    public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
    JComponent c = (JComponent) actionEvent.getSource();
    if (c == filechooser) {
    int retval = chooser.showDialog(frame, null);
    if (retval == JFileChooser.APPROVE_OPTION) {
    File theFile = chooser.getSelectedFile();
    if (theFile != null) {
    pathtofile.setText(theFile.getPath());
    // pathtooutfile.setText(theFile.getPath());
    JOptionPane.showMessageDialog(frame, "You chose this file: " + theFile.getPath());
    if (c == scanbutton) {
    //return object that can be passed to AVClient
    String policy;
    int thisport;
    int scanresult;
    String thisip;
    String inputfile;
    String outputfile;
    outputarea.append("Server: " + iptext.getText() + "\r\n");
    if (choosescan.isSelected()) {
    policy = "SCAN";
    else {
    policy = "SCANREPAIRDELETE";
    thisport = new Integer(porttext.getText()).intValue();
    thisip = iptext.getText();
    //mine= new AVClient(iptext.getText(),porttext.getText(),policy);
    mine = new AVClient(iptext.getText(), thisport, policy);
    if (mine.test() == 1) {
    outputarea.append("Sorry. Incorrect parameters specified.\r\n");
    System.exit(1);
    else {
    outputarea.append("Connection to SAVSE initialized.\r\n");
    inputfile = pathtofile.getText();
    // outputfile=pathtooutfile.getText();
    outputfile = "/tmp";
    outputarea.append("Scanning file " + inputfile + " \r\n");
    if (policy == "SCAN") {
    scanresult = mine.scanfile(inputfile);
    else {
    scanresult = mine.scanfile(inputfile, outputfile);
    if (scanresult == 0) {
    outputarea.append("File is clean.\r\n");
    else if (scanresult == -1) {
    outputarea.append("File is infected. \r\n");
    else {
    outputarea.append("Scan error.\r\n");
    void display() {
    Frame f = new Frame("SAVSE JAVA ICAP Client");
    f.setLayout(new GridLayout(1, 2));
    JPanel lpanel = new JPanel(new GridLayout(7, 1));
    JPanel ippanel = new JPanel();
    JPanel portpanel = new JPanel();
    JPanel rpanel = new JPanel();
    JPanel outputpanel = new JPanel();
    JPanel buttonpanel = new JPanel();
    JPanel pathpanel = new JPanel();
    // JPanel outpathpanel= new JPanel();
    JPanel policypanel = new JPanel();
    ButtonGroup policygroup = new ButtonGroup();
    filechooser.addActionListener(this);
    scanbutton.addActionListener(this);
    choosescan.setSelected(true);
    policygroup.add(choosescan);
    // policygroup.add(choosedelete);
    buttonpanel.setBorder(BorderFactory.createTitledBorder("Scan Policy"));
    buttonpanel.add(choosescan);
    // buttonpanel.add(choosedelete);
    pathpanel.setBorder(BorderFactory.createTitledBorder("Path to File"));
    pathpanel.add(pathtofile);
    f.setSize(new Dimension(650, 400));
    f.setBackground(Color.white);
    f.setResizable(true);
    ippanel.setBorder(BorderFactory.createTitledBorder("SAVSE IP Address"));
    ippanel.add(iptext);
    outputpanel.setBorder(BorderFactory.createTitledBorder("OUTPUT"));
    outputpanel.add(outputarea);
    portpanel.setBorder(BorderFactory.createTitledBorder("ICAP Port"));
    portpanel.add(porttext);
    // outpathpanel.setBorder(BorderFactory.createTitledBorder("Path to Repair File"));
    // outpathpanel.add(pathtooutfile);
    lpanel.add(ippanel);
    rpanel.add(outputpanel);
    lpanel.add(portpanel);
    lpanel.add(buttonpanel);
    lpanel.add(pathpanel);
    // lpanel.add(outpathpanel);
    lpanel.add(filechooser);
    lpanel.add(scanbutton);
    f.add(lpanel);
    f.add(rpanel);
    f.setVisible(true);
    public static void main(String[] args) {
    clienttester g = new clienttester();
    g.display();
    d)     my2.java – This is the class file I wrote to test that I am able to send a file and scan it and see the output in the JDEVELOPER. In this case the file is stored on the filesystem of the client machine. JDEVELOPER should be able to see the file.
    NOTE:
    “EICAR.com” is the test file downloaded from Symantec site to test a non malicious virus file. I n order to be able to test it like this, the Antivirus program running on your machine should be disabled, or else Antivirus will kick in and delete the file. In the first place you will not be able to download the test virus file either with anti virus running on the machine you are downloading to.
    package com.av;
    import java.io.*;
    public class my2 {
    static int my_return = 0;
    * @param fileBytes
    * @param fileName
    * @return
    public static int scanfile(String fileName){
    String avMode = "SCAN";
    boolean scan = avMode.startsWith("SCAN");
    String avServer = "xx";--avserver ip address
    int avPort = 1344;
    int the_return = 0;
    if (scan) {
    AVClient avc = new AVClient(avServer,avPort,avMode);
    the_return = avc.scanfile(fileName);
    if (the_return == -1) {
    return (the_return);
    } else
    return (the_return);
    //my_return = the_return;
    return (the_return);
    public static void main(String[] args) throws Exception {
    System.out.println("Hi there in Main");
    byte[] b1 = new byte[4];
    b1[1] = 68;
    my_return = scanfile("c:\\eicar.com");
    System.out.println(my_return);
    e)     Then finally we have my1.JAVA, which takes the filename, and it’s contents in the bytes form and scans the file. The reason for this method is we are not storing the file on the filesystem, it is read into the memory and only if it is clean, it is put into the database or else notify the user.
    package com.av;
    import java.io.*;
    public class my1 {
    static int my_return = 0;
    static int a_length = 0;
    * @param fileBytes
    * @param fileName
    * @return
    public static int scanfile(String fileName,byte[] fileBytes) throws IOException {
    String avMode = "SCAN";
    boolean scan = avMode.startsWith("SCAN");
    String avServer = "xxx";--avserver’s ip address
    int avPort = 1344;
    int the_return = 0;
    if (scan) {
    AVClient avc = new AVClient(avServer,avPort,avMode);
    // File file = new File(fileName) ;
    //byte[] fBytes = getBytesFromFile(file);
    the_return = avc.scanfile(fileName, fileBytes);
    if (the_return == -1) {
    return (the_return);
    } else
    {return (the_return);}
    my_return = the_return;
    return (the_return);
    // Returns the contents of the file in a byte array.
    * @param file
    * @return
    * @throws IOException
    public static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    // Get the size of the file
    long length = file.length();
    // You cannot create an array using a long type.
    // It needs to be an int type.
    // Before converting to an int type, check
    // to ensure that file is not larger than Integer.MAX_VALUE.
    if (length > Integer.MAX_VALUE) {
    // File is too large
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while (offset < bytes.length
    && (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) {
    offset += numRead;
    // Ensure all the bytes have been read in
    if (offset < bytes.length) {
    throw new IOException("Could not completely read file "+file.getName());
    // Close the input stream and return bytes
    is.close();
    return bytes;
    // public static void main(String[] args) throws Exception {
    //System.out.println("Hi there in Main");
    // File file = new File() ;
    // byte[] b1 = getBytesFromFile(file);
    //System.out.println(b1);
    // my_return = scanfile(,b1);
    //System.out.println(my_return); }
    Finally , you have the exceptions file,
    e) package com.av;
    public class VirusException
    extends Exception {
    public VirusException() {
    super();
    public VirusException(String text) {
    super(text);
    Once you have all these classes, you can use JDEVELOPER , to load these classes into the database: This is as follows:
    Right click on the project, which has all these classes.
    NEW -> deployment profiles -> load java and stored procedures.
    When you are created deployment profile, you have to specify,
    Loadjava options.
    -f, -v (check the check boxes)
    Under privileges:
    -s – specify database schema these classes are loaded into
    -s – create sysnonym check box
    -g – grant to public or any specific users per your policy.
    Under Resolver,
    -r and –o (check the check boxes)
    I accepted the default name storedproc1. Then you right click on the storedproc1.deploy, deploy to whichever database connection you created.
    And then, In order to access this java class we need a pl/sql wrapper as follows:
    create or replace package my1 is
    function mycheck (pfilename in varchar2, psize in number)
    return number;
    end my1;
    create or replace package body my1 is
         function mycheck (pfilename in varchar2, psize in number)
    return number is
    language java
         name 'com.av.my1.scanfile(java.lang.String, byte[]) return int';
         end my1;
    And the code is invoked from sql plus as follows:
    Select my1.mycheck(“filename”, “filebytes”) from dual;
    One important catch in the above method is to send the filename and filecontents in bytes form. In order to send the file contents as filebytes, you will need another java class and load into the data base as described above.
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.InputStream;
    * This program demonstrates how to read a file into a byte array. This method
    * reads the entire contents of the file into a byte array.
    * @version 1.0
    * @author Jeffrey M. Hunter ([email protected])
    * @author http://www.idevelopment.info
    public class ReadFileIntoByteArray {
    * method to convert a byte to a hex string.
    * @param data the byte to convert
    * @return String the converted byte
    public static String byteToHex(byte data) {
    StringBuffer buf = new StringBuffer();
    buf.append(toHexChar((data >>> 4) & 0x0F));
    buf.append(toHexChar(data & 0x0F));
    return buf.toString();
    * Convenience method to convert an int to a hex char.
    * @param i the int to convert
    * @return char the converted char
    public static char toHexChar(int i) {
    if ((0 <= i) && (i <= 9)) {
    return (char) ('0' + i);
    } else {
    return (char) ('a' + (i - 10));
    * Returns the contents of the file in a byte array
    * @param file File this method should read
    * @return byte[] Returns a byte[] array of the contents of the file
    private static byte[] getBytesFromFile(File file) throws IOException {
    InputStream is = new FileInputStream(file);
    System.out.println("\nDEBUG: FileInputStream is " + file);
    // Get the size of the file
    long length = file.length();
    System.out.println("DEBUG: Length of " + file + " is " + length + "\n");
    * You cannot create an array using a long type. It needs to be an int
    * type. Before converting to an int type, check to ensure that file is
    * not loarger than Integer.MAX_VALUE;
    if (length > Integer.MAX_VALUE) {
    System.out.println("File is too large to process");
    return null;
    // Create the byte array to hold the data
    byte[] bytes = new byte[(int)length];
    // Read in the bytes
    int offset = 0;
    int numRead = 0;
    while ( (offset < bytes.length)
    ( (numRead=is.read(bytes, offset, bytes.length-offset)) >= 0) ) {
    offset += numRead;
    // Ensure all the bytes have been read in
    if (offset < bytes.length) {
    throw new IOException("Could not completely read file " + file.getName());
    is.close();
    return bytes;
    * @param filename
    public static byte[] chk_file(String filename) {
    byte[] fileArray = null;
    try {
    fileArray = getBytesFromFile(new File( filename));
    } catch (IOException e) {
    e.printStackTrace();
    if (fileArray != null) {
    for (int i=0; i<fileArray.length; i++) {
    System.out.println(
    "fileArray[" + i + "] = " +
    ((int)fileArray[i] < 9 ? " " : "") +
    ( ((int)fileArray[i] > 9 && (int)fileArray[i] <= 99) ? " " : "") +
    fileArray[i] + " : " +
    " HEX=(0x" + byteToHex(fileArray) + ") : " +
    " charValue=(" + (char)fileArray[i] + ")");
    return fileArray;
    * Sole entry point to the class and application.
    * @param args Array of String arguments.
    public static void main(String[] args) {
    byte[] fileArray = null;
    try {
    fileArray = getBytesFromFile(new File("c:\\eicar.com"));
    } catch (IOException e) {
    e.printStackTrace();
    if (fileArray != null) {
    for (int i=0; i<fileArray.length; i++) {
    System.out.println(
    "fileArray[" + i + "] = " +
    ((int)fileArray[i] < 9 ? " " : "") +
    ( ((int)fileArray[i] > 9 && (int)fileArray[i] <= 99) ? " " : "") +
    fileArray[i] + " : " +
    " HEX=(0x" + byteToHex(fileArray[i]) + ") : " +
    " charValue=(" + (char)fileArray[i] + ")");
    Having main method helps you to run the file in JDEVELOPER or using JAVA.
    DO not forget to load this class into the database.
    And you create the pl/sql wrapper again as follows:
    create or replace FUNCTION TOBY (pfilename in varchar2) RETURN VARCHAR2 iS
    language java name
    'ReadFileIntoByteArray.chk_file(java.lang.String) return byte[]';
    And you call the function from sqlplus as follows:
    Sql>Set serveroutput on size 20000;
    Sql> call dbms_java.set_output(20000);
    Sql> Select toby(“filename”) from dual; --
    this file should be accessible, I mean you will not be able to send a file on your pc, from sql plus as sql/plus is running on your db server.
    You will be able to see the output in sql plus:
    If you are running it from the APEX:
    When we use file browser widget from APEX, the file is stored in APEX_APPLICATION_FILES table. And we retrieve that into a variable and pass this variable to the function as follows:
    DECLARE
    scan_failed EXCEPTION;
    x varchar2(400);
    z number;
    BEGIN
    select filename into x from wwv_flow_files where name = :P1_FILE_NAME;
    select my1.mycheck(x,toby(x)) into z from dual;
    if z = 0 then
    :P1_SUBJECT:= 'PASSED';
    else
    :P1_SUBJECT:= 'FAILED';
    end if;
    :P1_SCAN_RESULT := '** Scanning File **';
    IF UPPER(:P1_SUBJECT) = 'PASSED' THEN
    BEGIN
    :P1_SCAN_FLAG := 'PASSED';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** File passed scan **';
    END;
    ELSIF UPPER(:P1_SUBJECT) = 'FAILED' THEN
    BEGIN
    :P1_SCAN_FLAG := 'FAILED';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** File failed scan **';
    END;
    ELSE
    BEGIN
    :P1_SCAN_FLAG := 'UNKNOWN';
    :P1_SCAN_RESULT := :P1_SCAN_RESULT || ' ** Scan Is Not Conclussive **';
    END;
    END IF;
    --IF :P1_SCAN_FLAG = 'FAILED'
    -- THEN RAISE scan_failed;
    --END IF;
    EXCEPTION
    WHEN OTHERS THEN
    DELETE from APEX_APPLICATION_FILES WHERE name = :P1_FILE_NAME;
    RAISE_APPLICATION_ERROR (-20000, 'seb OTHERS error encountered - file upload not allowed. Possible virus detected !');
    raise;
    END;
    ACKNOWLEDMENTS:
    1) JOHN SCOTT – who suggested this ICAP API in one of the threads which is my initial starting point in this direction.
    2) VLAD KOFMAN who wrote the article on WWW.DEVELOPER.com
    3) Mr. KIRAN –One of the engineers from Metalink, who helped me at every step of getting this java programs and pl/sql wrappers working. But for him, I would have not completed my project.

Maybe you are looking for

  • Can I using whatsapp in my ipade A1459???

    Can I using whatsapp in my ipade

  • ATV1 screen saver photo shuffle?

    I have synced about 8500 photos onto the ATV1 hard-drive.  I have selected them all to be shuffled - yet it seems the same 200 or 300 photos turn up when the screen saver kicks in.   Any suggestions on how to get a wider variety engaged in the screen

  • Error when access EP - Dispatcher running but no server connected- details

    Hi every body: I have problem when I try to access SAP EP with URL: http://192.168.122.82:50000/irj/portal I tried to activate the debug remote, I access on configTool and on the section of process node I activate the options of debugabble, enable de

  • Migrating from a 32 bit architecture to a 64 bit architecture for BOE XI 31

    We have (OS) Windows 2003 server, on two servers clustered together running BOE XI 3.1. Are there any known issues or encountered issues with migrating from 32 bit architecture to 64 bit architecture?

  • Relink syntax - VB - CS4

    I just upgraded to CS 4 and I am going through and updating my scripts. I have a script that goes through text boxes and updates the links to a new path. I keep getting an error when I relink. syntax example.... 'This is how I define what link I want