parse_spoolss.c
来自「samba-3.0.22.tar.gz 编译smb服务器的源码」· C语言 代码 · 共 2,230 行 · 第 1/5 页
C
2,230 行
const fstring printername, const fstring datatype, uint32 access_required, const fstring clientname, const fstring user_name){ DEBUG(5,("make_spoolss_q_open_printer_ex\n")); q_u->printername = TALLOC_P( get_talloc_ctx(), UNISTR2 ); init_unistr2(q_u->printername, printername, UNI_STR_TERMINATE); q_u->printer_default.datatype_ptr = 0; q_u->printer_default.devmode_cont.size=0; q_u->printer_default.devmode_cont.devmode_ptr=0; q_u->printer_default.devmode_cont.devmode=NULL; q_u->printer_default.access_required=access_required; q_u->user_switch = 1; q_u->user_ctr.level = 1; q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 ); q_u->user_ctr.user.user1->size = strlen(clientname) + strlen(user_name) + 10; q_u->user_ctr.user.user1->build = 1381; q_u->user_ctr.user.user1->major = 2; q_u->user_ctr.user.user1->minor = 0; q_u->user_ctr.user.user1->processor = 0; q_u->user_ctr.user.user1->client_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); q_u->user_ctr.user.user1->user_name = TALLOC_P( get_talloc_ctx(), UNISTR2 ); init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE); init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE); return True;}/******************************************************************* * init a structure. ********************************************************************/BOOL make_spoolss_q_addprinterex( TALLOC_CTX *mem_ctx, SPOOL_Q_ADDPRINTEREX *q_u, const char *srv_name, const char* clientname, const char* user_name, uint32 level, PRINTER_INFO_CTR *ctr){ DEBUG(5,("make_spoolss_q_addprinterex\n")); if (!ctr) return False; ZERO_STRUCTP(q_u); q_u->server_name = TALLOC_P( mem_ctx, UNISTR2 ); init_unistr2(q_u->server_name, srv_name, UNI_FLAGS_NONE); q_u->level = level; q_u->info.level = level; q_u->info.info_ptr = (ctr->printers_2!=NULL)?1:0; switch (level) { case 2: /* init q_u->info.info2 from *info */ if (!make_spoolss_printer_info_2(mem_ctx, &q_u->info.info_2, ctr->printers_2)) { DEBUG(0,("make_spoolss_q_addprinterex: Unable to fill SPOOL_Q_ADDPRINTEREX struct!\n")); return False; } break; default : break; } q_u->user_switch=1; q_u->user_ctr.level = 1; q_u->user_ctr.user.user1 = TALLOC_P( get_talloc_ctx(), SPOOL_USER_1 ); q_u->user_ctr.user.user1->build = 1381; q_u->user_ctr.user.user1->major = 2; q_u->user_ctr.user.user1->minor = 0; q_u->user_ctr.user.user1->processor = 0; q_u->user_ctr.user.user1->client_name = TALLOC_P( mem_ctx, UNISTR2 ); q_u->user_ctr.user.user1->user_name = TALLOC_P( mem_ctx, UNISTR2 ); init_unistr2(q_u->user_ctr.user.user1->client_name, clientname, UNI_STR_TERMINATE); init_unistr2(q_u->user_ctr.user.user1->user_name, user_name, UNI_STR_TERMINATE); q_u->user_ctr.user.user1->size = q_u->user_ctr.user.user1->user_name->uni_str_len + q_u->user_ctr.user.user1->client_name->uni_str_len + 2; return True;} /*******************************************************************create a SPOOL_PRINTER_INFO_2 stuct from a PRINTER_INFO_2 struct*******************************************************************/BOOL make_spoolss_printer_info_2(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2 **spool_info2, PRINTER_INFO_2 *info){ SPOOL_PRINTER_INFO_LEVEL_2 *inf; /* allocate the necessary memory */ if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_2))) { DEBUG(0,("make_spoolss_printer_info_2: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_2 sruct!\n")); return False; } inf->servername_ptr = (info->servername.buffer!=NULL)?1:0; inf->printername_ptr = (info->printername.buffer!=NULL)?1:0; inf->sharename_ptr = (info->sharename.buffer!=NULL)?1:0; inf->portname_ptr = (info->portname.buffer!=NULL)?1:0; inf->drivername_ptr = (info->drivername.buffer!=NULL)?1:0; inf->comment_ptr = (info->comment.buffer!=NULL)?1:0; inf->location_ptr = (info->location.buffer!=NULL)?1:0; inf->devmode_ptr = (info->devmode!=NULL)?1:0; inf->sepfile_ptr = (info->sepfile.buffer!=NULL)?1:0; inf->printprocessor_ptr = (info->printprocessor.buffer!=NULL)?1:0; inf->datatype_ptr = (info->datatype.buffer!=NULL)?1:0; inf->parameters_ptr = (info->parameters.buffer!=NULL)?1:0; inf->secdesc_ptr = (info->secdesc!=NULL)?1:0; inf->attributes = info->attributes; inf->priority = info->priority; inf->default_priority = info->defaultpriority; inf->starttime = info->starttime; inf->untiltime = info->untiltime; inf->cjobs = info->cjobs; inf->averageppm = info->averageppm; init_unistr2_from_unistr(&inf->servername, &info->servername); init_unistr2_from_unistr(&inf->printername, &info->printername); init_unistr2_from_unistr(&inf->sharename, &info->sharename); init_unistr2_from_unistr(&inf->portname, &info->portname); init_unistr2_from_unistr(&inf->drivername, &info->drivername); init_unistr2_from_unistr(&inf->comment, &info->comment); init_unistr2_from_unistr(&inf->location, &info->location); init_unistr2_from_unistr(&inf->sepfile, &info->sepfile); init_unistr2_from_unistr(&inf->printprocessor, &info->printprocessor); init_unistr2_from_unistr(&inf->datatype, &info->datatype); init_unistr2_from_unistr(&inf->parameters, &info->parameters); init_unistr2_from_unistr(&inf->datatype, &info->datatype); *spool_info2 = inf; return True;}/*******************************************************************create a SPOOL_PRINTER_INFO_3 struct from a PRINTER_INFO_3 struct*******************************************************************/BOOL make_spoolss_printer_info_3(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3 **spool_info3, PRINTER_INFO_3 *info){ SPOOL_PRINTER_INFO_LEVEL_3 *inf; /* allocate the necessary memory */ if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_3))) { DEBUG(0,("make_spoolss_printer_info_3: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_3 sruct!\n")); return False; } inf->secdesc_ptr = (info->secdesc!=NULL)?1:0; *spool_info3 = inf; return True;}/*******************************************************************create a SPOOL_PRINTER_INFO_7 struct from a PRINTER_INFO_7 struct*******************************************************************/BOOL make_spoolss_printer_info_7(TALLOC_CTX *mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7 **spool_info7, PRINTER_INFO_7 *info){ SPOOL_PRINTER_INFO_LEVEL_7 *inf; /* allocate the necessary memory */ if (!(inf=TALLOC_P(mem_ctx, SPOOL_PRINTER_INFO_LEVEL_7))) { DEBUG(0,("make_spoolss_printer_info_7: Unable to allocate SPOOL_PRINTER_INFO_LEVEL_7 struct!\n")); return False; } inf->guid_ptr = (info->guid.buffer!=NULL)?1:0; inf->action = info->action; init_unistr2_from_unistr(&inf->guid, &info->guid); *spool_info7 = inf; return True;}/******************************************************************* * read a structure. * called from spoolss_q_open_printer_ex (srv_spoolss.c) ********************************************************************/BOOL spoolss_io_q_open_printer(const char *desc, SPOOL_Q_OPEN_PRINTER *q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_q_open_printer"); depth++; if (!prs_align(ps)) return False; if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername)) return False; if (!prs_io_unistr2("printername", ps, depth, q_u->printername)) return False; if (!prs_align(ps)) return False; if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth)) return False; return True;}/******************************************************************* * write a structure. * called from static spoolss_r_open_printer_ex (srv_spoolss.c) * called from spoolss_open_printer_ex (cli_spoolss.c) ********************************************************************/BOOL spoolss_io_r_open_printer(const char *desc, SPOOL_R_OPEN_PRINTER *r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_r_open_printer"); depth++; if (!prs_align(ps)) return False; if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth)) return False; if (!prs_werror("status code", ps, depth, &(r_u->status))) return False; return True;}/******************************************************************* * read a structure. * called from spoolss_q_open_printer_ex (srv_spoolss.c) ********************************************************************/BOOL spoolss_io_q_open_printer_ex(const char *desc, SPOOL_Q_OPEN_PRINTER_EX *q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_q_open_printer_ex"); depth++; if (!prs_align(ps)) return False; if (!prs_io_unistr2_p("ptr", ps, depth, &q_u->printername)) return False; if (!prs_io_unistr2("printername", ps, depth, q_u->printername)) return False; if (!prs_align(ps)) return False; if (!spoolss_io_printer_default("", &q_u->printer_default, ps, depth)) return False; if (!prs_uint32("user_switch", ps, depth, &q_u->user_switch)) return False; if (!spool_io_user_level("", &q_u->user_ctr, ps, depth)) return False; return True;}/******************************************************************* * write a structure. * called from static spoolss_r_open_printer_ex (srv_spoolss.c) * called from spoolss_open_printer_ex (cli_spoolss.c) ********************************************************************/BOOL spoolss_io_r_open_printer_ex(const char *desc, SPOOL_R_OPEN_PRINTER_EX *r_u, prs_struct *ps, int depth){ if (r_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_r_open_printer_ex"); depth++; if (!prs_align(ps)) return False; if (!smb_io_pol_hnd("printer handle",&(r_u->handle),ps,depth)) return False; if (!prs_werror("status code", ps, depth, &(r_u->status))) return False; return True;}/******************************************************************* * init a structure. ********************************************************************/BOOL make_spoolss_q_deleteprinterdriverex( TALLOC_CTX *mem_ctx, SPOOL_Q_DELETEPRINTERDRIVEREX *q_u, const char *server, const char* arch, const char* driver, int version){ DEBUG(5,("make_spoolss_q_deleteprinterdriverex\n")); q_u->server_ptr = (server!=NULL)?1:0; q_u->delete_flags = DPD_DELETE_UNUSED_FILES; /* these must be NULL terminated or else NT4 will complain about invalid parameters --jerry */ init_unistr2(&q_u->server, server, UNI_STR_TERMINATE); init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE); init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE); if (version >= 0) { q_u->delete_flags |= DPD_DELETE_SPECIFIC_VERSION; q_u->version = version; } return True;}/******************************************************************* * init a structure. ********************************************************************/BOOL make_spoolss_q_deleteprinterdriver( TALLOC_CTX *mem_ctx, SPOOL_Q_DELETEPRINTERDRIVER *q_u, const char *server, const char* arch, const char* driver ){ DEBUG(5,("make_spoolss_q_deleteprinterdriver\n")); q_u->server_ptr = (server!=NULL)?1:0; /* these must be NULL terminated or else NT4 will complain about invalid parameters --jerry */ init_unistr2(&q_u->server, server, UNI_STR_TERMINATE); init_unistr2(&q_u->arch, arch, UNI_STR_TERMINATE); init_unistr2(&q_u->driver, driver, UNI_STR_TERMINATE); return True;}/******************************************************************* * make a structure. ********************************************************************/BOOL make_spoolss_q_getprinterdata(SPOOL_Q_GETPRINTERDATA *q_u, const POLICY_HND *handle, const char *valuename, uint32 size){ if (q_u == NULL) return False; DEBUG(5,("make_spoolss_q_getprinterdata\n")); q_u->handle = *handle; init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE); q_u->size = size; return True;}/******************************************************************* * make a structure. ********************************************************************/BOOL make_spoolss_q_getprinterdataex(SPOOL_Q_GETPRINTERDATAEX *q_u, const POLICY_HND *handle, const char *keyname, const char *valuename, uint32 size){ if (q_u == NULL) return False; DEBUG(5,("make_spoolss_q_getprinterdataex\n")); q_u->handle = *handle; init_unistr2(&q_u->valuename, valuename, UNI_STR_TERMINATE); init_unistr2(&q_u->keyname, keyname, UNI_STR_TERMINATE); q_u->size = size; return True;}/******************************************************************* * read a structure. * called from spoolss_q_getprinterdata (srv_spoolss.c) ********************************************************************/BOOL spoolss_io_q_getprinterdata(const char *desc, SPOOL_Q_GETPRINTERDATA *q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_q_getprinterdata"); depth++; if (!prs_align(ps)) return False; if (!smb_io_pol_hnd("printer handle",&q_u->handle,ps,depth)) return False; if (!prs_align(ps)) return False; if (!smb_io_unistr2("valuename", &q_u->valuename,True,ps,depth)) return False; if (!prs_align(ps)) return False; if (!prs_uint32("size", ps, depth, &q_u->size)) return False; return True;}/******************************************************************* * read a structure. * called from spoolss_q_deleteprinterdata (srv_spoolss.c) ********************************************************************/BOOL spoolss_io_q_deleteprinterdata(const char *desc, SPOOL_Q_DELETEPRINTERDATA *q_u, prs_struct *ps, int depth){ if (q_u == NULL) return False; prs_debug(ps, depth, desc, "spoolss_io_q_deleteprinterdata"); depth++;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?