Esempio n. 1
0
int main(int argc, char **argv)
{
	int i;

	if (argc < 4)
	{
		printf(usage);
		return -1;
	}

	in_file_count = argc - 2;
	if (in_file_count > MAX_FILES)
	{
		printf("文件太多,最多32个!\n");
		return -1;
	}

	for (i = 0; i < in_file_count; i++)
		in_file_name[i] = argv[1 + i];

	out_file_name = argv[argc - 1];

	if (!open_all())
		return -1;

	process();

	printf("\n");

	close_all();
	return 0;
}
Esempio n. 2
0
  void Lua::setup(std::string filename){

#ifdef linux
    lua_std_in = fdopen(dup(STDIN_FILENO), "r");
    lua_std_out = fdopen(dup(STDOUT_FILENO), "a");
    lua_std_err = fdopen(dup(STDERR_FILENO), "a");

    fprintf(lua_std_err,"-- Loading Lua libs\n");
#else
    printf("-- Loading Lua libs\n");
#endif
    luaL_openlibs(L);

    open_all();
    if(lua_cpcall(L,init_callback_table,0) != 0) {
      lua_error(L);
    }

    lua_register(L, "add_ins_callback", add_ins_call);

#ifdef linux
    fprintf(lua_std_err,"-- Loading file: %s \n",filename.c_str());
#else
    printf("-- Loading file: %s \n",filename.c_str());
#endif

    lua_getglobal(L, "debug"); //addes debug backtrace as formater for errors
    lua_getfield(L, -1, "traceback");
    int s = luaL_loadfile(L, filename.c_str());
    if ( s==0 ) {
      s = lua_pcall(L, 0, LUA_MULTRET, -2); // LAST 0 is the traceback
    }
    report_errors(s);
    std::cerr << std::endl;
  }
Esempio n. 3
0
vector<string> StreamSorter<Message>::streaming_merge(const vector<string>& temp_files_in, unordered_map<string, size_t>* messages_per_file) {
    
    // What are the names of the merged files we create?
    vector<string> temp_files_out;
    
    // We don't do this loop in parallel because the point of looping is to limit the total currently open files.
    for (size_t start_file = 0; start_file < temp_files_in.size(); start_file += max_fan_in) {
        // For each range of sufficiently few files, starting at start_file and running for file_count
        size_t file_count = min(max_fan_in, temp_files_in.size() - start_file);
    
        // Open up cursors into all the files.
        list<ifstream> temp_ifstreams;
        list<cursor_t> temp_cursors;
        open_all(vector<string>(&temp_files_out[start_file], &temp_files_out[start_file + file_count]), temp_ifstreams, temp_cursors);
        
        // Work out how many messages to expect
        size_t expected_messages = 0;
        if (messages_per_file != nullptr) {
            for (size_t i = start_file; i < start_file + file_count; i++) {
                expected_messages += messages_per_file->at(temp_files_in.at(i));
            }
        }
        
        // Open an output file
        string out_file_name = temp_file::create();
        ofstream out_stream(out_file_name);
        temp_files_out.push_back(out_file_name);
        
        // Make an output emitter
        emitter_t emitter(out_stream);
        
        // Merge the cursors into the emitter
        streaming_merge(temp_cursors, emitter, expected_messages);
        
        // The output file will be flushed and finished automatically when the emitter goes away.
        
        // Clean up the input files we used
        temp_cursors.clear();
        temp_ifstreams.clear();
        for (size_t i = start_file; i < file_count; i++) {
            temp_file::remove(temp_files_in.at(i));
        }
        
        if (messages_per_file != nullptr) {
            // Save the total messages that should be in the created file, in case we need to do another pass
            (*messages_per_file)[out_file_name] = expected_messages;
        }
    }
    
    return temp_files_out;
        
}
Esempio n. 4
0
main()
{
  putenv("_=productivity");
  chdir(getenv("HOME"));
  
  getparms(0);
  
  open_all();

  while(1)
  {
    prompt();                             /* get parameters                  */

    if (!store_all()) continue;           /* get all data                    */

    print_prompt();                       /* show or print data              */
  }
}                                         /*end of main                      */
Esempio n. 5
0
main()
{
  register struct oi_item *o;
  register struct zone_item *z;
  register struct bay_item  *b;
  register struct hw_item   *h;
  register struct pw_item   *p;
  
  extern leave();

  open_all();                             /*open all files                   */

  for(i = 0;i < NUM_PROMPTS;i++)          /*clear the buffers                */
  for(j = 0;j < BUF_SIZE;j++)
  buf[i][j] = 0;

  fix(zero_counts);
  sd_screen_off();
  sd_clear_screen();
  sd_text(zero_counts);
  sd_screen_on();
  
  while(1)
  {
    t = sd_input(&fld[0],sd_prompt(&fld[0],0),&rm,buf[0],0);
    if(t == EXIT) leave();
   
    if(code_to_caps(*buf[0]) == 'y')      /* zero the shorts counts          */
    {
      sp->sp_sh_printed = 0;
      sp->sp_sh_count = 0;
      sp->sp_rs_printed = 0;
      sp->sp_rs_count = 0;
      sp->sp_tl_printed = 0;
      sp->sp_tl_count = 0;
      sp->sp_sl_printed = 0;
      sp->sp_sl_count = 0;
      sp->sp_pl_printed = 0;
      sp->sp_pl_count = 0;
      sp->sp_bpl_printed = 0;
      sp->sp_bpl_count = 0;
      
      sp->sp_pl_order = 0;
      sp->sp_pl_print = 0;
      sp->sp_sl_order = 0;
      sp->sp_sl_print = 0;
      sp->sp_tl_order = 0;
      sp->sp_tl_print = 0;

      eh_post(ERR_CONFIRM,"Zero Counts");
      break;
    }
    else if(code_to_caps(*buf[0]) == 'n') break;

    else
    {
      eh_post(ERR_YN,0);
    }
  }
  if(sp->sp_config_status != 'y') leave();
    
  while(1)
  {
    while (1)
    {
      t = sd_input(&fld[1],sd_prompt(&fld[1],0),&rm,buf[1],0);
      if(t == EXIT) leave();
   
      if(code_to_caps(*buf[1]) == 'n' || code_to_caps(*buf[1]) == 'y') break;
 
      eh_post(ERR_YN,0);
    }
    while (1)
    {
      t = sd_input(&fld[2],sd_prompt(&fld[2],0),&rm,buf[2],0);
      if(t == EXIT) leave();
 
      if(code_to_caps(*buf[2]) == 'n' || code_to_caps(*buf[2]) == 'y') break;
 
      eh_post(ERR_YN,0);
    }
    if (code_to_caps(*buf[1]) == 'n' && code_to_caps(*buf[2]) == 'n') leave();

    if(IS_ONE_PICKLINE) pickline = op_pl;
    else
    {
      if(SUPER_OP) pickline_prompt();
      else pickline = op_pl;
    }
    if (pickline == 0 && code_to_caps(*buf[1]) == 'y')
    {
      for (i = 0; i < coh->co_pl_cnt; i++) /*for all picklines               */
      {
        pl[i].pl_complete = 0;
      }
      for (i = 0; i < coh->co_zone_cnt; i++)
      {
        zone[i].zt_count = 0;
      }
      eh_post(ERR_CONFIRM,"Zero counts");
    }
    else if (code_to_caps(*buf[1]) == 'y')
    {
      pl[pickline - 1].pl_complete = 0;

      for (i = 0; i < coh->co_zone_cnt; i++)
      {
        if (pickline == zone[i].zt_pl) zone[i].zt_count = 0;
      }
      eh_post(ERR_CONFIRM,"Zero counts");
    }
    if (code_to_caps(*buf[2]) == 'y')
    {
      sd_wait();
      
      for (i = 0; i < coh->co_pl_cnt; i++)
      {
        if (pickline && pl[i].pl_pl != pickline) continue;

        pl[i].pl_lines_to_go = 0;
        pl[i].pl_units_to_go = 0;
      }
      for (j = 0, p = pw; j < coh->co_prod_cnt; j++, p++)
      {
        h = &hw[p->pw_ptr - 1];
        if (h->hw_bay)
        {
          b = &bay[h->hw_bay - 1];
          if (b->bay_zone)
          {
            z = &zone[b->bay_zone - 1];
         
            if (pickline && z->zt_pl != pickline) continue;
            
            p->pw_units_to_go = 0;
            p->pw_lines_to_go = 0;
          }
        }
      }
      for (i = 0, o = oc->oi_tab; i < oc->of_size; i++, o++)
      {
        if (!o->oi_pl || !o->oi_on) continue;

        if (pickline && o->oi_pl != pickline) continue;
        if (o->oi_queue == OC_COMPLETE) continue;
        
        op_rec->pi_pl  = o->oi_pl;
        op_rec->pi_on  = o->oi_on;
        op_rec->pi_mod = 1;
        pick_startkey(op_rec);
      
        op_rec->pi_mod = coh->co_prod_cnt;
        pick_stopkey(op_rec);

        begin_work();
        while (!pick_next(op_rec, NOLOCK))
        {
          if (op_rec->pi_flags & PICKED)  continue;
          if (op_rec->pi_flags & NO_PICK) continue;
        
          pl[op_rec->pi_pl - 1].pl_units_to_go += op_rec->pi_ordered;
          pl[op_rec->pi_pl - 1].pl_lines_to_go += 1;
          
          pw[op_rec->pi_mod - 1].pw_units_to_go += op_rec->pi_ordered;
          pw[op_rec->pi_mod - 1].pw_lines_to_go += 1;
        }
        commit_work();
      }
      eh_post(ERR_CONFIRM, "Zero Remaining:");
    }
    if (SUPER_OP && pickline != 0 && (!(IS_ONE_PICKLINE)))
    {
      sd_cursor(0,9,1);
      sd_clear_line();
      sd_cursor(0,10,1);
      sd_clear_line();
      continue;
    }
    leave();
  }
}
Esempio n. 6
0
void StreamSorter<Message>::stream_sort(istream& stream_in, ostream& stream_out, StreamIndex<Message>* index_to) {

    // We want to work out the file size, if we can.
    size_t file_size = 0;
    {
        // Save our position
        auto here = stream_in.tellg();
        // Go to the end
        stream_in.seekg(0, stream_in.end);
        // Get its position
        auto there = stream_in.tellg();
        // Go back to where we were
        stream_in.seekg(here);
            
        if (stream_in.good()) {
            // We can seek in this stream. So how far until the end?
            file_size = there - here;
        } else {
            // It's entirely possible that none of that worked. So clear the error flags and leave the size at 0.
            stream_in.clear();
        }
    }
    
    
    // Don't give an actual 0 to the progress code or it will NaN
    create_progress("break into sorted chunks", file_size == 0 ? 1 : file_size);

    // Eventually we put sorted chunks of data in temp files and put their names here
    vector<string> outstanding_temp_files;
    
    // This tracks the number of messages in each file, by file name
    unordered_map<string, size_t> messages_per_file;
    // This tracks the total messages observed on input
    size_t total_messages_read = 0;
    
    // This cursor will read in the input file.
    cursor_t input_cursor(stream_in);
    
    #pragma omp parallel shared(stream_in, input_cursor, outstanding_temp_files, messages_per_file, total_messages_read)
    {
    
        while(true) {
    
            vector<Message> thread_buffer;
        
            #pragma omp critical (input_cursor)
            {
                // Each thread fights for the file and the winner takes some data
                size_t buffered_message_bytes = 0;
                while (input_cursor.has_next() && buffered_message_bytes < max_buf_size) {
                    // Until we run out of input messages or space, buffer each, recording its size.
                    thread_buffer.emplace_back(std::move(input_cursor.take()));
                    buffered_message_bytes += thread_buffer.back().ByteSizeLong();
                }
            
                // Update the progress bar
                update_progress(stream_in.tellg());
            }
            
            if (thread_buffer.empty()) {
                // No data was found
                break;
            }
            
            // Do a sort of the data we grabbed
            this->sort(thread_buffer);
            
            // Save it to a temp file.
            string temp_name = temp_file::create();
            ofstream temp_stream(temp_name);
            // OK to save as one massive group here.
            // TODO: This write could also be in a thread.
            stream::write_buffered(temp_stream, thread_buffer, 0);
            
            #pragma omp critical (outstanding_temp_files)
            {
                // Remember the temp file name
                outstanding_temp_files.push_back(temp_name);
                // Remember the messages in the file, for progress purposes
                messages_per_file[temp_name] = thread_buffer.size();
                // Remember how many messages we found in the total
                total_messages_read += thread_buffer.size();
            }
        }
    }
    
    // Now we know the reader thmessages have taken care of the input, and all the data is in temp files.
    
    destroy_progress();
    
    while (outstanding_temp_files.size() > max_fan_in) {
        // We can't merge them all at once, so merge subsets of them.
        outstanding_temp_files = streaming_merge(outstanding_temp_files, &messages_per_file);
    }
    
    // Now we can merge (and maybe index) the final layer of the tree.
    
    // Open up cursors into all the files.
    list<ifstream> temp_ifstreams;
    list<cursor_t> temp_cursors;
    open_all(outstanding_temp_files, temp_ifstreams, temp_cursors);
    
    // Maintain our own group buffer at a higher scope than the emitter.
    vector<Message> group_buffer;
    {
        // Make an output emitter
        emitter_t emitter(stream_out);
        
        if (index_to != nullptr) {
            emitter.on_message([&index_to,&group_buffer](const Message& m) {
                // Copy every message that is emitted.
                // TODO: Just compute indexing stats instead.
                group_buffer.push_back(m);
            });
        
            emitter.on_group([&index_to,&group_buffer](int64_t start_vo, int64_t past_end_vo) {
                // On every group, tell the index to record the group stats, and clear the buffer.
                index_to->add_group(group_buffer, start_vo, past_end_vo);
                group_buffer.clear();
            });
        }
    
        // Merge the cursors into the emitter
        streaming_merge(temp_cursors, emitter, total_messages_read);
        
    }
    
    // Clean up
    temp_cursors.clear();
    temp_ifstreams.clear();
    for (auto& filename : outstanding_temp_files) {
        temp_file::remove(filename);
    }
            
}
Esempio n. 7
0
main()
{
  short i;
  unsigned char t;
  int index = 0;

  putenv("_=picker_zero_counts");
  chdir(getenv("HOME"));
  
  /*
  ** do setup and create the data on the screen
  */
  open_all();

  sd_screen_off();
  fix(picker_zero_counts);
  sd_clear_screen();
  sd_text(picker_zero_counts);
  sd_screen_on();
  
/*
 ** show and process the menu
 */
  sd_prompt(&fld[CURRENT], rm);

  while(1)
  {
    /*
    ** get user input until user presses RETURN on last field
    ** (or presses EXIT at any time)
    */
    t = sd_input(&fld[index],rm,&rm,buffers[index],0);

    switch (t) {
      case EXIT:
        leave();
      case UP_CURSOR:
        if (index > 0) index--;
        continue;
      case DOWN_CURSOR:
      case TAB:
        if (index < LAST)
          index++;
        else
          index = 0;
        continue;
      case RETURN:
        if (index < LAST)
        {
          index++;
          continue;
        }
    }

    /*
    ** now check out all the given information and verify it as ok 
    */
    if (buffers[CURRENT][0] == '\0')
    {
      eh_post(ERR_YN, 0);
      continue;
    }
    if ((buffers[CURRENT][0] != '\0')
        && (code_to_caps(buffers[CURRENT][0]) != 'n')
        && (code_to_caps(buffers[CURRENT][0]) != 'y'))
    {
      eh_post(ERR_YN, "");
      index = CURRENT;
      continue;
    }
    
    /*
    ** all ok, so perform the desired action
    */
    if (code_to_caps(buffers[CURRENT][0]) == 'y') zero_current();
    else leave();

    /*
    ** now clear the input fields and loop again, getting more user input
    */
    index = CURRENT;
    buffers[CURRENT][0] = '\0';
    sd_prompt(&fld[CURRENT], rm);
  }
}
Esempio n. 8
0
main()
{
  register long k;
  unsigned char t, incode[2], ans[2], yn[2], again[2];
  unsigned char timestr[30], datetime[15], intime[20];
  long systime;
  long pid, status;

  putenv("_=transac_output");
  chdir(getenv("HOME"));

  open_all();

  fix(transac_output);
  sd_screen_off();
  sd_clear_screen();
  sd_text(transac_output);
  sd_screen_on();
  
  sd_prompt(&fld[0], 0);

  while(1)
  {
    for (k = 15; k <= 20; k++)
    {
      sd_cursor(0, k, 1);
      sd_clear_line();
    }
    while(1)
    {
      memset(incode, 0, 2);

      t = sd_input(&fld[0], 0, 0, incode, 0);
      if(t == EXIT)      leave();
      if(t == UP_CURSOR) continue;

      if (!*incode) break;

      *incode = tolower(*incode);
        
      if (*incode != 'c' && *incode != 'd' &&
          *incode != 'p' && *incode != 'e')
      {
        eh_post(ERR_CODE, incode);
        continue;
      }
      break;
    }
    if (*incode == 'p')
    {
      if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b')
      {
        eh_post(LOCAL_MSG, "No Transaction File Feature");
        continue;
      }
      sd_wait();
      
      if((pid = fork()) == 0)
      {
        ss_close();
        execlp("transac_short_rpt", "transac_short_rpt", 0);
        exit(1);
      }
      else pid = wait(&status);

      if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Short Printing");
      else eh_post(CRASH_MSG, "tranac_short_rpt failed");
      continue;
    }
    if (*incode == 'e')
    {
      if (sp->sp_to_flag != 'y' && sp->sp_to_flag != 'b')
      {
        eh_post(LOCAL_MSG, "No Transaction File Feature");
        continue;
      }
      while(1)
      {
        memset(ans, 0, 2);                /* are you sure response           */
        memset(yn, 0, 2);
        
        t = sd_input(&fld[5],sd_prompt(&fld[5],0), 0, yn, 0);
        if (t == EXIT)      leave();
        if (t == UP_CURSOR) break;

        *ans = code_to_caps(*yn);

        if(*ans != 'y' && *ans != 'n')
        {
          eh_post(ERR_YN,0);
          continue;
        }
        if(*ans == 'y')
        {
          eh_post(LOCAL_MSG, "Purging Transaction File");

          database_open();
          xt_open();
          transaction_setkey(0);
          
          begin_work();
          while (!transaction_next(&xt, LOCK)) 
          {
            transaction_delete();
            commit_work();
            begin_work();
          }
          commit_work();
          xt_close();
          database_close();
          
          sp->sp_to_count = 0;
          
          eh_post(PURGE_TRANS, 0);
        }
        break;
      }                                   /* end while(1)                    */
      continue;
    }                                     /* end if                          */
    if (*incode == 'c' || *incode == 'd')
    {
      if (sp->sp_to_mode != 0x20 || sp->sp_oi_mode == *incode) /* F071395    */
      {
        eh_post(LOCAL_MSG, "Device/Port In Use");          
        continue;
      }
    }
    if (*incode == 'd')
    {
      while(1)
      {
        memset(ans, 0, 2);
        memset(yn, 0, 2);
        
        t = sd_input(&fld[1],sd_prompt(&fld[1],0), 0, yn, 0);
        if (t == EXIT)     leave();
        if (t == UP_CURSOR) break;

        *ans = code_to_caps(*yn);
        
        if(*ans != 'y' && *ans != 'n')
        {
          eh_post(ERR_YN,0);
          continue;
        }
        break;
      }
      if (t == UP_CURSOR) continue;
      if (*ans == 'n') continue;          /* abort diskette in               */
    }
    while(1)
    {
      memset(again, 0, 2);                /* retransmit response             */
      memset(yn, 0, 2);
      
      t = sd_input(&fld[2],sd_prompt(&fld[2],0), 0, yn, 0);
      if (t == EXIT)     leave();
      if (t == UP_CURSOR) break;

      *again = code_to_caps(*yn);
      if (*again != 'y' && *again != 'n')
      {
        eh_post(ERR_YN, 0);
        continue;
      }
      break;
    }
    if (t == UP_CURSOR) continue;

    while(1)
    {
      memset(ans, 0, 2);                  /* purge response                  */
      memset(yn, 0, 2);
      
      t = sd_input(&fld[3],sd_prompt(&fld[3],0), 0, yn, 0);
      if(t == EXIT)      leave();
      if(t == UP_CURSOR) break;

      *ans = code_to_caps(*yn);
      if(*ans != 'y' && *ans != 'n')
      {
        eh_post(ERR_YN,0);
        continue;
      }
      break;
    }
    if(*ans == 'y')
    {
      sd_prompt(&fld[4],0);
      systime = time(0) - sp->sp_purge_window;
      strcpy(timestr, ctime(&systime));
      timestr[24] = 0;
      sd_cursor(0,18,25);
      sd_text("Default Date/Time:");
      sd_cursor(0,18,54);
      sd_text(&timestr[4]);
      sd_cursor(0,20,25);
      sd_text("Format is:");
      sd_cursor(0,20,54);
      sd_text("mm/dd/yyyy hh:mm:ss");

      while(1)
      {
        t = sd_input(&fld[4], 0, 0, intime, 0);
        if(t == EXIT)      leave();
        if(t == UP_CURSOR) break;

        if(*intime != 0)
        {
          if(!time_convert(intime, &systime))
          {
            eh_post(ERR_TIME, intime);
            continue;
          }
        }
        eh_post(LOCAL_MSG, "Purging Orders");

        if ((pid = fork()) == 0)
        {
          sprintf(datetime, "%d", systime);
          ss_close();
          execlp("order_purge", "order_purge", datetime, 0);
          exit(1);
        }
        else pid = wait(&status);

        if (pid > 0 && !status) eh_post(ERR_CONFIRM, "Order purge");
        else eh_post(CRASH_MSG, "order_purge failed");
        break;
      }
      if (t == UP_CURSOR) continue;
    }
    if (*again == 'n')                    /* transmit current file           */
    {
      eh_post(LOCAL_MSG, "Extracting Transactions");

      if ((pid = fork()) == 0)
      {
        ss_close();
        execlp("transac_copy", "transac_copy", 0);
        exit(1);
      }
      else pid = wait(&status);

      if (pid < 0 || status)
      {
        eh_post(LOCAL_MSG, "transac_copy failed");
        continue;
      }
      eh_post(ERR_CONFIRM, "Transaction File");
    }
/*
 *  Start Transaction Output Operations
 */
    if (*incode == 'c')                   /* comm output                     */
    {
      if (sp->sp_commo_trans_out == 'n')
      {
        eh_post(LOCAL_MSG, "No Communication Feature");
        continue;
      }
      eh_post(LOCAL_MSG, "Sending Transactions");
      sd_close();

      sp->sp_to_mode = 'c';
      
      if (fork() == 0)
      {
        if (sp->sp_commo_trans_out == 'k') 
        {
          ss_close();
          execlp("com_kermit_out", "com_kermit_out", 0);
        }
        else 
        {
          ss_close();
          execlp("comsend",  "comsend",  0);
        }
        ss_open();
        sd_open();
        sp->sp_to_mode = 0x20;
        eh_post(LOCAL_MSG, "Program Not Found");
        continue;
      }
      pid = wait(&status);
      sp->sp_to_mode = 0x20;
      sd_open();
      
      if (pid < 0 || status) 
      {
        eh_post(LOCAL_MSG, "Communications Failed");
      }
      else eh_post(ERR_CONFIRM, "Transactions Output");
      continue;
    }
    if (*incode == 'd')
    {
      sd_wait();

      sp->sp_to_mode = 'd';

      sprintf(message, command);
      status = system(message);
      sp->sp_to_mode = 0x20;
      
      if (status) eh_post(LOCAL_MSG, "Diskette output failed");
      else eh_post(ERR_CONFIRM, "Tranaction Output");
    }
  }
}
Esempio n. 9
0
main()
{
  unsigned char t;
  
  putenv("_=pff_inquiry_input");
  chdir(getenv("HOME"));
  
  open_all();                             /* open ss, eh, co                 */

  /* initialize and show screen display */

  fix(pff_inquiry_input);
  sd_screen_off();
  sd_clear_screen();                      /* clear entire screen             */
  sd_text(pff_inquiry_input);
  sd_screen_on();
  
  sd_cursor(0, 6, 10);
  sd_text("F = Family Group                       L = CAPS Stock Location");
  sd_cursor(0, 7, 10);
  sd_text("P = Pick Module Number                 S = SKU");

  while(1)
  {
    memset(buf, 0, NUM_PROMPTS * BUF_SIZE); /* clear buffers                 */

    get_parms();                            /* get all parmeters             */

    sd_prompt(&fld[4], 0);
    memset(yn0, 0, 2);
    
    while(1)
    {
      t = sd_input(&fld[4], 0, 0, yn0, 0);
      if (t == EXIT) leave();
      
      *buf[4] = code_to_caps(*yn0);

      if (*buf[4] == 'y')
      {
        sd_wait();
        close_all();
        execlp("pff_inquiry_create", "pff_inquiry_create",
                buf[0], buf[1], sort_buf, rng_buf[0], rng_buf[1],
                "", "print", 0);

        krash("main", "pff_inquiry_create load", 1);
      }
      else if (*buf[4] == 'n')
      {
        sd_wait();
        close_all();
        execlp("pff_inquiry_create","pff_inquiry_create",
                buf[0], buf[1], sort_buf, rng_buf[0], rng_buf[1],
                "", "report", 0);

        krash("main", "pff_inquiry_create load", 1);
      }
      eh_post(ERR_YN,0);
    }
  }
}
Esempio n. 10
0
main()
{
  long pid, status;
  short rm,ret,i,si,n;
  unsigned char t;
  char buf[NUM_PROMPTS][BUF_SIZE];
  long order_num=0;
  short pickline;
  short all_pl=0;

  putenv("_=stockout_input");
  chdir(getenv("HOME"));
  
  open_all();

        /* set order length into fld_parms structure */

  LORDER = rf->rf_on;

        /* determine operator status */

  rm = 0; si = 1;
  if (SUPER_OP && !IS_ONE_PICKLINE) {rm = 1; si = 0;}
  pickline = op_pl;
  sprintf(buf[0], "%d", pickline);
  
  fix(stockout_input);
  sd_clear_screen();
  sd_screen_off();
  sd_text(stockout_input);
  sd_screen_on();

  for(i=0;i<NUM_PROMPTS;i++)
  for(n=0;n<BUF_SIZE;n++)
  buf[i][n] = 0;

  for(i = si; i < LAST_PROMPT; i++)
  sd_prompt(&fld[i],rm);                  /* display prompts                 */
  i = si;


        /* main loop to gather input */

  while(1)
  {
    t = sd_input(&fld[i],rm,&rm,buf[i],0);

    if(t == EXIT) leave();
    else if(t == UP_CURSOR && i > si) i--;
    
    else if(t == DOWN_CURSOR || t == TAB)
    {
      if(i == (LAST_PROMPT - 1)) i = 0;
      else i++;
    }
    else if (t == RETURN)
    {
                        /* validate proper pickline */

      if (si == 0)                        /* have pickline input             */
      {
        n = pl_lookup(buf[0], pickline);  /* numeric of pickline             */

        if (n <= 0)          
        {
          eh_post(ERR_CODE,buf[0]);       /* invalid pickline                */
          i=0;
          continue;
        }
        pickline = n;
        sprintf(buf[0], "%d", pickline);
        chng_pkln(buf[0]);
      }          
                        /* validate entered order number */

      if(!(*buf[1]) && !(*buf[2]))        /* nothing entered                 */
      {
        eh_post(ERR_REQ_ORDER, 0);
        i=1;
        continue;
      }
      if(*buf[2])                         /* if order number entered         */
      {
        order_num=atol(buf[2]);
        ret = oc_find(pickline, order_num);
        if(!ret)
        {
          eh_post(ERR_ORDER,buf[2]);
          i=2;
          continue;
        }
      }
      break;
    }
  }

        /* process print request */

  for(i=1;i<3;i++)                        /* fill non-entered with zero      */
  {
    if(*buf[i])
    ;
    else
    strcpy(buf[i],"0");
  }

  sd_prompt(&fld[4],rm);
  while(1)
  {
    t = sd_input(&fld[4],rm,&rm,buf[4],0);
    switch(sd_early(t, code_to_caps(*buf[4]))) /* F041897 */
    {
      case (0):
        leave();

      case (4):                           /* print == y                      */
        if(!(*buf[0]))                    /* no pickline entered             */
        {
          strcpy(buf[0], getenv("PICKLINE"));/* set current                  */
        }
        sd_wait();
        close_all();
        execlp("stockout_create", "stockout_create",
          buf[0], buf[1], buf[2], "", "print",  0);

        krash("main", "stockout_create load", 1);

      case (5):                           /* print == n                      */
        
        sd_wait();
        if(!(*buf[0]))                    /* no pickline entered             */
        {
          strcpy(buf[0], getenv("PICKLINE"));/* set current                  */
        }
        close_all();
        execlp("stockout_create", "stockout_create",
          buf[0], buf[1], buf[2], "", "report",  0);

        krash("main", "stockout_create load", 1);

      case (6):
        eh_post(ERR_YN,0);
        break;
      }
  }
}
Esempio n. 11
0
main()
{
  short rm;
  short ret;
  unsigned char t;
  char buf[NUM_PROMPTS][BUF_SIZE];        /* array of buffers                */

  short i;
  short n;

  putenv("_=printer_control");
  chdir(getenv("HOME"));

  open_all();

  while(1)                                /* begin massive loop              */
  {
    fix(berkeley_control);
    sd_screen_off();
    sd_clear_screen();                    /* clear screen                    */
    sd_text(berkeley_control);
    sd_screen_on();

                /* clear input buffers */

    for(i = 0; i < NUM_PROMPTS; i++)
    for(n = 0; n < BUF_SIZE; n++)
    buf[i][n] = 0;


                /* main loop to get code */

    while(1)
    {
      t = sd_input(&fld[0],sd_prompt(&fld[0],0),&rm,buf[0],0);

      if (t == EXIT) leave();
      if (t == UP_CURSOR) continue;

      *buf[0] = tolower(*buf[0]);      
      
      if (*buf[0] == 'a' || *buf[0] == 'c' || 
          *buf[0] == 'k' || *buf[0] == 's' || 
          *buf[0] == 'r' || *buf[0] == 'd')  break;
      
      eh_post(ERR_CODE, buf[0]);
    }
    if (*buf[0] == 'c')
    {
      t = sd_input(&fld1, sd_prompt(&fld1, 0), 0, op_printer, 0);
      if (t == EXIT) leave();
      if (t == UP_CURSOR) continue;
      
      message_put(sd_server, ChangePrinterEvent, op_printer, 
        strlen(op_printer));

      sprintf(printer, "PRINTER=%s", op_printer);
      putenv(printer);
      continue;
    }
                /* code entered. display second prompt */

    if(buf[0][0] != 'd')                  /* not display                     */
    {
      while (*buf[0] == 'k')
      {
        sd_prompt(&fld[1],0);
        t = sd_input(&fld[1],0,&rm,buf[1],0);
        if(t == EXIT) leave();
        else if(t == RETURN) break;
      }
      switch(buf[0][0])    
      {
        case 'a':                         /* abort current print job         */
        
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "cancel %s", op_printer);
          system(command);
          sleep(2);
          break;

        case 'k':                         /* kill print file                 */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "cancel %s-%s", op_printer, buf[1]);
          system(command);
          sleep(2);
          break;
          
        case 's':                         /* stop print file                 */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "disable %s", op_printer);
          system(command);
          sleep(2);
          break;
          
        case 'r':                         /* restart printing                */
          
          sd_wait();
          sd_cursor(0, 18, 27);
          sd_text(".");
          sprintf(command, "enable %s", op_printer);
          system(command);
          sleep(2);
          break;
      }
      continue;
    }
    else                                  /* display request                 */
    {
      sd_cursor(0,16,2);
      sd_text("Job ID                  Operator          Size   Date");
    }
/*
 *  Get Printer Queue Data
 */
    tmp_name(tname);                      /* get temp name                   */
    sprintf(command, "lpstat -o %s >%s", op_printer, tname);
    system(command);

    t_fd = fopen(tname, "r");
    if (t_fd == 0) continue;              /* open failed                     */
    
    memset(x, 0, sizeof(x));
    
    for (max = 0; max < 25; max++)
    {
      if (!fgets(x[max], 80, t_fd)) break;
      n = strlen(x[max]) - 1;
      x[max][n] = 0;
    }
    n = 0;

    fclose(t_fd);
    unlink(tname);

    while(1)
    {
      sd_cursor(0, 17, 1);
      sd_clear_rest();

      for (i = 0; i < 5 && n + i < max; i++)
      {
        sd_cursor(0, 17 + i, 2);
        sd_text(x[i + n]);
      }
      sd_cursor(0,23,23);
      sd_text("(Exit, Forward, or Backward)");
      sd_prompt(&fld[2],0);

      t = sd_input(&fld[2],0,&rm,buf[2],0);

      ret = sd_more(t, code_to_caps(buf[2][0]));  /* F041897 */
                        
      if (ret == 0) leave();               /* exit                           */
      
      else if (ret == 1)                  /* forward                         */
      {
        if (n + 5 < max) n += 5;
      }
      else if (ret == 2)                  /* backward                        */
      {
        if (n > 0) n -= 5;
      }
      else if (ret == 3) break;           /* quit display                    */
    }
  }                                       /* end massive while(1)loop        */

}
Esempio n. 12
0
main()
{
  short rm,ret,i,n;
  unsigned char t;
  char buf[BUF_SIZE];

  putenv("_=delete_pm_screen");
  chdir(getenv("HOME"));

  open_all();
 
        /* set lengths into field structures */

  LMOD = rf->rf_mod;

  fix(delete_pm_screen);
  sd_screen_off();
  sd_clear_screen();                      /* clear screen                    */
  sd_text(delete_pm_screen);
  sd_screen_on();  

  while(1)                                /* begin massive loop              */
  {
                /* clear input buffers */

    memset(buf, 0, BUF_SIZE);

    sd_prompt(&fld,0);

                /* main loop to gather input */

    while(1)
    {
      t = sd_input(&fld,0,&rm,buf,0);

                        /* erase previous SKU */

      sd_cursor(0,7,10);
      sd_clear_rest();

      if (t == EXIT) leave();
      if (sp->sp_running_status == 'y')
      {
        eh_post(ERR_IS_CONFIG, 0);
        continue;
      }
      if (t != RETURN) continue;

      if(!(*buf))                       /* no data entered                 */
      {
        eh_post(ERR_PM_INV,"");
        continue;
      }
      pm.p_pmodno = atol(buf);          /* cnvrt PM to int                 */
        
      begin_work();
      if (!pmfile_read(&pm, LOCK))
      {
        if (pm.p_pmsku[0] > 0x20)
        {
          sd_cursor(0,7,12);
          sd_text("SKU: ");
          sd_text_2(pm.p_pmsku, rf->rf_sku);
          sd_text("   Stkloc: ");
          sd_text_2(pm.p_stkloc, 6);
        
          eh_post(ERR_PM_DEL,0);
          commit_work();
          continue;
        }
        pmfile_delete();
      }
      commit_work();
                                /* everything OK. to delete.  */

      sd_wait();
      
      pm.p_pmodno = atol(buf);
      pmfile_startkey(&pm);
      pm.p_pmodno = 0x7fff;
      pmfile_stopkey(&pm);

      begin_work();
      while (!pmfile_next(&pm, LOCK))
      {
        pm.p_pmodno -= 1;
        pmfile_update(&pm);
        commit_work();
        begin_work();
      }
      commit_work();
      eh_post(ERR_CONFIRM, "Module delete");
    }
  }                                       /* end massive while(1)loop        */
}
Esempio n. 13
0
main()
{
  short rm;
  short ret;
  unsigned char t;
  char buf[4];
  
  putenv("_=pfead_pmfile");
  chdir(getenv("HOME"));
  
  open_all();
  
  fix(pfead_pmfile);
  sd_screen_off();
  sd_clear_screen();
  sd_text(pfead_pmfile);
  sd_screen_on();
  
  while(1)
  {
    memset(buf, 0, sizeof(buf));

    t = sd_input(&fld1,(sd_prompt(&fld1,0)),&rm,buf,0);

    if(t ==  EXIT) leave();
    if(t != RETURN) continue;                  /* invalid keys               */

    *buf = tolower(*buf);
 
    if (!LEGAL(toupper(*buf)))
    {
      eh_post(ERR_CODE, buf);
      continue;
    }
    switch(*buf)
    {
      case 'a':  
        
        loadprog("acd_pm_screen", "assign");
        break;
        
      case 'b':
        
        loadprog("acd_pm_screen", "add");
        break;
        
      case 'c':
        
        loadprog("acd_pm_screen", "change");
        break;
        
      case 'd':
        
        loadprog("acd_pm_screen", "deassign");
        break;

      case 'e':
        
        loadprog("acd_pm_screen", "move");
        break;

      case 'f':
        
        loadprog("ins_pm_screen", 0);
        break;

      case 'g':
        
        loadprog("delete_pm_screen", 0);
        break;

      case 'z':
        
        loadprog("zero_move_counts", 0);
        break;
    
      default:
    
        eh_post(ERR_CODE, buf);
        break;
    }                                      /* end switch                     */
  } 
}
Esempio n. 14
0
main()
{
  short rm;
  short ret;
  unsigned char t;
  char buf[4];
  
  putenv("_=pfead_reports");
  chdir(getenv("HOME"));
  
  open_all();
  
  fix(pfead_reports);
  sd_screen_off();
  sd_clear_screen();
  sd_text(pfead_reports);
  sd_screen_on();
  
  while(1)
  {
    memset(buf, 0, sizeof(buf));

    t = sd_input(&fld1,(sd_prompt(&fld1,0)),&rm,buf,0);

    if(t ==  EXIT) leave();
    if(t != RETURN) continue;                  /* invalid keys               */

    *buf = tolower(*buf);
 
    if (sp->sp_running_status == 'y')
    {
      if (*buf == 'q' || *buf == 'i')
      {
        eh_post(ERR_IS_CONFIG, 0);        /* system is running message       */
      }
    }
    if (sp->sp_config_status != 'y')
    {
      if (*buf == 'a' || *buf == 'm')
      {
        eh_post(ERR_NO_CONFIG, 0);
        continue;
      }
    }
    switch(*buf)
    {
      case 'a':  
        
        loadprog("stockout_input", 0);
        break;

      case 'i':
        
        loadprog("pff_inquiry_input", 0);
        break;

      case 'k':
        
        loadprog("i_o_sku_data", 0);
        break;
       
      case 'l':
        
        loadprog("pick_loc_input", 0);
        break;

      case 'm':
        
        loadprog("item_move_input", 0);
        break;
        
      case 'q':
        
        loadprog("product_file_query", 0);
        break;

      case 'r':
        
        loadprog("restock_rpt_input", 0);
        break;

      case 's':
        
        loadprog("stock_stat_input", 0);
        break;

      case 't':
        
        loadprog("e_d_res_tick_prnt", 0);
        break;

#ifdef DELL        
      case 'b':
      
        loadprog("location_report", 0);
        break;
        
      case 'p':
     
        loadprog("parts_report", 0);
        break;
#endif      

      default:
    
        eh_post(ERR_CODE, buf);
        break;
    }                                      /* end switch                     */
  } 
}