int SubReqCommand::Execute() { Networks networks(*config()->config()); if (!networks.IsInitialized()) { LOG(ERROR) << "Unable to load networks."; return 1; } wwiv::net::NetworkCommandLine net_cmdline(config()->bbsdir(), arg("net").as_int()); if (!net_cmdline.IsInitialized()) { return 1; } auto r = this->remaining(); if (r.size() < 3) { cout << GetUsage(); return 2; } auto net = net_cmdline.network(); string packet_filename = wwiv::net::create_pend(net.dir, false, 'r'); uint16_t main_type = main_type_sub_add_req; auto add_drop = upcase(r.at(0).front()); if (add_drop != 'A') { main_type = main_type_sub_drop_req; } net_header_rec nh = {}; auto host = StringToUnsignedShort(r.at(2)); nh.tosys = static_cast<uint16_t>(host); nh.touser = 1; nh.fromsys = net.sysnum; nh.fromuser = 1; nh.main_type = main_type_sub_add_req; // always use 0 since we use the stype nh.minor_type = 0; nh.list_len = 0; nh.daten = static_cast<uint32_t>(time(nullptr)); nh.method = 0; // This is an alphanumeric sub type. auto subtype = r.at(1); nh.length = subtype.size() + 1; string text = subtype; StringUpperCase(&text); text.push_back('\0'); wwiv::net::Packet packet(nh, {}, text); bool ok = wwiv::net::write_packet(packet_filename, net, packet); if (!ok) { LOG(ERROR) << "Error writing packet: " << packet_filename; return 1; } LOG(INFO) << "Wrote Packet: " << packet_filename; return 0; }
int CVICALLBACK clbCommandNameChanged (int panel, int control, int event, void *callbackData, int eventData1, int eventData2) { int iIndex = giCurrentItemIndex; char szStringValue[LOW_STRING] = {0}; char *pTemp = NULL; switch (event) { case EVENT_COMMIT: bSaveChanges = 1; GetCtrlVal( panel , control , szStringValue ); StringUpperCase (szStringValue); RemoveSurroundingWhiteSpace (szStringValue); do { pTemp = strchr( szStringValue , ' ' ); if ( pTemp == NULL ) break; *pTemp = '_'; }while(1); strcpy( gvtListOfCommands[iIndex].szCommandName , szStringValue ); ReplaceListItem ( panel , PANEL_COMMAND_NAME_LIST , iIndex , szStringValue , iIndex ); if ( iIndex == giNumberOfItems ) { InsertListItem( panel , PANEL_COMMAND_NAME_LIST , -1 , "..." , iIndex ); giNumberOfItems++; } break; } return 0; }
int image_save_header (image_t *image, char *filename, char *varname) { FILE *file = fopen (filename, "w"); char app[256], str[256]="", def_name[64] ; int count = image->size, col=0; unsigned char *dataptr = image->data ; if (file==NULL) return -1 ; /* Author information */ fprintf(file, "/*\n * Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n *\n"); fprintf(file, " * To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n *\n", varname); fprintf(file, " * Where:\t'screen'\tis the pointer to the frame buffer\n"); fprintf(file, " *\t\t'width'\tis the screen width\n"); fprintf(file, " *\t\t'x'\t\tis the horizontal position\n"); fprintf(file, " *\t\t'y'\t\tis the vertical position\n */\n\n"); /* Headers */ fprintf(file, "#include <video_easylogo.h>\n\n"); /* Macros */ strcpy(def_name, varname); StringUpperCase (def_name); fprintf(file, "#define DEF_%s_WIDTH\t\t%d\n", def_name, image->width); fprintf(file, "#define DEF_%s_HEIGHT\t\t%d\n", def_name, image->height); fprintf(file, "#define DEF_%s_PIXELS\t\t%d\n", def_name, image->pixels); fprintf(file, "#define DEF_%s_BPP\t\t%d\n", def_name, image->bpp); fprintf(file, "#define DEF_%s_PIXEL_SIZE\t%d\n", def_name, image->pixel_size); fprintf(file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name, image->size); /* Declaration */ fprintf(file, "unsigned char DEF_%s_DATA[DEF_%s_SIZE] = {\n", def_name, def_name); /* Data */ while(count) switch (col){ case 0: sprintf(str, " 0x%02x", *dataptr++); col++; count-- ; break; case 16: fprintf(file, "%s", str); if (count > 0) fprintf(file,","); fprintf(file, "\n"); col = 0 ; break; default: strcpy(app, str); sprintf(str, "%s, 0x%02x", app, *dataptr++); col++ ; count-- ; break; } if (col) fprintf(file, "%s\n", str); /* End of declaration */ fprintf(file, "};\n\n"); /* Variable */ fprintf(file, "fastimage_t %s = {\n", varname); fprintf(file, " DEF_%s_DATA,\n", def_name); fprintf(file, " DEF_%s_WIDTH,\n", def_name); fprintf(file, " DEF_%s_HEIGHT,\n", def_name); fprintf(file, " DEF_%s_BPP,\n", def_name); fprintf(file, " DEF_%s_PIXEL_SIZE,\n", def_name); fprintf(file, " DEF_%s_SIZE\n};\n", def_name); fclose (file); return 0 ; }
void* DLLEXPORT Equipment_Info ( int hLowLevelHandle , char *pAddress , char **pVendor , char **pSerialNumber , char **pModel , char **pFirmware ) { STD_ERROR StdError = {0}; int iCount = 0, status = 0, //iIndex = 0, //bSupport = 0, defaultRM = 0, hConnectionHandle = 0; char szIdentificationText[LOW_STRING] = {0}, szIdentificationUpperText[LOW_STRING] = {0}, *pTemp = NULL; if ( hLowLevelHandle == 0 ) { viOpenDefaultRM (&defaultRM); SetBreakOnLibraryErrors (0); status = viOpen ( defaultRM , pAddress , NULL, NULL, &hConnectionHandle ); } else { hConnectionHandle = hLowLevelHandle; } if ( status == 0 ) { status = viPrintf ( hConnectionHandle , "*IDN?\n" ); if ( status == 0 ) { viRead ( hConnectionHandle , szIdentificationText , (LOW_STRING-1) , &iCount ); RemoveSurroundingWhiteSpace (szIdentificationText); } } if (( hLowLevelHandle == 0 ) && hConnectionHandle ) viClose(hConnectionHandle); SetBreakOnLibraryErrors (1); do { strcpy( szIdentificationUpperText , szIdentificationText ); StringUpperCase (szIdentificationUpperText); IF ((( strstr( szIdentificationUpperText , "AGILENT TECHNOLOGIES" ) == NULL ) && ( strstr( szIdentificationUpperText ,"HEWLETT-PACKARD") == NULL )) , "Is not supported" ); pTemp = strrchr( szIdentificationText , ',' ); if ( pTemp ) { *pTemp = 0; pTemp++; if ( pFirmware ) { CALLOC_COPY_STRING( *pFirmware , pTemp ); } } else break; pTemp = strrchr( szIdentificationText , ',' ); if ( pTemp ) { *pTemp = 0; pTemp++; if ( pSerialNumber ) { CALLOC_COPY_STRING( *pSerialNumber , pTemp ); } } else break; pTemp = strrchr( szIdentificationText , ',' ); if ( pTemp ) { *pTemp = 0; pTemp++; if ( pModel ) { CALLOC_COPY_STRING( *pModel , pTemp ); } } else break; if ( pVendor ) { CALLOC_COPY_STRING( *pVendor , szIdentificationText ); } } while(0); Error: RETURN_STDERR_POINTER; }
void* DLLEXPORT Equipment_IsSupported ( int hLowLevelHandle , char *pAddress , char *pID_String , char *pIdentificationText , int *pbSupporting , void **pLocalData ) { STD_ERROR StdError = {0}; int iCount = 0, status = 0, bSupport = 0, defaultRM = 0, hConnectionHandle = 0; char szIdentificationText[LOW_STRING] = {0}, szIdentificationUpperText[LOW_STRING] = {0}; if (( pIdentificationText == NULL ) || ( strlen(pIdentificationText) < 10 )) { SetBreakOnLibraryErrors (0); if ( hLowLevelHandle == 0 ) { viOpenDefaultRM (&defaultRM); SetBreakOnLibraryErrors (0); status = viOpen ( defaultRM , pAddress , NULL, NULL, &hConnectionHandle ); } else { hConnectionHandle = hLowLevelHandle; } if ( status == 0 ) { status = viPrintf ( hConnectionHandle , "*IDN?\n" ); if ( status == 0 ) { viRead ( hConnectionHandle , szIdentificationText , (LOW_STRING-1) , &iCount ); RemoveSurroundingWhiteSpace (szIdentificationText); } } if (( hLowLevelHandle == 0 ) && hConnectionHandle ) viClose(hConnectionHandle); SetBreakOnLibraryErrors (1); } else { if ( strlen(pIdentificationText) < LOW_STRING ) strcpy( szIdentificationText , pIdentificationText ); else memcpy( szIdentificationText , pIdentificationText , (LOW_STRING-1) ); } do { strcpy( szIdentificationUpperText , szIdentificationText ); StringUpperCase (szIdentificationUpperText); if (( strstr( szIdentificationUpperText , "AGILENT TECHNOLOGIES" ) == NULL ) && ( strstr( szIdentificationUpperText ,"HEWLETT-PACKARD") == NULL )) break; if ( strstr( szIdentificationText , ",E441" )) { bSupport = 1; break; } }while(0); if (pbSupporting) *pbSupporting = bSupport; RETURN_STDERR_POINTER; }
int image_save_header (image_t * image, char *filename, char *varname) { FILE *file = fopen (filename, "w"); char app[256], str[256] = "", def_name[64]; int count = image->size, col = 0; unsigned char *dataptr = image->data; if (file == NULL) return -1; /* Author information */ fprintf (file, "/*\n * Generated by EasyLogo, (C) 2000 by Paolo Scaffardi\n *\n"); fprintf (file, " * To use this, include it and call: easylogo_plot(screen,&%s, width,x,y)\n *\n", varname); fprintf (file, " * Where:\t'screen'\tis the pointer to the frame buffer\n"); fprintf (file, " *\t\t'width'\tis the screen width\n"); fprintf (file, " *\t\t'x'\t\tis the horizontal position\n"); fprintf (file, " *\t\t'y'\t\tis the vertical position\n */\n\n"); /* gzip compress */ if (use_gzip & 0x1) { const char *errstr = NULL; unsigned char *compressed; struct stat st; FILE *gz; char *gzfilename = xmalloc(strlen (filename) + 20); char *gzcmd = xmalloc(strlen (filename) + 20); sprintf (gzfilename, "%s.gz", filename); sprintf (gzcmd, "gzip > %s", gzfilename); gz = popen (gzcmd, "w"); if (!gz) { errstr = "\nerror: popen() failed"; goto done; } if (fwrite (image->data, image->size, 1, gz) != 1) { errstr = "\nerror: writing data to gzip failed"; goto done; } if (pclose (gz)) { errstr = "\nerror: gzip process failed"; goto done; } gz = fopen (gzfilename, "r"); if (!gz) { errstr = "\nerror: open() on gzip data failed"; goto done; } if (stat (gzfilename, &st)) { errstr = "\nerror: stat() on gzip file failed"; goto done; } compressed = xmalloc (st.st_size); if (fread (compressed, st.st_size, 1, gz) != 1) { errstr = "\nerror: reading gzip data failed"; goto done; } fclose (gz); unlink (gzfilename); dataptr = compressed; count = st.st_size; fprintf (file, "#define EASYLOGO_ENABLE_GZIP %i\n\n", count); if (use_gzip & 0x2) fprintf (file, "static unsigned char EASYLOGO_DECOMP_BUFFER[%i];\n\n", image->size); done: free (gzfilename); free (gzcmd); if (errstr) { perror (errstr); return -1; } } /* Headers */ fprintf (file, "#include <video_easylogo.h>\n\n"); /* Macros */ strcpy (def_name, varname); StringUpperCase (def_name); fprintf (file, "#define DEF_%s_WIDTH\t\t%d\n", def_name, image->width); fprintf (file, "#define DEF_%s_HEIGHT\t\t%d\n", def_name, image->height); fprintf (file, "#define DEF_%s_PIXELS\t\t%d\n", def_name, image->pixels); fprintf (file, "#define DEF_%s_BPP\t\t%d\n", def_name, image->bpp); fprintf (file, "#define DEF_%s_PIXEL_SIZE\t%d\n", def_name, image->pixel_size); fprintf (file, "#define DEF_%s_SIZE\t\t%d\n\n", def_name, image->size); /* Declaration */ fprintf (file, "unsigned char DEF_%s_DATA[] = {\n", def_name); /* Data */ while (count) switch (col) { case 0: sprintf (str, " 0x%02x", *dataptr++); col++; count--; break; case 16: fprintf (file, "%s", str); if (count > 0) fprintf (file, ","); fprintf (file, "\n"); col = 0; break; default: strcpy (app, str); sprintf (str, "%s, 0x%02x", app, *dataptr++); col++; count--; break; } if (col) fprintf (file, "%s\n", str); /* End of declaration */ fprintf (file, "};\n\n"); /* Variable */ fprintf (file, "fastimage_t %s = {\n", varname); fprintf (file, " DEF_%s_DATA,\n", def_name); fprintf (file, " DEF_%s_WIDTH,\n", def_name); fprintf (file, " DEF_%s_HEIGHT,\n", def_name); fprintf (file, " DEF_%s_BPP,\n", def_name); fprintf (file, " DEF_%s_PIXEL_SIZE,\n", def_name); fprintf (file, " DEF_%s_SIZE\n};\n", def_name); fclose (file); return 0; }