int main(int argc, char *argv[]) { filedb_top("."); make_init(); context* ctx = make_context(); assert(lib_read(argv[1],strlen(argv[1]),ctx)); VipsImage* image = lib_thumbnail(ctx); lib_write(image,argv[2],1,ctx); return 0; }
int cli_hs_stage1_prepare(conn_t *c) { int res = 0; cli_conn_t *cli; buf_t *buf; my_auth_init_t init; my_info_t *info; my_node_t *node; my_conn_t *my; cli = c->cli; if( (res = conn_alloc_my_conn(c)) < 0 ){ log(g_log, "conn:%u conn_alloc_my_conn error\n", c->connid); return -1; } my = c->my; node = my->node; info = node->info; buf = &(cli->buf); bzero(&init, sizeof(init)); init.pktno = 0; init.prot_ver = info->protocol; strncpy(init.srv_ver, info->ver, sizeof(init.srv_ver) - 1); init.srv_ver[sizeof(init.srv_ver) - 1] = '\0'; init.tid = c->connid; memcpy(init.scram, cli->scram, 8); init.cap = info->cap; init.lang = 8;//info->lang; init.status = info->status; strncpy(init.plug, cli->scram + 8, 12); init.scram_len = 21; init.plug[12] = '\0'; if( (res = make_init(buf, &init)) < 0 ){ log(g_log, "conn:%u make_init error\n", c->connid); return res; } res = add_handler(cli->fd, EPOLLOUT, cli_hs_stage1_cb, cli); if(res < 0){ log(g_log, "conn:%u add_handler fail\n", c->connid); return -1; } return res; }
static void pcl_header(fz_output *out, fz_pcl_options *pcl, int num_copies, int xres) { char odd_page_init[80]; char even_page_init[80]; make_init(pcl, odd_page_init, sizeof(odd_page_init), pcl->odd_page_init, xres); make_init(pcl, even_page_init, sizeof(even_page_init), pcl->even_page_init, xres); if (pcl->page_count == 0) { if (pcl->features & HACK__IS_A_LJET4PJL) fz_puts(out, "\033%-12345X@PJL\r\n@PJL ENTER LANGUAGE = PCL\r\n"); fz_puts(out, "\033E"); /* reset printer */ /* If the printer supports it, set the paper size */ /* based on the actual requested size. */ if (pcl->features & PCL_CAN_SET_PAPER_SIZE) fz_printf(out, "\033&l%dA", pcl->paper_size); /* If printer can duplex, set duplex mode appropriately. */ if (pcl->features & PCL_HAS_DUPLEX) { if (pcl->duplex_set) { if (pcl->duplex) { if (!pcl->tumble) fz_puts(out, "\033&l1S"); else fz_puts(out, "\033&l2S"); } else fz_puts(out, "\033&l0S"); } else { /* default to duplex for this printer */ fz_puts(out, "\033&l1S"); } } } /* Put out per-page initialization. */ /* in duplex mode the sheet is already in process, so there are some * commands which must not be sent to the printer for the 2nd page, * as this commands will cause the printer to eject the sheet with * only the 1st page printed. This commands are: * \033&l%dA (setting paper size) * \033&l%dH (setting paper tray) * in simplex mode we set this parameters for each page, * in duplex mode we set this parameters for each odd page */ if ((pcl->features & PCL_HAS_DUPLEX) && pcl->duplex_set && pcl->duplex) { /* We are printing duplex, so change margins as needed */ if (((pcl->page_count/num_copies)%2) == 0) { if (pcl->page_count != 0 && (pcl->features & PCL_CAN_SET_PAPER_SIZE)) { fz_printf(out, "\033&l%dA", pcl->paper_size); } fz_puts(out, "\033&l0o0l0E"); fz_puts(out, pcl->odd_page_init); } else fz_puts(out, pcl->even_page_init); } else { if (pcl->features & PCL_CAN_SET_PAPER_SIZE) { fz_printf(out, "\033&l%dA", pcl->paper_size); } fz_puts(out, "\033&l0o0l0E"); fz_puts(out, pcl->odd_page_init); } fz_printf(out, "\033&l%dX", num_copies); /* # of copies */ /* End raster graphics, position cursor at top. */ fz_puts(out, "\033*rB\033*p0x0Y"); /* The DeskJet and DeskJet Plus reset everything upon */ /* receiving \033*rB, so we must reinitialize graphics mode. */ if (pcl->features & PCL_END_GRAPHICS_DOES_RESET) { fz_puts(out, pcl->odd_page_init); /* Assume this does the right thing */ fz_printf(out, "\033&l%dX", num_copies); /* # of copies */ } /* Set resolution. */ fz_printf(out, "\033*t%dR", xres); pcl->page_count++; }