printing/print_svid.c

説明を見る。
00001 /*
00002  * Copyright (C) 1997-1998 by Norm Jacobs, Colorado Springs, Colorado, USA
00003  * Copyright (C) 1997-1998 by Sun Microsystem, Inc.
00004  * All Rights Reserved
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  * 
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  * 
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 /*
00022  * This module implements support for gathering and comparing available
00023  * printer information on a SVID or XPG4 compliant system.  It does this
00024  * through the use of the SVID/XPG4 command "lpstat(1)".
00025  *
00026  * The expectations is that execution of the command "lpstat -v" will
00027  * generate responses in the form of:
00028  *
00029  *      device for serial: /dev/term/b
00030  *      system for fax: server
00031  *      system for color: server (as printer chroma)
00032  */
00033 
00034 
00035 #include "includes.h"
00036 
00037 #if defined(SYSV) || defined(HPUX)
00038 BOOL sysv_cache_reload(void)
00039 {
00040         char **lines;
00041         int i;
00042 
00043 #if defined(HPUX)
00044         DEBUG(5, ("reloading hpux printcap cache\n"));
00045 #else
00046         DEBUG(5, ("reloading sysv printcap cache\n"));
00047 #endif
00048 
00049         if ((lines = file_lines_pload("/usr/bin/lpstat -v", NULL)) == NULL)
00050         {
00051 #if defined(HPUX)
00052       
00053                /*
00054                 * if "lpstat -v" is NULL then we check if schedular is running if it is
00055                 * that means no printers are added on the HP-UX system, if schedular is not
00056                 * running we display reload error.
00057                 */
00058 
00059                 char **scheduler;
00060                 scheduler = file_lines_pload("/usr/bin/lpstat -r", NULL);
00061                 if(!strcmp(*scheduler,"scheduler is running")){
00062                         DEBUG(3,("No Printers found!!!\n"));
00063                         file_lines_free(scheduler);
00064                         return True;
00065                 }
00066                 else{
00067                         DEBUG(3,("Scheduler is not running!!!\n"));
00068                         file_lines_free(scheduler);
00069                         return False;
00070                 }
00071 #else
00072                 DEBUG(3,("No Printers found!!!\n"));
00073                 return False;
00074 #endif
00075         }
00076 
00077         for (i = 0; lines[i]; i++) {
00078                 char *name, *tmp;
00079                 char *buf = lines[i];
00080 
00081                 /* eat "system/device for " */
00082                 if (((tmp = strchr_m(buf, ' ')) == NULL) ||
00083                     ((tmp = strchr_m(++tmp, ' ')) == NULL))
00084                         continue;
00085 
00086                 /*
00087                  * In case we're only at the "for ".
00088                  */
00089 
00090                 if(!strncmp("for ", ++tmp, 4)) {
00091                         tmp=strchr_m(tmp, ' ');
00092                         tmp++;
00093                 }
00094 
00095                 /* Eat whitespace. */
00096 
00097                 while(*tmp == ' ')
00098                         ++tmp;
00099 
00100                 /*
00101                  * On HPUX there is an extra line that can be ignored.
00102                  * d.thibadeau 2001/08/09
00103                  */
00104                 if(!strncmp("remote to", tmp, 9))
00105                         continue;
00106 
00107                 name = tmp;
00108 
00109                 /* truncate the ": ..." */
00110                 if ((tmp = strchr_m(name, ':')) != NULL)
00111                         *tmp = '\0';
00112                 
00113                 /* add it to the cache */
00114                 if (!pcap_cache_add(name, NULL)) {
00115                         file_lines_free(lines);
00116                         return False;
00117                 }
00118         }
00119 
00120         file_lines_free(lines);
00121         return True;
00122 }
00123 
00124 #else
00125 /* this keeps fussy compilers happy */
00126  void print_svid_dummy(void);
00127  void print_svid_dummy(void) {}
00128 #endif

Sambaに対してSat Aug 29 21:23:14 2009に生成されました。  doxygen 1.4.7