# corrected readproc for SANE

Oliver.Rauch@Wolfsburg.DE
Fri, 17 Apr 1998 23:14:03 +0200 (MET DST)

- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
- Next message: Gernot Ziegler: "Dexxa Flatbedscanner support ...."
- Previous message: Hugo van der Kooij: "Re: Minolta Reply (was:Public Relation Department (Ref. No. CR-3255 V)"

Hello backend-developers!

The Makefile.in in the backend-directory was not correct!
This is the right version!

I just made the follwing test that works fine:

My sytsem:
/dev/sg0: scsi-disk (id 0)
/dev/sg1: scsi-cdrom (id 4)
/dev/sg2: scanner (id 5)

in umax.conf: SCSI_NAME: "UMAX " "UMAX S-12"

xscanimage finds scanner on /dev/sg2

as root: echo "scsi remove-single-device 0 0 4 0" >/proc/scsi/scsi

xscanimage finds scanner on /dev/sg1 (must rw for users!)

as root: echo "scsi remove-single-device 0 0 4 0" >/proc/scsi/scsi
as root: echo "scsi add-single-device 0 0 4 0" >/proc/scsi/scsi
as root: echo "scsi add-single-device 0 0 5 0" >/proc/scsi/scsi

xscanimage finds scanner on /dev/sg2 again!

So the user only needs to make all devices on which the scanner may
be connected set to rw for user, then sane always finds the scanner!

Bye
Oliver

------------------------------------------------------------------------
I included the readproc routine into sane. It already works with
the umax-backend.

I added sanei_readproc to sane-0.72/sanei with the function:
char *sanei_readproc_get_device(char *findvendor, char *findmodel,
int findbus, int findcha, int findid, int findlun)

You call it with findvendor and findmodel set or
with findbus, findcha, findid and findlun set, see example!
There three differnt possibilities to specifiy a device in the config-file:
SCSI_ID: 0 0 5 0
SCSI_NAME: "UMAX " "UMAX S-12"
/dev/scanner

And I added two functions to sanei/sanei_config.c:
void sanei_config_kill_spaces(char **string)
char *sanei_config_read_string(char **string)

Example for reading configure-file and using readproc:
( you have to #include "sane/sanei_readproc.h" )

-------------------------------------------------------------------------------

fp = sanei_config_open(UMAX_CONFIG_FILE);
if (!fp)
{
attach_scanner("/dev/scanner", 0); /* no config-file: /dev/scanner */
return SANE_STATUS_GOOD;
}

while(fgets(dev_name, sizeof(dev_name), fp))
{
if (dev_name[0] == '#') { continue; } /* ignore line comments */

len = strlen (dev_name);
if (dev_name[len - 1] == '\n') { dev_name[--len] = '\0'; }

if (!len) { continue; } /* ignore empty lines */

if (strncmp(dev_name, "SCSI_ID:",8) == 0)
{
int bus, cha, id, lun;
char *dev;
char *pos = &dev_name[8];

bus = strtol(pos, &pos, 10);
cha = strtol(pos, &pos, 10);
id = strtol(pos, &pos, 10);
lun = strtol(pos, &pos, 10);

dev = sanei_readproc_get_device(NULL,NULL,bus,cha,id,lun);
if (dev != NULL)
{
attach_scanner(dev,0);
}
}
else if (strncmp(dev_name, "SCSI_NAME:",10) == 0)
{
char *vendor, *model;
char *dev;
char *pos = &dev_name[10];

vendor = sanei_config_read_string(&pos);
model = sanei_config_read_string(&pos);

DBG(DBG_info, "looking for vendor=\"%s\", model=\"%s\"\n",vendor, model);

dev = sanei_readproc_get_device(vendor, model, -1, -1, -1, -1);
if (dev != NULL)
{
attach_scanner(dev,0);
}

free(vendor);
free(model);
}
else
{
attach_scanner(dev_name, 0);
}
}

fclose(fp);

-------------------------------------------------------------------------------

This is the snapshot of the readproc-changes.
It overwirtes/creates the following files:

sane-0.72/backend/Makefile.in
sane-0.72/include/sane/sanei_readproc.h
sane-0.72/include/sane/sanei_config.h
sane-0.72/sanei/Makefile.in
sane-0.72/sanei/sanei_config.c
sane-0.72/sanei/sanei_readproc.c

Bye
Oliver

=============================================================

begin 644 readproc-0.72a.tar.gz
M'XL(`+"^-S4``^P\:7<:Q[+YROR*-I8CD`$!VJY%Y",L(9L$+4^@)#Y.+AEF
M&C%/PPR91;*NH_?;7U5U]VR@!4>2WWF!8XN97JIK[^KJ;GS=X>5J9:N^^MV3
M?=AZ=6MC@WW'&-O:7*?OVKKXEI\J8YL;M8VMVD9];1-JJ^M;Z]^QC:=#*?Z$
M?J![C'WGVM8][;CG/P="S_OQ(_D/=..".^83Z,$\\J]MKD%MO;I97\C_.3[3
M\C_4+_C0LGG%<AYIC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M4$6*4FL8HH_9R)$.?RW$!BB(<9:&^&+(W:%"IA@C,@3Y^@7D88D!$TN*J*+*
MMLAT`;:01;=E=[Z/TCO83#`=<['(=/A63(='H>+)7$DV4Y).?0Q%5L(83V0*
MJ<22TU1)IL8+R<)B,6)Y$E9$$F.O=V;V:\0M[Z<T)\DD'4WF@&(6?/H7^DJD
MJC$3AS=S#2@:)E/:,]F3F*(C[B3*YF%.LMM7H,JD`LQF$=5]JFW>S:+:UE/P
M*!VD1&Q*%]_+J9A1F8Y?Q:N$D619I:H^K=_-K/6GX%44KT5LBDINY5!R>KM5
MNV(P\]D=.CTFE4H/7*LP#26I0$_!DU2,&O$E53J/G:4[SL<-=/X/YT;]*;BA
MHO&($:I@#@N*NLR%H):#6>\;4Q\M-B+RHY(YZ(_[?)7SP'G_?]LUGQ6$81B,
MWWV*,B@H#"_>!-]DQR+L(?;NIE_^M0UZ$O'07%Q#EVW?LO87XL]DT,>1H/29
M)VWI&60GV5GKM@YF0:^#]P-SA?;Y^;8N0MBYI#OZ>+R6=$!.LQPR-JH@MF4U
MV-`Q+9I7&R*2PJ"PH*ZJ(31352[VG<L(A)69$W&$J`$AO?O/0C@U]V(8.X^"
MR(F>:GKC+7]+WKAK2#:R>A$-(<^<&F!O0\!%$3A$NJ13R-DGUT<])%83,AU*
M6WEM30(%4:#SHPKH@H!E@;3NVX'0>W$/7@!HUS7[XIWR[P>XUFGH8<>KO2D:
=[:\LE#>8I_6B0/TQ&V/3IDW[(WL!ZVTY.@!X````
`
end

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com

- Next message: Gernot Ziegler: "Dexxa Flatbedscanner support ...."
- Previous message: Hugo van der Kooij: "Re: Minolta Reply (was:Public Relation Department (Ref. No. CR-3255 V)"