static int hop_poll(lua_State *L) { snHopLoop *hloop = checkLoop(L); struct timeval *tv = NULL; double usec_total = 0; if (lua_istable(L, 2)) { usec_total = table_to_usec(L, 2); if (usec_total > 0) { tv = malloc(sizeof(struct timeval)); tv->tv_sec = (long int) (usec_total / SIM); tv->tv_usec = (long int) fmod(usec_total, SIM); } } int nevents = hloop->api->poll(hloop, tv); if (tv != NULL) free(tv); int i = 0; for (i=0; i<nevents; i++) { snFiredEvent fevent = hloop->fired[i]; int mask = fevent.mask; int fd = fevent.fd; if (mask & SN_TIMER) { /* timer event */ snTimerEvent *timerEvent = &hloop->timers[fd]; lua_State *ctx = timerEvent->L; if (timerEvent->mask & mask & SN_TIMER) { int callback = timerEvent->callback; run_callback(L, ctx, callback, fd, mask, hloop); if (timerEvent->mask & SN_ONCE) { _clearTimer(L, hloop, fd); } } } else { /* <file event> */ snFileEvent *evData = &hloop->events[fd]; lua_State *ctx = evData->L; int rcallback = evData->rcallback; int wcallback = evData->wcallback; int rfired = 0; if (evData->mask & mask & SN_READABLE) { rfired = 1; run_callback(L, ctx, rcallback, fd, mask, NULL); } if (evData->mask & mask & SN_WRITABLE) { if (!rfired || evData->wcallback != evData->rcallback) { run_callback(L, ctx, wcallback, fd, mask, NULL); } } } /* </file event> */ } return 0; }
static int stdarg_test(void) { const char *src = "#include <stdarg.h>\n" "typedef struct {long long a, b, c;} stdarg_test_struct_type;\n" "void f(int n_int, int n_float, int n_struct, ...) {\n" " int i, ti = 0;\n" " double td = 0.0;\n" " stdarg_test_struct_type ts = {0,0,0}, tmp;\n" " va_list ap;\n" " va_start(ap, n_struct);\n" " for (i = 0, ti = 0; i < n_int; ++i)\n" " ti += va_arg(ap, int);\n" " *va_arg(ap, int*) = ti;\n" " for (i = 0, td = 0; i < n_float; ++i)\n" " td += va_arg(ap, double);\n" " *va_arg(ap, double*) = td;\n" " for (i = 0; i < n_struct; ++i) {\n" " tmp = va_arg(ap, stdarg_test_struct_type);\n" " ts.a += tmp.a; ts.b += tmp.b; ts.c += tmp.c;" " }\n" " *va_arg(ap, stdarg_test_struct_type*) = ts;\n" " va_end(ap);" "}\n"; return run_callback(src, stdarg_test_callback); }
static int arg_align_test(void) { const char *src = "long double f(long double a, int b, long double c, int d, long double e) {\n" " return a + c + e;\n" "}\n"; return run_callback(src, arg_align_test_callback); }
/** \brief run one callback * * assumes, that the queue contains at least one callback * * */ void run_callback(void) { callback_type* runme; bool dequeued = callbacks.dequeue(&runme); assert(dequeued); run_callback(runme); }
static int two_member_union_test(void) { const char *src = "typedef union two_member_union_test_type_u {int x; long y;} two_member_union_test_type;\n" "two_member_union_test_type f(two_member_union_test_type a) {\n" " two_member_union_test_type b;\n" " b.x = a.x * 2;\n" " return b;\n" "}\n"; return run_callback(src, two_member_union_test_callback); }
static int one_member_union_test(void) { const char *src = "typedef union one_member_union_test_type_u {int x;} one_member_union_test_type;\n" "one_member_union_test_type f(one_member_union_test_type a) {\n" " one_member_union_test_type b;\n" " b.x = a.x * 2;\n" " return b;\n" "}\n"; return run_callback(src, one_member_union_test_callback); }
static int sret_test(void) { const char *src = "typedef struct sret_test_type_s {long long a, b, c;} sret_test_type;\n" "sret_test_type f(sret_test_type x) {\n" " sret_test_type r = {x.a*35, x.b*19, x.c*21};\n" " return r;\n" "}\n"; return run_callback(src, sret_test_callback); }
static int ret_2float_test(void) { const char *src = "typedef struct ret_2float_test_type_s {float x, y;} ret_2float_test_type;" "ret_2float_test_type f(ret_2float_test_type a) {\n" " ret_2float_test_type r = {a.x*5, a.y*3};\n" " return r;\n" "}\n"; return run_callback(src, ret_2float_test_callback); }
void pdf_place_rule(PDF pdf,halfword q,scaledpos size,int callback_id) { pdfpos dim; pdfstructure*p= pdf->pstruct; scaledpos pos= pdf->posstruct->pos; if(subtype(q)==box_rule){ pdf_place_form(pdf,q); }else if(subtype(q)==image_rule){ pdf_place_image(pdf,q); }else if(subtype(q)==empty_rule){ }else if(subtype(q)==user_rule){ if(callback_id!=0){ pdf_goto_pagemode(pdf); pdf_puts(pdf,"q\n"); pdf_set_pos_temp(pdf,pos); run_callback(callback_id,"Ndd->",q,size.h,size.v); pdf_puts(pdf,"\nQ\n"); } }else{ pdf_goto_pagemode(pdf); dim.h.m= i64round(size.h*p->k1); dim.h.e= p->pdf.h.e; dim.v.m= i64round(size.v*p->k1); dim.v.e= p->pdf.v.e; pdf_puts(pdf,"q\n"); if(size.v<=one_bp){ pos.v+= i64round(0.5*size.v); pdf_set_pos_temp(pdf,pos); pdf_puts(pdf,"[]0 d 0 J "); print_pdffloat(pdf,dim.v); pdf_puts(pdf," w 0 0 m "); print_pdffloat(pdf,dim.h); pdf_puts(pdf," 0 l S\n"); }else if(size.h<=one_bp){ pos.h+= i64round(0.5*size.h); pdf_set_pos_temp(pdf,pos); pdf_puts(pdf,"[]0 d 0 J "); print_pdffloat(pdf,dim.h); pdf_puts(pdf," w 0 0 m 0 "); print_pdffloat(pdf,dim.v); pdf_puts(pdf," l S\n"); }else{ pdf_set_pos_temp(pdf,pos); pdf_puts(pdf,"0 0 "); print_pdffloat(pdf,dim.h); pdf_out(pdf,' '); print_pdffloat(pdf,dim.v); pdf_puts(pdf," re f\n"); } pdf_puts(pdf,"Q\n"); } }/*:2*/
static int many_struct_test_2(void) { const char *src = "typedef struct many_struct_test_2_type_s {int a, b;} many_struct_test_2_type;\n" "many_struct_test_2_type f(many_struct_test_2_type x1, many_struct_test_2_type x2, many_struct_test_2_type x3, many_struct_test_2_type x4, many_struct_test_2_type x5, many_struct_test_2_type x6) {\n" " many_struct_test_2_type y;\n" " y.a = x1.a + x2.a + x3.a + x4.a + x5.a + x6.a;\n" " y.b = x1.b + x2.b + x3.b + x4.b + x5.b + x6.b;\n" " return y;\n" "}\n"; return run_callback(src, many_struct_test_2_callback); }
ff_entry *check_ff_exist(char *ff_name, boolean is_tt) { ff_entry *ff; ff_entry tmp; void **aa; int callback_id; char *filepath=NULL; assert(ff_name != NULL); tmp.ff_name = ff_name; ff = (ff_entry *) avl_find(ff_tree, &tmp); if (ff == NULL) { /* not yet in database */ ff = new_ff_entry(); ff->ff_name = xstrdup(ff_name); if (is_tt) { callback_id=callback_defined(find_truetype_file_callback); if (callback_id>0) { run_callback(callback_id,"S->S",ff_name,&filepath); if (filepath && strlen(filepath)==0) filepath=NULL; ff->ff_path = filepath; } else { ff->ff_path = kpse_find_file (ff_name, kpse_truetype_format, 0); } } else { callback_id=callback_defined(find_type1_file_callback); if (callback_id>0) { run_callback(callback_id,"S->S",ff_name,&filepath); if (filepath && strlen(filepath)==0) filepath=NULL; ff->ff_path = filepath; } else { ff->ff_path = kpse_find_file (ff_name, kpse_type1_format, 0); } } aa = avl_probe(ff_tree, ff); assert(aa != NULL); } return ff; }
/** \brief run all callbacks */ inline void run_callbacks(void) { for (;;) { callback_type* runme; if (not callbacks.dequeue(&runme)) break; run_callback(runme); } }
static int stdarg_struct_test(void) { const char *src = "#include <stdarg.h>\n" "typedef struct {long long a, b, c;} stdarg_struct_test_struct_type;\n" "int f(stdarg_struct_test_struct_type a, ...) {\n" " va_list ap;\n" " va_start(ap, a);\n" " int z = va_arg(ap, int);\n" " va_end(ap);\n" " return z + a.a + a.b + a.c;\n" "}\n"; return run_callback(src, stdarg_struct_test_callback); }
static switch_status_t ru_say_string(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, char **rstr) { switch_new_say_callback_ru_t say_cb = NULL; char *string = NULL; switch_status_t status = SWITCH_STATUS_FALSE; say_cb = choose_callback(say_args); if (say_cb) { status = run_callback(say_cb, tosay, say_args, session, &string); if (string) { status = SWITCH_STATUS_SUCCESS; *rstr = string; } } return status; }
int gui_d_check_proc(int msg, DIALOG *d, int c) { struct callback_data *acd = d->dp3; int ret; ret = d_check_proc(msg, d, c); if (msg == MSG_CLICK) { if (d->dp3 != NULL) { if (d->flags & D_SELECTED) callback_set_int(acd, 1); else callback_set_int(acd, 0); ret = run_callback(acd, D_O_K); } } return ret; }
/* PL */ static switch_status_t pl_say(switch_core_session_t *session, char *tosay, switch_say_args_t *say_args, switch_input_args_t *args) { switch_new_say_callback_t say_cb = NULL; char *string = NULL; switch_status_t status = SWITCH_STATUS_FALSE; say_cb = choose_callback(say_args); if (say_cb) { status = run_callback(say_cb, tosay, say_args, session, &string); if (session && string) { status = switch_ivr_play_file(session, NULL, string, args); } switch_safe_free(string); } return status; }
int portaudio_client::process(const void *input_buffer, void *output_buffer, unsigned long frames_per_buffer, const PaStreamCallbackTimeInfo* time_info, PaStreamCallbackFlags status_flags, void *user_data) { m_buffer_size=frames_per_buffer; if(run_callback&&run_context) { // do the work run_callback(run_context, frames_per_buffer); } if (m_right_data && m_left_data) { float *out = (float*)output_buffer; for (unsigned int n=0; n<m_buffer_size; n++) { *out=m_left_data[n]; out++; *out=m_right_data[n]; out++; } } /* if (m_right_in_data && m_left_in_data) { float *in = (float*)input_buffer; for (unsigned int n=0; n<m_buffer_size; n++) { m_left_in_data[n]=*in; in++; m_right_in_data[n]=*in; in++; } }*/ return 0; }
void write_out(halfword p) { int old_setting; int j; char*s,*ss; int callback_id; int lua_retval; expand_macros_in_tokenlist(p); old_setting= selector; j= write_stream(p); if(file_can_be_written(j)){ selector= j; }else if((j==term_only)&&(selector==term_and_log)){ selector= log_only; tprint_nl(""); }else{ tprint_nl(""); } s= tokenlist_to_cstring(def_ref,false,NULL); if(selector<no_print){ callback_id= callback_defined(process_output_buffer_callback); if(callback_id> 0){ lua_retval= run_callback(callback_id,"S->S",s,&ss); if((lua_retval==true)&&(ss!=NULL)){ xfree(s); s= ss; } } } tprint(s); xfree(s); print_ln(); flush_list(def_ref); selector= old_setting; }
void print_banner(const char*v) { int callback_id= callback_defined(start_run_callback); if(callback_id==0){ fprintf(term_out,"This is "MyName", Version %s%s ",v,WEB2CVERSION); if(format_ident> 0) print(format_ident); print_ln(); if(show_luahashchars){ wterm(' '); fprintf(term_out,"Number of bits used by the hash function ("my_name"): %d",LUAI_HASHLIMIT); print_ln(); } if(shellenabledp){ wterm(' '); if(restrictedshell) fprintf(term_out,"restricted "); fprintf(term_out,"system commands enabled.\n"); } }else if(callback_id> 0){ run_callback(callback_id,"->"); } }
static bool attempt_fb_mem_exploit(unsigned long int address, unsigned long int write_value, unsigned long int restore_value, callback_info_t *info) { unsigned long int offset; offset = get_kernel_physical_offset(); if (offset) { fb_mem_set_kernel_phys_offset(offset - 0x00008000); } if (fb_mem_write_value_at_address(address, write_value)) { run_callback(info); fb_mem_write_value_at_address(address, restore_value); return true; } return false; }
static bool attempt_msm_cameraconfig_exploit(unsigned long int address, unsigned long int write_value, unsigned long int restore_value, callback_info_t *info) { unsigned long int offset; void *p; offset = get_kernel_physical_offset(); if (offset) { msm_cameraconfig_set_kernel_phys_offset(offset - 0x00008000); } if (msm_cameraconfig_write_value_at_address(address, write_value)) { run_callback(info); msm_cameraconfig_write_value_at_address(address, restore_value); return true; } return false; }
static sfd_entry *read_sfd (char *sfd_name) { void **aa; sfd_entry *sfd, tmp_sfd; subfont_entry *sf; char *ftemp = NULL; char buf[SMALL_BUF_SIZE], *p; long int i, j, k; int n; int callback_id=0; int file_opened=0; /* check whether this sfd has been read */ tmp_sfd.name = sfd_name; if (sfd_tree == NULL) { sfd_tree = avl_create (comp_sfd_entry, NULL, &avl_xallocator); assert (sfd_tree != NULL); } sfd = (sfd_entry *) avl_find (sfd_tree, &tmp_sfd); if (sfd != NULL) return sfd; set_cur_file_name (sfd_name); if (sfd_buffer!=NULL) { xfree(sfd_buffer); sfd_buffer=NULL; } sfd_curbyte=0; sfd_size=0; callback_id=callback_defined(find_sfd_file_callback); if (callback_id>0) { if(run_callback(callback_id,"S->S",cur_file_name,&ftemp)) { if(ftemp!=NULL&&strlen(ftemp)) { if (cur_file_name) free(cur_file_name); cur_file_name = xstrdup(ftemp); free(ftemp); } } } callback_id=callback_defined(read_sfd_file_callback); if (callback_id>0) { if(! (run_callback(callback_id,"S->bSd",cur_file_name, &file_opened, &sfd_buffer,&sfd_size) && file_opened && sfd_size>0 ) ) { pdftex_warn ("cannot open SFD file for reading"); cur_file_name = NULL; return NULL; } sfd_read_file(); sfd_close(); } tex_printf ("{"); tex_printf (cur_file_name); sfd = new_sfd_entry (); sfd->name = xstrdup (sfd_name); while (!sfd_eof ()) { sfd_getline (true); if (*sfd_line == 10) /* empty line indicating eof */ break; sf = new_subfont_entry (); sf->next = sfd->subfont; sfd->subfont = sf; sscanf (sfd_line, "%s %n", buf, &n); sf->infix = xstrdup (buf); p = sfd_line + n; /* skip to the next word */ k = 0; read_ranges: for (;;) { if (*p == '\\') { /* continue on next line */ sfd_getline (false); p = sfd_line; goto read_ranges; } else if (*p == 0) /* end of subfont */ break; if (sscanf (p, " %li %n", &i, &n) == 0) pdftex_fail ("invalid token:\n%s", p); p += n; if (*p == ':') { /* offset */ k = i; p++; } else if (*p == '_') { /* range */ if (sscanf (p + 1, " %li %n", &j, &n) == 0) pdftex_fail ("invalid token:\n%s", p); if (i > j || k + (j - i) > 255) pdftex_fail ("invalid range:\n%s", p); while (i <= j) sf->charcodes[k++] = i++; p += n + 1; } else /* codepoint */ sf->charcodes[k++] = i; } } tex_printf ("}"); aa = avl_probe (sfd_tree, sfd); assert (aa != NULL); return sfd; }
/** * @brief Main looping method */ void IOService::run() { char msg_buffer[MAX_BUFFER_SIZE]; m_is_active = true; while(m_is_active) { // This will wait for another job to be inserted on next call // Do we want to insert the job back, if poll is empty or // move to vector then look polls.. i think #2. for(unsigned int i = 0; i < m_service_list.size(); i++) { service_base_ptr job_work = m_service_list.get(i); /** * Handle Read Service if Data is Available. */ if (job_work->getServiceType() == SERVICE_TYPE_READ) { // If Data Available, read, then populate buffer // Otherwise keep polling till data is available. int result = job_work->getSocket()->poll(); if (result > 0) { memset(&msg_buffer, 0, MAX_BUFFER_SIZE); int length = job_work->getSocket()->recvSocket(msg_buffer); if(length < 0) { // Error - Lost Connection std::cout << "async_read - lost connection!: " << length << std::endl; job_work->getSocket()->setInactive(); callback_function_handler run_callback(job_work->getCallback()); std::error_code lost_connect_error_code (1, std::system_category()); run_callback(lost_connect_error_code); m_service_list.remove(i); } else { job_work->setBuffer((unsigned char *)msg_buffer); callback_function_handler run_callback(job_work->getCallback()); std::error_code success_code (0, std::generic_category()); run_callback(success_code); m_service_list.remove(i); } } else if (result == -1) { std::cout << "async_poll - lost connection" << std::endl; callback_function_handler run_callback(job_work->getCallback()); std::error_code lost_connect_error_code (1, std::system_category()); run_callback(lost_connect_error_code); m_service_list.remove(i); } } /** * Handle Write Service if Data is Available. */ else if (job_work->getServiceType() == SERVICE_TYPE_WRITE) { // std::cout << "* SERVICE_TYPE_WRITE" << std::endl; int result = job_work->getSocket()->sendSocket( (unsigned char*)job_work->getStringSequence().c_str(), job_work->getStringSequence().size()); if (result <= 0) { // Error - Lost Connection std::cout << "async_write - lost connection!" << std::endl; job_work->getSocket()->setInactive(); callback_function_handler run_callback(job_work->getCallback()); std::error_code lost_connect_error_code (1, std::system_category()); run_callback(lost_connect_error_code); m_service_list.remove(i); } else { callback_function_handler run_callback(job_work->getCallback()); std::error_code success_code (0, std::generic_category()); run_callback(success_code); m_service_list.remove(i); } } else if (job_work->getServiceType() == SERVICE_TYPE_CONNECT_TELNET) { // Get host and port from string. // This would better as a vector<std::string> for the sequqnce, // More versitile.! std::vector<std::string> ip_address = split(job_work->getStringSequence(), ':'); bool is_success = false; if (ip_address.size() > 1) { is_success = job_work->getSocket()->connectTelnetSocket( ip_address.at(0), std::atoi(ip_address.at(1).c_str()) ); } else { is_success = job_work->getSocket()->connectTelnetSocket( ip_address.at(0), 23 ); } if (is_success) { callback_function_handler run_callback(job_work->getCallback()); std::error_code success_code (0, std::generic_category()); run_callback(success_code); m_service_list.remove(i); } else { // Error - Unable to connect std::cout << "async_connection - unable to connect" << std::endl; job_work->getSocket()->setInactive(); callback_function_handler run_callback(job_work->getCallback()); std::error_code not_connected_error_code (1, std::system_category()); run_callback(not_connected_error_code); m_service_list.remove(i); } } else if (job_work->getServiceType() == SERVICE_TYPE_CONNECT_SSH) { // Get host and port from string. // This would better as a vector<std::string> for the sequqnce, // More versitile.! std::vector<std::string> ip_address = split(job_work->getStringSequence(), ':'); std::cout << "ip_address: " << ip_address.size(); bool is_success = false; if (ip_address.size() >= 4) { std::cout << "1. " << ip_address.at(0) << std::endl; std::cout << "2. " << ip_address.at(1) << std::endl; std::cout << "3. " << ip_address.at(2) << std::endl; std::cout << "4. " << ip_address.at(3) << std::endl; is_success = job_work->getSocket()->connectSshSocket( ip_address.at(0), std::atoi(ip_address.at(1).c_str()), ip_address.at(2), ip_address.at(3) ); } if (is_success) { callback_function_handler run_callback(job_work->getCallback()); std::error_code success_code (0, std::generic_category()); run_callback(success_code); m_service_list.remove(i); } else { // Error - Unable to connect std::cout << "async_connection - unable to connect" << std::endl; job_work->getSocket()->setInactive(); callback_function_handler run_callback(job_work->getCallback()); std::error_code not_connected_error_code (1, std::system_category()); run_callback(not_connected_error_code); m_service_list.remove(i); } } // SERVICE_TYPE_CONNECT_IRC else if (job_work->getServiceType() == SERVICE_TYPE_CONNECT_IRC) { // Get host and port from string. // This would better as a vector<std::string> for the sequqnce, // More versitile.! std::vector<std::string> ip_address = split(job_work->getStringSequence(), ':'); bool is_success = false; if (ip_address.size() > 1) { is_success = job_work->getSocket()->connectIrcSocket( ip_address.at(0), std::atoi(ip_address.at(1).c_str()) ); } else { is_success = job_work->getSocket()->connectIrcSocket( ip_address.at(0), 6667 ); } if (is_success) { // Send Initial Connection Information std::string nick = "mercyful1"; std::string ident = "mercyful1"; std::string read_name = "michael"; std::string host = "localhost"; std::stringstream ss; ss << "NICK " << nick << "\r\n" << "USER " << ident << " " << host << " bla : " << read_name << "\r\n"; std::string output = ss.str(); job_work->getSocket()->sendSocket((unsigned char *)output.c_str(), output.size()); callback_function_handler run_callback(job_work->getCallback()); std::error_code success_code (0, std::generic_category()); run_callback(success_code); m_service_list.remove(i); } else { // Error - Unable to connect std::cout << "async_connection - unable to connect" << std::endl; job_work->getSocket()->setInactive(); callback_function_handler run_callback(job_work->getCallback()); std::error_code not_connected_error_code (1, std::system_category()); run_callback(not_connected_error_code); m_service_list.remove(i); } } } // Temp timer, change to 10/20 miliseconds for cpu useage std::this_thread::sleep_for(std::chrono::milliseconds(20)); } }
void read_img(image_dict * idict) { char *filepath = NULL; int callback_id; if (img_filename(idict) == NULL) { normal_error("pdf backend","image file name missing"); } callback_id = callback_defined(find_image_file_callback); if (img_filepath(idict) == NULL) { if (callback_id > 0) { /*tex We always callback, also for a mem stream. */ if (run_callback(callback_id, "S->S", img_filename(idict),&filepath)) { if (filepath && (strlen(filepath) > 0)) { img_filepath(idict) = strdup(filepath); } } } if (img_filepath(idict) == NULL && (strstr(img_filename(idict),"data:application/pdf,") != NULL)) { /*tex We need to check here for a pdf memstream. */ img_filepath(idict) = strdup(img_filename(idict)); } else if (callback_id == 0) { /*tex Otherwise we use kpse but only when we don't callback. */ img_filepath(idict) = kpse_find_file(img_filename(idict), kpse_tex_format, true); } if (img_filepath(idict) == NULL) { /*tex In any case we need a name. */ formatted_error("pdf backend","cannot find image file '%s'", img_filename(idict)); } } recorder_record_input(img_filepath(idict)); /*tex A few type checks. */ check_type_by_header(idict); check_type_by_extension(idict); /*tex Now we're ready to read the image. */ switch (img_type(idict)) { case IMG_TYPE_PDFMEMSTREAM: case IMG_TYPE_PDF: read_pdf_info(idict); break; case IMG_TYPE_PNG: read_png_info(idict); break; case IMG_TYPE_JPG: read_jpg_info(idict); break; case IMG_TYPE_JP2: read_jp2_info(idict); break; case IMG_TYPE_JBIG2: read_jbig2_info(idict); break; default: img_type(idict) = IMG_TYPE_NONE; if (pdf_ignore_unknown_images) { normal_warning("pdf backend","internal error: ignoring unknown image type"); } else { normal_error("pdf backend","internal error: unknown image type"); } break; } cur_file_name = NULL; if (img_type(idict) == IMG_TYPE_NONE) { img_state(idict) = DICT_NEW; } else if (img_state(idict) < DICT_FILESCANNED) { img_state(idict) = DICT_FILESCANNED; } }
void fm_read_info () { int callback_id; int file_opened = 0; char *ftemp = NULL; if (tfm_tree == NULL) create_avl_trees (); if (mitem->line == NULL) /* nothing to do */ return; mitem->lineno = 1; switch (mitem->type) { case MAPFILE: set_cur_file_name (mitem->line); if (fm_buffer!=NULL) { xfree(fm_buffer); fm_buffer=NULL; } fm_curbyte=0; fm_size=0; callback_id=callback_defined(find_map_file_callback); if (callback_id>0) { if(run_callback(callback_id,"S->S",(char *)(nameoffile+1),&ftemp)) { if(ftemp!=NULL&&strlen(ftemp)) { free(nameoffile); namelength = strlen(ftemp); nameoffile = xmalloc(namelength+2); strcpy((char *)(nameoffile+1),ftemp); free(ftemp); } } } callback_id=callback_defined(read_map_file_callback); if (callback_id>0) { if(run_callback(callback_id,"S->bSd",(char *)(nameoffile+1), &file_opened, &fm_buffer,&fm_size)) { if(file_opened) { if (fm_size>0) { cur_file_name = (char *) nameoffile + 1; if (tracefilenames) tex_printf ("{%s", cur_file_name); while (!fm_eof ()) { fm_scan_line (); mitem->lineno++; } if (tracefilenames) tex_printf ("}"); fm_file = NULL; } } else { pdftex_warn ("cannot open font map file"); } } else { pdftex_warn ("cannot open font map file"); } } else { if (!fm_open ()) { pdftex_warn ("cannot open font map file"); } else { fm_read_file(); cur_file_name = (char *) nameoffile + 1; tex_printf ("{%s", cur_file_name); while (!fm_eof ()) { fm_scan_line (); mitem->lineno++; } fm_close (); tex_printf ("}"); fm_file = NULL; } } break; case MAPLINE: cur_file_name = NULL; /* makes pdftex_warn() shorter */ fm_scan_line (); break; default: assert (0); } mitem->line = NULL; /* done with this line */ cur_file_name = NULL; return; }