* parse error at the end of input
@ 2005-06-03 9:19 Mohit Kumar
2005-06-03 11:21 ` Mohit Kumar
0 siblings, 1 reply; 2+ messages in thread
From: Mohit Kumar @ 2005-06-03 9:19 UTC (permalink / raw)
To: gcc-help
[-- Attachment #1: Type: text/plain, Size: 218 bytes --]
Hi All,
I am trying to compile DSM.cpp, but keep on getting this error:
parse error at the end of input
I am attaching the files for reference.
Kindly let me know where am I going wrong.
Thanks,
Mohit
[-- Attachment #2: DSM.cpp --]
[-- Type: application/octet-stream, Size: 3365 bytes --]
#include "DSM.h"
#include <stdlib.h>
#include <string.h>
CSane::CSane()
{
device_list = NULL;
local_only = true; // we will get device names of scanners locally attached, not on the network
noOfDevices = 0;
}
CSane::~CSane()
{
}
SANE_Status CSane::GetLastError(void)
{
return m_Error;
}
bool CSane::InitializeSane(void)
{
bool bReturn=false;
SetLastError(SANE_STATUS_GOOD);
SANE_Status status = sane_init(&m_VersionCode,NULL); //Not looking to do any authorization right now, need to check whether this needs to be implemented
if(status == SANE_STATUS_GOOD)
bReturn = true;
else
SetLastError(status);
return bReturn;
}
void CSane::SetLastError(SANE_Status status)
{
m_Error = status;
}
void CSane::CloseSane(void)
{
sane_exit(); //called to terminate the use of backend
}
void CSane::CleanUp(void)
{
/*TODO : code for cleanup if required*/
}
bool CSane::GetDevices(char* devicenames, unsigned short nCount)
{
unsigned long length = 0;
SetLastError(SANE_STATUS_GOOD);
if(device_list)
{
for(int i=0;i<noOfDevices;i++)
free((void*)device_list[i]);
free(device_list);
}
SANE_Status status = sane_get_devices(&device_list, local_only);
if(status != SANE_STATUS_GOOD)
{
SetLastError(status);
/* Some error in SANE*/
return false;
}
const SANE_Device **temp = device_list;
int n=0;
while(temp)
{
n++;
temp++;
}
noOfDevices = n;
scannernames = (char**) malloc(sizeof(char*)*noOfDevices);
temp = device_list;
*devicenames = 0;
int i=0;
for(; i<n;i++)
{
int len = strlen((const char*)device_list[i]->vendor) + strlen((const char*)device_list[i]->model)+3; //1 for " " and 1 for \r
if(length + len >nCount)
{
SetLastError(SANE_STATUS_NO_MEM);
return false;
}
scannernames[i] = (char*)malloc(sizeof(char)*(len-2));
strcpy(scannernames[i], (const char*)device_list[i]->vendor);
strcat(scannernames[i]," ");
strcat(scannernames[i], (const char*)device_list[i]->model);
strcat(devicenames,scannernames[i]);
strcat(devicenames,"\r");
}
return true;
}
bool CSane::ValidateScannerName(char* devicename,int* index)
{
/* The name is in the following format : Vendor Model stored in the member scannernames
*/
for(int i = 0; i<noOfDevices; i++)
{
if(strcmp(scannernames[i],devicename)==0)
{
*index = i;
return true;
}
}
*index = -1;
return false;
}
bool CSane::OpenScanner(int index)
{
/* This index maps to the index of the devuce chosen in device_list*/
if(index < 0)
return false;
SetLastError(SANE_STATUS_GOOD);
SANE_Status status = sane_open(device_list[index]->name,&handle);
if(status != SANE_STATUS_GOOD)
{
SetLastError(status);
return false;
}
return true;
}
bool CSane::EnableScanner()
{
if (handle)
return true;
return false;
}
bool CSane::GetImageXferParams(bool firstTime)
{
SANE_Status status = sane_get_parameters(handle,¶ms);
if(status != SANE_STATUS_GOOD)
{
SetLastError(status);
return false;
}
image.read_offset_16 = 0;
image.scan_lines = params.lines; //XXX:this value can also be -1 in which case we do not know how many lines will be tranferred
image.bit_depth = params.depth;
image.bytes_per_line = params.bytes_per_line;
image.total_bytes = params.lines * params.depth;
if(firstTime) image.bytes_read = 0;
image.format = params.format;
image.last_frame = params.last_frame;
return true;
}
[-- Attachment #3: DSM.h --]
[-- Type: application/octet-stream, Size: 1151 bytes --]
#ifndef _H_DSM_
#define _H_DSM_
#ifdef __cplusplus
extern "C" {
#endif
#include <sane/sane.h>
#ifdef _cplusplus
}
#endif
typedef struct Image_Data
{
unsigned int scan_lines;
unsigned short bit_depth;
unsigned int bytes_per_line;
unsigned long total_bytes;
unsigned long bytes_read;
SANE_Frame format;
SANE_Bool last_frame;
int read_offset_16;
}Image_Data;
class CSane
{
private:
static SANE_Status m_Error;
static SANE_Int m_VersionCode;
static const SANE_Device **device_list;
static char ** scannernames;
static SANE_Bool local_only;
static SANE_Int noOfDevices;
static SANE_Handle handle;
static SANE_Parameters params;
static Image_Data image;
public:
CSane();
~CSane();
static SANE_Status GetLastError(void);
static bool InitializeSane(void);
static void SetLastError(SANE_Status status);
static void CloseSane(void);
static void CleanUp(void);
static bool GetDevices(char* devicenames,unsigned short nCount);
static bool ValidateScannerName(char* devicename,int *index);
static bool OpenScanner(int index);
static bool EnableScanner(void);
static bool GetImageXferParams(bool firstTime);
};
#endif
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: parse error at the end of input
2005-06-03 9:19 parse error at the end of input Mohit Kumar
@ 2005-06-03 11:21 ` Mohit Kumar
0 siblings, 0 replies; 2+ messages in thread
From: Mohit Kumar @ 2005-06-03 11:21 UTC (permalink / raw)
To: gcc-help
Got it!!!
So no need to get troubled....
Thanks,
Mohit
On 6/3/05, Mohit Kumar <mohit.kumar@gmail.com> wrote:
> Hi All,
>
> I am trying to compile DSM.cpp, but keep on getting this error:
>
> parse error at the end of input
>
> I am attaching the files for reference.
>
> Kindly let me know where am I going wrong.
>
> Thanks,
> Mohit
>
>
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-06-03 11:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-03 9:19 parse error at the end of input Mohit Kumar
2005-06-03 11:21 ` Mohit Kumar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).