readproc for SANE

Oliver.Rauch@Wolfsburg.DE
Fri, 17 Apr 1998 20:28:36 +0200 (MET DST)

Hello backend-developers!

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.72.tar.gz
M'XL(`*^:-S4``^T[:W/;MK+]*OX*5'4:T9'U\NO$JC-6_$ATZM=8<MM,TE$I
M$K)X3)&Z!&G')\W][7=W`?`AR7&=VLZ=*3%C"UP`BWT"BR4H+)^O-&J;K?IW
MCU;86F-S?9U]QQC;W%BCW^::_%6EP=C&>G-]L[G>6MV`UL;:YMIW;/WQ2$I+
M+"(K9.R[P'/OZ,=#\10$/6T1B?Z'EGW)?><1[.`^^F]NK$)KJ['1*O3_%&5>
M_T?6)1^Y'J^Y_@/-T6PT-I2^%^E_=76])?7?:C0WFRUL;377OV.-!YK_B^4?
MKO_>V_W#0[;-ZD/7KXNQ8?QRVNF_!<"."&W'#7<,^9N%1,%TD$+3)]DRC%W/
MD6TUPYB&8$P?L9^L[1C\([<'*3CSN&,`$0JKK,'L*4AHF.<.<90"IT\[AF-%
ME@*K*F"X$7;@CS22Y`E:QE;('=!_Q'5K#@(S!;;E93OD`$1)2@5!7'\4*)"J
M[A@32[,@:]C+]F*')QWUTXX1>$ZNL1Z+L*X@AG'T\U[W#*!+E53J9GURZ?I`
MDP=#0V%TCWO]#NET1U5W-&QP>G;RYJQSE&G3H+3/7J??R7;`YQW#V.GM]P='
MG9_WH:Z:]O<&W>/=P_.]_1[19#F.TFN>/D5^'=>:>A7_U\8,?USX_6"4J#I0
MZX]N&MB!`Y9A"=MU9V!@!PG$X</X(HO&YU'2*&R1CKUVPV3>0<@MH#6P%2"8
M1J(V-A%+CE@T%1?0&T;O_#6(OE?:9J!IB80IBMDH#/P(*TY@LR@(/&$8H(TM
M!O]60F['H7"O0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<8:&EG0"_TW-7UE4FL*BS-LS01LQRA[H1\O2*)7A2!.I
MH(F8RFH8DH_9R+$%_UVD!CA(:5:.^/V(!R--C)D2,@+]B@K*L,I`B%7-E*FS
M+2I=@#T4Z+;LSH])>@>[2:%C+A:%#K]:Z%"5)I[-E<QF2O*ICY',2MB3J4HA
M55EVFZJJU'@E"S3-1.197`E+C+W87CBNG?:\F].28I-L-)L#2D7P_E^X5B)7
M[84TO+S7A+)C-J6]4#R9+3J13@9V'^%DAWT%J4P9P&(14=O[YL:71=3<?`P9
MY8.41$QY\)V22@4U,_"K9)5QDEE1Z:;W:U\6UMICR"J)UQ(Q)9!;)93=WFZU
MKA3-_?P.%SVFC,J*`K<RCR5K0(\ADUR,FL@E![V/G^4'WD\:N/C_=6FT'D,:
M.AI/!*$!]_"@9,B]"#1*L.M]8^Z3PT;"?@*Y!__IF*]:/'#??S(Q:'844G!S
MIE_I)4$V4SLK;NL4L]"[#KD?)*"YU^>5U6I91=C/'+9%[_'D6I(+R*%7&F1\
M@!/$AW(U"3;T,RR:M>21,.E@4,6">E6=0RVCJF=.XN?JB2*L9S).I!IAG0LA
MT[?_4A!IU)P71A([SPI$#4Q-31.>C;^5W:2@&6.#@I-H%(IGE@G8LR@(!!@D
M"F8R8\YF1_)\E`\2L:C(=.9HJ]26,:`YH9"<MU&`J4`HEJ60-H6Y%$*[3@HA
M!5"TF\KL`2F5OU\(KG4W>H<]/]LMA\;D*@O8#?73YT45U'\N7HP5I2A%*4I1
BBE*4HA2E*$4I2E&*4I2B%*4H12E*49ZH_!_>=R:P`'@`````
`
end

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