printing/print_aix.c

説明を見る。
00001 /* 
00002    AIX-specific printcap loading
00003    Copyright (C) Jean-Pierre.Boulard@univ-rennes1.fr      1996
00004 
00005    This program is free software; you can redistribute it and/or modify
00006    it under the terms of the GNU General Public License as published by
00007    the Free Software Foundation; either version 2 of the License, or
00008    (at your option) any later version.
00009    
00010    This program is distributed in the hope that it will be useful,
00011    but WITHOUT ANY WARRANTY; without even the implied warranty of
00012    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013    GNU General Public License for more details.
00014    
00015    You should have received a copy of the GNU General Public License
00016    along with this program; if not, write to the Free Software
00017    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00018 */
00019 
00020 /*
00021  * This module implements AIX-specific printcap loading.  Most of the code
00022  * here was originally provided by Jean-Pierre.Boulard@univ-rennes1.fr in
00023  * the Samba 1.9.14 release, and was formerly contained in pcap.c.  It has
00024  * been moved here and condensed as part of a larger effort to clean up and
00025  * simplify the printcap code.    -- Rob Foehl, 2004/12/06
00026  */
00027 
00028 #include "includes.h"
00029 
00030 #ifdef AIX
00031 BOOL aix_cache_reload(void)
00032 {
00033         int iEtat;
00034         XFILE *pfile;
00035         char *line = NULL, *p;
00036         pstring name, comment;
00037 
00038         *name = 0;
00039         *comment = 0;
00040 
00041         DEBUG(5, ("reloading aix printcap cache\n"));
00042 
00043         if ((pfile = x_fopen(lp_printcapname(), O_RDONLY, 0)) == NULL) {
00044                 DEBUG(0,( "Unable to open qconfig file %s for read!\n", lp_printcapname()));
00045                 return False;
00046         }
00047 
00048         iEtat = 0;
00049         /* scan qconfig file for searching <printername>:       */
00050         for (;(line = fgets_slash(NULL, sizeof(pstring), pfile)); safe_free(line)) {
00051                 if (*line == '*' || *line == 0)
00052                         continue;
00053 
00054                 switch (iEtat) {
00055                 case 0: /* locate an entry */
00056                         if (*line == '\t' || *line == ' ')
00057                                 continue;
00058 
00059                         if ((p = strchr_m(line, ':'))) {
00060                                 *p = '\0';
00061                                 p = strtok(line, ":");
00062                                 if (strcmp(p, "bsh") != 0) {
00063                                         pstrcpy(name, p);
00064                                         iEtat = 1;
00065                                         continue;
00066                                 }
00067                          }
00068                          break;
00069 
00070                 case 1: /* scanning device stanza */
00071                         if (*line == '*' || *line == 0)
00072                                 continue;
00073 
00074                         if (*line != '\t' && *line != ' ') {
00075                                 /* name is found without stanza device  */
00076                                 /* probably a good printer ???          */
00077                                 iEtat = 0;
00078                                 if (!pcap_cache_add(name, NULL)) {
00079                                         safe_free(line);
00080                                         x_fclose(pfile);
00081                                         return False;
00082                                 }
00083                                 continue;
00084                         }
00085                         
00086                         if (strstr_m(line, "backend")) {
00087                                 /* it's a device, not a virtual printer */
00088                                 iEtat = 0;
00089                         } else if (strstr_m(line, "device")) {
00090                                 /* it's a good virtual printer */
00091                                 iEtat = 0;
00092                                 if (!pcap_cache_add(name, NULL)) {
00093                                         safe_free(line);
00094                                         x_fclose(pfile);
00095                                         return False;
00096                                 }
00097                                 continue;
00098                         }
00099                         break;
00100                 }
00101         }
00102 
00103         x_fclose(pfile);
00104         return True;
00105 }
00106 
00107 #else
00108 /* this keeps fussy compilers happy */
00109  void print_aix_dummy(void);
00110  void print_aix_dummy(void) {}
00111 #endif /* AIX */

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