Friday, March 25, 2022

Ultra light Linux = MiYO Linux distro

 https://sourceforge.net/projects/miyolinux/

https://gosamples.dev/read-file/#:~:text=The%20simplest%20way%20of%20reading,by%20line%20or%20in%20chunks.

https://stackoverflow.com/questions/37122401/execute-another-go-program-from-within-a-golang-program

https://zetcode.com/golang/exec-command/

https://gist.github.com/hyg/9c4afcd91fe24316cbf0

https://www.instructables.com/Complete-Guide-for-Tech-Beginners/


Working on Golang:

package main

import (
    "fmt"
    "log"
    "os/exec"
    "runtime"
)

func openbrowser(url string) {
    var err error

    switch runtime.GOOS {
    case "linux":
        err = exec.Command("xdg-open", url).Start()
    case "windows":
        err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
    case "darwin":
        err = exec.Command("open", url).Start()
    default:
        err = fmt.Errorf("unsupported platform")
    }
    if err != nil {
        log.Fatal(err)
    }

}

func main() {

    openbrowser("d:/go/dokument.htm")

}



Working on TCC:


#include <stdio.h>
#include <wchar.h>
#include <stdlib.h>
#include <locale.h>
int main ()
{
  setlocale(LC_ALL, "en_US.UTF-8");
  FILE * fin;
  FILE * fout;
  wint_t wc;
  fin=fopen ("in.txt","r");
  fout=fopen("out.txt","w");
  while((wc=fgetwc(fin))!=WEOF){
        // work with: "wc"
        putchar(wc);
        fprintf(fout,"%c",wc);
  }
  fclose(fin);
  fclose(fout);
  printf("File has been created...\n");
  return 0;
}

https://www.calculate-linux.org/


https://www.howtogeek.com/howto/windows-vista/enable-the-hidden-administrator-account-on-windows-vista/

??:



#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <wchar.h>

int main(void)
{
FILE *stream;
wchar_t wcs[100];

if (NULL == (stream = fopen("fgetws.dat", "r"))) {
printf("Unable to open: \"fgetws.dat\"\n");
exit(1);

}

errno = 0;
if (NULL == fgetws(wcs, 100, stream)) {
if (EILSEQ == errno) {
printf("An invalid wide character was encountered.\n");
exit(1);

}

else if (feof(stream))
printf("End of file reached.\n");
else
perror("Read error.\n");
}
printf("wcs = \"%ls\"\n", wcs);
fclose(stream);
return 0;

/************************************************************
Assuming the file fgetws.dat contains:
This test string should not return -1
The output should be similar to:
wcs = "This test string should not return -1"
************************************************************/

}


int sqlite3_exec16(
sqlite3 *db, /* The database on which the SQL executes */
const short *zSql, /* The SQL(16) to be executed */
sqlite3_callback16 xCallback, /* Invoke this callback routine */
void *pArg, /* First argument to xCallback() */
short **pzErrMsg /* Write error messages here */
){
int rc = SQLITE_OK;
const short *zLeftover;
sqlite3_stmt *pStmt = 0;
short **azCols = 0;

int nRetry = 0;
int nCallback;

if( zSql==0 ) return SQLITE_OK;
while( (rc==SQLITE_OK || (rc==SQLITE_SCHEMA && (++nRetry)<2)) && zSql[0]
){
int nCol;
short **azVals = 0;

pStmt = 0;
rc = sqlite3_prepare16_v2(db, zSql, -1, &pStmt, &zLeftover);
assert( rc==SQLITE_OK || pStmt==0 );
if( rc!=SQLITE_OK ){
continue;
}
if( !pStmt ){
/* this happens for a comment or white-space */
zSql = zLeftover;
continue;
}

nCallback = 0;

nCol = sqlite3_column_count(pStmt);
azCols = sqliteMalloc(2*nCol*sizeof(const short *) + 1);
if( azCols==0 ){
goto exec_out;
}

while( 1 ){
int i;
rc = sqlite3_step(pStmt);

/* Invoke the callback function if required */
if( xCallback && (SQLITE_ROW==rc ||
(SQLITE_DONE==rc && !nCallback && db->flags&SQLITE_NullCallback))
){
if( 0==nCallback ){
for(i=0; i<nCol; i++){
azCols[i] = (short *)sqlite3_column_name16(pStmt, i);
}
nCallback++;
}
if( rc==SQLITE_ROW ){
azVals = &azCols[nCol];
for(i=0; i<nCol; i++){
azVals[i] = (short *)sqlite3_column_text16(pStmt, i);
}
}
if( xCallback(pArg, nCol, azVals, azCols) ){
rc = SQLITE_ABORT;
goto exec_out;
}
}

if( rc!=SQLITE_ROW ){
rc = sqlite3_finalize(pStmt);
pStmt = 0;
if( rc!=SQLITE_SCHEMA ){
nRetry = 0;
zSql = zLeftover;
while( iswspace((unsigned char)zSql[0]) ) zSql++;
}
break;
}
}

sqliteFree(azCols);
azCols = 0;
}

exec_out:
if( pStmt ) sqlite3_finalize(pStmt);
if( azCols ) sqliteFree(azCols);

rc = sqlite3ApiExit(0, rc);
if( rc!=SQLITE_OK && rc==sqlite3_errcode(db) && pzErrMsg ){
*pzErrMsg = sqlite3_malloc(1+strlen(sqlite3_errmsg16(db)));
if( *pzErrMsg ){
strcpy(*pzErrMsg, sqlite3_errmsg16(db));
}
}else if( pzErrMsg ){
*pzErrMsg = 0;
}

assert( (rc&db->errMask)==rc );
return rc;
}




No comments:

Post a Comment

Коментар: