From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26836 invoked by alias); 12 Sep 2014 02:58:47 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 19065 Received: (qmail 4527 invoked from network); 12 Sep 2014 02:58:35 -0000 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,HTML_MESSAGE, RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:content-type; bh=gFJiVqMF9Uk3RtZ3tcFBmk26GksZ6EW0iA0MzZTffjk=; b=mr7XYBTBsnCEswtNbMWSF4iMEjzQfd5+mxb+MJ0Cbg9EOkfWWPnydASc+IsQXhq1uJ 4KlJSIRfxeqx7uObBLaQ5n1iEZU8MY4M9xoOAbKrSFsu9Vub/DmBVtBVaRKTOu9HkG+m LmGsX05rKOGvEOO4QflAPenP1cvM1T3CDS7I+Wz91BddLxBOs/HQTH6IuOKoqjvYMYVg Tb3xxQffHdlq5CxGjR+6TrfvCUISACVn64mPFArJxjWDntaXFJXjlwM4BKrzVc6ek+4M /dK6Mk7Hzqg7rhWdVITtVbsYryKPjcd1vyM8UHnmZLn9rf8qXqt+kVJ6/dAgDqUFUZXb kn+g== X-Gm-Message-State: ALoCoQmDCZD4N0ZUvukJRMusdCKTBxDp0eNXDhrDdggD0CUaMcHBzLa54RHE5/dhzh8+rqzNzCFR MIME-Version: 1.0 X-Received: by 10.52.52.136 with SMTP id t8mr3491162vdo.21.1410490709849; Thu, 11 Sep 2014 19:58:29 -0700 (PDT) In-Reply-To: <20140911213608.GA1029@gmx.de> References: <20140911213608.GA1029@gmx.de> Date: Thu, 11 Sep 2014 19:58:29 -0700 Message-ID: Subject: Re: Determining the length of "long"? From: Kurtis Rader To: dominik.vogt@gmx.de, Zsh Users Content-Type: multipart/alternative; boundary=089e0115f048b850920502d5751a --089e0115f048b850920502d5751a Content-Type: text/plain; charset=UTF-8 There may be a way but why? A command shell is the wrong tool for that task. You don't need to compile a C program to do this. If you have perl or python it's an almost trivial problem. For example, #!/usr/bin/env python import ctypes l = ctypes.c_long(0x12345) print(ctypes.sizeof(l)) b = ctypes.string_at(ctypes.addressof(l), ctypes.sizeof(l)) print(''.join('\\x{:02x}'.format(ord(x)) for x in b)) On Thu, Sep 11, 2014 at 2:36 PM, Dominik Vogt wrote: > Is there a way to determine the length of the C type long from > inside a zsh script (without using external programs, of course). > > As an alternative, is there a direct way to print out a "long" > integer value as binary bytes in host byte order? > > I.e. given a value, say 0x12345, I need to print that as > > \\x00\\x01\\x23\\x45 > > on a 32 bit platform, and as > > \\x00\\x00\\x00\\x00\\x00\\x01\\x23\\x45 > > on a 64 bit platform (possibly in reverse byte order, depending on > the hardware). > > Ciao > > Dominik ^_^ ^_^ > > -- > > Dominik Vogt > > > -- Kurtis Rader Caretaker of the exceptional canines Junior and Hank --089e0115f048b850920502d5751a--